Completed
Branch ENH/rss-feed-fix (319d50)
by
unknown
02:42 queued 30s
created
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4111 added lines, -4111 removed lines patch added patch discarded remove patch
@@ -18,4187 +18,4187 @@
 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 . ']' ] = $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 . ']' ] = $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'd 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, false);
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
-            false
1995
-        );
1996
-        // ENQUEUE ALL BASICS BY DEFAULT
1997
-        wp_enqueue_style('ee-admin-css');
1998
-        wp_enqueue_script('ee_admin_js');
1999
-        wp_enqueue_script('ee-accounting');
2000
-        wp_enqueue_script('jquery-validate');
2001
-        // taking care of metaboxes
2002
-        if (
2003
-            empty($this->_cpt_route)
2004
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
-        ) {
2006
-            wp_enqueue_script('dashboard');
2007
-        }
2008
-        // LOCALIZED DATA
2009
-        // localize script for ajax lazy loading
2010
-        $lazy_loader_container_ids = apply_filters(
2011
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
-            ['espresso_news_post_box_content']
2013
-        );
2014
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
-        // /**
2017
-        //  * help tour stuff
2018
-        //  */
2019
-        // if (! empty($this->_help_tour)) {
2020
-        //     // register the js for kicking things off
2021
-        //     wp_enqueue_script(
2022
-        //         'ee-help-tour',
2023
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
-        //         array('jquery-joyride'),
2025
-        //         EVENT_ESPRESSO_VERSION,
2026
-        //         true
2027
-        //     );
2028
-        //     $tours = array();
2029
-        //     // setup tours for the js tour object
2030
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2031
-        //         if ($tour instanceof EE_Help_Tour) {
2032
-        //             $tours[] = array(
2033
-        //                 'id'      => $tour->get_slug(),
2034
-        //                 'options' => $tour->get_options(),
2035
-        //             );
2036
-        //         }
2037
-        //     }
2038
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
-        // }
2041
-
2042
-        add_filter(
2043
-            'admin_body_class',
2044
-            function ($classes) {
2045
-                if (strpos($classes, 'espresso-admin') === false) {
2046
-                    $classes .= ' espresso-admin';
2047
-                }
2048
-                return $classes;
2049
-            }
2050
-        );
2051
-    }
2052
-
2053
-
2054
-    /**
2055
-     *        admin_footer_scripts_eei18n_js_strings
2056
-     *
2057
-     * @return        void
2058
-     */
2059
-    public function admin_footer_scripts_eei18n_js_strings()
2060
-    {
2061
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
-            __(
2064
-                '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!!!',
2065
-                'event_espresso'
2066
-            )
2067
-        );
2068
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
-    }
2107
-
2108
-
2109
-    /**
2110
-     *        load enhanced xdebug styles for ppl with failing eyesight
2111
-     *
2112
-     * @return        void
2113
-     */
2114
-    public function add_xdebug_style()
2115
-    {
2116
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
-    }
2118
-
2119
-
2120
-    /************************/
2121
-    /** LIST TABLE METHODS **/
2122
-    /************************/
2123
-    /**
2124
-     * this sets up the list table if the current view requires it.
2125
-     *
2126
-     * @return void
2127
-     * @throws EE_Error
2128
-     */
2129
-    protected function _set_list_table()
2130
-    {
2131
-        // first is this a list_table view?
2132
-        if (! isset($this->_route_config['list_table'])) {
2133
-            return;
2134
-        } //not a list_table view so get out.
2135
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2136
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
-            // user error msg
2139
-            $error_msg = esc_html__(
2140
-                'An error occurred. The requested list table views could not be found.',
2141
-                'event_espresso'
2142
-            );
2143
-            // developer error msg
2144
-            $error_msg .= '||'
2145
-                          . sprintf(
2146
-                              esc_html__(
2147
-                                  '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.',
2148
-                                  'event_espresso'
2149
-                              ),
2150
-                              $this->_req_action,
2151
-                              $list_table_view
2152
-                          );
2153
-            throw new EE_Error($error_msg);
2154
-        }
2155
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
-        $this->_views = apply_filters(
2157
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
-            $this->_views
2159
-        );
2160
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
-        $this->_set_list_table_view();
2163
-        $this->_set_list_table_object();
2164
-    }
2165
-
2166
-
2167
-    /**
2168
-     * set current view for List Table
2169
-     *
2170
-     * @return void
2171
-     */
2172
-    protected function _set_list_table_view()
2173
-    {
2174
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
-        $status = $this->request->getRequestParam('status', null, 'key');
2176
-        $this->_view = $status && array_key_exists($status, $this->_views)
2177
-            ? $status
2178
-            : $this->_view;
2179
-    }
2180
-
2181
-
2182
-    /**
2183
-     * _set_list_table_object
2184
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
-     *
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws InvalidArgumentException
2188
-     * @throws InvalidDataTypeException
2189
-     * @throws EE_Error
2190
-     * @throws InvalidInterfaceException
2191
-     */
2192
-    protected function _set_list_table_object()
2193
-    {
2194
-        if (isset($this->_route_config['list_table'])) {
2195
-            if (! class_exists($this->_route_config['list_table'])) {
2196
-                throw new EE_Error(
2197
-                    sprintf(
2198
-                        esc_html__(
2199
-                            '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.',
2200
-                            'event_espresso'
2201
-                        ),
2202
-                        $this->_route_config['list_table'],
2203
-                        get_class($this)
2204
-                    )
2205
-                );
2206
-            }
2207
-            $this->_list_table_object = $this->loader->getShared(
2208
-                $this->_route_config['list_table'],
2209
-                [$this]
2210
-            );
2211
-        }
2212
-    }
2213
-
2214
-
2215
-    /**
2216
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
-     *
2218
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
-     *                                                    urls.  The array should be indexed by the view it is being
2220
-     *                                                    added to.
2221
-     * @return array
2222
-     */
2223
-    public function get_list_table_view_RLs($extra_query_args = [])
2224
-    {
2225
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
-        if (empty($this->_views)) {
2227
-            $this->_views = [];
2228
-        }
2229
-        // cycle thru views
2230
-        foreach ($this->_views as $key => $view) {
2231
-            $query_args = [];
2232
-            // check for current view
2233
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
-            $query_args['action']                        = $this->_req_action;
2235
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
-            $query_args['status']                        = $view['slug'];
2237
-            // merge any other arguments sent in.
2238
-            if (isset($extra_query_args[ $view['slug'] ])) {
2239
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
-            }
2241
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
-        }
2243
-        return $this->_views;
2244
-    }
2245
-
2246
-
2247
-    /**
2248
-     * _entries_per_page_dropdown
2249
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
-     *
2251
-     * @param int $max_entries total number of rows in the table
2252
-     * @return string
2253
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
-     *         WP does it.
2255
-     */
2256
-    protected function _entries_per_page_dropdown($max_entries = 0)
2257
-    {
2258
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
-        $values   = [10, 25, 50, 100];
2260
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
-        if ($max_entries) {
2262
-            $values[] = $max_entries;
2263
-            sort($values);
2264
-        }
2265
-        $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'd 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, false);
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
+			false
1995
+		);
1996
+		// ENQUEUE ALL BASICS BY DEFAULT
1997
+		wp_enqueue_style('ee-admin-css');
1998
+		wp_enqueue_script('ee_admin_js');
1999
+		wp_enqueue_script('ee-accounting');
2000
+		wp_enqueue_script('jquery-validate');
2001
+		// taking care of metaboxes
2002
+		if (
2003
+			empty($this->_cpt_route)
2004
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
+		) {
2006
+			wp_enqueue_script('dashboard');
2007
+		}
2008
+		// LOCALIZED DATA
2009
+		// localize script for ajax lazy loading
2010
+		$lazy_loader_container_ids = apply_filters(
2011
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
+			['espresso_news_post_box_content']
2013
+		);
2014
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
+		// /**
2017
+		//  * help tour stuff
2018
+		//  */
2019
+		// if (! empty($this->_help_tour)) {
2020
+		//     // register the js for kicking things off
2021
+		//     wp_enqueue_script(
2022
+		//         'ee-help-tour',
2023
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
+		//         array('jquery-joyride'),
2025
+		//         EVENT_ESPRESSO_VERSION,
2026
+		//         true
2027
+		//     );
2028
+		//     $tours = array();
2029
+		//     // setup tours for the js tour object
2030
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2031
+		//         if ($tour instanceof EE_Help_Tour) {
2032
+		//             $tours[] = array(
2033
+		//                 'id'      => $tour->get_slug(),
2034
+		//                 'options' => $tour->get_options(),
2035
+		//             );
2036
+		//         }
2037
+		//     }
2038
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
+		// }
2041
+
2042
+		add_filter(
2043
+			'admin_body_class',
2044
+			function ($classes) {
2045
+				if (strpos($classes, 'espresso-admin') === false) {
2046
+					$classes .= ' espresso-admin';
2047
+				}
2048
+				return $classes;
2049
+			}
2050
+		);
2051
+	}
2052
+
2053
+
2054
+	/**
2055
+	 *        admin_footer_scripts_eei18n_js_strings
2056
+	 *
2057
+	 * @return        void
2058
+	 */
2059
+	public function admin_footer_scripts_eei18n_js_strings()
2060
+	{
2061
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
+			__(
2064
+				'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!!!',
2065
+				'event_espresso'
2066
+			)
2067
+		);
2068
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
+	}
2107
+
2108
+
2109
+	/**
2110
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2111
+	 *
2112
+	 * @return        void
2113
+	 */
2114
+	public function add_xdebug_style()
2115
+	{
2116
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
+	}
2118
+
2119
+
2120
+	/************************/
2121
+	/** LIST TABLE METHODS **/
2122
+	/************************/
2123
+	/**
2124
+	 * this sets up the list table if the current view requires it.
2125
+	 *
2126
+	 * @return void
2127
+	 * @throws EE_Error
2128
+	 */
2129
+	protected function _set_list_table()
2130
+	{
2131
+		// first is this a list_table view?
2132
+		if (! isset($this->_route_config['list_table'])) {
2133
+			return;
2134
+		} //not a list_table view so get out.
2135
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2136
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
+			// user error msg
2139
+			$error_msg = esc_html__(
2140
+				'An error occurred. The requested list table views could not be found.',
2141
+				'event_espresso'
2142
+			);
2143
+			// developer error msg
2144
+			$error_msg .= '||'
2145
+						  . sprintf(
2146
+							  esc_html__(
2147
+								  '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.',
2148
+								  'event_espresso'
2149
+							  ),
2150
+							  $this->_req_action,
2151
+							  $list_table_view
2152
+						  );
2153
+			throw new EE_Error($error_msg);
2154
+		}
2155
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
+		$this->_views = apply_filters(
2157
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
+			$this->_views
2159
+		);
2160
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
+		$this->_set_list_table_view();
2163
+		$this->_set_list_table_object();
2164
+	}
2165
+
2166
+
2167
+	/**
2168
+	 * set current view for List Table
2169
+	 *
2170
+	 * @return void
2171
+	 */
2172
+	protected function _set_list_table_view()
2173
+	{
2174
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
+		$status = $this->request->getRequestParam('status', null, 'key');
2176
+		$this->_view = $status && array_key_exists($status, $this->_views)
2177
+			? $status
2178
+			: $this->_view;
2179
+	}
2180
+
2181
+
2182
+	/**
2183
+	 * _set_list_table_object
2184
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
+	 *
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws InvalidArgumentException
2188
+	 * @throws InvalidDataTypeException
2189
+	 * @throws EE_Error
2190
+	 * @throws InvalidInterfaceException
2191
+	 */
2192
+	protected function _set_list_table_object()
2193
+	{
2194
+		if (isset($this->_route_config['list_table'])) {
2195
+			if (! class_exists($this->_route_config['list_table'])) {
2196
+				throw new EE_Error(
2197
+					sprintf(
2198
+						esc_html__(
2199
+							'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.',
2200
+							'event_espresso'
2201
+						),
2202
+						$this->_route_config['list_table'],
2203
+						get_class($this)
2204
+					)
2205
+				);
2206
+			}
2207
+			$this->_list_table_object = $this->loader->getShared(
2208
+				$this->_route_config['list_table'],
2209
+				[$this]
2210
+			);
2211
+		}
2212
+	}
2213
+
2214
+
2215
+	/**
2216
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
+	 *
2218
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
+	 *                                                    urls.  The array should be indexed by the view it is being
2220
+	 *                                                    added to.
2221
+	 * @return array
2222
+	 */
2223
+	public function get_list_table_view_RLs($extra_query_args = [])
2224
+	{
2225
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
+		if (empty($this->_views)) {
2227
+			$this->_views = [];
2228
+		}
2229
+		// cycle thru views
2230
+		foreach ($this->_views as $key => $view) {
2231
+			$query_args = [];
2232
+			// check for current view
2233
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
+			$query_args['action']                        = $this->_req_action;
2235
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
+			$query_args['status']                        = $view['slug'];
2237
+			// merge any other arguments sent in.
2238
+			if (isset($extra_query_args[ $view['slug'] ])) {
2239
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
+			}
2241
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
+		}
2243
+		return $this->_views;
2244
+	}
2245
+
2246
+
2247
+	/**
2248
+	 * _entries_per_page_dropdown
2249
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
+	 *
2251
+	 * @param int $max_entries total number of rows in the table
2252
+	 * @return string
2253
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
+	 *         WP does it.
2255
+	 */
2256
+	protected function _entries_per_page_dropdown($max_entries = 0)
2257
+	{
2258
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
+		$values   = [10, 25, 50, 100];
2260
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
+		if ($max_entries) {
2262
+			$values[] = $max_entries;
2263
+			sort($values);
2264
+		}
2265
+		$entries_per_page_dropdown = '
2266 2266
 			<div id="entries-per-page-dv" class="alignleft actions">
2267 2267
 				<label class="hide-if-no-js">
2268 2268
 					Show
2269 2269
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2270
-        foreach ($values as $value) {
2271
-            if ($value < $max_entries) {
2272
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
-                $entries_per_page_dropdown .= '
2270
+		foreach ($values as $value) {
2271
+			if ($value < $max_entries) {
2272
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
+				$entries_per_page_dropdown .= '
2274 2274
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2275
-            }
2276
-        }
2277
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
-        $entries_per_page_dropdown .= '
2275
+			}
2276
+		}
2277
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
+		$entries_per_page_dropdown .= '
2279 2279
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2280
-        $entries_per_page_dropdown .= '
2280
+		$entries_per_page_dropdown .= '
2281 2281
 					</select>
2282 2282
 					entries
2283 2283
 				</label>
2284 2284
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2285 2285
 			</div>
2286 2286
 		';
2287
-        return $entries_per_page_dropdown;
2288
-    }
2289
-
2290
-
2291
-    /**
2292
-     *        _set_search_attributes
2293
-     *
2294
-     * @return        void
2295
-     */
2296
-    public function _set_search_attributes()
2297
-    {
2298
-        $this->_template_args['search']['btn_label'] = sprintf(
2299
-            esc_html__('Search %s', 'event_espresso'),
2300
-            empty($this->_search_btn_label) ? $this->page_label
2301
-                : $this->_search_btn_label
2302
-        );
2303
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
-    }
2305
-
2306
-
2307
-
2308
-    /*** END LIST TABLE METHODS **/
2309
-
2310
-
2311
-    /**
2312
-     * _add_registered_metaboxes
2313
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
-     *
2315
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
-     * @return void
2317
-     * @throws EE_Error
2318
-     */
2319
-    private function _add_registered_meta_boxes()
2320
-    {
2321
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
-        // we only add meta boxes if the page_route calls for it
2323
-        if (
2324
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
-            && is_array(
2326
-                $this->_route_config['metaboxes']
2327
-            )
2328
-        ) {
2329
-            // this simply loops through the callbacks provided
2330
-            // and checks if there is a corresponding callback registered by the child
2331
-            // if there is then we go ahead and process the metabox loader.
2332
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
-                // first check for Closures
2334
-                if ($metabox_callback instanceof Closure) {
2335
-                    $result = $metabox_callback();
2336
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
-                } else {
2339
-                    $result = call_user_func([$this, &$metabox_callback]);
2340
-                }
2341
-                if ($result === false) {
2342
-                    // user error msg
2343
-                    $error_msg = esc_html__(
2344
-                        'An error occurred. The  requested metabox could not be found.',
2345
-                        'event_espresso'
2346
-                    );
2347
-                    // developer error msg
2348
-                    $error_msg .= '||'
2349
-                                  . sprintf(
2350
-                                      esc_html__(
2351
-                                          '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.',
2352
-                                          'event_espresso'
2353
-                                      ),
2354
-                                      $metabox_callback
2355
-                                  );
2356
-                    throw new EE_Error($error_msg);
2357
-                }
2358
-            }
2359
-        }
2360
-    }
2361
-
2362
-
2363
-    /**
2364
-     * _add_screen_columns
2365
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
-     * the dynamic column template and we'll setup the column options for the page.
2367
-     *
2368
-     * @return void
2369
-     */
2370
-    private function _add_screen_columns()
2371
-    {
2372
-        if (
2373
-            is_array($this->_route_config)
2374
-            && isset($this->_route_config['columns'])
2375
-            && is_array($this->_route_config['columns'])
2376
-            && count($this->_route_config['columns']) === 2
2377
-        ) {
2378
-            add_screen_option(
2379
-                'layout_columns',
2380
-                [
2381
-                    'max'     => (int) $this->_route_config['columns'][0],
2382
-                    'default' => (int) $this->_route_config['columns'][1],
2383
-                ]
2384
-            );
2385
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
-            $screen_id                                           = $this->_current_screen->id;
2387
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
-            $total_columns                                       = ! empty($screen_columns)
2389
-                ? $screen_columns
2390
-                : $this->_route_config['columns'][1];
2391
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2393
-            $this->_template_args['screen']                      = $this->_current_screen;
2394
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2396
-            // finally if we don't have has_metaboxes set in the route config
2397
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
-            $this->_route_config['has_metaboxes'] = true;
2399
-        }
2400
-    }
2401
-
2402
-
2403
-
2404
-    /** GLOBALLY AVAILABLE METABOXES **/
2405
-
2406
-
2407
-    /**
2408
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
-     * these get loaded on.
2411
-     */
2412
-    private function _espresso_news_post_box()
2413
-    {
2414
-        $news_box_title = apply_filters(
2415
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
-            esc_html__('New @ Event Espresso', 'event_espresso')
2417
-        );
2418
-        add_meta_box(
2419
-            'espresso_news_post_box',
2420
-            $news_box_title,
2421
-            [
2422
-                $this,
2423
-                'espresso_news_post_box',
2424
-            ],
2425
-            $this->_wp_page_slug,
2426
-            'side'
2427
-        );
2428
-    }
2429
-
2430
-
2431
-    /**
2432
-     * Code for setting up espresso ratings request metabox.
2433
-     */
2434
-    protected function _espresso_ratings_request()
2435
-    {
2436
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
-            return;
2438
-        }
2439
-        $ratings_box_title = apply_filters(
2440
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
-        );
2443
-        add_meta_box(
2444
-            'espresso_ratings_request',
2445
-            $ratings_box_title,
2446
-            [
2447
-                $this,
2448
-                'espresso_ratings_request',
2449
-            ],
2450
-            $this->_wp_page_slug,
2451
-            'side'
2452
-        );
2453
-    }
2454
-
2455
-
2456
-    /**
2457
-     * Code for setting up espresso ratings request metabox content.
2458
-     *
2459
-     * @throws DomainException
2460
-     */
2461
-    public function espresso_ratings_request()
2462
-    {
2463
-        EEH_Template::display_template(
2464
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
-            []
2466
-        );
2467
-    }
2468
-
2469
-
2470
-    public static function cached_rss_display($rss_id, $url)
2471
-    {
2472
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2473
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2474
-                     . '</p><p class="hide-if-js">'
2475
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
-                     . '</p>';
2477
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
-        $post      = '</div>' . "\n";
2480
-        $cache_key = 'ee_rss_' . md5($rss_id);
2481
-        $output    = get_transient($cache_key);
2482
-        if ($output !== false) {
2483
-            echo $pre . $output . $post; // already escaped
2484
-            return true;
2485
-        }
2486
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
-            echo $pre . $loading . $post; // already escaped
2488
-            return false;
2489
-        }
2490
-        ob_start();
2491
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
-        return true;
2494
-    }
2495
-
2496
-
2497
-    public function espresso_news_post_box()
2498
-    {
2499
-        ?>
2287
+		return $entries_per_page_dropdown;
2288
+	}
2289
+
2290
+
2291
+	/**
2292
+	 *        _set_search_attributes
2293
+	 *
2294
+	 * @return        void
2295
+	 */
2296
+	public function _set_search_attributes()
2297
+	{
2298
+		$this->_template_args['search']['btn_label'] = sprintf(
2299
+			esc_html__('Search %s', 'event_espresso'),
2300
+			empty($this->_search_btn_label) ? $this->page_label
2301
+				: $this->_search_btn_label
2302
+		);
2303
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
+	}
2305
+
2306
+
2307
+
2308
+	/*** END LIST TABLE METHODS **/
2309
+
2310
+
2311
+	/**
2312
+	 * _add_registered_metaboxes
2313
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
+	 *
2315
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
+	 * @return void
2317
+	 * @throws EE_Error
2318
+	 */
2319
+	private function _add_registered_meta_boxes()
2320
+	{
2321
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
+		// we only add meta boxes if the page_route calls for it
2323
+		if (
2324
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
+			&& is_array(
2326
+				$this->_route_config['metaboxes']
2327
+			)
2328
+		) {
2329
+			// this simply loops through the callbacks provided
2330
+			// and checks if there is a corresponding callback registered by the child
2331
+			// if there is then we go ahead and process the metabox loader.
2332
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
+				// first check for Closures
2334
+				if ($metabox_callback instanceof Closure) {
2335
+					$result = $metabox_callback();
2336
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
+				} else {
2339
+					$result = call_user_func([$this, &$metabox_callback]);
2340
+				}
2341
+				if ($result === false) {
2342
+					// user error msg
2343
+					$error_msg = esc_html__(
2344
+						'An error occurred. The  requested metabox could not be found.',
2345
+						'event_espresso'
2346
+					);
2347
+					// developer error msg
2348
+					$error_msg .= '||'
2349
+								  . sprintf(
2350
+									  esc_html__(
2351
+										  '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.',
2352
+										  'event_espresso'
2353
+									  ),
2354
+									  $metabox_callback
2355
+								  );
2356
+					throw new EE_Error($error_msg);
2357
+				}
2358
+			}
2359
+		}
2360
+	}
2361
+
2362
+
2363
+	/**
2364
+	 * _add_screen_columns
2365
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
+	 * the dynamic column template and we'll setup the column options for the page.
2367
+	 *
2368
+	 * @return void
2369
+	 */
2370
+	private function _add_screen_columns()
2371
+	{
2372
+		if (
2373
+			is_array($this->_route_config)
2374
+			&& isset($this->_route_config['columns'])
2375
+			&& is_array($this->_route_config['columns'])
2376
+			&& count($this->_route_config['columns']) === 2
2377
+		) {
2378
+			add_screen_option(
2379
+				'layout_columns',
2380
+				[
2381
+					'max'     => (int) $this->_route_config['columns'][0],
2382
+					'default' => (int) $this->_route_config['columns'][1],
2383
+				]
2384
+			);
2385
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
+			$screen_id                                           = $this->_current_screen->id;
2387
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
+			$total_columns                                       = ! empty($screen_columns)
2389
+				? $screen_columns
2390
+				: $this->_route_config['columns'][1];
2391
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2393
+			$this->_template_args['screen']                      = $this->_current_screen;
2394
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
+																   . 'admin_details_metabox_column_wrapper.template.php';
2396
+			// finally if we don't have has_metaboxes set in the route config
2397
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
+			$this->_route_config['has_metaboxes'] = true;
2399
+		}
2400
+	}
2401
+
2402
+
2403
+
2404
+	/** GLOBALLY AVAILABLE METABOXES **/
2405
+
2406
+
2407
+	/**
2408
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
+	 * these get loaded on.
2411
+	 */
2412
+	private function _espresso_news_post_box()
2413
+	{
2414
+		$news_box_title = apply_filters(
2415
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
+			esc_html__('New @ Event Espresso', 'event_espresso')
2417
+		);
2418
+		add_meta_box(
2419
+			'espresso_news_post_box',
2420
+			$news_box_title,
2421
+			[
2422
+				$this,
2423
+				'espresso_news_post_box',
2424
+			],
2425
+			$this->_wp_page_slug,
2426
+			'side'
2427
+		);
2428
+	}
2429
+
2430
+
2431
+	/**
2432
+	 * Code for setting up espresso ratings request metabox.
2433
+	 */
2434
+	protected function _espresso_ratings_request()
2435
+	{
2436
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
+			return;
2438
+		}
2439
+		$ratings_box_title = apply_filters(
2440
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
+		);
2443
+		add_meta_box(
2444
+			'espresso_ratings_request',
2445
+			$ratings_box_title,
2446
+			[
2447
+				$this,
2448
+				'espresso_ratings_request',
2449
+			],
2450
+			$this->_wp_page_slug,
2451
+			'side'
2452
+		);
2453
+	}
2454
+
2455
+
2456
+	/**
2457
+	 * Code for setting up espresso ratings request metabox content.
2458
+	 *
2459
+	 * @throws DomainException
2460
+	 */
2461
+	public function espresso_ratings_request()
2462
+	{
2463
+		EEH_Template::display_template(
2464
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
+			[]
2466
+		);
2467
+	}
2468
+
2469
+
2470
+	public static function cached_rss_display($rss_id, $url)
2471
+	{
2472
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2473
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2474
+					 . '</p><p class="hide-if-js">'
2475
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
+					 . '</p>';
2477
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
+		$post      = '</div>' . "\n";
2480
+		$cache_key = 'ee_rss_' . md5($rss_id);
2481
+		$output    = get_transient($cache_key);
2482
+		if ($output !== false) {
2483
+			echo $pre . $output . $post; // already escaped
2484
+			return true;
2485
+		}
2486
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
+			echo $pre . $loading . $post; // already escaped
2488
+			return false;
2489
+		}
2490
+		ob_start();
2491
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
+		return true;
2494
+	}
2495
+
2496
+
2497
+	public function espresso_news_post_box()
2498
+	{
2499
+		?>
2500 2500
         <div class="padding">
2501 2501
             <div id="espresso_news_post_box_content" class="infolinks">
2502 2502
                 <?php
2503
-                // Get RSS Feed(s)
2504
-                self::cached_rss_display(
2505
-                    'espresso_news_post_box_content',
2506
-                    esc_url_raw(
2507
-                        apply_filters(
2508
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
-                            'https://eventespresso.com/feed/'
2510
-                        )
2511
-                    )
2512
-                );
2513
-                ?>
2503
+				// Get RSS Feed(s)
2504
+				self::cached_rss_display(
2505
+					'espresso_news_post_box_content',
2506
+					esc_url_raw(
2507
+						apply_filters(
2508
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
+							'https://eventespresso.com/feed/'
2510
+						)
2511
+					)
2512
+				);
2513
+				?>
2514 2514
             </div>
2515 2515
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2516 2516
         </div>
2517 2517
         <?php
2518
-    }
2519
-
2520
-
2521
-    private function _espresso_links_post_box()
2522
-    {
2523
-        // Hiding until we actually have content to put in here...
2524
-        // 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');
2525
-    }
2526
-
2527
-
2528
-    public function espresso_links_post_box()
2529
-    {
2530
-        // Hiding until we actually have content to put in here...
2531
-        // EEH_Template::display_template(
2532
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
-        // );
2534
-    }
2535
-
2536
-
2537
-    protected function _espresso_sponsors_post_box()
2538
-    {
2539
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
-            add_meta_box(
2541
-                'espresso_sponsors_post_box',
2542
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
-                [$this, 'espresso_sponsors_post_box'],
2544
-                $this->_wp_page_slug,
2545
-                'side'
2546
-            );
2547
-        }
2548
-    }
2549
-
2550
-
2551
-    public function espresso_sponsors_post_box()
2552
-    {
2553
-        EEH_Template::display_template(
2554
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
-        );
2556
-    }
2557
-
2558
-
2559
-    private function _publish_post_box()
2560
-    {
2561
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
-        // then we'll use that for the metabox label.
2564
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
-        if (! empty($this->_labels['publishbox'])) {
2566
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
-                : $this->_labels['publishbox'];
2568
-        } else {
2569
-            $box_label = esc_html__('Publish', 'event_espresso');
2570
-        }
2571
-        $box_label = apply_filters(
2572
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
-            $box_label,
2574
-            $this->_req_action,
2575
-            $this
2576
-        );
2577
-        add_meta_box(
2578
-            $meta_box_ref,
2579
-            $box_label,
2580
-            [$this, 'editor_overview'],
2581
-            $this->_current_screen->id,
2582
-            'side',
2583
-            'high'
2584
-        );
2585
-    }
2586
-
2587
-
2588
-    public function editor_overview()
2589
-    {
2590
-        // if we have extra content set let's add it in if not make sure its empty
2591
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
-            ? $this->_template_args['publish_box_extra_content']
2593
-            : '';
2594
-        echo EEH_Template::display_template(
2595
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
-            $this->_template_args,
2597
-            true
2598
-        );
2599
-    }
2600
-
2601
-
2602
-    /** end of globally available metaboxes section **/
2603
-
2604
-
2605
-    /**
2606
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
-     * protected method.
2608
-     *
2609
-     * @param string $name
2610
-     * @param int    $id
2611
-     * @param bool   $delete
2612
-     * @param string $save_close_redirect_URL
2613
-     * @param bool   $both_btns
2614
-     * @throws EE_Error
2615
-     * @throws InvalidArgumentException
2616
-     * @throws InvalidDataTypeException
2617
-     * @throws InvalidInterfaceException
2618
-     * @see   $this->_set_publish_post_box_vars for param details
2619
-     * @since 4.6.0
2620
-     */
2621
-    public function set_publish_post_box_vars(
2622
-        $name = '',
2623
-        $id = 0,
2624
-        $delete = false,
2625
-        $save_close_redirect_URL = '',
2626
-        $both_btns = true
2627
-    ) {
2628
-        $this->_set_publish_post_box_vars(
2629
-            $name,
2630
-            $id,
2631
-            $delete,
2632
-            $save_close_redirect_URL,
2633
-            $both_btns
2634
-        );
2635
-    }
2636
-
2637
-
2638
-    /**
2639
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2641
-     * save, and save and close buttons to work properly, then you will want to include a
2642
-     * values for the name and id arguments.
2643
-     *
2644
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2645
-     * @param int     $id                         id attached to the item published
2646
-     * @param string  $delete                     page route callback for the delete action
2647
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
-     *                                            the Save button
2650
-     * @throws EE_Error
2651
-     * @throws InvalidArgumentException
2652
-     * @throws InvalidDataTypeException
2653
-     * @throws InvalidInterfaceException
2654
-     * @todo  Add in validation for name/id arguments.
2655
-     */
2656
-    protected function _set_publish_post_box_vars(
2657
-        $name = '',
2658
-        $id = 0,
2659
-        $delete = '',
2660
-        $save_close_redirect_URL = '',
2661
-        $both_btns = true
2662
-    ) {
2663
-        // if Save & Close, use a custom redirect URL or default to the main page?
2664
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
-            ? $save_close_redirect_URL
2666
-            : $this->_admin_base_url;
2667
-        // create the Save & Close and Save buttons
2668
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
-        // if we have extra content set let's add it in if not make sure its empty
2670
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
-            ? $this->_template_args['publish_box_extra_content']
2672
-            : '';
2673
-        if ($delete && ! empty($id)) {
2674
-            // make sure we have a default if just true is sent.
2675
-            $delete           = ! empty($delete) ? $delete : 'delete';
2676
-            $delete_link_args = [$name => $id];
2677
-            $delete           = $this->get_action_link_or_button(
2678
-                $delete,
2679
-                $delete,
2680
-                $delete_link_args,
2681
-                'submitdelete deletion',
2682
-                '',
2683
-                false
2684
-            );
2685
-        }
2686
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
-        if (! empty($name) && ! empty($id)) {
2688
-            $hidden_field_arr[ $name ] = [
2689
-                'type'  => 'hidden',
2690
-                'value' => $id,
2691
-            ];
2692
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
-        } else {
2694
-            $hf = '';
2695
-        }
2696
-        // add hidden field
2697
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
-            ? $hf[ $name ]['field']
2699
-            : $hf;
2700
-    }
2701
-
2702
-
2703
-    /**
2704
-     * displays an error message to ppl who have javascript disabled
2705
-     *
2706
-     * @return void
2707
-     */
2708
-    private function _display_no_javascript_warning()
2709
-    {
2710
-        ?>
2518
+	}
2519
+
2520
+
2521
+	private function _espresso_links_post_box()
2522
+	{
2523
+		// Hiding until we actually have content to put in here...
2524
+		// 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');
2525
+	}
2526
+
2527
+
2528
+	public function espresso_links_post_box()
2529
+	{
2530
+		// Hiding until we actually have content to put in here...
2531
+		// EEH_Template::display_template(
2532
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
+		// );
2534
+	}
2535
+
2536
+
2537
+	protected function _espresso_sponsors_post_box()
2538
+	{
2539
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
+			add_meta_box(
2541
+				'espresso_sponsors_post_box',
2542
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
+				[$this, 'espresso_sponsors_post_box'],
2544
+				$this->_wp_page_slug,
2545
+				'side'
2546
+			);
2547
+		}
2548
+	}
2549
+
2550
+
2551
+	public function espresso_sponsors_post_box()
2552
+	{
2553
+		EEH_Template::display_template(
2554
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
+		);
2556
+	}
2557
+
2558
+
2559
+	private function _publish_post_box()
2560
+	{
2561
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
+		// then we'll use that for the metabox label.
2564
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
+		if (! empty($this->_labels['publishbox'])) {
2566
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
+				: $this->_labels['publishbox'];
2568
+		} else {
2569
+			$box_label = esc_html__('Publish', 'event_espresso');
2570
+		}
2571
+		$box_label = apply_filters(
2572
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
+			$box_label,
2574
+			$this->_req_action,
2575
+			$this
2576
+		);
2577
+		add_meta_box(
2578
+			$meta_box_ref,
2579
+			$box_label,
2580
+			[$this, 'editor_overview'],
2581
+			$this->_current_screen->id,
2582
+			'side',
2583
+			'high'
2584
+		);
2585
+	}
2586
+
2587
+
2588
+	public function editor_overview()
2589
+	{
2590
+		// if we have extra content set let's add it in if not make sure its empty
2591
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
+			? $this->_template_args['publish_box_extra_content']
2593
+			: '';
2594
+		echo EEH_Template::display_template(
2595
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
+			$this->_template_args,
2597
+			true
2598
+		);
2599
+	}
2600
+
2601
+
2602
+	/** end of globally available metaboxes section **/
2603
+
2604
+
2605
+	/**
2606
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
+	 * protected method.
2608
+	 *
2609
+	 * @param string $name
2610
+	 * @param int    $id
2611
+	 * @param bool   $delete
2612
+	 * @param string $save_close_redirect_URL
2613
+	 * @param bool   $both_btns
2614
+	 * @throws EE_Error
2615
+	 * @throws InvalidArgumentException
2616
+	 * @throws InvalidDataTypeException
2617
+	 * @throws InvalidInterfaceException
2618
+	 * @see   $this->_set_publish_post_box_vars for param details
2619
+	 * @since 4.6.0
2620
+	 */
2621
+	public function set_publish_post_box_vars(
2622
+		$name = '',
2623
+		$id = 0,
2624
+		$delete = false,
2625
+		$save_close_redirect_URL = '',
2626
+		$both_btns = true
2627
+	) {
2628
+		$this->_set_publish_post_box_vars(
2629
+			$name,
2630
+			$id,
2631
+			$delete,
2632
+			$save_close_redirect_URL,
2633
+			$both_btns
2634
+		);
2635
+	}
2636
+
2637
+
2638
+	/**
2639
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2641
+	 * save, and save and close buttons to work properly, then you will want to include a
2642
+	 * values for the name and id arguments.
2643
+	 *
2644
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2645
+	 * @param int     $id                         id attached to the item published
2646
+	 * @param string  $delete                     page route callback for the delete action
2647
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
+	 *                                            the Save button
2650
+	 * @throws EE_Error
2651
+	 * @throws InvalidArgumentException
2652
+	 * @throws InvalidDataTypeException
2653
+	 * @throws InvalidInterfaceException
2654
+	 * @todo  Add in validation for name/id arguments.
2655
+	 */
2656
+	protected function _set_publish_post_box_vars(
2657
+		$name = '',
2658
+		$id = 0,
2659
+		$delete = '',
2660
+		$save_close_redirect_URL = '',
2661
+		$both_btns = true
2662
+	) {
2663
+		// if Save & Close, use a custom redirect URL or default to the main page?
2664
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
+			? $save_close_redirect_URL
2666
+			: $this->_admin_base_url;
2667
+		// create the Save & Close and Save buttons
2668
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
+		// if we have extra content set let's add it in if not make sure its empty
2670
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
+			? $this->_template_args['publish_box_extra_content']
2672
+			: '';
2673
+		if ($delete && ! empty($id)) {
2674
+			// make sure we have a default if just true is sent.
2675
+			$delete           = ! empty($delete) ? $delete : 'delete';
2676
+			$delete_link_args = [$name => $id];
2677
+			$delete           = $this->get_action_link_or_button(
2678
+				$delete,
2679
+				$delete,
2680
+				$delete_link_args,
2681
+				'submitdelete deletion',
2682
+				'',
2683
+				false
2684
+			);
2685
+		}
2686
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
+		if (! empty($name) && ! empty($id)) {
2688
+			$hidden_field_arr[ $name ] = [
2689
+				'type'  => 'hidden',
2690
+				'value' => $id,
2691
+			];
2692
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
+		} else {
2694
+			$hf = '';
2695
+		}
2696
+		// add hidden field
2697
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
+			? $hf[ $name ]['field']
2699
+			: $hf;
2700
+	}
2701
+
2702
+
2703
+	/**
2704
+	 * displays an error message to ppl who have javascript disabled
2705
+	 *
2706
+	 * @return void
2707
+	 */
2708
+	private function _display_no_javascript_warning()
2709
+	{
2710
+		?>
2711 2711
         <noscript>
2712 2712
             <div id="no-js-message" class="error">
2713 2713
                 <p style="font-size:1.3em;">
2714 2714
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2715 2715
                     <?php esc_html_e(
2716
-                        '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.',
2717
-                        'event_espresso'
2718
-                    ); ?>
2716
+						'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.',
2717
+						'event_espresso'
2718
+					); ?>
2719 2719
                 </p>
2720 2720
             </div>
2721 2721
         </noscript>
2722 2722
         <?php
2723
-    }
2724
-
2725
-
2726
-    /**
2727
-     * displays espresso success and/or error notices
2728
-     *
2729
-     * @return void
2730
-     */
2731
-    private function _display_espresso_notices()
2732
-    {
2733
-        $notices = $this->_get_transient(true);
2734
-        echo stripslashes($notices);
2735
-    }
2736
-
2737
-
2738
-    /**
2739
-     * spinny things pacify the masses
2740
-     *
2741
-     * @return void
2742
-     */
2743
-    protected function _add_admin_page_ajax_loading_img()
2744
-    {
2745
-        ?>
2723
+	}
2724
+
2725
+
2726
+	/**
2727
+	 * displays espresso success and/or error notices
2728
+	 *
2729
+	 * @return void
2730
+	 */
2731
+	private function _display_espresso_notices()
2732
+	{
2733
+		$notices = $this->_get_transient(true);
2734
+		echo stripslashes($notices);
2735
+	}
2736
+
2737
+
2738
+	/**
2739
+	 * spinny things pacify the masses
2740
+	 *
2741
+	 * @return void
2742
+	 */
2743
+	protected function _add_admin_page_ajax_loading_img()
2744
+	{
2745
+		?>
2746 2746
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2747 2747
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2748
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2748
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2749 2749
         </div>
2750 2750
         <?php
2751
-    }
2751
+	}
2752 2752
 
2753 2753
 
2754
-    /**
2755
-     * add admin page overlay for modal boxes
2756
-     *
2757
-     * @return void
2758
-     */
2759
-    protected function _add_admin_page_overlay()
2760
-    {
2761
-        ?>
2754
+	/**
2755
+	 * add admin page overlay for modal boxes
2756
+	 *
2757
+	 * @return void
2758
+	 */
2759
+	protected function _add_admin_page_overlay()
2760
+	{
2761
+		?>
2762 2762
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2763 2763
         <?php
2764
-    }
2765
-
2766
-
2767
-    /**
2768
-     * facade for add_meta_box
2769
-     *
2770
-     * @param string  $action        where the metabox get's displayed
2771
-     * @param string  $title         Title of Metabox (output in metabox header)
2772
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
-     *                               instead of the one created in here.
2774
-     * @param array   $callback_args an array of args supplied for the metabox
2775
-     * @param string  $column        what metabox column
2776
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
-     *                               created but just set our own callback for wp's add_meta_box.
2779
-     * @throws DomainException
2780
-     */
2781
-    public function _add_admin_page_meta_box(
2782
-        $action,
2783
-        $title,
2784
-        $callback,
2785
-        $callback_args,
2786
-        $column = 'normal',
2787
-        $priority = 'high',
2788
-        $create_func = true
2789
-    ) {
2790
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
-        // 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.
2792
-        if (empty($callback_args) && $create_func) {
2793
-            $callback_args = [
2794
-                'template_path' => $this->_template_path,
2795
-                'template_args' => $this->_template_args,
2796
-            ];
2797
-        }
2798
-        // 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)
2799
-        $call_back_func = $create_func
2800
-            ? function ($post, $metabox) {
2801
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
-                echo EEH_Template::display_template(
2803
-                    $metabox['args']['template_path'],
2804
-                    $metabox['args']['template_args'],
2805
-                    true
2806
-                );
2807
-            }
2808
-            : $callback;
2809
-        add_meta_box(
2810
-            str_replace('_', '-', $action) . '-mbox',
2811
-            $title,
2812
-            $call_back_func,
2813
-            $this->_wp_page_slug,
2814
-            $column,
2815
-            $priority,
2816
-            $callback_args
2817
-        );
2818
-    }
2819
-
2820
-
2821
-    /**
2822
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
-     *
2824
-     * @throws DomainException
2825
-     * @throws EE_Error
2826
-     */
2827
-    public function display_admin_page_with_metabox_columns()
2828
-    {
2829
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
-            $this->_column_template_path,
2832
-            $this->_template_args,
2833
-            true
2834
-        );
2835
-        // the final wrapper
2836
-        $this->admin_page_wrapper();
2837
-    }
2838
-
2839
-
2840
-    /**
2841
-     * generates  HTML wrapper for an admin details page
2842
-     *
2843
-     * @return void
2844
-     * @throws EE_Error
2845
-     * @throws DomainException
2846
-     */
2847
-    public function display_admin_page_with_sidebar()
2848
-    {
2849
-        $this->_display_admin_page(true);
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2855
-     *
2856
-     * @return void
2857
-     * @throws EE_Error
2858
-     * @throws DomainException
2859
-     */
2860
-    public function display_admin_page_with_no_sidebar()
2861
-    {
2862
-        $this->_display_admin_page();
2863
-    }
2864
-
2865
-
2866
-    /**
2867
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2868
-     *
2869
-     * @return void
2870
-     * @throws EE_Error
2871
-     * @throws DomainException
2872
-     */
2873
-    public function display_about_admin_page()
2874
-    {
2875
-        $this->_display_admin_page(false, true);
2876
-    }
2877
-
2878
-
2879
-    /**
2880
-     * display_admin_page
2881
-     * contains the code for actually displaying an admin page
2882
-     *
2883
-     * @param boolean $sidebar true with sidebar, false without
2884
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
-     * @return void
2886
-     * @throws DomainException
2887
-     * @throws EE_Error
2888
-     */
2889
-    private function _display_admin_page($sidebar = false, $about = false)
2890
-    {
2891
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2895
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2897
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
-            ? 'poststuff'
2899
-            : 'espresso-default-admin';
2900
-        $template_path                                     = $sidebar
2901
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
-        if ($this->request->isAjax()) {
2904
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
-        }
2906
-        $template_path                                     = ! empty($this->_column_template_path)
2907
-            ? $this->_column_template_path : $template_path;
2908
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
-            ? $this->_template_args['admin_page_content']
2910
-            : '';
2911
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
-            ? $this->_template_args['before_admin_page_content']
2913
-            : '';
2914
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
-            ? $this->_template_args['after_admin_page_content']
2916
-            : '';
2917
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
-            $template_path,
2919
-            $this->_template_args,
2920
-            true
2921
-        );
2922
-        // the final template wrapper
2923
-        $this->admin_page_wrapper($about);
2924
-    }
2925
-
2926
-
2927
-    /**
2928
-     * This is used to display caf preview pages.
2929
-     *
2930
-     * @param string $utm_campaign_source what is the key used for google analytics link
2931
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
-     * @return void
2934
-     * @throws DomainException
2935
-     * @throws EE_Error
2936
-     * @throws InvalidArgumentException
2937
-     * @throws InvalidDataTypeException
2938
-     * @throws InvalidInterfaceException
2939
-     * @since 4.3.2
2940
-     */
2941
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
-    {
2943
-        // let's generate a default preview action button if there isn't one already present.
2944
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2945
-            'Upgrade to Event Espresso 4 Right Now',
2946
-            'event_espresso'
2947
-        );
2948
-        $buy_now_url                                   = add_query_arg(
2949
-            [
2950
-                'ee_ver'       => 'ee4',
2951
-                'utm_source'   => 'ee4_plugin_admin',
2952
-                'utm_medium'   => 'link',
2953
-                'utm_campaign' => $utm_campaign_source,
2954
-                'utm_content'  => 'buy_now_button',
2955
-            ],
2956
-            'https://eventespresso.com/pricing/'
2957
-        );
2958
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
-            ? $this->get_action_link_or_button(
2960
-                '',
2961
-                'buy_now',
2962
-                [],
2963
-                'button-primary button-large',
2964
-                esc_url_raw($buy_now_url),
2965
-                true
2966
-            )
2967
-            : $this->_template_args['preview_action_button'];
2968
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
-            $this->_template_args,
2971
-            true
2972
-        );
2973
-        $this->_display_admin_page($display_sidebar);
2974
-    }
2975
-
2976
-
2977
-    /**
2978
-     * display_admin_list_table_page_with_sidebar
2979
-     * generates HTML wrapper for an admin_page with list_table
2980
-     *
2981
-     * @return void
2982
-     * @throws EE_Error
2983
-     * @throws DomainException
2984
-     */
2985
-    public function display_admin_list_table_page_with_sidebar()
2986
-    {
2987
-        $this->_display_admin_list_table_page(true);
2988
-    }
2989
-
2990
-
2991
-    /**
2992
-     * display_admin_list_table_page_with_no_sidebar
2993
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
-     *
2995
-     * @return void
2996
-     * @throws EE_Error
2997
-     * @throws DomainException
2998
-     */
2999
-    public function display_admin_list_table_page_with_no_sidebar()
3000
-    {
3001
-        $this->_display_admin_list_table_page();
3002
-    }
3003
-
3004
-
3005
-    /**
3006
-     * generates html wrapper for an admin_list_table page
3007
-     *
3008
-     * @param boolean $sidebar whether to display with sidebar or not.
3009
-     * @return void
3010
-     * @throws DomainException
3011
-     * @throws EE_Error
3012
-     */
3013
-    private function _display_admin_list_table_page($sidebar = false)
3014
-    {
3015
-        // setup search attributes
3016
-        $this->_set_search_attributes();
3017
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3018
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
-        $this->_template_args['table_url']        = $this->request->isAjax()
3020
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
-        $this->_template_args['list_table']       = $this->_list_table_object;
3023
-        $this->_template_args['current_route']    = $this->_req_action;
3024
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3027
-            $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                false,
3031
-                false
3032
-            );
3033
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
-                                                . $this->page_slug
3035
-                                                . '" />';
3036
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
-                                                . $ajax_sorting_callback
3038
-                                                . '" />';
3039
-        } else {
3040
-            $sortable_list_table_form_fields = '';
3041
-        }
3042
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
-        $hidden_form_fields                                      =
3044
-            isset($this->_template_args['list_table_hidden_fields'])
3045
-                ? $this->_template_args['list_table_hidden_fields']
3046
-                : '';
3047
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3048
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3049
-                                                                    . $nonce_ref
3050
-                                                                    . '" value="'
3051
-                                                                    . wp_create_nonce($nonce_ref)
3052
-                                                                    . '">';
3053
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
-        // display message about search results?
3055
-        $search = $this->request->getRequestParam('s');
3056
-        $this->_template_args['before_list_table'] .= ! empty($search)
3057
-            ? '<p class="ee-search-results">' . sprintf(
3058
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
-                trim($search, '%')
3060
-            ) . '</p>'
3061
-            : '';
3062
-        // filter before_list_table template arg
3063
-        $this->_template_args['before_list_table'] = apply_filters(
3064
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
-            $this->_template_args['before_list_table'],
3066
-            $this->page_slug,
3067
-            $this->request->requestParams(),
3068
-            $this->_req_action
3069
-        );
3070
-        // convert to array and filter again
3071
-        // arrays are easier to inject new items in a specific location,
3072
-        // but would not be backwards compatible, so we have to add a new filter
3073
-        $this->_template_args['before_list_table'] = implode(
3074
-            " \n",
3075
-            (array) apply_filters(
3076
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
-                (array) $this->_template_args['before_list_table'],
3078
-                $this->page_slug,
3079
-                $this->request->requestParams(),
3080
-                $this->_req_action
3081
-            )
3082
-        );
3083
-        // filter after_list_table template arg
3084
-        $this->_template_args['after_list_table'] = apply_filters(
3085
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
-            $this->_template_args['after_list_table'],
3087
-            $this->page_slug,
3088
-            $this->request->requestParams(),
3089
-            $this->_req_action
3090
-        );
3091
-        // convert to array and filter again
3092
-        // arrays are easier to inject new items in a specific location,
3093
-        // but would not be backwards compatible, so we have to add a new filter
3094
-        $this->_template_args['after_list_table']   = implode(
3095
-            " \n",
3096
-            (array) apply_filters(
3097
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
-                (array) $this->_template_args['after_list_table'],
3099
-                $this->page_slug,
3100
-                $this->request->requestParams(),
3101
-                $this->_req_action
3102
-            )
3103
-        );
3104
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
-            $template_path,
3106
-            $this->_template_args,
3107
-            true
3108
-        );
3109
-        // the final template wrapper
3110
-        if ($sidebar) {
3111
-            $this->display_admin_page_with_sidebar();
3112
-        } else {
3113
-            $this->display_admin_page_with_no_sidebar();
3114
-        }
3115
-    }
3116
-
3117
-
3118
-    /**
3119
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
-     * html string for the legend.
3121
-     * $items are expected in an array in the following format:
3122
-     * $legend_items = array(
3123
-     *        'item_id' => array(
3124
-     *            'icon' => 'http://url_to_icon_being_described.png',
3125
-     *            'desc' => esc_html__('localized description of item');
3126
-     *        )
3127
-     * );
3128
-     *
3129
-     * @param array $items see above for format of array
3130
-     * @return string html string of legend
3131
-     * @throws DomainException
3132
-     */
3133
-    protected function _display_legend($items)
3134
-    {
3135
-        $this->_template_args['items'] = apply_filters(
3136
-            'FHEE__EE_Admin_Page___display_legend__items',
3137
-            (array) $items,
3138
-            $this
3139
-        );
3140
-        return EEH_Template::display_template(
3141
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
-            $this->_template_args,
3143
-            true
3144
-        );
3145
-    }
3146
-
3147
-
3148
-    /**
3149
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
-     * The returned json object is created from an array in the following format:
3151
-     * array(
3152
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
-     *  'notices' => '', // - contains any EE_Error formatted notices
3155
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
-     *  that might be included in here)
3159
-     * )
3160
-     * The json object is populated by whatever is set in the $_template_args property.
3161
-     *
3162
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
-     *                                 instead of displayed.
3164
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
-     * @return void
3166
-     * @throws EE_Error
3167
-     */
3168
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
-    {
3170
-        // make sure any EE_Error notices have been handled.
3171
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3172
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
-        unset($this->_template_args['data']);
3174
-        $json = [
3175
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
-            'notices'   => EE_Error::get_notices(),
3180
-            'content'   => isset($this->_template_args['admin_page_content'])
3181
-                ? $this->_template_args['admin_page_content'] : '',
3182
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
-            'isEEajax'  => true
3184
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
-        ];
3186
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
-        if (null === error_get_last() || ! headers_sent()) {
3188
-            header('Content-Type: application/json; charset=UTF-8');
3189
-        }
3190
-        echo wp_json_encode($json);
3191
-        exit();
3192
-    }
3193
-
3194
-
3195
-    /**
3196
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
-     *
3198
-     * @return void
3199
-     * @throws EE_Error
3200
-     */
3201
-    public function return_json()
3202
-    {
3203
-        if ($this->request->isAjax()) {
3204
-            $this->_return_json();
3205
-        } else {
3206
-            throw new EE_Error(
3207
-                sprintf(
3208
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
-                    __FUNCTION__
3210
-                )
3211
-            );
3212
-        }
3213
-    }
3214
-
3215
-
3216
-    /**
3217
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
-     *
3220
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
-     */
3222
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
-    {
3224
-        $this->_hook_obj = $hook_obj;
3225
-    }
3226
-
3227
-
3228
-    /**
3229
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3230
-     *
3231
-     * @param boolean $about whether to use the special about page wrapper or default.
3232
-     * @return void
3233
-     * @throws DomainException
3234
-     * @throws EE_Error
3235
-     */
3236
-    public function admin_page_wrapper($about = false)
3237
-    {
3238
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
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
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3249
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
-            isset($this->_template_args['after_admin_page_content'])
3251
-                ? $this->_template_args['after_admin_page_content']
3252
-                : ''
3253
-        );
3254
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
-        // load settings page wrapper template
3256
-        $template_path = ! $this->request->isAjax()
3257
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
-        // about page?
3260
-        $template_path = $about
3261
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
-            : $template_path;
3263
-        if ($this->request->isAjax()) {
3264
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
-                $template_path,
3266
-                $this->_template_args,
3267
-                true
3268
-            );
3269
-            $this->_return_json();
3270
-        } else {
3271
-            EEH_Template::display_template($template_path, $this->_template_args);
3272
-        }
3273
-    }
3274
-
3275
-
3276
-    /**
3277
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
-     *
3279
-     * @return string html
3280
-     * @throws EE_Error
3281
-     */
3282
-    protected function _get_main_nav_tabs()
3283
-    {
3284
-        // let's generate the html using the EEH_Tabbed_Content helper.
3285
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
-        // (rather than setting in the page_routes array)
3287
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *        sort nav tabs
3293
-     *
3294
-     * @param $a
3295
-     * @param $b
3296
-     * @return int
3297
-     */
3298
-    private function _sort_nav_tabs($a, $b)
3299
-    {
3300
-        if ($a['order'] === $b['order']) {
3301
-            return 0;
3302
-        }
3303
-        return ($a['order'] < $b['order']) ? -1 : 1;
3304
-    }
3305
-
3306
-
3307
-    /**
3308
-     *    generates HTML for the forms used on admin pages
3309
-     *
3310
-     * @param array  $input_vars   - array of input field details
3311
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
-     *                             use)
3313
-     * @param bool   $id
3314
-     * @return string
3315
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
-     */
3318
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
-    {
3320
-        return $generator === 'string'
3321
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3323
-    }
3324
-
3325
-
3326
-    /**
3327
-     * generates the "Save" and "Save & Close" buttons for edit forms
3328
-     *
3329
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
-     *                                   Close" button.
3331
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
-     *                                   'Save', [1] => 'save & close')
3333
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
-     *                                   via the "name" value in the button).  We can also use this to just dump
3335
-     *                                   default actions by submitting some other value.
3336
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
-     *                                   close (normal form handling).
3339
-     */
3340
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
-    {
3342
-        // make sure $text and $actions are in an array
3343
-        $text          = (array) $text;
3344
-        $actions       = (array) $actions;
3345
-        $referrer_url  = empty($referrer)
3346
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
-              . $this->request->getServerParam('REQUEST_URI')
3348
-              . '" />'
3349
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
-              . $referrer
3351
-              . '" />';
3352
-        $button_text   = ! empty($text)
3353
-            ? $text
3354
-            : [
3355
-                esc_html__('Save', 'event_espresso'),
3356
-                esc_html__('Save and Close', 'event_espresso'),
3357
-            ];
3358
-        $default_names = ['save', 'save_and_close'];
3359
-        // add in a hidden index for the current page (so save and close redirects properly)
3360
-        $this->_template_args['save_buttons'] = $referrer_url;
3361
-        foreach ($button_text as $key => $button) {
3362
-            $ref                                  = $default_names[ $key ];
3363
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
-                                                     . $ref
3365
-                                                     . '" value="'
3366
-                                                     . $button
3367
-                                                     . '" name="'
3368
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3369
-                                                     . '" id="'
3370
-                                                     . $this->_current_view . '_' . $ref
3371
-                                                     . '" />';
3372
-            if (! $both) {
3373
-                break;
3374
-            }
3375
-        }
3376
-    }
3377
-
3378
-
3379
-    /**
3380
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
-     *
3382
-     * @param string $route
3383
-     * @param array  $additional_hidden_fields
3384
-     * @see   $this->_set_add_edit_form_tags() for details on params
3385
-     * @since 4.6.0
3386
-     */
3387
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
-    {
3389
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
-    }
3391
-
3392
-
3393
-    /**
3394
-     * set form open and close tags on add/edit pages.
3395
-     *
3396
-     * @param string $route                    the route you want the form to direct to
3397
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
-     * @return void
3399
-     */
3400
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
-    {
3402
-        if (empty($route)) {
3403
-            $user_msg = esc_html__(
3404
-                'An error occurred. No action was set for this page\'s form.',
3405
-                'event_espresso'
3406
-            );
3407
-            $dev_msg  = $user_msg . "\n"
3408
-                        . sprintf(
3409
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
-                            __FUNCTION__,
3411
-                            __CLASS__
3412
-                        );
3413
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
-        }
3415
-        // open form
3416
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
-                                                             . $this->_admin_base_url
3418
-                                                             . '" id="'
3419
-                                                             . $route
3420
-                                                             . '_event_form" >';
3421
-        // add nonce
3422
-        $nonce                                             =
3423
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
-        // add REQUIRED form action
3426
-        $hidden_fields = [
3427
-            'action' => ['type' => 'hidden', 'value' => $route],
3428
-        ];
3429
-        // merge arrays
3430
-        $hidden_fields = is_array($additional_hidden_fields)
3431
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3432
-            : $hidden_fields;
3433
-        // generate form fields
3434
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
-        // add fields to form
3436
-        foreach ((array) $form_fields as $field_name => $form_field) {
3437
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
-        }
3439
-        // close form
3440
-        $this->_template_args['after_admin_page_content'] = '</form>';
3441
-    }
3442
-
3443
-
3444
-    /**
3445
-     * Public Wrapper for _redirect_after_action() method since its
3446
-     * discovered it would be useful for external code to have access.
3447
-     *
3448
-     * @param bool   $success
3449
-     * @param string $what
3450
-     * @param string $action_desc
3451
-     * @param array  $query_args
3452
-     * @param bool   $override_overwrite
3453
-     * @throws EE_Error
3454
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
-     * @since 4.5.0
3456
-     */
3457
-    public function redirect_after_action(
3458
-        $success = false,
3459
-        $what = 'item',
3460
-        $action_desc = 'processed',
3461
-        $query_args = [],
3462
-        $override_overwrite = false
3463
-    ) {
3464
-        $this->_redirect_after_action(
3465
-            $success,
3466
-            $what,
3467
-            $action_desc,
3468
-            $query_args,
3469
-            $override_overwrite
3470
-        );
3471
-    }
3472
-
3473
-
3474
-    /**
3475
-     * Helper method for merging existing request data with the returned redirect url.
3476
-     *
3477
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
-     * filters are still applied.
3479
-     *
3480
-     * @param array $new_route_data
3481
-     * @return array
3482
-     */
3483
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
-    {
3485
-        foreach ($this->request->requestParams() as $ref => $value) {
3486
-            // unset nonces
3487
-            if (strpos($ref, 'nonce') !== false) {
3488
-                $this->request->unSetRequestParam($ref);
3489
-                continue;
3490
-            }
3491
-            // urlencode values.
3492
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
-            $this->request->setRequestParam($ref, $value);
3494
-        }
3495
-        return array_merge($this->request->requestParams(), $new_route_data);
3496
-    }
3497
-
3498
-
3499
-    /**
3500
-     *    _redirect_after_action
3501
-     *
3502
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3503
-     * @param string $what               - what the action was performed on
3504
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
-     *                                   action is completed
3507
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
-     *                                   override this so that they show.
3509
-     * @return void
3510
-     * @throws EE_Error
3511
-     */
3512
-    protected function _redirect_after_action(
3513
-        $success = 0,
3514
-        $what = 'item',
3515
-        $action_desc = 'processed',
3516
-        $query_args = [],
3517
-        $override_overwrite = false
3518
-    ) {
3519
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
-        // class name for actions/filters.
3521
-        $classname = get_class($this);
3522
-        // set redirect url.
3523
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
-        // otherwise we go with whatever is set as the _admin_base_url
3525
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
-        $notices      = EE_Error::get_notices(false);
3527
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3528
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3529
-            EE_Error::overwrite_success();
3530
-        }
3531
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
-            // how many records affected ? more than one record ? or just one ?
3533
-            if ($success > 1) {
3534
-                // set plural msg
3535
-                EE_Error::add_success(
3536
-                    sprintf(
3537
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
-                        $what,
3539
-                        $action_desc
3540
-                    ),
3541
-                    __FILE__,
3542
-                    __FUNCTION__,
3543
-                    __LINE__
3544
-                );
3545
-            } elseif ($success === 1) {
3546
-                // set singular msg
3547
-                EE_Error::add_success(
3548
-                    sprintf(
3549
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
-                        $what,
3551
-                        $action_desc
3552
-                    ),
3553
-                    __FILE__,
3554
-                    __FUNCTION__,
3555
-                    __LINE__
3556
-                );
3557
-            }
3558
-        }
3559
-        // check that $query_args isn't something crazy
3560
-        if (! is_array($query_args)) {
3561
-            $query_args = [];
3562
-        }
3563
-        /**
3564
-         * Allow injecting actions before the query_args are modified for possible different
3565
-         * redirections on save and close actions
3566
-         *
3567
-         * @param array $query_args       The original query_args array coming into the
3568
-         *                                method.
3569
-         * @since 4.2.0
3570
-         */
3571
-        do_action(
3572
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
-            $query_args
3574
-        );
3575
-        // calculate where we're going (if we have a "save and close" button pushed)
3576
-
3577
-        if (
3578
-            $this->request->requestParamIsSet('save_and_close')
3579
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3580
-        ) {
3581
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
-            // regenerate query args array from referrer URL
3584
-            parse_str($parsed_url['query'], $query_args);
3585
-            // correct page and action will be in the query args now
3586
-            $redirect_url = admin_url('admin.php');
3587
-        }
3588
-        // merge any default query_args set in _default_route_query_args property
3589
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
-            $args_to_merge = [];
3591
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
-                // is there a wp_referer array in our _default_route_query_args property?
3593
-                if ($query_param === 'wp_referer') {
3594
-                    $query_value = (array) $query_value;
3595
-                    foreach ($query_value as $reference => $value) {
3596
-                        if (strpos($reference, 'nonce') !== false) {
3597
-                            continue;
3598
-                        }
3599
-                        // finally we will override any arguments in the referer with
3600
-                        // what might be set on the _default_route_query_args array.
3601
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3602
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
-                        } else {
3604
-                            $args_to_merge[ $reference ] = urlencode($value);
3605
-                        }
3606
-                    }
3607
-                    continue;
3608
-                }
3609
-                $args_to_merge[ $query_param ] = $query_value;
3610
-            }
3611
-            // now let's merge these arguments but override with what was specifically sent in to the
3612
-            // redirect.
3613
-            $query_args = array_merge($args_to_merge, $query_args);
3614
-        }
3615
-        $this->_process_notices($query_args);
3616
-        // generate redirect url
3617
-        // if redirecting to anything other than the main page, add a nonce
3618
-        if (isset($query_args['action'])) {
3619
-            // manually generate wp_nonce and merge that with the query vars
3620
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3621
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
-        }
3623
-        // we're adding some hooks and filters in here for processing any things just before redirects
3624
-        // (example: an admin page has done an insert or update and we want to run something after that).
3625
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
-        $redirect_url = apply_filters(
3627
-            'FHEE_redirect_' . $classname . $this->_req_action,
3628
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3629
-            $query_args
3630
-        );
3631
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
-        if ($this->request->isAjax()) {
3633
-            $default_data                    = [
3634
-                'close'        => true,
3635
-                'redirect_url' => $redirect_url,
3636
-                'where'        => 'main',
3637
-                'what'         => 'append',
3638
-            ];
3639
-            $this->_template_args['success'] = $success;
3640
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
-                $default_data,
3642
-                $this->_template_args['data']
3643
-            ) : $default_data;
3644
-            $this->_return_json();
3645
-        }
3646
-        wp_safe_redirect($redirect_url);
3647
-        exit();
3648
-    }
3649
-
3650
-
3651
-    /**
3652
-     * process any notices before redirecting (or returning ajax request)
3653
-     * This method sets the $this->_template_args['notices'] attribute;
3654
-     *
3655
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
-     *                                  page_routes haven't been defined yet.
3658
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
-     *                                  still save a transient for the notice.
3660
-     * @return void
3661
-     * @throws EE_Error
3662
-     */
3663
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
-    {
3665
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
-        if ($this->request->isAjax()) {
3667
-            $notices = EE_Error::get_notices(false);
3668
-            if (empty($this->_template_args['success'])) {
3669
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
-            }
3671
-            if (empty($this->_template_args['errors'])) {
3672
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
-            }
3674
-            if (empty($this->_template_args['attention'])) {
3675
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
-            }
3677
-        }
3678
-        $this->_template_args['notices'] = EE_Error::get_notices();
3679
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
-        if (! $this->request->isAjax() || $sticky_notices) {
3681
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
-            $this->_add_transient(
3683
-                $route,
3684
-                $this->_template_args['notices'],
3685
-                true,
3686
-                $skip_route_verify
3687
-            );
3688
-        }
3689
-    }
3690
-
3691
-
3692
-    /**
3693
-     * get_action_link_or_button
3694
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
-     *
3696
-     * @param string $action        use this to indicate which action the url is generated with.
3697
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
-     *                              property.
3699
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
-     * @param string $base_url      If this is not provided
3702
-     *                              the _admin_base_url will be used as the default for the button base_url.
3703
-     *                              Otherwise this value will be used.
3704
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
-     * @return string
3706
-     * @throws InvalidArgumentException
3707
-     * @throws InvalidInterfaceException
3708
-     * @throws InvalidDataTypeException
3709
-     * @throws EE_Error
3710
-     */
3711
-    public function get_action_link_or_button(
3712
-        $action,
3713
-        $type = 'add',
3714
-        $extra_request = [],
3715
-        $class = 'button-primary',
3716
-        $base_url = '',
3717
-        $exclude_nonce = false
3718
-    ) {
3719
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
-            throw new EE_Error(
3722
-                sprintf(
3723
-                    esc_html__(
3724
-                        'There is no page route for given action for the button.  This action was given: %s',
3725
-                        'event_espresso'
3726
-                    ),
3727
-                    $action
3728
-                )
3729
-            );
3730
-        }
3731
-        if (! isset($this->_labels['buttons'][ $type ])) {
3732
-            throw new EE_Error(
3733
-                sprintf(
3734
-                    esc_html__(
3735
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
-                        'event_espresso'
3737
-                    ),
3738
-                    $type
3739
-                )
3740
-            );
3741
-        }
3742
-        // finally check user access for this button.
3743
-        $has_access = $this->check_user_access($action, true);
3744
-        if (! $has_access) {
3745
-            return '';
3746
-        }
3747
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
-        $query_args = [
3749
-            'action' => $action,
3750
-        ];
3751
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
-        if (! empty($extra_request)) {
3753
-            $query_args = array_merge($extra_request, $query_args);
3754
-        }
3755
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
-    }
3758
-
3759
-
3760
-    /**
3761
-     * _per_page_screen_option
3762
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
-     *
3764
-     * @return void
3765
-     * @throws InvalidArgumentException
3766
-     * @throws InvalidInterfaceException
3767
-     * @throws InvalidDataTypeException
3768
-     */
3769
-    protected function _per_page_screen_option()
3770
-    {
3771
-        $option = 'per_page';
3772
-        $args   = [
3773
-            'label'   => apply_filters(
3774
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
-                $this->_admin_page_title,
3776
-                $this
3777
-            ),
3778
-            'default' => (int) apply_filters(
3779
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
-                20
3781
-            ),
3782
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
-        ];
3784
-        // ONLY add the screen option if the user has access to it.
3785
-        if ($this->check_user_access($this->_current_view, true)) {
3786
-            add_screen_option($option, $args);
3787
-        }
3788
-    }
3789
-
3790
-
3791
-    /**
3792
-     * set_per_page_screen_option
3793
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
-     * admin_menu.
3796
-     *
3797
-     * @return void
3798
-     */
3799
-    private function _set_per_page_screen_options()
3800
-    {
3801
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
-            if (! $user = wp_get_current_user()) {
3804
-                return;
3805
-            }
3806
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
-            if (! $option) {
3808
-                return;
3809
-            }
3810
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
-            $map_option = $option;
3812
-            $option     = str_replace('-', '_', $option);
3813
-            switch ($map_option) {
3814
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
-                    $max_value = apply_filters(
3816
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
-                        999,
3818
-                        $this->_current_page,
3819
-                        $this->_current_view
3820
-                    );
3821
-                    if ($value < 1) {
3822
-                        return;
3823
-                    }
3824
-                    $value = min($value, $max_value);
3825
-                    break;
3826
-                default:
3827
-                    $value = apply_filters(
3828
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
-                        false,
3830
-                        $option,
3831
-                        $value
3832
-                    );
3833
-                    if (false === $value) {
3834
-                        return;
3835
-                    }
3836
-                    break;
3837
-            }
3838
-            update_user_meta($user->ID, $option, $value);
3839
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
-            exit;
3841
-        }
3842
-    }
3843
-
3844
-
3845
-    /**
3846
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
-     *
3848
-     * @param array $data array that will be assigned to template args.
3849
-     */
3850
-    public function set_template_args($data)
3851
-    {
3852
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3853
-    }
3854
-
3855
-
3856
-    /**
3857
-     * This makes available the WP transient system for temporarily moving data between routes
3858
-     *
3859
-     * @param string $route             the route that should receive the transient
3860
-     * @param array  $data              the data that gets sent
3861
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
-     *                                  normal route transient.
3863
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
-     *                                  when we are adding a transient before page_routes have been defined.
3865
-     * @return void
3866
-     * @throws EE_Error
3867
-     */
3868
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
-    {
3870
-        $user_id = get_current_user_id();
3871
-        if (! $skip_route_verify) {
3872
-            $this->_verify_route($route);
3873
-        }
3874
-        // now let's set the string for what kind of transient we're setting
3875
-        $transient = $notices
3876
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
-            : 'rte_tx_' . $route . '_' . $user_id;
3878
-        $data      = $notices ? ['notices' => $data] : $data;
3879
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3880
-        $existing = is_multisite() && is_network_admin()
3881
-            ? get_site_transient($transient)
3882
-            : get_transient($transient);
3883
-        if ($existing) {
3884
-            $data = array_merge((array) $data, (array) $existing);
3885
-        }
3886
-        if (is_multisite() && is_network_admin()) {
3887
-            set_site_transient($transient, $data, 8);
3888
-        } else {
3889
-            set_transient($transient, $data, 8);
3890
-        }
3891
-    }
3892
-
3893
-
3894
-    /**
3895
-     * this retrieves the temporary transient that has been set for moving data between routes.
3896
-     *
3897
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
-     * @param string $route
3899
-     * @return mixed data
3900
-     */
3901
-    protected function _get_transient($notices = false, $route = '')
3902
-    {
3903
-        $user_id   = get_current_user_id();
3904
-        $route     = ! $route ? $this->_req_action : $route;
3905
-        $transient = $notices
3906
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
-            : 'rte_tx_' . $route . '_' . $user_id;
3908
-        $data      = is_multisite() && is_network_admin()
3909
-            ? get_site_transient($transient)
3910
-            : get_transient($transient);
3911
-        // delete transient after retrieval (just in case it hasn't expired);
3912
-        if (is_multisite() && is_network_admin()) {
3913
-            delete_site_transient($transient);
3914
-        } else {
3915
-            delete_transient($transient);
3916
-        }
3917
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
-     * default route callback on the EE_Admin page you want it run.)
3925
-     *
3926
-     * @return void
3927
-     */
3928
-    protected function _transient_garbage_collection()
3929
-    {
3930
-        global $wpdb;
3931
-        // retrieve all existing transients
3932
-        $query =
3933
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
-        if ($results = $wpdb->get_results($query)) {
3935
-            foreach ($results as $result) {
3936
-                $transient = str_replace('_transient_', '', $result->option_name);
3937
-                get_transient($transient);
3938
-                if (is_multisite() && is_network_admin()) {
3939
-                    get_site_transient($transient);
3940
-                }
3941
-            }
3942
-        }
3943
-    }
3944
-
3945
-
3946
-    /**
3947
-     * get_view
3948
-     *
3949
-     * @return string content of _view property
3950
-     */
3951
-    public function get_view()
3952
-    {
3953
-        return $this->_view;
3954
-    }
3955
-
3956
-
3957
-    /**
3958
-     * getter for the protected $_views property
3959
-     *
3960
-     * @return array
3961
-     */
3962
-    public function get_views()
3963
-    {
3964
-        return $this->_views;
3965
-    }
3966
-
3967
-
3968
-    /**
3969
-     * get_current_page
3970
-     *
3971
-     * @return string _current_page property value
3972
-     */
3973
-    public function get_current_page()
3974
-    {
3975
-        return $this->_current_page;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * get_current_view
3981
-     *
3982
-     * @return string _current_view property value
3983
-     */
3984
-    public function get_current_view()
3985
-    {
3986
-        return $this->_current_view;
3987
-    }
3988
-
3989
-
3990
-    /**
3991
-     * get_current_screen
3992
-     *
3993
-     * @return object The current WP_Screen object
3994
-     */
3995
-    public function get_current_screen()
3996
-    {
3997
-        return $this->_current_screen;
3998
-    }
3999
-
4000
-
4001
-    /**
4002
-     * get_current_page_view_url
4003
-     *
4004
-     * @return string This returns the url for the current_page_view.
4005
-     */
4006
-    public function get_current_page_view_url()
4007
-    {
4008
-        return $this->_current_page_view_url;
4009
-    }
4010
-
4011
-
4012
-    /**
4013
-     * just returns the Request
4014
-     *
4015
-     * @return RequestInterface
4016
-     */
4017
-    public function get_request()
4018
-    {
4019
-        return $this->request;
4020
-    }
4021
-
4022
-
4023
-    /**
4024
-     * just returns the _req_data property
4025
-     *
4026
-     * @return array
4027
-     */
4028
-    public function get_request_data()
4029
-    {
4030
-        return $this->request->requestParams();
4031
-    }
4032
-
4033
-
4034
-    /**
4035
-     * returns the _req_data protected property
4036
-     *
4037
-     * @return string
4038
-     */
4039
-    public function get_req_action()
4040
-    {
4041
-        return $this->_req_action;
4042
-    }
4043
-
4044
-
4045
-    /**
4046
-     * @return bool  value of $_is_caf property
4047
-     */
4048
-    public function is_caf()
4049
-    {
4050
-        return $this->_is_caf;
4051
-    }
4052
-
4053
-
4054
-    /**
4055
-     * @return mixed
4056
-     */
4057
-    public function default_espresso_metaboxes()
4058
-    {
4059
-        return $this->_default_espresso_metaboxes;
4060
-    }
4061
-
4062
-
4063
-    /**
4064
-     * @return mixed
4065
-     */
4066
-    public function admin_base_url()
4067
-    {
4068
-        return $this->_admin_base_url;
4069
-    }
4070
-
4071
-
4072
-    /**
4073
-     * @return mixed
4074
-     */
4075
-    public function wp_page_slug()
4076
-    {
4077
-        return $this->_wp_page_slug;
4078
-    }
4079
-
4080
-
4081
-    /**
4082
-     * updates  espresso configuration settings
4083
-     *
4084
-     * @param string                   $tab
4085
-     * @param EE_Config_Base|EE_Config $config
4086
-     * @param string                   $file file where error occurred
4087
-     * @param string                   $func function  where error occurred
4088
-     * @param string                   $line line no where error occurred
4089
-     * @return boolean
4090
-     */
4091
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
-    {
4093
-        // remove any options that are NOT going to be saved with the config settings.
4094
-        if (isset($config->core->ee_ueip_optin)) {
4095
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4096
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
-            update_option('ee_ueip_has_notified', true);
4098
-        }
4099
-        // and save it (note we're also doing the network save here)
4100
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
-        if ($config_saved && $net_saved) {
4103
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
-            return true;
4105
-        }
4106
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
-        return false;
4108
-    }
4109
-
4110
-
4111
-    /**
4112
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
-     *
4114
-     * @return array
4115
-     */
4116
-    public function get_yes_no_values()
4117
-    {
4118
-        return $this->_yes_no_values;
4119
-    }
4120
-
4121
-
4122
-    protected function _get_dir()
4123
-    {
4124
-        $reflector = new ReflectionClass(get_class($this));
4125
-        return dirname($reflector->getFileName());
4126
-    }
4127
-
4128
-
4129
-    /**
4130
-     * A helper for getting a "next link".
4131
-     *
4132
-     * @param string $url   The url to link to
4133
-     * @param string $class The class to use.
4134
-     * @return string
4135
-     */
4136
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
-    {
4138
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
-    }
4140
-
4141
-
4142
-    /**
4143
-     * A helper for getting a "previous link".
4144
-     *
4145
-     * @param string $url   The url to link to
4146
-     * @param string $class The class to use.
4147
-     * @return string
4148
-     */
4149
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
-    {
4151
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
-    }
4153
-
4154
-
4155
-
4156
-
4157
-
4158
-
4159
-
4160
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
-
4162
-
4163
-    /**
4164
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
-     * 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
4166
-     * _req_data array.
4167
-     *
4168
-     * @return bool success/fail
4169
-     * @throws EE_Error
4170
-     * @throws InvalidArgumentException
4171
-     * @throws ReflectionException
4172
-     * @throws InvalidDataTypeException
4173
-     * @throws InvalidInterfaceException
4174
-     */
4175
-    protected function _process_resend_registration()
4176
-    {
4177
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
-        do_action(
4179
-            'AHEE__EE_Admin_Page___process_resend_registration',
4180
-            $this->_template_args['success'],
4181
-            $this->request->requestParams()
4182
-        );
4183
-        return $this->_template_args['success'];
4184
-    }
4185
-
4186
-
4187
-    /**
4188
-     * This automatically processes any payment message notifications when manual payment has been applied.
4189
-     *
4190
-     * @param EE_Payment $payment
4191
-     * @return bool success/fail
4192
-     */
4193
-    protected function _process_payment_notification(EE_Payment $payment)
4194
-    {
4195
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
-        $this->_template_args['success'] = apply_filters(
4198
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
-            false,
4200
-            $payment
4201
-        );
4202
-        return $this->_template_args['success'];
4203
-    }
2764
+	}
2765
+
2766
+
2767
+	/**
2768
+	 * facade for add_meta_box
2769
+	 *
2770
+	 * @param string  $action        where the metabox get's displayed
2771
+	 * @param string  $title         Title of Metabox (output in metabox header)
2772
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
+	 *                               instead of the one created in here.
2774
+	 * @param array   $callback_args an array of args supplied for the metabox
2775
+	 * @param string  $column        what metabox column
2776
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
+	 *                               created but just set our own callback for wp's add_meta_box.
2779
+	 * @throws DomainException
2780
+	 */
2781
+	public function _add_admin_page_meta_box(
2782
+		$action,
2783
+		$title,
2784
+		$callback,
2785
+		$callback_args,
2786
+		$column = 'normal',
2787
+		$priority = 'high',
2788
+		$create_func = true
2789
+	) {
2790
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
+		// 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.
2792
+		if (empty($callback_args) && $create_func) {
2793
+			$callback_args = [
2794
+				'template_path' => $this->_template_path,
2795
+				'template_args' => $this->_template_args,
2796
+			];
2797
+		}
2798
+		// 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)
2799
+		$call_back_func = $create_func
2800
+			? function ($post, $metabox) {
2801
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
+				echo EEH_Template::display_template(
2803
+					$metabox['args']['template_path'],
2804
+					$metabox['args']['template_args'],
2805
+					true
2806
+				);
2807
+			}
2808
+			: $callback;
2809
+		add_meta_box(
2810
+			str_replace('_', '-', $action) . '-mbox',
2811
+			$title,
2812
+			$call_back_func,
2813
+			$this->_wp_page_slug,
2814
+			$column,
2815
+			$priority,
2816
+			$callback_args
2817
+		);
2818
+	}
2819
+
2820
+
2821
+	/**
2822
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
+	 *
2824
+	 * @throws DomainException
2825
+	 * @throws EE_Error
2826
+	 */
2827
+	public function display_admin_page_with_metabox_columns()
2828
+	{
2829
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
+			$this->_column_template_path,
2832
+			$this->_template_args,
2833
+			true
2834
+		);
2835
+		// the final wrapper
2836
+		$this->admin_page_wrapper();
2837
+	}
2838
+
2839
+
2840
+	/**
2841
+	 * generates  HTML wrapper for an admin details page
2842
+	 *
2843
+	 * @return void
2844
+	 * @throws EE_Error
2845
+	 * @throws DomainException
2846
+	 */
2847
+	public function display_admin_page_with_sidebar()
2848
+	{
2849
+		$this->_display_admin_page(true);
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2855
+	 *
2856
+	 * @return void
2857
+	 * @throws EE_Error
2858
+	 * @throws DomainException
2859
+	 */
2860
+	public function display_admin_page_with_no_sidebar()
2861
+	{
2862
+		$this->_display_admin_page();
2863
+	}
2864
+
2865
+
2866
+	/**
2867
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2868
+	 *
2869
+	 * @return void
2870
+	 * @throws EE_Error
2871
+	 * @throws DomainException
2872
+	 */
2873
+	public function display_about_admin_page()
2874
+	{
2875
+		$this->_display_admin_page(false, true);
2876
+	}
2877
+
2878
+
2879
+	/**
2880
+	 * display_admin_page
2881
+	 * contains the code for actually displaying an admin page
2882
+	 *
2883
+	 * @param boolean $sidebar true with sidebar, false without
2884
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
+	 * @return void
2886
+	 * @throws DomainException
2887
+	 * @throws EE_Error
2888
+	 */
2889
+	private function _display_admin_page($sidebar = false, $about = false)
2890
+	{
2891
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2895
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2897
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
+			? 'poststuff'
2899
+			: 'espresso-default-admin';
2900
+		$template_path                                     = $sidebar
2901
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
+		if ($this->request->isAjax()) {
2904
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
+		}
2906
+		$template_path                                     = ! empty($this->_column_template_path)
2907
+			? $this->_column_template_path : $template_path;
2908
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
+			? $this->_template_args['admin_page_content']
2910
+			: '';
2911
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
+			? $this->_template_args['before_admin_page_content']
2913
+			: '';
2914
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
+			? $this->_template_args['after_admin_page_content']
2916
+			: '';
2917
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
+			$template_path,
2919
+			$this->_template_args,
2920
+			true
2921
+		);
2922
+		// the final template wrapper
2923
+		$this->admin_page_wrapper($about);
2924
+	}
2925
+
2926
+
2927
+	/**
2928
+	 * This is used to display caf preview pages.
2929
+	 *
2930
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2931
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
+	 * @return void
2934
+	 * @throws DomainException
2935
+	 * @throws EE_Error
2936
+	 * @throws InvalidArgumentException
2937
+	 * @throws InvalidDataTypeException
2938
+	 * @throws InvalidInterfaceException
2939
+	 * @since 4.3.2
2940
+	 */
2941
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
+	{
2943
+		// let's generate a default preview action button if there isn't one already present.
2944
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2945
+			'Upgrade to Event Espresso 4 Right Now',
2946
+			'event_espresso'
2947
+		);
2948
+		$buy_now_url                                   = add_query_arg(
2949
+			[
2950
+				'ee_ver'       => 'ee4',
2951
+				'utm_source'   => 'ee4_plugin_admin',
2952
+				'utm_medium'   => 'link',
2953
+				'utm_campaign' => $utm_campaign_source,
2954
+				'utm_content'  => 'buy_now_button',
2955
+			],
2956
+			'https://eventespresso.com/pricing/'
2957
+		);
2958
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
+			? $this->get_action_link_or_button(
2960
+				'',
2961
+				'buy_now',
2962
+				[],
2963
+				'button-primary button-large',
2964
+				esc_url_raw($buy_now_url),
2965
+				true
2966
+			)
2967
+			: $this->_template_args['preview_action_button'];
2968
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
+			$this->_template_args,
2971
+			true
2972
+		);
2973
+		$this->_display_admin_page($display_sidebar);
2974
+	}
2975
+
2976
+
2977
+	/**
2978
+	 * display_admin_list_table_page_with_sidebar
2979
+	 * generates HTML wrapper for an admin_page with list_table
2980
+	 *
2981
+	 * @return void
2982
+	 * @throws EE_Error
2983
+	 * @throws DomainException
2984
+	 */
2985
+	public function display_admin_list_table_page_with_sidebar()
2986
+	{
2987
+		$this->_display_admin_list_table_page(true);
2988
+	}
2989
+
2990
+
2991
+	/**
2992
+	 * display_admin_list_table_page_with_no_sidebar
2993
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
+	 *
2995
+	 * @return void
2996
+	 * @throws EE_Error
2997
+	 * @throws DomainException
2998
+	 */
2999
+	public function display_admin_list_table_page_with_no_sidebar()
3000
+	{
3001
+		$this->_display_admin_list_table_page();
3002
+	}
3003
+
3004
+
3005
+	/**
3006
+	 * generates html wrapper for an admin_list_table page
3007
+	 *
3008
+	 * @param boolean $sidebar whether to display with sidebar or not.
3009
+	 * @return void
3010
+	 * @throws DomainException
3011
+	 * @throws EE_Error
3012
+	 */
3013
+	private function _display_admin_list_table_page($sidebar = false)
3014
+	{
3015
+		// setup search attributes
3016
+		$this->_set_search_attributes();
3017
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3018
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
+		$this->_template_args['table_url']        = $this->request->isAjax()
3020
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
+		$this->_template_args['list_table']       = $this->_list_table_object;
3023
+		$this->_template_args['current_route']    = $this->_req_action;
3024
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
+		if (! empty($ajax_sorting_callback)) {
3027
+			$sortable_list_table_form_fields = wp_nonce_field(
3028
+				$ajax_sorting_callback . '_nonce',
3029
+				$ajax_sorting_callback . '_nonce',
3030
+				false,
3031
+				false
3032
+			);
3033
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
+												. $this->page_slug
3035
+												. '" />';
3036
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
+												. $ajax_sorting_callback
3038
+												. '" />';
3039
+		} else {
3040
+			$sortable_list_table_form_fields = '';
3041
+		}
3042
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
+		$hidden_form_fields                                      =
3044
+			isset($this->_template_args['list_table_hidden_fields'])
3045
+				? $this->_template_args['list_table_hidden_fields']
3046
+				: '';
3047
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3048
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3049
+																	. $nonce_ref
3050
+																	. '" value="'
3051
+																	. wp_create_nonce($nonce_ref)
3052
+																	. '">';
3053
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
+		// display message about search results?
3055
+		$search = $this->request->getRequestParam('s');
3056
+		$this->_template_args['before_list_table'] .= ! empty($search)
3057
+			? '<p class="ee-search-results">' . sprintf(
3058
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
+				trim($search, '%')
3060
+			) . '</p>'
3061
+			: '';
3062
+		// filter before_list_table template arg
3063
+		$this->_template_args['before_list_table'] = apply_filters(
3064
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
+			$this->_template_args['before_list_table'],
3066
+			$this->page_slug,
3067
+			$this->request->requestParams(),
3068
+			$this->_req_action
3069
+		);
3070
+		// convert to array and filter again
3071
+		// arrays are easier to inject new items in a specific location,
3072
+		// but would not be backwards compatible, so we have to add a new filter
3073
+		$this->_template_args['before_list_table'] = implode(
3074
+			" \n",
3075
+			(array) apply_filters(
3076
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
+				(array) $this->_template_args['before_list_table'],
3078
+				$this->page_slug,
3079
+				$this->request->requestParams(),
3080
+				$this->_req_action
3081
+			)
3082
+		);
3083
+		// filter after_list_table template arg
3084
+		$this->_template_args['after_list_table'] = apply_filters(
3085
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
+			$this->_template_args['after_list_table'],
3087
+			$this->page_slug,
3088
+			$this->request->requestParams(),
3089
+			$this->_req_action
3090
+		);
3091
+		// convert to array and filter again
3092
+		// arrays are easier to inject new items in a specific location,
3093
+		// but would not be backwards compatible, so we have to add a new filter
3094
+		$this->_template_args['after_list_table']   = implode(
3095
+			" \n",
3096
+			(array) apply_filters(
3097
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
+				(array) $this->_template_args['after_list_table'],
3099
+				$this->page_slug,
3100
+				$this->request->requestParams(),
3101
+				$this->_req_action
3102
+			)
3103
+		);
3104
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
+			$template_path,
3106
+			$this->_template_args,
3107
+			true
3108
+		);
3109
+		// the final template wrapper
3110
+		if ($sidebar) {
3111
+			$this->display_admin_page_with_sidebar();
3112
+		} else {
3113
+			$this->display_admin_page_with_no_sidebar();
3114
+		}
3115
+	}
3116
+
3117
+
3118
+	/**
3119
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
+	 * html string for the legend.
3121
+	 * $items are expected in an array in the following format:
3122
+	 * $legend_items = array(
3123
+	 *        'item_id' => array(
3124
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3125
+	 *            'desc' => esc_html__('localized description of item');
3126
+	 *        )
3127
+	 * );
3128
+	 *
3129
+	 * @param array $items see above for format of array
3130
+	 * @return string html string of legend
3131
+	 * @throws DomainException
3132
+	 */
3133
+	protected function _display_legend($items)
3134
+	{
3135
+		$this->_template_args['items'] = apply_filters(
3136
+			'FHEE__EE_Admin_Page___display_legend__items',
3137
+			(array) $items,
3138
+			$this
3139
+		);
3140
+		return EEH_Template::display_template(
3141
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
+			$this->_template_args,
3143
+			true
3144
+		);
3145
+	}
3146
+
3147
+
3148
+	/**
3149
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
+	 * The returned json object is created from an array in the following format:
3151
+	 * array(
3152
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3155
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
+	 *  that might be included in here)
3159
+	 * )
3160
+	 * The json object is populated by whatever is set in the $_template_args property.
3161
+	 *
3162
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
+	 *                                 instead of displayed.
3164
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
+	 * @return void
3166
+	 * @throws EE_Error
3167
+	 */
3168
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
+	{
3170
+		// make sure any EE_Error notices have been handled.
3171
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3172
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
+		unset($this->_template_args['data']);
3174
+		$json = [
3175
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
+			'notices'   => EE_Error::get_notices(),
3180
+			'content'   => isset($this->_template_args['admin_page_content'])
3181
+				? $this->_template_args['admin_page_content'] : '',
3182
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
+			'isEEajax'  => true
3184
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
+		];
3186
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
+		if (null === error_get_last() || ! headers_sent()) {
3188
+			header('Content-Type: application/json; charset=UTF-8');
3189
+		}
3190
+		echo wp_json_encode($json);
3191
+		exit();
3192
+	}
3193
+
3194
+
3195
+	/**
3196
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
+	 *
3198
+	 * @return void
3199
+	 * @throws EE_Error
3200
+	 */
3201
+	public function return_json()
3202
+	{
3203
+		if ($this->request->isAjax()) {
3204
+			$this->_return_json();
3205
+		} else {
3206
+			throw new EE_Error(
3207
+				sprintf(
3208
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
+					__FUNCTION__
3210
+				)
3211
+			);
3212
+		}
3213
+	}
3214
+
3215
+
3216
+	/**
3217
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
+	 *
3220
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
+	 */
3222
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
+	{
3224
+		$this->_hook_obj = $hook_obj;
3225
+	}
3226
+
3227
+
3228
+	/**
3229
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3230
+	 *
3231
+	 * @param boolean $about whether to use the special about page wrapper or default.
3232
+	 * @return void
3233
+	 * @throws DomainException
3234
+	 * @throws EE_Error
3235
+	 */
3236
+	public function admin_page_wrapper($about = false)
3237
+	{
3238
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
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
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3249
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
+			isset($this->_template_args['after_admin_page_content'])
3251
+				? $this->_template_args['after_admin_page_content']
3252
+				: ''
3253
+		);
3254
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
+		// load settings page wrapper template
3256
+		$template_path = ! $this->request->isAjax()
3257
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
+		// about page?
3260
+		$template_path = $about
3261
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
+			: $template_path;
3263
+		if ($this->request->isAjax()) {
3264
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
+				$template_path,
3266
+				$this->_template_args,
3267
+				true
3268
+			);
3269
+			$this->_return_json();
3270
+		} else {
3271
+			EEH_Template::display_template($template_path, $this->_template_args);
3272
+		}
3273
+	}
3274
+
3275
+
3276
+	/**
3277
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
+	 *
3279
+	 * @return string html
3280
+	 * @throws EE_Error
3281
+	 */
3282
+	protected function _get_main_nav_tabs()
3283
+	{
3284
+		// let's generate the html using the EEH_Tabbed_Content helper.
3285
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
+		// (rather than setting in the page_routes array)
3287
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *        sort nav tabs
3293
+	 *
3294
+	 * @param $a
3295
+	 * @param $b
3296
+	 * @return int
3297
+	 */
3298
+	private function _sort_nav_tabs($a, $b)
3299
+	{
3300
+		if ($a['order'] === $b['order']) {
3301
+			return 0;
3302
+		}
3303
+		return ($a['order'] < $b['order']) ? -1 : 1;
3304
+	}
3305
+
3306
+
3307
+	/**
3308
+	 *    generates HTML for the forms used on admin pages
3309
+	 *
3310
+	 * @param array  $input_vars   - array of input field details
3311
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
+	 *                             use)
3313
+	 * @param bool   $id
3314
+	 * @return string
3315
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
+	 */
3318
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
+	{
3320
+		return $generator === 'string'
3321
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3323
+	}
3324
+
3325
+
3326
+	/**
3327
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3328
+	 *
3329
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
+	 *                                   Close" button.
3331
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
+	 *                                   'Save', [1] => 'save & close')
3333
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3335
+	 *                                   default actions by submitting some other value.
3336
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
+	 *                                   close (normal form handling).
3339
+	 */
3340
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
+	{
3342
+		// make sure $text and $actions are in an array
3343
+		$text          = (array) $text;
3344
+		$actions       = (array) $actions;
3345
+		$referrer_url  = empty($referrer)
3346
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
+			  . $this->request->getServerParam('REQUEST_URI')
3348
+			  . '" />'
3349
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
+			  . $referrer
3351
+			  . '" />';
3352
+		$button_text   = ! empty($text)
3353
+			? $text
3354
+			: [
3355
+				esc_html__('Save', 'event_espresso'),
3356
+				esc_html__('Save and Close', 'event_espresso'),
3357
+			];
3358
+		$default_names = ['save', 'save_and_close'];
3359
+		// add in a hidden index for the current page (so save and close redirects properly)
3360
+		$this->_template_args['save_buttons'] = $referrer_url;
3361
+		foreach ($button_text as $key => $button) {
3362
+			$ref                                  = $default_names[ $key ];
3363
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
+													 . $ref
3365
+													 . '" value="'
3366
+													 . $button
3367
+													 . '" name="'
3368
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3369
+													 . '" id="'
3370
+													 . $this->_current_view . '_' . $ref
3371
+													 . '" />';
3372
+			if (! $both) {
3373
+				break;
3374
+			}
3375
+		}
3376
+	}
3377
+
3378
+
3379
+	/**
3380
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
+	 *
3382
+	 * @param string $route
3383
+	 * @param array  $additional_hidden_fields
3384
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3385
+	 * @since 4.6.0
3386
+	 */
3387
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
+	{
3389
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
+	}
3391
+
3392
+
3393
+	/**
3394
+	 * set form open and close tags on add/edit pages.
3395
+	 *
3396
+	 * @param string $route                    the route you want the form to direct to
3397
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
+	 * @return void
3399
+	 */
3400
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
+	{
3402
+		if (empty($route)) {
3403
+			$user_msg = esc_html__(
3404
+				'An error occurred. No action was set for this page\'s form.',
3405
+				'event_espresso'
3406
+			);
3407
+			$dev_msg  = $user_msg . "\n"
3408
+						. sprintf(
3409
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
+							__FUNCTION__,
3411
+							__CLASS__
3412
+						);
3413
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
+		}
3415
+		// open form
3416
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
+															 . $this->_admin_base_url
3418
+															 . '" id="'
3419
+															 . $route
3420
+															 . '_event_form" >';
3421
+		// add nonce
3422
+		$nonce                                             =
3423
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
+		// add REQUIRED form action
3426
+		$hidden_fields = [
3427
+			'action' => ['type' => 'hidden', 'value' => $route],
3428
+		];
3429
+		// merge arrays
3430
+		$hidden_fields = is_array($additional_hidden_fields)
3431
+			? array_merge($hidden_fields, $additional_hidden_fields)
3432
+			: $hidden_fields;
3433
+		// generate form fields
3434
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
+		// add fields to form
3436
+		foreach ((array) $form_fields as $field_name => $form_field) {
3437
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
+		}
3439
+		// close form
3440
+		$this->_template_args['after_admin_page_content'] = '</form>';
3441
+	}
3442
+
3443
+
3444
+	/**
3445
+	 * Public Wrapper for _redirect_after_action() method since its
3446
+	 * discovered it would be useful for external code to have access.
3447
+	 *
3448
+	 * @param bool   $success
3449
+	 * @param string $what
3450
+	 * @param string $action_desc
3451
+	 * @param array  $query_args
3452
+	 * @param bool   $override_overwrite
3453
+	 * @throws EE_Error
3454
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
+	 * @since 4.5.0
3456
+	 */
3457
+	public function redirect_after_action(
3458
+		$success = false,
3459
+		$what = 'item',
3460
+		$action_desc = 'processed',
3461
+		$query_args = [],
3462
+		$override_overwrite = false
3463
+	) {
3464
+		$this->_redirect_after_action(
3465
+			$success,
3466
+			$what,
3467
+			$action_desc,
3468
+			$query_args,
3469
+			$override_overwrite
3470
+		);
3471
+	}
3472
+
3473
+
3474
+	/**
3475
+	 * Helper method for merging existing request data with the returned redirect url.
3476
+	 *
3477
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
+	 * filters are still applied.
3479
+	 *
3480
+	 * @param array $new_route_data
3481
+	 * @return array
3482
+	 */
3483
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
+	{
3485
+		foreach ($this->request->requestParams() as $ref => $value) {
3486
+			// unset nonces
3487
+			if (strpos($ref, 'nonce') !== false) {
3488
+				$this->request->unSetRequestParam($ref);
3489
+				continue;
3490
+			}
3491
+			// urlencode values.
3492
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
+			$this->request->setRequestParam($ref, $value);
3494
+		}
3495
+		return array_merge($this->request->requestParams(), $new_route_data);
3496
+	}
3497
+
3498
+
3499
+	/**
3500
+	 *    _redirect_after_action
3501
+	 *
3502
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3503
+	 * @param string $what               - what the action was performed on
3504
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
+	 *                                   action is completed
3507
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
+	 *                                   override this so that they show.
3509
+	 * @return void
3510
+	 * @throws EE_Error
3511
+	 */
3512
+	protected function _redirect_after_action(
3513
+		$success = 0,
3514
+		$what = 'item',
3515
+		$action_desc = 'processed',
3516
+		$query_args = [],
3517
+		$override_overwrite = false
3518
+	) {
3519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
+		// class name for actions/filters.
3521
+		$classname = get_class($this);
3522
+		// set redirect url.
3523
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
+		// otherwise we go with whatever is set as the _admin_base_url
3525
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
+		$notices      = EE_Error::get_notices(false);
3527
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3528
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3529
+			EE_Error::overwrite_success();
3530
+		}
3531
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
+			// how many records affected ? more than one record ? or just one ?
3533
+			if ($success > 1) {
3534
+				// set plural msg
3535
+				EE_Error::add_success(
3536
+					sprintf(
3537
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
+						$what,
3539
+						$action_desc
3540
+					),
3541
+					__FILE__,
3542
+					__FUNCTION__,
3543
+					__LINE__
3544
+				);
3545
+			} elseif ($success === 1) {
3546
+				// set singular msg
3547
+				EE_Error::add_success(
3548
+					sprintf(
3549
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
+						$what,
3551
+						$action_desc
3552
+					),
3553
+					__FILE__,
3554
+					__FUNCTION__,
3555
+					__LINE__
3556
+				);
3557
+			}
3558
+		}
3559
+		// check that $query_args isn't something crazy
3560
+		if (! is_array($query_args)) {
3561
+			$query_args = [];
3562
+		}
3563
+		/**
3564
+		 * Allow injecting actions before the query_args are modified for possible different
3565
+		 * redirections on save and close actions
3566
+		 *
3567
+		 * @param array $query_args       The original query_args array coming into the
3568
+		 *                                method.
3569
+		 * @since 4.2.0
3570
+		 */
3571
+		do_action(
3572
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
+			$query_args
3574
+		);
3575
+		// calculate where we're going (if we have a "save and close" button pushed)
3576
+
3577
+		if (
3578
+			$this->request->requestParamIsSet('save_and_close')
3579
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3580
+		) {
3581
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
+			// regenerate query args array from referrer URL
3584
+			parse_str($parsed_url['query'], $query_args);
3585
+			// correct page and action will be in the query args now
3586
+			$redirect_url = admin_url('admin.php');
3587
+		}
3588
+		// merge any default query_args set in _default_route_query_args property
3589
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
+			$args_to_merge = [];
3591
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
+				// is there a wp_referer array in our _default_route_query_args property?
3593
+				if ($query_param === 'wp_referer') {
3594
+					$query_value = (array) $query_value;
3595
+					foreach ($query_value as $reference => $value) {
3596
+						if (strpos($reference, 'nonce') !== false) {
3597
+							continue;
3598
+						}
3599
+						// finally we will override any arguments in the referer with
3600
+						// what might be set on the _default_route_query_args array.
3601
+						if (isset($this->_default_route_query_args[ $reference ])) {
3602
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
+						} else {
3604
+							$args_to_merge[ $reference ] = urlencode($value);
3605
+						}
3606
+					}
3607
+					continue;
3608
+				}
3609
+				$args_to_merge[ $query_param ] = $query_value;
3610
+			}
3611
+			// now let's merge these arguments but override with what was specifically sent in to the
3612
+			// redirect.
3613
+			$query_args = array_merge($args_to_merge, $query_args);
3614
+		}
3615
+		$this->_process_notices($query_args);
3616
+		// generate redirect url
3617
+		// if redirecting to anything other than the main page, add a nonce
3618
+		if (isset($query_args['action'])) {
3619
+			// manually generate wp_nonce and merge that with the query vars
3620
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3621
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
+		}
3623
+		// we're adding some hooks and filters in here for processing any things just before redirects
3624
+		// (example: an admin page has done an insert or update and we want to run something after that).
3625
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
+		$redirect_url = apply_filters(
3627
+			'FHEE_redirect_' . $classname . $this->_req_action,
3628
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3629
+			$query_args
3630
+		);
3631
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
+		if ($this->request->isAjax()) {
3633
+			$default_data                    = [
3634
+				'close'        => true,
3635
+				'redirect_url' => $redirect_url,
3636
+				'where'        => 'main',
3637
+				'what'         => 'append',
3638
+			];
3639
+			$this->_template_args['success'] = $success;
3640
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
+				$default_data,
3642
+				$this->_template_args['data']
3643
+			) : $default_data;
3644
+			$this->_return_json();
3645
+		}
3646
+		wp_safe_redirect($redirect_url);
3647
+		exit();
3648
+	}
3649
+
3650
+
3651
+	/**
3652
+	 * process any notices before redirecting (or returning ajax request)
3653
+	 * This method sets the $this->_template_args['notices'] attribute;
3654
+	 *
3655
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
+	 *                                  page_routes haven't been defined yet.
3658
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
+	 *                                  still save a transient for the notice.
3660
+	 * @return void
3661
+	 * @throws EE_Error
3662
+	 */
3663
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
+	{
3665
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
+		if ($this->request->isAjax()) {
3667
+			$notices = EE_Error::get_notices(false);
3668
+			if (empty($this->_template_args['success'])) {
3669
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
+			}
3671
+			if (empty($this->_template_args['errors'])) {
3672
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
+			}
3674
+			if (empty($this->_template_args['attention'])) {
3675
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
+			}
3677
+		}
3678
+		$this->_template_args['notices'] = EE_Error::get_notices();
3679
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
+		if (! $this->request->isAjax() || $sticky_notices) {
3681
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
+			$this->_add_transient(
3683
+				$route,
3684
+				$this->_template_args['notices'],
3685
+				true,
3686
+				$skip_route_verify
3687
+			);
3688
+		}
3689
+	}
3690
+
3691
+
3692
+	/**
3693
+	 * get_action_link_or_button
3694
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
+	 *
3696
+	 * @param string $action        use this to indicate which action the url is generated with.
3697
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
+	 *                              property.
3699
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
+	 * @param string $base_url      If this is not provided
3702
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3703
+	 *                              Otherwise this value will be used.
3704
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
+	 * @return string
3706
+	 * @throws InvalidArgumentException
3707
+	 * @throws InvalidInterfaceException
3708
+	 * @throws InvalidDataTypeException
3709
+	 * @throws EE_Error
3710
+	 */
3711
+	public function get_action_link_or_button(
3712
+		$action,
3713
+		$type = 'add',
3714
+		$extra_request = [],
3715
+		$class = 'button-primary',
3716
+		$base_url = '',
3717
+		$exclude_nonce = false
3718
+	) {
3719
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
+			throw new EE_Error(
3722
+				sprintf(
3723
+					esc_html__(
3724
+						'There is no page route for given action for the button.  This action was given: %s',
3725
+						'event_espresso'
3726
+					),
3727
+					$action
3728
+				)
3729
+			);
3730
+		}
3731
+		if (! isset($this->_labels['buttons'][ $type ])) {
3732
+			throw new EE_Error(
3733
+				sprintf(
3734
+					esc_html__(
3735
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
+						'event_espresso'
3737
+					),
3738
+					$type
3739
+				)
3740
+			);
3741
+		}
3742
+		// finally check user access for this button.
3743
+		$has_access = $this->check_user_access($action, true);
3744
+		if (! $has_access) {
3745
+			return '';
3746
+		}
3747
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
+		$query_args = [
3749
+			'action' => $action,
3750
+		];
3751
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
+		if (! empty($extra_request)) {
3753
+			$query_args = array_merge($extra_request, $query_args);
3754
+		}
3755
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
+	}
3758
+
3759
+
3760
+	/**
3761
+	 * _per_page_screen_option
3762
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
+	 *
3764
+	 * @return void
3765
+	 * @throws InvalidArgumentException
3766
+	 * @throws InvalidInterfaceException
3767
+	 * @throws InvalidDataTypeException
3768
+	 */
3769
+	protected function _per_page_screen_option()
3770
+	{
3771
+		$option = 'per_page';
3772
+		$args   = [
3773
+			'label'   => apply_filters(
3774
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
+				$this->_admin_page_title,
3776
+				$this
3777
+			),
3778
+			'default' => (int) apply_filters(
3779
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
+				20
3781
+			),
3782
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
+		];
3784
+		// ONLY add the screen option if the user has access to it.
3785
+		if ($this->check_user_access($this->_current_view, true)) {
3786
+			add_screen_option($option, $args);
3787
+		}
3788
+	}
3789
+
3790
+
3791
+	/**
3792
+	 * set_per_page_screen_option
3793
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
+	 * admin_menu.
3796
+	 *
3797
+	 * @return void
3798
+	 */
3799
+	private function _set_per_page_screen_options()
3800
+	{
3801
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
+			if (! $user = wp_get_current_user()) {
3804
+				return;
3805
+			}
3806
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
+			if (! $option) {
3808
+				return;
3809
+			}
3810
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
+			$map_option = $option;
3812
+			$option     = str_replace('-', '_', $option);
3813
+			switch ($map_option) {
3814
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
+					$max_value = apply_filters(
3816
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
+						999,
3818
+						$this->_current_page,
3819
+						$this->_current_view
3820
+					);
3821
+					if ($value < 1) {
3822
+						return;
3823
+					}
3824
+					$value = min($value, $max_value);
3825
+					break;
3826
+				default:
3827
+					$value = apply_filters(
3828
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
+						false,
3830
+						$option,
3831
+						$value
3832
+					);
3833
+					if (false === $value) {
3834
+						return;
3835
+					}
3836
+					break;
3837
+			}
3838
+			update_user_meta($user->ID, $option, $value);
3839
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
+			exit;
3841
+		}
3842
+	}
3843
+
3844
+
3845
+	/**
3846
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
+	 *
3848
+	 * @param array $data array that will be assigned to template args.
3849
+	 */
3850
+	public function set_template_args($data)
3851
+	{
3852
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3853
+	}
3854
+
3855
+
3856
+	/**
3857
+	 * This makes available the WP transient system for temporarily moving data between routes
3858
+	 *
3859
+	 * @param string $route             the route that should receive the transient
3860
+	 * @param array  $data              the data that gets sent
3861
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
+	 *                                  normal route transient.
3863
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
+	 *                                  when we are adding a transient before page_routes have been defined.
3865
+	 * @return void
3866
+	 * @throws EE_Error
3867
+	 */
3868
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
+	{
3870
+		$user_id = get_current_user_id();
3871
+		if (! $skip_route_verify) {
3872
+			$this->_verify_route($route);
3873
+		}
3874
+		// now let's set the string for what kind of transient we're setting
3875
+		$transient = $notices
3876
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
+			: 'rte_tx_' . $route . '_' . $user_id;
3878
+		$data      = $notices ? ['notices' => $data] : $data;
3879
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3880
+		$existing = is_multisite() && is_network_admin()
3881
+			? get_site_transient($transient)
3882
+			: get_transient($transient);
3883
+		if ($existing) {
3884
+			$data = array_merge((array) $data, (array) $existing);
3885
+		}
3886
+		if (is_multisite() && is_network_admin()) {
3887
+			set_site_transient($transient, $data, 8);
3888
+		} else {
3889
+			set_transient($transient, $data, 8);
3890
+		}
3891
+	}
3892
+
3893
+
3894
+	/**
3895
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3896
+	 *
3897
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
+	 * @param string $route
3899
+	 * @return mixed data
3900
+	 */
3901
+	protected function _get_transient($notices = false, $route = '')
3902
+	{
3903
+		$user_id   = get_current_user_id();
3904
+		$route     = ! $route ? $this->_req_action : $route;
3905
+		$transient = $notices
3906
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
+			: 'rte_tx_' . $route . '_' . $user_id;
3908
+		$data      = is_multisite() && is_network_admin()
3909
+			? get_site_transient($transient)
3910
+			: get_transient($transient);
3911
+		// delete transient after retrieval (just in case it hasn't expired);
3912
+		if (is_multisite() && is_network_admin()) {
3913
+			delete_site_transient($transient);
3914
+		} else {
3915
+			delete_transient($transient);
3916
+		}
3917
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
+	 * default route callback on the EE_Admin page you want it run.)
3925
+	 *
3926
+	 * @return void
3927
+	 */
3928
+	protected function _transient_garbage_collection()
3929
+	{
3930
+		global $wpdb;
3931
+		// retrieve all existing transients
3932
+		$query =
3933
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
+		if ($results = $wpdb->get_results($query)) {
3935
+			foreach ($results as $result) {
3936
+				$transient = str_replace('_transient_', '', $result->option_name);
3937
+				get_transient($transient);
3938
+				if (is_multisite() && is_network_admin()) {
3939
+					get_site_transient($transient);
3940
+				}
3941
+			}
3942
+		}
3943
+	}
3944
+
3945
+
3946
+	/**
3947
+	 * get_view
3948
+	 *
3949
+	 * @return string content of _view property
3950
+	 */
3951
+	public function get_view()
3952
+	{
3953
+		return $this->_view;
3954
+	}
3955
+
3956
+
3957
+	/**
3958
+	 * getter for the protected $_views property
3959
+	 *
3960
+	 * @return array
3961
+	 */
3962
+	public function get_views()
3963
+	{
3964
+		return $this->_views;
3965
+	}
3966
+
3967
+
3968
+	/**
3969
+	 * get_current_page
3970
+	 *
3971
+	 * @return string _current_page property value
3972
+	 */
3973
+	public function get_current_page()
3974
+	{
3975
+		return $this->_current_page;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * get_current_view
3981
+	 *
3982
+	 * @return string _current_view property value
3983
+	 */
3984
+	public function get_current_view()
3985
+	{
3986
+		return $this->_current_view;
3987
+	}
3988
+
3989
+
3990
+	/**
3991
+	 * get_current_screen
3992
+	 *
3993
+	 * @return object The current WP_Screen object
3994
+	 */
3995
+	public function get_current_screen()
3996
+	{
3997
+		return $this->_current_screen;
3998
+	}
3999
+
4000
+
4001
+	/**
4002
+	 * get_current_page_view_url
4003
+	 *
4004
+	 * @return string This returns the url for the current_page_view.
4005
+	 */
4006
+	public function get_current_page_view_url()
4007
+	{
4008
+		return $this->_current_page_view_url;
4009
+	}
4010
+
4011
+
4012
+	/**
4013
+	 * just returns the Request
4014
+	 *
4015
+	 * @return RequestInterface
4016
+	 */
4017
+	public function get_request()
4018
+	{
4019
+		return $this->request;
4020
+	}
4021
+
4022
+
4023
+	/**
4024
+	 * just returns the _req_data property
4025
+	 *
4026
+	 * @return array
4027
+	 */
4028
+	public function get_request_data()
4029
+	{
4030
+		return $this->request->requestParams();
4031
+	}
4032
+
4033
+
4034
+	/**
4035
+	 * returns the _req_data protected property
4036
+	 *
4037
+	 * @return string
4038
+	 */
4039
+	public function get_req_action()
4040
+	{
4041
+		return $this->_req_action;
4042
+	}
4043
+
4044
+
4045
+	/**
4046
+	 * @return bool  value of $_is_caf property
4047
+	 */
4048
+	public function is_caf()
4049
+	{
4050
+		return $this->_is_caf;
4051
+	}
4052
+
4053
+
4054
+	/**
4055
+	 * @return mixed
4056
+	 */
4057
+	public function default_espresso_metaboxes()
4058
+	{
4059
+		return $this->_default_espresso_metaboxes;
4060
+	}
4061
+
4062
+
4063
+	/**
4064
+	 * @return mixed
4065
+	 */
4066
+	public function admin_base_url()
4067
+	{
4068
+		return $this->_admin_base_url;
4069
+	}
4070
+
4071
+
4072
+	/**
4073
+	 * @return mixed
4074
+	 */
4075
+	public function wp_page_slug()
4076
+	{
4077
+		return $this->_wp_page_slug;
4078
+	}
4079
+
4080
+
4081
+	/**
4082
+	 * updates  espresso configuration settings
4083
+	 *
4084
+	 * @param string                   $tab
4085
+	 * @param EE_Config_Base|EE_Config $config
4086
+	 * @param string                   $file file where error occurred
4087
+	 * @param string                   $func function  where error occurred
4088
+	 * @param string                   $line line no where error occurred
4089
+	 * @return boolean
4090
+	 */
4091
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
+	{
4093
+		// remove any options that are NOT going to be saved with the config settings.
4094
+		if (isset($config->core->ee_ueip_optin)) {
4095
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4096
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
+			update_option('ee_ueip_has_notified', true);
4098
+		}
4099
+		// and save it (note we're also doing the network save here)
4100
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
+		if ($config_saved && $net_saved) {
4103
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
+			return true;
4105
+		}
4106
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
+		return false;
4108
+	}
4109
+
4110
+
4111
+	/**
4112
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
+	 *
4114
+	 * @return array
4115
+	 */
4116
+	public function get_yes_no_values()
4117
+	{
4118
+		return $this->_yes_no_values;
4119
+	}
4120
+
4121
+
4122
+	protected function _get_dir()
4123
+	{
4124
+		$reflector = new ReflectionClass(get_class($this));
4125
+		return dirname($reflector->getFileName());
4126
+	}
4127
+
4128
+
4129
+	/**
4130
+	 * A helper for getting a "next link".
4131
+	 *
4132
+	 * @param string $url   The url to link to
4133
+	 * @param string $class The class to use.
4134
+	 * @return string
4135
+	 */
4136
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
+	{
4138
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
+	}
4140
+
4141
+
4142
+	/**
4143
+	 * A helper for getting a "previous link".
4144
+	 *
4145
+	 * @param string $url   The url to link to
4146
+	 * @param string $class The class to use.
4147
+	 * @return string
4148
+	 */
4149
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
+	{
4151
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
+	}
4153
+
4154
+
4155
+
4156
+
4157
+
4158
+
4159
+
4160
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
+
4162
+
4163
+	/**
4164
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
+	 * 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
4166
+	 * _req_data array.
4167
+	 *
4168
+	 * @return bool success/fail
4169
+	 * @throws EE_Error
4170
+	 * @throws InvalidArgumentException
4171
+	 * @throws ReflectionException
4172
+	 * @throws InvalidDataTypeException
4173
+	 * @throws InvalidInterfaceException
4174
+	 */
4175
+	protected function _process_resend_registration()
4176
+	{
4177
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
+		do_action(
4179
+			'AHEE__EE_Admin_Page___process_resend_registration',
4180
+			$this->_template_args['success'],
4181
+			$this->request->requestParams()
4182
+		);
4183
+		return $this->_template_args['success'];
4184
+	}
4185
+
4186
+
4187
+	/**
4188
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4189
+	 *
4190
+	 * @param EE_Payment $payment
4191
+	 * @return bool success/fail
4192
+	 */
4193
+	protected function _process_payment_notification(EE_Payment $payment)
4194
+	{
4195
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
+		$this->_template_args['success'] = apply_filters(
4198
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
+			false,
4200
+			$payment
4201
+		);
4202
+		return $this->_template_args['success'];
4203
+	}
4204 4204
 }
Please login to merge, or discard this patch.