Completed
Branch tweak-status-change-notice (50cb96)
by
unknown
45:30 queued 36:14
created
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4068 added lines, -4068 removed lines patch added patch discarded remove patch
@@ -18,4137 +18,4137 @@
 block discarded – undo
18 18
  */
19 19
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
20 20
 {
21
-    /**
22
-     * @var EE_Admin_Config
23
-     */
24
-    protected $admin_config;
21
+	/**
22
+	 * @var EE_Admin_Config
23
+	 */
24
+	protected $admin_config;
25 25
 
26
-    /**
27
-     * @var LoaderInterface $loader
28
-     */
29
-    protected $loader;
26
+	/**
27
+	 * @var LoaderInterface $loader
28
+	 */
29
+	protected $loader;
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
-    // nav tabs
52
-    protected $_nav_tabs;
51
+	// nav tabs
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 = array();
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = array();
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 = array();
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = array();
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
-    // boolean
80
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
79
+	// boolean
80
+	protected $_is_UI_request; // 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
-    // sanitized request action (and nonce)
132
-
133
-    /**
134
-     * @var string $_req_action
135
-     */
136
-    protected $_req_action;
137
-
138
-    /**
139
-     * @var string $_req_nonce
140
-     */
141
-    protected $_req_nonce;
142
-
143
-    // search related
144
-    protected $_search_btn_label;
145
-
146
-    protected $_search_box_callback;
147
-
148
-    /**
149
-     * WP Current Screen object
150
-     *
151
-     * @var WP_Screen
152
-     */
153
-    protected $_current_screen;
154
-
155
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
-    protected $_hook_obj;
157
-
158
-    // for holding incoming request data
159
-    protected $_req_data;
160
-
161
-    // yes / no array for admin form fields
162
-    protected $_yes_no_values = array();
163
-
164
-    // some default things shared by all child classes
165
-    protected $_default_espresso_metaboxes;
166
-
167
-    /**
168
-     *    EE_Registry Object
169
-     *
170
-     * @var    EE_Registry
171
-     */
172
-    protected $EE;
173
-
174
-
175
-    /**
176
-     * This is just a property that flags whether the given route is a caffeinated route or not.
177
-     *
178
-     * @var boolean
179
-     */
180
-    protected $_is_caf = false;
181
-
182
-
183
-    /**
184
-     * @Constructor
185
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
-     * @throws InvalidArgumentException
187
-     * @throws InvalidDataTypeException
188
-     * @throws InvalidInterfaceException
189
-     * @throws ReflectionException
190
-     */
191
-    public function __construct($routing = true)
192
-    {
193
-        $this->loader = LoaderFactory::getLoader();
194
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
195
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
196
-            $this->_is_caf = true;
197
-        }
198
-        $this->_yes_no_values = array(
199
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
200
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
201
-        );
202
-        // set the _req_data property.
203
-        $this->_req_data = array_merge($_GET, $_POST);
204
-        // routing enabled?
205
-        $this->_routing = $routing;
206
-    }
207
-
208
-
209
-    /**
210
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
211
-     * for child classes that needed to set properties prior to these methods getting called,
212
-     * but also needed the parent class to have its construction completed as well.
213
-     * Bottom line is that constructors should ONLY be used for setting initial properties
214
-     * and any complex initialization logic should only run after instantiation is complete.
215
-     *
216
-     * This method gets called immediately after construction from within
217
-     *      EE_Admin_Page_Init::_initialize_admin_page()
218
-     *
219
-     * @throws EE_Error
220
-     * @throws InvalidArgumentException
221
-     * @throws InvalidDataTypeException
222
-     * @throws InvalidInterfaceException
223
-     * @throws ReflectionException
224
-     * @since $VID:$
225
-     */
226
-    public function initializePage()
227
-    {
228
-        // set initial page props (child method)
229
-        $this->_init_page_props();
230
-        // set global defaults
231
-        $this->_set_defaults();
232
-        // set early because incoming requests could be ajax related and we need to register those hooks.
233
-        $this->_global_ajax_hooks();
234
-        $this->_ajax_hooks();
235
-        // other_page_hooks have to be early too.
236
-        $this->_do_other_page_hooks();
237
-        // This just allows us to have extending classes do something specific
238
-        // before the parent constructor runs _page_setup().
239
-        if (method_exists($this, '_before_page_setup')) {
240
-            $this->_before_page_setup();
241
-        }
242
-        // set up page dependencies
243
-        $this->_page_setup();
244
-    }
245
-
246
-
247
-    /**
248
-     * _init_page_props
249
-     * Child classes use to set at least the following properties:
250
-     * $page_slug.
251
-     * $page_label.
252
-     *
253
-     * @abstract
254
-     * @return void
255
-     */
256
-    abstract protected function _init_page_props();
257
-
258
-
259
-    /**
260
-     * _ajax_hooks
261
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
262
-     * Note: within the ajax callback methods.
263
-     *
264
-     * @abstract
265
-     * @return void
266
-     */
267
-    abstract protected function _ajax_hooks();
268
-
269
-
270
-    /**
271
-     * _define_page_props
272
-     * child classes define page properties in here.  Must include at least:
273
-     * $_admin_base_url = base_url for all admin pages
274
-     * $_admin_page_title = default admin_page_title for admin pages
275
-     * $_labels = array of default labels for various automatically generated elements:
276
-     *    array(
277
-     *        'buttons' => array(
278
-     *            'add' => esc_html__('label for add new button'),
279
-     *            'edit' => esc_html__('label for edit button'),
280
-     *            'delete' => esc_html__('label for delete button')
281
-     *            )
282
-     *        )
283
-     *
284
-     * @abstract
285
-     * @return void
286
-     */
287
-    abstract protected function _define_page_props();
288
-
289
-
290
-    /**
291
-     * _set_page_routes
292
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
293
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
294
-     * have a 'default' route. Here's the format
295
-     * $this->_page_routes = array(
296
-     *        'default' => array(
297
-     *            'func' => '_default_method_handling_route',
298
-     *            'args' => array('array','of','args'),
299
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
300
-     *            ajax request, backend processing)
301
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
302
-     *            headers route after.  The string you enter here should match the defined route reference for a
303
-     *            headers sent route.
304
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
305
-     *            this route.
306
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
307
-     *            checks).
308
-     *        ),
309
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
310
-     *        handling method.
311
-     *        )
312
-     * )
313
-     *
314
-     * @abstract
315
-     * @return void
316
-     */
317
-    abstract protected function _set_page_routes();
318
-
319
-
320
-    /**
321
-     * _set_page_config
322
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
323
-     * array corresponds to the page_route for the loaded page. Format:
324
-     * $this->_page_config = array(
325
-     *        'default' => array(
326
-     *            'labels' => array(
327
-     *                'buttons' => array(
328
-     *                    'add' => esc_html__('label for adding item'),
329
-     *                    'edit' => esc_html__('label for editing item'),
330
-     *                    'delete' => esc_html__('label for deleting item')
331
-     *                ),
332
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
333
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
334
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
335
-     *            _define_page_props() method
336
-     *            'nav' => array(
337
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
338
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
339
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
340
-     *                'order' => 10, //required to indicate tab position.
341
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
342
-     *                displayed then add this parameter.
343
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
344
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
345
-     *            metaboxes set for eventespresso admin pages.
346
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
347
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
348
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
349
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
350
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
351
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
352
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
353
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
354
-     *            want to display.
355
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
356
-     *                'tab_id' => array(
357
-     *                    'title' => 'tab_title',
358
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
359
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
360
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
361
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
362
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
363
-     *                    attempt to use the callback which should match the name of a method in the class
364
-     *                    ),
365
-     *                'tab2_id' => array(
366
-     *                    'title' => 'tab2 title',
367
-     *                    'filename' => 'file_name_2'
368
-     *                    'callback' => 'callback_method_for_content',
369
-     *                 ),
370
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
371
-     *            help tab area on an admin page. @link
372
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
373
-     *            'help_tour' => array(
374
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
375
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
376
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
377
-     *            ),
378
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
379
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
380
-     *            just set
381
-     *            'require_nonce' to FALSE
382
-     *            )
383
-     * )
384
-     *
385
-     * @abstract
386
-     * @return void
387
-     */
388
-    abstract protected function _set_page_config();
389
-
390
-
391
-
392
-
393
-
394
-    /** end sample help_tour methods **/
395
-    /**
396
-     * _add_screen_options
397
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
398
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
399
-     * to a particular view.
400
-     *
401
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
402
-     *         see also WP_Screen object documents...
403
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract protected function _add_screen_options();
408
-
409
-
410
-    /**
411
-     * _add_feature_pointers
412
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
413
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
414
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
415
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
416
-     * extended) also see:
417
-     *
418
-     * @link   http://eamann.com/tech/wordpress-portland/
419
-     * @abstract
420
-     * @return void
421
-     */
422
-    abstract protected function _add_feature_pointers();
423
-
424
-
425
-    /**
426
-     * load_scripts_styles
427
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
428
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
429
-     * scripts/styles per view by putting them in a dynamic function in this format
430
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
431
-     *
432
-     * @abstract
433
-     * @return void
434
-     */
435
-    abstract public function load_scripts_styles();
436
-
437
-
438
-    /**
439
-     * admin_init
440
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
441
-     * all pages/views loaded by child class.
442
-     *
443
-     * @abstract
444
-     * @return void
445
-     */
446
-    abstract public function admin_init();
447
-
448
-
449
-    /**
450
-     * admin_notices
451
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
452
-     * all pages/views loaded by child class.
453
-     *
454
-     * @abstract
455
-     * @return void
456
-     */
457
-    abstract public function admin_notices();
458
-
459
-
460
-    /**
461
-     * admin_footer_scripts
462
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
463
-     * will apply to all pages/views loaded by child class.
464
-     *
465
-     * @return void
466
-     */
467
-    abstract public function admin_footer_scripts();
468
-
469
-
470
-    /**
471
-     * admin_footer
472
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
473
-     * apply to all pages/views loaded by child class.
474
-     *
475
-     * @return void
476
-     */
477
-    public function admin_footer()
478
-    {
479
-    }
480
-
481
-
482
-    /**
483
-     * _global_ajax_hooks
484
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
485
-     * Note: within the ajax callback methods.
486
-     *
487
-     * @abstract
488
-     * @return void
489
-     */
490
-    protected function _global_ajax_hooks()
491
-    {
492
-        // for lazy loading of metabox content
493
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
494
-
495
-        add_action(
496
-            'wp_ajax_espresso_hide_status_change_notice',
497
-            [$this, 'hideStatusChangeNotice']
498
-        );
499
-        add_action(
500
-            'wp_ajax_nopriv_espresso_hide_status_change_notice',
501
-            [$this, 'hideStatusChangeNotice']
502
-        );
503
-    }
504
-
505
-
506
-    public function ajax_metabox_content()
507
-    {
508
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
509
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
510
-        EE_Admin_Page::cached_rss_display($contentid, $url);
511
-        wp_die();
512
-    }
513
-
514
-
515
-    public function hideStatusChangeNotice()
516
-    {
517
-        $response = [];
518
-        try {
519
-            /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
520
-            $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
521
-            $response['success'] = $status_change_notice->dismiss() > -1;
522
-        } catch (Exception $exception) {
523
-            $response['errors'] = $exception->getMessage();
524
-        }
525
-        echo wp_json_encode($response);
526
-        exit();
527
-    }
528
-
529
-
530
-    /**
531
-     * _page_setup
532
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
533
-     * doesn't match the object.
534
-     *
535
-     * @final
536
-     * @return void
537
-     * @throws EE_Error
538
-     * @throws InvalidArgumentException
539
-     * @throws ReflectionException
540
-     * @throws InvalidDataTypeException
541
-     * @throws InvalidInterfaceException
542
-     */
543
-    final protected function _page_setup()
544
-    {
545
-        // requires?
546
-        // admin_init stuff - global - we're setting this REALLY early
547
-        // so if EE_Admin pages have to hook into other WP pages they can.
548
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
549
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
550
-        // next verify if we need to load anything...
551
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
552
-        $this->page_folder = strtolower(
553
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
554
-        );
555
-        global $ee_menu_slugs;
556
-        $ee_menu_slugs = (array) $ee_menu_slugs;
557
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
558
-            return;
559
-        }
560
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
561
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
562
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
563
-                ? $this->_req_data['action2']
564
-                : $this->_req_data['action'];
565
-        }
566
-        // then set blank or -1 action values to 'default'
567
-        $this->_req_action = isset($this->_req_data['action'])
568
-                             && ! empty($this->_req_data['action'])
569
-                             && $this->_req_data['action'] !== '-1'
570
-            ? sanitize_key($this->_req_data['action'])
571
-            : 'default';
572
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
573
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
574
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
575
-            ? $this->_req_data['route'] : $this->_req_action;
576
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
577
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
578
-            ? $this->_req_data['route']
579
-            : $this->_req_action;
580
-        $this->_current_view = $this->_req_action;
581
-        $this->_req_nonce = $this->_req_action . '_nonce';
582
-        $this->_define_page_props();
583
-        $this->_current_page_view_url = add_query_arg(
584
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
585
-            $this->_admin_base_url
586
-        );
587
-        // default things
588
-        $this->_default_espresso_metaboxes = array(
589
-            '_espresso_news_post_box',
590
-            '_espresso_links_post_box',
591
-            '_espresso_ratings_request',
592
-            '_espresso_sponsors_post_box',
593
-        );
594
-        // set page configs
595
-        $this->_set_page_routes();
596
-        $this->_set_page_config();
597
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
598
-        if (isset($this->_req_data['wp_referer'])) {
599
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
600
-        }
601
-        // for caffeinated and other extended functionality.
602
-        //  If there is a _extend_page_config method
603
-        // then let's run that to modify the all the various page configuration arrays
604
-        if (method_exists($this, '_extend_page_config')) {
605
-            $this->_extend_page_config();
606
-        }
607
-        // for CPT and other extended functionality.
608
-        // If there is an _extend_page_config_for_cpt
609
-        // then let's run that to modify all the various page configuration arrays.
610
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
611
-            $this->_extend_page_config_for_cpt();
612
-        }
613
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
614
-        $this->_page_routes = apply_filters(
615
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
616
-            $this->_page_routes,
617
-            $this
618
-        );
619
-        $this->_page_config = apply_filters(
620
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
621
-            $this->_page_config,
622
-            $this
623
-        );
624
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
625
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
626
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
627
-            add_action(
628
-                'AHEE__EE_Admin_Page__route_admin_request',
629
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
630
-                10,
631
-                2
632
-            );
633
-        }
634
-        // next route only if routing enabled
635
-        if ($this->_routing && ! defined('DOING_AJAX')) {
636
-            $this->_verify_routes();
637
-            // next let's just check user_access and kill if no access
638
-            $this->check_user_access();
639
-            if ($this->_is_UI_request) {
640
-                // admin_init stuff - global, all views for this page class, specific view
641
-                add_action('admin_init', array($this, 'admin_init'), 10);
642
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
643
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
644
-                }
645
-            } else {
646
-                // hijack regular WP loading and route admin request immediately
647
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
648
-                $this->route_admin_request();
649
-            }
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
656
-     *
657
-     * @return void
658
-     * @throws EE_Error
659
-     */
660
-    private function _do_other_page_hooks()
661
-    {
662
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
663
-        foreach ($registered_pages as $page) {
664
-            // now let's setup the file name and class that should be present
665
-            $classname = str_replace('.class.php', '', $page);
666
-            // autoloaders should take care of loading file
667
-            if (! class_exists($classname)) {
668
-                $error_msg[] = sprintf(
669
-                    esc_html__(
670
-                        'Something went wrong with loading the %s admin hooks page.',
671
-                        'event_espresso'
672
-                    ),
673
-                    $page
674
-                );
675
-                $error_msg[] = $error_msg[0]
676
-                               . "\r\n"
677
-                               . sprintf(
678
-                                   esc_html__(
679
-                                       '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',
680
-                                       'event_espresso'
681
-                                   ),
682
-                                   $page,
683
-                                   '<br />',
684
-                                   '<strong>' . $classname . '</strong>'
685
-                               );
686
-                throw new EE_Error(implode('||', $error_msg));
687
-            }
688
-            // // notice we are passing the instance of this class to the hook object.
689
-            $this->loader->getShared($classname, [$this]);
690
-        }
691
-    }
692
-
693
-
694
-    /**
695
-     * @throws DomainException
696
-     * @throws EE_Error
697
-     * @throws InvalidArgumentException
698
-     * @throws InvalidDataTypeException
699
-     * @throws InvalidInterfaceException
700
-     * @throws ReflectionException
701
-     * @since $VID:$
702
-     */
703
-    public function load_page_dependencies()
704
-    {
705
-        try {
706
-            $this->_load_page_dependencies();
707
-        } catch (EE_Error $e) {
708
-            $e->get_error();
709
-        }
710
-    }
711
-
712
-
713
-    /**
714
-     * load_page_dependencies
715
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
716
-     *
717
-     * @return void
718
-     * @throws DomainException
719
-     * @throws EE_Error
720
-     * @throws InvalidArgumentException
721
-     * @throws InvalidDataTypeException
722
-     * @throws InvalidInterfaceException
723
-     * @throws ReflectionException
724
-     */
725
-    protected function _load_page_dependencies()
726
-    {
727
-        // let's set the current_screen and screen options to override what WP set
728
-        $this->_current_screen = get_current_screen();
729
-        // load admin_notices - global, page class, and view specific
730
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
731
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
732
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
733
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
734
-        }
735
-        // load network admin_notices - global, page class, and view specific
736
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
737
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
738
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
739
-        }
740
-        // this will save any per_page screen options if they are present
741
-        $this->_set_per_page_screen_options();
742
-        // setup list table properties
743
-        $this->_set_list_table();
744
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
745
-        // However in some cases the metaboxes will need to be added within a route handling callback.
746
-        $this->_add_registered_meta_boxes();
747
-        $this->_add_screen_columns();
748
-        // add screen options - global, page child class, and view specific
749
-        $this->_add_global_screen_options();
750
-        $this->_add_screen_options();
751
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
752
-        if (method_exists($this, $add_screen_options)) {
753
-            $this->{$add_screen_options}();
754
-        }
755
-        // add help tab(s) and tours- set via page_config and qtips.
756
-        $this->_add_help_tour();
757
-        $this->_add_help_tabs();
758
-        $this->_add_qtips();
759
-        // add feature_pointers - global, page child class, and view specific
760
-        $this->_add_feature_pointers();
761
-        $this->_add_global_feature_pointers();
762
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
763
-        if (method_exists($this, $add_feature_pointer)) {
764
-            $this->{$add_feature_pointer}();
765
-        }
766
-        // enqueue scripts/styles - global, page class, and view specific
767
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
768
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
769
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
770
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
771
-        }
772
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
773
-        // admin_print_footer_scripts - global, page child class, and view specific.
774
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
775
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
776
-        // is a good use case. Notice the late priority we're giving these
777
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
778
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
779
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
780
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
781
-        }
782
-        // admin footer scripts
783
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
784
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
785
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
786
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
787
-        }
788
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
789
-        // targeted hook
790
-        do_action(
791
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
792
-        );
793
-    }
794
-
795
-
796
-    /**
797
-     * _set_defaults
798
-     * This sets some global defaults for class properties.
799
-     */
800
-    private function _set_defaults()
801
-    {
802
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
803
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
804
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
805
-        $this->_page_config = $this->_default_route_query_args = array();
806
-        $this->_default_nav_tab_name = 'overview';
807
-        // init template args
808
-        $this->_template_args = array(
809
-            'admin_page_header'  => '',
810
-            'admin_page_content' => '',
811
-            'post_body_content'  => '',
812
-            'before_list_table'  => '',
813
-            'after_list_table'   => '',
814
-        );
815
-    }
816
-
817
-
818
-    /**
819
-     * route_admin_request
820
-     *
821
-     * @see    _route_admin_request()
822
-     * @return exception|void error
823
-     * @throws InvalidArgumentException
824
-     * @throws InvalidInterfaceException
825
-     * @throws InvalidDataTypeException
826
-     * @throws EE_Error
827
-     * @throws ReflectionException
828
-     */
829
-    public function route_admin_request()
830
-    {
831
-        try {
832
-            $this->_route_admin_request();
833
-        } catch (EE_Error $e) {
834
-            $e->get_error();
835
-        }
836
-    }
837
-
838
-
839
-    public function set_wp_page_slug($wp_page_slug)
840
-    {
841
-        $this->_wp_page_slug = $wp_page_slug;
842
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
843
-        if (is_network_admin()) {
844
-            $this->_wp_page_slug .= '-network';
845
-        }
846
-    }
847
-
848
-
849
-    /**
850
-     * _verify_routes
851
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
852
-     * we know if we need to drop out.
853
-     *
854
-     * @return bool
855
-     * @throws EE_Error
856
-     */
857
-    protected function _verify_routes()
858
-    {
859
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
860
-            return false;
861
-        }
862
-        $this->_route = false;
863
-        // check that the page_routes array is not empty
864
-        if (empty($this->_page_routes)) {
865
-            // user error msg
866
-            $error_msg = sprintf(
867
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
868
-                $this->_admin_page_title
869
-            );
870
-            // developer error msg
871
-            $error_msg .= '||' . $error_msg
872
-                          . esc_html__(
873
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
874
-                              'event_espresso'
875
-                          );
876
-            throw new EE_Error($error_msg);
877
-        }
878
-        // and that the requested page route exists
879
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
880
-            $this->_route = $this->_page_routes[ $this->_req_action ];
881
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
882
-                ? $this->_page_config[ $this->_req_action ] : array();
883
-        } else {
884
-            // user error msg
885
-            $error_msg = sprintf(
886
-                esc_html__(
887
-                    'The requested page route does not exist for the %s admin page.',
888
-                    'event_espresso'
889
-                ),
890
-                $this->_admin_page_title
891
-            );
892
-            // developer error msg
893
-            $error_msg .= '||' . $error_msg
894
-                          . sprintf(
895
-                              esc_html__(
896
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
897
-                                  'event_espresso'
898
-                              ),
899
-                              $this->_req_action
900
-                          );
901
-            throw new EE_Error($error_msg);
902
-        }
903
-        // and that a default route exists
904
-        if (! array_key_exists('default', $this->_page_routes)) {
905
-            // user error msg
906
-            $error_msg = sprintf(
907
-                esc_html__(
908
-                    'A default page route has not been set for the % admin page.',
909
-                    'event_espresso'
910
-                ),
911
-                $this->_admin_page_title
912
-            );
913
-            // developer error msg
914
-            $error_msg .= '||' . $error_msg
915
-                          . esc_html__(
916
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
917
-                              'event_espresso'
918
-                          );
919
-            throw new EE_Error($error_msg);
920
-        }
921
-
922
-        // first lets' catch if the UI request has EVER been set.
923
-        if ($this->_is_UI_request === null) {
924
-            // lets set if this is a UI request or not.
925
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
926
-            // wait a minute... we might have a noheader in the route array
927
-            $this->_is_UI_request = is_array($this->_route)
928
-                                    && isset($this->_route['noheader'])
929
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
930
-        }
931
-        $this->_set_current_labels();
932
-        return true;
933
-    }
934
-
935
-
936
-    /**
937
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
938
-     *
939
-     * @param  string $route the route name we're verifying
940
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
941
-     * @throws EE_Error
942
-     */
943
-    protected function _verify_route($route)
944
-    {
945
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
946
-            return true;
947
-        }
948
-        // user error msg
949
-        $error_msg = sprintf(
950
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
951
-            $this->_admin_page_title
952
-        );
953
-        // developer error msg
954
-        $error_msg .= '||' . $error_msg
955
-                      . sprintf(
956
-                          esc_html__(
957
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
958
-                              'event_espresso'
959
-                          ),
960
-                          $route
961
-                      );
962
-        throw new EE_Error($error_msg);
963
-    }
964
-
965
-
966
-    /**
967
-     * perform nonce verification
968
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
969
-     * using this method (and save retyping!)
970
-     *
971
-     * @param string $nonce     The nonce sent
972
-     * @param string $nonce_ref The nonce reference string (name0)
973
-     * @return void
974
-     * @throws EE_Error
975
-     * @throws InvalidArgumentException
976
-     * @throws InvalidDataTypeException
977
-     * @throws InvalidInterfaceException
978
-     */
979
-    protected function _verify_nonce($nonce, $nonce_ref)
980
-    {
981
-        // verify nonce against expected value
982
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
983
-            // these are not the droids you are looking for !!!
984
-            $msg = sprintf(
985
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
986
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
987
-                '</a>'
988
-            );
989
-            if (WP_DEBUG) {
990
-                $msg .= "\n  "
991
-                        . sprintf(
992
-                            esc_html__(
993
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
994
-                                'event_espresso'
995
-                            ),
996
-                            EE_Admin_Page::class
997
-                        );
998
-            }
999
-            if (! defined('DOING_AJAX')) {
1000
-                wp_die($msg);
1001
-            } else {
1002
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1003
-                $this->_return_json();
1004
-            }
1005
-        }
1006
-    }
1007
-
1008
-
1009
-    /**
1010
-     * _route_admin_request()
1011
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1012
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1013
-     * in the page routes and then will try to load the corresponding method.
1014
-     *
1015
-     * @return void
1016
-     * @throws EE_Error
1017
-     * @throws InvalidArgumentException
1018
-     * @throws InvalidDataTypeException
1019
-     * @throws InvalidInterfaceException
1020
-     * @throws ReflectionException
1021
-     */
1022
-    protected function _route_admin_request()
1023
-    {
1024
-        if (! $this->_is_UI_request) {
1025
-            $this->_verify_routes();
1026
-        }
1027
-        $nonce_check = isset($this->_route_config['require_nonce'])
1028
-            ? $this->_route_config['require_nonce']
1029
-            : true;
1030
-        if ($this->_req_action !== 'default' && $nonce_check) {
1031
-            // set nonce from post data
1032
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
1033
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1034
-                : '';
1035
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1036
-        }
1037
-        // set the nav_tabs array but ONLY if this is  UI_request
1038
-        if ($this->_is_UI_request) {
1039
-            $this->_set_nav_tabs();
1040
-        }
1041
-        // grab callback function
1042
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1043
-        // check if callback has args
1044
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1045
-        $error_msg = '';
1046
-        // action right before calling route
1047
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1048
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1049
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1050
-        }
1051
-        // right before calling the route, let's remove _wp_http_referer from the
1052
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1053
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
1054
-            '_wp_http_referer',
1055
-            wp_unslash($_SERVER['REQUEST_URI'])
1056
-        );
1057
-        if (! empty($func)) {
1058
-            if (is_array($func)) {
1059
-                list($class, $method) = $func;
1060
-            } elseif (strpos($func, '::') !== false) {
1061
-                list($class, $method) = explode('::', $func);
1062
-            } else {
1063
-                $class = $this;
1064
-                $method = $func;
1065
-            }
1066
-            if (! (is_object($class) && $class === $this)) {
1067
-                // send along this admin page object for access by addons.
1068
-                $args['admin_page_object'] = $this;
1069
-            }
1070
-            // is it a method on a class that doesn't work?
1071
-            if (((method_exists($class, $method)
1072
-                  && call_user_func_array(array($class, $method), $args) === false)
1073
-                 && (// is it a standalone function that doesn't work?
1074
-                     function_exists($method)
1075
-                     && call_user_func_array(
1076
-                         $func,
1077
-                         array_merge(array('admin_page_object' => $this), $args)
1078
-                     ) === false
1079
-                 )) || (// is it neither a class method NOR a standalone function?
1080
-                    ! function_exists($method)
1081
-                    && ! method_exists($class, $method)
1082
-                )
1083
-            ) {
1084
-                // user error msg
1085
-                $error_msg = esc_html__(
1086
-                    'An error occurred. The  requested page route could not be found.',
1087
-                    'event_espresso'
1088
-                );
1089
-                // developer error msg
1090
-                $error_msg .= '||';
1091
-                $error_msg .= sprintf(
1092
-                    esc_html__(
1093
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1094
-                        'event_espresso'
1095
-                    ),
1096
-                    $method
1097
-                );
1098
-            }
1099
-            if (! empty($error_msg)) {
1100
-                throw new EE_Error($error_msg);
1101
-            }
1102
-        }
1103
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1104
-        // then we need to reset the routing properties to the new route.
1105
-        // 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.
1106
-        if ($this->_is_UI_request === false
1107
-            && is_array($this->_route)
1108
-            && ! empty($this->_route['headers_sent_route'])
1109
-        ) {
1110
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1111
-        }
1112
-    }
1113
-
1114
-
1115
-    /**
1116
-     * This method just allows the resetting of page properties in the case where a no headers
1117
-     * route redirects to a headers route in its route config.
1118
-     *
1119
-     * @since   4.3.0
1120
-     * @param  string $new_route New (non header) route to redirect to.
1121
-     * @return   void
1122
-     * @throws ReflectionException
1123
-     * @throws InvalidArgumentException
1124
-     * @throws InvalidInterfaceException
1125
-     * @throws InvalidDataTypeException
1126
-     * @throws EE_Error
1127
-     */
1128
-    protected function _reset_routing_properties($new_route)
1129
-    {
1130
-        $this->_is_UI_request = true;
1131
-        // now we set the current route to whatever the headers_sent_route is set at
1132
-        $this->_req_data['action'] = $new_route;
1133
-        // rerun page setup
1134
-        $this->_page_setup();
1135
-    }
1136
-
1137
-
1138
-    /**
1139
-     * _add_query_arg
1140
-     * adds nonce to array of arguments then calls WP add_query_arg function
1141
-     *(internally just uses EEH_URL's function with the same name)
1142
-     *
1143
-     * @param array  $args
1144
-     * @param string $url
1145
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1146
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1147
-     *                                        Example usage: If the current page is:
1148
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1149
-     *                                        &action=default&event_id=20&month_range=March%202015
1150
-     *                                        &_wpnonce=5467821
1151
-     *                                        and you call:
1152
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1153
-     *                                        array(
1154
-     *                                        'action' => 'resend_something',
1155
-     *                                        'page=>espresso_registrations'
1156
-     *                                        ),
1157
-     *                                        $some_url,
1158
-     *                                        true
1159
-     *                                        );
1160
-     *                                        It will produce a url in this structure:
1161
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1162
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1163
-     *                                        month_range]=March%202015
1164
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1165
-     * @return string
1166
-     */
1167
-    public static function add_query_args_and_nonce(
1168
-        $args = array(),
1169
-        $url = '',
1170
-        $sticky = false,
1171
-        $exclude_nonce = false
1172
-    ) {
1173
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1174
-        if ($sticky) {
1175
-            $request = $_REQUEST;
1176
-            unset($request['_wp_http_referer'], $request['wp_referer']);
1177
-            foreach ($request as $key => $value) {
1178
-                // do not add nonces
1179
-                if (strpos($key, 'nonce') !== false) {
1180
-                    continue;
1181
-                }
1182
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1183
-            }
1184
-        }
1185
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1186
-    }
1187
-
1188
-
1189
-    /**
1190
-     * This returns a generated link that will load the related help tab.
1191
-     *
1192
-     * @param  string $help_tab_id the id for the connected help tab
1193
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1194
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1195
-     * @uses EEH_Template::get_help_tab_link()
1196
-     * @return string              generated link
1197
-     */
1198
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1199
-    {
1200
-        return EEH_Template::get_help_tab_link(
1201
-            $help_tab_id,
1202
-            $this->page_slug,
1203
-            $this->_req_action,
1204
-            $icon_style,
1205
-            $help_text
1206
-        );
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * _add_help_tabs
1212
-     * Note child classes define their help tabs within the page_config array.
1213
-     *
1214
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1215
-     * @return void
1216
-     * @throws DomainException
1217
-     * @throws EE_Error
1218
-     * @throws ReflectionException
1219
-     */
1220
-    protected function _add_help_tabs()
1221
-    {
1222
-        $tour_buttons = '';
1223
-        if (isset($this->_page_config[ $this->_req_action ])) {
1224
-            $config = $this->_page_config[ $this->_req_action ];
1225
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1226
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1227
-                $tb = array();
1228
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1229
-                foreach ($this->_help_tour['tours'] as $tour) {
1230
-                    // if this is the end tour then we don't need to setup a button
1231
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1232
-                        continue;
1233
-                    }
1234
-                    $tb[] = '<button id="trigger-tour-'
1235
-                            . $tour->get_slug()
1236
-                            . '" class="button-primary trigger-ee-help-tour">'
1237
-                            . $tour->get_label()
1238
-                            . '</button>';
1239
-                }
1240
-                $tour_buttons .= implode('<br />', $tb);
1241
-                $tour_buttons .= '</div></div>';
1242
-            }
1243
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1244
-            if (is_array($config) && isset($config['help_sidebar'])) {
1245
-                // check that the callback given is valid
1246
-                if (! method_exists($this, $config['help_sidebar'])) {
1247
-                    throw new EE_Error(
1248
-                        sprintf(
1249
-                            esc_html__(
1250
-                                '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',
1251
-                                'event_espresso'
1252
-                            ),
1253
-                            $config['help_sidebar'],
1254
-                            get_class($this)
1255
-                        )
1256
-                    );
1257
-                }
1258
-                $content = apply_filters(
1259
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1260
-                    $this->{$config['help_sidebar']}()
1261
-                );
1262
-                $content .= $tour_buttons; // add help tour buttons.
1263
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1264
-                $this->_current_screen->set_help_sidebar($content);
1265
-            }
1266
-            // if there ARE tour buttons...
1267
-            if (! empty($tour_buttons)) {
1268
-                // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1269
-                if (! isset($config['help_sidebar'])) {
1270
-                    $this->_current_screen->set_help_sidebar($tour_buttons);
1271
-                }
1272
-                // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1273
-                if (! isset($config['help_tabs'])) {
1274
-                    $_ht['id'] = $this->page_slug;
1275
-                    $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1276
-                    $_ht['content'] = '<p>'
1277
-                                      . esc_html__(
1278
-                                          'The buttons to the right allow you to start/restart any help tours available for this page',
1279
-                                          'event_espresso'
1280
-                                      ) . '</p>';
1281
-                    $this->_current_screen->add_help_tab($_ht);
1282
-                }
1283
-            }
1284
-            if (! isset($config['help_tabs'])) {
1285
-                return;
1286
-            } //no help tabs for this route
1287
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1288
-                // we're here so there ARE help tabs!
1289
-                // make sure we've got what we need
1290
-                if (! isset($cfg['title'])) {
1291
-                    throw new EE_Error(
1292
-                        esc_html__(
1293
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1294
-                            'event_espresso'
1295
-                        )
1296
-                    );
1297
-                }
1298
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1299
-                    throw new EE_Error(
1300
-                        esc_html__(
1301
-                            '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',
1302
-                            'event_espresso'
1303
-                        )
1304
-                    );
1305
-                }
1306
-                // first priority goes to content.
1307
-                if (! empty($cfg['content'])) {
1308
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1309
-                    // second priority goes to filename
1310
-                } elseif (! empty($cfg['filename'])) {
1311
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1312
-                    // 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)
1313
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1314
-                                                             . basename($this->_get_dir())
1315
-                                                             . '/help_tabs/'
1316
-                                                             . $cfg['filename']
1317
-                                                             . '.help_tab.php' : $file_path;
1318
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1319
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1320
-                        EE_Error::add_error(
1321
-                            sprintf(
1322
-                                esc_html__(
1323
-                                    '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',
1324
-                                    'event_espresso'
1325
-                                ),
1326
-                                $tab_id,
1327
-                                key($config),
1328
-                                $file_path
1329
-                            ),
1330
-                            __FILE__,
1331
-                            __FUNCTION__,
1332
-                            __LINE__
1333
-                        );
1334
-                        return;
1335
-                    }
1336
-                    $template_args['admin_page_obj'] = $this;
1337
-                    $content = EEH_Template::display_template(
1338
-                        $file_path,
1339
-                        $template_args,
1340
-                        true
1341
-                    );
1342
-                } else {
1343
-                    $content = '';
1344
-                }
1345
-                // check if callback is valid
1346
-                if (empty($content) && (
1347
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1348
-                    )
1349
-                ) {
1350
-                    EE_Error::add_error(
1351
-                        sprintf(
1352
-                            esc_html__(
1353
-                                '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.',
1354
-                                'event_espresso'
1355
-                            ),
1356
-                            $cfg['title']
1357
-                        ),
1358
-                        __FILE__,
1359
-                        __FUNCTION__,
1360
-                        __LINE__
1361
-                    );
1362
-                    return;
1363
-                }
1364
-                // setup config array for help tab method
1365
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1366
-                $_ht = array(
1367
-                    'id'       => $id,
1368
-                    'title'    => $cfg['title'],
1369
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1370
-                    'content'  => $content,
1371
-                );
1372
-                $this->_current_screen->add_help_tab($_ht);
1373
-            }
1374
-        }
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1380
-     * an array with properties for setting up usage of the joyride plugin
1381
-     *
1382
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1383
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1384
-     *         _set_page_config() comments
1385
-     * @return void
1386
-     * @throws EE_Error
1387
-     * @throws InvalidArgumentException
1388
-     * @throws InvalidDataTypeException
1389
-     * @throws InvalidInterfaceException
1390
-     * @throws ReflectionException
1391
-     */
1392
-    protected function _add_help_tour()
1393
-    {
1394
-        $tours = array();
1395
-        $this->_help_tour = array();
1396
-        // exit early if help tours are turned off globally
1397
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1398
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1399
-        ) {
1400
-            return;
1401
-        }
1402
-        // loop through _page_config to find any help_tour defined
1403
-        foreach ($this->_page_config as $route => $config) {
1404
-            // we're only going to set things up for this route
1405
-            if ($route !== $this->_req_action) {
1406
-                continue;
1407
-            }
1408
-            if (isset($config['help_tour'])) {
1409
-                foreach ($config['help_tour'] as $tour) {
1410
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1411
-                    // let's see if we can get that file...
1412
-                    // if not its possible this is a decaf route not set in caffeinated
1413
-                    // so lets try and get the caffeinated equivalent
1414
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1415
-                                                             . basename($this->_get_dir())
1416
-                                                             . '/help_tours/'
1417
-                                                             . $tour
1418
-                                                             . '.class.php' : $file_path;
1419
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1420
-                    if (! is_readable($file_path)) {
1421
-                        EE_Error::add_error(
1422
-                            sprintf(
1423
-                                esc_html__(
1424
-                                    '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',
1425
-                                    'event_espresso'
1426
-                                ),
1427
-                                $file_path,
1428
-                                $tour
1429
-                            ),
1430
-                            __FILE__,
1431
-                            __FUNCTION__,
1432
-                            __LINE__
1433
-                        );
1434
-                        return;
1435
-                    }
1436
-                    require_once $file_path;
1437
-                    if (! class_exists($tour)) {
1438
-                        $error_msg = [];
1439
-                        $error_msg[] = sprintf(
1440
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1441
-                            $tour
1442
-                        );
1443
-                        $error_msg[] = $error_msg[0] . "\r\n"
1444
-                                       . sprintf(
1445
-                                           esc_html__(
1446
-                                               '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.',
1447
-                                               'event_espresso'
1448
-                                           ),
1449
-                                           $tour,
1450
-                                           '<br />',
1451
-                                           $tour,
1452
-                                           $this->_req_action,
1453
-                                           get_class($this)
1454
-                                       );
1455
-                        throw new EE_Error(implode('||', $error_msg));
1456
-                    }
1457
-                    $tour_obj = new $tour($this->_is_caf);
1458
-                    $tours[] = $tour_obj;
1459
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1460
-                }
1461
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1462
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1463
-                $tours[] = $end_stop_tour;
1464
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1465
-            }
1466
-        }
1467
-
1468
-        if (! empty($tours)) {
1469
-            $this->_help_tour['tours'] = $tours;
1470
-        }
1471
-        // that's it!  Now that the $_help_tours property is set (or not)
1472
-        // the scripts and html should be taken care of automatically.
1473
-
1474
-        /**
1475
-         * Allow extending the help tours variable.
1476
-         *
1477
-         * @param array $_help_tour The array containing all help tour information to be displayed.
1478
-         */
1479
-        $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1480
-    }
1481
-
1482
-
1483
-    /**
1484
-     * This simply sets up any qtips that have been defined in the page config
1485
-     *
1486
-     * @return void
1487
-     * @throws ReflectionException
1488
-     * @throws EE_Error
1489
-     */
1490
-    protected function _add_qtips()
1491
-    {
1492
-        if (isset($this->_route_config['qtips'])) {
1493
-            $qtips = (array) $this->_route_config['qtips'];
1494
-            // load qtip loader
1495
-            $path = array(
1496
-                $this->_get_dir() . '/qtips/',
1497
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1498
-            );
1499
-            $qtip_loader = EEH_Qtip_Loader::instance();
1500
-            if ($qtip_loader instanceof EEH_Qtip_Loader) {
1501
-                $qtip_loader->register($qtips, $path);
1502
-            }
1503
-        }
1504
-    }
1505
-
1506
-
1507
-    /**
1508
-     * _set_nav_tabs
1509
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1510
-     * wish to add additional tabs or modify accordingly.
1511
-     *
1512
-     * @return void
1513
-     * @throws InvalidArgumentException
1514
-     * @throws InvalidInterfaceException
1515
-     * @throws InvalidDataTypeException
1516
-     */
1517
-    protected function _set_nav_tabs()
1518
-    {
1519
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1520
-        $i = 0;
1521
-        foreach ($this->_page_config as $slug => $config) {
1522
-            if (! is_array($config)
1523
-                || (
1524
-                    is_array($config)
1525
-                    && (
1526
-                        (isset($config['nav']) && ! $config['nav'])
1527
-                        || ! isset($config['nav'])
1528
-                    )
1529
-                )
1530
-            ) {
1531
-                continue;
1532
-            }
1533
-            // no nav tab for this config
1534
-            // check for persistent flag
1535
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1536
-                // nav tab is only to appear when route requested.
1537
-                continue;
1538
-            }
1539
-            if (! $this->check_user_access($slug, true)) {
1540
-                // no nav tab because current user does not have access.
1541
-                continue;
1542
-            }
1543
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1544
-            $this->_nav_tabs[ $slug ] = array(
1545
-                'url'       => isset($config['nav']['url'])
1546
-                    ? $config['nav']['url']
1547
-                    : EE_Admin_Page::add_query_args_and_nonce(
1548
-                        array('action' => $slug),
1549
-                        $this->_admin_base_url
1550
-                    ),
1551
-                'link_text' => isset($config['nav']['label'])
1552
-                    ? $config['nav']['label']
1553
-                    : ucwords(
1554
-                        str_replace('_', ' ', $slug)
1555
-                    ),
1556
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1557
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1558
-            );
1559
-            $i++;
1560
-        }
1561
-        // if $this->_nav_tabs is empty then lets set the default
1562
-        if (empty($this->_nav_tabs)) {
1563
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1564
-                'url'       => $this->_admin_base_url,
1565
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1566
-                'css_class' => 'nav-tab-active',
1567
-                'order'     => 10,
1568
-            );
1569
-        }
1570
-        // now let's sort the tabs according to order
1571
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1572
-    }
1573
-
1574
-
1575
-    /**
1576
-     * _set_current_labels
1577
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1578
-     * property array
1579
-     *
1580
-     * @return void
1581
-     */
1582
-    private function _set_current_labels()
1583
-    {
1584
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1585
-            foreach ($this->_route_config['labels'] as $label => $text) {
1586
-                if (is_array($text)) {
1587
-                    foreach ($text as $sublabel => $subtext) {
1588
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1589
-                    }
1590
-                } else {
1591
-                    $this->_labels[ $label ] = $text;
1592
-                }
1593
-            }
1594
-        }
1595
-    }
1596
-
1597
-
1598
-    /**
1599
-     *        verifies user access for this admin page
1600
-     *
1601
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1602
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1603
-     *                               return false if verify fail.
1604
-     * @return bool
1605
-     * @throws InvalidArgumentException
1606
-     * @throws InvalidDataTypeException
1607
-     * @throws InvalidInterfaceException
1608
-     */
1609
-    public function check_user_access($route_to_check = '', $verify_only = false)
1610
-    {
1611
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1612
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1613
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1614
-                      && is_array(
1615
-                          $this->_page_routes[ $route_to_check ]
1616
-                      )
1617
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1618
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1619
-        if (empty($capability) && empty($route_to_check)) {
1620
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1621
-                : $this->_route['capability'];
1622
-        } else {
1623
-            $capability = empty($capability) ? 'manage_options' : $capability;
1624
-        }
1625
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1626
-        if (! defined('DOING_AJAX')
1627
-            && (
1628
-                ! function_exists('is_admin')
1629
-                || ! EE_Registry::instance()->CAP->current_user_can(
1630
-                    $capability,
1631
-                    $this->page_slug
1632
-                    . '_'
1633
-                    . $route_to_check,
1634
-                    $id
1635
-                )
1636
-            )
1637
-        ) {
1638
-            if ($verify_only) {
1639
-                return false;
1640
-            }
1641
-            if (is_user_logged_in()) {
1642
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1643
-            } else {
1644
-                return false;
1645
-            }
1646
-        }
1647
-        return true;
1648
-    }
1649
-
1650
-
1651
-    /**
1652
-     * admin_init_global
1653
-     * This runs all the code that we want executed within the WP admin_init hook.
1654
-     * This method executes for ALL EE Admin pages.
1655
-     *
1656
-     * @return void
1657
-     */
1658
-    public function admin_init_global()
1659
-    {
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     * wp_loaded_global
1665
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1666
-     * EE_Admin page and will execute on every EE Admin Page load
1667
-     *
1668
-     * @return void
1669
-     */
1670
-    public function wp_loaded()
1671
-    {
1672
-    }
1673
-
1674
-
1675
-    /**
1676
-     * admin_notices
1677
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1678
-     * ALL EE_Admin pages.
1679
-     *
1680
-     * @return void
1681
-     */
1682
-    public function admin_notices_global()
1683
-    {
1684
-        $this->_display_no_javascript_warning();
1685
-        $this->_display_espresso_notices();
1686
-    }
1687
-
1688
-
1689
-    public function network_admin_notices_global()
1690
-    {
1691
-        $this->_display_no_javascript_warning();
1692
-        $this->_display_espresso_notices();
1693
-    }
1694
-
1695
-
1696
-    /**
1697
-     * admin_footer_scripts_global
1698
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1699
-     * will apply on ALL EE_Admin pages.
1700
-     *
1701
-     * @return void
1702
-     */
1703
-    public function admin_footer_scripts_global()
1704
-    {
1705
-        $this->_add_admin_page_ajax_loading_img();
1706
-        $this->_add_admin_page_overlay();
1707
-        // if metaboxes are present we need to add the nonce field
1708
-        if (isset($this->_route_config['metaboxes'])
1709
-            || isset($this->_route_config['list_table'])
1710
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1711
-        ) {
1712
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1713
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1714
-        }
1715
-    }
1716
-
1717
-
1718
-    /**
1719
-     * admin_footer_global
1720
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1721
-     * This particular method will apply on ALL EE_Admin Pages.
1722
-     *
1723
-     * @return void
1724
-     * @throws InvalidArgumentException
1725
-     * @throws InvalidDataTypeException
1726
-     * @throws InvalidInterfaceException
1727
-     */
1728
-    public function admin_footer_global()
1729
-    {
1730
-        // dialog container for dialog helper
1731
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1732
-        $d_cont .= '<div class="ee-notices"></div>';
1733
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1734
-        $d_cont .= '</div>';
1735
-        echo $d_cont;
1736
-        // help tour stuff?
1737
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1738
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1739
-        }
1740
-        // current set timezone for timezone js
1741
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1747
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1748
-     * help popups then in your templates or your content you set "triggers" for the content using the
1749
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1750
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1751
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1752
-     * for the
1753
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1754
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1755
-     *    'help_trigger_id' => array(
1756
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1757
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1758
-     *    )
1759
-     * );
1760
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1761
-     *
1762
-     * @param array $help_array
1763
-     * @param bool  $display
1764
-     * @return string content
1765
-     * @throws DomainException
1766
-     * @throws EE_Error
1767
-     */
1768
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1769
-    {
1770
-        $content = '';
1771
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1772
-        // loop through the array and setup content
1773
-        foreach ($help_array as $trigger => $help) {
1774
-            // make sure the array is setup properly
1775
-            if (! isset($help['title'], $help['content'])) {
1776
-                throw new EE_Error(
1777
-                    esc_html__(
1778
-                        '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',
1779
-                        'event_espresso'
1780
-                    )
1781
-                );
1782
-            }
1783
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1784
-            $template_args = array(
1785
-                'help_popup_id'      => $trigger,
1786
-                'help_popup_title'   => $help['title'],
1787
-                'help_popup_content' => $help['content'],
1788
-            );
1789
-            $content .= EEH_Template::display_template(
1790
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1791
-                $template_args,
1792
-                true
1793
-            );
1794
-        }
1795
-        if ($display) {
1796
-            echo $content;
1797
-            return '';
1798
-        }
1799
-        return $content;
1800
-    }
1801
-
1802
-
1803
-    /**
1804
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1805
-     *
1806
-     * @return array properly formatted array for help popup content
1807
-     * @throws EE_Error
1808
-     */
1809
-    private function _get_help_content()
1810
-    {
1811
-        // what is the method we're looking for?
1812
-        $method_name = '_help_popup_content_' . $this->_req_action;
1813
-        // if method doesn't exist let's get out.
1814
-        if (! method_exists($this, $method_name)) {
1815
-            return array();
1816
-        }
1817
-        // k we're good to go let's retrieve the help array
1818
-        $help_array = $this->{$method_name}();
1819
-        // make sure we've got an array!
1820
-        if (! is_array($help_array)) {
1821
-            throw new EE_Error(
1822
-                esc_html__(
1823
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1824
-                    'event_espresso'
1825
-                )
1826
-            );
1827
-        }
1828
-        return $help_array;
1829
-    }
1830
-
1831
-
1832
-    /**
1833
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1834
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1835
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1836
-     *
1837
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1838
-     * @param boolean $display    if false then we return the trigger string
1839
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1840
-     * @return string
1841
-     * @throws DomainException
1842
-     * @throws EE_Error
1843
-     */
1844
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1845
-    {
1846
-        if (defined('DOING_AJAX')) {
1847
-            return '';
1848
-        }
1849
-        // 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
1850
-        $help_array = $this->_get_help_content();
1851
-        $help_content = '';
1852
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1853
-            $help_array[ $trigger_id ] = array(
1854
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1855
-                'content' => esc_html__(
1856
-                    '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.)',
1857
-                    'event_espresso'
1858
-                ),
1859
-            );
1860
-            $help_content = $this->_set_help_popup_content($help_array);
1861
-        }
1862
-        // let's setup the trigger
1863
-        $content = '<a class="ee-dialog" href="?height='
1864
-                   . $dimensions[0]
1865
-                   . '&width='
1866
-                   . $dimensions[1]
1867
-                   . '&inlineId='
1868
-                   . $trigger_id
1869
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1870
-        $content .= $help_content;
1871
-        if ($display) {
1872
-            echo $content;
1873
-            return '';
1874
-        }
1875
-        return $content;
1876
-    }
1877
-
1878
-
1879
-    /**
1880
-     * _add_global_screen_options
1881
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1882
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1883
-     *
1884
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1885
-     *         see also WP_Screen object documents...
1886
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1887
-     * @abstract
1888
-     * @return void
1889
-     */
1890
-    private function _add_global_screen_options()
1891
-    {
1892
-    }
1893
-
1894
-
1895
-    /**
1896
-     * _add_global_feature_pointers
1897
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1898
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1899
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1900
-     *
1901
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1902
-     *         extended) also see:
1903
-     * @link   http://eamann.com/tech/wordpress-portland/
1904
-     * @abstract
1905
-     * @return void
1906
-     */
1907
-    private function _add_global_feature_pointers()
1908
-    {
1909
-    }
1910
-
1911
-
1912
-    /**
1913
-     * load_global_scripts_styles
1914
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1915
-     *
1916
-     * @return void
1917
-     * @throws EE_Error
1918
-     */
1919
-    public function load_global_scripts_styles()
1920
-    {
1921
-        // add debugging styles
1922
-        if (WP_DEBUG) {
1923
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1924
-        }
1925
-        // taking care of metaboxes
1926
-        if (empty($this->_cpt_route)
1927
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1928
-        ) {
1929
-            wp_enqueue_script('dashboard');
1930
-        }
1931
-
1932
-        // LOCALIZED DATA
1933
-        // localize script for ajax lazy loading
1934
-        wp_localize_script(
1935
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1936
-            'eeLazyLoadingContainers',
1937
-            apply_filters(
1938
-                'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1939
-                ['espresso_news_post_box_content']
1940
-            )
1941
-        );
1942
-        /**
1943
-         * help tour stuff
1944
-         */
1945
-        if (EE_Registry::instance()->CFG->admin->help_tour_activation && ! empty($this->_help_tour)) {
1946
-            add_filter('FHEE_load_joyride', '__return_true');
1947
-            $tours = array();
1948
-            // setup tours for the js tour object
1949
-            foreach ($this->_help_tour['tours'] as $tour) {
1950
-                if ($tour instanceof EE_Help_Tour) {
1951
-                    $tours[] = array(
1952
-                        'id'      => $tour->get_slug(),
1953
-                        'options' => $tour->get_options(),
1954
-                    );
1955
-                }
1956
-            }
1957
-            wp_localize_script(
1958
-                EspressoLegacyAdminAssetManager::JS_HANDLE_EE_HELP_TOUR,
1959
-                'EE_HELP_TOUR',
1960
-                ['tours' => $tours]
1961
-            );
1962
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1963
-        }
1964
-    }
1965
-
1966
-
1967
-    /**
1968
-     *        admin_footer_scripts_eei18n_js_strings
1969
-     *
1970
-     * @return        void
1971
-     */
1972
-    public function admin_footer_scripts_eei18n_js_strings()
1973
-    {
1974
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1975
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
1976
-            '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!!!',
1977
-            'event_espresso'
1978
-        );
1979
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
1980
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
1981
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
1982
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
1983
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
1984
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
1985
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
1986
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
1987
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
1988
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
1989
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
1990
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
1991
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
1992
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
1993
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
1994
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
1995
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
1996
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
1997
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
1998
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
1999
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2000
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2001
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2002
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2003
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2004
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2005
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2006
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2007
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2008
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2009
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2010
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2011
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2012
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2013
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2014
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2015
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2016
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2017
-    }
2018
-
2019
-
2020
-    /**
2021
-     *        load enhanced xdebug styles for ppl with failing eyesight
2022
-     *
2023
-     * @return        void
2024
-     */
2025
-    public function add_xdebug_style()
2026
-    {
2027
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2028
-    }
2029
-
2030
-
2031
-    /************************/
2032
-    /** LIST TABLE METHODS **/
2033
-    /************************/
2034
-    /**
2035
-     * this sets up the list table if the current view requires it.
2036
-     *
2037
-     * @return void
2038
-     * @throws EE_Error
2039
-     * @throws InvalidArgumentException
2040
-     * @throws InvalidDataTypeException
2041
-     * @throws InvalidInterfaceException
2042
-     */
2043
-    protected function _set_list_table()
2044
-    {
2045
-        // first is this a list_table view?
2046
-        if (! isset($this->_route_config['list_table'])) {
2047
-            return;
2048
-        } //not a list_table view so get out.
2049
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2050
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2051
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2052
-            // user error msg
2053
-            $error_msg = esc_html__(
2054
-                'An error occurred. The requested list table views could not be found.',
2055
-                'event_espresso'
2056
-            );
2057
-            // developer error msg
2058
-            $error_msg .= '||'
2059
-                          . sprintf(
2060
-                              esc_html__(
2061
-                                  '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.',
2062
-                                  'event_espresso'
2063
-                              ),
2064
-                              $this->_req_action,
2065
-                              $list_table_view
2066
-                          );
2067
-            throw new EE_Error($error_msg);
2068
-        }
2069
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2070
-        $this->_views = apply_filters(
2071
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2072
-            $this->_views
2073
-        );
2074
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2075
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2076
-        $this->_set_list_table_view();
2077
-        $this->_set_list_table_object();
2078
-    }
2079
-
2080
-
2081
-    /**
2082
-     * set current view for List Table
2083
-     *
2084
-     * @return void
2085
-     */
2086
-    protected function _set_list_table_view()
2087
-    {
2088
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2089
-        // looking at active items or dumpster diving ?
2090
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2091
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2092
-        } else {
2093
-            $this->_view = sanitize_key($this->_req_data['status']);
2094
-        }
2095
-    }
2096
-
2097
-
2098
-    /**
2099
-     * _set_list_table_object
2100
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2101
-     *
2102
-     * @throws InvalidInterfaceException
2103
-     * @throws InvalidArgumentException
2104
-     * @throws InvalidDataTypeException
2105
-     * @throws EE_Error
2106
-     * @throws InvalidInterfaceException
2107
-     */
2108
-    protected function _set_list_table_object()
2109
-    {
2110
-        if (isset($this->_route_config['list_table'])) {
2111
-            if (! class_exists($this->_route_config['list_table'])) {
2112
-                throw new EE_Error(
2113
-                    sprintf(
2114
-                        esc_html__(
2115
-                            '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.',
2116
-                            'event_espresso'
2117
-                        ),
2118
-                        $this->_route_config['list_table'],
2119
-                        get_class($this)
2120
-                    )
2121
-                );
2122
-            }
2123
-            $this->_list_table_object = $this->loader->getShared(
2124
-                $this->_route_config['list_table'],
2125
-                array($this)
2126
-            );
2127
-        }
2128
-    }
2129
-
2130
-
2131
-    /**
2132
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2133
-     *
2134
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2135
-     *                                                    urls.  The array should be indexed by the view it is being
2136
-     *                                                    added to.
2137
-     * @return array
2138
-     */
2139
-    public function get_list_table_view_RLs($extra_query_args = array())
2140
-    {
2141
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2142
-        if (empty($this->_views)) {
2143
-            $this->_views = array();
2144
-        }
2145
-        // cycle thru views
2146
-        foreach ($this->_views as $key => $view) {
2147
-            $query_args = array();
2148
-            // check for current view
2149
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2150
-            $query_args['action'] = $this->_req_action;
2151
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2152
-            $query_args['status'] = $view['slug'];
2153
-            // merge any other arguments sent in.
2154
-            if (isset($extra_query_args[ $view['slug'] ])) {
2155
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2156
-                    $query_args[] = $extra_query_arg;
2157
-                }
2158
-            }
2159
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2160
-        }
2161
-        return $this->_views;
2162
-    }
2163
-
2164
-
2165
-    /**
2166
-     * _entries_per_page_dropdown
2167
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2168
-     *
2169
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2170
-     *         WP does it.
2171
-     * @param int $max_entries total number of rows in the table
2172
-     * @return string
2173
-     */
2174
-    protected function _entries_per_page_dropdown($max_entries = 0)
2175
-    {
2176
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2177
-        $values = array(10, 25, 50, 100);
2178
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2179
-        if ($max_entries) {
2180
-            $values[] = $max_entries;
2181
-            sort($values);
2182
-        }
2183
-        $entries_per_page_dropdown = '
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
+	// sanitized request action (and nonce)
132
+
133
+	/**
134
+	 * @var string $_req_action
135
+	 */
136
+	protected $_req_action;
137
+
138
+	/**
139
+	 * @var string $_req_nonce
140
+	 */
141
+	protected $_req_nonce;
142
+
143
+	// search related
144
+	protected $_search_btn_label;
145
+
146
+	protected $_search_box_callback;
147
+
148
+	/**
149
+	 * WP Current Screen object
150
+	 *
151
+	 * @var WP_Screen
152
+	 */
153
+	protected $_current_screen;
154
+
155
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
+	protected $_hook_obj;
157
+
158
+	// for holding incoming request data
159
+	protected $_req_data;
160
+
161
+	// yes / no array for admin form fields
162
+	protected $_yes_no_values = array();
163
+
164
+	// some default things shared by all child classes
165
+	protected $_default_espresso_metaboxes;
166
+
167
+	/**
168
+	 *    EE_Registry Object
169
+	 *
170
+	 * @var    EE_Registry
171
+	 */
172
+	protected $EE;
173
+
174
+
175
+	/**
176
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
177
+	 *
178
+	 * @var boolean
179
+	 */
180
+	protected $_is_caf = false;
181
+
182
+
183
+	/**
184
+	 * @Constructor
185
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
+	 * @throws InvalidArgumentException
187
+	 * @throws InvalidDataTypeException
188
+	 * @throws InvalidInterfaceException
189
+	 * @throws ReflectionException
190
+	 */
191
+	public function __construct($routing = true)
192
+	{
193
+		$this->loader = LoaderFactory::getLoader();
194
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
195
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
196
+			$this->_is_caf = true;
197
+		}
198
+		$this->_yes_no_values = array(
199
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
200
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
201
+		);
202
+		// set the _req_data property.
203
+		$this->_req_data = array_merge($_GET, $_POST);
204
+		// routing enabled?
205
+		$this->_routing = $routing;
206
+	}
207
+
208
+
209
+	/**
210
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
211
+	 * for child classes that needed to set properties prior to these methods getting called,
212
+	 * but also needed the parent class to have its construction completed as well.
213
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
214
+	 * and any complex initialization logic should only run after instantiation is complete.
215
+	 *
216
+	 * This method gets called immediately after construction from within
217
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
218
+	 *
219
+	 * @throws EE_Error
220
+	 * @throws InvalidArgumentException
221
+	 * @throws InvalidDataTypeException
222
+	 * @throws InvalidInterfaceException
223
+	 * @throws ReflectionException
224
+	 * @since $VID:$
225
+	 */
226
+	public function initializePage()
227
+	{
228
+		// set initial page props (child method)
229
+		$this->_init_page_props();
230
+		// set global defaults
231
+		$this->_set_defaults();
232
+		// set early because incoming requests could be ajax related and we need to register those hooks.
233
+		$this->_global_ajax_hooks();
234
+		$this->_ajax_hooks();
235
+		// other_page_hooks have to be early too.
236
+		$this->_do_other_page_hooks();
237
+		// This just allows us to have extending classes do something specific
238
+		// before the parent constructor runs _page_setup().
239
+		if (method_exists($this, '_before_page_setup')) {
240
+			$this->_before_page_setup();
241
+		}
242
+		// set up page dependencies
243
+		$this->_page_setup();
244
+	}
245
+
246
+
247
+	/**
248
+	 * _init_page_props
249
+	 * Child classes use to set at least the following properties:
250
+	 * $page_slug.
251
+	 * $page_label.
252
+	 *
253
+	 * @abstract
254
+	 * @return void
255
+	 */
256
+	abstract protected function _init_page_props();
257
+
258
+
259
+	/**
260
+	 * _ajax_hooks
261
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
262
+	 * Note: within the ajax callback methods.
263
+	 *
264
+	 * @abstract
265
+	 * @return void
266
+	 */
267
+	abstract protected function _ajax_hooks();
268
+
269
+
270
+	/**
271
+	 * _define_page_props
272
+	 * child classes define page properties in here.  Must include at least:
273
+	 * $_admin_base_url = base_url for all admin pages
274
+	 * $_admin_page_title = default admin_page_title for admin pages
275
+	 * $_labels = array of default labels for various automatically generated elements:
276
+	 *    array(
277
+	 *        'buttons' => array(
278
+	 *            'add' => esc_html__('label for add new button'),
279
+	 *            'edit' => esc_html__('label for edit button'),
280
+	 *            'delete' => esc_html__('label for delete button')
281
+	 *            )
282
+	 *        )
283
+	 *
284
+	 * @abstract
285
+	 * @return void
286
+	 */
287
+	abstract protected function _define_page_props();
288
+
289
+
290
+	/**
291
+	 * _set_page_routes
292
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
293
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
294
+	 * have a 'default' route. Here's the format
295
+	 * $this->_page_routes = array(
296
+	 *        'default' => array(
297
+	 *            'func' => '_default_method_handling_route',
298
+	 *            'args' => array('array','of','args'),
299
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
300
+	 *            ajax request, backend processing)
301
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
302
+	 *            headers route after.  The string you enter here should match the defined route reference for a
303
+	 *            headers sent route.
304
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
305
+	 *            this route.
306
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
307
+	 *            checks).
308
+	 *        ),
309
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
310
+	 *        handling method.
311
+	 *        )
312
+	 * )
313
+	 *
314
+	 * @abstract
315
+	 * @return void
316
+	 */
317
+	abstract protected function _set_page_routes();
318
+
319
+
320
+	/**
321
+	 * _set_page_config
322
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
323
+	 * array corresponds to the page_route for the loaded page. Format:
324
+	 * $this->_page_config = array(
325
+	 *        'default' => array(
326
+	 *            'labels' => array(
327
+	 *                'buttons' => array(
328
+	 *                    'add' => esc_html__('label for adding item'),
329
+	 *                    'edit' => esc_html__('label for editing item'),
330
+	 *                    'delete' => esc_html__('label for deleting item')
331
+	 *                ),
332
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
333
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
334
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
335
+	 *            _define_page_props() method
336
+	 *            'nav' => array(
337
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
338
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
339
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
340
+	 *                'order' => 10, //required to indicate tab position.
341
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
342
+	 *                displayed then add this parameter.
343
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
344
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
345
+	 *            metaboxes set for eventespresso admin pages.
346
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
347
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
348
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
349
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
350
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
351
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
352
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
353
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
354
+	 *            want to display.
355
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
356
+	 *                'tab_id' => array(
357
+	 *                    'title' => 'tab_title',
358
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
359
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
360
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
361
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
362
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
363
+	 *                    attempt to use the callback which should match the name of a method in the class
364
+	 *                    ),
365
+	 *                'tab2_id' => array(
366
+	 *                    'title' => 'tab2 title',
367
+	 *                    'filename' => 'file_name_2'
368
+	 *                    'callback' => 'callback_method_for_content',
369
+	 *                 ),
370
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
371
+	 *            help tab area on an admin page. @link
372
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
373
+	 *            'help_tour' => array(
374
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
375
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
376
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
377
+	 *            ),
378
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
379
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
380
+	 *            just set
381
+	 *            'require_nonce' to FALSE
382
+	 *            )
383
+	 * )
384
+	 *
385
+	 * @abstract
386
+	 * @return void
387
+	 */
388
+	abstract protected function _set_page_config();
389
+
390
+
391
+
392
+
393
+
394
+	/** end sample help_tour methods **/
395
+	/**
396
+	 * _add_screen_options
397
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
398
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
399
+	 * to a particular view.
400
+	 *
401
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
402
+	 *         see also WP_Screen object documents...
403
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract protected function _add_screen_options();
408
+
409
+
410
+	/**
411
+	 * _add_feature_pointers
412
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
413
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
414
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
415
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
416
+	 * extended) also see:
417
+	 *
418
+	 * @link   http://eamann.com/tech/wordpress-portland/
419
+	 * @abstract
420
+	 * @return void
421
+	 */
422
+	abstract protected function _add_feature_pointers();
423
+
424
+
425
+	/**
426
+	 * load_scripts_styles
427
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
428
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
429
+	 * scripts/styles per view by putting them in a dynamic function in this format
430
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
431
+	 *
432
+	 * @abstract
433
+	 * @return void
434
+	 */
435
+	abstract public function load_scripts_styles();
436
+
437
+
438
+	/**
439
+	 * admin_init
440
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
441
+	 * all pages/views loaded by child class.
442
+	 *
443
+	 * @abstract
444
+	 * @return void
445
+	 */
446
+	abstract public function admin_init();
447
+
448
+
449
+	/**
450
+	 * admin_notices
451
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
452
+	 * all pages/views loaded by child class.
453
+	 *
454
+	 * @abstract
455
+	 * @return void
456
+	 */
457
+	abstract public function admin_notices();
458
+
459
+
460
+	/**
461
+	 * admin_footer_scripts
462
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
463
+	 * will apply to all pages/views loaded by child class.
464
+	 *
465
+	 * @return void
466
+	 */
467
+	abstract public function admin_footer_scripts();
468
+
469
+
470
+	/**
471
+	 * admin_footer
472
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
473
+	 * apply to all pages/views loaded by child class.
474
+	 *
475
+	 * @return void
476
+	 */
477
+	public function admin_footer()
478
+	{
479
+	}
480
+
481
+
482
+	/**
483
+	 * _global_ajax_hooks
484
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
485
+	 * Note: within the ajax callback methods.
486
+	 *
487
+	 * @abstract
488
+	 * @return void
489
+	 */
490
+	protected function _global_ajax_hooks()
491
+	{
492
+		// for lazy loading of metabox content
493
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
494
+
495
+		add_action(
496
+			'wp_ajax_espresso_hide_status_change_notice',
497
+			[$this, 'hideStatusChangeNotice']
498
+		);
499
+		add_action(
500
+			'wp_ajax_nopriv_espresso_hide_status_change_notice',
501
+			[$this, 'hideStatusChangeNotice']
502
+		);
503
+	}
504
+
505
+
506
+	public function ajax_metabox_content()
507
+	{
508
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
509
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
510
+		EE_Admin_Page::cached_rss_display($contentid, $url);
511
+		wp_die();
512
+	}
513
+
514
+
515
+	public function hideStatusChangeNotice()
516
+	{
517
+		$response = [];
518
+		try {
519
+			/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
520
+			$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
521
+			$response['success'] = $status_change_notice->dismiss() > -1;
522
+		} catch (Exception $exception) {
523
+			$response['errors'] = $exception->getMessage();
524
+		}
525
+		echo wp_json_encode($response);
526
+		exit();
527
+	}
528
+
529
+
530
+	/**
531
+	 * _page_setup
532
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
533
+	 * doesn't match the object.
534
+	 *
535
+	 * @final
536
+	 * @return void
537
+	 * @throws EE_Error
538
+	 * @throws InvalidArgumentException
539
+	 * @throws ReflectionException
540
+	 * @throws InvalidDataTypeException
541
+	 * @throws InvalidInterfaceException
542
+	 */
543
+	final protected function _page_setup()
544
+	{
545
+		// requires?
546
+		// admin_init stuff - global - we're setting this REALLY early
547
+		// so if EE_Admin pages have to hook into other WP pages they can.
548
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
549
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
550
+		// next verify if we need to load anything...
551
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
552
+		$this->page_folder = strtolower(
553
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
554
+		);
555
+		global $ee_menu_slugs;
556
+		$ee_menu_slugs = (array) $ee_menu_slugs;
557
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
558
+			return;
559
+		}
560
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
561
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
562
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
563
+				? $this->_req_data['action2']
564
+				: $this->_req_data['action'];
565
+		}
566
+		// then set blank or -1 action values to 'default'
567
+		$this->_req_action = isset($this->_req_data['action'])
568
+							 && ! empty($this->_req_data['action'])
569
+							 && $this->_req_data['action'] !== '-1'
570
+			? sanitize_key($this->_req_data['action'])
571
+			: 'default';
572
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
573
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
574
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
575
+			? $this->_req_data['route'] : $this->_req_action;
576
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
577
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
578
+			? $this->_req_data['route']
579
+			: $this->_req_action;
580
+		$this->_current_view = $this->_req_action;
581
+		$this->_req_nonce = $this->_req_action . '_nonce';
582
+		$this->_define_page_props();
583
+		$this->_current_page_view_url = add_query_arg(
584
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
585
+			$this->_admin_base_url
586
+		);
587
+		// default things
588
+		$this->_default_espresso_metaboxes = array(
589
+			'_espresso_news_post_box',
590
+			'_espresso_links_post_box',
591
+			'_espresso_ratings_request',
592
+			'_espresso_sponsors_post_box',
593
+		);
594
+		// set page configs
595
+		$this->_set_page_routes();
596
+		$this->_set_page_config();
597
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
598
+		if (isset($this->_req_data['wp_referer'])) {
599
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
600
+		}
601
+		// for caffeinated and other extended functionality.
602
+		//  If there is a _extend_page_config method
603
+		// then let's run that to modify the all the various page configuration arrays
604
+		if (method_exists($this, '_extend_page_config')) {
605
+			$this->_extend_page_config();
606
+		}
607
+		// for CPT and other extended functionality.
608
+		// If there is an _extend_page_config_for_cpt
609
+		// then let's run that to modify all the various page configuration arrays.
610
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
611
+			$this->_extend_page_config_for_cpt();
612
+		}
613
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
614
+		$this->_page_routes = apply_filters(
615
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
616
+			$this->_page_routes,
617
+			$this
618
+		);
619
+		$this->_page_config = apply_filters(
620
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
621
+			$this->_page_config,
622
+			$this
623
+		);
624
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
625
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
626
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
627
+			add_action(
628
+				'AHEE__EE_Admin_Page__route_admin_request',
629
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
630
+				10,
631
+				2
632
+			);
633
+		}
634
+		// next route only if routing enabled
635
+		if ($this->_routing && ! defined('DOING_AJAX')) {
636
+			$this->_verify_routes();
637
+			// next let's just check user_access and kill if no access
638
+			$this->check_user_access();
639
+			if ($this->_is_UI_request) {
640
+				// admin_init stuff - global, all views for this page class, specific view
641
+				add_action('admin_init', array($this, 'admin_init'), 10);
642
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
643
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
644
+				}
645
+			} else {
646
+				// hijack regular WP loading and route admin request immediately
647
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
648
+				$this->route_admin_request();
649
+			}
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
656
+	 *
657
+	 * @return void
658
+	 * @throws EE_Error
659
+	 */
660
+	private function _do_other_page_hooks()
661
+	{
662
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
663
+		foreach ($registered_pages as $page) {
664
+			// now let's setup the file name and class that should be present
665
+			$classname = str_replace('.class.php', '', $page);
666
+			// autoloaders should take care of loading file
667
+			if (! class_exists($classname)) {
668
+				$error_msg[] = sprintf(
669
+					esc_html__(
670
+						'Something went wrong with loading the %s admin hooks page.',
671
+						'event_espresso'
672
+					),
673
+					$page
674
+				);
675
+				$error_msg[] = $error_msg[0]
676
+							   . "\r\n"
677
+							   . sprintf(
678
+								   esc_html__(
679
+									   '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',
680
+									   'event_espresso'
681
+								   ),
682
+								   $page,
683
+								   '<br />',
684
+								   '<strong>' . $classname . '</strong>'
685
+							   );
686
+				throw new EE_Error(implode('||', $error_msg));
687
+			}
688
+			// // notice we are passing the instance of this class to the hook object.
689
+			$this->loader->getShared($classname, [$this]);
690
+		}
691
+	}
692
+
693
+
694
+	/**
695
+	 * @throws DomainException
696
+	 * @throws EE_Error
697
+	 * @throws InvalidArgumentException
698
+	 * @throws InvalidDataTypeException
699
+	 * @throws InvalidInterfaceException
700
+	 * @throws ReflectionException
701
+	 * @since $VID:$
702
+	 */
703
+	public function load_page_dependencies()
704
+	{
705
+		try {
706
+			$this->_load_page_dependencies();
707
+		} catch (EE_Error $e) {
708
+			$e->get_error();
709
+		}
710
+	}
711
+
712
+
713
+	/**
714
+	 * load_page_dependencies
715
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
716
+	 *
717
+	 * @return void
718
+	 * @throws DomainException
719
+	 * @throws EE_Error
720
+	 * @throws InvalidArgumentException
721
+	 * @throws InvalidDataTypeException
722
+	 * @throws InvalidInterfaceException
723
+	 * @throws ReflectionException
724
+	 */
725
+	protected function _load_page_dependencies()
726
+	{
727
+		// let's set the current_screen and screen options to override what WP set
728
+		$this->_current_screen = get_current_screen();
729
+		// load admin_notices - global, page class, and view specific
730
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
731
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
732
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
733
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
734
+		}
735
+		// load network admin_notices - global, page class, and view specific
736
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
737
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
738
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
739
+		}
740
+		// this will save any per_page screen options if they are present
741
+		$this->_set_per_page_screen_options();
742
+		// setup list table properties
743
+		$this->_set_list_table();
744
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
745
+		// However in some cases the metaboxes will need to be added within a route handling callback.
746
+		$this->_add_registered_meta_boxes();
747
+		$this->_add_screen_columns();
748
+		// add screen options - global, page child class, and view specific
749
+		$this->_add_global_screen_options();
750
+		$this->_add_screen_options();
751
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
752
+		if (method_exists($this, $add_screen_options)) {
753
+			$this->{$add_screen_options}();
754
+		}
755
+		// add help tab(s) and tours- set via page_config and qtips.
756
+		$this->_add_help_tour();
757
+		$this->_add_help_tabs();
758
+		$this->_add_qtips();
759
+		// add feature_pointers - global, page child class, and view specific
760
+		$this->_add_feature_pointers();
761
+		$this->_add_global_feature_pointers();
762
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
763
+		if (method_exists($this, $add_feature_pointer)) {
764
+			$this->{$add_feature_pointer}();
765
+		}
766
+		// enqueue scripts/styles - global, page class, and view specific
767
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
768
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
769
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
770
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
771
+		}
772
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
773
+		// admin_print_footer_scripts - global, page child class, and view specific.
774
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
775
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
776
+		// is a good use case. Notice the late priority we're giving these
777
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
778
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
779
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
780
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
781
+		}
782
+		// admin footer scripts
783
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
784
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
785
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
786
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
787
+		}
788
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
789
+		// targeted hook
790
+		do_action(
791
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
792
+		);
793
+	}
794
+
795
+
796
+	/**
797
+	 * _set_defaults
798
+	 * This sets some global defaults for class properties.
799
+	 */
800
+	private function _set_defaults()
801
+	{
802
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
803
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
804
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
805
+		$this->_page_config = $this->_default_route_query_args = array();
806
+		$this->_default_nav_tab_name = 'overview';
807
+		// init template args
808
+		$this->_template_args = array(
809
+			'admin_page_header'  => '',
810
+			'admin_page_content' => '',
811
+			'post_body_content'  => '',
812
+			'before_list_table'  => '',
813
+			'after_list_table'   => '',
814
+		);
815
+	}
816
+
817
+
818
+	/**
819
+	 * route_admin_request
820
+	 *
821
+	 * @see    _route_admin_request()
822
+	 * @return exception|void error
823
+	 * @throws InvalidArgumentException
824
+	 * @throws InvalidInterfaceException
825
+	 * @throws InvalidDataTypeException
826
+	 * @throws EE_Error
827
+	 * @throws ReflectionException
828
+	 */
829
+	public function route_admin_request()
830
+	{
831
+		try {
832
+			$this->_route_admin_request();
833
+		} catch (EE_Error $e) {
834
+			$e->get_error();
835
+		}
836
+	}
837
+
838
+
839
+	public function set_wp_page_slug($wp_page_slug)
840
+	{
841
+		$this->_wp_page_slug = $wp_page_slug;
842
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
843
+		if (is_network_admin()) {
844
+			$this->_wp_page_slug .= '-network';
845
+		}
846
+	}
847
+
848
+
849
+	/**
850
+	 * _verify_routes
851
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
852
+	 * we know if we need to drop out.
853
+	 *
854
+	 * @return bool
855
+	 * @throws EE_Error
856
+	 */
857
+	protected function _verify_routes()
858
+	{
859
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
860
+			return false;
861
+		}
862
+		$this->_route = false;
863
+		// check that the page_routes array is not empty
864
+		if (empty($this->_page_routes)) {
865
+			// user error msg
866
+			$error_msg = sprintf(
867
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
868
+				$this->_admin_page_title
869
+			);
870
+			// developer error msg
871
+			$error_msg .= '||' . $error_msg
872
+						  . esc_html__(
873
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
874
+							  'event_espresso'
875
+						  );
876
+			throw new EE_Error($error_msg);
877
+		}
878
+		// and that the requested page route exists
879
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
880
+			$this->_route = $this->_page_routes[ $this->_req_action ];
881
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
882
+				? $this->_page_config[ $this->_req_action ] : array();
883
+		} else {
884
+			// user error msg
885
+			$error_msg = sprintf(
886
+				esc_html__(
887
+					'The requested page route does not exist for the %s admin page.',
888
+					'event_espresso'
889
+				),
890
+				$this->_admin_page_title
891
+			);
892
+			// developer error msg
893
+			$error_msg .= '||' . $error_msg
894
+						  . sprintf(
895
+							  esc_html__(
896
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
897
+								  'event_espresso'
898
+							  ),
899
+							  $this->_req_action
900
+						  );
901
+			throw new EE_Error($error_msg);
902
+		}
903
+		// and that a default route exists
904
+		if (! array_key_exists('default', $this->_page_routes)) {
905
+			// user error msg
906
+			$error_msg = sprintf(
907
+				esc_html__(
908
+					'A default page route has not been set for the % admin page.',
909
+					'event_espresso'
910
+				),
911
+				$this->_admin_page_title
912
+			);
913
+			// developer error msg
914
+			$error_msg .= '||' . $error_msg
915
+						  . esc_html__(
916
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
917
+							  'event_espresso'
918
+						  );
919
+			throw new EE_Error($error_msg);
920
+		}
921
+
922
+		// first lets' catch if the UI request has EVER been set.
923
+		if ($this->_is_UI_request === null) {
924
+			// lets set if this is a UI request or not.
925
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
926
+			// wait a minute... we might have a noheader in the route array
927
+			$this->_is_UI_request = is_array($this->_route)
928
+									&& isset($this->_route['noheader'])
929
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
930
+		}
931
+		$this->_set_current_labels();
932
+		return true;
933
+	}
934
+
935
+
936
+	/**
937
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
938
+	 *
939
+	 * @param  string $route the route name we're verifying
940
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
941
+	 * @throws EE_Error
942
+	 */
943
+	protected function _verify_route($route)
944
+	{
945
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
946
+			return true;
947
+		}
948
+		// user error msg
949
+		$error_msg = sprintf(
950
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
951
+			$this->_admin_page_title
952
+		);
953
+		// developer error msg
954
+		$error_msg .= '||' . $error_msg
955
+					  . sprintf(
956
+						  esc_html__(
957
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
958
+							  'event_espresso'
959
+						  ),
960
+						  $route
961
+					  );
962
+		throw new EE_Error($error_msg);
963
+	}
964
+
965
+
966
+	/**
967
+	 * perform nonce verification
968
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
969
+	 * using this method (and save retyping!)
970
+	 *
971
+	 * @param string $nonce     The nonce sent
972
+	 * @param string $nonce_ref The nonce reference string (name0)
973
+	 * @return void
974
+	 * @throws EE_Error
975
+	 * @throws InvalidArgumentException
976
+	 * @throws InvalidDataTypeException
977
+	 * @throws InvalidInterfaceException
978
+	 */
979
+	protected function _verify_nonce($nonce, $nonce_ref)
980
+	{
981
+		// verify nonce against expected value
982
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
983
+			// these are not the droids you are looking for !!!
984
+			$msg = sprintf(
985
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
986
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
987
+				'</a>'
988
+			);
989
+			if (WP_DEBUG) {
990
+				$msg .= "\n  "
991
+						. sprintf(
992
+							esc_html__(
993
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
994
+								'event_espresso'
995
+							),
996
+							EE_Admin_Page::class
997
+						);
998
+			}
999
+			if (! defined('DOING_AJAX')) {
1000
+				wp_die($msg);
1001
+			} else {
1002
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1003
+				$this->_return_json();
1004
+			}
1005
+		}
1006
+	}
1007
+
1008
+
1009
+	/**
1010
+	 * _route_admin_request()
1011
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1012
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1013
+	 * in the page routes and then will try to load the corresponding method.
1014
+	 *
1015
+	 * @return void
1016
+	 * @throws EE_Error
1017
+	 * @throws InvalidArgumentException
1018
+	 * @throws InvalidDataTypeException
1019
+	 * @throws InvalidInterfaceException
1020
+	 * @throws ReflectionException
1021
+	 */
1022
+	protected function _route_admin_request()
1023
+	{
1024
+		if (! $this->_is_UI_request) {
1025
+			$this->_verify_routes();
1026
+		}
1027
+		$nonce_check = isset($this->_route_config['require_nonce'])
1028
+			? $this->_route_config['require_nonce']
1029
+			: true;
1030
+		if ($this->_req_action !== 'default' && $nonce_check) {
1031
+			// set nonce from post data
1032
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
1033
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1034
+				: '';
1035
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1036
+		}
1037
+		// set the nav_tabs array but ONLY if this is  UI_request
1038
+		if ($this->_is_UI_request) {
1039
+			$this->_set_nav_tabs();
1040
+		}
1041
+		// grab callback function
1042
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1043
+		// check if callback has args
1044
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1045
+		$error_msg = '';
1046
+		// action right before calling route
1047
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1048
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1049
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1050
+		}
1051
+		// right before calling the route, let's remove _wp_http_referer from the
1052
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1053
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
1054
+			'_wp_http_referer',
1055
+			wp_unslash($_SERVER['REQUEST_URI'])
1056
+		);
1057
+		if (! empty($func)) {
1058
+			if (is_array($func)) {
1059
+				list($class, $method) = $func;
1060
+			} elseif (strpos($func, '::') !== false) {
1061
+				list($class, $method) = explode('::', $func);
1062
+			} else {
1063
+				$class = $this;
1064
+				$method = $func;
1065
+			}
1066
+			if (! (is_object($class) && $class === $this)) {
1067
+				// send along this admin page object for access by addons.
1068
+				$args['admin_page_object'] = $this;
1069
+			}
1070
+			// is it a method on a class that doesn't work?
1071
+			if (((method_exists($class, $method)
1072
+				  && call_user_func_array(array($class, $method), $args) === false)
1073
+				 && (// is it a standalone function that doesn't work?
1074
+					 function_exists($method)
1075
+					 && call_user_func_array(
1076
+						 $func,
1077
+						 array_merge(array('admin_page_object' => $this), $args)
1078
+					 ) === false
1079
+				 )) || (// is it neither a class method NOR a standalone function?
1080
+					! function_exists($method)
1081
+					&& ! method_exists($class, $method)
1082
+				)
1083
+			) {
1084
+				// user error msg
1085
+				$error_msg = esc_html__(
1086
+					'An error occurred. The  requested page route could not be found.',
1087
+					'event_espresso'
1088
+				);
1089
+				// developer error msg
1090
+				$error_msg .= '||';
1091
+				$error_msg .= sprintf(
1092
+					esc_html__(
1093
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1094
+						'event_espresso'
1095
+					),
1096
+					$method
1097
+				);
1098
+			}
1099
+			if (! empty($error_msg)) {
1100
+				throw new EE_Error($error_msg);
1101
+			}
1102
+		}
1103
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1104
+		// then we need to reset the routing properties to the new route.
1105
+		// 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.
1106
+		if ($this->_is_UI_request === false
1107
+			&& is_array($this->_route)
1108
+			&& ! empty($this->_route['headers_sent_route'])
1109
+		) {
1110
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1111
+		}
1112
+	}
1113
+
1114
+
1115
+	/**
1116
+	 * This method just allows the resetting of page properties in the case where a no headers
1117
+	 * route redirects to a headers route in its route config.
1118
+	 *
1119
+	 * @since   4.3.0
1120
+	 * @param  string $new_route New (non header) route to redirect to.
1121
+	 * @return   void
1122
+	 * @throws ReflectionException
1123
+	 * @throws InvalidArgumentException
1124
+	 * @throws InvalidInterfaceException
1125
+	 * @throws InvalidDataTypeException
1126
+	 * @throws EE_Error
1127
+	 */
1128
+	protected function _reset_routing_properties($new_route)
1129
+	{
1130
+		$this->_is_UI_request = true;
1131
+		// now we set the current route to whatever the headers_sent_route is set at
1132
+		$this->_req_data['action'] = $new_route;
1133
+		// rerun page setup
1134
+		$this->_page_setup();
1135
+	}
1136
+
1137
+
1138
+	/**
1139
+	 * _add_query_arg
1140
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1141
+	 *(internally just uses EEH_URL's function with the same name)
1142
+	 *
1143
+	 * @param array  $args
1144
+	 * @param string $url
1145
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1146
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1147
+	 *                                        Example usage: If the current page is:
1148
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1149
+	 *                                        &action=default&event_id=20&month_range=March%202015
1150
+	 *                                        &_wpnonce=5467821
1151
+	 *                                        and you call:
1152
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1153
+	 *                                        array(
1154
+	 *                                        'action' => 'resend_something',
1155
+	 *                                        'page=>espresso_registrations'
1156
+	 *                                        ),
1157
+	 *                                        $some_url,
1158
+	 *                                        true
1159
+	 *                                        );
1160
+	 *                                        It will produce a url in this structure:
1161
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1162
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1163
+	 *                                        month_range]=March%202015
1164
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1165
+	 * @return string
1166
+	 */
1167
+	public static function add_query_args_and_nonce(
1168
+		$args = array(),
1169
+		$url = '',
1170
+		$sticky = false,
1171
+		$exclude_nonce = false
1172
+	) {
1173
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1174
+		if ($sticky) {
1175
+			$request = $_REQUEST;
1176
+			unset($request['_wp_http_referer'], $request['wp_referer']);
1177
+			foreach ($request as $key => $value) {
1178
+				// do not add nonces
1179
+				if (strpos($key, 'nonce') !== false) {
1180
+					continue;
1181
+				}
1182
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1183
+			}
1184
+		}
1185
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1186
+	}
1187
+
1188
+
1189
+	/**
1190
+	 * This returns a generated link that will load the related help tab.
1191
+	 *
1192
+	 * @param  string $help_tab_id the id for the connected help tab
1193
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1194
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1195
+	 * @uses EEH_Template::get_help_tab_link()
1196
+	 * @return string              generated link
1197
+	 */
1198
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1199
+	{
1200
+		return EEH_Template::get_help_tab_link(
1201
+			$help_tab_id,
1202
+			$this->page_slug,
1203
+			$this->_req_action,
1204
+			$icon_style,
1205
+			$help_text
1206
+		);
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * _add_help_tabs
1212
+	 * Note child classes define their help tabs within the page_config array.
1213
+	 *
1214
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1215
+	 * @return void
1216
+	 * @throws DomainException
1217
+	 * @throws EE_Error
1218
+	 * @throws ReflectionException
1219
+	 */
1220
+	protected function _add_help_tabs()
1221
+	{
1222
+		$tour_buttons = '';
1223
+		if (isset($this->_page_config[ $this->_req_action ])) {
1224
+			$config = $this->_page_config[ $this->_req_action ];
1225
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1226
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1227
+				$tb = array();
1228
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1229
+				foreach ($this->_help_tour['tours'] as $tour) {
1230
+					// if this is the end tour then we don't need to setup a button
1231
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1232
+						continue;
1233
+					}
1234
+					$tb[] = '<button id="trigger-tour-'
1235
+							. $tour->get_slug()
1236
+							. '" class="button-primary trigger-ee-help-tour">'
1237
+							. $tour->get_label()
1238
+							. '</button>';
1239
+				}
1240
+				$tour_buttons .= implode('<br />', $tb);
1241
+				$tour_buttons .= '</div></div>';
1242
+			}
1243
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1244
+			if (is_array($config) && isset($config['help_sidebar'])) {
1245
+				// check that the callback given is valid
1246
+				if (! method_exists($this, $config['help_sidebar'])) {
1247
+					throw new EE_Error(
1248
+						sprintf(
1249
+							esc_html__(
1250
+								'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',
1251
+								'event_espresso'
1252
+							),
1253
+							$config['help_sidebar'],
1254
+							get_class($this)
1255
+						)
1256
+					);
1257
+				}
1258
+				$content = apply_filters(
1259
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1260
+					$this->{$config['help_sidebar']}()
1261
+				);
1262
+				$content .= $tour_buttons; // add help tour buttons.
1263
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1264
+				$this->_current_screen->set_help_sidebar($content);
1265
+			}
1266
+			// if there ARE tour buttons...
1267
+			if (! empty($tour_buttons)) {
1268
+				// if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1269
+				if (! isset($config['help_sidebar'])) {
1270
+					$this->_current_screen->set_help_sidebar($tour_buttons);
1271
+				}
1272
+				// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1273
+				if (! isset($config['help_tabs'])) {
1274
+					$_ht['id'] = $this->page_slug;
1275
+					$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1276
+					$_ht['content'] = '<p>'
1277
+									  . esc_html__(
1278
+										  'The buttons to the right allow you to start/restart any help tours available for this page',
1279
+										  'event_espresso'
1280
+									  ) . '</p>';
1281
+					$this->_current_screen->add_help_tab($_ht);
1282
+				}
1283
+			}
1284
+			if (! isset($config['help_tabs'])) {
1285
+				return;
1286
+			} //no help tabs for this route
1287
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1288
+				// we're here so there ARE help tabs!
1289
+				// make sure we've got what we need
1290
+				if (! isset($cfg['title'])) {
1291
+					throw new EE_Error(
1292
+						esc_html__(
1293
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1294
+							'event_espresso'
1295
+						)
1296
+					);
1297
+				}
1298
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1299
+					throw new EE_Error(
1300
+						esc_html__(
1301
+							'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',
1302
+							'event_espresso'
1303
+						)
1304
+					);
1305
+				}
1306
+				// first priority goes to content.
1307
+				if (! empty($cfg['content'])) {
1308
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1309
+					// second priority goes to filename
1310
+				} elseif (! empty($cfg['filename'])) {
1311
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1312
+					// 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)
1313
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1314
+															 . basename($this->_get_dir())
1315
+															 . '/help_tabs/'
1316
+															 . $cfg['filename']
1317
+															 . '.help_tab.php' : $file_path;
1318
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1319
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1320
+						EE_Error::add_error(
1321
+							sprintf(
1322
+								esc_html__(
1323
+									'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',
1324
+									'event_espresso'
1325
+								),
1326
+								$tab_id,
1327
+								key($config),
1328
+								$file_path
1329
+							),
1330
+							__FILE__,
1331
+							__FUNCTION__,
1332
+							__LINE__
1333
+						);
1334
+						return;
1335
+					}
1336
+					$template_args['admin_page_obj'] = $this;
1337
+					$content = EEH_Template::display_template(
1338
+						$file_path,
1339
+						$template_args,
1340
+						true
1341
+					);
1342
+				} else {
1343
+					$content = '';
1344
+				}
1345
+				// check if callback is valid
1346
+				if (empty($content) && (
1347
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1348
+					)
1349
+				) {
1350
+					EE_Error::add_error(
1351
+						sprintf(
1352
+							esc_html__(
1353
+								'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.',
1354
+								'event_espresso'
1355
+							),
1356
+							$cfg['title']
1357
+						),
1358
+						__FILE__,
1359
+						__FUNCTION__,
1360
+						__LINE__
1361
+					);
1362
+					return;
1363
+				}
1364
+				// setup config array for help tab method
1365
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1366
+				$_ht = array(
1367
+					'id'       => $id,
1368
+					'title'    => $cfg['title'],
1369
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1370
+					'content'  => $content,
1371
+				);
1372
+				$this->_current_screen->add_help_tab($_ht);
1373
+			}
1374
+		}
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1380
+	 * an array with properties for setting up usage of the joyride plugin
1381
+	 *
1382
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1383
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1384
+	 *         _set_page_config() comments
1385
+	 * @return void
1386
+	 * @throws EE_Error
1387
+	 * @throws InvalidArgumentException
1388
+	 * @throws InvalidDataTypeException
1389
+	 * @throws InvalidInterfaceException
1390
+	 * @throws ReflectionException
1391
+	 */
1392
+	protected function _add_help_tour()
1393
+	{
1394
+		$tours = array();
1395
+		$this->_help_tour = array();
1396
+		// exit early if help tours are turned off globally
1397
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1398
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1399
+		) {
1400
+			return;
1401
+		}
1402
+		// loop through _page_config to find any help_tour defined
1403
+		foreach ($this->_page_config as $route => $config) {
1404
+			// we're only going to set things up for this route
1405
+			if ($route !== $this->_req_action) {
1406
+				continue;
1407
+			}
1408
+			if (isset($config['help_tour'])) {
1409
+				foreach ($config['help_tour'] as $tour) {
1410
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1411
+					// let's see if we can get that file...
1412
+					// if not its possible this is a decaf route not set in caffeinated
1413
+					// so lets try and get the caffeinated equivalent
1414
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1415
+															 . basename($this->_get_dir())
1416
+															 . '/help_tours/'
1417
+															 . $tour
1418
+															 . '.class.php' : $file_path;
1419
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1420
+					if (! is_readable($file_path)) {
1421
+						EE_Error::add_error(
1422
+							sprintf(
1423
+								esc_html__(
1424
+									'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',
1425
+									'event_espresso'
1426
+								),
1427
+								$file_path,
1428
+								$tour
1429
+							),
1430
+							__FILE__,
1431
+							__FUNCTION__,
1432
+							__LINE__
1433
+						);
1434
+						return;
1435
+					}
1436
+					require_once $file_path;
1437
+					if (! class_exists($tour)) {
1438
+						$error_msg = [];
1439
+						$error_msg[] = sprintf(
1440
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1441
+							$tour
1442
+						);
1443
+						$error_msg[] = $error_msg[0] . "\r\n"
1444
+									   . sprintf(
1445
+										   esc_html__(
1446
+											   '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.',
1447
+											   'event_espresso'
1448
+										   ),
1449
+										   $tour,
1450
+										   '<br />',
1451
+										   $tour,
1452
+										   $this->_req_action,
1453
+										   get_class($this)
1454
+									   );
1455
+						throw new EE_Error(implode('||', $error_msg));
1456
+					}
1457
+					$tour_obj = new $tour($this->_is_caf);
1458
+					$tours[] = $tour_obj;
1459
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1460
+				}
1461
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1462
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1463
+				$tours[] = $end_stop_tour;
1464
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1465
+			}
1466
+		}
1467
+
1468
+		if (! empty($tours)) {
1469
+			$this->_help_tour['tours'] = $tours;
1470
+		}
1471
+		// that's it!  Now that the $_help_tours property is set (or not)
1472
+		// the scripts and html should be taken care of automatically.
1473
+
1474
+		/**
1475
+		 * Allow extending the help tours variable.
1476
+		 *
1477
+		 * @param array $_help_tour The array containing all help tour information to be displayed.
1478
+		 */
1479
+		$this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1480
+	}
1481
+
1482
+
1483
+	/**
1484
+	 * This simply sets up any qtips that have been defined in the page config
1485
+	 *
1486
+	 * @return void
1487
+	 * @throws ReflectionException
1488
+	 * @throws EE_Error
1489
+	 */
1490
+	protected function _add_qtips()
1491
+	{
1492
+		if (isset($this->_route_config['qtips'])) {
1493
+			$qtips = (array) $this->_route_config['qtips'];
1494
+			// load qtip loader
1495
+			$path = array(
1496
+				$this->_get_dir() . '/qtips/',
1497
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1498
+			);
1499
+			$qtip_loader = EEH_Qtip_Loader::instance();
1500
+			if ($qtip_loader instanceof EEH_Qtip_Loader) {
1501
+				$qtip_loader->register($qtips, $path);
1502
+			}
1503
+		}
1504
+	}
1505
+
1506
+
1507
+	/**
1508
+	 * _set_nav_tabs
1509
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1510
+	 * wish to add additional tabs or modify accordingly.
1511
+	 *
1512
+	 * @return void
1513
+	 * @throws InvalidArgumentException
1514
+	 * @throws InvalidInterfaceException
1515
+	 * @throws InvalidDataTypeException
1516
+	 */
1517
+	protected function _set_nav_tabs()
1518
+	{
1519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1520
+		$i = 0;
1521
+		foreach ($this->_page_config as $slug => $config) {
1522
+			if (! is_array($config)
1523
+				|| (
1524
+					is_array($config)
1525
+					&& (
1526
+						(isset($config['nav']) && ! $config['nav'])
1527
+						|| ! isset($config['nav'])
1528
+					)
1529
+				)
1530
+			) {
1531
+				continue;
1532
+			}
1533
+			// no nav tab for this config
1534
+			// check for persistent flag
1535
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1536
+				// nav tab is only to appear when route requested.
1537
+				continue;
1538
+			}
1539
+			if (! $this->check_user_access($slug, true)) {
1540
+				// no nav tab because current user does not have access.
1541
+				continue;
1542
+			}
1543
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1544
+			$this->_nav_tabs[ $slug ] = array(
1545
+				'url'       => isset($config['nav']['url'])
1546
+					? $config['nav']['url']
1547
+					: EE_Admin_Page::add_query_args_and_nonce(
1548
+						array('action' => $slug),
1549
+						$this->_admin_base_url
1550
+					),
1551
+				'link_text' => isset($config['nav']['label'])
1552
+					? $config['nav']['label']
1553
+					: ucwords(
1554
+						str_replace('_', ' ', $slug)
1555
+					),
1556
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1557
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1558
+			);
1559
+			$i++;
1560
+		}
1561
+		// if $this->_nav_tabs is empty then lets set the default
1562
+		if (empty($this->_nav_tabs)) {
1563
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1564
+				'url'       => $this->_admin_base_url,
1565
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1566
+				'css_class' => 'nav-tab-active',
1567
+				'order'     => 10,
1568
+			);
1569
+		}
1570
+		// now let's sort the tabs according to order
1571
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1572
+	}
1573
+
1574
+
1575
+	/**
1576
+	 * _set_current_labels
1577
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1578
+	 * property array
1579
+	 *
1580
+	 * @return void
1581
+	 */
1582
+	private function _set_current_labels()
1583
+	{
1584
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1585
+			foreach ($this->_route_config['labels'] as $label => $text) {
1586
+				if (is_array($text)) {
1587
+					foreach ($text as $sublabel => $subtext) {
1588
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1589
+					}
1590
+				} else {
1591
+					$this->_labels[ $label ] = $text;
1592
+				}
1593
+			}
1594
+		}
1595
+	}
1596
+
1597
+
1598
+	/**
1599
+	 *        verifies user access for this admin page
1600
+	 *
1601
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1602
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1603
+	 *                               return false if verify fail.
1604
+	 * @return bool
1605
+	 * @throws InvalidArgumentException
1606
+	 * @throws InvalidDataTypeException
1607
+	 * @throws InvalidInterfaceException
1608
+	 */
1609
+	public function check_user_access($route_to_check = '', $verify_only = false)
1610
+	{
1611
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1612
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1613
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1614
+					  && is_array(
1615
+						  $this->_page_routes[ $route_to_check ]
1616
+					  )
1617
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1618
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1619
+		if (empty($capability) && empty($route_to_check)) {
1620
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1621
+				: $this->_route['capability'];
1622
+		} else {
1623
+			$capability = empty($capability) ? 'manage_options' : $capability;
1624
+		}
1625
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1626
+		if (! defined('DOING_AJAX')
1627
+			&& (
1628
+				! function_exists('is_admin')
1629
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1630
+					$capability,
1631
+					$this->page_slug
1632
+					. '_'
1633
+					. $route_to_check,
1634
+					$id
1635
+				)
1636
+			)
1637
+		) {
1638
+			if ($verify_only) {
1639
+				return false;
1640
+			}
1641
+			if (is_user_logged_in()) {
1642
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1643
+			} else {
1644
+				return false;
1645
+			}
1646
+		}
1647
+		return true;
1648
+	}
1649
+
1650
+
1651
+	/**
1652
+	 * admin_init_global
1653
+	 * This runs all the code that we want executed within the WP admin_init hook.
1654
+	 * This method executes for ALL EE Admin pages.
1655
+	 *
1656
+	 * @return void
1657
+	 */
1658
+	public function admin_init_global()
1659
+	{
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 * wp_loaded_global
1665
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1666
+	 * EE_Admin page and will execute on every EE Admin Page load
1667
+	 *
1668
+	 * @return void
1669
+	 */
1670
+	public function wp_loaded()
1671
+	{
1672
+	}
1673
+
1674
+
1675
+	/**
1676
+	 * admin_notices
1677
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1678
+	 * ALL EE_Admin pages.
1679
+	 *
1680
+	 * @return void
1681
+	 */
1682
+	public function admin_notices_global()
1683
+	{
1684
+		$this->_display_no_javascript_warning();
1685
+		$this->_display_espresso_notices();
1686
+	}
1687
+
1688
+
1689
+	public function network_admin_notices_global()
1690
+	{
1691
+		$this->_display_no_javascript_warning();
1692
+		$this->_display_espresso_notices();
1693
+	}
1694
+
1695
+
1696
+	/**
1697
+	 * admin_footer_scripts_global
1698
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1699
+	 * will apply on ALL EE_Admin pages.
1700
+	 *
1701
+	 * @return void
1702
+	 */
1703
+	public function admin_footer_scripts_global()
1704
+	{
1705
+		$this->_add_admin_page_ajax_loading_img();
1706
+		$this->_add_admin_page_overlay();
1707
+		// if metaboxes are present we need to add the nonce field
1708
+		if (isset($this->_route_config['metaboxes'])
1709
+			|| isset($this->_route_config['list_table'])
1710
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1711
+		) {
1712
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1713
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1714
+		}
1715
+	}
1716
+
1717
+
1718
+	/**
1719
+	 * admin_footer_global
1720
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1721
+	 * This particular method will apply on ALL EE_Admin Pages.
1722
+	 *
1723
+	 * @return void
1724
+	 * @throws InvalidArgumentException
1725
+	 * @throws InvalidDataTypeException
1726
+	 * @throws InvalidInterfaceException
1727
+	 */
1728
+	public function admin_footer_global()
1729
+	{
1730
+		// dialog container for dialog helper
1731
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1732
+		$d_cont .= '<div class="ee-notices"></div>';
1733
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1734
+		$d_cont .= '</div>';
1735
+		echo $d_cont;
1736
+		// help tour stuff?
1737
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1738
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1739
+		}
1740
+		// current set timezone for timezone js
1741
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1747
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1748
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1749
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1750
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1751
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1752
+	 * for the
1753
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1754
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1755
+	 *    'help_trigger_id' => array(
1756
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1757
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1758
+	 *    )
1759
+	 * );
1760
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1761
+	 *
1762
+	 * @param array $help_array
1763
+	 * @param bool  $display
1764
+	 * @return string content
1765
+	 * @throws DomainException
1766
+	 * @throws EE_Error
1767
+	 */
1768
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1769
+	{
1770
+		$content = '';
1771
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1772
+		// loop through the array and setup content
1773
+		foreach ($help_array as $trigger => $help) {
1774
+			// make sure the array is setup properly
1775
+			if (! isset($help['title'], $help['content'])) {
1776
+				throw new EE_Error(
1777
+					esc_html__(
1778
+						'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',
1779
+						'event_espresso'
1780
+					)
1781
+				);
1782
+			}
1783
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1784
+			$template_args = array(
1785
+				'help_popup_id'      => $trigger,
1786
+				'help_popup_title'   => $help['title'],
1787
+				'help_popup_content' => $help['content'],
1788
+			);
1789
+			$content .= EEH_Template::display_template(
1790
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1791
+				$template_args,
1792
+				true
1793
+			);
1794
+		}
1795
+		if ($display) {
1796
+			echo $content;
1797
+			return '';
1798
+		}
1799
+		return $content;
1800
+	}
1801
+
1802
+
1803
+	/**
1804
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1805
+	 *
1806
+	 * @return array properly formatted array for help popup content
1807
+	 * @throws EE_Error
1808
+	 */
1809
+	private function _get_help_content()
1810
+	{
1811
+		// what is the method we're looking for?
1812
+		$method_name = '_help_popup_content_' . $this->_req_action;
1813
+		// if method doesn't exist let's get out.
1814
+		if (! method_exists($this, $method_name)) {
1815
+			return array();
1816
+		}
1817
+		// k we're good to go let's retrieve the help array
1818
+		$help_array = $this->{$method_name}();
1819
+		// make sure we've got an array!
1820
+		if (! is_array($help_array)) {
1821
+			throw new EE_Error(
1822
+				esc_html__(
1823
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1824
+					'event_espresso'
1825
+				)
1826
+			);
1827
+		}
1828
+		return $help_array;
1829
+	}
1830
+
1831
+
1832
+	/**
1833
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1834
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1835
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1836
+	 *
1837
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1838
+	 * @param boolean $display    if false then we return the trigger string
1839
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1840
+	 * @return string
1841
+	 * @throws DomainException
1842
+	 * @throws EE_Error
1843
+	 */
1844
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1845
+	{
1846
+		if (defined('DOING_AJAX')) {
1847
+			return '';
1848
+		}
1849
+		// 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
1850
+		$help_array = $this->_get_help_content();
1851
+		$help_content = '';
1852
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1853
+			$help_array[ $trigger_id ] = array(
1854
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1855
+				'content' => esc_html__(
1856
+					'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.)',
1857
+					'event_espresso'
1858
+				),
1859
+			);
1860
+			$help_content = $this->_set_help_popup_content($help_array);
1861
+		}
1862
+		// let's setup the trigger
1863
+		$content = '<a class="ee-dialog" href="?height='
1864
+				   . $dimensions[0]
1865
+				   . '&width='
1866
+				   . $dimensions[1]
1867
+				   . '&inlineId='
1868
+				   . $trigger_id
1869
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1870
+		$content .= $help_content;
1871
+		if ($display) {
1872
+			echo $content;
1873
+			return '';
1874
+		}
1875
+		return $content;
1876
+	}
1877
+
1878
+
1879
+	/**
1880
+	 * _add_global_screen_options
1881
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1882
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1883
+	 *
1884
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1885
+	 *         see also WP_Screen object documents...
1886
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1887
+	 * @abstract
1888
+	 * @return void
1889
+	 */
1890
+	private function _add_global_screen_options()
1891
+	{
1892
+	}
1893
+
1894
+
1895
+	/**
1896
+	 * _add_global_feature_pointers
1897
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1898
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1899
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1900
+	 *
1901
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1902
+	 *         extended) also see:
1903
+	 * @link   http://eamann.com/tech/wordpress-portland/
1904
+	 * @abstract
1905
+	 * @return void
1906
+	 */
1907
+	private function _add_global_feature_pointers()
1908
+	{
1909
+	}
1910
+
1911
+
1912
+	/**
1913
+	 * load_global_scripts_styles
1914
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1915
+	 *
1916
+	 * @return void
1917
+	 * @throws EE_Error
1918
+	 */
1919
+	public function load_global_scripts_styles()
1920
+	{
1921
+		// add debugging styles
1922
+		if (WP_DEBUG) {
1923
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1924
+		}
1925
+		// taking care of metaboxes
1926
+		if (empty($this->_cpt_route)
1927
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1928
+		) {
1929
+			wp_enqueue_script('dashboard');
1930
+		}
1931
+
1932
+		// LOCALIZED DATA
1933
+		// localize script for ajax lazy loading
1934
+		wp_localize_script(
1935
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1936
+			'eeLazyLoadingContainers',
1937
+			apply_filters(
1938
+				'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1939
+				['espresso_news_post_box_content']
1940
+			)
1941
+		);
1942
+		/**
1943
+		 * help tour stuff
1944
+		 */
1945
+		if (EE_Registry::instance()->CFG->admin->help_tour_activation && ! empty($this->_help_tour)) {
1946
+			add_filter('FHEE_load_joyride', '__return_true');
1947
+			$tours = array();
1948
+			// setup tours for the js tour object
1949
+			foreach ($this->_help_tour['tours'] as $tour) {
1950
+				if ($tour instanceof EE_Help_Tour) {
1951
+					$tours[] = array(
1952
+						'id'      => $tour->get_slug(),
1953
+						'options' => $tour->get_options(),
1954
+					);
1955
+				}
1956
+			}
1957
+			wp_localize_script(
1958
+				EspressoLegacyAdminAssetManager::JS_HANDLE_EE_HELP_TOUR,
1959
+				'EE_HELP_TOUR',
1960
+				['tours' => $tours]
1961
+			);
1962
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1963
+		}
1964
+	}
1965
+
1966
+
1967
+	/**
1968
+	 *        admin_footer_scripts_eei18n_js_strings
1969
+	 *
1970
+	 * @return        void
1971
+	 */
1972
+	public function admin_footer_scripts_eei18n_js_strings()
1973
+	{
1974
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1975
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
1976
+			'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!!!',
1977
+			'event_espresso'
1978
+		);
1979
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
1980
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
1981
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
1982
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
1983
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
1984
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
1985
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
1986
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
1987
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
1988
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
1989
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
1990
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
1991
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
1992
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
1993
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
1994
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
1995
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
1996
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
1997
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
1998
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
1999
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2000
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2001
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2002
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2003
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2004
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2005
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2006
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2007
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2008
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2009
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2010
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2011
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2012
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2013
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2014
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2015
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2016
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2017
+	}
2018
+
2019
+
2020
+	/**
2021
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2022
+	 *
2023
+	 * @return        void
2024
+	 */
2025
+	public function add_xdebug_style()
2026
+	{
2027
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2028
+	}
2029
+
2030
+
2031
+	/************************/
2032
+	/** LIST TABLE METHODS **/
2033
+	/************************/
2034
+	/**
2035
+	 * this sets up the list table if the current view requires it.
2036
+	 *
2037
+	 * @return void
2038
+	 * @throws EE_Error
2039
+	 * @throws InvalidArgumentException
2040
+	 * @throws InvalidDataTypeException
2041
+	 * @throws InvalidInterfaceException
2042
+	 */
2043
+	protected function _set_list_table()
2044
+	{
2045
+		// first is this a list_table view?
2046
+		if (! isset($this->_route_config['list_table'])) {
2047
+			return;
2048
+		} //not a list_table view so get out.
2049
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2050
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2051
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2052
+			// user error msg
2053
+			$error_msg = esc_html__(
2054
+				'An error occurred. The requested list table views could not be found.',
2055
+				'event_espresso'
2056
+			);
2057
+			// developer error msg
2058
+			$error_msg .= '||'
2059
+						  . sprintf(
2060
+							  esc_html__(
2061
+								  '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.',
2062
+								  'event_espresso'
2063
+							  ),
2064
+							  $this->_req_action,
2065
+							  $list_table_view
2066
+						  );
2067
+			throw new EE_Error($error_msg);
2068
+		}
2069
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2070
+		$this->_views = apply_filters(
2071
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2072
+			$this->_views
2073
+		);
2074
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2075
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2076
+		$this->_set_list_table_view();
2077
+		$this->_set_list_table_object();
2078
+	}
2079
+
2080
+
2081
+	/**
2082
+	 * set current view for List Table
2083
+	 *
2084
+	 * @return void
2085
+	 */
2086
+	protected function _set_list_table_view()
2087
+	{
2088
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2089
+		// looking at active items or dumpster diving ?
2090
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2091
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2092
+		} else {
2093
+			$this->_view = sanitize_key($this->_req_data['status']);
2094
+		}
2095
+	}
2096
+
2097
+
2098
+	/**
2099
+	 * _set_list_table_object
2100
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2101
+	 *
2102
+	 * @throws InvalidInterfaceException
2103
+	 * @throws InvalidArgumentException
2104
+	 * @throws InvalidDataTypeException
2105
+	 * @throws EE_Error
2106
+	 * @throws InvalidInterfaceException
2107
+	 */
2108
+	protected function _set_list_table_object()
2109
+	{
2110
+		if (isset($this->_route_config['list_table'])) {
2111
+			if (! class_exists($this->_route_config['list_table'])) {
2112
+				throw new EE_Error(
2113
+					sprintf(
2114
+						esc_html__(
2115
+							'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.',
2116
+							'event_espresso'
2117
+						),
2118
+						$this->_route_config['list_table'],
2119
+						get_class($this)
2120
+					)
2121
+				);
2122
+			}
2123
+			$this->_list_table_object = $this->loader->getShared(
2124
+				$this->_route_config['list_table'],
2125
+				array($this)
2126
+			);
2127
+		}
2128
+	}
2129
+
2130
+
2131
+	/**
2132
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2133
+	 *
2134
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2135
+	 *                                                    urls.  The array should be indexed by the view it is being
2136
+	 *                                                    added to.
2137
+	 * @return array
2138
+	 */
2139
+	public function get_list_table_view_RLs($extra_query_args = array())
2140
+	{
2141
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2142
+		if (empty($this->_views)) {
2143
+			$this->_views = array();
2144
+		}
2145
+		// cycle thru views
2146
+		foreach ($this->_views as $key => $view) {
2147
+			$query_args = array();
2148
+			// check for current view
2149
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2150
+			$query_args['action'] = $this->_req_action;
2151
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2152
+			$query_args['status'] = $view['slug'];
2153
+			// merge any other arguments sent in.
2154
+			if (isset($extra_query_args[ $view['slug'] ])) {
2155
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2156
+					$query_args[] = $extra_query_arg;
2157
+				}
2158
+			}
2159
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2160
+		}
2161
+		return $this->_views;
2162
+	}
2163
+
2164
+
2165
+	/**
2166
+	 * _entries_per_page_dropdown
2167
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2168
+	 *
2169
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2170
+	 *         WP does it.
2171
+	 * @param int $max_entries total number of rows in the table
2172
+	 * @return string
2173
+	 */
2174
+	protected function _entries_per_page_dropdown($max_entries = 0)
2175
+	{
2176
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2177
+		$values = array(10, 25, 50, 100);
2178
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2179
+		if ($max_entries) {
2180
+			$values[] = $max_entries;
2181
+			sort($values);
2182
+		}
2183
+		$entries_per_page_dropdown = '
2184 2184
 			<div id="entries-per-page-dv" class="alignleft actions">
2185 2185
 				<label class="hide-if-no-js">
2186 2186
 					Show
2187 2187
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2188
-        foreach ($values as $value) {
2189
-            if ($value < $max_entries) {
2190
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2191
-                $entries_per_page_dropdown .= '
2188
+		foreach ($values as $value) {
2189
+			if ($value < $max_entries) {
2190
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2191
+				$entries_per_page_dropdown .= '
2192 2192
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2193
-            }
2194
-        }
2195
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2196
-        $entries_per_page_dropdown .= '
2193
+			}
2194
+		}
2195
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2196
+		$entries_per_page_dropdown .= '
2197 2197
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2198
-        $entries_per_page_dropdown .= '
2198
+		$entries_per_page_dropdown .= '
2199 2199
 					</select>
2200 2200
 					entries
2201 2201
 				</label>
2202 2202
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2203 2203
 			</div>
2204 2204
 		';
2205
-        return $entries_per_page_dropdown;
2206
-    }
2207
-
2208
-
2209
-    /**
2210
-     *        _set_search_attributes
2211
-     *
2212
-     * @return        void
2213
-     */
2214
-    public function _set_search_attributes()
2215
-    {
2216
-        $this->_template_args['search']['btn_label'] = sprintf(
2217
-            esc_html__('Search %s', 'event_espresso'),
2218
-            empty($this->_search_btn_label) ? $this->page_label
2219
-                : $this->_search_btn_label
2220
-        );
2221
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2222
-    }
2223
-
2224
-
2225
-
2226
-    /*** END LIST TABLE METHODS **/
2227
-
2228
-
2229
-    /**
2230
-     * _add_registered_metaboxes
2231
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2232
-     *
2233
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2234
-     * @return void
2235
-     * @throws EE_Error
2236
-     */
2237
-    private function _add_registered_meta_boxes()
2238
-    {
2239
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2240
-        // we only add meta boxes if the page_route calls for it
2241
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2242
-            && is_array(
2243
-                $this->_route_config['metaboxes']
2244
-            )
2245
-        ) {
2246
-            // this simply loops through the callbacks provided
2247
-            // and checks if there is a corresponding callback registered by the child
2248
-            // if there is then we go ahead and process the metabox loader.
2249
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2250
-                // first check for Closures
2251
-                if ($metabox_callback instanceof Closure) {
2252
-                    $result = $metabox_callback();
2253
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2254
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2255
-                } else {
2256
-                    $result = $this->{$metabox_callback}();
2257
-                }
2258
-                if ($result === false) {
2259
-                    // user error msg
2260
-                    $error_msg = esc_html__(
2261
-                        'An error occurred. The  requested metabox could not be found.',
2262
-                        'event_espresso'
2263
-                    );
2264
-                    // developer error msg
2265
-                    $error_msg .= '||'
2266
-                                  . sprintf(
2267
-                                      esc_html__(
2268
-                                          '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.',
2269
-                                          'event_espresso'
2270
-                                      ),
2271
-                                      $metabox_callback
2272
-                                  );
2273
-                    throw new EE_Error($error_msg);
2274
-                }
2275
-            }
2276
-        }
2277
-    }
2278
-
2279
-
2280
-    /**
2281
-     * _add_screen_columns
2282
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2283
-     * the dynamic column template and we'll setup the column options for the page.
2284
-     *
2285
-     * @return void
2286
-     */
2287
-    private function _add_screen_columns()
2288
-    {
2289
-        if (is_array($this->_route_config)
2290
-            && isset($this->_route_config['columns'])
2291
-            && is_array($this->_route_config['columns'])
2292
-            && count($this->_route_config['columns']) === 2
2293
-        ) {
2294
-            add_screen_option(
2295
-                'layout_columns',
2296
-                array(
2297
-                    'max'     => (int) $this->_route_config['columns'][0],
2298
-                    'default' => (int) $this->_route_config['columns'][1],
2299
-                )
2300
-            );
2301
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2302
-            $screen_id = $this->_current_screen->id;
2303
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2304
-            $total_columns = ! empty($screen_columns)
2305
-                ? $screen_columns
2306
-                : $this->_route_config['columns'][1];
2307
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2308
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2309
-            $this->_template_args['screen'] = $this->_current_screen;
2310
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2311
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2312
-            // finally if we don't have has_metaboxes set in the route config
2313
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2314
-            $this->_route_config['has_metaboxes'] = true;
2315
-        }
2316
-    }
2317
-
2318
-
2319
-
2320
-    /** GLOBALLY AVAILABLE METABOXES **/
2321
-
2322
-
2323
-    /**
2324
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2325
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2326
-     * these get loaded on.
2327
-     */
2328
-    private function _espresso_news_post_box()
2329
-    {
2330
-        $news_box_title = apply_filters(
2331
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2332
-            esc_html__('New @ Event Espresso', 'event_espresso')
2333
-        );
2334
-        add_meta_box(
2335
-            'espresso_news_post_box',
2336
-            $news_box_title,
2337
-            array(
2338
-                $this,
2339
-                'espresso_news_post_box',
2340
-            ),
2341
-            $this->_wp_page_slug,
2342
-            'side'
2343
-        );
2344
-    }
2345
-
2346
-
2347
-    /**
2348
-     * Code for setting up espresso ratings request metabox.
2349
-     */
2350
-    protected function _espresso_ratings_request()
2351
-    {
2352
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2353
-            return;
2354
-        }
2355
-        $ratings_box_title = apply_filters(
2356
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2357
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2358
-        );
2359
-        add_meta_box(
2360
-            'espresso_ratings_request',
2361
-            $ratings_box_title,
2362
-            array(
2363
-                $this,
2364
-                'espresso_ratings_request',
2365
-            ),
2366
-            $this->_wp_page_slug,
2367
-            'side'
2368
-        );
2369
-    }
2370
-
2371
-
2372
-    /**
2373
-     * Code for setting up espresso ratings request metabox content.
2374
-     *
2375
-     * @throws DomainException
2376
-     */
2377
-    public function espresso_ratings_request()
2378
-    {
2379
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2380
-    }
2381
-
2382
-
2383
-    public static function cached_rss_display($rss_id, $url)
2384
-    {
2385
-        $loading = '<p class="widget-loading hide-if-no-js">'
2386
-                   . __('Loading&#8230;', 'event_espresso')
2387
-                   . '</p><p class="hide-if-js">'
2388
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2389
-                   . '</p>';
2390
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2391
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2392
-        $post = '</div>' . "\n";
2393
-        $cache_key = 'ee_rss_' . md5($rss_id);
2394
-        $output = get_transient($cache_key);
2395
-        if ($output !== false) {
2396
-            echo $pre . $output . $post;
2397
-            return true;
2398
-        }
2399
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2400
-            echo $pre . $loading . $post;
2401
-            return false;
2402
-        }
2403
-        ob_start();
2404
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2405
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2406
-        return true;
2407
-    }
2408
-
2409
-
2410
-    public function espresso_news_post_box()
2411
-    {
2412
-        ?>
2205
+		return $entries_per_page_dropdown;
2206
+	}
2207
+
2208
+
2209
+	/**
2210
+	 *        _set_search_attributes
2211
+	 *
2212
+	 * @return        void
2213
+	 */
2214
+	public function _set_search_attributes()
2215
+	{
2216
+		$this->_template_args['search']['btn_label'] = sprintf(
2217
+			esc_html__('Search %s', 'event_espresso'),
2218
+			empty($this->_search_btn_label) ? $this->page_label
2219
+				: $this->_search_btn_label
2220
+		);
2221
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2222
+	}
2223
+
2224
+
2225
+
2226
+	/*** END LIST TABLE METHODS **/
2227
+
2228
+
2229
+	/**
2230
+	 * _add_registered_metaboxes
2231
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2232
+	 *
2233
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2234
+	 * @return void
2235
+	 * @throws EE_Error
2236
+	 */
2237
+	private function _add_registered_meta_boxes()
2238
+	{
2239
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2240
+		// we only add meta boxes if the page_route calls for it
2241
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2242
+			&& is_array(
2243
+				$this->_route_config['metaboxes']
2244
+			)
2245
+		) {
2246
+			// this simply loops through the callbacks provided
2247
+			// and checks if there is a corresponding callback registered by the child
2248
+			// if there is then we go ahead and process the metabox loader.
2249
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2250
+				// first check for Closures
2251
+				if ($metabox_callback instanceof Closure) {
2252
+					$result = $metabox_callback();
2253
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2254
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2255
+				} else {
2256
+					$result = $this->{$metabox_callback}();
2257
+				}
2258
+				if ($result === false) {
2259
+					// user error msg
2260
+					$error_msg = esc_html__(
2261
+						'An error occurred. The  requested metabox could not be found.',
2262
+						'event_espresso'
2263
+					);
2264
+					// developer error msg
2265
+					$error_msg .= '||'
2266
+								  . sprintf(
2267
+									  esc_html__(
2268
+										  '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.',
2269
+										  'event_espresso'
2270
+									  ),
2271
+									  $metabox_callback
2272
+								  );
2273
+					throw new EE_Error($error_msg);
2274
+				}
2275
+			}
2276
+		}
2277
+	}
2278
+
2279
+
2280
+	/**
2281
+	 * _add_screen_columns
2282
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2283
+	 * the dynamic column template and we'll setup the column options for the page.
2284
+	 *
2285
+	 * @return void
2286
+	 */
2287
+	private function _add_screen_columns()
2288
+	{
2289
+		if (is_array($this->_route_config)
2290
+			&& isset($this->_route_config['columns'])
2291
+			&& is_array($this->_route_config['columns'])
2292
+			&& count($this->_route_config['columns']) === 2
2293
+		) {
2294
+			add_screen_option(
2295
+				'layout_columns',
2296
+				array(
2297
+					'max'     => (int) $this->_route_config['columns'][0],
2298
+					'default' => (int) $this->_route_config['columns'][1],
2299
+				)
2300
+			);
2301
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2302
+			$screen_id = $this->_current_screen->id;
2303
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2304
+			$total_columns = ! empty($screen_columns)
2305
+				? $screen_columns
2306
+				: $this->_route_config['columns'][1];
2307
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2308
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2309
+			$this->_template_args['screen'] = $this->_current_screen;
2310
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2311
+										   . 'admin_details_metabox_column_wrapper.template.php';
2312
+			// finally if we don't have has_metaboxes set in the route config
2313
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2314
+			$this->_route_config['has_metaboxes'] = true;
2315
+		}
2316
+	}
2317
+
2318
+
2319
+
2320
+	/** GLOBALLY AVAILABLE METABOXES **/
2321
+
2322
+
2323
+	/**
2324
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2325
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2326
+	 * these get loaded on.
2327
+	 */
2328
+	private function _espresso_news_post_box()
2329
+	{
2330
+		$news_box_title = apply_filters(
2331
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2332
+			esc_html__('New @ Event Espresso', 'event_espresso')
2333
+		);
2334
+		add_meta_box(
2335
+			'espresso_news_post_box',
2336
+			$news_box_title,
2337
+			array(
2338
+				$this,
2339
+				'espresso_news_post_box',
2340
+			),
2341
+			$this->_wp_page_slug,
2342
+			'side'
2343
+		);
2344
+	}
2345
+
2346
+
2347
+	/**
2348
+	 * Code for setting up espresso ratings request metabox.
2349
+	 */
2350
+	protected function _espresso_ratings_request()
2351
+	{
2352
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2353
+			return;
2354
+		}
2355
+		$ratings_box_title = apply_filters(
2356
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2357
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2358
+		);
2359
+		add_meta_box(
2360
+			'espresso_ratings_request',
2361
+			$ratings_box_title,
2362
+			array(
2363
+				$this,
2364
+				'espresso_ratings_request',
2365
+			),
2366
+			$this->_wp_page_slug,
2367
+			'side'
2368
+		);
2369
+	}
2370
+
2371
+
2372
+	/**
2373
+	 * Code for setting up espresso ratings request metabox content.
2374
+	 *
2375
+	 * @throws DomainException
2376
+	 */
2377
+	public function espresso_ratings_request()
2378
+	{
2379
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2380
+	}
2381
+
2382
+
2383
+	public static function cached_rss_display($rss_id, $url)
2384
+	{
2385
+		$loading = '<p class="widget-loading hide-if-no-js">'
2386
+				   . __('Loading&#8230;', 'event_espresso')
2387
+				   . '</p><p class="hide-if-js">'
2388
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2389
+				   . '</p>';
2390
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2391
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2392
+		$post = '</div>' . "\n";
2393
+		$cache_key = 'ee_rss_' . md5($rss_id);
2394
+		$output = get_transient($cache_key);
2395
+		if ($output !== false) {
2396
+			echo $pre . $output . $post;
2397
+			return true;
2398
+		}
2399
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2400
+			echo $pre . $loading . $post;
2401
+			return false;
2402
+		}
2403
+		ob_start();
2404
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2405
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2406
+		return true;
2407
+	}
2408
+
2409
+
2410
+	public function espresso_news_post_box()
2411
+	{
2412
+		?>
2413 2413
         <div class="padding">
2414 2414
             <div id="espresso_news_post_box_content" class="infolinks">
2415 2415
                 <?php
2416
-                // Get RSS Feed(s)
2417
-                EE_Admin_Page::cached_rss_display(
2418
-                    'espresso_news_post_box_content',
2419
-                    urlencode(
2420
-                        apply_filters(
2421
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2422
-                            'http://eventespresso.com/feed/'
2423
-                        )
2424
-                    )
2425
-                );
2426
-                ?>
2416
+				// Get RSS Feed(s)
2417
+				EE_Admin_Page::cached_rss_display(
2418
+					'espresso_news_post_box_content',
2419
+					urlencode(
2420
+						apply_filters(
2421
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2422
+							'http://eventespresso.com/feed/'
2423
+						)
2424
+					)
2425
+				);
2426
+				?>
2427 2427
             </div>
2428 2428
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2429 2429
         </div>
2430 2430
         <?php
2431
-    }
2432
-
2433
-
2434
-    private function _espresso_links_post_box()
2435
-    {
2436
-        // Hiding until we actually have content to put in here...
2437
-        // 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');
2438
-    }
2439
-
2440
-
2441
-    public function espresso_links_post_box()
2442
-    {
2443
-        // Hiding until we actually have content to put in here...
2444
-        // EEH_Template::display_template(
2445
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2446
-        // );
2447
-    }
2448
-
2449
-
2450
-    protected function _espresso_sponsors_post_box()
2451
-    {
2452
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2453
-            add_meta_box(
2454
-                'espresso_sponsors_post_box',
2455
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2456
-                array($this, 'espresso_sponsors_post_box'),
2457
-                $this->_wp_page_slug,
2458
-                'side'
2459
-            );
2460
-        }
2461
-    }
2462
-
2463
-
2464
-    public function espresso_sponsors_post_box()
2465
-    {
2466
-        EEH_Template::display_template(
2467
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2468
-        );
2469
-    }
2470
-
2471
-
2472
-    private function _publish_post_box()
2473
-    {
2474
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2475
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2476
-        // then we'll use that for the metabox label.
2477
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2478
-        if (! empty($this->_labels['publishbox'])) {
2479
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2480
-                : $this->_labels['publishbox'];
2481
-        } else {
2482
-            $box_label = esc_html__('Publish', 'event_espresso');
2483
-        }
2484
-        $box_label = apply_filters(
2485
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2486
-            $box_label,
2487
-            $this->_req_action,
2488
-            $this
2489
-        );
2490
-        add_meta_box(
2491
-            $meta_box_ref,
2492
-            $box_label,
2493
-            array($this, 'editor_overview'),
2494
-            $this->_current_screen->id,
2495
-            'side',
2496
-            'high'
2497
-        );
2498
-    }
2499
-
2500
-
2501
-    public function editor_overview()
2502
-    {
2503
-        // if we have extra content set let's add it in if not make sure its empty
2504
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2505
-            ? $this->_template_args['publish_box_extra_content']
2506
-            : '';
2507
-        echo EEH_Template::display_template(
2508
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2509
-            $this->_template_args,
2510
-            true
2511
-        );
2512
-    }
2513
-
2514
-
2515
-    /** end of globally available metaboxes section **/
2516
-
2517
-
2518
-    /**
2519
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2520
-     * protected method.
2521
-     *
2522
-     * @see   $this->_set_publish_post_box_vars for param details
2523
-     * @since 4.6.0
2524
-     * @param string $name
2525
-     * @param int    $id
2526
-     * @param bool   $delete
2527
-     * @param string $save_close_redirect_URL
2528
-     * @param bool   $both_btns
2529
-     * @throws EE_Error
2530
-     * @throws InvalidArgumentException
2531
-     * @throws InvalidDataTypeException
2532
-     * @throws InvalidInterfaceException
2533
-     */
2534
-    public function set_publish_post_box_vars(
2535
-        $name = '',
2536
-        $id = 0,
2537
-        $delete = false,
2538
-        $save_close_redirect_URL = '',
2539
-        $both_btns = true
2540
-    ) {
2541
-        $this->_set_publish_post_box_vars(
2542
-            $name,
2543
-            $id,
2544
-            $delete,
2545
-            $save_close_redirect_URL,
2546
-            $both_btns
2547
-        );
2548
-    }
2549
-
2550
-
2551
-    /**
2552
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2553
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2554
-     * save, and save and close buttons to work properly, then you will want to include a
2555
-     * values for the name and id arguments.
2556
-     *
2557
-     * @todo  Add in validation for name/id arguments.
2558
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2559
-     * @param    int     $id                      id attached to the item published
2560
-     * @param    string  $delete                  page route callback for the delete action
2561
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2562
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2563
-     *                                            the Save button
2564
-     * @throws EE_Error
2565
-     * @throws InvalidArgumentException
2566
-     * @throws InvalidDataTypeException
2567
-     * @throws InvalidInterfaceException
2568
-     */
2569
-    protected function _set_publish_post_box_vars(
2570
-        $name = '',
2571
-        $id = 0,
2572
-        $delete = '',
2573
-        $save_close_redirect_URL = '',
2574
-        $both_btns = true
2575
-    ) {
2576
-        // if Save & Close, use a custom redirect URL or default to the main page?
2577
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2578
-            ? $save_close_redirect_URL
2579
-            : $this->_admin_base_url;
2580
-        // create the Save & Close and Save buttons
2581
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2582
-        // if we have extra content set let's add it in if not make sure its empty
2583
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2584
-            ? $this->_template_args['publish_box_extra_content']
2585
-            : '';
2586
-        if ($delete && ! empty($id)) {
2587
-            // make sure we have a default if just true is sent.
2588
-            $delete = ! empty($delete) ? $delete : 'delete';
2589
-            $delete_link_args = array($name => $id);
2590
-            $delete = $this->get_action_link_or_button(
2591
-                $delete,
2592
-                $delete,
2593
-                $delete_link_args,
2594
-                'submitdelete deletion'
2595
-            );
2596
-        }
2597
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2598
-        if (! empty($name) && ! empty($id)) {
2599
-            $hidden_field_arr[ $name ] = array(
2600
-                'type'  => 'hidden',
2601
-                'value' => $id,
2602
-            );
2603
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2604
-        } else {
2605
-            $hf = '';
2606
-        }
2607
-        // add hidden field
2608
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2609
-            ? $hf[ $name ]['field']
2610
-            : $hf;
2611
-    }
2612
-
2613
-
2614
-    /**
2615
-     * displays an error message to ppl who have javascript disabled
2616
-     *
2617
-     * @return void
2618
-     */
2619
-    private function _display_no_javascript_warning()
2620
-    {
2621
-        ?>
2431
+	}
2432
+
2433
+
2434
+	private function _espresso_links_post_box()
2435
+	{
2436
+		// Hiding until we actually have content to put in here...
2437
+		// 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');
2438
+	}
2439
+
2440
+
2441
+	public function espresso_links_post_box()
2442
+	{
2443
+		// Hiding until we actually have content to put in here...
2444
+		// EEH_Template::display_template(
2445
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2446
+		// );
2447
+	}
2448
+
2449
+
2450
+	protected function _espresso_sponsors_post_box()
2451
+	{
2452
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2453
+			add_meta_box(
2454
+				'espresso_sponsors_post_box',
2455
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2456
+				array($this, 'espresso_sponsors_post_box'),
2457
+				$this->_wp_page_slug,
2458
+				'side'
2459
+			);
2460
+		}
2461
+	}
2462
+
2463
+
2464
+	public function espresso_sponsors_post_box()
2465
+	{
2466
+		EEH_Template::display_template(
2467
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2468
+		);
2469
+	}
2470
+
2471
+
2472
+	private function _publish_post_box()
2473
+	{
2474
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2475
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2476
+		// then we'll use that for the metabox label.
2477
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2478
+		if (! empty($this->_labels['publishbox'])) {
2479
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2480
+				: $this->_labels['publishbox'];
2481
+		} else {
2482
+			$box_label = esc_html__('Publish', 'event_espresso');
2483
+		}
2484
+		$box_label = apply_filters(
2485
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2486
+			$box_label,
2487
+			$this->_req_action,
2488
+			$this
2489
+		);
2490
+		add_meta_box(
2491
+			$meta_box_ref,
2492
+			$box_label,
2493
+			array($this, 'editor_overview'),
2494
+			$this->_current_screen->id,
2495
+			'side',
2496
+			'high'
2497
+		);
2498
+	}
2499
+
2500
+
2501
+	public function editor_overview()
2502
+	{
2503
+		// if we have extra content set let's add it in if not make sure its empty
2504
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2505
+			? $this->_template_args['publish_box_extra_content']
2506
+			: '';
2507
+		echo EEH_Template::display_template(
2508
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2509
+			$this->_template_args,
2510
+			true
2511
+		);
2512
+	}
2513
+
2514
+
2515
+	/** end of globally available metaboxes section **/
2516
+
2517
+
2518
+	/**
2519
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2520
+	 * protected method.
2521
+	 *
2522
+	 * @see   $this->_set_publish_post_box_vars for param details
2523
+	 * @since 4.6.0
2524
+	 * @param string $name
2525
+	 * @param int    $id
2526
+	 * @param bool   $delete
2527
+	 * @param string $save_close_redirect_URL
2528
+	 * @param bool   $both_btns
2529
+	 * @throws EE_Error
2530
+	 * @throws InvalidArgumentException
2531
+	 * @throws InvalidDataTypeException
2532
+	 * @throws InvalidInterfaceException
2533
+	 */
2534
+	public function set_publish_post_box_vars(
2535
+		$name = '',
2536
+		$id = 0,
2537
+		$delete = false,
2538
+		$save_close_redirect_URL = '',
2539
+		$both_btns = true
2540
+	) {
2541
+		$this->_set_publish_post_box_vars(
2542
+			$name,
2543
+			$id,
2544
+			$delete,
2545
+			$save_close_redirect_URL,
2546
+			$both_btns
2547
+		);
2548
+	}
2549
+
2550
+
2551
+	/**
2552
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2553
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2554
+	 * save, and save and close buttons to work properly, then you will want to include a
2555
+	 * values for the name and id arguments.
2556
+	 *
2557
+	 * @todo  Add in validation for name/id arguments.
2558
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2559
+	 * @param    int     $id                      id attached to the item published
2560
+	 * @param    string  $delete                  page route callback for the delete action
2561
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2562
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2563
+	 *                                            the Save button
2564
+	 * @throws EE_Error
2565
+	 * @throws InvalidArgumentException
2566
+	 * @throws InvalidDataTypeException
2567
+	 * @throws InvalidInterfaceException
2568
+	 */
2569
+	protected function _set_publish_post_box_vars(
2570
+		$name = '',
2571
+		$id = 0,
2572
+		$delete = '',
2573
+		$save_close_redirect_URL = '',
2574
+		$both_btns = true
2575
+	) {
2576
+		// if Save & Close, use a custom redirect URL or default to the main page?
2577
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2578
+			? $save_close_redirect_URL
2579
+			: $this->_admin_base_url;
2580
+		// create the Save & Close and Save buttons
2581
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2582
+		// if we have extra content set let's add it in if not make sure its empty
2583
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2584
+			? $this->_template_args['publish_box_extra_content']
2585
+			: '';
2586
+		if ($delete && ! empty($id)) {
2587
+			// make sure we have a default if just true is sent.
2588
+			$delete = ! empty($delete) ? $delete : 'delete';
2589
+			$delete_link_args = array($name => $id);
2590
+			$delete = $this->get_action_link_or_button(
2591
+				$delete,
2592
+				$delete,
2593
+				$delete_link_args,
2594
+				'submitdelete deletion'
2595
+			);
2596
+		}
2597
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2598
+		if (! empty($name) && ! empty($id)) {
2599
+			$hidden_field_arr[ $name ] = array(
2600
+				'type'  => 'hidden',
2601
+				'value' => $id,
2602
+			);
2603
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2604
+		} else {
2605
+			$hf = '';
2606
+		}
2607
+		// add hidden field
2608
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2609
+			? $hf[ $name ]['field']
2610
+			: $hf;
2611
+	}
2612
+
2613
+
2614
+	/**
2615
+	 * displays an error message to ppl who have javascript disabled
2616
+	 *
2617
+	 * @return void
2618
+	 */
2619
+	private function _display_no_javascript_warning()
2620
+	{
2621
+		?>
2622 2622
         <noscript>
2623 2623
             <div id="no-js-message" class="error">
2624 2624
                 <p style="font-size:1.3em;">
2625 2625
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2626 2626
                     <?php esc_html_e(
2627
-                        '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.',
2628
-                        'event_espresso'
2629
-                    ); ?>
2627
+						'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.',
2628
+						'event_espresso'
2629
+					); ?>
2630 2630
                 </p>
2631 2631
             </div>
2632 2632
         </noscript>
2633 2633
         <?php
2634
-    }
2635
-
2636
-
2637
-    /**
2638
-     * displays espresso success and/or error notices
2639
-     *
2640
-     * @return void
2641
-     */
2642
-    private function _display_espresso_notices()
2643
-    {
2644
-        $notices = $this->_get_transient(true);
2645
-        echo stripslashes($notices);
2646
-    }
2647
-
2648
-
2649
-    /**
2650
-     * spinny things pacify the masses
2651
-     *
2652
-     * @return void
2653
-     */
2654
-    protected function _add_admin_page_ajax_loading_img()
2655
-    {
2656
-        ?>
2634
+	}
2635
+
2636
+
2637
+	/**
2638
+	 * displays espresso success and/or error notices
2639
+	 *
2640
+	 * @return void
2641
+	 */
2642
+	private function _display_espresso_notices()
2643
+	{
2644
+		$notices = $this->_get_transient(true);
2645
+		echo stripslashes($notices);
2646
+	}
2647
+
2648
+
2649
+	/**
2650
+	 * spinny things pacify the masses
2651
+	 *
2652
+	 * @return void
2653
+	 */
2654
+	protected function _add_admin_page_ajax_loading_img()
2655
+	{
2656
+		?>
2657 2657
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2658 2658
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2659
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2659
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2660 2660
         </div>
2661 2661
         <?php
2662
-    }
2662
+	}
2663 2663
 
2664 2664
 
2665
-    /**
2666
-     * add admin page overlay for modal boxes
2667
-     *
2668
-     * @return void
2669
-     */
2670
-    protected function _add_admin_page_overlay()
2671
-    {
2672
-        ?>
2665
+	/**
2666
+	 * add admin page overlay for modal boxes
2667
+	 *
2668
+	 * @return void
2669
+	 */
2670
+	protected function _add_admin_page_overlay()
2671
+	{
2672
+		?>
2673 2673
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2674 2674
         <?php
2675
-    }
2676
-
2677
-
2678
-    /**
2679
-     * facade for add_meta_box
2680
-     *
2681
-     * @param string  $action        where the metabox get's displayed
2682
-     * @param string  $title         Title of Metabox (output in metabox header)
2683
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2684
-     *                               instead of the one created in here.
2685
-     * @param array   $callback_args an array of args supplied for the metabox
2686
-     * @param string  $column        what metabox column
2687
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2688
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2689
-     *                               created but just set our own callback for wp's add_meta_box.
2690
-     * @throws DomainException
2691
-     */
2692
-    public function _add_admin_page_meta_box(
2693
-        $action,
2694
-        $title,
2695
-        $callback,
2696
-        $callback_args,
2697
-        $column = 'normal',
2698
-        $priority = 'high',
2699
-        $create_func = true
2700
-    ) {
2701
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2702
-        // 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.
2703
-        if (empty($callback_args) && $create_func) {
2704
-            $callback_args = array(
2705
-                'template_path' => $this->_template_path,
2706
-                'template_args' => $this->_template_args,
2707
-            );
2708
-        }
2709
-        // 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)
2710
-        $call_back_func = $create_func
2711
-            ? static function ($post, $metabox) {
2712
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2713
-                echo EEH_Template::display_template(
2714
-                    $metabox['args']['template_path'],
2715
-                    $metabox['args']['template_args'],
2716
-                    true
2717
-                );
2718
-            }
2719
-            : $callback;
2720
-        add_meta_box(
2721
-            str_replace('_', '-', $action) . '-mbox',
2722
-            $title,
2723
-            $call_back_func,
2724
-            $this->_wp_page_slug,
2725
-            $column,
2726
-            $priority,
2727
-            $callback_args
2728
-        );
2729
-    }
2730
-
2731
-
2732
-    /**
2733
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2734
-     *
2735
-     * @throws DomainException
2736
-     * @throws EE_Error
2737
-     * @throws InvalidArgumentException
2738
-     * @throws InvalidDataTypeException
2739
-     * @throws InvalidInterfaceException
2740
-     */
2741
-    public function display_admin_page_with_metabox_columns()
2742
-    {
2743
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2744
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2745
-            $this->_column_template_path,
2746
-            $this->_template_args,
2747
-            true
2748
-        );
2749
-        // the final wrapper
2750
-        $this->admin_page_wrapper();
2751
-    }
2752
-
2753
-
2754
-    /**
2755
-     * generates  HTML wrapper for an admin details page
2756
-     *
2757
-     * @return void
2758
-     * @throws DomainException
2759
-     * @throws EE_Error
2760
-     * @throws InvalidArgumentException
2761
-     * @throws InvalidDataTypeException
2762
-     * @throws InvalidInterfaceException
2763
-     */
2764
-    public function display_admin_page_with_sidebar()
2765
-    {
2766
-        $this->_display_admin_page(true);
2767
-    }
2768
-
2769
-
2770
-    /**
2771
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2772
-     *
2773
-     * @return void
2774
-     * @throws DomainException
2775
-     * @throws EE_Error
2776
-     * @throws InvalidArgumentException
2777
-     * @throws InvalidDataTypeException
2778
-     * @throws InvalidInterfaceException
2779
-     */
2780
-    public function display_admin_page_with_no_sidebar()
2781
-    {
2782
-        $this->_display_admin_page();
2783
-    }
2784
-
2785
-
2786
-    /**
2787
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2788
-     *
2789
-     * @return void
2790
-     * @throws DomainException
2791
-     * @throws EE_Error
2792
-     * @throws InvalidArgumentException
2793
-     * @throws InvalidDataTypeException
2794
-     * @throws InvalidInterfaceException
2795
-     */
2796
-    public function display_about_admin_page()
2797
-    {
2798
-        $this->_display_admin_page(false, true);
2799
-    }
2800
-
2801
-
2802
-    /**
2803
-     * display_admin_page
2804
-     * contains the code for actually displaying an admin page
2805
-     *
2806
-     * @param boolean $sidebar true with sidebar, false without
2807
-     * @param boolean $about   use the about admin wrapper instead of the default.
2808
-     * @return void
2809
-     * @throws DomainException
2810
-     * @throws EE_Error
2811
-     * @throws InvalidArgumentException
2812
-     * @throws InvalidDataTypeException
2813
-     * @throws InvalidInterfaceException
2814
-     */
2815
-    private function _display_admin_page($sidebar = false, $about = false)
2816
-    {
2817
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2818
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2819
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2820
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2821
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2822
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2823
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2824
-            ? 'poststuff'
2825
-            : 'espresso-default-admin';
2826
-        $template_path = $sidebar
2827
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2828
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2829
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2830
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2831
-        }
2832
-        $template_path = ! empty($this->_column_template_path)
2833
-            ? $this->_column_template_path : $template_path;
2834
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2835
-            ? $this->_template_args['admin_page_content']
2836
-            : '';
2837
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2838
-            ? $this->_template_args['before_admin_page_content']
2839
-            : '';
2840
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2841
-            ? $this->_template_args['after_admin_page_content']
2842
-            : '';
2843
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2844
-            $template_path,
2845
-            $this->_template_args,
2846
-            true
2847
-        );
2848
-        // the final template wrapper
2849
-        $this->admin_page_wrapper($about);
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * This is used to display caf preview pages.
2855
-     *
2856
-     * @since 4.3.2
2857
-     * @param string $utm_campaign_source what is the key used for google analytics link
2858
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2859
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2860
-     * @return void
2861
-     * @throws DomainException
2862
-     * @throws EE_Error
2863
-     * @throws InvalidArgumentException
2864
-     * @throws InvalidDataTypeException
2865
-     * @throws InvalidInterfaceException
2866
-     */
2867
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2868
-    {
2869
-        // let's generate a default preview action button if there isn't one already present.
2870
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2871
-            'Upgrade to Event Espresso 4 Right Now',
2872
-            'event_espresso'
2873
-        );
2874
-        $buy_now_url = add_query_arg(
2875
-            array(
2876
-                'ee_ver'       => 'ee4',
2877
-                'utm_source'   => 'ee4_plugin_admin',
2878
-                'utm_medium'   => 'link',
2879
-                'utm_campaign' => $utm_campaign_source,
2880
-                'utm_content'  => 'buy_now_button',
2881
-            ),
2882
-            'http://eventespresso.com/pricing/'
2883
-        );
2884
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2885
-            ? $this->get_action_link_or_button(
2886
-                '',
2887
-                'buy_now',
2888
-                array(),
2889
-                'button-primary button-large',
2890
-                $buy_now_url,
2891
-                true
2892
-            )
2893
-            : $this->_template_args['preview_action_button'];
2894
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2895
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2896
-            $this->_template_args,
2897
-            true
2898
-        );
2899
-        $this->_display_admin_page($display_sidebar);
2900
-    }
2901
-
2902
-
2903
-    /**
2904
-     * display_admin_list_table_page_with_sidebar
2905
-     * generates HTML wrapper for an admin_page with list_table
2906
-     *
2907
-     * @return void
2908
-     * @throws DomainException
2909
-     * @throws EE_Error
2910
-     * @throws InvalidArgumentException
2911
-     * @throws InvalidDataTypeException
2912
-     * @throws InvalidInterfaceException
2913
-     */
2914
-    public function display_admin_list_table_page_with_sidebar()
2915
-    {
2916
-        $this->_display_admin_list_table_page(true);
2917
-    }
2918
-
2919
-
2920
-    /**
2921
-     * display_admin_list_table_page_with_no_sidebar
2922
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2923
-     *
2924
-     * @return void
2925
-     * @throws DomainException
2926
-     * @throws EE_Error
2927
-     * @throws InvalidArgumentException
2928
-     * @throws InvalidDataTypeException
2929
-     * @throws InvalidInterfaceException
2930
-     */
2931
-    public function display_admin_list_table_page_with_no_sidebar()
2932
-    {
2933
-        $this->_display_admin_list_table_page();
2934
-    }
2935
-
2936
-
2937
-    /**
2938
-     * generates html wrapper for an admin_list_table page
2939
-     *
2940
-     * @param boolean $sidebar whether to display with sidebar or not.
2941
-     * @return void
2942
-     * @throws DomainException
2943
-     * @throws EE_Error
2944
-     * @throws InvalidArgumentException
2945
-     * @throws InvalidDataTypeException
2946
-     * @throws InvalidInterfaceException
2947
-     */
2948
-    private function _display_admin_list_table_page($sidebar = false)
2949
-    {
2950
-        // setup search attributes
2951
-        $this->_set_search_attributes();
2952
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2953
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2954
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2955
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2956
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2957
-        $this->_template_args['list_table'] = $this->_list_table_object;
2958
-        $this->_template_args['current_route'] = $this->_req_action;
2959
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2960
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2961
-        if (! empty($ajax_sorting_callback)) {
2962
-            $sortable_list_table_form_fields = wp_nonce_field(
2963
-                $ajax_sorting_callback . '_nonce',
2964
-                $ajax_sorting_callback . '_nonce',
2965
-                false,
2966
-                false
2967
-            );
2968
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2969
-                                                . $this->page_slug
2970
-                                                . '" />';
2971
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2972
-                                                . $ajax_sorting_callback
2973
-                                                . '" />';
2974
-        } else {
2975
-            $sortable_list_table_form_fields = '';
2976
-        }
2977
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2978
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2979
-            ? $this->_template_args['list_table_hidden_fields']
2980
-            : '';
2981
-        $nonce_ref = $this->_req_action . '_nonce';
2982
-        $hidden_form_fields .= '<input type="hidden" name="'
2983
-                               . $nonce_ref
2984
-                               . '" value="'
2985
-                               . wp_create_nonce($nonce_ref)
2986
-                               . '">';
2987
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2988
-        // display message about search results?
2989
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2990
-            ? '<p class="ee-search-results">' . sprintf(
2991
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2992
-                trim($this->_req_data['s'], '%')
2993
-            ) . '</p>'
2994
-            : '';
2995
-        // filter before_list_table template arg
2996
-        $this->_template_args['before_list_table'] = apply_filters(
2997
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2998
-            $this->_template_args['before_list_table'],
2999
-            $this->page_slug,
3000
-            $this->_req_data,
3001
-            $this->_req_action
3002
-        );
3003
-        // convert to array and filter again
3004
-        // arrays are easier to inject new items in a specific location,
3005
-        // but would not be backwards compatible, so we have to add a new filter
3006
-        $this->_template_args['before_list_table'] = implode(
3007
-            " \n",
3008
-            (array) apply_filters(
3009
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3010
-                (array) $this->_template_args['before_list_table'],
3011
-                $this->page_slug,
3012
-                $this->_req_data,
3013
-                $this->_req_action
3014
-            )
3015
-        );
3016
-        // filter after_list_table template arg
3017
-        $this->_template_args['after_list_table'] = apply_filters(
3018
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3019
-            $this->_template_args['after_list_table'],
3020
-            $this->page_slug,
3021
-            $this->_req_data,
3022
-            $this->_req_action
3023
-        );
3024
-        // convert to array and filter again
3025
-        // arrays are easier to inject new items in a specific location,
3026
-        // but would not be backwards compatible, so we have to add a new filter
3027
-        $this->_template_args['after_list_table'] = implode(
3028
-            " \n",
3029
-            (array) apply_filters(
3030
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3031
-                (array) $this->_template_args['after_list_table'],
3032
-                $this->page_slug,
3033
-                $this->_req_data,
3034
-                $this->_req_action
3035
-            )
3036
-        );
3037
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3038
-            $template_path,
3039
-            $this->_template_args,
3040
-            true
3041
-        );
3042
-        // the final template wrapper
3043
-        if ($sidebar) {
3044
-            $this->display_admin_page_with_sidebar();
3045
-        } else {
3046
-            $this->display_admin_page_with_no_sidebar();
3047
-        }
3048
-    }
3049
-
3050
-
3051
-    /**
3052
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3053
-     * html string for the legend.
3054
-     * $items are expected in an array in the following format:
3055
-     * $legend_items = array(
3056
-     *        'item_id' => array(
3057
-     *            'icon' => 'http://url_to_icon_being_described.png',
3058
-     *            'desc' => esc_html__('localized description of item');
3059
-     *        )
3060
-     * );
3061
-     *
3062
-     * @param  array $items see above for format of array
3063
-     * @return string html string of legend
3064
-     * @throws DomainException
3065
-     */
3066
-    protected function _display_legend($items)
3067
-    {
3068
-        $this->_template_args['items'] = apply_filters(
3069
-            'FHEE__EE_Admin_Page___display_legend__items',
3070
-            (array) $items,
3071
-            $this
3072
-        );
3073
-        /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
3074
-        $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
3075
-        if (! $status_change_notice->isDismissed()) {
3076
-            $this->_template_args['status_change_notice'] = EEH_Template::display_template(
3077
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
3078
-                [ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
3079
-                true
3080
-            );
3081
-        }
3082
-        return EEH_Template::display_template(
3083
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3084
-            $this->_template_args,
3085
-            true
3086
-        );
3087
-    }
3088
-
3089
-
3090
-    /**
3091
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3092
-     * The returned json object is created from an array in the following format:
3093
-     * array(
3094
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3095
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3096
-     *  'notices' => '', // - contains any EE_Error formatted notices
3097
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3098
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3099
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3100
-     *  that might be included in here)
3101
-     * )
3102
-     * The json object is populated by whatever is set in the $_template_args property.
3103
-     *
3104
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3105
-     *                                 instead of displayed.
3106
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3107
-     * @return void
3108
-     * @throws EE_Error
3109
-     * @throws InvalidArgumentException
3110
-     * @throws InvalidDataTypeException
3111
-     * @throws InvalidInterfaceException
3112
-     */
3113
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3114
-    {
3115
-        // make sure any EE_Error notices have been handled.
3116
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3117
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3118
-        unset($this->_template_args['data']);
3119
-        $json = array(
3120
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3121
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3122
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3123
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3124
-            'notices'   => EE_Error::get_notices(),
3125
-            'content'   => isset($this->_template_args['admin_page_content'])
3126
-                ? $this->_template_args['admin_page_content'] : '',
3127
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3128
-            'isEEajax'  => true
3129
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3130
-        );
3131
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3132
-        if (null === error_get_last() || ! headers_sent()) {
3133
-            header('Content-Type: application/json; charset=UTF-8');
3134
-        }
3135
-        echo wp_json_encode($json);
3136
-        exit();
3137
-    }
3138
-
3139
-
3140
-    /**
3141
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3142
-     *
3143
-     * @return void
3144
-     * @throws EE_Error
3145
-     * @throws InvalidArgumentException
3146
-     * @throws InvalidDataTypeException
3147
-     * @throws InvalidInterfaceException
3148
-     */
3149
-    public function return_json()
3150
-    {
3151
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3152
-            $this->_return_json();
3153
-        } else {
3154
-            throw new EE_Error(
3155
-                sprintf(
3156
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3157
-                    __FUNCTION__
3158
-                )
3159
-            );
3160
-        }
3161
-    }
3162
-
3163
-
3164
-    /**
3165
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3166
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3167
-     *
3168
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3169
-     */
3170
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3171
-    {
3172
-        $this->_hook_obj = $hook_obj;
3173
-    }
3174
-
3175
-
3176
-    /**
3177
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3178
-     *
3179
-     * @param boolean $about whether to use the special about page wrapper or default.
3180
-     * @return void
3181
-     * @throws DomainException
3182
-     * @throws EE_Error
3183
-     * @throws InvalidArgumentException
3184
-     * @throws InvalidDataTypeException
3185
-     * @throws InvalidInterfaceException
3186
-     */
3187
-    public function admin_page_wrapper($about = false)
3188
-    {
3189
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3190
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3191
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3192
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3193
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3194
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3195
-            isset($this->_template_args['before_admin_page_content'])
3196
-                ? $this->_template_args['before_admin_page_content']
3197
-                : ''
3198
-        );
3199
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3200
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3201
-            isset($this->_template_args['after_admin_page_content'])
3202
-                ? $this->_template_args['after_admin_page_content']
3203
-                : ''
3204
-        );
3205
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3206
-        // load settings page wrapper template
3207
-        $template_path = ! defined('DOING_AJAX')
3208
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3209
-            : EE_ADMIN_TEMPLATE
3210
-              . 'admin_wrapper_ajax.template.php';
3211
-        // about page?
3212
-        $template_path = $about
3213
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3214
-            : $template_path;
3215
-        if (defined('DOING_AJAX')) {
3216
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3217
-                $template_path,
3218
-                $this->_template_args,
3219
-                true
3220
-            );
3221
-            $this->_return_json();
3222
-        } else {
3223
-            EEH_Template::display_template($template_path, $this->_template_args);
3224
-        }
3225
-    }
3226
-
3227
-
3228
-    /**
3229
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3230
-     *
3231
-     * @return string html
3232
-     * @throws EE_Error
3233
-     */
3234
-    protected function _get_main_nav_tabs()
3235
-    {
3236
-        // let's generate the html using the EEH_Tabbed_Content helper.
3237
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3238
-        // (rather than setting in the page_routes array)
3239
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3240
-    }
3241
-
3242
-
3243
-    /**
3244
-     *        sort nav tabs
3245
-     *
3246
-     * @param $a
3247
-     * @param $b
3248
-     * @return int
3249
-     */
3250
-    private function _sort_nav_tabs($a, $b)
3251
-    {
3252
-        if ($a['order'] === $b['order']) {
3253
-            return 0;
3254
-        }
3255
-        return ($a['order'] < $b['order']) ? -1 : 1;
3256
-    }
3257
-
3258
-
3259
-    /**
3260
-     *    generates HTML for the forms used on admin pages
3261
-     *
3262
-     * @param    array $input_vars - array of input field details
3263
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3264
-     *                             use)
3265
-     * @param bool     $id
3266
-     * @return string
3267
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3268
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3269
-     */
3270
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3271
-    {
3272
-        return $generator === 'string'
3273
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3274
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3275
-    }
3276
-
3277
-
3278
-    /**
3279
-     * generates the "Save" and "Save & Close" buttons for edit forms
3280
-     *
3281
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3282
-     *                                   Close" button.
3283
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3284
-     *                                   'Save', [1] => 'save & close')
3285
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3286
-     *                                   via the "name" value in the button).  We can also use this to just dump
3287
-     *                                   default actions by submitting some other value.
3288
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3289
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3290
-     *                                   close (normal form handling).
3291
-     */
3292
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3293
-    {
3294
-        // make sure $text and $actions are in an array
3295
-        $text = (array) $text;
3296
-        $actions = (array) $actions;
3297
-        $referrer_url = empty($referrer)
3298
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3299
-              . $_SERVER['REQUEST_URI']
3300
-              . '" />'
3301
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3302
-              . $referrer
3303
-              . '" />';
3304
-        $button_text = ! empty($text)
3305
-            ? $text
3306
-            : array(
3307
-                esc_html__('Save', 'event_espresso'),
3308
-                esc_html__('Save and Close', 'event_espresso'),
3309
-            );
3310
-        $default_names = array('save', 'save_and_close');
3311
-        // add in a hidden index for the current page (so save and close redirects properly)
3312
-        $this->_template_args['save_buttons'] = $referrer_url;
3313
-        foreach ($button_text as $key => $button) {
3314
-            $ref = $default_names[ $key ];
3315
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3316
-                                                     . $ref
3317
-                                                     . '" value="'
3318
-                                                     . $button
3319
-                                                     . '" name="'
3320
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3321
-                                                     . '" id="'
3322
-                                                     . $this->_current_view . '_' . $ref
3323
-                                                     . '" />';
3324
-            if (! $both) {
3325
-                break;
3326
-            }
3327
-        }
3328
-    }
3329
-
3330
-
3331
-    /**
3332
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3333
-     *
3334
-     * @see   $this->_set_add_edit_form_tags() for details on params
3335
-     * @since 4.6.0
3336
-     * @param string $route
3337
-     * @param array  $additional_hidden_fields
3338
-     */
3339
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
-    {
3341
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3342
-    }
3343
-
3344
-
3345
-    /**
3346
-     * set form open and close tags on add/edit pages.
3347
-     *
3348
-     * @param string $route                    the route you want the form to direct to
3349
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3350
-     * @return void
3351
-     */
3352
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3353
-    {
3354
-        if (empty($route)) {
3355
-            $user_msg = esc_html__(
3356
-                'An error occurred. No action was set for this page\'s form.',
3357
-                'event_espresso'
3358
-            );
3359
-            $dev_msg = $user_msg . "\n"
3360
-                       . sprintf(
3361
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3362
-                           __FUNCTION__,
3363
-                           EE_Admin_Page::class
3364
-                       );
3365
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3366
-        }
3367
-        // open form
3368
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3369
-                                                             . $this->_admin_base_url
3370
-                                                             . '" id="'
3371
-                                                             . $route
3372
-                                                             . '_event_form" >';
3373
-        // add nonce
3374
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3375
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3376
-        // add REQUIRED form action
3377
-        $hidden_fields = array(
3378
-            'action' => array('type' => 'hidden', 'value' => $route),
3379
-        );
3380
-        // merge arrays
3381
-        $hidden_fields = is_array($additional_hidden_fields)
3382
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3383
-            : $hidden_fields;
3384
-        // generate form fields
3385
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3386
-        // add fields to form
3387
-        foreach ((array) $form_fields as $field_name => $form_field) {
3388
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3389
-        }
3390
-        // close form
3391
-        $this->_template_args['after_admin_page_content'] = '</form>';
3392
-    }
3393
-
3394
-
3395
-    /**
3396
-     * Public Wrapper for _redirect_after_action() method since its
3397
-     * discovered it would be useful for external code to have access.
3398
-     *
3399
-     * @param bool   $success
3400
-     * @param string $what
3401
-     * @param string $action_desc
3402
-     * @param array  $query_args
3403
-     * @param bool   $override_overwrite
3404
-     * @throws EE_Error
3405
-     * @throws InvalidArgumentException
3406
-     * @throws InvalidDataTypeException
3407
-     * @throws InvalidInterfaceException
3408
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3409
-     * @since 4.5.0
3410
-     */
3411
-    public function redirect_after_action(
3412
-        $success = false,
3413
-        $what = 'item',
3414
-        $action_desc = 'processed',
3415
-        $query_args = array(),
3416
-        $override_overwrite = false
3417
-    ) {
3418
-        $this->_redirect_after_action(
3419
-            $success,
3420
-            $what,
3421
-            $action_desc,
3422
-            $query_args,
3423
-            $override_overwrite
3424
-        );
3425
-    }
3426
-
3427
-
3428
-    /**
3429
-     * Helper method for merging existing request data with the returned redirect url.
3430
-     *
3431
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3432
-     * filters are still applied.
3433
-     *
3434
-     * @param array $new_route_data
3435
-     * @return array
3436
-     */
3437
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3438
-    {
3439
-        foreach ($this->_req_data as $ref => $value) {
3440
-            // unset nonces
3441
-            if (strpos($ref, 'nonce') !== false) {
3442
-                unset($this->_req_data[ $ref ]);
3443
-                continue;
3444
-            }
3445
-            // urlencode values.
3446
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3447
-            $this->_req_data[ $ref ] = $value;
3448
-        }
3449
-        return array_merge($this->_req_data, $new_route_data);
3450
-    }
3451
-
3452
-
3453
-    /**
3454
-     *    _redirect_after_action
3455
-     *
3456
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3457
-     * @param string $what               - what the action was performed on
3458
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3459
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3460
-     *                                   action is completed
3461
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3462
-     *                                   override this so that they show.
3463
-     * @return void
3464
-     * @throws EE_Error
3465
-     * @throws InvalidArgumentException
3466
-     * @throws InvalidDataTypeException
3467
-     * @throws InvalidInterfaceException
3468
-     */
3469
-    protected function _redirect_after_action(
3470
-        $success = 0,
3471
-        $what = 'item',
3472
-        $action_desc = 'processed',
3473
-        $query_args = array(),
3474
-        $override_overwrite = false
3475
-    ) {
3476
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3477
-        // class name for actions/filters.
3478
-        $classname = get_class($this);
3479
-        // set redirect url.
3480
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3481
-        // otherwise we go with whatever is set as the _admin_base_url
3482
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3483
-        $notices = EE_Error::get_notices(false);
3484
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3485
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3486
-            EE_Error::overwrite_success();
3487
-        }
3488
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3489
-            // how many records affected ? more than one record ? or just one ?
3490
-            if ($success > 1) {
3491
-                // set plural msg
3492
-                EE_Error::add_success(
3493
-                    sprintf(
3494
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3495
-                        $what,
3496
-                        $action_desc
3497
-                    ),
3498
-                    __FILE__,
3499
-                    __FUNCTION__,
3500
-                    __LINE__
3501
-                );
3502
-            } elseif ($success === 1) {
3503
-                // set singular msg
3504
-                EE_Error::add_success(
3505
-                    sprintf(
3506
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3507
-                        $what,
3508
-                        $action_desc
3509
-                    ),
3510
-                    __FILE__,
3511
-                    __FUNCTION__,
3512
-                    __LINE__
3513
-                );
3514
-            }
3515
-        }
3516
-        // check that $query_args isn't something crazy
3517
-        if (! is_array($query_args)) {
3518
-            $query_args = array();
3519
-        }
3520
-        /**
3521
-         * Allow injecting actions before the query_args are modified for possible different
3522
-         * redirections on save and close actions
3523
-         *
3524
-         * @since 4.2.0
3525
-         * @param array $query_args       The original query_args array coming into the
3526
-         *                                method.
3527
-         */
3528
-        do_action(
3529
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3530
-            $query_args
3531
-        );
3532
-        // calculate where we're going (if we have a "save and close" button pushed)
3533
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3534
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3535
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3536
-            // regenerate query args array from referrer URL
3537
-            parse_str($parsed_url['query'], $query_args);
3538
-            // correct page and action will be in the query args now
3539
-            $redirect_url = admin_url('admin.php');
3540
-        }
3541
-        // merge any default query_args set in _default_route_query_args property
3542
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3543
-            $args_to_merge = array();
3544
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3545
-                // is there a wp_referer array in our _default_route_query_args property?
3546
-                if ($query_param === 'wp_referer') {
3547
-                    $query_value = (array) $query_value;
3548
-                    foreach ($query_value as $reference => $value) {
3549
-                        if (strpos($reference, 'nonce') !== false) {
3550
-                            continue;
3551
-                        }
3552
-                        // finally we will override any arguments in the referer with
3553
-                        // what might be set on the _default_route_query_args array.
3554
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3555
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3556
-                        } else {
3557
-                            $args_to_merge[ $reference ] = urlencode($value);
3558
-                        }
3559
-                    }
3560
-                    continue;
3561
-                }
3562
-                $args_to_merge[ $query_param ] = $query_value;
3563
-            }
3564
-            // now let's merge these arguments but override with what was specifically sent in to the
3565
-            // redirect.
3566
-            $query_args = array_merge($args_to_merge, $query_args);
3567
-        }
3568
-        $this->_process_notices($query_args);
3569
-        // generate redirect url
3570
-        // if redirecting to anything other than the main page, add a nonce
3571
-        if (isset($query_args['action'])) {
3572
-            // manually generate wp_nonce and merge that with the query vars
3573
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3574
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3575
-        }
3576
-        // we're adding some hooks and filters in here for processing any things just before redirects
3577
-        // (example: an admin page has done an insert or update and we want to run something after that).
3578
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3579
-        $redirect_url = apply_filters(
3580
-            'FHEE_redirect_' . $classname . $this->_req_action,
3581
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3582
-            $query_args
3583
-        );
3584
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3585
-        if (defined('DOING_AJAX')) {
3586
-            $default_data = array(
3587
-                'close'        => true,
3588
-                'redirect_url' => $redirect_url,
3589
-                'where'        => 'main',
3590
-                'what'         => 'append',
3591
-            );
3592
-            $this->_template_args['success'] = $success;
3593
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3594
-                $default_data,
3595
-                $this->_template_args['data']
3596
-            ) : $default_data;
3597
-            $this->_return_json();
3598
-        }
3599
-        wp_safe_redirect($redirect_url);
3600
-        exit();
3601
-    }
3602
-
3603
-
3604
-    /**
3605
-     * process any notices before redirecting (or returning ajax request)
3606
-     * This method sets the $this->_template_args['notices'] attribute;
3607
-     *
3608
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3609
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3610
-     *                                  page_routes haven't been defined yet.
3611
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3612
-     *                                  still save a transient for the notice.
3613
-     * @return void
3614
-     * @throws EE_Error
3615
-     * @throws InvalidArgumentException
3616
-     * @throws InvalidDataTypeException
3617
-     * @throws InvalidInterfaceException
3618
-     */
3619
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3620
-    {
3621
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3622
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3623
-            $notices = EE_Error::get_notices(false);
3624
-            if (empty($this->_template_args['success'])) {
3625
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3626
-            }
3627
-            if (empty($this->_template_args['errors'])) {
3628
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3629
-            }
3630
-            if (empty($this->_template_args['attention'])) {
3631
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3632
-            }
3633
-        }
3634
-        $this->_template_args['notices'] = EE_Error::get_notices();
3635
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3636
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3637
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3638
-            $this->_add_transient(
3639
-                $route,
3640
-                $this->_template_args['notices'],
3641
-                true,
3642
-                $skip_route_verify
3643
-            );
3644
-        }
3645
-    }
3646
-
3647
-
3648
-    /**
3649
-     * get_action_link_or_button
3650
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3651
-     *
3652
-     * @param string $action        use this to indicate which action the url is generated with.
3653
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3654
-     *                              property.
3655
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3656
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3657
-     * @param string $base_url      If this is not provided
3658
-     *                              the _admin_base_url will be used as the default for the button base_url.
3659
-     *                              Otherwise this value will be used.
3660
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3661
-     * @return string
3662
-     * @throws InvalidArgumentException
3663
-     * @throws InvalidInterfaceException
3664
-     * @throws InvalidDataTypeException
3665
-     * @throws EE_Error
3666
-     */
3667
-    public function get_action_link_or_button(
3668
-        $action,
3669
-        $type = 'add',
3670
-        $extra_request = array(),
3671
-        $class = 'button-primary',
3672
-        $base_url = '',
3673
-        $exclude_nonce = false
3674
-    ) {
3675
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3676
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3677
-            throw new EE_Error(
3678
-                sprintf(
3679
-                    esc_html__(
3680
-                        'There is no page route for given action for the button.  This action was given: %s',
3681
-                        'event_espresso'
3682
-                    ),
3683
-                    $action
3684
-                )
3685
-            );
3686
-        }
3687
-        if (! isset($this->_labels['buttons'][ $type ])) {
3688
-            throw new EE_Error(
3689
-                sprintf(
3690
-                    __(
3691
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3692
-                        'event_espresso'
3693
-                    ),
3694
-                    $type
3695
-                )
3696
-            );
3697
-        }
3698
-        // finally check user access for this button.
3699
-        $has_access = $this->check_user_access($action, true);
3700
-        if (! $has_access) {
3701
-            return '';
3702
-        }
3703
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3704
-        $query_args = array(
3705
-            'action' => $action,
3706
-        );
3707
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3708
-        if (! empty($extra_request)) {
3709
-            $query_args = array_merge($extra_request, $query_args);
3710
-        }
3711
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3712
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3713
-    }
3714
-
3715
-
3716
-    /**
3717
-     * _per_page_screen_option
3718
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3719
-     *
3720
-     * @return void
3721
-     * @throws InvalidArgumentException
3722
-     * @throws InvalidInterfaceException
3723
-     * @throws InvalidDataTypeException
3724
-     */
3725
-    protected function _per_page_screen_option()
3726
-    {
3727
-        $option = 'per_page';
3728
-        $args = array(
3729
-            'label'   => apply_filters(
3730
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3731
-                $this->_admin_page_title,
3732
-                $this
3733
-            ),
3734
-            'default' => (int) apply_filters(
3735
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3736
-                20
3737
-            ),
3738
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3739
-        );
3740
-        // ONLY add the screen option if the user has access to it.
3741
-        if ($this->check_user_access($this->_current_view, true)) {
3742
-            add_screen_option($option, $args);
3743
-        }
3744
-    }
3745
-
3746
-
3747
-    /**
3748
-     * set_per_page_screen_option
3749
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3750
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3751
-     * admin_menu.
3752
-     *
3753
-     * @return void
3754
-     */
3755
-    private function _set_per_page_screen_options()
3756
-    {
3757
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3758
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3759
-            if (! $user = wp_get_current_user()) {
3760
-                return;
3761
-            }
3762
-            $option = $_POST['wp_screen_options']['option'];
3763
-            $value = $_POST['wp_screen_options']['value'];
3764
-            if ($option !== sanitize_key($option)) {
3765
-                return;
3766
-            }
3767
-            $map_option = $option;
3768
-            $option = str_replace('-', '_', $option);
3769
-            switch ($map_option) {
3770
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3771
-                    $value = (int) $value;
3772
-                    $max_value = apply_filters(
3773
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3774
-                        999,
3775
-                        $this->_current_page,
3776
-                        $this->_current_view
3777
-                    );
3778
-                    if ($value < 1) {
3779
-                        return;
3780
-                    }
3781
-                    $value = min($value, $max_value);
3782
-                    break;
3783
-                default:
3784
-                    $value = apply_filters(
3785
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3786
-                        false,
3787
-                        $option,
3788
-                        $value
3789
-                    );
3790
-                    if (false === $value) {
3791
-                        return;
3792
-                    }
3793
-                    break;
3794
-            }
3795
-            update_user_meta($user->ID, $option, $value);
3796
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3797
-            exit;
3798
-        }
3799
-    }
3800
-
3801
-
3802
-    /**
3803
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3804
-     *
3805
-     * @param array $data array that will be assigned to template args.
3806
-     */
3807
-    public function set_template_args($data)
3808
-    {
3809
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3810
-    }
3811
-
3812
-
3813
-    /**
3814
-     * This makes available the WP transient system for temporarily moving data between routes
3815
-     *
3816
-     * @param string $route             the route that should receive the transient
3817
-     * @param array  $data              the data that gets sent
3818
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3819
-     *                                  normal route transient.
3820
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3821
-     *                                  when we are adding a transient before page_routes have been defined.
3822
-     * @return void
3823
-     * @throws EE_Error
3824
-     */
3825
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826
-    {
3827
-        $user_id = get_current_user_id();
3828
-        if (! $skip_route_verify) {
3829
-            $this->_verify_route($route);
3830
-        }
3831
-        // now let's set the string for what kind of transient we're setting
3832
-        $transient = $notices
3833
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
-            : 'rte_tx_' . $route . '_' . $user_id;
3835
-        $data = $notices ? array('notices' => $data) : $data;
3836
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3837
-        $existing = is_multisite() && is_network_admin()
3838
-            ? get_site_transient($transient)
3839
-            : get_transient($transient);
3840
-        if ($existing) {
3841
-            $data = array_merge((array) $data, (array) $existing);
3842
-        }
3843
-        if (is_multisite() && is_network_admin()) {
3844
-            set_site_transient($transient, $data, 8);
3845
-        } else {
3846
-            set_transient($transient, $data, 8);
3847
-        }
3848
-    }
3849
-
3850
-
3851
-    /**
3852
-     * this retrieves the temporary transient that has been set for moving data between routes.
3853
-     *
3854
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3855
-     * @param string $route
3856
-     * @return mixed data
3857
-     */
3858
-    protected function _get_transient($notices = false, $route = '')
3859
-    {
3860
-        $user_id = get_current_user_id();
3861
-        $route = ! $route ? $this->_req_action : $route;
3862
-        $transient = $notices
3863
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
-            : 'rte_tx_' . $route . '_' . $user_id;
3865
-        $data = is_multisite() && is_network_admin()
3866
-            ? get_site_transient($transient)
3867
-            : get_transient($transient);
3868
-        // delete transient after retrieval (just in case it hasn't expired);
3869
-        if (is_multisite() && is_network_admin()) {
3870
-            delete_site_transient($transient);
3871
-        } else {
3872
-            delete_transient($transient);
3873
-        }
3874
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3875
-    }
3876
-
3877
-
3878
-    /**
3879
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3880
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3881
-     * default route callback on the EE_Admin page you want it run.)
3882
-     *
3883
-     * @return void
3884
-     */
3885
-    protected function _transient_garbage_collection()
3886
-    {
3887
-        global $wpdb;
3888
-        // retrieve all existing transients
3889
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3890
-        if ($results = $wpdb->get_results($query)) {
3891
-            foreach ($results as $result) {
3892
-                $transient = str_replace('_transient_', '', $result->option_name);
3893
-                get_transient($transient);
3894
-                if (is_multisite() && is_network_admin()) {
3895
-                    get_site_transient($transient);
3896
-                }
3897
-            }
3898
-        }
3899
-    }
3900
-
3901
-
3902
-    /**
3903
-     * get_view
3904
-     *
3905
-     * @return string content of _view property
3906
-     */
3907
-    public function get_view()
3908
-    {
3909
-        return $this->_view;
3910
-    }
3911
-
3912
-
3913
-    /**
3914
-     * getter for the protected $_views property
3915
-     *
3916
-     * @return array
3917
-     */
3918
-    public function get_views()
3919
-    {
3920
-        return $this->_views;
3921
-    }
3922
-
3923
-
3924
-    /**
3925
-     * get_current_page
3926
-     *
3927
-     * @return string _current_page property value
3928
-     */
3929
-    public function get_current_page()
3930
-    {
3931
-        return $this->_current_page;
3932
-    }
3933
-
3934
-
3935
-    /**
3936
-     * get_current_view
3937
-     *
3938
-     * @return string _current_view property value
3939
-     */
3940
-    public function get_current_view()
3941
-    {
3942
-        return $this->_current_view;
3943
-    }
3944
-
3945
-
3946
-    /**
3947
-     * get_current_screen
3948
-     *
3949
-     * @return object The current WP_Screen object
3950
-     */
3951
-    public function get_current_screen()
3952
-    {
3953
-        return $this->_current_screen;
3954
-    }
3955
-
3956
-
3957
-    /**
3958
-     * get_current_page_view_url
3959
-     *
3960
-     * @return string This returns the url for the current_page_view.
3961
-     */
3962
-    public function get_current_page_view_url()
3963
-    {
3964
-        return $this->_current_page_view_url;
3965
-    }
3966
-
3967
-
3968
-    /**
3969
-     * just returns the _req_data property
3970
-     *
3971
-     * @return array
3972
-     */
3973
-    public function get_request_data()
3974
-    {
3975
-        return $this->_req_data;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * returns the _req_data protected property
3981
-     *
3982
-     * @return string
3983
-     */
3984
-    public function get_req_action()
3985
-    {
3986
-        return $this->_req_action;
3987
-    }
3988
-
3989
-
3990
-    /**
3991
-     * @return bool  value of $_is_caf property
3992
-     */
3993
-    public function is_caf()
3994
-    {
3995
-        return $this->_is_caf;
3996
-    }
3997
-
3998
-
3999
-    /**
4000
-     * @return mixed
4001
-     */
4002
-    public function default_espresso_metaboxes()
4003
-    {
4004
-        return $this->_default_espresso_metaboxes;
4005
-    }
4006
-
4007
-
4008
-    /**
4009
-     * @return mixed
4010
-     */
4011
-    public function admin_base_url()
4012
-    {
4013
-        return $this->_admin_base_url;
4014
-    }
4015
-
4016
-
4017
-    /**
4018
-     * @return mixed
4019
-     */
4020
-    public function wp_page_slug()
4021
-    {
4022
-        return $this->_wp_page_slug;
4023
-    }
4024
-
4025
-
4026
-    /**
4027
-     * updates  espresso configuration settings
4028
-     *
4029
-     * @param string                   $tab
4030
-     * @param EE_Config_Base|EE_Config $config
4031
-     * @param string                   $file file where error occurred
4032
-     * @param string                   $func function  where error occurred
4033
-     * @param string                   $line line no where error occurred
4034
-     * @return boolean
4035
-     */
4036
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4037
-    {
4038
-        // remove any options that are NOT going to be saved with the config settings.
4039
-        if (isset($config->core->ee_ueip_optin)) {
4040
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4041
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4042
-            update_option('ee_ueip_has_notified', true);
4043
-        }
4044
-        // and save it (note we're also doing the network save here)
4045
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4046
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4047
-        if ($config_saved && $net_saved) {
4048
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4049
-            return true;
4050
-        }
4051
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4052
-        return false;
4053
-    }
4054
-
4055
-
4056
-    /**
4057
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4058
-     *
4059
-     * @return array
4060
-     */
4061
-    public function get_yes_no_values()
4062
-    {
4063
-        return $this->_yes_no_values;
4064
-    }
4065
-
4066
-
4067
-    /**
4068
-     * @return string
4069
-     * @throws ReflectionException
4070
-     * @since $VID:$
4071
-     */
4072
-    protected function _get_dir()
4073
-    {
4074
-        $reflector = new ReflectionClass(get_class($this));
4075
-        return dirname($reflector->getFileName());
4076
-    }
4077
-
4078
-
4079
-    /**
4080
-     * A helper for getting a "next link".
4081
-     *
4082
-     * @param string $url   The url to link to
4083
-     * @param string $class The class to use.
4084
-     * @return string
4085
-     */
4086
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4087
-    {
4088
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4089
-    }
4090
-
4091
-
4092
-    /**
4093
-     * A helper for getting a "previous link".
4094
-     *
4095
-     * @param string $url   The url to link to
4096
-     * @param string $class The class to use.
4097
-     * @return string
4098
-     */
4099
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4100
-    {
4101
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4102
-    }
4103
-
4104
-
4105
-
4106
-
4107
-
4108
-
4109
-
4110
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4111
-
4112
-
4113
-    /**
4114
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4115
-     * 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
4116
-     * _req_data array.
4117
-     *
4118
-     * @return bool success/fail
4119
-     * @throws EE_Error
4120
-     * @throws InvalidArgumentException
4121
-     * @throws ReflectionException
4122
-     * @throws InvalidDataTypeException
4123
-     * @throws InvalidInterfaceException
4124
-     */
4125
-    protected function _process_resend_registration()
4126
-    {
4127
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4128
-        do_action(
4129
-            'AHEE__EE_Admin_Page___process_resend_registration',
4130
-            $this->_template_args['success'],
4131
-            $this->_req_data
4132
-        );
4133
-        return $this->_template_args['success'];
4134
-    }
4135
-
4136
-
4137
-    /**
4138
-     * This automatically processes any payment message notifications when manual payment has been applied.
4139
-     *
4140
-     * @param EE_Payment $payment
4141
-     * @return bool success/fail
4142
-     */
4143
-    protected function _process_payment_notification(EE_Payment $payment)
4144
-    {
4145
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4146
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4147
-        $this->_template_args['success'] = apply_filters(
4148
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4149
-            false,
4150
-            $payment
4151
-        );
4152
-        return $this->_template_args['success'];
4153
-    }
2675
+	}
2676
+
2677
+
2678
+	/**
2679
+	 * facade for add_meta_box
2680
+	 *
2681
+	 * @param string  $action        where the metabox get's displayed
2682
+	 * @param string  $title         Title of Metabox (output in metabox header)
2683
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2684
+	 *                               instead of the one created in here.
2685
+	 * @param array   $callback_args an array of args supplied for the metabox
2686
+	 * @param string  $column        what metabox column
2687
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2688
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2689
+	 *                               created but just set our own callback for wp's add_meta_box.
2690
+	 * @throws DomainException
2691
+	 */
2692
+	public function _add_admin_page_meta_box(
2693
+		$action,
2694
+		$title,
2695
+		$callback,
2696
+		$callback_args,
2697
+		$column = 'normal',
2698
+		$priority = 'high',
2699
+		$create_func = true
2700
+	) {
2701
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2702
+		// 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.
2703
+		if (empty($callback_args) && $create_func) {
2704
+			$callback_args = array(
2705
+				'template_path' => $this->_template_path,
2706
+				'template_args' => $this->_template_args,
2707
+			);
2708
+		}
2709
+		// 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)
2710
+		$call_back_func = $create_func
2711
+			? static function ($post, $metabox) {
2712
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2713
+				echo EEH_Template::display_template(
2714
+					$metabox['args']['template_path'],
2715
+					$metabox['args']['template_args'],
2716
+					true
2717
+				);
2718
+			}
2719
+			: $callback;
2720
+		add_meta_box(
2721
+			str_replace('_', '-', $action) . '-mbox',
2722
+			$title,
2723
+			$call_back_func,
2724
+			$this->_wp_page_slug,
2725
+			$column,
2726
+			$priority,
2727
+			$callback_args
2728
+		);
2729
+	}
2730
+
2731
+
2732
+	/**
2733
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2734
+	 *
2735
+	 * @throws DomainException
2736
+	 * @throws EE_Error
2737
+	 * @throws InvalidArgumentException
2738
+	 * @throws InvalidDataTypeException
2739
+	 * @throws InvalidInterfaceException
2740
+	 */
2741
+	public function display_admin_page_with_metabox_columns()
2742
+	{
2743
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2744
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2745
+			$this->_column_template_path,
2746
+			$this->_template_args,
2747
+			true
2748
+		);
2749
+		// the final wrapper
2750
+		$this->admin_page_wrapper();
2751
+	}
2752
+
2753
+
2754
+	/**
2755
+	 * generates  HTML wrapper for an admin details page
2756
+	 *
2757
+	 * @return void
2758
+	 * @throws DomainException
2759
+	 * @throws EE_Error
2760
+	 * @throws InvalidArgumentException
2761
+	 * @throws InvalidDataTypeException
2762
+	 * @throws InvalidInterfaceException
2763
+	 */
2764
+	public function display_admin_page_with_sidebar()
2765
+	{
2766
+		$this->_display_admin_page(true);
2767
+	}
2768
+
2769
+
2770
+	/**
2771
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2772
+	 *
2773
+	 * @return void
2774
+	 * @throws DomainException
2775
+	 * @throws EE_Error
2776
+	 * @throws InvalidArgumentException
2777
+	 * @throws InvalidDataTypeException
2778
+	 * @throws InvalidInterfaceException
2779
+	 */
2780
+	public function display_admin_page_with_no_sidebar()
2781
+	{
2782
+		$this->_display_admin_page();
2783
+	}
2784
+
2785
+
2786
+	/**
2787
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2788
+	 *
2789
+	 * @return void
2790
+	 * @throws DomainException
2791
+	 * @throws EE_Error
2792
+	 * @throws InvalidArgumentException
2793
+	 * @throws InvalidDataTypeException
2794
+	 * @throws InvalidInterfaceException
2795
+	 */
2796
+	public function display_about_admin_page()
2797
+	{
2798
+		$this->_display_admin_page(false, true);
2799
+	}
2800
+
2801
+
2802
+	/**
2803
+	 * display_admin_page
2804
+	 * contains the code for actually displaying an admin page
2805
+	 *
2806
+	 * @param boolean $sidebar true with sidebar, false without
2807
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2808
+	 * @return void
2809
+	 * @throws DomainException
2810
+	 * @throws EE_Error
2811
+	 * @throws InvalidArgumentException
2812
+	 * @throws InvalidDataTypeException
2813
+	 * @throws InvalidInterfaceException
2814
+	 */
2815
+	private function _display_admin_page($sidebar = false, $about = false)
2816
+	{
2817
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2818
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2819
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2820
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2821
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2822
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2823
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2824
+			? 'poststuff'
2825
+			: 'espresso-default-admin';
2826
+		$template_path = $sidebar
2827
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2828
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2829
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2830
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2831
+		}
2832
+		$template_path = ! empty($this->_column_template_path)
2833
+			? $this->_column_template_path : $template_path;
2834
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2835
+			? $this->_template_args['admin_page_content']
2836
+			: '';
2837
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2838
+			? $this->_template_args['before_admin_page_content']
2839
+			: '';
2840
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2841
+			? $this->_template_args['after_admin_page_content']
2842
+			: '';
2843
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2844
+			$template_path,
2845
+			$this->_template_args,
2846
+			true
2847
+		);
2848
+		// the final template wrapper
2849
+		$this->admin_page_wrapper($about);
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * This is used to display caf preview pages.
2855
+	 *
2856
+	 * @since 4.3.2
2857
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2858
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2859
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2860
+	 * @return void
2861
+	 * @throws DomainException
2862
+	 * @throws EE_Error
2863
+	 * @throws InvalidArgumentException
2864
+	 * @throws InvalidDataTypeException
2865
+	 * @throws InvalidInterfaceException
2866
+	 */
2867
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2868
+	{
2869
+		// let's generate a default preview action button if there isn't one already present.
2870
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2871
+			'Upgrade to Event Espresso 4 Right Now',
2872
+			'event_espresso'
2873
+		);
2874
+		$buy_now_url = add_query_arg(
2875
+			array(
2876
+				'ee_ver'       => 'ee4',
2877
+				'utm_source'   => 'ee4_plugin_admin',
2878
+				'utm_medium'   => 'link',
2879
+				'utm_campaign' => $utm_campaign_source,
2880
+				'utm_content'  => 'buy_now_button',
2881
+			),
2882
+			'http://eventespresso.com/pricing/'
2883
+		);
2884
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2885
+			? $this->get_action_link_or_button(
2886
+				'',
2887
+				'buy_now',
2888
+				array(),
2889
+				'button-primary button-large',
2890
+				$buy_now_url,
2891
+				true
2892
+			)
2893
+			: $this->_template_args['preview_action_button'];
2894
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2895
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2896
+			$this->_template_args,
2897
+			true
2898
+		);
2899
+		$this->_display_admin_page($display_sidebar);
2900
+	}
2901
+
2902
+
2903
+	/**
2904
+	 * display_admin_list_table_page_with_sidebar
2905
+	 * generates HTML wrapper for an admin_page with list_table
2906
+	 *
2907
+	 * @return void
2908
+	 * @throws DomainException
2909
+	 * @throws EE_Error
2910
+	 * @throws InvalidArgumentException
2911
+	 * @throws InvalidDataTypeException
2912
+	 * @throws InvalidInterfaceException
2913
+	 */
2914
+	public function display_admin_list_table_page_with_sidebar()
2915
+	{
2916
+		$this->_display_admin_list_table_page(true);
2917
+	}
2918
+
2919
+
2920
+	/**
2921
+	 * display_admin_list_table_page_with_no_sidebar
2922
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2923
+	 *
2924
+	 * @return void
2925
+	 * @throws DomainException
2926
+	 * @throws EE_Error
2927
+	 * @throws InvalidArgumentException
2928
+	 * @throws InvalidDataTypeException
2929
+	 * @throws InvalidInterfaceException
2930
+	 */
2931
+	public function display_admin_list_table_page_with_no_sidebar()
2932
+	{
2933
+		$this->_display_admin_list_table_page();
2934
+	}
2935
+
2936
+
2937
+	/**
2938
+	 * generates html wrapper for an admin_list_table page
2939
+	 *
2940
+	 * @param boolean $sidebar whether to display with sidebar or not.
2941
+	 * @return void
2942
+	 * @throws DomainException
2943
+	 * @throws EE_Error
2944
+	 * @throws InvalidArgumentException
2945
+	 * @throws InvalidDataTypeException
2946
+	 * @throws InvalidInterfaceException
2947
+	 */
2948
+	private function _display_admin_list_table_page($sidebar = false)
2949
+	{
2950
+		// setup search attributes
2951
+		$this->_set_search_attributes();
2952
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2953
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2954
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2955
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2956
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2957
+		$this->_template_args['list_table'] = $this->_list_table_object;
2958
+		$this->_template_args['current_route'] = $this->_req_action;
2959
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2960
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2961
+		if (! empty($ajax_sorting_callback)) {
2962
+			$sortable_list_table_form_fields = wp_nonce_field(
2963
+				$ajax_sorting_callback . '_nonce',
2964
+				$ajax_sorting_callback . '_nonce',
2965
+				false,
2966
+				false
2967
+			);
2968
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2969
+												. $this->page_slug
2970
+												. '" />';
2971
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2972
+												. $ajax_sorting_callback
2973
+												. '" />';
2974
+		} else {
2975
+			$sortable_list_table_form_fields = '';
2976
+		}
2977
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2978
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2979
+			? $this->_template_args['list_table_hidden_fields']
2980
+			: '';
2981
+		$nonce_ref = $this->_req_action . '_nonce';
2982
+		$hidden_form_fields .= '<input type="hidden" name="'
2983
+							   . $nonce_ref
2984
+							   . '" value="'
2985
+							   . wp_create_nonce($nonce_ref)
2986
+							   . '">';
2987
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2988
+		// display message about search results?
2989
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2990
+			? '<p class="ee-search-results">' . sprintf(
2991
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2992
+				trim($this->_req_data['s'], '%')
2993
+			) . '</p>'
2994
+			: '';
2995
+		// filter before_list_table template arg
2996
+		$this->_template_args['before_list_table'] = apply_filters(
2997
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2998
+			$this->_template_args['before_list_table'],
2999
+			$this->page_slug,
3000
+			$this->_req_data,
3001
+			$this->_req_action
3002
+		);
3003
+		// convert to array and filter again
3004
+		// arrays are easier to inject new items in a specific location,
3005
+		// but would not be backwards compatible, so we have to add a new filter
3006
+		$this->_template_args['before_list_table'] = implode(
3007
+			" \n",
3008
+			(array) apply_filters(
3009
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3010
+				(array) $this->_template_args['before_list_table'],
3011
+				$this->page_slug,
3012
+				$this->_req_data,
3013
+				$this->_req_action
3014
+			)
3015
+		);
3016
+		// filter after_list_table template arg
3017
+		$this->_template_args['after_list_table'] = apply_filters(
3018
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3019
+			$this->_template_args['after_list_table'],
3020
+			$this->page_slug,
3021
+			$this->_req_data,
3022
+			$this->_req_action
3023
+		);
3024
+		// convert to array and filter again
3025
+		// arrays are easier to inject new items in a specific location,
3026
+		// but would not be backwards compatible, so we have to add a new filter
3027
+		$this->_template_args['after_list_table'] = implode(
3028
+			" \n",
3029
+			(array) apply_filters(
3030
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3031
+				(array) $this->_template_args['after_list_table'],
3032
+				$this->page_slug,
3033
+				$this->_req_data,
3034
+				$this->_req_action
3035
+			)
3036
+		);
3037
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3038
+			$template_path,
3039
+			$this->_template_args,
3040
+			true
3041
+		);
3042
+		// the final template wrapper
3043
+		if ($sidebar) {
3044
+			$this->display_admin_page_with_sidebar();
3045
+		} else {
3046
+			$this->display_admin_page_with_no_sidebar();
3047
+		}
3048
+	}
3049
+
3050
+
3051
+	/**
3052
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3053
+	 * html string for the legend.
3054
+	 * $items are expected in an array in the following format:
3055
+	 * $legend_items = array(
3056
+	 *        'item_id' => array(
3057
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3058
+	 *            'desc' => esc_html__('localized description of item');
3059
+	 *        )
3060
+	 * );
3061
+	 *
3062
+	 * @param  array $items see above for format of array
3063
+	 * @return string html string of legend
3064
+	 * @throws DomainException
3065
+	 */
3066
+	protected function _display_legend($items)
3067
+	{
3068
+		$this->_template_args['items'] = apply_filters(
3069
+			'FHEE__EE_Admin_Page___display_legend__items',
3070
+			(array) $items,
3071
+			$this
3072
+		);
3073
+		/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
3074
+		$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
3075
+		if (! $status_change_notice->isDismissed()) {
3076
+			$this->_template_args['status_change_notice'] = EEH_Template::display_template(
3077
+				EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
3078
+				[ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
3079
+				true
3080
+			);
3081
+		}
3082
+		return EEH_Template::display_template(
3083
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3084
+			$this->_template_args,
3085
+			true
3086
+		);
3087
+	}
3088
+
3089
+
3090
+	/**
3091
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3092
+	 * The returned json object is created from an array in the following format:
3093
+	 * array(
3094
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3095
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3096
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3097
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3098
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3099
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3100
+	 *  that might be included in here)
3101
+	 * )
3102
+	 * The json object is populated by whatever is set in the $_template_args property.
3103
+	 *
3104
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3105
+	 *                                 instead of displayed.
3106
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3107
+	 * @return void
3108
+	 * @throws EE_Error
3109
+	 * @throws InvalidArgumentException
3110
+	 * @throws InvalidDataTypeException
3111
+	 * @throws InvalidInterfaceException
3112
+	 */
3113
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3114
+	{
3115
+		// make sure any EE_Error notices have been handled.
3116
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3117
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3118
+		unset($this->_template_args['data']);
3119
+		$json = array(
3120
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3121
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3122
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3123
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3124
+			'notices'   => EE_Error::get_notices(),
3125
+			'content'   => isset($this->_template_args['admin_page_content'])
3126
+				? $this->_template_args['admin_page_content'] : '',
3127
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3128
+			'isEEajax'  => true
3129
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3130
+		);
3131
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3132
+		if (null === error_get_last() || ! headers_sent()) {
3133
+			header('Content-Type: application/json; charset=UTF-8');
3134
+		}
3135
+		echo wp_json_encode($json);
3136
+		exit();
3137
+	}
3138
+
3139
+
3140
+	/**
3141
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3142
+	 *
3143
+	 * @return void
3144
+	 * @throws EE_Error
3145
+	 * @throws InvalidArgumentException
3146
+	 * @throws InvalidDataTypeException
3147
+	 * @throws InvalidInterfaceException
3148
+	 */
3149
+	public function return_json()
3150
+	{
3151
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3152
+			$this->_return_json();
3153
+		} else {
3154
+			throw new EE_Error(
3155
+				sprintf(
3156
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3157
+					__FUNCTION__
3158
+				)
3159
+			);
3160
+		}
3161
+	}
3162
+
3163
+
3164
+	/**
3165
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3166
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3167
+	 *
3168
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3169
+	 */
3170
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3171
+	{
3172
+		$this->_hook_obj = $hook_obj;
3173
+	}
3174
+
3175
+
3176
+	/**
3177
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3178
+	 *
3179
+	 * @param boolean $about whether to use the special about page wrapper or default.
3180
+	 * @return void
3181
+	 * @throws DomainException
3182
+	 * @throws EE_Error
3183
+	 * @throws InvalidArgumentException
3184
+	 * @throws InvalidDataTypeException
3185
+	 * @throws InvalidInterfaceException
3186
+	 */
3187
+	public function admin_page_wrapper($about = false)
3188
+	{
3189
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3190
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3191
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3192
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3193
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3194
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3195
+			isset($this->_template_args['before_admin_page_content'])
3196
+				? $this->_template_args['before_admin_page_content']
3197
+				: ''
3198
+		);
3199
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3200
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3201
+			isset($this->_template_args['after_admin_page_content'])
3202
+				? $this->_template_args['after_admin_page_content']
3203
+				: ''
3204
+		);
3205
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3206
+		// load settings page wrapper template
3207
+		$template_path = ! defined('DOING_AJAX')
3208
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3209
+			: EE_ADMIN_TEMPLATE
3210
+			  . 'admin_wrapper_ajax.template.php';
3211
+		// about page?
3212
+		$template_path = $about
3213
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3214
+			: $template_path;
3215
+		if (defined('DOING_AJAX')) {
3216
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3217
+				$template_path,
3218
+				$this->_template_args,
3219
+				true
3220
+			);
3221
+			$this->_return_json();
3222
+		} else {
3223
+			EEH_Template::display_template($template_path, $this->_template_args);
3224
+		}
3225
+	}
3226
+
3227
+
3228
+	/**
3229
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3230
+	 *
3231
+	 * @return string html
3232
+	 * @throws EE_Error
3233
+	 */
3234
+	protected function _get_main_nav_tabs()
3235
+	{
3236
+		// let's generate the html using the EEH_Tabbed_Content helper.
3237
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3238
+		// (rather than setting in the page_routes array)
3239
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3240
+	}
3241
+
3242
+
3243
+	/**
3244
+	 *        sort nav tabs
3245
+	 *
3246
+	 * @param $a
3247
+	 * @param $b
3248
+	 * @return int
3249
+	 */
3250
+	private function _sort_nav_tabs($a, $b)
3251
+	{
3252
+		if ($a['order'] === $b['order']) {
3253
+			return 0;
3254
+		}
3255
+		return ($a['order'] < $b['order']) ? -1 : 1;
3256
+	}
3257
+
3258
+
3259
+	/**
3260
+	 *    generates HTML for the forms used on admin pages
3261
+	 *
3262
+	 * @param    array $input_vars - array of input field details
3263
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3264
+	 *                             use)
3265
+	 * @param bool     $id
3266
+	 * @return string
3267
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3268
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3269
+	 */
3270
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3271
+	{
3272
+		return $generator === 'string'
3273
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3274
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3275
+	}
3276
+
3277
+
3278
+	/**
3279
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3280
+	 *
3281
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3282
+	 *                                   Close" button.
3283
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3284
+	 *                                   'Save', [1] => 'save & close')
3285
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3286
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3287
+	 *                                   default actions by submitting some other value.
3288
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3289
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3290
+	 *                                   close (normal form handling).
3291
+	 */
3292
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3293
+	{
3294
+		// make sure $text and $actions are in an array
3295
+		$text = (array) $text;
3296
+		$actions = (array) $actions;
3297
+		$referrer_url = empty($referrer)
3298
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3299
+			  . $_SERVER['REQUEST_URI']
3300
+			  . '" />'
3301
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3302
+			  . $referrer
3303
+			  . '" />';
3304
+		$button_text = ! empty($text)
3305
+			? $text
3306
+			: array(
3307
+				esc_html__('Save', 'event_espresso'),
3308
+				esc_html__('Save and Close', 'event_espresso'),
3309
+			);
3310
+		$default_names = array('save', 'save_and_close');
3311
+		// add in a hidden index for the current page (so save and close redirects properly)
3312
+		$this->_template_args['save_buttons'] = $referrer_url;
3313
+		foreach ($button_text as $key => $button) {
3314
+			$ref = $default_names[ $key ];
3315
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3316
+													 . $ref
3317
+													 . '" value="'
3318
+													 . $button
3319
+													 . '" name="'
3320
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3321
+													 . '" id="'
3322
+													 . $this->_current_view . '_' . $ref
3323
+													 . '" />';
3324
+			if (! $both) {
3325
+				break;
3326
+			}
3327
+		}
3328
+	}
3329
+
3330
+
3331
+	/**
3332
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3333
+	 *
3334
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3335
+	 * @since 4.6.0
3336
+	 * @param string $route
3337
+	 * @param array  $additional_hidden_fields
3338
+	 */
3339
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
+	{
3341
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3342
+	}
3343
+
3344
+
3345
+	/**
3346
+	 * set form open and close tags on add/edit pages.
3347
+	 *
3348
+	 * @param string $route                    the route you want the form to direct to
3349
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3350
+	 * @return void
3351
+	 */
3352
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3353
+	{
3354
+		if (empty($route)) {
3355
+			$user_msg = esc_html__(
3356
+				'An error occurred. No action was set for this page\'s form.',
3357
+				'event_espresso'
3358
+			);
3359
+			$dev_msg = $user_msg . "\n"
3360
+					   . sprintf(
3361
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3362
+						   __FUNCTION__,
3363
+						   EE_Admin_Page::class
3364
+					   );
3365
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3366
+		}
3367
+		// open form
3368
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3369
+															 . $this->_admin_base_url
3370
+															 . '" id="'
3371
+															 . $route
3372
+															 . '_event_form" >';
3373
+		// add nonce
3374
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3375
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3376
+		// add REQUIRED form action
3377
+		$hidden_fields = array(
3378
+			'action' => array('type' => 'hidden', 'value' => $route),
3379
+		);
3380
+		// merge arrays
3381
+		$hidden_fields = is_array($additional_hidden_fields)
3382
+			? array_merge($hidden_fields, $additional_hidden_fields)
3383
+			: $hidden_fields;
3384
+		// generate form fields
3385
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3386
+		// add fields to form
3387
+		foreach ((array) $form_fields as $field_name => $form_field) {
3388
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3389
+		}
3390
+		// close form
3391
+		$this->_template_args['after_admin_page_content'] = '</form>';
3392
+	}
3393
+
3394
+
3395
+	/**
3396
+	 * Public Wrapper for _redirect_after_action() method since its
3397
+	 * discovered it would be useful for external code to have access.
3398
+	 *
3399
+	 * @param bool   $success
3400
+	 * @param string $what
3401
+	 * @param string $action_desc
3402
+	 * @param array  $query_args
3403
+	 * @param bool   $override_overwrite
3404
+	 * @throws EE_Error
3405
+	 * @throws InvalidArgumentException
3406
+	 * @throws InvalidDataTypeException
3407
+	 * @throws InvalidInterfaceException
3408
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3409
+	 * @since 4.5.0
3410
+	 */
3411
+	public function redirect_after_action(
3412
+		$success = false,
3413
+		$what = 'item',
3414
+		$action_desc = 'processed',
3415
+		$query_args = array(),
3416
+		$override_overwrite = false
3417
+	) {
3418
+		$this->_redirect_after_action(
3419
+			$success,
3420
+			$what,
3421
+			$action_desc,
3422
+			$query_args,
3423
+			$override_overwrite
3424
+		);
3425
+	}
3426
+
3427
+
3428
+	/**
3429
+	 * Helper method for merging existing request data with the returned redirect url.
3430
+	 *
3431
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3432
+	 * filters are still applied.
3433
+	 *
3434
+	 * @param array $new_route_data
3435
+	 * @return array
3436
+	 */
3437
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3438
+	{
3439
+		foreach ($this->_req_data as $ref => $value) {
3440
+			// unset nonces
3441
+			if (strpos($ref, 'nonce') !== false) {
3442
+				unset($this->_req_data[ $ref ]);
3443
+				continue;
3444
+			}
3445
+			// urlencode values.
3446
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3447
+			$this->_req_data[ $ref ] = $value;
3448
+		}
3449
+		return array_merge($this->_req_data, $new_route_data);
3450
+	}
3451
+
3452
+
3453
+	/**
3454
+	 *    _redirect_after_action
3455
+	 *
3456
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3457
+	 * @param string $what               - what the action was performed on
3458
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3459
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3460
+	 *                                   action is completed
3461
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3462
+	 *                                   override this so that they show.
3463
+	 * @return void
3464
+	 * @throws EE_Error
3465
+	 * @throws InvalidArgumentException
3466
+	 * @throws InvalidDataTypeException
3467
+	 * @throws InvalidInterfaceException
3468
+	 */
3469
+	protected function _redirect_after_action(
3470
+		$success = 0,
3471
+		$what = 'item',
3472
+		$action_desc = 'processed',
3473
+		$query_args = array(),
3474
+		$override_overwrite = false
3475
+	) {
3476
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3477
+		// class name for actions/filters.
3478
+		$classname = get_class($this);
3479
+		// set redirect url.
3480
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3481
+		// otherwise we go with whatever is set as the _admin_base_url
3482
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3483
+		$notices = EE_Error::get_notices(false);
3484
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3485
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3486
+			EE_Error::overwrite_success();
3487
+		}
3488
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3489
+			// how many records affected ? more than one record ? or just one ?
3490
+			if ($success > 1) {
3491
+				// set plural msg
3492
+				EE_Error::add_success(
3493
+					sprintf(
3494
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3495
+						$what,
3496
+						$action_desc
3497
+					),
3498
+					__FILE__,
3499
+					__FUNCTION__,
3500
+					__LINE__
3501
+				);
3502
+			} elseif ($success === 1) {
3503
+				// set singular msg
3504
+				EE_Error::add_success(
3505
+					sprintf(
3506
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3507
+						$what,
3508
+						$action_desc
3509
+					),
3510
+					__FILE__,
3511
+					__FUNCTION__,
3512
+					__LINE__
3513
+				);
3514
+			}
3515
+		}
3516
+		// check that $query_args isn't something crazy
3517
+		if (! is_array($query_args)) {
3518
+			$query_args = array();
3519
+		}
3520
+		/**
3521
+		 * Allow injecting actions before the query_args are modified for possible different
3522
+		 * redirections on save and close actions
3523
+		 *
3524
+		 * @since 4.2.0
3525
+		 * @param array $query_args       The original query_args array coming into the
3526
+		 *                                method.
3527
+		 */
3528
+		do_action(
3529
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3530
+			$query_args
3531
+		);
3532
+		// calculate where we're going (if we have a "save and close" button pushed)
3533
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3534
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3535
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3536
+			// regenerate query args array from referrer URL
3537
+			parse_str($parsed_url['query'], $query_args);
3538
+			// correct page and action will be in the query args now
3539
+			$redirect_url = admin_url('admin.php');
3540
+		}
3541
+		// merge any default query_args set in _default_route_query_args property
3542
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3543
+			$args_to_merge = array();
3544
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3545
+				// is there a wp_referer array in our _default_route_query_args property?
3546
+				if ($query_param === 'wp_referer') {
3547
+					$query_value = (array) $query_value;
3548
+					foreach ($query_value as $reference => $value) {
3549
+						if (strpos($reference, 'nonce') !== false) {
3550
+							continue;
3551
+						}
3552
+						// finally we will override any arguments in the referer with
3553
+						// what might be set on the _default_route_query_args array.
3554
+						if (isset($this->_default_route_query_args[ $reference ])) {
3555
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3556
+						} else {
3557
+							$args_to_merge[ $reference ] = urlencode($value);
3558
+						}
3559
+					}
3560
+					continue;
3561
+				}
3562
+				$args_to_merge[ $query_param ] = $query_value;
3563
+			}
3564
+			// now let's merge these arguments but override with what was specifically sent in to the
3565
+			// redirect.
3566
+			$query_args = array_merge($args_to_merge, $query_args);
3567
+		}
3568
+		$this->_process_notices($query_args);
3569
+		// generate redirect url
3570
+		// if redirecting to anything other than the main page, add a nonce
3571
+		if (isset($query_args['action'])) {
3572
+			// manually generate wp_nonce and merge that with the query vars
3573
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3574
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3575
+		}
3576
+		// we're adding some hooks and filters in here for processing any things just before redirects
3577
+		// (example: an admin page has done an insert or update and we want to run something after that).
3578
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3579
+		$redirect_url = apply_filters(
3580
+			'FHEE_redirect_' . $classname . $this->_req_action,
3581
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3582
+			$query_args
3583
+		);
3584
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3585
+		if (defined('DOING_AJAX')) {
3586
+			$default_data = array(
3587
+				'close'        => true,
3588
+				'redirect_url' => $redirect_url,
3589
+				'where'        => 'main',
3590
+				'what'         => 'append',
3591
+			);
3592
+			$this->_template_args['success'] = $success;
3593
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3594
+				$default_data,
3595
+				$this->_template_args['data']
3596
+			) : $default_data;
3597
+			$this->_return_json();
3598
+		}
3599
+		wp_safe_redirect($redirect_url);
3600
+		exit();
3601
+	}
3602
+
3603
+
3604
+	/**
3605
+	 * process any notices before redirecting (or returning ajax request)
3606
+	 * This method sets the $this->_template_args['notices'] attribute;
3607
+	 *
3608
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3609
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3610
+	 *                                  page_routes haven't been defined yet.
3611
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3612
+	 *                                  still save a transient for the notice.
3613
+	 * @return void
3614
+	 * @throws EE_Error
3615
+	 * @throws InvalidArgumentException
3616
+	 * @throws InvalidDataTypeException
3617
+	 * @throws InvalidInterfaceException
3618
+	 */
3619
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3620
+	{
3621
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3622
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3623
+			$notices = EE_Error::get_notices(false);
3624
+			if (empty($this->_template_args['success'])) {
3625
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3626
+			}
3627
+			if (empty($this->_template_args['errors'])) {
3628
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3629
+			}
3630
+			if (empty($this->_template_args['attention'])) {
3631
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3632
+			}
3633
+		}
3634
+		$this->_template_args['notices'] = EE_Error::get_notices();
3635
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3636
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3637
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3638
+			$this->_add_transient(
3639
+				$route,
3640
+				$this->_template_args['notices'],
3641
+				true,
3642
+				$skip_route_verify
3643
+			);
3644
+		}
3645
+	}
3646
+
3647
+
3648
+	/**
3649
+	 * get_action_link_or_button
3650
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3651
+	 *
3652
+	 * @param string $action        use this to indicate which action the url is generated with.
3653
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3654
+	 *                              property.
3655
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3656
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3657
+	 * @param string $base_url      If this is not provided
3658
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3659
+	 *                              Otherwise this value will be used.
3660
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3661
+	 * @return string
3662
+	 * @throws InvalidArgumentException
3663
+	 * @throws InvalidInterfaceException
3664
+	 * @throws InvalidDataTypeException
3665
+	 * @throws EE_Error
3666
+	 */
3667
+	public function get_action_link_or_button(
3668
+		$action,
3669
+		$type = 'add',
3670
+		$extra_request = array(),
3671
+		$class = 'button-primary',
3672
+		$base_url = '',
3673
+		$exclude_nonce = false
3674
+	) {
3675
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3676
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3677
+			throw new EE_Error(
3678
+				sprintf(
3679
+					esc_html__(
3680
+						'There is no page route for given action for the button.  This action was given: %s',
3681
+						'event_espresso'
3682
+					),
3683
+					$action
3684
+				)
3685
+			);
3686
+		}
3687
+		if (! isset($this->_labels['buttons'][ $type ])) {
3688
+			throw new EE_Error(
3689
+				sprintf(
3690
+					__(
3691
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3692
+						'event_espresso'
3693
+					),
3694
+					$type
3695
+				)
3696
+			);
3697
+		}
3698
+		// finally check user access for this button.
3699
+		$has_access = $this->check_user_access($action, true);
3700
+		if (! $has_access) {
3701
+			return '';
3702
+		}
3703
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3704
+		$query_args = array(
3705
+			'action' => $action,
3706
+		);
3707
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3708
+		if (! empty($extra_request)) {
3709
+			$query_args = array_merge($extra_request, $query_args);
3710
+		}
3711
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3712
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3713
+	}
3714
+
3715
+
3716
+	/**
3717
+	 * _per_page_screen_option
3718
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3719
+	 *
3720
+	 * @return void
3721
+	 * @throws InvalidArgumentException
3722
+	 * @throws InvalidInterfaceException
3723
+	 * @throws InvalidDataTypeException
3724
+	 */
3725
+	protected function _per_page_screen_option()
3726
+	{
3727
+		$option = 'per_page';
3728
+		$args = array(
3729
+			'label'   => apply_filters(
3730
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3731
+				$this->_admin_page_title,
3732
+				$this
3733
+			),
3734
+			'default' => (int) apply_filters(
3735
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3736
+				20
3737
+			),
3738
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3739
+		);
3740
+		// ONLY add the screen option if the user has access to it.
3741
+		if ($this->check_user_access($this->_current_view, true)) {
3742
+			add_screen_option($option, $args);
3743
+		}
3744
+	}
3745
+
3746
+
3747
+	/**
3748
+	 * set_per_page_screen_option
3749
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3750
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3751
+	 * admin_menu.
3752
+	 *
3753
+	 * @return void
3754
+	 */
3755
+	private function _set_per_page_screen_options()
3756
+	{
3757
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3758
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3759
+			if (! $user = wp_get_current_user()) {
3760
+				return;
3761
+			}
3762
+			$option = $_POST['wp_screen_options']['option'];
3763
+			$value = $_POST['wp_screen_options']['value'];
3764
+			if ($option !== sanitize_key($option)) {
3765
+				return;
3766
+			}
3767
+			$map_option = $option;
3768
+			$option = str_replace('-', '_', $option);
3769
+			switch ($map_option) {
3770
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3771
+					$value = (int) $value;
3772
+					$max_value = apply_filters(
3773
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3774
+						999,
3775
+						$this->_current_page,
3776
+						$this->_current_view
3777
+					);
3778
+					if ($value < 1) {
3779
+						return;
3780
+					}
3781
+					$value = min($value, $max_value);
3782
+					break;
3783
+				default:
3784
+					$value = apply_filters(
3785
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3786
+						false,
3787
+						$option,
3788
+						$value
3789
+					);
3790
+					if (false === $value) {
3791
+						return;
3792
+					}
3793
+					break;
3794
+			}
3795
+			update_user_meta($user->ID, $option, $value);
3796
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3797
+			exit;
3798
+		}
3799
+	}
3800
+
3801
+
3802
+	/**
3803
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3804
+	 *
3805
+	 * @param array $data array that will be assigned to template args.
3806
+	 */
3807
+	public function set_template_args($data)
3808
+	{
3809
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3810
+	}
3811
+
3812
+
3813
+	/**
3814
+	 * This makes available the WP transient system for temporarily moving data between routes
3815
+	 *
3816
+	 * @param string $route             the route that should receive the transient
3817
+	 * @param array  $data              the data that gets sent
3818
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3819
+	 *                                  normal route transient.
3820
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3821
+	 *                                  when we are adding a transient before page_routes have been defined.
3822
+	 * @return void
3823
+	 * @throws EE_Error
3824
+	 */
3825
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826
+	{
3827
+		$user_id = get_current_user_id();
3828
+		if (! $skip_route_verify) {
3829
+			$this->_verify_route($route);
3830
+		}
3831
+		// now let's set the string for what kind of transient we're setting
3832
+		$transient = $notices
3833
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
+			: 'rte_tx_' . $route . '_' . $user_id;
3835
+		$data = $notices ? array('notices' => $data) : $data;
3836
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3837
+		$existing = is_multisite() && is_network_admin()
3838
+			? get_site_transient($transient)
3839
+			: get_transient($transient);
3840
+		if ($existing) {
3841
+			$data = array_merge((array) $data, (array) $existing);
3842
+		}
3843
+		if (is_multisite() && is_network_admin()) {
3844
+			set_site_transient($transient, $data, 8);
3845
+		} else {
3846
+			set_transient($transient, $data, 8);
3847
+		}
3848
+	}
3849
+
3850
+
3851
+	/**
3852
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3853
+	 *
3854
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3855
+	 * @param string $route
3856
+	 * @return mixed data
3857
+	 */
3858
+	protected function _get_transient($notices = false, $route = '')
3859
+	{
3860
+		$user_id = get_current_user_id();
3861
+		$route = ! $route ? $this->_req_action : $route;
3862
+		$transient = $notices
3863
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
+			: 'rte_tx_' . $route . '_' . $user_id;
3865
+		$data = is_multisite() && is_network_admin()
3866
+			? get_site_transient($transient)
3867
+			: get_transient($transient);
3868
+		// delete transient after retrieval (just in case it hasn't expired);
3869
+		if (is_multisite() && is_network_admin()) {
3870
+			delete_site_transient($transient);
3871
+		} else {
3872
+			delete_transient($transient);
3873
+		}
3874
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3875
+	}
3876
+
3877
+
3878
+	/**
3879
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3880
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3881
+	 * default route callback on the EE_Admin page you want it run.)
3882
+	 *
3883
+	 * @return void
3884
+	 */
3885
+	protected function _transient_garbage_collection()
3886
+	{
3887
+		global $wpdb;
3888
+		// retrieve all existing transients
3889
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3890
+		if ($results = $wpdb->get_results($query)) {
3891
+			foreach ($results as $result) {
3892
+				$transient = str_replace('_transient_', '', $result->option_name);
3893
+				get_transient($transient);
3894
+				if (is_multisite() && is_network_admin()) {
3895
+					get_site_transient($transient);
3896
+				}
3897
+			}
3898
+		}
3899
+	}
3900
+
3901
+
3902
+	/**
3903
+	 * get_view
3904
+	 *
3905
+	 * @return string content of _view property
3906
+	 */
3907
+	public function get_view()
3908
+	{
3909
+		return $this->_view;
3910
+	}
3911
+
3912
+
3913
+	/**
3914
+	 * getter for the protected $_views property
3915
+	 *
3916
+	 * @return array
3917
+	 */
3918
+	public function get_views()
3919
+	{
3920
+		return $this->_views;
3921
+	}
3922
+
3923
+
3924
+	/**
3925
+	 * get_current_page
3926
+	 *
3927
+	 * @return string _current_page property value
3928
+	 */
3929
+	public function get_current_page()
3930
+	{
3931
+		return $this->_current_page;
3932
+	}
3933
+
3934
+
3935
+	/**
3936
+	 * get_current_view
3937
+	 *
3938
+	 * @return string _current_view property value
3939
+	 */
3940
+	public function get_current_view()
3941
+	{
3942
+		return $this->_current_view;
3943
+	}
3944
+
3945
+
3946
+	/**
3947
+	 * get_current_screen
3948
+	 *
3949
+	 * @return object The current WP_Screen object
3950
+	 */
3951
+	public function get_current_screen()
3952
+	{
3953
+		return $this->_current_screen;
3954
+	}
3955
+
3956
+
3957
+	/**
3958
+	 * get_current_page_view_url
3959
+	 *
3960
+	 * @return string This returns the url for the current_page_view.
3961
+	 */
3962
+	public function get_current_page_view_url()
3963
+	{
3964
+		return $this->_current_page_view_url;
3965
+	}
3966
+
3967
+
3968
+	/**
3969
+	 * just returns the _req_data property
3970
+	 *
3971
+	 * @return array
3972
+	 */
3973
+	public function get_request_data()
3974
+	{
3975
+		return $this->_req_data;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * returns the _req_data protected property
3981
+	 *
3982
+	 * @return string
3983
+	 */
3984
+	public function get_req_action()
3985
+	{
3986
+		return $this->_req_action;
3987
+	}
3988
+
3989
+
3990
+	/**
3991
+	 * @return bool  value of $_is_caf property
3992
+	 */
3993
+	public function is_caf()
3994
+	{
3995
+		return $this->_is_caf;
3996
+	}
3997
+
3998
+
3999
+	/**
4000
+	 * @return mixed
4001
+	 */
4002
+	public function default_espresso_metaboxes()
4003
+	{
4004
+		return $this->_default_espresso_metaboxes;
4005
+	}
4006
+
4007
+
4008
+	/**
4009
+	 * @return mixed
4010
+	 */
4011
+	public function admin_base_url()
4012
+	{
4013
+		return $this->_admin_base_url;
4014
+	}
4015
+
4016
+
4017
+	/**
4018
+	 * @return mixed
4019
+	 */
4020
+	public function wp_page_slug()
4021
+	{
4022
+		return $this->_wp_page_slug;
4023
+	}
4024
+
4025
+
4026
+	/**
4027
+	 * updates  espresso configuration settings
4028
+	 *
4029
+	 * @param string                   $tab
4030
+	 * @param EE_Config_Base|EE_Config $config
4031
+	 * @param string                   $file file where error occurred
4032
+	 * @param string                   $func function  where error occurred
4033
+	 * @param string                   $line line no where error occurred
4034
+	 * @return boolean
4035
+	 */
4036
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4037
+	{
4038
+		// remove any options that are NOT going to be saved with the config settings.
4039
+		if (isset($config->core->ee_ueip_optin)) {
4040
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4041
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4042
+			update_option('ee_ueip_has_notified', true);
4043
+		}
4044
+		// and save it (note we're also doing the network save here)
4045
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4046
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4047
+		if ($config_saved && $net_saved) {
4048
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4049
+			return true;
4050
+		}
4051
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4052
+		return false;
4053
+	}
4054
+
4055
+
4056
+	/**
4057
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4058
+	 *
4059
+	 * @return array
4060
+	 */
4061
+	public function get_yes_no_values()
4062
+	{
4063
+		return $this->_yes_no_values;
4064
+	}
4065
+
4066
+
4067
+	/**
4068
+	 * @return string
4069
+	 * @throws ReflectionException
4070
+	 * @since $VID:$
4071
+	 */
4072
+	protected function _get_dir()
4073
+	{
4074
+		$reflector = new ReflectionClass(get_class($this));
4075
+		return dirname($reflector->getFileName());
4076
+	}
4077
+
4078
+
4079
+	/**
4080
+	 * A helper for getting a "next link".
4081
+	 *
4082
+	 * @param string $url   The url to link to
4083
+	 * @param string $class The class to use.
4084
+	 * @return string
4085
+	 */
4086
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4087
+	{
4088
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4089
+	}
4090
+
4091
+
4092
+	/**
4093
+	 * A helper for getting a "previous link".
4094
+	 *
4095
+	 * @param string $url   The url to link to
4096
+	 * @param string $class The class to use.
4097
+	 * @return string
4098
+	 */
4099
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4100
+	{
4101
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4102
+	}
4103
+
4104
+
4105
+
4106
+
4107
+
4108
+
4109
+
4110
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4111
+
4112
+
4113
+	/**
4114
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4115
+	 * 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
4116
+	 * _req_data array.
4117
+	 *
4118
+	 * @return bool success/fail
4119
+	 * @throws EE_Error
4120
+	 * @throws InvalidArgumentException
4121
+	 * @throws ReflectionException
4122
+	 * @throws InvalidDataTypeException
4123
+	 * @throws InvalidInterfaceException
4124
+	 */
4125
+	protected function _process_resend_registration()
4126
+	{
4127
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4128
+		do_action(
4129
+			'AHEE__EE_Admin_Page___process_resend_registration',
4130
+			$this->_template_args['success'],
4131
+			$this->_req_data
4132
+		);
4133
+		return $this->_template_args['success'];
4134
+	}
4135
+
4136
+
4137
+	/**
4138
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4139
+	 *
4140
+	 * @param EE_Payment $payment
4141
+	 * @return bool success/fail
4142
+	 */
4143
+	protected function _process_payment_notification(EE_Payment $payment)
4144
+	{
4145
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4146
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4147
+		$this->_template_args['success'] = apply_filters(
4148
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4149
+			false,
4150
+			$payment
4151
+		);
4152
+		return $this->_template_args['success'];
4153
+	}
4154 4154
 }
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
         );
555 555
         global $ee_menu_slugs;
556 556
         $ee_menu_slugs = (array) $ee_menu_slugs;
557
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
557
+        if ( ! defined('DOING_AJAX') && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))) {
558 558
             return;
559 559
         }
560 560
         // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             ? $this->_req_data['route']
579 579
             : $this->_req_action;
580 580
         $this->_current_view = $this->_req_action;
581
-        $this->_req_nonce = $this->_req_action . '_nonce';
581
+        $this->_req_nonce = $this->_req_action.'_nonce';
582 582
         $this->_define_page_props();
583 583
         $this->_current_page_view_url = add_query_arg(
584 584
             array('page' => $this->_current_page, 'action' => $this->_current_view),
@@ -612,21 +612,21 @@  discard block
 block discarded – undo
612 612
         }
613 613
         // filter routes and page_config so addons can add their stuff. Filtering done per class
614 614
         $this->_page_routes = apply_filters(
615
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
615
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
616 616
             $this->_page_routes,
617 617
             $this
618 618
         );
619 619
         $this->_page_config = apply_filters(
620
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
620
+            'FHEE__'.get_class($this).'__page_setup__page_config',
621 621
             $this->_page_config,
622 622
             $this
623 623
         );
624 624
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
625 625
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
626
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
626
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
627 627
             add_action(
628 628
                 'AHEE__EE_Admin_Page__route_admin_request',
629
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
629
+                array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view),
630 630
                 10,
631 631
                 2
632 632
             );
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
             if ($this->_is_UI_request) {
640 640
                 // admin_init stuff - global, all views for this page class, specific view
641 641
                 add_action('admin_init', array($this, 'admin_init'), 10);
642
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
643
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
642
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
643
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
644 644
                 }
645 645
             } else {
646 646
                 // hijack regular WP loading and route admin request immediately
@@ -659,12 +659,12 @@  discard block
 block discarded – undo
659 659
      */
660 660
     private function _do_other_page_hooks()
661 661
     {
662
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
662
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
663 663
         foreach ($registered_pages as $page) {
664 664
             // now let's setup the file name and class that should be present
665 665
             $classname = str_replace('.class.php', '', $page);
666 666
             // autoloaders should take care of loading file
667
-            if (! class_exists($classname)) {
667
+            if ( ! class_exists($classname)) {
668 668
                 $error_msg[] = sprintf(
669 669
                     esc_html__(
670 670
                         'Something went wrong with loading the %s admin hooks page.',
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
                                    ),
682 682
                                    $page,
683 683
                                    '<br />',
684
-                                   '<strong>' . $classname . '</strong>'
684
+                                   '<strong>'.$classname.'</strong>'
685 685
                                );
686 686
                 throw new EE_Error(implode('||', $error_msg));
687 687
             }
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
         // load admin_notices - global, page class, and view specific
730 730
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
731 731
         add_action('admin_notices', array($this, 'admin_notices'), 10);
732
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
733
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
732
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
733
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
734 734
         }
735 735
         // load network admin_notices - global, page class, and view specific
736 736
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
737
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
738
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
737
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
738
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
739 739
         }
740 740
         // this will save any per_page screen options if they are present
741 741
         $this->_set_per_page_screen_options();
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
      */
857 857
     protected function _verify_routes()
858 858
     {
859
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
859
+        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
860 860
             return false;
861 861
         }
862 862
         $this->_route = false;
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                 $this->_admin_page_title
869 869
             );
870 870
             // developer error msg
871
-            $error_msg .= '||' . $error_msg
871
+            $error_msg .= '||'.$error_msg
872 872
                           . esc_html__(
873 873
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
874 874
                               'event_espresso'
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
         }
878 878
         // and that the requested page route exists
879 879
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
880
-            $this->_route = $this->_page_routes[ $this->_req_action ];
881
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
882
-                ? $this->_page_config[ $this->_req_action ] : array();
880
+            $this->_route = $this->_page_routes[$this->_req_action];
881
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
882
+                ? $this->_page_config[$this->_req_action] : array();
883 883
         } else {
884 884
             // user error msg
885 885
             $error_msg = sprintf(
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                 $this->_admin_page_title
891 891
             );
892 892
             // developer error msg
893
-            $error_msg .= '||' . $error_msg
893
+            $error_msg .= '||'.$error_msg
894 894
                           . sprintf(
895 895
                               esc_html__(
896 896
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
             throw new EE_Error($error_msg);
902 902
         }
903 903
         // and that a default route exists
904
-        if (! array_key_exists('default', $this->_page_routes)) {
904
+        if ( ! array_key_exists('default', $this->_page_routes)) {
905 905
             // user error msg
906 906
             $error_msg = sprintf(
907 907
                 esc_html__(
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
                 $this->_admin_page_title
912 912
             );
913 913
             // developer error msg
914
-            $error_msg .= '||' . $error_msg
914
+            $error_msg .= '||'.$error_msg
915 915
                           . esc_html__(
916 916
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
917 917
                               'event_espresso'
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
             $this->_admin_page_title
952 952
         );
953 953
         // developer error msg
954
-        $error_msg .= '||' . $error_msg
954
+        $error_msg .= '||'.$error_msg
955 955
                       . sprintf(
956 956
                           esc_html__(
957 957
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
     protected function _verify_nonce($nonce, $nonce_ref)
980 980
     {
981 981
         // verify nonce against expected value
982
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
982
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
983 983
             // these are not the droids you are looking for !!!
984 984
             $msg = sprintf(
985 985
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                             EE_Admin_Page::class
997 997
                         );
998 998
             }
999
-            if (! defined('DOING_AJAX')) {
999
+            if ( ! defined('DOING_AJAX')) {
1000 1000
                 wp_die($msg);
1001 1001
             } else {
1002 1002
                 EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
      */
1022 1022
     protected function _route_admin_request()
1023 1023
     {
1024
-        if (! $this->_is_UI_request) {
1024
+        if ( ! $this->_is_UI_request) {
1025 1025
             $this->_verify_routes();
1026 1026
         }
1027 1027
         $nonce_check = isset($this->_route_config['require_nonce'])
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
             : true;
1030 1030
         if ($this->_req_action !== 'default' && $nonce_check) {
1031 1031
             // set nonce from post data
1032
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
1033
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
1032
+            $nonce = isset($this->_req_data[$this->_req_nonce])
1033
+                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
1034 1034
                 : '';
1035 1035
             $this->_verify_nonce($nonce, $this->_req_nonce);
1036 1036
         }
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
         $error_msg = '';
1046 1046
         // action right before calling route
1047 1047
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1048
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1048
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1049 1049
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1050 1050
         }
1051 1051
         // right before calling the route, let's remove _wp_http_referer from the
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
             '_wp_http_referer',
1055 1055
             wp_unslash($_SERVER['REQUEST_URI'])
1056 1056
         );
1057
-        if (! empty($func)) {
1057
+        if ( ! empty($func)) {
1058 1058
             if (is_array($func)) {
1059 1059
                 list($class, $method) = $func;
1060 1060
             } elseif (strpos($func, '::') !== false) {
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
                 $class = $this;
1064 1064
                 $method = $func;
1065 1065
             }
1066
-            if (! (is_object($class) && $class === $this)) {
1066
+            if ( ! (is_object($class) && $class === $this)) {
1067 1067
                 // send along this admin page object for access by addons.
1068 1068
                 $args['admin_page_object'] = $this;
1069 1069
             }
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
                     $method
1097 1097
                 );
1098 1098
             }
1099
-            if (! empty($error_msg)) {
1099
+            if ( ! empty($error_msg)) {
1100 1100
                 throw new EE_Error($error_msg);
1101 1101
             }
1102 1102
         }
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
                 if (strpos($key, 'nonce') !== false) {
1180 1180
                     continue;
1181 1181
                 }
1182
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1182
+                $args['wp_referer['.$key.']'] = $value;
1183 1183
             }
1184 1184
         }
1185 1185
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1220,10 +1220,10 @@  discard block
 block discarded – undo
1220 1220
     protected function _add_help_tabs()
1221 1221
     {
1222 1222
         $tour_buttons = '';
1223
-        if (isset($this->_page_config[ $this->_req_action ])) {
1224
-            $config = $this->_page_config[ $this->_req_action ];
1223
+        if (isset($this->_page_config[$this->_req_action])) {
1224
+            $config = $this->_page_config[$this->_req_action];
1225 1225
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1226
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1226
+            if (isset($this->_help_tour[$this->_req_action])) {
1227 1227
                 $tb = array();
1228 1228
                 $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1229 1229
                 foreach ($this->_help_tour['tours'] as $tour) {
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1244 1244
             if (is_array($config) && isset($config['help_sidebar'])) {
1245 1245
                 // check that the callback given is valid
1246
-                if (! method_exists($this, $config['help_sidebar'])) {
1246
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1247 1247
                     throw new EE_Error(
1248 1248
                         sprintf(
1249 1249
                             esc_html__(
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
                     );
1257 1257
                 }
1258 1258
                 $content = apply_filters(
1259
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1259
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1260 1260
                     $this->{$config['help_sidebar']}()
1261 1261
                 );
1262 1262
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1264,30 +1264,30 @@  discard block
 block discarded – undo
1264 1264
                 $this->_current_screen->set_help_sidebar($content);
1265 1265
             }
1266 1266
             // if there ARE tour buttons...
1267
-            if (! empty($tour_buttons)) {
1267
+            if ( ! empty($tour_buttons)) {
1268 1268
                 // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1269
-                if (! isset($config['help_sidebar'])) {
1269
+                if ( ! isset($config['help_sidebar'])) {
1270 1270
                     $this->_current_screen->set_help_sidebar($tour_buttons);
1271 1271
                 }
1272 1272
                 // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1273
-                if (! isset($config['help_tabs'])) {
1273
+                if ( ! isset($config['help_tabs'])) {
1274 1274
                     $_ht['id'] = $this->page_slug;
1275 1275
                     $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1276 1276
                     $_ht['content'] = '<p>'
1277 1277
                                       . esc_html__(
1278 1278
                                           'The buttons to the right allow you to start/restart any help tours available for this page',
1279 1279
                                           'event_espresso'
1280
-                                      ) . '</p>';
1280
+                                      ).'</p>';
1281 1281
                     $this->_current_screen->add_help_tab($_ht);
1282 1282
                 }
1283 1283
             }
1284
-            if (! isset($config['help_tabs'])) {
1284
+            if ( ! isset($config['help_tabs'])) {
1285 1285
                 return;
1286 1286
             } //no help tabs for this route
1287 1287
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1288 1288
                 // we're here so there ARE help tabs!
1289 1289
                 // make sure we've got what we need
1290
-                if (! isset($cfg['title'])) {
1290
+                if ( ! isset($cfg['title'])) {
1291 1291
                     throw new EE_Error(
1292 1292
                         esc_html__(
1293 1293
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
                         )
1296 1296
                     );
1297 1297
                 }
1298
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1298
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1299 1299
                     throw new EE_Error(
1300 1300
                         esc_html__(
1301 1301
                             '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',
@@ -1304,11 +1304,11 @@  discard block
 block discarded – undo
1304 1304
                     );
1305 1305
                 }
1306 1306
                 // first priority goes to content.
1307
-                if (! empty($cfg['content'])) {
1307
+                if ( ! empty($cfg['content'])) {
1308 1308
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1309 1309
                     // second priority goes to filename
1310
-                } elseif (! empty($cfg['filename'])) {
1311
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1310
+                } elseif ( ! empty($cfg['filename'])) {
1311
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1312 1312
                     // 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)
1313 1313
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1314 1314
                                                              . basename($this->_get_dir())
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
                                                              . $cfg['filename']
1317 1317
                                                              . '.help_tab.php' : $file_path;
1318 1318
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1319
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1319
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1320 1320
                         EE_Error::add_error(
1321 1321
                             sprintf(
1322 1322
                                 esc_html__(
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
                     return;
1363 1363
                 }
1364 1364
                 // setup config array for help tab method
1365
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1365
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1366 1366
                 $_ht = array(
1367 1367
                     'id'       => $id,
1368 1368
                     'title'    => $cfg['title'],
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
             }
1408 1408
             if (isset($config['help_tour'])) {
1409 1409
                 foreach ($config['help_tour'] as $tour) {
1410
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1410
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1411 1411
                     // let's see if we can get that file...
1412 1412
                     // if not its possible this is a decaf route not set in caffeinated
1413 1413
                     // so lets try and get the caffeinated equivalent
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
                                                              . $tour
1418 1418
                                                              . '.class.php' : $file_path;
1419 1419
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1420
-                    if (! is_readable($file_path)) {
1420
+                    if ( ! is_readable($file_path)) {
1421 1421
                         EE_Error::add_error(
1422 1422
                             sprintf(
1423 1423
                                 esc_html__(
@@ -1434,13 +1434,13 @@  discard block
 block discarded – undo
1434 1434
                         return;
1435 1435
                     }
1436 1436
                     require_once $file_path;
1437
-                    if (! class_exists($tour)) {
1437
+                    if ( ! class_exists($tour)) {
1438 1438
                         $error_msg = [];
1439 1439
                         $error_msg[] = sprintf(
1440 1440
                             esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1441 1441
                             $tour
1442 1442
                         );
1443
-                        $error_msg[] = $error_msg[0] . "\r\n"
1443
+                        $error_msg[] = $error_msg[0]."\r\n"
1444 1444
                                        . sprintf(
1445 1445
                                            esc_html__(
1446 1446
                                                '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.',
@@ -1456,16 +1456,16 @@  discard block
 block discarded – undo
1456 1456
                     }
1457 1457
                     $tour_obj = new $tour($this->_is_caf);
1458 1458
                     $tours[] = $tour_obj;
1459
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1459
+                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1460 1460
                 }
1461 1461
                 // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1462 1462
                 $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1463 1463
                 $tours[] = $end_stop_tour;
1464
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1464
+                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1465 1465
             }
1466 1466
         }
1467 1467
 
1468
-        if (! empty($tours)) {
1468
+        if ( ! empty($tours)) {
1469 1469
             $this->_help_tour['tours'] = $tours;
1470 1470
         }
1471 1471
         // that's it!  Now that the $_help_tours property is set (or not)
@@ -1493,8 +1493,8 @@  discard block
 block discarded – undo
1493 1493
             $qtips = (array) $this->_route_config['qtips'];
1494 1494
             // load qtip loader
1495 1495
             $path = array(
1496
-                $this->_get_dir() . '/qtips/',
1497
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1496
+                $this->_get_dir().'/qtips/',
1497
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1498 1498
             );
1499 1499
             $qtip_loader = EEH_Qtip_Loader::instance();
1500 1500
             if ($qtip_loader instanceof EEH_Qtip_Loader) {
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1520 1520
         $i = 0;
1521 1521
         foreach ($this->_page_config as $slug => $config) {
1522
-            if (! is_array($config)
1522
+            if ( ! is_array($config)
1523 1523
                 || (
1524 1524
                     is_array($config)
1525 1525
                     && (
@@ -1536,12 +1536,12 @@  discard block
 block discarded – undo
1536 1536
                 // nav tab is only to appear when route requested.
1537 1537
                 continue;
1538 1538
             }
1539
-            if (! $this->check_user_access($slug, true)) {
1539
+            if ( ! $this->check_user_access($slug, true)) {
1540 1540
                 // no nav tab because current user does not have access.
1541 1541
                 continue;
1542 1542
             }
1543
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1544
-            $this->_nav_tabs[ $slug ] = array(
1543
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1544
+            $this->_nav_tabs[$slug] = array(
1545 1545
                 'url'       => isset($config['nav']['url'])
1546 1546
                     ? $config['nav']['url']
1547 1547
                     : EE_Admin_Page::add_query_args_and_nonce(
@@ -1553,14 +1553,14 @@  discard block
 block discarded – undo
1553 1553
                     : ucwords(
1554 1554
                         str_replace('_', ' ', $slug)
1555 1555
                     ),
1556
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1556
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1557 1557
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1558 1558
             );
1559 1559
             $i++;
1560 1560
         }
1561 1561
         // if $this->_nav_tabs is empty then lets set the default
1562 1562
         if (empty($this->_nav_tabs)) {
1563
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1563
+            $this->_nav_tabs[$this->_default_nav_tab_name] = array(
1564 1564
                 'url'       => $this->_admin_base_url,
1565 1565
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1566 1566
                 'css_class' => 'nav-tab-active',
@@ -1585,10 +1585,10 @@  discard block
 block discarded – undo
1585 1585
             foreach ($this->_route_config['labels'] as $label => $text) {
1586 1586
                 if (is_array($text)) {
1587 1587
                     foreach ($text as $sublabel => $subtext) {
1588
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1588
+                        $this->_labels[$label][$sublabel] = $subtext;
1589 1589
                     }
1590 1590
                 } else {
1591
-                    $this->_labels[ $label ] = $text;
1591
+                    $this->_labels[$label] = $text;
1592 1592
                 }
1593 1593
             }
1594 1594
         }
@@ -1610,12 +1610,12 @@  discard block
 block discarded – undo
1610 1610
     {
1611 1611
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1612 1612
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1613
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1613
+        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1614 1614
                       && is_array(
1615
-                          $this->_page_routes[ $route_to_check ]
1615
+                          $this->_page_routes[$route_to_check]
1616 1616
                       )
1617
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1618
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1617
+                      && ! empty($this->_page_routes[$route_to_check]['capability'])
1618
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1619 1619
         if (empty($capability) && empty($route_to_check)) {
1620 1620
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1621 1621
                 : $this->_route['capability'];
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
             $capability = empty($capability) ? 'manage_options' : $capability;
1624 1624
         }
1625 1625
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1626
-        if (! defined('DOING_AJAX')
1626
+        if ( ! defined('DOING_AJAX')
1627 1627
             && (
1628 1628
                 ! function_exists('is_admin')
1629 1629
                 || ! EE_Registry::instance()->CAP->current_user_can(
@@ -1728,17 +1728,17 @@  discard block
 block discarded – undo
1728 1728
     public function admin_footer_global()
1729 1729
     {
1730 1730
         // dialog container for dialog helper
1731
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1731
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1732 1732
         $d_cont .= '<div class="ee-notices"></div>';
1733 1733
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1734 1734
         $d_cont .= '</div>';
1735 1735
         echo $d_cont;
1736 1736
         // help tour stuff?
1737
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1738
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1737
+        if (isset($this->_help_tour[$this->_req_action])) {
1738
+            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1739 1739
         }
1740 1740
         // current set timezone for timezone js
1741
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1741
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1742 1742
     }
1743 1743
 
1744 1744
 
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
         // loop through the array and setup content
1773 1773
         foreach ($help_array as $trigger => $help) {
1774 1774
             // make sure the array is setup properly
1775
-            if (! isset($help['title'], $help['content'])) {
1775
+            if ( ! isset($help['title'], $help['content'])) {
1776 1776
                 throw new EE_Error(
1777 1777
                     esc_html__(
1778 1778
                         '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',
@@ -1787,7 +1787,7 @@  discard block
 block discarded – undo
1787 1787
                 'help_popup_content' => $help['content'],
1788 1788
             );
1789 1789
             $content .= EEH_Template::display_template(
1790
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1790
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1791 1791
                 $template_args,
1792 1792
                 true
1793 1793
             );
@@ -1809,15 +1809,15 @@  discard block
 block discarded – undo
1809 1809
     private function _get_help_content()
1810 1810
     {
1811 1811
         // what is the method we're looking for?
1812
-        $method_name = '_help_popup_content_' . $this->_req_action;
1812
+        $method_name = '_help_popup_content_'.$this->_req_action;
1813 1813
         // if method doesn't exist let's get out.
1814
-        if (! method_exists($this, $method_name)) {
1814
+        if ( ! method_exists($this, $method_name)) {
1815 1815
             return array();
1816 1816
         }
1817 1817
         // k we're good to go let's retrieve the help array
1818 1818
         $help_array = $this->{$method_name}();
1819 1819
         // make sure we've got an array!
1820
-        if (! is_array($help_array)) {
1820
+        if ( ! is_array($help_array)) {
1821 1821
             throw new EE_Error(
1822 1822
                 esc_html__(
1823 1823
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1849,8 +1849,8 @@  discard block
 block discarded – undo
1849 1849
         // 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
1850 1850
         $help_array = $this->_get_help_content();
1851 1851
         $help_content = '';
1852
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1853
-            $help_array[ $trigger_id ] = array(
1852
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1853
+            $help_array[$trigger_id] = array(
1854 1854
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1855 1855
                 'content' => esc_html__(
1856 1856
                     '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.)',
@@ -2043,12 +2043,12 @@  discard block
 block discarded – undo
2043 2043
     protected function _set_list_table()
2044 2044
     {
2045 2045
         // first is this a list_table view?
2046
-        if (! isset($this->_route_config['list_table'])) {
2046
+        if ( ! isset($this->_route_config['list_table'])) {
2047 2047
             return;
2048 2048
         } //not a list_table view so get out.
2049 2049
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2050
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2051
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2050
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2051
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2052 2052
             // user error msg
2053 2053
             $error_msg = esc_html__(
2054 2054
                 'An error occurred. The requested list table views could not be found.',
@@ -2068,10 +2068,10 @@  discard block
 block discarded – undo
2068 2068
         }
2069 2069
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2070 2070
         $this->_views = apply_filters(
2071
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2071
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2072 2072
             $this->_views
2073 2073
         );
2074
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2074
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2075 2075
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2076 2076
         $this->_set_list_table_view();
2077 2077
         $this->_set_list_table_object();
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
     {
2088 2088
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2089 2089
         // looking at active items or dumpster diving ?
2090
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2090
+        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2091 2091
             $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2092 2092
         } else {
2093 2093
             $this->_view = sanitize_key($this->_req_data['status']);
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
     protected function _set_list_table_object()
2109 2109
     {
2110 2110
         if (isset($this->_route_config['list_table'])) {
2111
-            if (! class_exists($this->_route_config['list_table'])) {
2111
+            if ( ! class_exists($this->_route_config['list_table'])) {
2112 2112
                 throw new EE_Error(
2113 2113
                     sprintf(
2114 2114
                         esc_html__(
@@ -2146,17 +2146,17 @@  discard block
 block discarded – undo
2146 2146
         foreach ($this->_views as $key => $view) {
2147 2147
             $query_args = array();
2148 2148
             // check for current view
2149
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2149
+            $this->_views[$key]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2150 2150
             $query_args['action'] = $this->_req_action;
2151
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2151
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2152 2152
             $query_args['status'] = $view['slug'];
2153 2153
             // merge any other arguments sent in.
2154
-            if (isset($extra_query_args[ $view['slug'] ])) {
2155
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2154
+            if (isset($extra_query_args[$view['slug']])) {
2155
+                foreach ($extra_query_args[$view['slug']] as $extra_query_arg) {
2156 2156
                     $query_args[] = $extra_query_arg;
2157 2157
                 }
2158 2158
             }
2159
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2159
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2160 2160
         }
2161 2161
         return $this->_views;
2162 2162
     }
@@ -2175,7 +2175,7 @@  discard block
 block discarded – undo
2175 2175
     {
2176 2176
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2177 2177
         $values = array(10, 25, 50, 100);
2178
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2178
+        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2179 2179
         if ($max_entries) {
2180 2180
             $values[] = $max_entries;
2181 2181
             sort($values);
@@ -2187,14 +2187,14 @@  discard block
 block discarded – undo
2187 2187
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2188 2188
         foreach ($values as $value) {
2189 2189
             if ($value < $max_entries) {
2190
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2190
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2191 2191
                 $entries_per_page_dropdown .= '
2192
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2192
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2193 2193
             }
2194 2194
         }
2195
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2195
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2196 2196
         $entries_per_page_dropdown .= '
2197
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2197
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2198 2198
         $entries_per_page_dropdown .= '
2199 2199
 					</select>
2200 2200
 					entries
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
             empty($this->_search_btn_label) ? $this->page_label
2219 2219
                 : $this->_search_btn_label
2220 2220
         );
2221
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2221
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2222 2222
     }
2223 2223
 
2224 2224
 
@@ -2304,7 +2304,7 @@  discard block
 block discarded – undo
2304 2304
             $total_columns = ! empty($screen_columns)
2305 2305
                 ? $screen_columns
2306 2306
                 : $this->_route_config['columns'][1];
2307
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2307
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2308 2308
             $this->_template_args['current_page'] = $this->_wp_page_slug;
2309 2309
             $this->_template_args['screen'] = $this->_current_screen;
2310 2310
             $this->_column_template_path = EE_ADMIN_TEMPLATE
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
      */
2350 2350
     protected function _espresso_ratings_request()
2351 2351
     {
2352
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2352
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2353 2353
             return;
2354 2354
         }
2355 2355
         $ratings_box_title = apply_filters(
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
      */
2377 2377
     public function espresso_ratings_request()
2378 2378
     {
2379
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2379
+        EEH_Template::display_template(EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php');
2380 2380
     }
2381 2381
 
2382 2382
 
@@ -2387,17 +2387,17 @@  discard block
 block discarded – undo
2387 2387
                    . '</p><p class="hide-if-js">'
2388 2388
                    . esc_html__('This widget requires JavaScript.', 'event_espresso')
2389 2389
                    . '</p>';
2390
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2391
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2392
-        $post = '</div>' . "\n";
2393
-        $cache_key = 'ee_rss_' . md5($rss_id);
2390
+        $pre = '<div class="espresso-rss-display">'."\n\t";
2391
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2392
+        $post = '</div>'."\n";
2393
+        $cache_key = 'ee_rss_'.md5($rss_id);
2394 2394
         $output = get_transient($cache_key);
2395 2395
         if ($output !== false) {
2396
-            echo $pre . $output . $post;
2396
+            echo $pre.$output.$post;
2397 2397
             return true;
2398 2398
         }
2399
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2400
-            echo $pre . $loading . $post;
2399
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2400
+            echo $pre.$loading.$post;
2401 2401
             return false;
2402 2402
         }
2403 2403
         ob_start();
@@ -2464,19 +2464,19 @@  discard block
 block discarded – undo
2464 2464
     public function espresso_sponsors_post_box()
2465 2465
     {
2466 2466
         EEH_Template::display_template(
2467
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2467
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2468 2468
         );
2469 2469
     }
2470 2470
 
2471 2471
 
2472 2472
     private function _publish_post_box()
2473 2473
     {
2474
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2474
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2475 2475
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2476 2476
         // then we'll use that for the metabox label.
2477 2477
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2478
-        if (! empty($this->_labels['publishbox'])) {
2479
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2478
+        if ( ! empty($this->_labels['publishbox'])) {
2479
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2480 2480
                 : $this->_labels['publishbox'];
2481 2481
         } else {
2482 2482
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
             ? $this->_template_args['publish_box_extra_content']
2506 2506
             : '';
2507 2507
         echo EEH_Template::display_template(
2508
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2508
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2509 2509
             $this->_template_args,
2510 2510
             true
2511 2511
         );
@@ -2595,8 +2595,8 @@  discard block
 block discarded – undo
2595 2595
             );
2596 2596
         }
2597 2597
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2598
-        if (! empty($name) && ! empty($id)) {
2599
-            $hidden_field_arr[ $name ] = array(
2598
+        if ( ! empty($name) && ! empty($id)) {
2599
+            $hidden_field_arr[$name] = array(
2600 2600
                 'type'  => 'hidden',
2601 2601
                 'value' => $id,
2602 2602
             );
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
         }
2607 2607
         // add hidden field
2608 2608
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2609
-            ? $hf[ $name ]['field']
2609
+            ? $hf[$name]['field']
2610 2610
             : $hf;
2611 2611
     }
2612 2612
 
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
         }
2709 2709
         // 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)
2710 2710
         $call_back_func = $create_func
2711
-            ? static function ($post, $metabox) {
2711
+            ? static function($post, $metabox) {
2712 2712
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2713 2713
                 echo EEH_Template::display_template(
2714 2714
                     $metabox['args']['template_path'],
@@ -2718,7 +2718,7 @@  discard block
 block discarded – undo
2718 2718
             }
2719 2719
             : $callback;
2720 2720
         add_meta_box(
2721
-            str_replace('_', '-', $action) . '-mbox',
2721
+            str_replace('_', '-', $action).'-mbox',
2722 2722
             $title,
2723 2723
             $call_back_func,
2724 2724
             $this->_wp_page_slug,
@@ -2825,9 +2825,9 @@  discard block
 block discarded – undo
2825 2825
             : 'espresso-default-admin';
2826 2826
         $template_path = $sidebar
2827 2827
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2828
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2828
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2829 2829
         if (defined('DOING_AJAX') && DOING_AJAX) {
2830
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2830
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2831 2831
         }
2832 2832
         $template_path = ! empty($this->_column_template_path)
2833 2833
             ? $this->_column_template_path : $template_path;
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
             )
2893 2893
             : $this->_template_args['preview_action_button'];
2894 2894
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2895
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2895
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2896 2896
             $this->_template_args,
2897 2897
             true
2898 2898
         );
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
         // setup search attributes
2951 2951
         $this->_set_search_attributes();
2952 2952
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2953
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2953
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2954 2954
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2955 2955
             ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2956 2956
             : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2958,10 +2958,10 @@  discard block
 block discarded – undo
2958 2958
         $this->_template_args['current_route'] = $this->_req_action;
2959 2959
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2960 2960
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2961
-        if (! empty($ajax_sorting_callback)) {
2961
+        if ( ! empty($ajax_sorting_callback)) {
2962 2962
             $sortable_list_table_form_fields = wp_nonce_field(
2963
-                $ajax_sorting_callback . '_nonce',
2964
-                $ajax_sorting_callback . '_nonce',
2963
+                $ajax_sorting_callback.'_nonce',
2964
+                $ajax_sorting_callback.'_nonce',
2965 2965
                 false,
2966 2966
                 false
2967 2967
             );
@@ -2978,7 +2978,7 @@  discard block
 block discarded – undo
2978 2978
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2979 2979
             ? $this->_template_args['list_table_hidden_fields']
2980 2980
             : '';
2981
-        $nonce_ref = $this->_req_action . '_nonce';
2981
+        $nonce_ref = $this->_req_action.'_nonce';
2982 2982
         $hidden_form_fields .= '<input type="hidden" name="'
2983 2983
                                . $nonce_ref
2984 2984
                                . '" value="'
@@ -2987,10 +2987,10 @@  discard block
 block discarded – undo
2987 2987
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2988 2988
         // display message about search results?
2989 2989
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2990
-            ? '<p class="ee-search-results">' . sprintf(
2990
+            ? '<p class="ee-search-results">'.sprintf(
2991 2991
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2992 2992
                 trim($this->_req_data['s'], '%')
2993
-            ) . '</p>'
2993
+            ).'</p>'
2994 2994
             : '';
2995 2995
         // filter before_list_table template arg
2996 2996
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3072,15 +3072,15 @@  discard block
 block discarded – undo
3072 3072
         );
3073 3073
         /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
3074 3074
         $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
3075
-        if (! $status_change_notice->isDismissed()) {
3075
+        if ( ! $status_change_notice->isDismissed()) {
3076 3076
             $this->_template_args['status_change_notice'] = EEH_Template::display_template(
3077
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
3078
-                [ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
3077
+                EE_ADMIN_TEMPLATE.'status_change_notice.template.php',
3078
+                ['context' => '__admin-legend', 'page_slug' => $this->page_slug],
3079 3079
                 true
3080 3080
             );
3081 3081
         }
3082 3082
         return EEH_Template::display_template(
3083
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3083
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3084 3084
             $this->_template_args,
3085 3085
             true
3086 3086
         );
@@ -3311,17 +3311,17 @@  discard block
 block discarded – undo
3311 3311
         // add in a hidden index for the current page (so save and close redirects properly)
3312 3312
         $this->_template_args['save_buttons'] = $referrer_url;
3313 3313
         foreach ($button_text as $key => $button) {
3314
-            $ref = $default_names[ $key ];
3314
+            $ref = $default_names[$key];
3315 3315
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3316 3316
                                                      . $ref
3317 3317
                                                      . '" value="'
3318 3318
                                                      . $button
3319 3319
                                                      . '" name="'
3320
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3320
+                                                     . ( ! empty($actions) ? $actions[$key] : $ref)
3321 3321
                                                      . '" id="'
3322
-                                                     . $this->_current_view . '_' . $ref
3322
+                                                     . $this->_current_view.'_'.$ref
3323 3323
                                                      . '" />';
3324
-            if (! $both) {
3324
+            if ( ! $both) {
3325 3325
                 break;
3326 3326
             }
3327 3327
         }
@@ -3356,13 +3356,13 @@  discard block
 block discarded – undo
3356 3356
                 'An error occurred. No action was set for this page\'s form.',
3357 3357
                 'event_espresso'
3358 3358
             );
3359
-            $dev_msg = $user_msg . "\n"
3359
+            $dev_msg = $user_msg."\n"
3360 3360
                        . sprintf(
3361 3361
                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3362 3362
                            __FUNCTION__,
3363 3363
                            EE_Admin_Page::class
3364 3364
                        );
3365
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3365
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3366 3366
         }
3367 3367
         // open form
3368 3368
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3371,8 +3371,8 @@  discard block
 block discarded – undo
3371 3371
                                                              . $route
3372 3372
                                                              . '_event_form" >';
3373 3373
         // add nonce
3374
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3375
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3374
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3375
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3376 3376
         // add REQUIRED form action
3377 3377
         $hidden_fields = array(
3378 3378
             'action' => array('type' => 'hidden', 'value' => $route),
@@ -3385,7 +3385,7 @@  discard block
 block discarded – undo
3385 3385
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3386 3386
         // add fields to form
3387 3387
         foreach ((array) $form_fields as $field_name => $form_field) {
3388
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3388
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3389 3389
         }
3390 3390
         // close form
3391 3391
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3439,12 +3439,12 @@  discard block
 block discarded – undo
3439 3439
         foreach ($this->_req_data as $ref => $value) {
3440 3440
             // unset nonces
3441 3441
             if (strpos($ref, 'nonce') !== false) {
3442
-                unset($this->_req_data[ $ref ]);
3442
+                unset($this->_req_data[$ref]);
3443 3443
                 continue;
3444 3444
             }
3445 3445
             // urlencode values.
3446 3446
             $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3447
-            $this->_req_data[ $ref ] = $value;
3447
+            $this->_req_data[$ref] = $value;
3448 3448
         }
3449 3449
         return array_merge($this->_req_data, $new_route_data);
3450 3450
     }
@@ -3482,10 +3482,10 @@  discard block
 block discarded – undo
3482 3482
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3483 3483
         $notices = EE_Error::get_notices(false);
3484 3484
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3485
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3485
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3486 3486
             EE_Error::overwrite_success();
3487 3487
         }
3488
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3488
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3489 3489
             // how many records affected ? more than one record ? or just one ?
3490 3490
             if ($success > 1) {
3491 3491
                 // set plural msg
@@ -3514,7 +3514,7 @@  discard block
 block discarded – undo
3514 3514
             }
3515 3515
         }
3516 3516
         // check that $query_args isn't something crazy
3517
-        if (! is_array($query_args)) {
3517
+        if ( ! is_array($query_args)) {
3518 3518
             $query_args = array();
3519 3519
         }
3520 3520
         /**
@@ -3539,7 +3539,7 @@  discard block
 block discarded – undo
3539 3539
             $redirect_url = admin_url('admin.php');
3540 3540
         }
3541 3541
         // merge any default query_args set in _default_route_query_args property
3542
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3542
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3543 3543
             $args_to_merge = array();
3544 3544
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3545 3545
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3551,15 +3551,15 @@  discard block
 block discarded – undo
3551 3551
                         }
3552 3552
                         // finally we will override any arguments in the referer with
3553 3553
                         // what might be set on the _default_route_query_args array.
3554
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3555
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3554
+                        if (isset($this->_default_route_query_args[$reference])) {
3555
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3556 3556
                         } else {
3557
-                            $args_to_merge[ $reference ] = urlencode($value);
3557
+                            $args_to_merge[$reference] = urlencode($value);
3558 3558
                         }
3559 3559
                     }
3560 3560
                     continue;
3561 3561
                 }
3562
-                $args_to_merge[ $query_param ] = $query_value;
3562
+                $args_to_merge[$query_param] = $query_value;
3563 3563
             }
3564 3564
             // now let's merge these arguments but override with what was specifically sent in to the
3565 3565
             // redirect.
@@ -3571,13 +3571,13 @@  discard block
 block discarded – undo
3571 3571
         if (isset($query_args['action'])) {
3572 3572
             // manually generate wp_nonce and merge that with the query vars
3573 3573
             // becuz the wp_nonce_url function wrecks havoc on some vars
3574
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3574
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3575 3575
         }
3576 3576
         // we're adding some hooks and filters in here for processing any things just before redirects
3577 3577
         // (example: an admin page has done an insert or update and we want to run something after that).
3578
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3578
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3579 3579
         $redirect_url = apply_filters(
3580
-            'FHEE_redirect_' . $classname . $this->_req_action,
3580
+            'FHEE_redirect_'.$classname.$this->_req_action,
3581 3581
             EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3582 3582
             $query_args
3583 3583
         );
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
         }
3634 3634
         $this->_template_args['notices'] = EE_Error::get_notices();
3635 3635
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3636
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3636
+        if ( ! defined('DOING_AJAX') || $sticky_notices) {
3637 3637
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3638 3638
             $this->_add_transient(
3639 3639
                 $route,
@@ -3673,7 +3673,7 @@  discard block
 block discarded – undo
3673 3673
         $exclude_nonce = false
3674 3674
     ) {
3675 3675
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3676
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3676
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3677 3677
             throw new EE_Error(
3678 3678
                 sprintf(
3679 3679
                     esc_html__(
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
                 )
3685 3685
             );
3686 3686
         }
3687
-        if (! isset($this->_labels['buttons'][ $type ])) {
3687
+        if ( ! isset($this->_labels['buttons'][$type])) {
3688 3688
             throw new EE_Error(
3689 3689
                 sprintf(
3690 3690
                     __(
@@ -3697,7 +3697,7 @@  discard block
 block discarded – undo
3697 3697
         }
3698 3698
         // finally check user access for this button.
3699 3699
         $has_access = $this->check_user_access($action, true);
3700
-        if (! $has_access) {
3700
+        if ( ! $has_access) {
3701 3701
             return '';
3702 3702
         }
3703 3703
         $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3705,11 +3705,11 @@  discard block
 block discarded – undo
3705 3705
             'action' => $action,
3706 3706
         );
3707 3707
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3708
-        if (! empty($extra_request)) {
3708
+        if ( ! empty($extra_request)) {
3709 3709
             $query_args = array_merge($extra_request, $query_args);
3710 3710
         }
3711 3711
         $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3712
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3712
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3713 3713
     }
3714 3714
 
3715 3715
 
@@ -3735,7 +3735,7 @@  discard block
 block discarded – undo
3735 3735
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3736 3736
                 20
3737 3737
             ),
3738
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3738
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3739 3739
         );
3740 3740
         // ONLY add the screen option if the user has access to it.
3741 3741
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3756,7 +3756,7 @@  discard block
 block discarded – undo
3756 3756
     {
3757 3757
         if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3758 3758
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3759
-            if (! $user = wp_get_current_user()) {
3759
+            if ( ! $user = wp_get_current_user()) {
3760 3760
                 return;
3761 3761
             }
3762 3762
             $option = $_POST['wp_screen_options']['option'];
@@ -3767,7 +3767,7 @@  discard block
 block discarded – undo
3767 3767
             $map_option = $option;
3768 3768
             $option = str_replace('-', '_', $option);
3769 3769
             switch ($map_option) {
3770
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3770
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3771 3771
                     $value = (int) $value;
3772 3772
                     $max_value = apply_filters(
3773 3773
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
@@ -3825,13 +3825,13 @@  discard block
 block discarded – undo
3825 3825
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826 3826
     {
3827 3827
         $user_id = get_current_user_id();
3828
-        if (! $skip_route_verify) {
3828
+        if ( ! $skip_route_verify) {
3829 3829
             $this->_verify_route($route);
3830 3830
         }
3831 3831
         // now let's set the string for what kind of transient we're setting
3832 3832
         $transient = $notices
3833
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
-            : 'rte_tx_' . $route . '_' . $user_id;
3833
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3834
+            : 'rte_tx_'.$route.'_'.$user_id;
3835 3835
         $data = $notices ? array('notices' => $data) : $data;
3836 3836
         // is there already a transient for this route?  If there is then let's ADD to that transient
3837 3837
         $existing = is_multisite() && is_network_admin()
@@ -3860,8 +3860,8 @@  discard block
 block discarded – undo
3860 3860
         $user_id = get_current_user_id();
3861 3861
         $route = ! $route ? $this->_req_action : $route;
3862 3862
         $transient = $notices
3863
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
-            : 'rte_tx_' . $route . '_' . $user_id;
3863
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3864
+            : 'rte_tx_'.$route.'_'.$user_id;
3865 3865
         $data = is_multisite() && is_network_admin()
3866 3866
             ? get_site_transient($transient)
3867 3867
             : get_transient($transient);
@@ -4085,7 +4085,7 @@  discard block
 block discarded – undo
4085 4085
      */
4086 4086
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4087 4087
     {
4088
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4088
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4089 4089
     }
4090 4090
 
4091 4091
 
@@ -4098,7 +4098,7 @@  discard block
 block discarded – undo
4098 4098
      */
4099 4099
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4100 4100
     {
4101
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4101
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4102 4102
     }
4103 4103
 
4104 4104
 
Please login to merge, or discard this patch.
core/admin/templates/status_change_notice.template.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 
7 7
 $page_slug          = ! empty($page_slug) ? "{$page_slug}-page" : '';
8 8
 $unknown_error_msg  = __(
9
-    'Oops... an unknown error has occurred on the server and this notice could not be dismissed.',
10
-    'event_espresso'
9
+	'Oops... an unknown error has occurred on the server and this notice could not be dismissed.',
10
+	'event_espresso'
11 11
 );
12 12
 $failed_request_msg = __('Request failed. The server returned status code: ', 'event_espresso');
13 13
 ?>
@@ -240,100 +240,100 @@  discard block
 block discarded – undo
240 240
             <h3><?php esc_html_e('Important Notice Regarding Status Color Codes', 'event_espresso'); ?></h3>
241 241
             <p>
242 242
                 <?php esc_html_e(
243
-                    'In order to correct some inconsistencies in our event, datetime, and ticket status color codes, we have made the following changes:',
244
-                    'event_espresso'
245
-                ); ?>
243
+					'In order to correct some inconsistencies in our event, datetime, and ticket status color codes, we have made the following changes:',
244
+					'event_espresso'
245
+				); ?>
246 246
             </p>
247 247
             <ul>
248 248
                 <li class="ee-status-event">
249 249
                     <?php printf(
250
-                        esc_html__(
251
-                            'The Event, Datetime, and Ticket "Sold Out" status colors have changed from %1$sYellow%3$s to %2$sPurple%3$s',
252
-                            'event_espresso'
253
-                        ),
254
-                        '<span class="yellow pill">',
255
-                        '<span class="purple pill">',
256
-                        '</span>'
257
-                    ); ?>
250
+						esc_html__(
251
+							'The Event, Datetime, and Ticket "Sold Out" status colors have changed from %1$sYellow%3$s to %2$sPurple%3$s',
252
+							'event_espresso'
253
+						),
254
+						'<span class="yellow pill">',
255
+						'<span class="purple pill">',
256
+						'</span>'
257
+					); ?>
258 258
                 </li>
259 259
                 <li class="ee-status-event">
260 260
                     <?php printf(
261
-                        esc_html__(
262
-                            'The Event and Datetime "Postponed" status colors have changed from %1$sPurple%3$s to %2$sYellow%3$s',
263
-                            'event_espresso'
264
-                        ),
265
-                        '<span class="purple pill">',
266
-                        '<span class="yellow pill">',
267
-                        '</span>'
268
-                    ); ?>
261
+						esc_html__(
262
+							'The Event and Datetime "Postponed" status colors have changed from %1$sPurple%3$s to %2$sYellow%3$s',
263
+							'event_espresso'
264
+						),
265
+						'<span class="purple pill">',
266
+						'<span class="yellow pill">',
267
+						'</span>'
268
+					); ?>
269 269
                 </li>
270 270
                 <li class="ee-status-event">
271 271
                     <?php printf(
272
-                        esc_html__(
273
-                            'The Event "Inactive" and Ticket "Archived" status colors have changed from %1$sPurple%3$s to %2$sCharcoal%3$s',
274
-                            'event_espresso'
275
-                        ),
276
-                        '<span class="purple pill">',
277
-                        '<span class="charcoal pill">',
278
-                        '</span>'
279
-                    ); ?>
272
+						esc_html__(
273
+							'The Event "Inactive" and Ticket "Archived" status colors have changed from %1$sPurple%3$s to %2$sCharcoal%3$s',
274
+							'event_espresso'
275
+						),
276
+						'<span class="purple pill">',
277
+						'<span class="charcoal pill">',
278
+						'</span>'
279
+					); ?>
280 280
                 </li>
281 281
                 <li class="ee-status-message">
282 282
                     <?php printf(
283
-                        esc_html__(
284
-                            'The Message "Queued For Resending" status color has changed from %1$sYellow%3$s to %2$sBlue%3$s',
285
-                            'event_espresso'
286
-                        ),
287
-                        '<span class="yellow pill">',
288
-                        '<span class="blue pill">',
289
-                        '</span>'
290
-                    ); ?>
283
+						esc_html__(
284
+							'The Message "Queued For Resending" status color has changed from %1$sYellow%3$s to %2$sBlue%3$s',
285
+							'event_espresso'
286
+						),
287
+						'<span class="yellow pill">',
288
+						'<span class="blue pill">',
289
+						'</span>'
290
+					); ?>
291 291
                 </li>
292 292
                 <li class="ee-status-message">
293 293
                     <?php printf(
294
-                        esc_html__(
295
-                            'The Message "Messenger Is Executing" status color has changed from %1$sPink%3$s to %2$sGreen%3$s',
296
-                            'event_espresso'
297
-                        ),
298
-                        '<span class="pink pill">',
299
-                        '<span class="green pill">',
300
-                        '</span>'
301
-                    ); ?>
294
+						esc_html__(
295
+							'The Message "Messenger Is Executing" status color has changed from %1$sPink%3$s to %2$sGreen%3$s',
296
+							'event_espresso'
297
+						),
298
+						'<span class="pink pill">',
299
+						'<span class="green pill">',
300
+						'</span>'
301
+					); ?>
302 302
                 </li>
303 303
                 <li class="ee-status-message">
304 304
                     <?php printf(
305
-                        esc_html__(
306
-                            'The Message "Failed" status color has changed from %1$sRed%3$s to %2$sPink%3$s',
307
-                            'event_espresso'
308
-                        ),
309
-                        '<span class="red pill">',
310
-                        '<span class="pink pill">',
311
-                        '</span>'
312
-                    ); ?>
305
+						esc_html__(
306
+							'The Message "Failed" status color has changed from %1$sRed%3$s to %2$sPink%3$s',
307
+							'event_espresso'
308
+						),
309
+						'<span class="red pill">',
310
+						'<span class="pink pill">',
311
+						'</span>'
312
+					); ?>
313 313
                 </li>
314 314
                 <li class="ee-status-message">
315 315
                     <?php printf(
316
-                        esc_html__(
317
-                            'The Message "Debug only" status color has changed from %1$sYellow%3$s to %2$sRed%3$s',
318
-                            'event_espresso'
319
-                        ),
320
-                        '<span class="yellow pill">',
321
-                        '<span class="red pill">',
322
-                        '</span>'
323
-                    ); ?>
316
+						esc_html__(
317
+							'The Message "Debug only" status color has changed from %1$sYellow%3$s to %2$sRed%3$s',
318
+							'event_espresso'
319
+						),
320
+						'<span class="yellow pill">',
321
+						'<span class="red pill">',
322
+						'</span>'
323
+					); ?>
324 324
                 </li>
325 325
             </ul>
326 326
             <p>
327 327
                 <?php esc_html_e(
328
-                    'Please accept our sincere apologies for any inconvenience this might cause.',
329
-                    'event_espresso'
330
-                ); ?>
328
+					'Please accept our sincere apologies for any inconvenience this might cause.',
329
+					'event_espresso'
330
+				); ?>
331 331
             </p>
332 332
             <p class="ee-dismiss-notice-pg">
333 333
                 <a href="javascript:void(0);" onclick="dismissStatusNotice();" class="ee-dismiss-notice-link">
334 334
                     <span class="pill pink"><?php
335
-                        esc_html_e('don\'t show this notice again please', 'event_espresso');
336
-                    ?></span>
335
+						esc_html_e('don\'t show this notice again please', 'event_espresso');
336
+					?></span>
337 337
                 </a>
338 338
             </p>
339 339
         </div>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_legend.template.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@  discard block
 block discarded – undo
8 8
 <div class="ee-list-table-legend-container">
9 9
     <h3><?php _e('Legend', 'event_espresso'); ?></h3>
10 10
     <?php
11
-    if (isset($status_change_notice)) {
12
-        echo $status_change_notice;
13
-    }
14
-    ?>
11
+	if (isset($status_change_notice)) {
12
+		echo $status_change_notice;
13
+	}
14
+	?>
15 15
     <dl class="alignleft ee-list-table-legend">
16 16
         <?php foreach ($items as $item => $details) : ?>
17 17
             <?php
18
-            if ($per_col < $count) : ?>
18
+			if ($per_col < $count) : ?>
19 19
     </dl>
20 20
     <dl class="alignleft ee-list-table-legend">
21 21
                 <?php $count = 1;
22
-            endif; ?>
22
+			endif; ?>
23 23
         <dt id="ee-legend-item-<?php echo $item; ?>">
24 24
             <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?>
25 25
             <span class="ee-legend-item-wrap">
26 26
             <?php
27
-            if (strpos($details['class'], '<span') !== false) {
28
-                echo $class;
29
-            } else { ?>
27
+			if (strpos($details['class'], '<span') !== false) {
28
+				echo $class;
29
+			} else { ?>
30 30
                 <span class="<?php echo $class; ?>">
31 31
                     <?php if (! empty($details['icon'])) : ?>
32 32
                         <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon"
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             <span class="ee-legend-description"><?php echo $details['desc']; ?></span>
39 39
         </dt>
40 40
             <?php $count++;
41
-        endforeach; ?>
41
+		endforeach; ?>
42 42
     </dl>
43 43
     <div style="clear:both"></div>
44 44
 </div>
Please login to merge, or discard this patch.
core/services/database/WordPressOption.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -15,134 +15,134 @@
 block discarded – undo
15 15
  */
16 16
 abstract class WordPressOption
17 17
 {
18
-    const NOT_SET_YET = 'wordpress-option-value-not-yet-set';
19
-
20
-    /**
21
-     * WordPress makes it difficult to determine if an option was successfully saved or not
22
-     * which is sometimes really important to know if the information you are saving is critical.
23
-     * The following options allow us to have a better chance of knowing when an update actually failed
24
-     * or when it just didn't update because the value hasn't changed, but everything is safe.
25
-     */
26
-    const UPDATE_SUCCESS = 1;
27
-
28
-    const UPDATE_NONE    = 0;
29
-
30
-    const UPDATE_ERROR   = -1;
31
-
32
-    /**
33
-     * @var boolean
34
-     */
35
-    private $autoload;
36
-
37
-    /**
38
-     * @var mixed
39
-     */
40
-    private $default_value;
41
-
42
-    /**
43
-     * @var string
44
-     */
45
-    private $option_name;
46
-
47
-    /**
48
-     * @var mixed
49
-     */
50
-    private $value = WordPressOption::NOT_SET_YET;
51
-
52
-
53
-    /**
54
-     * WordPressOption constructor.
55
-     *
56
-     * @param bool   $autoload
57
-     * @param mixed  $default_value
58
-     * @param string $option_name
59
-     */
60
-    public function __construct(string $option_name, $default_value, bool $autoload = false)
61
-    {
62
-        $this->setAutoload($autoload);
63
-        $this->setDefaultValue($default_value);
64
-        $this->setOptionName($option_name);
65
-    }
66
-
67
-
68
-    /**
69
-     * @param bool|string $autoload
70
-     */
71
-    public function setAutoload($autoload): void
72
-    {
73
-        $this->autoload = filter_var($autoload, FILTER_VALIDATE_BOOLEAN);
74
-    }
75
-
76
-
77
-    /**
78
-     * @param mixed $default_value
79
-     */
80
-    public function setDefaultValue($default_value): void
81
-    {
82
-        $this->default_value = $default_value;
83
-    }
84
-
85
-
86
-    /**
87
-     * @param string $option_name
88
-     */
89
-    public function setOptionName(string $option_name): void
90
-    {
91
-        $this->option_name = sanitize_key($option_name);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getOptionName(): string
99
-    {
100
-        return $this->option_name;
101
-    }
102
-
103
-
104
-    /**
105
-     * @return false|mixed|void
106
-     */
107
-    public function loadOption()
108
-    {
109
-        if ($this->value === WordPressOption::NOT_SET_YET) {
110
-            $this->value = get_option($this->option_name, $this->default_value);
111
-        }
112
-        return $this->value;
113
-    }
114
-
115
-
116
-    /**
117
-     * @param $value
118
-     * @return int
119
-     */
120
-    public function updateOption($value): int
121
-    {
122
-        // don't update if value has not changed since last update
123
-        if ($value === $this->value) {
124
-            return WordPressOption::UPDATE_NONE;
125
-        }
126
-        // because the options for updating differ when adding an option for the first time
127
-        // we use the WordPressOption::NOT_SET_YET to determine if things already exist in the db
128
-        if (get_option($this->option_name, WordPressOption::NOT_SET_YET) === WordPressOption::NOT_SET_YET) {
129
-            $updated = add_option($this->option_name, $value, '', $this->autoload());
130
-        } else {
131
-            $updated = update_option($this->option_name, $value);
132
-        }
133
-        if ($updated) {
134
-            $this->value = $value;
135
-            return WordPressOption::UPDATE_SUCCESS;
136
-        }
137
-        return WordPressOption::UPDATE_ERROR;
138
-    }
139
-
140
-
141
-    /**
142
-     * @return string
143
-     */
144
-    private function autoload(): string
145
-    {
146
-        return $this->autoload ? 'yes' : 'no';
147
-    }
18
+	const NOT_SET_YET = 'wordpress-option-value-not-yet-set';
19
+
20
+	/**
21
+	 * WordPress makes it difficult to determine if an option was successfully saved or not
22
+	 * which is sometimes really important to know if the information you are saving is critical.
23
+	 * The following options allow us to have a better chance of knowing when an update actually failed
24
+	 * or when it just didn't update because the value hasn't changed, but everything is safe.
25
+	 */
26
+	const UPDATE_SUCCESS = 1;
27
+
28
+	const UPDATE_NONE    = 0;
29
+
30
+	const UPDATE_ERROR   = -1;
31
+
32
+	/**
33
+	 * @var boolean
34
+	 */
35
+	private $autoload;
36
+
37
+	/**
38
+	 * @var mixed
39
+	 */
40
+	private $default_value;
41
+
42
+	/**
43
+	 * @var string
44
+	 */
45
+	private $option_name;
46
+
47
+	/**
48
+	 * @var mixed
49
+	 */
50
+	private $value = WordPressOption::NOT_SET_YET;
51
+
52
+
53
+	/**
54
+	 * WordPressOption constructor.
55
+	 *
56
+	 * @param bool   $autoload
57
+	 * @param mixed  $default_value
58
+	 * @param string $option_name
59
+	 */
60
+	public function __construct(string $option_name, $default_value, bool $autoload = false)
61
+	{
62
+		$this->setAutoload($autoload);
63
+		$this->setDefaultValue($default_value);
64
+		$this->setOptionName($option_name);
65
+	}
66
+
67
+
68
+	/**
69
+	 * @param bool|string $autoload
70
+	 */
71
+	public function setAutoload($autoload): void
72
+	{
73
+		$this->autoload = filter_var($autoload, FILTER_VALIDATE_BOOLEAN);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @param mixed $default_value
79
+	 */
80
+	public function setDefaultValue($default_value): void
81
+	{
82
+		$this->default_value = $default_value;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param string $option_name
88
+	 */
89
+	public function setOptionName(string $option_name): void
90
+	{
91
+		$this->option_name = sanitize_key($option_name);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getOptionName(): string
99
+	{
100
+		return $this->option_name;
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return false|mixed|void
106
+	 */
107
+	public function loadOption()
108
+	{
109
+		if ($this->value === WordPressOption::NOT_SET_YET) {
110
+			$this->value = get_option($this->option_name, $this->default_value);
111
+		}
112
+		return $this->value;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param $value
118
+	 * @return int
119
+	 */
120
+	public function updateOption($value): int
121
+	{
122
+		// don't update if value has not changed since last update
123
+		if ($value === $this->value) {
124
+			return WordPressOption::UPDATE_NONE;
125
+		}
126
+		// because the options for updating differ when adding an option for the first time
127
+		// we use the WordPressOption::NOT_SET_YET to determine if things already exist in the db
128
+		if (get_option($this->option_name, WordPressOption::NOT_SET_YET) === WordPressOption::NOT_SET_YET) {
129
+			$updated = add_option($this->option_name, $value, '', $this->autoload());
130
+		} else {
131
+			$updated = update_option($this->option_name, $value);
132
+		}
133
+		if ($updated) {
134
+			$this->value = $value;
135
+			return WordPressOption::UPDATE_SUCCESS;
136
+		}
137
+		return WordPressOption::UPDATE_ERROR;
138
+	}
139
+
140
+
141
+	/**
142
+	 * @return string
143
+	 */
144
+	private function autoload(): string
145
+	{
146
+		return $this->autoload ? 'yes' : 'no';
147
+	}
148 148
 }
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 2 patches
Indentation   +2146 added lines, -2146 removed lines patch added patch discarded remove patch
@@ -15,2208 +15,2208 @@
 block discarded – undo
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17 17
 
18
-    /**
19
-     * This property is just used to hold the status of whether an event is currently being
20
-     * created (true) or edited (false)
21
-     *
22
-     * @access protected
23
-     * @var bool
24
-     */
25
-    protected $_is_creating_event;
18
+	/**
19
+	 * This property is just used to hold the status of whether an event is currently being
20
+	 * created (true) or edited (false)
21
+	 *
22
+	 * @access protected
23
+	 * @var bool
24
+	 */
25
+	protected $_is_creating_event;
26 26
 
27
-    /**
28
-     * Used to contain the format strings for date and time that will be used for php date and
29
-     * time.
30
-     * Is set in the _set_hooks_properties() method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_date_format_strings;
27
+	/**
28
+	 * Used to contain the format strings for date and time that will be used for php date and
29
+	 * time.
30
+	 * Is set in the _set_hooks_properties() method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_date_format_strings;
35 35
 
36
-    /**
37
-     * @var string $_date_time_format
38
-     */
39
-    protected $_date_time_format;
36
+	/**
37
+	 * @var string $_date_time_format
38
+	 */
39
+	protected $_date_time_format;
40 40
 
41 41
 
42
-    /**
43
-     * @throws InvalidArgumentException
44
-     * @throws InvalidInterfaceException
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    protected function _set_hooks_properties()
48
-    {
49
-        $this->_name = 'pricing';
50
-        // capability check
51
-        if (EE_Registry::instance()->CFG->admin->useAdvancedEditor() ||
52
-            ! EE_Registry::instance()->CAP->current_user_can(
53
-                'ee_read_default_prices',
54
-                'advanced_ticket_datetime_metabox'
55
-            )
56
-        ) {
57
-            return;
58
-        }
59
-        $this->_setup_metaboxes();
60
-        $this->_set_date_time_formats();
61
-        $this->_validate_format_strings();
62
-        $this->_set_scripts_styles();
63
-        // commented out temporarily until logic is implemented in callback
64
-        // add_action(
65
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
-        //     array($this, 'autosave_handling')
67
-        // );
68
-        add_filter(
69
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
-            array($this, 'caf_updates')
71
-        );
72
-    }
42
+	/**
43
+	 * @throws InvalidArgumentException
44
+	 * @throws InvalidInterfaceException
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	protected function _set_hooks_properties()
48
+	{
49
+		$this->_name = 'pricing';
50
+		// capability check
51
+		if (EE_Registry::instance()->CFG->admin->useAdvancedEditor() ||
52
+			! EE_Registry::instance()->CAP->current_user_can(
53
+				'ee_read_default_prices',
54
+				'advanced_ticket_datetime_metabox'
55
+			)
56
+		) {
57
+			return;
58
+		}
59
+		$this->_setup_metaboxes();
60
+		$this->_set_date_time_formats();
61
+		$this->_validate_format_strings();
62
+		$this->_set_scripts_styles();
63
+		// commented out temporarily until logic is implemented in callback
64
+		// add_action(
65
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
+		//     array($this, 'autosave_handling')
67
+		// );
68
+		add_filter(
69
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
+			array($this, 'caf_updates')
71
+		);
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function _setup_metaboxes()
79
-    {
80
-        // if we were going to add our own metaboxes we'd use the below.
81
-        $this->_metaboxes = array(
82
-            0 => array(
83
-                'page_route' => array('edit', 'create_new'),
84
-                'func'       => 'pricing_metabox',
85
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
-                'priority'   => 'high',
87
-                'context'    => 'normal',
88
-            ),
89
-        );
90
-        $this->_remove_metaboxes = array(
91
-            0 => array(
92
-                'page_route' => array('edit', 'create_new'),
93
-                'id'         => 'espresso_event_editor_tickets',
94
-                'context'    => 'normal',
95
-            ),
96
-        );
97
-    }
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function _setup_metaboxes()
79
+	{
80
+		// if we were going to add our own metaboxes we'd use the below.
81
+		$this->_metaboxes = array(
82
+			0 => array(
83
+				'page_route' => array('edit', 'create_new'),
84
+				'func'       => 'pricing_metabox',
85
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
+				'priority'   => 'high',
87
+				'context'    => 'normal',
88
+			),
89
+		);
90
+		$this->_remove_metaboxes = array(
91
+			0 => array(
92
+				'page_route' => array('edit', 'create_new'),
93
+				'id'         => 'espresso_event_editor_tickets',
94
+				'context'    => 'normal',
95
+			),
96
+		);
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * @return void
102
-     */
103
-    protected function _set_date_time_formats()
104
-    {
105
-        /**
106
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
-         *
110
-         * @since 4.6.7
111
-         * @var array  Expected an array returned with 'date' and 'time' keys.
112
-         */
113
-        $this->_date_format_strings = apply_filters(
114
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
-            array(
116
-                'date' => 'Y-m-d',
117
-                'time' => 'h:i a',
118
-            )
119
-        );
120
-        // validate
121
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
-            ? $this->_date_format_strings['date']
123
-            : null;
124
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
-            ? $this->_date_format_strings['time']
126
-            : null;
127
-        $this->_date_time_format = $this->_date_format_strings['date']
128
-                                   . ' '
129
-                                   . $this->_date_format_strings['time'];
130
-    }
100
+	/**
101
+	 * @return void
102
+	 */
103
+	protected function _set_date_time_formats()
104
+	{
105
+		/**
106
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
+		 *
110
+		 * @since 4.6.7
111
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
112
+		 */
113
+		$this->_date_format_strings = apply_filters(
114
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
+			array(
116
+				'date' => 'Y-m-d',
117
+				'time' => 'h:i a',
118
+			)
119
+		);
120
+		// validate
121
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
+			? $this->_date_format_strings['date']
123
+			: null;
124
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
+			? $this->_date_format_strings['time']
126
+			: null;
127
+		$this->_date_time_format = $this->_date_format_strings['date']
128
+								   . ' '
129
+								   . $this->_date_format_strings['time'];
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * @return void
135
-     */
136
-    protected function _validate_format_strings()
137
-    {
138
-        // validate format strings
139
-        $format_validation = EEH_DTT_Helper::validate_format_string(
140
-            $this->_date_time_format
141
-        );
142
-        if (is_array($format_validation)) {
143
-            $msg = '<p>';
144
-            $msg .= sprintf(
145
-                esc_html__(
146
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
-                    'event_espresso'
148
-                ),
149
-                $this->_date_time_format
150
-            );
151
-            $msg .= '</p><ul>';
152
-            foreach ($format_validation as $error) {
153
-                $msg .= '<li>' . $error . '</li>';
154
-            }
155
-            $msg .= '</ul><p>';
156
-            $msg .= sprintf(
157
-                esc_html__(
158
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
-                    'event_espresso'
160
-                ),
161
-                '<span style="color:#D54E21;">',
162
-                '</span>'
163
-            );
164
-            $msg .= '</p>';
165
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
-            $this->_date_format_strings = array(
167
-                'date' => 'Y-m-d',
168
-                'time' => 'h:i a',
169
-            );
170
-        }
171
-    }
133
+	/**
134
+	 * @return void
135
+	 */
136
+	protected function _validate_format_strings()
137
+	{
138
+		// validate format strings
139
+		$format_validation = EEH_DTT_Helper::validate_format_string(
140
+			$this->_date_time_format
141
+		);
142
+		if (is_array($format_validation)) {
143
+			$msg = '<p>';
144
+			$msg .= sprintf(
145
+				esc_html__(
146
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
+					'event_espresso'
148
+				),
149
+				$this->_date_time_format
150
+			);
151
+			$msg .= '</p><ul>';
152
+			foreach ($format_validation as $error) {
153
+				$msg .= '<li>' . $error . '</li>';
154
+			}
155
+			$msg .= '</ul><p>';
156
+			$msg .= sprintf(
157
+				esc_html__(
158
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
+					'event_espresso'
160
+				),
161
+				'<span style="color:#D54E21;">',
162
+				'</span>'
163
+			);
164
+			$msg .= '</p>';
165
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
+			$this->_date_format_strings = array(
167
+				'date' => 'Y-m-d',
168
+				'time' => 'h:i a',
169
+			);
170
+		}
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * @return void
176
-     */
177
-    protected function _set_scripts_styles()
178
-    {
179
-        $this->_scripts_styles = array(
180
-            'registers'   => array(
181
-                'ee-tickets-datetimes-css' => array(
182
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
-                    'type' => 'css',
184
-                ),
185
-                'ee-dtt-ticket-metabox'    => array(
186
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
-                ),
189
-            ),
190
-            'deregisters' => array(
191
-                'event-editor-css'       => array('type' => 'css'),
192
-                'event-datetime-metabox' => array('type' => 'js'),
193
-            ),
194
-            'enqueues'    => array(
195
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
-            ),
198
-            'localize'    => array(
199
-                'ee-dtt-ticket-metabox' => array(
200
-                    'DTT_TRASH_BLOCK'       => array(
201
-                        'main_warning'            => esc_html__(
202
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
-                            'event_espresso'
204
-                        ),
205
-                        'after_warning'           => esc_html__(
206
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
-                            'event_espresso'
208
-                        ),
209
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
211
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
213
-                        'single_warning_from_tkt' => esc_html__(
214
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
-                            'event_espresso'
216
-                        ),
217
-                        'single_warning_from_dtt' => esc_html__(
218
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
-                            'event_espresso'
220
-                        ),
221
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
-                    ),
224
-                    'DTT_ERROR_MSG'         => array(
225
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
227
-                                            . '<button class="button-secondary ee-modal-cancel">'
228
-                                            . esc_html__('Dismiss', 'event_espresso')
229
-                                            . '</button></div>',
230
-                    ),
231
-                    'DTT_OVERSELL_WARNING'  => array(
232
-                        'datetime_ticket' => esc_html__(
233
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
-                            'event_espresso'
235
-                        ),
236
-                        'ticket_datetime' => esc_html__(
237
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
-                            'event_espresso'
239
-                        ),
240
-                    ),
241
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
-                        $this->_date_format_strings['date'],
243
-                        $this->_date_format_strings['time']
244
-                    ),
245
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
-                ),
247
-            ),
248
-        );
249
-    }
174
+	/**
175
+	 * @return void
176
+	 */
177
+	protected function _set_scripts_styles()
178
+	{
179
+		$this->_scripts_styles = array(
180
+			'registers'   => array(
181
+				'ee-tickets-datetimes-css' => array(
182
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
+					'type' => 'css',
184
+				),
185
+				'ee-dtt-ticket-metabox'    => array(
186
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
+				),
189
+			),
190
+			'deregisters' => array(
191
+				'event-editor-css'       => array('type' => 'css'),
192
+				'event-datetime-metabox' => array('type' => 'js'),
193
+			),
194
+			'enqueues'    => array(
195
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
+			),
198
+			'localize'    => array(
199
+				'ee-dtt-ticket-metabox' => array(
200
+					'DTT_TRASH_BLOCK'       => array(
201
+						'main_warning'            => esc_html__(
202
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
+							'event_espresso'
204
+						),
205
+						'after_warning'           => esc_html__(
206
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
+							'event_espresso'
208
+						),
209
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
211
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
+													 . esc_html__('Close', 'event_espresso') . '</button>',
213
+						'single_warning_from_tkt' => esc_html__(
214
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
+							'event_espresso'
216
+						),
217
+						'single_warning_from_dtt' => esc_html__(
218
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
+							'event_espresso'
220
+						),
221
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
+					),
224
+					'DTT_ERROR_MSG'         => array(
225
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
+						'dismiss_button' => '<div class="save-cancel-button-container">'
227
+											. '<button class="button-secondary ee-modal-cancel">'
228
+											. esc_html__('Dismiss', 'event_espresso')
229
+											. '</button></div>',
230
+					),
231
+					'DTT_OVERSELL_WARNING'  => array(
232
+						'datetime_ticket' => esc_html__(
233
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
+							'event_espresso'
235
+						),
236
+						'ticket_datetime' => esc_html__(
237
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
+							'event_espresso'
239
+						),
240
+					),
241
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
+						$this->_date_format_strings['date'],
243
+						$this->_date_format_strings['time']
244
+					),
245
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
+				),
247
+			),
248
+		);
249
+	}
250 250
 
251 251
 
252
-    /**
253
-     * @param array $update_callbacks
254
-     * @return array
255
-     */
256
-    public function caf_updates(array $update_callbacks)
257
-    {
258
-        foreach ($update_callbacks as $key => $callback) {
259
-            if ($callback[1] === '_default_tickets_update') {
260
-                unset($update_callbacks[ $key ]);
261
-            }
262
-        }
263
-        $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
-        return $update_callbacks;
265
-    }
252
+	/**
253
+	 * @param array $update_callbacks
254
+	 * @return array
255
+	 */
256
+	public function caf_updates(array $update_callbacks)
257
+	{
258
+		foreach ($update_callbacks as $key => $callback) {
259
+			if ($callback[1] === '_default_tickets_update') {
260
+				unset($update_callbacks[ $key ]);
261
+			}
262
+		}
263
+		$update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
+		return $update_callbacks;
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
-     *
271
-     * @param  EE_Event $event The Event object we're attaching data to
272
-     * @param  array    $data  The request data from the form
273
-     * @throws ReflectionException
274
-     * @throws Exception
275
-     * @throws InvalidInterfaceException
276
-     * @throws InvalidDataTypeException
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     */
280
-    public function datetime_and_tickets_caf_update($event, $data)
281
-    {
282
-        // first we need to start with datetimes cause they are the "root" items attached to events.
283
-        $saved_datetimes = $this->_update_datetimes($event, $data);
284
-        // next tackle the tickets (and prices?)
285
-        $this->_update_tickets($event, $saved_datetimes, $data);
286
-    }
268
+	/**
269
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
+	 *
271
+	 * @param  EE_Event $event The Event object we're attaching data to
272
+	 * @param  array    $data  The request data from the form
273
+	 * @throws ReflectionException
274
+	 * @throws Exception
275
+	 * @throws InvalidInterfaceException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 */
280
+	public function datetime_and_tickets_caf_update($event, $data)
281
+	{
282
+		// first we need to start with datetimes cause they are the "root" items attached to events.
283
+		$saved_datetimes = $this->_update_datetimes($event, $data);
284
+		// next tackle the tickets (and prices?)
285
+		$this->_update_tickets($event, $saved_datetimes, $data);
286
+	}
287 287
 
288 288
 
289
-    /**
290
-     * update event_datetimes
291
-     *
292
-     * @param  EE_Event $event Event being updated
293
-     * @param  array    $data  the request data from the form
294
-     * @return EE_Datetime[]
295
-     * @throws Exception
296
-     * @throws ReflectionException
297
-     * @throws InvalidInterfaceException
298
-     * @throws InvalidDataTypeException
299
-     * @throws InvalidArgumentException
300
-     * @throws EE_Error
301
-     */
302
-    protected function _update_datetimes($event, $data)
303
-    {
304
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
-        $saved_dtt_ids = array();
306
-        $saved_dtt_objs = array();
307
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
-            throw new InvalidArgumentException(
309
-                esc_html__(
310
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
-                    'event_espresso'
312
-                )
313
-            );
314
-        }
315
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
-            // trim all values to ensure any excess whitespace is removed.
317
-            $datetime_data = array_map(
318
-                function ($datetime_data) {
319
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
-                },
321
-                $datetime_data
322
-            );
323
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
-                                            && ! empty($datetime_data['DTT_EVT_end'])
325
-                ? $datetime_data['DTT_EVT_end']
326
-                : $datetime_data['DTT_EVT_start'];
327
-            $datetime_values = array(
328
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
-                    ? $datetime_data['DTT_ID']
330
-                    : null,
331
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
-                    ? $datetime_data['DTT_name']
333
-                    : '',
334
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
335
-                    ? $datetime_data['DTT_description']
336
-                    : '',
337
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
-                    ? EE_INF
341
-                    : $datetime_data['DTT_reg_limit'],
342
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
-                    ? $row
344
-                    : $datetime_data['DTT_order'],
345
-            );
346
-            // if we have an id then let's get existing object first and then set the new values.
347
-            // Otherwise we instantiate a new object for save.
348
-            if (! empty($datetime_data['DTT_ID'])) {
349
-                $datetime = EE_Registry::instance()
350
-                                       ->load_model('Datetime', array($timezone))
351
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
352
-                // set date and time format according to what is set in this class.
353
-                $datetime->set_date_format($this->_date_format_strings['date']);
354
-                $datetime->set_time_format($this->_date_format_strings['time']);
355
-                foreach ($datetime_values as $field => $value) {
356
-                    $datetime->set($field, $value);
357
-                }
358
-                // make sure the $dtt_id here is saved just in case
359
-                // after the add_relation_to() the autosave replaces it.
360
-                // We need to do this so we dont' TRASH the parent DTT.
361
-                // (save the ID for both key and value to avoid duplications)
362
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
-            } else {
364
-                $datetime = EE_Registry::instance()->load_class(
365
-                    'Datetime',
366
-                    array(
367
-                        $datetime_values,
368
-                        $timezone,
369
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
-                    ),
371
-                    false,
372
-                    false
373
-                );
374
-                foreach ($datetime_values as $field => $value) {
375
-                    $datetime->set($field, $value);
376
-                }
377
-            }
378
-            $datetime->save();
379
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
380
-            // before going any further make sure our dates are setup correctly
381
-            // so that the end date is always equal or greater than the start date.
382
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
383
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
384
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
385
-                $datetime->save();
386
-            }
387
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
388
-            // because it is possible there was a new one created for the autosave.
389
-            // (save the ID for both key and value to avoid duplications)
390
-            $DTT_ID = $datetime->ID();
391
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
392
-            $saved_dtt_objs[ $row ] = $datetime;
393
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
394
-        }
395
-        $event->save();
396
-        // now we need to REMOVE any datetimes that got deleted.
397
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
398
-        // So its safe to permanently delete at this point.
399
-        $old_datetimes = explode(',', $data['datetime_IDs']);
400
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
401
-        if (is_array($old_datetimes)) {
402
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
403
-            foreach ($datetimes_to_delete as $id) {
404
-                $id = absint($id);
405
-                if (empty($id)) {
406
-                    continue;
407
-                }
408
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
409
-                // remove tkt relationships.
410
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
411
-                foreach ($related_tickets as $tkt) {
412
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
413
-                }
414
-                $event->_remove_relation_to($id, 'Datetime');
415
-                $dtt_to_remove->refresh_cache_of_related_objects();
416
-            }
417
-        }
418
-        return $saved_dtt_objs;
419
-    }
289
+	/**
290
+	 * update event_datetimes
291
+	 *
292
+	 * @param  EE_Event $event Event being updated
293
+	 * @param  array    $data  the request data from the form
294
+	 * @return EE_Datetime[]
295
+	 * @throws Exception
296
+	 * @throws ReflectionException
297
+	 * @throws InvalidInterfaceException
298
+	 * @throws InvalidDataTypeException
299
+	 * @throws InvalidArgumentException
300
+	 * @throws EE_Error
301
+	 */
302
+	protected function _update_datetimes($event, $data)
303
+	{
304
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
+		$saved_dtt_ids = array();
306
+		$saved_dtt_objs = array();
307
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
+			throw new InvalidArgumentException(
309
+				esc_html__(
310
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
+					'event_espresso'
312
+				)
313
+			);
314
+		}
315
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
+			// trim all values to ensure any excess whitespace is removed.
317
+			$datetime_data = array_map(
318
+				function ($datetime_data) {
319
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
+				},
321
+				$datetime_data
322
+			);
323
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
+											&& ! empty($datetime_data['DTT_EVT_end'])
325
+				? $datetime_data['DTT_EVT_end']
326
+				: $datetime_data['DTT_EVT_start'];
327
+			$datetime_values = array(
328
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
+					? $datetime_data['DTT_ID']
330
+					: null,
331
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
+					? $datetime_data['DTT_name']
333
+					: '',
334
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
335
+					? $datetime_data['DTT_description']
336
+					: '',
337
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
+					? EE_INF
341
+					: $datetime_data['DTT_reg_limit'],
342
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
+					? $row
344
+					: $datetime_data['DTT_order'],
345
+			);
346
+			// if we have an id then let's get existing object first and then set the new values.
347
+			// Otherwise we instantiate a new object for save.
348
+			if (! empty($datetime_data['DTT_ID'])) {
349
+				$datetime = EE_Registry::instance()
350
+									   ->load_model('Datetime', array($timezone))
351
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
352
+				// set date and time format according to what is set in this class.
353
+				$datetime->set_date_format($this->_date_format_strings['date']);
354
+				$datetime->set_time_format($this->_date_format_strings['time']);
355
+				foreach ($datetime_values as $field => $value) {
356
+					$datetime->set($field, $value);
357
+				}
358
+				// make sure the $dtt_id here is saved just in case
359
+				// after the add_relation_to() the autosave replaces it.
360
+				// We need to do this so we dont' TRASH the parent DTT.
361
+				// (save the ID for both key and value to avoid duplications)
362
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
+			} else {
364
+				$datetime = EE_Registry::instance()->load_class(
365
+					'Datetime',
366
+					array(
367
+						$datetime_values,
368
+						$timezone,
369
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
+					),
371
+					false,
372
+					false
373
+				);
374
+				foreach ($datetime_values as $field => $value) {
375
+					$datetime->set($field, $value);
376
+				}
377
+			}
378
+			$datetime->save();
379
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
380
+			// before going any further make sure our dates are setup correctly
381
+			// so that the end date is always equal or greater than the start date.
382
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
383
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
384
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
385
+				$datetime->save();
386
+			}
387
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
388
+			// because it is possible there was a new one created for the autosave.
389
+			// (save the ID for both key and value to avoid duplications)
390
+			$DTT_ID = $datetime->ID();
391
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
392
+			$saved_dtt_objs[ $row ] = $datetime;
393
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
394
+		}
395
+		$event->save();
396
+		// now we need to REMOVE any datetimes that got deleted.
397
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
398
+		// So its safe to permanently delete at this point.
399
+		$old_datetimes = explode(',', $data['datetime_IDs']);
400
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
401
+		if (is_array($old_datetimes)) {
402
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
403
+			foreach ($datetimes_to_delete as $id) {
404
+				$id = absint($id);
405
+				if (empty($id)) {
406
+					continue;
407
+				}
408
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
409
+				// remove tkt relationships.
410
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
411
+				foreach ($related_tickets as $tkt) {
412
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
413
+				}
414
+				$event->_remove_relation_to($id, 'Datetime');
415
+				$dtt_to_remove->refresh_cache_of_related_objects();
416
+			}
417
+		}
418
+		return $saved_dtt_objs;
419
+	}
420 420
 
421 421
 
422
-    /**
423
-     * update tickets
424
-     *
425
-     * @param  EE_Event      $event           Event object being updated
426
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
427
-     * @param  array         $data            incoming request data
428
-     * @return EE_Ticket[]
429
-     * @throws Exception
430
-     * @throws ReflectionException
431
-     * @throws InvalidInterfaceException
432
-     * @throws InvalidDataTypeException
433
-     * @throws InvalidArgumentException
434
-     * @throws EE_Error
435
-     */
436
-    protected function _update_tickets($event, $saved_datetimes, $data)
437
-    {
438
-        $new_tkt = null;
439
-        $new_default = null;
440
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
441
-        $data = stripslashes_deep($data);
442
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
443
-        $saved_tickets = $datetimes_on_existing = array();
444
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
445
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
446
-            throw new InvalidArgumentException(
447
-                esc_html__(
448
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
449
-                    'event_espresso'
450
-                )
451
-            );
452
-        }
453
-        foreach ($data['edit_tickets'] as $row => $tkt) {
454
-            $update_prices = $create_new_TKT = false;
455
-            // figure out what datetimes were added to the ticket
456
-            // and what datetimes were removed from the ticket in the session.
457
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
458
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
459
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
460
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
461
-            // trim inputs to ensure any excess whitespace is removed.
462
-            $tkt = array_map(
463
-                function ($ticket_data) {
464
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
465
-                },
466
-                $tkt
467
-            );
468
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
469
-            // because we're doing calculations prior to using the models.
470
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
471
-            $ticket_price = isset($tkt['TKT_price'])
472
-                ? round((float) $tkt['TKT_price'], 3)
473
-                : 0;
474
-            // note incoming base price needs converted from localized value.
475
-            $base_price = isset($tkt['TKT_base_price'])
476
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
477
-                : 0;
478
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
479
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
480
-                ? $base_price
481
-                : $ticket_price;
482
-            $base_price_id = isset($tkt['TKT_base_price_ID'])
483
-                ? $tkt['TKT_base_price_ID']
484
-                : 0;
485
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
486
-                ? $data['edit_prices'][ $row ]
487
-                : array();
488
-            $now = null;
489
-            if (empty($tkt['TKT_start_date'])) {
490
-                // lets' use now in the set timezone.
491
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
492
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
493
-            }
494
-            if (empty($tkt['TKT_end_date'])) {
495
-                /**
496
-                 * set the TKT_end_date to the first datetime attached to the ticket.
497
-                 */
498
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
499
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
500
-            }
501
-            $TKT_values = array(
502
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
503
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
504
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
505
-                'TKT_description' => ! empty($tkt['TKT_description'])
506
-                                     && $tkt['TKT_description'] !== esc_html__(
507
-                                         'You can modify this description',
508
-                                         'event_espresso'
509
-                                     )
510
-                    ? $tkt['TKT_description']
511
-                    : '',
512
-                'TKT_start_date'  => $tkt['TKT_start_date'],
513
-                'TKT_end_date'    => $tkt['TKT_end_date'],
514
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
515
-                    ? EE_INF
516
-                    : $tkt['TKT_qty'],
517
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
518
-                    ? EE_INF
519
-                    : $tkt['TKT_uses'],
520
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
521
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
522
-                'TKT_row'         => $row,
523
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
524
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
525
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
526
-                'TKT_price'       => $ticket_price,
527
-            );
528
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
529
-            // which means in turn that the prices will become new prices as well.
530
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
531
-                $TKT_values['TKT_ID'] = 0;
532
-                $TKT_values['TKT_is_default'] = 0;
533
-                $update_prices = true;
534
-            }
535
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
536
-            // we actually do our saves ahead of doing any add_relations to
537
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
538
-            // but DID have it's items modified.
539
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
540
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
541
-            if (absint($TKT_values['TKT_ID'])) {
542
-                $ticket = EE_Registry::instance()
543
-                                     ->load_model('Ticket', array($timezone))
544
-                                     ->get_one_by_ID($tkt['TKT_ID']);
545
-                if ($ticket instanceof EE_Ticket) {
546
-                    $ticket = $this->_update_ticket_datetimes(
547
-                        $ticket,
548
-                        $saved_datetimes,
549
-                        $datetimes_added,
550
-                        $datetimes_removed
551
-                    );
552
-                    // are there any registrations using this ticket ?
553
-                    $tickets_sold = $ticket->count_related(
554
-                        'Registration',
555
-                        array(
556
-                            array(
557
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
558
-                            ),
559
-                        )
560
-                    );
561
-                    // set ticket formats
562
-                    $ticket->set_date_format($this->_date_format_strings['date']);
563
-                    $ticket->set_time_format($this->_date_format_strings['time']);
564
-                    // let's just check the total price for the existing ticket
565
-                    // and determine if it matches the new total price.
566
-                    // if they are different then we create a new ticket (if tickets sold)
567
-                    // if they aren't different then we go ahead and modify existing ticket.
568
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
569
-                    // set new values
570
-                    foreach ($TKT_values as $field => $value) {
571
-                        if ($field === 'TKT_qty') {
572
-                            $ticket->set_qty($value);
573
-                        } else {
574
-                            $ticket->set($field, $value);
575
-                        }
576
-                    }
577
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
578
-                    // Otherwise we have to create a new ticket.
579
-                    if ($create_new_TKT) {
580
-                        $new_tkt = $this->_duplicate_ticket(
581
-                            $ticket,
582
-                            $price_rows,
583
-                            $ticket_price,
584
-                            $base_price,
585
-                            $base_price_id
586
-                        );
587
-                    }
588
-                }
589
-            } else {
590
-                // no TKT_id so a new TKT
591
-                $ticket = EE_Ticket::new_instance(
592
-                    $TKT_values,
593
-                    $timezone,
594
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
595
-                );
596
-                if ($ticket instanceof EE_Ticket) {
597
-                    // make sure ticket has an ID of setting relations won't work
598
-                    $ticket->save();
599
-                    $ticket = $this->_update_ticket_datetimes(
600
-                        $ticket,
601
-                        $saved_datetimes,
602
-                        $datetimes_added,
603
-                        $datetimes_removed
604
-                    );
605
-                    $update_prices = true;
606
-                }
607
-            }
608
-            // make sure any current values have been saved.
609
-            // $ticket->save();
610
-            // before going any further make sure our dates are setup correctly
611
-            // so that the end date is always equal or greater than the start date.
612
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
613
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
614
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
615
-            }
616
-            // let's make sure the base price is handled
617
-            $ticket = ! $create_new_TKT
618
-                ? $this->_add_prices_to_ticket(
619
-                    array(),
620
-                    $ticket,
621
-                    $update_prices,
622
-                    $base_price,
623
-                    $base_price_id
624
-                )
625
-                : $ticket;
626
-            // add/update price_modifiers
627
-            $ticket = ! $create_new_TKT
628
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
629
-                : $ticket;
630
-            // need to make sue that the TKT_price is accurate after saving the prices.
631
-            $ticket->ensure_TKT_Price_correct();
632
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
633
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
634
-                $update_prices = true;
635
-                $new_default = clone $ticket;
636
-                $new_default->set('TKT_ID', 0);
637
-                $new_default->set('TKT_is_default', 1);
638
-                $new_default->set('TKT_row', 1);
639
-                $new_default->set('TKT_price', $ticket_price);
640
-                // remove any dtt relations cause we DON'T want dtt relations attached
641
-                // (note this is just removing the cached relations in the object)
642
-                $new_default->_remove_relations('Datetime');
643
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
644
-                $new_default = $this->_add_prices_to_ticket(
645
-                    $price_rows,
646
-                    $new_default,
647
-                    $update_prices
648
-                );
649
-                // don't forget the base price!
650
-                $new_default = $this->_add_prices_to_ticket(
651
-                    array(),
652
-                    $new_default,
653
-                    $update_prices,
654
-                    $base_price,
655
-                    $base_price_id
656
-                );
657
-                $new_default->save();
658
-                do_action(
659
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
660
-                    $new_default,
661
-                    $row,
662
-                    $ticket,
663
-                    $data
664
-                );
665
-            }
666
-            // DO ALL dtt relationships for both current tickets and any archived tickets
667
-            // for the given dtt that are related to the current ticket.
668
-            // TODO... not sure exactly how we're going to do this considering we don't know
669
-            // what current ticket the archived tickets are related to
670
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
671
-            // let's assign any tickets that have been setup to the saved_tickets tracker
672
-            // save existing TKT
673
-            $ticket->save();
674
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
675
-                // save new TKT
676
-                $new_tkt->save();
677
-                // add new ticket to array
678
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
679
-                do_action(
680
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
681
-                    $new_tkt,
682
-                    $row,
683
-                    $tkt,
684
-                    $data
685
-                );
686
-            } else {
687
-                // add tkt to saved tkts
688
-                $saved_tickets[ $ticket->ID() ] = $ticket;
689
-                do_action(
690
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
691
-                    $ticket,
692
-                    $row,
693
-                    $tkt,
694
-                    $data
695
-                );
696
-            }
697
-        }
698
-        // now we need to handle tickets actually "deleted permanently".
699
-        // There are cases where we'd want this to happen
700
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
701
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
702
-        // No sense in keeping all the related data in the db!
703
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
704
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
705
-        foreach ($tickets_removed as $id) {
706
-            $id = absint($id);
707
-            // get the ticket for this id
708
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
709
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
710
-            if ($tkt_to_remove->get('TKT_is_default')) {
711
-                continue;
712
-            }
713
-            // if this tkt has any registrations attached so then we just ARCHIVE
714
-            // because we don't actually permanently delete these tickets.
715
-            if ($tkt_to_remove->count_related('Registration') > 0) {
716
-                $tkt_to_remove->delete();
717
-                continue;
718
-            }
719
-            // need to get all the related datetimes on this ticket and remove from every single one of them
720
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
721
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
722
-            foreach ($datetimes as $datetime) {
723
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
724
-            }
725
-            // need to do the same for prices (except these prices can also be deleted because again,
726
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
727
-            $tkt_to_remove->delete_related_permanently('Price');
728
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
729
-            // finally let's delete this ticket
730
-            // (which should not be blocked at this point b/c we've removed all our relationships)
731
-            $tkt_to_remove->delete_permanently();
732
-        }
733
-        return $saved_tickets;
734
-    }
422
+	/**
423
+	 * update tickets
424
+	 *
425
+	 * @param  EE_Event      $event           Event object being updated
426
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
427
+	 * @param  array         $data            incoming request data
428
+	 * @return EE_Ticket[]
429
+	 * @throws Exception
430
+	 * @throws ReflectionException
431
+	 * @throws InvalidInterfaceException
432
+	 * @throws InvalidDataTypeException
433
+	 * @throws InvalidArgumentException
434
+	 * @throws EE_Error
435
+	 */
436
+	protected function _update_tickets($event, $saved_datetimes, $data)
437
+	{
438
+		$new_tkt = null;
439
+		$new_default = null;
440
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
441
+		$data = stripslashes_deep($data);
442
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
443
+		$saved_tickets = $datetimes_on_existing = array();
444
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
445
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
446
+			throw new InvalidArgumentException(
447
+				esc_html__(
448
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
449
+					'event_espresso'
450
+				)
451
+			);
452
+		}
453
+		foreach ($data['edit_tickets'] as $row => $tkt) {
454
+			$update_prices = $create_new_TKT = false;
455
+			// figure out what datetimes were added to the ticket
456
+			// and what datetimes were removed from the ticket in the session.
457
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
458
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
459
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
460
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
461
+			// trim inputs to ensure any excess whitespace is removed.
462
+			$tkt = array_map(
463
+				function ($ticket_data) {
464
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
465
+				},
466
+				$tkt
467
+			);
468
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
469
+			// because we're doing calculations prior to using the models.
470
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
471
+			$ticket_price = isset($tkt['TKT_price'])
472
+				? round((float) $tkt['TKT_price'], 3)
473
+				: 0;
474
+			// note incoming base price needs converted from localized value.
475
+			$base_price = isset($tkt['TKT_base_price'])
476
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
477
+				: 0;
478
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
479
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
480
+				? $base_price
481
+				: $ticket_price;
482
+			$base_price_id = isset($tkt['TKT_base_price_ID'])
483
+				? $tkt['TKT_base_price_ID']
484
+				: 0;
485
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
486
+				? $data['edit_prices'][ $row ]
487
+				: array();
488
+			$now = null;
489
+			if (empty($tkt['TKT_start_date'])) {
490
+				// lets' use now in the set timezone.
491
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
492
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
493
+			}
494
+			if (empty($tkt['TKT_end_date'])) {
495
+				/**
496
+				 * set the TKT_end_date to the first datetime attached to the ticket.
497
+				 */
498
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
499
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
500
+			}
501
+			$TKT_values = array(
502
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
503
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
504
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
505
+				'TKT_description' => ! empty($tkt['TKT_description'])
506
+									 && $tkt['TKT_description'] !== esc_html__(
507
+										 'You can modify this description',
508
+										 'event_espresso'
509
+									 )
510
+					? $tkt['TKT_description']
511
+					: '',
512
+				'TKT_start_date'  => $tkt['TKT_start_date'],
513
+				'TKT_end_date'    => $tkt['TKT_end_date'],
514
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
515
+					? EE_INF
516
+					: $tkt['TKT_qty'],
517
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
518
+					? EE_INF
519
+					: $tkt['TKT_uses'],
520
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
521
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
522
+				'TKT_row'         => $row,
523
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
524
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
525
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
526
+				'TKT_price'       => $ticket_price,
527
+			);
528
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
529
+			// which means in turn that the prices will become new prices as well.
530
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
531
+				$TKT_values['TKT_ID'] = 0;
532
+				$TKT_values['TKT_is_default'] = 0;
533
+				$update_prices = true;
534
+			}
535
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
536
+			// we actually do our saves ahead of doing any add_relations to
537
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
538
+			// but DID have it's items modified.
539
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
540
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
541
+			if (absint($TKT_values['TKT_ID'])) {
542
+				$ticket = EE_Registry::instance()
543
+									 ->load_model('Ticket', array($timezone))
544
+									 ->get_one_by_ID($tkt['TKT_ID']);
545
+				if ($ticket instanceof EE_Ticket) {
546
+					$ticket = $this->_update_ticket_datetimes(
547
+						$ticket,
548
+						$saved_datetimes,
549
+						$datetimes_added,
550
+						$datetimes_removed
551
+					);
552
+					// are there any registrations using this ticket ?
553
+					$tickets_sold = $ticket->count_related(
554
+						'Registration',
555
+						array(
556
+							array(
557
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
558
+							),
559
+						)
560
+					);
561
+					// set ticket formats
562
+					$ticket->set_date_format($this->_date_format_strings['date']);
563
+					$ticket->set_time_format($this->_date_format_strings['time']);
564
+					// let's just check the total price for the existing ticket
565
+					// and determine if it matches the new total price.
566
+					// if they are different then we create a new ticket (if tickets sold)
567
+					// if they aren't different then we go ahead and modify existing ticket.
568
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
569
+					// set new values
570
+					foreach ($TKT_values as $field => $value) {
571
+						if ($field === 'TKT_qty') {
572
+							$ticket->set_qty($value);
573
+						} else {
574
+							$ticket->set($field, $value);
575
+						}
576
+					}
577
+					// if $create_new_TKT is false then we can safely update the existing ticket.
578
+					// Otherwise we have to create a new ticket.
579
+					if ($create_new_TKT) {
580
+						$new_tkt = $this->_duplicate_ticket(
581
+							$ticket,
582
+							$price_rows,
583
+							$ticket_price,
584
+							$base_price,
585
+							$base_price_id
586
+						);
587
+					}
588
+				}
589
+			} else {
590
+				// no TKT_id so a new TKT
591
+				$ticket = EE_Ticket::new_instance(
592
+					$TKT_values,
593
+					$timezone,
594
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
595
+				);
596
+				if ($ticket instanceof EE_Ticket) {
597
+					// make sure ticket has an ID of setting relations won't work
598
+					$ticket->save();
599
+					$ticket = $this->_update_ticket_datetimes(
600
+						$ticket,
601
+						$saved_datetimes,
602
+						$datetimes_added,
603
+						$datetimes_removed
604
+					);
605
+					$update_prices = true;
606
+				}
607
+			}
608
+			// make sure any current values have been saved.
609
+			// $ticket->save();
610
+			// before going any further make sure our dates are setup correctly
611
+			// so that the end date is always equal or greater than the start date.
612
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
613
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
614
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
615
+			}
616
+			// let's make sure the base price is handled
617
+			$ticket = ! $create_new_TKT
618
+				? $this->_add_prices_to_ticket(
619
+					array(),
620
+					$ticket,
621
+					$update_prices,
622
+					$base_price,
623
+					$base_price_id
624
+				)
625
+				: $ticket;
626
+			// add/update price_modifiers
627
+			$ticket = ! $create_new_TKT
628
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
629
+				: $ticket;
630
+			// need to make sue that the TKT_price is accurate after saving the prices.
631
+			$ticket->ensure_TKT_Price_correct();
632
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
633
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
634
+				$update_prices = true;
635
+				$new_default = clone $ticket;
636
+				$new_default->set('TKT_ID', 0);
637
+				$new_default->set('TKT_is_default', 1);
638
+				$new_default->set('TKT_row', 1);
639
+				$new_default->set('TKT_price', $ticket_price);
640
+				// remove any dtt relations cause we DON'T want dtt relations attached
641
+				// (note this is just removing the cached relations in the object)
642
+				$new_default->_remove_relations('Datetime');
643
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
644
+				$new_default = $this->_add_prices_to_ticket(
645
+					$price_rows,
646
+					$new_default,
647
+					$update_prices
648
+				);
649
+				// don't forget the base price!
650
+				$new_default = $this->_add_prices_to_ticket(
651
+					array(),
652
+					$new_default,
653
+					$update_prices,
654
+					$base_price,
655
+					$base_price_id
656
+				);
657
+				$new_default->save();
658
+				do_action(
659
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
660
+					$new_default,
661
+					$row,
662
+					$ticket,
663
+					$data
664
+				);
665
+			}
666
+			// DO ALL dtt relationships for both current tickets and any archived tickets
667
+			// for the given dtt that are related to the current ticket.
668
+			// TODO... not sure exactly how we're going to do this considering we don't know
669
+			// what current ticket the archived tickets are related to
670
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
671
+			// let's assign any tickets that have been setup to the saved_tickets tracker
672
+			// save existing TKT
673
+			$ticket->save();
674
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
675
+				// save new TKT
676
+				$new_tkt->save();
677
+				// add new ticket to array
678
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
679
+				do_action(
680
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
681
+					$new_tkt,
682
+					$row,
683
+					$tkt,
684
+					$data
685
+				);
686
+			} else {
687
+				// add tkt to saved tkts
688
+				$saved_tickets[ $ticket->ID() ] = $ticket;
689
+				do_action(
690
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
691
+					$ticket,
692
+					$row,
693
+					$tkt,
694
+					$data
695
+				);
696
+			}
697
+		}
698
+		// now we need to handle tickets actually "deleted permanently".
699
+		// There are cases where we'd want this to happen
700
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
701
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
702
+		// No sense in keeping all the related data in the db!
703
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
704
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
705
+		foreach ($tickets_removed as $id) {
706
+			$id = absint($id);
707
+			// get the ticket for this id
708
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
709
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
710
+			if ($tkt_to_remove->get('TKT_is_default')) {
711
+				continue;
712
+			}
713
+			// if this tkt has any registrations attached so then we just ARCHIVE
714
+			// because we don't actually permanently delete these tickets.
715
+			if ($tkt_to_remove->count_related('Registration') > 0) {
716
+				$tkt_to_remove->delete();
717
+				continue;
718
+			}
719
+			// need to get all the related datetimes on this ticket and remove from every single one of them
720
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
721
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
722
+			foreach ($datetimes as $datetime) {
723
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
724
+			}
725
+			// need to do the same for prices (except these prices can also be deleted because again,
726
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
727
+			$tkt_to_remove->delete_related_permanently('Price');
728
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
729
+			// finally let's delete this ticket
730
+			// (which should not be blocked at this point b/c we've removed all our relationships)
731
+			$tkt_to_remove->delete_permanently();
732
+		}
733
+		return $saved_tickets;
734
+	}
735 735
 
736 736
 
737
-    /**
738
-     * @access  protected
739
-     * @param EE_Ticket      $ticket
740
-     * @param \EE_Datetime[] $saved_datetimes
741
-     * @param \EE_Datetime[] $added_datetimes
742
-     * @param \EE_Datetime[] $removed_datetimes
743
-     * @return EE_Ticket
744
-     * @throws EE_Error
745
-     */
746
-    protected function _update_ticket_datetimes(
747
-        EE_Ticket $ticket,
748
-        $saved_datetimes = array(),
749
-        $added_datetimes = array(),
750
-        $removed_datetimes = array()
751
-    ) {
752
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
753
-        // and removing the ticket from datetimes it got removed from.
754
-        // first let's add datetimes
755
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
756
-            foreach ($added_datetimes as $row_id) {
757
-                $row_id = (int) $row_id;
758
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
759
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
760
-                    // Is this an existing ticket (has an ID) and does it have any sold?
761
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
762
-                    if ($ticket->ID() && $ticket->sold() > 0) {
763
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
764
-                    }
765
-                }
766
-            }
767
-        }
768
-        // then remove datetimes
769
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
770
-            foreach ($removed_datetimes as $row_id) {
771
-                $row_id = (int) $row_id;
772
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
773
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
774
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
775
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
776
-                    // Is this an existing ticket (has an ID) and does it have any sold?
777
-                    // If so, then we need to remove it's sold from the DTT_sold.
778
-                    if ($ticket->ID() && $ticket->sold() > 0) {
779
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
780
-                    }
781
-                }
782
-            }
783
-        }
784
-        // cap ticket qty by datetime reg limits
785
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
786
-        return $ticket;
787
-    }
737
+	/**
738
+	 * @access  protected
739
+	 * @param EE_Ticket      $ticket
740
+	 * @param \EE_Datetime[] $saved_datetimes
741
+	 * @param \EE_Datetime[] $added_datetimes
742
+	 * @param \EE_Datetime[] $removed_datetimes
743
+	 * @return EE_Ticket
744
+	 * @throws EE_Error
745
+	 */
746
+	protected function _update_ticket_datetimes(
747
+		EE_Ticket $ticket,
748
+		$saved_datetimes = array(),
749
+		$added_datetimes = array(),
750
+		$removed_datetimes = array()
751
+	) {
752
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
753
+		// and removing the ticket from datetimes it got removed from.
754
+		// first let's add datetimes
755
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
756
+			foreach ($added_datetimes as $row_id) {
757
+				$row_id = (int) $row_id;
758
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
759
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
760
+					// Is this an existing ticket (has an ID) and does it have any sold?
761
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
762
+					if ($ticket->ID() && $ticket->sold() > 0) {
763
+						$saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
764
+					}
765
+				}
766
+			}
767
+		}
768
+		// then remove datetimes
769
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
770
+			foreach ($removed_datetimes as $row_id) {
771
+				$row_id = (int) $row_id;
772
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
773
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
774
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
775
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
776
+					// Is this an existing ticket (has an ID) and does it have any sold?
777
+					// If so, then we need to remove it's sold from the DTT_sold.
778
+					if ($ticket->ID() && $ticket->sold() > 0) {
779
+						$saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
780
+					}
781
+				}
782
+			}
783
+		}
784
+		// cap ticket qty by datetime reg limits
785
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
786
+		return $ticket;
787
+	}
788 788
 
789 789
 
790
-    /**
791
-     * @access  protected
792
-     * @param EE_Ticket $ticket
793
-     * @param array     $price_rows
794
-     * @param int       $ticket_price
795
-     * @param int       $base_price
796
-     * @param int       $base_price_id
797
-     * @return EE_Ticket
798
-     * @throws ReflectionException
799
-     * @throws InvalidArgumentException
800
-     * @throws InvalidInterfaceException
801
-     * @throws InvalidDataTypeException
802
-     * @throws EE_Error
803
-     */
804
-    protected function _duplicate_ticket(
805
-        EE_Ticket $ticket,
806
-        $price_rows = array(),
807
-        $ticket_price = 0,
808
-        $base_price = 0,
809
-        $base_price_id = 0
810
-    ) {
811
-        // create new ticket that's a copy of the existing
812
-        // except a new id of course (and not archived)
813
-        // AND has the new TKT_price associated with it.
814
-        $new_ticket = clone $ticket;
815
-        $new_ticket->set('TKT_ID', 0);
816
-        $new_ticket->set_deleted(0);
817
-        $new_ticket->set_price($ticket_price);
818
-        $new_ticket->set_sold(0);
819
-        // let's get a new ID for this ticket
820
-        $new_ticket->save();
821
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
822
-        $datetimes_on_existing = $ticket->datetimes();
823
-        $new_ticket = $this->_update_ticket_datetimes(
824
-            $new_ticket,
825
-            $datetimes_on_existing,
826
-            array_keys($datetimes_on_existing)
827
-        );
828
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
829
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
830
-        // available.
831
-        if ($ticket->sold() > 0) {
832
-            $new_qty = $ticket->qty() - $ticket->sold();
833
-            $new_ticket->set_qty($new_qty);
834
-        }
835
-        // now we update the prices just for this ticket
836
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
837
-        // and we update the base price
838
-        $new_ticket = $this->_add_prices_to_ticket(
839
-            array(),
840
-            $new_ticket,
841
-            true,
842
-            $base_price,
843
-            $base_price_id
844
-        );
845
-        return $new_ticket;
846
-    }
790
+	/**
791
+	 * @access  protected
792
+	 * @param EE_Ticket $ticket
793
+	 * @param array     $price_rows
794
+	 * @param int       $ticket_price
795
+	 * @param int       $base_price
796
+	 * @param int       $base_price_id
797
+	 * @return EE_Ticket
798
+	 * @throws ReflectionException
799
+	 * @throws InvalidArgumentException
800
+	 * @throws InvalidInterfaceException
801
+	 * @throws InvalidDataTypeException
802
+	 * @throws EE_Error
803
+	 */
804
+	protected function _duplicate_ticket(
805
+		EE_Ticket $ticket,
806
+		$price_rows = array(),
807
+		$ticket_price = 0,
808
+		$base_price = 0,
809
+		$base_price_id = 0
810
+	) {
811
+		// create new ticket that's a copy of the existing
812
+		// except a new id of course (and not archived)
813
+		// AND has the new TKT_price associated with it.
814
+		$new_ticket = clone $ticket;
815
+		$new_ticket->set('TKT_ID', 0);
816
+		$new_ticket->set_deleted(0);
817
+		$new_ticket->set_price($ticket_price);
818
+		$new_ticket->set_sold(0);
819
+		// let's get a new ID for this ticket
820
+		$new_ticket->save();
821
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
822
+		$datetimes_on_existing = $ticket->datetimes();
823
+		$new_ticket = $this->_update_ticket_datetimes(
824
+			$new_ticket,
825
+			$datetimes_on_existing,
826
+			array_keys($datetimes_on_existing)
827
+		);
828
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
829
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
830
+		// available.
831
+		if ($ticket->sold() > 0) {
832
+			$new_qty = $ticket->qty() - $ticket->sold();
833
+			$new_ticket->set_qty($new_qty);
834
+		}
835
+		// now we update the prices just for this ticket
836
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
837
+		// and we update the base price
838
+		$new_ticket = $this->_add_prices_to_ticket(
839
+			array(),
840
+			$new_ticket,
841
+			true,
842
+			$base_price,
843
+			$base_price_id
844
+		);
845
+		return $new_ticket;
846
+	}
847 847
 
848 848
 
849
-    /**
850
-     * This attaches a list of given prices to a ticket.
851
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
852
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
853
-     * price info and prices are automatically "archived" via the ticket.
854
-     *
855
-     * @access  private
856
-     * @param array     $prices        Array of prices from the form.
857
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
858
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
859
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
860
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
861
-     * @return EE_Ticket
862
-     * @throws ReflectionException
863
-     * @throws InvalidArgumentException
864
-     * @throws InvalidInterfaceException
865
-     * @throws InvalidDataTypeException
866
-     * @throws EE_Error
867
-     */
868
-    protected function _add_prices_to_ticket(
869
-        $prices = array(),
870
-        EE_Ticket $ticket,
871
-        $new_prices = false,
872
-        $base_price = false,
873
-        $base_price_id = false
874
-    ) {
875
-        // let's just get any current prices that may exist on the given ticket
876
-        // so we can remove any prices that got trashed in this session.
877
-        $current_prices_on_ticket = $base_price !== false
878
-            ? $ticket->base_price(true)
879
-            : $ticket->price_modifiers();
880
-        $updated_prices = array();
881
-        // if $base_price ! FALSE then updating a base price.
882
-        if ($base_price !== false) {
883
-            $prices[1] = array(
884
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
885
-                'PRT_ID'     => 1,
886
-                'PRC_amount' => $base_price,
887
-                'PRC_name'   => $ticket->get('TKT_name'),
888
-                'PRC_desc'   => $ticket->get('TKT_description'),
889
-            );
890
-        }
891
-        // possibly need to save tkt
892
-        if (! $ticket->ID()) {
893
-            $ticket->save();
894
-        }
895
-        foreach ($prices as $row => $prc) {
896
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
897
-            if (empty($prt_id)) {
898
-                continue;
899
-            } //prices MUST have a price type id.
900
-            $PRC_values = array(
901
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
902
-                'PRT_ID'         => $prt_id,
903
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
904
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
905
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
906
-                'PRC_is_default' => false,
907
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
908
-                'PRC_order'      => $row,
909
-            );
910
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
911
-                $PRC_values['PRC_ID'] = 0;
912
-                $price = EE_Registry::instance()->load_class(
913
-                    'Price',
914
-                    array($PRC_values),
915
-                    false,
916
-                    false
917
-                );
918
-            } else {
919
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
920
-                // update this price with new values
921
-                foreach ($PRC_values as $field => $value) {
922
-                    $price->set($field, $value);
923
-                }
924
-            }
925
-            $price->save();
926
-            $updated_prices[ $price->ID() ] = $price;
927
-            $ticket->_add_relation_to($price, 'Price');
928
-        }
929
-        // now let's remove any prices that got removed from the ticket
930
-        if (! empty($current_prices_on_ticket)) {
931
-            $current = array_keys($current_prices_on_ticket);
932
-            $updated = array_keys($updated_prices);
933
-            $prices_to_remove = array_diff($current, $updated);
934
-            if (! empty($prices_to_remove)) {
935
-                foreach ($prices_to_remove as $prc_id) {
936
-                    $p = $current_prices_on_ticket[ $prc_id ];
937
-                    $ticket->_remove_relation_to($p, 'Price');
938
-                    // delete permanently the price
939
-                    $p->delete_permanently();
940
-                }
941
-            }
942
-        }
943
-        return $ticket;
944
-    }
849
+	/**
850
+	 * This attaches a list of given prices to a ticket.
851
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
852
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
853
+	 * price info and prices are automatically "archived" via the ticket.
854
+	 *
855
+	 * @access  private
856
+	 * @param array     $prices        Array of prices from the form.
857
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
858
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
859
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
860
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
861
+	 * @return EE_Ticket
862
+	 * @throws ReflectionException
863
+	 * @throws InvalidArgumentException
864
+	 * @throws InvalidInterfaceException
865
+	 * @throws InvalidDataTypeException
866
+	 * @throws EE_Error
867
+	 */
868
+	protected function _add_prices_to_ticket(
869
+		$prices = array(),
870
+		EE_Ticket $ticket,
871
+		$new_prices = false,
872
+		$base_price = false,
873
+		$base_price_id = false
874
+	) {
875
+		// let's just get any current prices that may exist on the given ticket
876
+		// so we can remove any prices that got trashed in this session.
877
+		$current_prices_on_ticket = $base_price !== false
878
+			? $ticket->base_price(true)
879
+			: $ticket->price_modifiers();
880
+		$updated_prices = array();
881
+		// if $base_price ! FALSE then updating a base price.
882
+		if ($base_price !== false) {
883
+			$prices[1] = array(
884
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
885
+				'PRT_ID'     => 1,
886
+				'PRC_amount' => $base_price,
887
+				'PRC_name'   => $ticket->get('TKT_name'),
888
+				'PRC_desc'   => $ticket->get('TKT_description'),
889
+			);
890
+		}
891
+		// possibly need to save tkt
892
+		if (! $ticket->ID()) {
893
+			$ticket->save();
894
+		}
895
+		foreach ($prices as $row => $prc) {
896
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
897
+			if (empty($prt_id)) {
898
+				continue;
899
+			} //prices MUST have a price type id.
900
+			$PRC_values = array(
901
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
902
+				'PRT_ID'         => $prt_id,
903
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
904
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
905
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
906
+				'PRC_is_default' => false,
907
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
908
+				'PRC_order'      => $row,
909
+			);
910
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
911
+				$PRC_values['PRC_ID'] = 0;
912
+				$price = EE_Registry::instance()->load_class(
913
+					'Price',
914
+					array($PRC_values),
915
+					false,
916
+					false
917
+				);
918
+			} else {
919
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
920
+				// update this price with new values
921
+				foreach ($PRC_values as $field => $value) {
922
+					$price->set($field, $value);
923
+				}
924
+			}
925
+			$price->save();
926
+			$updated_prices[ $price->ID() ] = $price;
927
+			$ticket->_add_relation_to($price, 'Price');
928
+		}
929
+		// now let's remove any prices that got removed from the ticket
930
+		if (! empty($current_prices_on_ticket)) {
931
+			$current = array_keys($current_prices_on_ticket);
932
+			$updated = array_keys($updated_prices);
933
+			$prices_to_remove = array_diff($current, $updated);
934
+			if (! empty($prices_to_remove)) {
935
+				foreach ($prices_to_remove as $prc_id) {
936
+					$p = $current_prices_on_ticket[ $prc_id ];
937
+					$ticket->_remove_relation_to($p, 'Price');
938
+					// delete permanently the price
939
+					$p->delete_permanently();
940
+				}
941
+			}
942
+		}
943
+		return $ticket;
944
+	}
945 945
 
946 946
 
947
-    /**
948
-     * @param Events_Admin_Page $event_admin_obj
949
-     * @return Events_Admin_Page
950
-     */
951
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
952
-    {
953
-        return $event_admin_obj;
954
-        // doing nothing for the moment.
955
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
956
-        // (use the set_template_args() method)
957
-        /**
958
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
959
-         * 1. TKT_is_default_selector (visible)
960
-         * 2. TKT_is_default (hidden)
961
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
962
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
963
-         * this ticket to be saved as a default.
964
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
965
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
966
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
967
-         * the TKT HAS been saved as a default..
968
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
969
-         * On Autosave:
970
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
971
-         * then set the TKT_is_default to false.
972
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
973
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
974
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
975
-         */
976
-    }
947
+	/**
948
+	 * @param Events_Admin_Page $event_admin_obj
949
+	 * @return Events_Admin_Page
950
+	 */
951
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
952
+	{
953
+		return $event_admin_obj;
954
+		// doing nothing for the moment.
955
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
956
+		// (use the set_template_args() method)
957
+		/**
958
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
959
+		 * 1. TKT_is_default_selector (visible)
960
+		 * 2. TKT_is_default (hidden)
961
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
962
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
963
+		 * this ticket to be saved as a default.
964
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
965
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
966
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
967
+		 * the TKT HAS been saved as a default..
968
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
969
+		 * On Autosave:
970
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
971
+		 * then set the TKT_is_default to false.
972
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
973
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
974
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
975
+		 */
976
+	}
977 977
 
978 978
 
979
-    /**
980
-     * @throws ReflectionException
981
-     * @throws InvalidArgumentException
982
-     * @throws InvalidInterfaceException
983
-     * @throws InvalidDataTypeException
984
-     * @throws DomainException
985
-     * @throws EE_Error
986
-     */
987
-    public function pricing_metabox()
988
-    {
989
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
990
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
991
-        // set is_creating_event property.
992
-        $EVT_ID = $event->ID();
993
-        $this->_is_creating_event = empty($this->_req_data['post']);
994
-        // default main template args
995
-        $main_template_args = array(
996
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
997
-                'event_editor_event_datetimes_help_tab',
998
-                $this->_adminpage_obj->page_slug,
999
-                $this->_adminpage_obj->get_req_action(),
1000
-                false,
1001
-                false
1002
-            ),
1003
-            // todo need to add a filter to the template for the help text
1004
-            // in the Events_Admin_Page core file so we can add further help
1005
-            'existing_datetime_ids'    => '',
1006
-            'total_dtt_rows'           => 1,
1007
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1008
-                'add_new_dtt_info',
1009
-                $this->_adminpage_obj->page_slug,
1010
-                $this->_adminpage_obj->get_req_action(),
1011
-                false,
1012
-                false
1013
-            ),
1014
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1015
-            'datetime_rows'            => '',
1016
-            'show_tickets_container'   => '',
1017
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1018
-            'ticket_rows'              => '',
1019
-            'existing_ticket_ids'      => '',
1020
-            'total_ticket_rows'        => 1,
1021
-            'ticket_js_structure'      => '',
1022
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1023
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1024
-        );
1025
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1026
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1027
-        /**
1028
-         * 1. Start with retrieving Datetimes
1029
-         * 2. For each datetime get related tickets
1030
-         * 3. For each ticket get related prices
1031
-         */
1032
-        /** @var EEM_Datetime $datetime_model */
1033
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1034
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1035
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1036
-        /**
1037
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1038
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1039
-         */
1040
-        $datetime_row = 1;
1041
-        foreach ($datetimes as $datetime) {
1042
-            $DTT_ID = $datetime->get('DTT_ID');
1043
-            $datetime->set('DTT_order', $datetime_row);
1044
-            $existing_datetime_ids[] = $DTT_ID;
1045
-            // tickets attached
1046
-            $related_tickets = $datetime->ID() > 0
1047
-                ? $datetime->get_many_related(
1048
-                    'Ticket',
1049
-                    array(
1050
-                        array(
1051
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1052
-                        ),
1053
-                        'default_where_conditions' => 'none',
1054
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1055
-                    )
1056
-                )
1057
-                : array();
1058
-            // if there are no related tickets this is likely a new event OR autodraft
1059
-            // event so we need to generate the default tickets because datetimes
1060
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1061
-            // datetime on the event.
1062
-            if (empty($related_tickets) && count($datetimes) < 2) {
1063
-                /** @var EEM_Ticket $ticket_model */
1064
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1065
-                $related_tickets = $ticket_model->get_all_default_tickets();
1066
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1067
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1068
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1069
-                $main_default_ticket = reset($related_tickets);
1070
-                if ($main_default_ticket instanceof EE_Ticket) {
1071
-                    foreach ($default_prices as $default_price) {
1072
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1073
-                            continue;
1074
-                        }
1075
-                        $main_default_ticket->cache('Price', $default_price);
1076
-                    }
1077
-                }
1078
-            }
1079
-            // we can't actually setup rows in this loop yet cause we don't know all
1080
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1081
-            // So we're going to temporarily cache some of that information.
1082
-            // loop through and setup the ticket rows and make sure the order is set.
1083
-            foreach ($related_tickets as $ticket) {
1084
-                $TKT_ID = $ticket->get('TKT_ID');
1085
-                $ticket_row = $ticket->get('TKT_row');
1086
-                // we only want unique tickets in our final display!!
1087
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1088
-                    $existing_ticket_ids[] = $TKT_ID;
1089
-                    $all_tickets[] = $ticket;
1090
-                }
1091
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1092
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1093
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1094
-                if (! isset($ticket_datetimes[ $TKT_ID ])
1095
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1096
-                ) {
1097
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1098
-                }
1099
-            }
1100
-            $datetime_row++;
1101
-        }
1102
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1103
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1104
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1105
-        // sort $all_tickets by order
1106
-        usort(
1107
-            $all_tickets,
1108
-            function (EE_Ticket $a, EE_Ticket $b) {
1109
-                $a_order = (int) $a->get('TKT_order');
1110
-                $b_order = (int) $b->get('TKT_order');
1111
-                if ($a_order === $b_order) {
1112
-                    return 0;
1113
-                }
1114
-                return ($a_order < $b_order) ? -1 : 1;
1115
-            }
1116
-        );
1117
-        // k NOW we have all the data we need for setting up the dtt rows
1118
-        // and ticket rows so we start our dtt loop again.
1119
-        $datetime_row = 1;
1120
-        foreach ($datetimes as $datetime) {
1121
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1122
-                $datetime_row,
1123
-                $datetime,
1124
-                $datetime_tickets,
1125
-                $all_tickets,
1126
-                false,
1127
-                $datetimes
1128
-            );
1129
-            $datetime_row++;
1130
-        }
1131
-        // then loop through all tickets for the ticket rows.
1132
-        $ticket_row = 1;
1133
-        foreach ($all_tickets as $ticket) {
1134
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1135
-                $ticket_row,
1136
-                $ticket,
1137
-                $ticket_datetimes,
1138
-                $datetimes,
1139
-                false,
1140
-                $all_tickets
1141
-            );
1142
-            $ticket_row++;
1143
-        }
1144
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
979
+	/**
980
+	 * @throws ReflectionException
981
+	 * @throws InvalidArgumentException
982
+	 * @throws InvalidInterfaceException
983
+	 * @throws InvalidDataTypeException
984
+	 * @throws DomainException
985
+	 * @throws EE_Error
986
+	 */
987
+	public function pricing_metabox()
988
+	{
989
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
990
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
991
+		// set is_creating_event property.
992
+		$EVT_ID = $event->ID();
993
+		$this->_is_creating_event = empty($this->_req_data['post']);
994
+		// default main template args
995
+		$main_template_args = array(
996
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
997
+				'event_editor_event_datetimes_help_tab',
998
+				$this->_adminpage_obj->page_slug,
999
+				$this->_adminpage_obj->get_req_action(),
1000
+				false,
1001
+				false
1002
+			),
1003
+			// todo need to add a filter to the template for the help text
1004
+			// in the Events_Admin_Page core file so we can add further help
1005
+			'existing_datetime_ids'    => '',
1006
+			'total_dtt_rows'           => 1,
1007
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1008
+				'add_new_dtt_info',
1009
+				$this->_adminpage_obj->page_slug,
1010
+				$this->_adminpage_obj->get_req_action(),
1011
+				false,
1012
+				false
1013
+			),
1014
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1015
+			'datetime_rows'            => '',
1016
+			'show_tickets_container'   => '',
1017
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1018
+			'ticket_rows'              => '',
1019
+			'existing_ticket_ids'      => '',
1020
+			'total_ticket_rows'        => 1,
1021
+			'ticket_js_structure'      => '',
1022
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1023
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1024
+		);
1025
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1026
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1027
+		/**
1028
+		 * 1. Start with retrieving Datetimes
1029
+		 * 2. For each datetime get related tickets
1030
+		 * 3. For each ticket get related prices
1031
+		 */
1032
+		/** @var EEM_Datetime $datetime_model */
1033
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1034
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1035
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1036
+		/**
1037
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1038
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1039
+		 */
1040
+		$datetime_row = 1;
1041
+		foreach ($datetimes as $datetime) {
1042
+			$DTT_ID = $datetime->get('DTT_ID');
1043
+			$datetime->set('DTT_order', $datetime_row);
1044
+			$existing_datetime_ids[] = $DTT_ID;
1045
+			// tickets attached
1046
+			$related_tickets = $datetime->ID() > 0
1047
+				? $datetime->get_many_related(
1048
+					'Ticket',
1049
+					array(
1050
+						array(
1051
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1052
+						),
1053
+						'default_where_conditions' => 'none',
1054
+						'order_by'                 => array('TKT_order' => 'ASC'),
1055
+					)
1056
+				)
1057
+				: array();
1058
+			// if there are no related tickets this is likely a new event OR autodraft
1059
+			// event so we need to generate the default tickets because datetimes
1060
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1061
+			// datetime on the event.
1062
+			if (empty($related_tickets) && count($datetimes) < 2) {
1063
+				/** @var EEM_Ticket $ticket_model */
1064
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1065
+				$related_tickets = $ticket_model->get_all_default_tickets();
1066
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1067
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1068
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1069
+				$main_default_ticket = reset($related_tickets);
1070
+				if ($main_default_ticket instanceof EE_Ticket) {
1071
+					foreach ($default_prices as $default_price) {
1072
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1073
+							continue;
1074
+						}
1075
+						$main_default_ticket->cache('Price', $default_price);
1076
+					}
1077
+				}
1078
+			}
1079
+			// we can't actually setup rows in this loop yet cause we don't know all
1080
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1081
+			// So we're going to temporarily cache some of that information.
1082
+			// loop through and setup the ticket rows and make sure the order is set.
1083
+			foreach ($related_tickets as $ticket) {
1084
+				$TKT_ID = $ticket->get('TKT_ID');
1085
+				$ticket_row = $ticket->get('TKT_row');
1086
+				// we only want unique tickets in our final display!!
1087
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1088
+					$existing_ticket_ids[] = $TKT_ID;
1089
+					$all_tickets[] = $ticket;
1090
+				}
1091
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1092
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1093
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1094
+				if (! isset($ticket_datetimes[ $TKT_ID ])
1095
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1096
+				) {
1097
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1098
+				}
1099
+			}
1100
+			$datetime_row++;
1101
+		}
1102
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1103
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1104
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1105
+		// sort $all_tickets by order
1106
+		usort(
1107
+			$all_tickets,
1108
+			function (EE_Ticket $a, EE_Ticket $b) {
1109
+				$a_order = (int) $a->get('TKT_order');
1110
+				$b_order = (int) $b->get('TKT_order');
1111
+				if ($a_order === $b_order) {
1112
+					return 0;
1113
+				}
1114
+				return ($a_order < $b_order) ? -1 : 1;
1115
+			}
1116
+		);
1117
+		// k NOW we have all the data we need for setting up the dtt rows
1118
+		// and ticket rows so we start our dtt loop again.
1119
+		$datetime_row = 1;
1120
+		foreach ($datetimes as $datetime) {
1121
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1122
+				$datetime_row,
1123
+				$datetime,
1124
+				$datetime_tickets,
1125
+				$all_tickets,
1126
+				false,
1127
+				$datetimes
1128
+			);
1129
+			$datetime_row++;
1130
+		}
1131
+		// then loop through all tickets for the ticket rows.
1132
+		$ticket_row = 1;
1133
+		foreach ($all_tickets as $ticket) {
1134
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1135
+				$ticket_row,
1136
+				$ticket,
1137
+				$ticket_datetimes,
1138
+				$datetimes,
1139
+				false,
1140
+				$all_tickets
1141
+			);
1142
+			$ticket_row++;
1143
+		}
1144
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1145 1145
 
1146
-        $status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1147
-            'EventEspresso\core\admin\StatusChangeNotice'
1148
-        );
1149
-        if (! $status_change_notice->isDismissed()) {
1150
-            $main_template_args['status_change_notice'] = EEH_Template::display_template(
1151
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
1152
-                ['context' => '__event-editor', 'page_slug' => 'espresso-events'],
1153
-                true
1154
-            );
1155
-        }
1146
+		$status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1147
+			'EventEspresso\core\admin\StatusChangeNotice'
1148
+		);
1149
+		if (! $status_change_notice->isDismissed()) {
1150
+			$main_template_args['status_change_notice'] = EEH_Template::display_template(
1151
+				EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
1152
+				['context' => '__event-editor', 'page_slug' => 'espresso-events'],
1153
+				true
1154
+			);
1155
+		}
1156 1156
 
1157
-        EEH_Template::display_template(
1158
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1159
-            $main_template_args
1160
-        );
1161
-    }
1157
+		EEH_Template::display_template(
1158
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1159
+			$main_template_args
1160
+		);
1161
+	}
1162 1162
 
1163 1163
 
1164
-    /**
1165
-     * @param int         $datetime_row
1166
-     * @param EE_Datetime $datetime
1167
-     * @param array       $datetime_tickets
1168
-     * @param array       $all_tickets
1169
-     * @param bool        $default
1170
-     * @param array       $all_datetimes
1171
-     * @return mixed
1172
-     * @throws DomainException
1173
-     * @throws EE_Error
1174
-     */
1175
-    protected function _get_datetime_row(
1176
-        $datetime_row,
1177
-        EE_Datetime $datetime,
1178
-        $datetime_tickets = array(),
1179
-        $all_tickets = array(),
1180
-        $default = false,
1181
-        $all_datetimes = array()
1182
-    ) {
1183
-        $dtt_display_template_args = array(
1184
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1185
-                $datetime_row,
1186
-                $datetime,
1187
-                $default,
1188
-                $all_datetimes
1189
-            ),
1190
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1191
-                $datetime_row,
1192
-                $datetime,
1193
-                $datetime_tickets,
1194
-                $all_tickets,
1195
-                $default
1196
-            ),
1197
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1198
-        );
1199
-        return EEH_Template::display_template(
1200
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1201
-            $dtt_display_template_args,
1202
-            true
1203
-        );
1204
-    }
1164
+	/**
1165
+	 * @param int         $datetime_row
1166
+	 * @param EE_Datetime $datetime
1167
+	 * @param array       $datetime_tickets
1168
+	 * @param array       $all_tickets
1169
+	 * @param bool        $default
1170
+	 * @param array       $all_datetimes
1171
+	 * @return mixed
1172
+	 * @throws DomainException
1173
+	 * @throws EE_Error
1174
+	 */
1175
+	protected function _get_datetime_row(
1176
+		$datetime_row,
1177
+		EE_Datetime $datetime,
1178
+		$datetime_tickets = array(),
1179
+		$all_tickets = array(),
1180
+		$default = false,
1181
+		$all_datetimes = array()
1182
+	) {
1183
+		$dtt_display_template_args = array(
1184
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1185
+				$datetime_row,
1186
+				$datetime,
1187
+				$default,
1188
+				$all_datetimes
1189
+			),
1190
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1191
+				$datetime_row,
1192
+				$datetime,
1193
+				$datetime_tickets,
1194
+				$all_tickets,
1195
+				$default
1196
+			),
1197
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1198
+		);
1199
+		return EEH_Template::display_template(
1200
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1201
+			$dtt_display_template_args,
1202
+			true
1203
+		);
1204
+	}
1205 1205
 
1206 1206
 
1207
-    /**
1208
-     * This method is used to generate a dtt fields  edit row.
1209
-     * The same row is used to generate a row with valid DTT objects
1210
-     * and the default row that is used as the skeleton by the js.
1211
-     *
1212
-     * @param int           $datetime_row  The row number for the row being generated.
1213
-     * @param EE_Datetime   $datetime
1214
-     * @param bool          $default       Whether a default row is being generated or not.
1215
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1216
-     * @return string
1217
-     * @throws DomainException
1218
-     * @throws EE_Error
1219
-     */
1220
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1221
-    {
1222
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1223
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1224
-        $template_args = array(
1225
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1226
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1227
-            'edit_dtt_expanded'    => '',
1228
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1229
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1230
-            'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1231
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1232
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1233
-            'DTT_reg_limit'        => $default
1234
-                ? ''
1235
-                : $datetime->get_pretty(
1236
-                    'DTT_reg_limit',
1237
-                    'input'
1238
-                ),
1239
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1240
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1241
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1242
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1243
-                ? ''
1244
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1245
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1246
-                ? 'ee-lock-icon'
1247
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1248
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1249
-                ? ''
1250
-                : EE_Admin_Page::add_query_args_and_nonce(
1251
-                    array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1252
-                    REG_ADMIN_URL
1253
-                ),
1254
-        );
1255
-        $template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1256
-            ? ' style="display:none"'
1257
-            : '';
1258
-        // allow filtering of template args at this point.
1259
-        $template_args = apply_filters(
1260
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1261
-            $template_args,
1262
-            $datetime_row,
1263
-            $datetime,
1264
-            $default,
1265
-            $all_datetimes,
1266
-            $this->_is_creating_event
1267
-        );
1268
-        return EEH_Template::display_template(
1269
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1270
-            $template_args,
1271
-            true
1272
-        );
1273
-    }
1207
+	/**
1208
+	 * This method is used to generate a dtt fields  edit row.
1209
+	 * The same row is used to generate a row with valid DTT objects
1210
+	 * and the default row that is used as the skeleton by the js.
1211
+	 *
1212
+	 * @param int           $datetime_row  The row number for the row being generated.
1213
+	 * @param EE_Datetime   $datetime
1214
+	 * @param bool          $default       Whether a default row is being generated or not.
1215
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1216
+	 * @return string
1217
+	 * @throws DomainException
1218
+	 * @throws EE_Error
1219
+	 */
1220
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1221
+	{
1222
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1223
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1224
+		$template_args = array(
1225
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1226
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1227
+			'edit_dtt_expanded'    => '',
1228
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1229
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1230
+			'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1231
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1232
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1233
+			'DTT_reg_limit'        => $default
1234
+				? ''
1235
+				: $datetime->get_pretty(
1236
+					'DTT_reg_limit',
1237
+					'input'
1238
+				),
1239
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1240
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1241
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1242
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1243
+				? ''
1244
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1245
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1246
+				? 'ee-lock-icon'
1247
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1248
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1249
+				? ''
1250
+				: EE_Admin_Page::add_query_args_and_nonce(
1251
+					array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1252
+					REG_ADMIN_URL
1253
+				),
1254
+		);
1255
+		$template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1256
+			? ' style="display:none"'
1257
+			: '';
1258
+		// allow filtering of template args at this point.
1259
+		$template_args = apply_filters(
1260
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1261
+			$template_args,
1262
+			$datetime_row,
1263
+			$datetime,
1264
+			$default,
1265
+			$all_datetimes,
1266
+			$this->_is_creating_event
1267
+		);
1268
+		return EEH_Template::display_template(
1269
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1270
+			$template_args,
1271
+			true
1272
+		);
1273
+	}
1274 1274
 
1275 1275
 
1276
-    /**
1277
-     * @param int         $datetime_row
1278
-     * @param EE_Datetime $datetime
1279
-     * @param array       $datetime_tickets
1280
-     * @param array       $all_tickets
1281
-     * @param bool        $default
1282
-     * @return mixed
1283
-     * @throws DomainException
1284
-     * @throws EE_Error
1285
-     */
1286
-    protected function _get_dtt_attached_tickets_row(
1287
-        $datetime_row,
1288
-        $datetime,
1289
-        $datetime_tickets = array(),
1290
-        $all_tickets = array(),
1291
-        $default
1292
-    ) {
1293
-        $template_args = array(
1294
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1295
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1296
-            'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1297
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1298
-            'show_tickets_row'                  => ' style="display:none;"',
1299
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1300
-                'add_new_ticket_via_datetime',
1301
-                $this->_adminpage_obj->page_slug,
1302
-                $this->_adminpage_obj->get_req_action(),
1303
-                false,
1304
-                false
1305
-            ),
1306
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1307
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1308
-        );
1309
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1310
-        if (! $default) {
1311
-            $ticket_row = 1;
1312
-            foreach ($all_tickets as $ticket) {
1313
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1314
-                    $datetime_row,
1315
-                    $ticket_row,
1316
-                    $datetime,
1317
-                    $ticket,
1318
-                    $datetime_tickets,
1319
-                    $default
1320
-                );
1321
-                $ticket_row++;
1322
-            }
1323
-        }
1324
-        // filter template args at this point
1325
-        $template_args = apply_filters(
1326
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1327
-            $template_args,
1328
-            $datetime_row,
1329
-            $datetime,
1330
-            $datetime_tickets,
1331
-            $all_tickets,
1332
-            $default,
1333
-            $this->_is_creating_event
1334
-        );
1335
-        return EEH_Template::display_template(
1336
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1337
-            $template_args,
1338
-            true
1339
-        );
1340
-    }
1276
+	/**
1277
+	 * @param int         $datetime_row
1278
+	 * @param EE_Datetime $datetime
1279
+	 * @param array       $datetime_tickets
1280
+	 * @param array       $all_tickets
1281
+	 * @param bool        $default
1282
+	 * @return mixed
1283
+	 * @throws DomainException
1284
+	 * @throws EE_Error
1285
+	 */
1286
+	protected function _get_dtt_attached_tickets_row(
1287
+		$datetime_row,
1288
+		$datetime,
1289
+		$datetime_tickets = array(),
1290
+		$all_tickets = array(),
1291
+		$default
1292
+	) {
1293
+		$template_args = array(
1294
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1295
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1296
+			'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1297
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1298
+			'show_tickets_row'                  => ' style="display:none;"',
1299
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1300
+				'add_new_ticket_via_datetime',
1301
+				$this->_adminpage_obj->page_slug,
1302
+				$this->_adminpage_obj->get_req_action(),
1303
+				false,
1304
+				false
1305
+			),
1306
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1307
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1308
+		);
1309
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1310
+		if (! $default) {
1311
+			$ticket_row = 1;
1312
+			foreach ($all_tickets as $ticket) {
1313
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1314
+					$datetime_row,
1315
+					$ticket_row,
1316
+					$datetime,
1317
+					$ticket,
1318
+					$datetime_tickets,
1319
+					$default
1320
+				);
1321
+				$ticket_row++;
1322
+			}
1323
+		}
1324
+		// filter template args at this point
1325
+		$template_args = apply_filters(
1326
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1327
+			$template_args,
1328
+			$datetime_row,
1329
+			$datetime,
1330
+			$datetime_tickets,
1331
+			$all_tickets,
1332
+			$default,
1333
+			$this->_is_creating_event
1334
+		);
1335
+		return EEH_Template::display_template(
1336
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1337
+			$template_args,
1338
+			true
1339
+		);
1340
+	}
1341 1341
 
1342 1342
 
1343
-    /**
1344
-     * @param int         $datetime_row
1345
-     * @param int         $ticket_row
1346
-     * @param EE_Datetime $datetime
1347
-     * @param EE_Ticket   $ticket
1348
-     * @param array       $datetime_tickets
1349
-     * @param bool        $default
1350
-     * @return mixed
1351
-     * @throws DomainException
1352
-     * @throws EE_Error
1353
-     */
1354
-    protected function _get_datetime_tickets_list_item(
1355
-        $datetime_row,
1356
-        $ticket_row,
1357
-        $datetime,
1358
-        $ticket,
1359
-        $datetime_tickets = array(),
1360
-        $default
1361
-    ) {
1362
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1363
-            ? $datetime_tickets[ $datetime->ID() ]
1364
-            : array();
1365
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1366
-        $no_ticket = $default && empty($ticket);
1367
-        $template_args = array(
1368
-            'dtt_row'                 => $default
1369
-                ? 'DTTNUM'
1370
-                : $datetime_row,
1371
-            'tkt_row'                 => $no_ticket
1372
-                ? 'TICKETNUM'
1373
-                : $ticket_row,
1374
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1375
-                ? ' checked="checked"'
1376
-                : '',
1377
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1378
-                ? ' ticket-selected'
1379
-                : '',
1380
-            'TKT_name'                => $no_ticket
1381
-                ? 'TKTNAME'
1382
-                : $ticket->get('TKT_name'),
1383
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1384
-                ? ' tkt-status-' . EE_Ticket::onsale
1385
-                : ' tkt-status-' . $ticket->ticket_status(),
1386
-        );
1387
-        // filter template args
1388
-        $template_args = apply_filters(
1389
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1390
-            $template_args,
1391
-            $datetime_row,
1392
-            $ticket_row,
1393
-            $datetime,
1394
-            $ticket,
1395
-            $datetime_tickets,
1396
-            $default,
1397
-            $this->_is_creating_event
1398
-        );
1399
-        return EEH_Template::display_template(
1400
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1401
-            $template_args,
1402
-            true
1403
-        );
1404
-    }
1343
+	/**
1344
+	 * @param int         $datetime_row
1345
+	 * @param int         $ticket_row
1346
+	 * @param EE_Datetime $datetime
1347
+	 * @param EE_Ticket   $ticket
1348
+	 * @param array       $datetime_tickets
1349
+	 * @param bool        $default
1350
+	 * @return mixed
1351
+	 * @throws DomainException
1352
+	 * @throws EE_Error
1353
+	 */
1354
+	protected function _get_datetime_tickets_list_item(
1355
+		$datetime_row,
1356
+		$ticket_row,
1357
+		$datetime,
1358
+		$ticket,
1359
+		$datetime_tickets = array(),
1360
+		$default
1361
+	) {
1362
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1363
+			? $datetime_tickets[ $datetime->ID() ]
1364
+			: array();
1365
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1366
+		$no_ticket = $default && empty($ticket);
1367
+		$template_args = array(
1368
+			'dtt_row'                 => $default
1369
+				? 'DTTNUM'
1370
+				: $datetime_row,
1371
+			'tkt_row'                 => $no_ticket
1372
+				? 'TICKETNUM'
1373
+				: $ticket_row,
1374
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1375
+				? ' checked="checked"'
1376
+				: '',
1377
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1378
+				? ' ticket-selected'
1379
+				: '',
1380
+			'TKT_name'                => $no_ticket
1381
+				? 'TKTNAME'
1382
+				: $ticket->get('TKT_name'),
1383
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1384
+				? ' tkt-status-' . EE_Ticket::onsale
1385
+				: ' tkt-status-' . $ticket->ticket_status(),
1386
+		);
1387
+		// filter template args
1388
+		$template_args = apply_filters(
1389
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1390
+			$template_args,
1391
+			$datetime_row,
1392
+			$ticket_row,
1393
+			$datetime,
1394
+			$ticket,
1395
+			$datetime_tickets,
1396
+			$default,
1397
+			$this->_is_creating_event
1398
+		);
1399
+		return EEH_Template::display_template(
1400
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1401
+			$template_args,
1402
+			true
1403
+		);
1404
+	}
1405 1405
 
1406 1406
 
1407
-    /**
1408
-     * This generates the ticket row for tickets.
1409
-     * This same method is used to generate both the actual rows and the js skeleton row
1410
-     * (when default === true)
1411
-     *
1412
-     * @param int           $ticket_row       Represents the row number being generated.
1413
-     * @param               $ticket
1414
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1415
-     *                                        or empty for default
1416
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1417
-     * @param bool          $default          Whether default row being generated or not.
1418
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1419
-     *                                        (or empty in the case of defaults)
1420
-     * @return mixed
1421
-     * @throws InvalidArgumentException
1422
-     * @throws InvalidInterfaceException
1423
-     * @throws InvalidDataTypeException
1424
-     * @throws DomainException
1425
-     * @throws EE_Error
1426
-     * @throws ReflectionException
1427
-     */
1428
-    protected function _get_ticket_row(
1429
-        $ticket_row,
1430
-        $ticket,
1431
-        $ticket_datetimes,
1432
-        $all_datetimes,
1433
-        $default = false,
1434
-        $all_tickets = array()
1435
-    ) {
1436
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1437
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1438
-        $prices = ! empty($ticket) && ! $default
1439
-            ? $ticket->get_many_related(
1440
-                'Price',
1441
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1442
-            )
1443
-            : array();
1444
-        // if there is only one price (which would be the base price)
1445
-        // or NO prices and this ticket is a default ticket,
1446
-        // let's just make sure there are no cached default prices on the object.
1447
-        // This is done by not including any query_params.
1448
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1449
-            $prices = $ticket->prices();
1450
-        }
1451
-        // check if we're dealing with a default ticket in which case
1452
-        // we don't want any starting_ticket_datetime_row values set
1453
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1454
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1455
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1456
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1457
-            ? $ticket_datetimes[ $ticket->ID() ]
1458
-            : array();
1459
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1460
-        $base_price = $default ? null : $ticket->base_price();
1461
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1462
-        // breaking out complicated condition for ticket_status
1463
-        if ($default) {
1464
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1465
-        } else {
1466
-            $ticket_status_class = $ticket->is_default()
1467
-                ? ' tkt-status-' . EE_Ticket::onsale
1468
-                : ' tkt-status-' . $ticket->ticket_status();
1469
-        }
1470
-        // breaking out complicated condition for TKT_taxable
1471
-        if ($default) {
1472
-            $TKT_taxable = '';
1473
-        } else {
1474
-            $TKT_taxable = $ticket->taxable()
1475
-                ? ' checked="checked"'
1476
-                : '';
1477
-        }
1478
-        if ($default) {
1479
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1480
-        } elseif ($ticket->is_default()) {
1481
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1482
-        } else {
1483
-            $TKT_status = $ticket->ticket_status(true);
1484
-        }
1485
-        if ($default) {
1486
-            $TKT_min = '';
1487
-        } else {
1488
-            $TKT_min = $ticket->min();
1489
-            if ($TKT_min === -1 || $TKT_min === 0) {
1490
-                $TKT_min = '';
1491
-            }
1492
-        }
1493
-        $template_args = array(
1494
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1495
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1496
-            // on initial page load this will always be the correct order.
1497
-            'tkt_status_class'              => $ticket_status_class,
1498
-            'display_edit_tkt_row'          => ' style="display:none;"',
1499
-            'edit_tkt_expanded'             => '',
1500
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1501
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1502
-            'TKT_start_date'                => $default
1503
-                ? ''
1504
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1505
-            'TKT_end_date'                  => $default
1506
-                ? ''
1507
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1508
-            'TKT_status'                    => $TKT_status,
1509
-            'TKT_price'                     => $default
1510
-                ? ''
1511
-                : EEH_Template::format_currency(
1512
-                    $ticket->get_ticket_total_with_taxes(),
1513
-                    false,
1514
-                    false
1515
-                ),
1516
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1517
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1518
-            'TKT_qty'                       => $default
1519
-                ? ''
1520
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1521
-            'TKT_qty_for_input'             => $default
1522
-                ? ''
1523
-                : $ticket->get_pretty('TKT_qty', 'input'),
1524
-            'TKT_uses'                      => $default
1525
-                ? ''
1526
-                : $ticket->get_pretty('TKT_uses', 'input'),
1527
-            'TKT_min'                       => $TKT_min,
1528
-            'TKT_max'                       => $default
1529
-                ? ''
1530
-                : $ticket->get_pretty('TKT_max', 'input'),
1531
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1532
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1533
-            'TKT_registrations'             => $default
1534
-                ? 0
1535
-                : $ticket->count_registrations(
1536
-                    array(
1537
-                        array(
1538
-                            'STS_ID' => array(
1539
-                                '!=',
1540
-                                EEM_Registration::status_id_incomplete,
1541
-                            ),
1542
-                        ),
1543
-                    )
1544
-                ),
1545
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1546
-            'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1547
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1548
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1549
-            'TKT_is_default_selector'       => '',
1550
-            'ticket_price_rows'             => '',
1551
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1552
-                ? ''
1553
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1554
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1555
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1556
-                ? ''
1557
-                : ' style="display:none;"',
1558
-            'show_price_mod_button'         => count($prices) > 1
1559
-                                               || ($default && $count_price_mods > 0)
1560
-                                               || (! $default && $ticket->deleted())
1561
-                ? ' style="display:none;"'
1562
-                : '',
1563
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1564
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1565
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1566
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1567
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1568
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1569
-            'TKT_taxable'                   => $TKT_taxable,
1570
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1571
-                ? ''
1572
-                : ' style="display:none"',
1573
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1574
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1575
-                $ticket_subtotal,
1576
-                false,
1577
-                false
1578
-            ),
1579
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1580
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1581
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1582
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1583
-                ? ' ticket-archived'
1584
-                : '',
1585
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1586
-                                               && $ticket->deleted()
1587
-                                               && ! $ticket->is_permanently_deleteable()
1588
-                ? 'ee-lock-icon '
1589
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1590
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1591
-                ? ''
1592
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1593
-        );
1594
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1595
-            ? ' style="display:none"'
1596
-            : '';
1597
-        // handle rows that should NOT be empty
1598
-        if (empty($template_args['TKT_start_date'])) {
1599
-            // if empty then the start date will be now.
1600
-            $template_args['TKT_start_date'] = date(
1601
-                $this->_date_time_format,
1602
-                current_time('timestamp')
1603
-            );
1604
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1605
-        }
1606
-        if (empty($template_args['TKT_end_date'])) {
1607
-            // get the earliest datetime (if present);
1608
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1609
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1610
-                    'Datetime',
1611
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1612
-                )
1613
-                : null;
1614
-            if (! empty($earliest_dtt)) {
1615
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1616
-                    'DTT_EVT_start',
1617
-                    $this->_date_time_format
1618
-                );
1619
-            } else {
1620
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1621
-                $template_args['TKT_end_date'] = date(
1622
-                    $this->_date_time_format,
1623
-                    mktime(
1624
-                        24,
1625
-                        0,
1626
-                        0,
1627
-                        date('m'),
1628
-                        date('d') + 29,
1629
-                        date('Y')
1630
-                    )
1631
-                );
1632
-            }
1633
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1634
-        }
1635
-        // generate ticket_datetime items
1636
-        if (! $default) {
1637
-            $datetime_row = 1;
1638
-            foreach ($all_datetimes as $datetime) {
1639
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1640
-                    $datetime_row,
1641
-                    $ticket_row,
1642
-                    $datetime,
1643
-                    $ticket,
1644
-                    $ticket_datetimes,
1645
-                    $default
1646
-                );
1647
-                $datetime_row++;
1648
-            }
1649
-        }
1650
-        $price_row = 1;
1651
-        foreach ($prices as $price) {
1652
-            if (! $price instanceof EE_Price) {
1653
-                continue;
1654
-            }
1655
-            if ($price->is_base_price()) {
1656
-                $price_row++;
1657
-                continue;
1658
-            }
1659
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1660
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1661
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1662
-                $ticket_row,
1663
-                $price_row,
1664
-                $price,
1665
-                $default,
1666
-                $ticket,
1667
-                $show_trash,
1668
-                $show_create
1669
-            );
1670
-            $price_row++;
1671
-        }
1672
-        // filter $template_args
1673
-        $template_args = apply_filters(
1674
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1675
-            $template_args,
1676
-            $ticket_row,
1677
-            $ticket,
1678
-            $ticket_datetimes,
1679
-            $all_datetimes,
1680
-            $default,
1681
-            $all_tickets,
1682
-            $this->_is_creating_event
1683
-        );
1684
-        return EEH_Template::display_template(
1685
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1686
-            $template_args,
1687
-            true
1688
-        );
1689
-    }
1407
+	/**
1408
+	 * This generates the ticket row for tickets.
1409
+	 * This same method is used to generate both the actual rows and the js skeleton row
1410
+	 * (when default === true)
1411
+	 *
1412
+	 * @param int           $ticket_row       Represents the row number being generated.
1413
+	 * @param               $ticket
1414
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1415
+	 *                                        or empty for default
1416
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1417
+	 * @param bool          $default          Whether default row being generated or not.
1418
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1419
+	 *                                        (or empty in the case of defaults)
1420
+	 * @return mixed
1421
+	 * @throws InvalidArgumentException
1422
+	 * @throws InvalidInterfaceException
1423
+	 * @throws InvalidDataTypeException
1424
+	 * @throws DomainException
1425
+	 * @throws EE_Error
1426
+	 * @throws ReflectionException
1427
+	 */
1428
+	protected function _get_ticket_row(
1429
+		$ticket_row,
1430
+		$ticket,
1431
+		$ticket_datetimes,
1432
+		$all_datetimes,
1433
+		$default = false,
1434
+		$all_tickets = array()
1435
+	) {
1436
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1437
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1438
+		$prices = ! empty($ticket) && ! $default
1439
+			? $ticket->get_many_related(
1440
+				'Price',
1441
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1442
+			)
1443
+			: array();
1444
+		// if there is only one price (which would be the base price)
1445
+		// or NO prices and this ticket is a default ticket,
1446
+		// let's just make sure there are no cached default prices on the object.
1447
+		// This is done by not including any query_params.
1448
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1449
+			$prices = $ticket->prices();
1450
+		}
1451
+		// check if we're dealing with a default ticket in which case
1452
+		// we don't want any starting_ticket_datetime_row values set
1453
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1454
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1455
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1456
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1457
+			? $ticket_datetimes[ $ticket->ID() ]
1458
+			: array();
1459
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1460
+		$base_price = $default ? null : $ticket->base_price();
1461
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1462
+		// breaking out complicated condition for ticket_status
1463
+		if ($default) {
1464
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1465
+		} else {
1466
+			$ticket_status_class = $ticket->is_default()
1467
+				? ' tkt-status-' . EE_Ticket::onsale
1468
+				: ' tkt-status-' . $ticket->ticket_status();
1469
+		}
1470
+		// breaking out complicated condition for TKT_taxable
1471
+		if ($default) {
1472
+			$TKT_taxable = '';
1473
+		} else {
1474
+			$TKT_taxable = $ticket->taxable()
1475
+				? ' checked="checked"'
1476
+				: '';
1477
+		}
1478
+		if ($default) {
1479
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1480
+		} elseif ($ticket->is_default()) {
1481
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1482
+		} else {
1483
+			$TKT_status = $ticket->ticket_status(true);
1484
+		}
1485
+		if ($default) {
1486
+			$TKT_min = '';
1487
+		} else {
1488
+			$TKT_min = $ticket->min();
1489
+			if ($TKT_min === -1 || $TKT_min === 0) {
1490
+				$TKT_min = '';
1491
+			}
1492
+		}
1493
+		$template_args = array(
1494
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1495
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1496
+			// on initial page load this will always be the correct order.
1497
+			'tkt_status_class'              => $ticket_status_class,
1498
+			'display_edit_tkt_row'          => ' style="display:none;"',
1499
+			'edit_tkt_expanded'             => '',
1500
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1501
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1502
+			'TKT_start_date'                => $default
1503
+				? ''
1504
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1505
+			'TKT_end_date'                  => $default
1506
+				? ''
1507
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1508
+			'TKT_status'                    => $TKT_status,
1509
+			'TKT_price'                     => $default
1510
+				? ''
1511
+				: EEH_Template::format_currency(
1512
+					$ticket->get_ticket_total_with_taxes(),
1513
+					false,
1514
+					false
1515
+				),
1516
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1517
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1518
+			'TKT_qty'                       => $default
1519
+				? ''
1520
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1521
+			'TKT_qty_for_input'             => $default
1522
+				? ''
1523
+				: $ticket->get_pretty('TKT_qty', 'input'),
1524
+			'TKT_uses'                      => $default
1525
+				? ''
1526
+				: $ticket->get_pretty('TKT_uses', 'input'),
1527
+			'TKT_min'                       => $TKT_min,
1528
+			'TKT_max'                       => $default
1529
+				? ''
1530
+				: $ticket->get_pretty('TKT_max', 'input'),
1531
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1532
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1533
+			'TKT_registrations'             => $default
1534
+				? 0
1535
+				: $ticket->count_registrations(
1536
+					array(
1537
+						array(
1538
+							'STS_ID' => array(
1539
+								'!=',
1540
+								EEM_Registration::status_id_incomplete,
1541
+							),
1542
+						),
1543
+					)
1544
+				),
1545
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1546
+			'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1547
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1548
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1549
+			'TKT_is_default_selector'       => '',
1550
+			'ticket_price_rows'             => '',
1551
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1552
+				? ''
1553
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1554
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1555
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1556
+				? ''
1557
+				: ' style="display:none;"',
1558
+			'show_price_mod_button'         => count($prices) > 1
1559
+											   || ($default && $count_price_mods > 0)
1560
+											   || (! $default && $ticket->deleted())
1561
+				? ' style="display:none;"'
1562
+				: '',
1563
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1564
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1565
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1566
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1567
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1568
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1569
+			'TKT_taxable'                   => $TKT_taxable,
1570
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1571
+				? ''
1572
+				: ' style="display:none"',
1573
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1574
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1575
+				$ticket_subtotal,
1576
+				false,
1577
+				false
1578
+			),
1579
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1580
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1581
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1582
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1583
+				? ' ticket-archived'
1584
+				: '',
1585
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1586
+											   && $ticket->deleted()
1587
+											   && ! $ticket->is_permanently_deleteable()
1588
+				? 'ee-lock-icon '
1589
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1590
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1591
+				? ''
1592
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1593
+		);
1594
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1595
+			? ' style="display:none"'
1596
+			: '';
1597
+		// handle rows that should NOT be empty
1598
+		if (empty($template_args['TKT_start_date'])) {
1599
+			// if empty then the start date will be now.
1600
+			$template_args['TKT_start_date'] = date(
1601
+				$this->_date_time_format,
1602
+				current_time('timestamp')
1603
+			);
1604
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1605
+		}
1606
+		if (empty($template_args['TKT_end_date'])) {
1607
+			// get the earliest datetime (if present);
1608
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1609
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1610
+					'Datetime',
1611
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1612
+				)
1613
+				: null;
1614
+			if (! empty($earliest_dtt)) {
1615
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1616
+					'DTT_EVT_start',
1617
+					$this->_date_time_format
1618
+				);
1619
+			} else {
1620
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1621
+				$template_args['TKT_end_date'] = date(
1622
+					$this->_date_time_format,
1623
+					mktime(
1624
+						24,
1625
+						0,
1626
+						0,
1627
+						date('m'),
1628
+						date('d') + 29,
1629
+						date('Y')
1630
+					)
1631
+				);
1632
+			}
1633
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1634
+		}
1635
+		// generate ticket_datetime items
1636
+		if (! $default) {
1637
+			$datetime_row = 1;
1638
+			foreach ($all_datetimes as $datetime) {
1639
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1640
+					$datetime_row,
1641
+					$ticket_row,
1642
+					$datetime,
1643
+					$ticket,
1644
+					$ticket_datetimes,
1645
+					$default
1646
+				);
1647
+				$datetime_row++;
1648
+			}
1649
+		}
1650
+		$price_row = 1;
1651
+		foreach ($prices as $price) {
1652
+			if (! $price instanceof EE_Price) {
1653
+				continue;
1654
+			}
1655
+			if ($price->is_base_price()) {
1656
+				$price_row++;
1657
+				continue;
1658
+			}
1659
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1660
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1661
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1662
+				$ticket_row,
1663
+				$price_row,
1664
+				$price,
1665
+				$default,
1666
+				$ticket,
1667
+				$show_trash,
1668
+				$show_create
1669
+			);
1670
+			$price_row++;
1671
+		}
1672
+		// filter $template_args
1673
+		$template_args = apply_filters(
1674
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1675
+			$template_args,
1676
+			$ticket_row,
1677
+			$ticket,
1678
+			$ticket_datetimes,
1679
+			$all_datetimes,
1680
+			$default,
1681
+			$all_tickets,
1682
+			$this->_is_creating_event
1683
+		);
1684
+		return EEH_Template::display_template(
1685
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1686
+			$template_args,
1687
+			true
1688
+		);
1689
+	}
1690 1690
 
1691 1691
 
1692
-    /**
1693
-     * @param int            $ticket_row
1694
-     * @param EE_Ticket|null $ticket
1695
-     * @return string
1696
-     * @throws DomainException
1697
-     * @throws EE_Error
1698
-     */
1699
-    protected function _get_tax_rows($ticket_row, $ticket)
1700
-    {
1701
-        $tax_rows = '';
1702
-        /** @var EE_Price[] $taxes */
1703
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1704
-        foreach ($taxes as $tax) {
1705
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1706
-            $template_args = array(
1707
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1708
-                    ? ''
1709
-                    : ' style="display:none;"',
1710
-                'tax_id'            => $tax->ID(),
1711
-                'tkt_row'           => $ticket_row,
1712
-                'tax_label'         => $tax->get('PRC_name'),
1713
-                'tax_added'         => $tax_added,
1714
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1715
-                'tax_amount'        => $tax->get('PRC_amount'),
1716
-            );
1717
-            $template_args = apply_filters(
1718
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1719
-                $template_args,
1720
-                $ticket_row,
1721
-                $ticket,
1722
-                $this->_is_creating_event
1723
-            );
1724
-            $tax_rows .= EEH_Template::display_template(
1725
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1726
-                $template_args,
1727
-                true
1728
-            );
1729
-        }
1730
-        return $tax_rows;
1731
-    }
1692
+	/**
1693
+	 * @param int            $ticket_row
1694
+	 * @param EE_Ticket|null $ticket
1695
+	 * @return string
1696
+	 * @throws DomainException
1697
+	 * @throws EE_Error
1698
+	 */
1699
+	protected function _get_tax_rows($ticket_row, $ticket)
1700
+	{
1701
+		$tax_rows = '';
1702
+		/** @var EE_Price[] $taxes */
1703
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1704
+		foreach ($taxes as $tax) {
1705
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1706
+			$template_args = array(
1707
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1708
+					? ''
1709
+					: ' style="display:none;"',
1710
+				'tax_id'            => $tax->ID(),
1711
+				'tkt_row'           => $ticket_row,
1712
+				'tax_label'         => $tax->get('PRC_name'),
1713
+				'tax_added'         => $tax_added,
1714
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1715
+				'tax_amount'        => $tax->get('PRC_amount'),
1716
+			);
1717
+			$template_args = apply_filters(
1718
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1719
+				$template_args,
1720
+				$ticket_row,
1721
+				$ticket,
1722
+				$this->_is_creating_event
1723
+			);
1724
+			$tax_rows .= EEH_Template::display_template(
1725
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1726
+				$template_args,
1727
+				true
1728
+			);
1729
+		}
1730
+		return $tax_rows;
1731
+	}
1732 1732
 
1733 1733
 
1734
-    /**
1735
-     * @param EE_Price       $tax
1736
-     * @param EE_Ticket|null $ticket
1737
-     * @return float|int
1738
-     * @throws EE_Error
1739
-     */
1740
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1741
-    {
1742
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1743
-        return $subtotal * $tax->get('PRC_amount') / 100;
1744
-    }
1734
+	/**
1735
+	 * @param EE_Price       $tax
1736
+	 * @param EE_Ticket|null $ticket
1737
+	 * @return float|int
1738
+	 * @throws EE_Error
1739
+	 */
1740
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1741
+	{
1742
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1743
+		return $subtotal * $tax->get('PRC_amount') / 100;
1744
+	}
1745 1745
 
1746 1746
 
1747
-    /**
1748
-     * @param int            $ticket_row
1749
-     * @param int            $price_row
1750
-     * @param EE_Price|null  $price
1751
-     * @param bool           $default
1752
-     * @param EE_Ticket|null $ticket
1753
-     * @param bool           $show_trash
1754
-     * @param bool           $show_create
1755
-     * @return mixed
1756
-     * @throws InvalidArgumentException
1757
-     * @throws InvalidInterfaceException
1758
-     * @throws InvalidDataTypeException
1759
-     * @throws DomainException
1760
-     * @throws EE_Error
1761
-     * @throws ReflectionException
1762
-     */
1763
-    protected function _get_ticket_price_row(
1764
-        $ticket_row,
1765
-        $price_row,
1766
-        $price,
1767
-        $default,
1768
-        $ticket,
1769
-        $show_trash = true,
1770
-        $show_create = true
1771
-    ) {
1772
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1773
-        $template_args = array(
1774
-            'tkt_row'               => $default && empty($ticket)
1775
-                ? 'TICKETNUM'
1776
-                : $ticket_row,
1777
-            'PRC_order'             => $default && empty($price)
1778
-                ? 'PRICENUM'
1779
-                : $price_row,
1780
-            'edit_prices_name'      => $default && empty($price)
1781
-                ? 'PRICENAMEATTR'
1782
-                : 'edit_prices',
1783
-            'price_type_selector'   => $default && empty($price)
1784
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1785
-                : $this->_get_price_type_selector(
1786
-                    $ticket_row,
1787
-                    $price_row,
1788
-                    $price,
1789
-                    $default,
1790
-                    $send_disabled
1791
-                ),
1792
-            'PRC_ID'                => $default && empty($price)
1793
-                ? 0
1794
-                : $price->ID(),
1795
-            'PRC_is_default'        => $default && empty($price)
1796
-                ? 0
1797
-                : $price->get('PRC_is_default'),
1798
-            'PRC_name'              => $default && empty($price)
1799
-                ? ''
1800
-                : $price->get('PRC_name'),
1801
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1802
-            'show_plus_or_minus'    => $default && empty($price)
1803
-                ? ''
1804
-                : ' style="display:none;"',
1805
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1806
-                ? ' style="display:none;"'
1807
-                : '',
1808
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1809
-                ? ' style="display:none;"'
1810
-                : '',
1811
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1812
-                ? ' style="display:none"'
1813
-                : '',
1814
-            'PRC_amount'            => $default && empty($price)
1815
-                ? 0
1816
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1817
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1818
-                ? ' style="display:none;"'
1819
-                : '',
1820
-            'show_trash_icon'       => $show_trash
1821
-                ? ''
1822
-                : ' style="display:none;"',
1823
-            'show_create_button'    => $show_create
1824
-                ? ''
1825
-                : ' style="display:none;"',
1826
-            'PRC_desc'              => $default && empty($price)
1827
-                ? ''
1828
-                : $price->get('PRC_desc'),
1829
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1830
-        );
1831
-        $template_args = apply_filters(
1832
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1833
-            $template_args,
1834
-            $ticket_row,
1835
-            $price_row,
1836
-            $price,
1837
-            $default,
1838
-            $ticket,
1839
-            $show_trash,
1840
-            $show_create,
1841
-            $this->_is_creating_event
1842
-        );
1843
-        return EEH_Template::display_template(
1844
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1845
-            $template_args,
1846
-            true
1847
-        );
1848
-    }
1747
+	/**
1748
+	 * @param int            $ticket_row
1749
+	 * @param int            $price_row
1750
+	 * @param EE_Price|null  $price
1751
+	 * @param bool           $default
1752
+	 * @param EE_Ticket|null $ticket
1753
+	 * @param bool           $show_trash
1754
+	 * @param bool           $show_create
1755
+	 * @return mixed
1756
+	 * @throws InvalidArgumentException
1757
+	 * @throws InvalidInterfaceException
1758
+	 * @throws InvalidDataTypeException
1759
+	 * @throws DomainException
1760
+	 * @throws EE_Error
1761
+	 * @throws ReflectionException
1762
+	 */
1763
+	protected function _get_ticket_price_row(
1764
+		$ticket_row,
1765
+		$price_row,
1766
+		$price,
1767
+		$default,
1768
+		$ticket,
1769
+		$show_trash = true,
1770
+		$show_create = true
1771
+	) {
1772
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1773
+		$template_args = array(
1774
+			'tkt_row'               => $default && empty($ticket)
1775
+				? 'TICKETNUM'
1776
+				: $ticket_row,
1777
+			'PRC_order'             => $default && empty($price)
1778
+				? 'PRICENUM'
1779
+				: $price_row,
1780
+			'edit_prices_name'      => $default && empty($price)
1781
+				? 'PRICENAMEATTR'
1782
+				: 'edit_prices',
1783
+			'price_type_selector'   => $default && empty($price)
1784
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1785
+				: $this->_get_price_type_selector(
1786
+					$ticket_row,
1787
+					$price_row,
1788
+					$price,
1789
+					$default,
1790
+					$send_disabled
1791
+				),
1792
+			'PRC_ID'                => $default && empty($price)
1793
+				? 0
1794
+				: $price->ID(),
1795
+			'PRC_is_default'        => $default && empty($price)
1796
+				? 0
1797
+				: $price->get('PRC_is_default'),
1798
+			'PRC_name'              => $default && empty($price)
1799
+				? ''
1800
+				: $price->get('PRC_name'),
1801
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1802
+			'show_plus_or_minus'    => $default && empty($price)
1803
+				? ''
1804
+				: ' style="display:none;"',
1805
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1806
+				? ' style="display:none;"'
1807
+				: '',
1808
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1809
+				? ' style="display:none;"'
1810
+				: '',
1811
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1812
+				? ' style="display:none"'
1813
+				: '',
1814
+			'PRC_amount'            => $default && empty($price)
1815
+				? 0
1816
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1817
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1818
+				? ' style="display:none;"'
1819
+				: '',
1820
+			'show_trash_icon'       => $show_trash
1821
+				? ''
1822
+				: ' style="display:none;"',
1823
+			'show_create_button'    => $show_create
1824
+				? ''
1825
+				: ' style="display:none;"',
1826
+			'PRC_desc'              => $default && empty($price)
1827
+				? ''
1828
+				: $price->get('PRC_desc'),
1829
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1830
+		);
1831
+		$template_args = apply_filters(
1832
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1833
+			$template_args,
1834
+			$ticket_row,
1835
+			$price_row,
1836
+			$price,
1837
+			$default,
1838
+			$ticket,
1839
+			$show_trash,
1840
+			$show_create,
1841
+			$this->_is_creating_event
1842
+		);
1843
+		return EEH_Template::display_template(
1844
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1845
+			$template_args,
1846
+			true
1847
+		);
1848
+	}
1849 1849
 
1850 1850
 
1851
-    /**
1852
-     * @param int      $ticket_row
1853
-     * @param int      $price_row
1854
-     * @param EE_Price $price
1855
-     * @param bool     $default
1856
-     * @param bool     $disabled
1857
-     * @return mixed
1858
-     * @throws ReflectionException
1859
-     * @throws InvalidArgumentException
1860
-     * @throws InvalidInterfaceException
1861
-     * @throws InvalidDataTypeException
1862
-     * @throws DomainException
1863
-     * @throws EE_Error
1864
-     */
1865
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1866
-    {
1867
-        if ($price->is_base_price()) {
1868
-            return $this->_get_base_price_template(
1869
-                $ticket_row,
1870
-                $price_row,
1871
-                $price,
1872
-                $default
1873
-            );
1874
-        }
1875
-        return $this->_get_price_modifier_template(
1876
-            $ticket_row,
1877
-            $price_row,
1878
-            $price,
1879
-            $default,
1880
-            $disabled
1881
-        );
1882
-    }
1851
+	/**
1852
+	 * @param int      $ticket_row
1853
+	 * @param int      $price_row
1854
+	 * @param EE_Price $price
1855
+	 * @param bool     $default
1856
+	 * @param bool     $disabled
1857
+	 * @return mixed
1858
+	 * @throws ReflectionException
1859
+	 * @throws InvalidArgumentException
1860
+	 * @throws InvalidInterfaceException
1861
+	 * @throws InvalidDataTypeException
1862
+	 * @throws DomainException
1863
+	 * @throws EE_Error
1864
+	 */
1865
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1866
+	{
1867
+		if ($price->is_base_price()) {
1868
+			return $this->_get_base_price_template(
1869
+				$ticket_row,
1870
+				$price_row,
1871
+				$price,
1872
+				$default
1873
+			);
1874
+		}
1875
+		return $this->_get_price_modifier_template(
1876
+			$ticket_row,
1877
+			$price_row,
1878
+			$price,
1879
+			$default,
1880
+			$disabled
1881
+		);
1882
+	}
1883 1883
 
1884 1884
 
1885
-    /**
1886
-     * @param int      $ticket_row
1887
-     * @param int      $price_row
1888
-     * @param EE_Price $price
1889
-     * @param bool     $default
1890
-     * @return mixed
1891
-     * @throws DomainException
1892
-     * @throws EE_Error
1893
-     */
1894
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1895
-    {
1896
-        $template_args = array(
1897
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1898
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1899
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1900
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1901
-            'price_selected_operator'   => '+',
1902
-            'price_selected_is_percent' => 0,
1903
-        );
1904
-        $template_args = apply_filters(
1905
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1906
-            $template_args,
1907
-            $ticket_row,
1908
-            $price_row,
1909
-            $price,
1910
-            $default,
1911
-            $this->_is_creating_event
1912
-        );
1913
-        return EEH_Template::display_template(
1914
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1915
-            $template_args,
1916
-            true
1917
-        );
1918
-    }
1885
+	/**
1886
+	 * @param int      $ticket_row
1887
+	 * @param int      $price_row
1888
+	 * @param EE_Price $price
1889
+	 * @param bool     $default
1890
+	 * @return mixed
1891
+	 * @throws DomainException
1892
+	 * @throws EE_Error
1893
+	 */
1894
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1895
+	{
1896
+		$template_args = array(
1897
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1898
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1899
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1900
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1901
+			'price_selected_operator'   => '+',
1902
+			'price_selected_is_percent' => 0,
1903
+		);
1904
+		$template_args = apply_filters(
1905
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1906
+			$template_args,
1907
+			$ticket_row,
1908
+			$price_row,
1909
+			$price,
1910
+			$default,
1911
+			$this->_is_creating_event
1912
+		);
1913
+		return EEH_Template::display_template(
1914
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1915
+			$template_args,
1916
+			true
1917
+		);
1918
+	}
1919 1919
 
1920 1920
 
1921
-    /**
1922
-     * @param int      $ticket_row
1923
-     * @param int      $price_row
1924
-     * @param EE_Price $price
1925
-     * @param bool     $default
1926
-     * @param bool     $disabled
1927
-     * @return mixed
1928
-     * @throws ReflectionException
1929
-     * @throws InvalidArgumentException
1930
-     * @throws InvalidInterfaceException
1931
-     * @throws InvalidDataTypeException
1932
-     * @throws DomainException
1933
-     * @throws EE_Error
1934
-     */
1935
-    protected function _get_price_modifier_template(
1936
-        $ticket_row,
1937
-        $price_row,
1938
-        $price,
1939
-        $default,
1940
-        $disabled = false
1941
-    ) {
1942
-        $select_name = $default && ! $price instanceof EE_Price
1943
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1944
-            : 'edit_prices[' . $ticket_row . '][' . $price_row . '][PRT_ID]';
1945
-        /** @var EEM_Price_Type $price_type_model */
1946
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1947
-        $price_types = $price_type_model->get_all(array(
1948
-            array(
1949
-                'OR' => array(
1950
-                    'PBT_ID'  => '2',
1951
-                    'PBT_ID*' => '3',
1952
-                ),
1953
-            ),
1954
-        ));
1955
-        $all_price_types = $default && ! $price instanceof EE_Price
1956
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1957
-            : array();
1958
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1959
-        $price_option_spans = '';
1960
-        // setup price types for selector
1961
-        foreach ($price_types as $price_type) {
1962
-            if (! $price_type instanceof EE_Price_Type) {
1963
-                continue;
1964
-            }
1965
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1966
-            // while we're in the loop let's setup the option spans used by js
1967
-            $span_args = array(
1968
-                'PRT_ID'         => $price_type->ID(),
1969
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1970
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1971
-            );
1972
-            $price_option_spans .= EEH_Template::display_template(
1973
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1974
-                $span_args,
1975
-                true
1976
-            );
1977
-        }
1978
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1979
-            : $select_name;
1980
-        $select_input = new EE_Select_Input(
1981
-            $all_price_types,
1982
-            array(
1983
-                'default'               => $selected_price_type_id,
1984
-                'html_name'             => $select_name,
1985
-                'html_class'            => 'edit-price-PRT_ID',
1986
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1987
-            )
1988
-        );
1989
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1990
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1991
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1992
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1993
-        $template_args = array(
1994
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1995
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1996
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1997
-            'main_name'                 => $select_name,
1998
-            'selected_price_type_id'    => $selected_price_type_id,
1999
-            'price_option_spans'        => $price_option_spans,
2000
-            'price_selected_operator'   => $price_selected_operator,
2001
-            'price_selected_is_percent' => $price_selected_is_percent,
2002
-            'disabled'                  => $disabled,
2003
-        );
2004
-        $template_args = apply_filters(
2005
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2006
-            $template_args,
2007
-            $ticket_row,
2008
-            $price_row,
2009
-            $price,
2010
-            $default,
2011
-            $disabled,
2012
-            $this->_is_creating_event
2013
-        );
2014
-        return EEH_Template::display_template(
2015
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2016
-            $template_args,
2017
-            true
2018
-        );
2019
-    }
1921
+	/**
1922
+	 * @param int      $ticket_row
1923
+	 * @param int      $price_row
1924
+	 * @param EE_Price $price
1925
+	 * @param bool     $default
1926
+	 * @param bool     $disabled
1927
+	 * @return mixed
1928
+	 * @throws ReflectionException
1929
+	 * @throws InvalidArgumentException
1930
+	 * @throws InvalidInterfaceException
1931
+	 * @throws InvalidDataTypeException
1932
+	 * @throws DomainException
1933
+	 * @throws EE_Error
1934
+	 */
1935
+	protected function _get_price_modifier_template(
1936
+		$ticket_row,
1937
+		$price_row,
1938
+		$price,
1939
+		$default,
1940
+		$disabled = false
1941
+	) {
1942
+		$select_name = $default && ! $price instanceof EE_Price
1943
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1944
+			: 'edit_prices[' . $ticket_row . '][' . $price_row . '][PRT_ID]';
1945
+		/** @var EEM_Price_Type $price_type_model */
1946
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1947
+		$price_types = $price_type_model->get_all(array(
1948
+			array(
1949
+				'OR' => array(
1950
+					'PBT_ID'  => '2',
1951
+					'PBT_ID*' => '3',
1952
+				),
1953
+			),
1954
+		));
1955
+		$all_price_types = $default && ! $price instanceof EE_Price
1956
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1957
+			: array();
1958
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1959
+		$price_option_spans = '';
1960
+		// setup price types for selector
1961
+		foreach ($price_types as $price_type) {
1962
+			if (! $price_type instanceof EE_Price_Type) {
1963
+				continue;
1964
+			}
1965
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1966
+			// while we're in the loop let's setup the option spans used by js
1967
+			$span_args = array(
1968
+				'PRT_ID'         => $price_type->ID(),
1969
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1970
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1971
+			);
1972
+			$price_option_spans .= EEH_Template::display_template(
1973
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1974
+				$span_args,
1975
+				true
1976
+			);
1977
+		}
1978
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1979
+			: $select_name;
1980
+		$select_input = new EE_Select_Input(
1981
+			$all_price_types,
1982
+			array(
1983
+				'default'               => $selected_price_type_id,
1984
+				'html_name'             => $select_name,
1985
+				'html_class'            => 'edit-price-PRT_ID',
1986
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1987
+			)
1988
+		);
1989
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1990
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1991
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1992
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1993
+		$template_args = array(
1994
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1995
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1996
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1997
+			'main_name'                 => $select_name,
1998
+			'selected_price_type_id'    => $selected_price_type_id,
1999
+			'price_option_spans'        => $price_option_spans,
2000
+			'price_selected_operator'   => $price_selected_operator,
2001
+			'price_selected_is_percent' => $price_selected_is_percent,
2002
+			'disabled'                  => $disabled,
2003
+		);
2004
+		$template_args = apply_filters(
2005
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2006
+			$template_args,
2007
+			$ticket_row,
2008
+			$price_row,
2009
+			$price,
2010
+			$default,
2011
+			$disabled,
2012
+			$this->_is_creating_event
2013
+		);
2014
+		return EEH_Template::display_template(
2015
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2016
+			$template_args,
2017
+			true
2018
+		);
2019
+	}
2020 2020
 
2021 2021
 
2022
-    /**
2023
-     * @param int              $datetime_row
2024
-     * @param int              $ticket_row
2025
-     * @param EE_Datetime|null $datetime
2026
-     * @param EE_Ticket|null   $ticket
2027
-     * @param array            $ticket_datetimes
2028
-     * @param bool             $default
2029
-     * @return mixed
2030
-     * @throws DomainException
2031
-     * @throws EE_Error
2032
-     */
2033
-    protected function _get_ticket_datetime_list_item(
2034
-        $datetime_row,
2035
-        $ticket_row,
2036
-        $datetime,
2037
-        $ticket,
2038
-        $ticket_datetimes = array(),
2039
-        $default
2040
-    ) {
2041
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2042
-            ? $ticket_datetimes[ $ticket->ID() ]
2043
-            : array();
2044
-        $template_args = array(
2045
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2046
-                ? 'DTTNUM'
2047
-                : $datetime_row,
2048
-            'tkt_row'                  => $default
2049
-                ? 'TICKETNUM'
2050
-                : $ticket_row,
2051
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2052
-                ? ' ticket-selected'
2053
-                : '',
2054
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2055
-                ? ' checked="checked"'
2056
-                : '',
2057
-            'DTT_name'                 => $default && empty($datetime)
2058
-                ? 'DTTNAME'
2059
-                : $datetime->get_dtt_display_name(true),
2060
-            'tkt_status_class'         => '',
2061
-        );
2062
-        $template_args = apply_filters(
2063
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2064
-            $template_args,
2065
-            $datetime_row,
2066
-            $ticket_row,
2067
-            $datetime,
2068
-            $ticket,
2069
-            $ticket_datetimes,
2070
-            $default,
2071
-            $this->_is_creating_event
2072
-        );
2073
-        return EEH_Template::display_template(
2074
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2075
-            $template_args,
2076
-            true
2077
-        );
2078
-    }
2022
+	/**
2023
+	 * @param int              $datetime_row
2024
+	 * @param int              $ticket_row
2025
+	 * @param EE_Datetime|null $datetime
2026
+	 * @param EE_Ticket|null   $ticket
2027
+	 * @param array            $ticket_datetimes
2028
+	 * @param bool             $default
2029
+	 * @return mixed
2030
+	 * @throws DomainException
2031
+	 * @throws EE_Error
2032
+	 */
2033
+	protected function _get_ticket_datetime_list_item(
2034
+		$datetime_row,
2035
+		$ticket_row,
2036
+		$datetime,
2037
+		$ticket,
2038
+		$ticket_datetimes = array(),
2039
+		$default
2040
+	) {
2041
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2042
+			? $ticket_datetimes[ $ticket->ID() ]
2043
+			: array();
2044
+		$template_args = array(
2045
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2046
+				? 'DTTNUM'
2047
+				: $datetime_row,
2048
+			'tkt_row'                  => $default
2049
+				? 'TICKETNUM'
2050
+				: $ticket_row,
2051
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2052
+				? ' ticket-selected'
2053
+				: '',
2054
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2055
+				? ' checked="checked"'
2056
+				: '',
2057
+			'DTT_name'                 => $default && empty($datetime)
2058
+				? 'DTTNAME'
2059
+				: $datetime->get_dtt_display_name(true),
2060
+			'tkt_status_class'         => '',
2061
+		);
2062
+		$template_args = apply_filters(
2063
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2064
+			$template_args,
2065
+			$datetime_row,
2066
+			$ticket_row,
2067
+			$datetime,
2068
+			$ticket,
2069
+			$ticket_datetimes,
2070
+			$default,
2071
+			$this->_is_creating_event
2072
+		);
2073
+		return EEH_Template::display_template(
2074
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2075
+			$template_args,
2076
+			true
2077
+		);
2078
+	}
2079 2079
 
2080 2080
 
2081
-    /**
2082
-     * @param array $all_datetimes
2083
-     * @param array $all_tickets
2084
-     * @return mixed
2085
-     * @throws ReflectionException
2086
-     * @throws InvalidArgumentException
2087
-     * @throws InvalidInterfaceException
2088
-     * @throws InvalidDataTypeException
2089
-     * @throws DomainException
2090
-     * @throws EE_Error
2091
-     */
2092
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2093
-    {
2094
-        $template_args = array(
2095
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2096
-                'DTTNUM',
2097
-                null,
2098
-                true,
2099
-                $all_datetimes
2100
-            ),
2101
-            'default_ticket_row'                       => $this->_get_ticket_row(
2102
-                'TICKETNUM',
2103
-                null,
2104
-                array(),
2105
-                array(),
2106
-                true
2107
-            ),
2108
-            'default_price_row'                        => $this->_get_ticket_price_row(
2109
-                'TICKETNUM',
2110
-                'PRICENUM',
2111
-                null,
2112
-                true,
2113
-                null
2114
-            ),
2115
-            'default_price_rows'                       => '',
2116
-            'default_base_price_amount'                => 0,
2117
-            'default_base_price_name'                  => '',
2118
-            'default_base_price_description'           => '',
2119
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2120
-                'TICKETNUM',
2121
-                'PRICENUM',
2122
-                null,
2123
-                true
2124
-            ),
2125
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2126
-                'DTTNUM',
2127
-                null,
2128
-                array(),
2129
-                array(),
2130
-                true
2131
-            ),
2132
-            'existing_available_datetime_tickets_list' => '',
2133
-            'existing_available_ticket_datetimes_list' => '',
2134
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2135
-                'DTTNUM',
2136
-                'TICKETNUM',
2137
-                null,
2138
-                null,
2139
-                array(),
2140
-                true
2141
-            ),
2142
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2143
-                'DTTNUM',
2144
-                'TICKETNUM',
2145
-                null,
2146
-                null,
2147
-                array(),
2148
-                true
2149
-            ),
2150
-        );
2151
-        $ticket_row = 1;
2152
-        foreach ($all_tickets as $ticket) {
2153
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2154
-                'DTTNUM',
2155
-                $ticket_row,
2156
-                null,
2157
-                $ticket,
2158
-                array(),
2159
-                true
2160
-            );
2161
-            $ticket_row++;
2162
-        }
2163
-        $datetime_row = 1;
2164
-        foreach ($all_datetimes as $datetime) {
2165
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2166
-                $datetime_row,
2167
-                'TICKETNUM',
2168
-                $datetime,
2169
-                null,
2170
-                array(),
2171
-                true
2172
-            );
2173
-            $datetime_row++;
2174
-        }
2175
-        /** @var EEM_Price $price_model */
2176
-        $price_model = EE_Registry::instance()->load_model('Price');
2177
-        $default_prices = $price_model->get_all_default_prices();
2178
-        $price_row = 1;
2179
-        foreach ($default_prices as $price) {
2180
-            if (! $price instanceof EE_Price) {
2181
-                continue;
2182
-            }
2183
-            if ($price->is_base_price()) {
2184
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2185
-                    'PRC_amount',
2186
-                    'localized_float'
2187
-                );
2188
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2189
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2190
-                $price_row++;
2191
-                continue;
2192
-            }
2193
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2194
-                             || count($default_prices) === 1);
2195
-            $show_create = ! (count($default_prices) > 1
2196
-                              && count($default_prices)
2197
-                                 !== $price_row);
2198
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2199
-                'TICKETNUM',
2200
-                $price_row,
2201
-                $price,
2202
-                true,
2203
-                null,
2204
-                $show_trash,
2205
-                $show_create
2206
-            );
2207
-            $price_row++;
2208
-        }
2209
-        $template_args = apply_filters(
2210
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2211
-            $template_args,
2212
-            $all_datetimes,
2213
-            $all_tickets,
2214
-            $this->_is_creating_event
2215
-        );
2216
-        return EEH_Template::display_template(
2217
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2218
-            $template_args,
2219
-            true
2220
-        );
2221
-    }
2081
+	/**
2082
+	 * @param array $all_datetimes
2083
+	 * @param array $all_tickets
2084
+	 * @return mixed
2085
+	 * @throws ReflectionException
2086
+	 * @throws InvalidArgumentException
2087
+	 * @throws InvalidInterfaceException
2088
+	 * @throws InvalidDataTypeException
2089
+	 * @throws DomainException
2090
+	 * @throws EE_Error
2091
+	 */
2092
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2093
+	{
2094
+		$template_args = array(
2095
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2096
+				'DTTNUM',
2097
+				null,
2098
+				true,
2099
+				$all_datetimes
2100
+			),
2101
+			'default_ticket_row'                       => $this->_get_ticket_row(
2102
+				'TICKETNUM',
2103
+				null,
2104
+				array(),
2105
+				array(),
2106
+				true
2107
+			),
2108
+			'default_price_row'                        => $this->_get_ticket_price_row(
2109
+				'TICKETNUM',
2110
+				'PRICENUM',
2111
+				null,
2112
+				true,
2113
+				null
2114
+			),
2115
+			'default_price_rows'                       => '',
2116
+			'default_base_price_amount'                => 0,
2117
+			'default_base_price_name'                  => '',
2118
+			'default_base_price_description'           => '',
2119
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2120
+				'TICKETNUM',
2121
+				'PRICENUM',
2122
+				null,
2123
+				true
2124
+			),
2125
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2126
+				'DTTNUM',
2127
+				null,
2128
+				array(),
2129
+				array(),
2130
+				true
2131
+			),
2132
+			'existing_available_datetime_tickets_list' => '',
2133
+			'existing_available_ticket_datetimes_list' => '',
2134
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2135
+				'DTTNUM',
2136
+				'TICKETNUM',
2137
+				null,
2138
+				null,
2139
+				array(),
2140
+				true
2141
+			),
2142
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2143
+				'DTTNUM',
2144
+				'TICKETNUM',
2145
+				null,
2146
+				null,
2147
+				array(),
2148
+				true
2149
+			),
2150
+		);
2151
+		$ticket_row = 1;
2152
+		foreach ($all_tickets as $ticket) {
2153
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2154
+				'DTTNUM',
2155
+				$ticket_row,
2156
+				null,
2157
+				$ticket,
2158
+				array(),
2159
+				true
2160
+			);
2161
+			$ticket_row++;
2162
+		}
2163
+		$datetime_row = 1;
2164
+		foreach ($all_datetimes as $datetime) {
2165
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2166
+				$datetime_row,
2167
+				'TICKETNUM',
2168
+				$datetime,
2169
+				null,
2170
+				array(),
2171
+				true
2172
+			);
2173
+			$datetime_row++;
2174
+		}
2175
+		/** @var EEM_Price $price_model */
2176
+		$price_model = EE_Registry::instance()->load_model('Price');
2177
+		$default_prices = $price_model->get_all_default_prices();
2178
+		$price_row = 1;
2179
+		foreach ($default_prices as $price) {
2180
+			if (! $price instanceof EE_Price) {
2181
+				continue;
2182
+			}
2183
+			if ($price->is_base_price()) {
2184
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2185
+					'PRC_amount',
2186
+					'localized_float'
2187
+				);
2188
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2189
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2190
+				$price_row++;
2191
+				continue;
2192
+			}
2193
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2194
+							 || count($default_prices) === 1);
2195
+			$show_create = ! (count($default_prices) > 1
2196
+							  && count($default_prices)
2197
+								 !== $price_row);
2198
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2199
+				'TICKETNUM',
2200
+				$price_row,
2201
+				$price,
2202
+				true,
2203
+				null,
2204
+				$show_trash,
2205
+				$show_create
2206
+			);
2207
+			$price_row++;
2208
+		}
2209
+		$template_args = apply_filters(
2210
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2211
+			$template_args,
2212
+			$all_datetimes,
2213
+			$all_tickets,
2214
+			$this->_is_creating_event
2215
+		);
2216
+		return EEH_Template::display_template(
2217
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2218
+			$template_args,
2219
+			true
2220
+		);
2221
+	}
2222 2222
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             );
151 151
             $msg .= '</p><ul>';
152 152
             foreach ($format_validation as $error) {
153
-                $msg .= '<li>' . $error . '</li>';
153
+                $msg .= '<li>'.$error.'</li>';
154 154
             }
155 155
             $msg .= '</ul><p>';
156 156
             $msg .= sprintf(
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         $this->_scripts_styles = array(
180 180
             'registers'   => array(
181 181
                 'ee-tickets-datetimes-css' => array(
182
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
182
+                    'url'  => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
183 183
                     'type' => 'css',
184 184
                 ),
185 185
                 'ee-dtt-ticket-metabox'    => array(
186
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
186
+                    'url'     => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
187 187
                     'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188 188
                 ),
189 189
             ),
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
                             'event_espresso'
208 208
                         ),
209 209
                         'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
210
+                                                     . esc_html__('Cancel', 'event_espresso').'</button>',
211 211
                         'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
212
+                                                     . esc_html__('Close', 'event_espresso').'</button>',
213 213
                         'single_warning_from_tkt' => esc_html__(
214 214
                             'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215 215
                             'event_espresso'
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                             'event_espresso'
220 220
                         ),
221 221
                         'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
222
+                                                     . esc_html__('Dismiss', 'event_espresso').'</button>',
223 223
                     ),
224 224
                     'DTT_ERROR_MSG'         => array(
225 225
                         'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     {
258 258
         foreach ($update_callbacks as $key => $callback) {
259 259
             if ($callback[1] === '_default_tickets_update') {
260
-                unset($update_callbacks[ $key ]);
260
+                unset($update_callbacks[$key]);
261 261
             }
262 262
         }
263 263
         $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316 316
             // trim all values to ensure any excess whitespace is removed.
317 317
             $datetime_data = array_map(
318
-                function ($datetime_data) {
318
+                function($datetime_data) {
319 319
                     return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320 320
                 },
321 321
                 $datetime_data
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             );
346 346
             // if we have an id then let's get existing object first and then set the new values.
347 347
             // Otherwise we instantiate a new object for save.
348
-            if (! empty($datetime_data['DTT_ID'])) {
348
+            if ( ! empty($datetime_data['DTT_ID'])) {
349 349
                 $datetime = EE_Registry::instance()
350 350
                                        ->load_model('Datetime', array($timezone))
351 351
                                        ->get_one_by_ID($datetime_data['DTT_ID']);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                 // after the add_relation_to() the autosave replaces it.
360 360
                 // We need to do this so we dont' TRASH the parent DTT.
361 361
                 // (save the ID for both key and value to avoid duplications)
362
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
362
+                $saved_dtt_ids[$datetime->ID()] = $datetime->ID();
363 363
             } else {
364 364
                 $datetime = EE_Registry::instance()->load_class(
365 365
                     'Datetime',
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
             // because it is possible there was a new one created for the autosave.
389 389
             // (save the ID for both key and value to avoid duplications)
390 390
             $DTT_ID = $datetime->ID();
391
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
392
-            $saved_dtt_objs[ $row ] = $datetime;
391
+            $saved_dtt_ids[$DTT_ID] = $DTT_ID;
392
+            $saved_dtt_objs[$row] = $datetime;
393 393
             // @todo if ANY of these updates fail then we want the appropriate global error message.
394 394
         }
395 395
         $event->save();
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
             $update_prices = $create_new_TKT = false;
455 455
             // figure out what datetimes were added to the ticket
456 456
             // and what datetimes were removed from the ticket in the session.
457
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
458
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
457
+            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
458
+            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
459 459
             $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
460 460
             $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
461 461
             // trim inputs to ensure any excess whitespace is removed.
462 462
             $tkt = array_map(
463
-                function ($ticket_data) {
463
+                function($ticket_data) {
464 464
                     return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
465 465
                 },
466 466
                 $tkt
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
             $base_price_id = isset($tkt['TKT_base_price_ID'])
483 483
                 ? $tkt['TKT_base_price_ID']
484 484
                 : 0;
485
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
486
-                ? $data['edit_prices'][ $row ]
485
+            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row])
486
+                ? $data['edit_prices'][$row]
487 487
                 : array();
488 488
             $now = null;
489 489
             if (empty($tkt['TKT_start_date'])) {
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                 /**
496 496
                  * set the TKT_end_date to the first datetime attached to the ticket.
497 497
                  */
498
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
498
+                $first_dtt = $saved_datetimes[reset($tkt_dtt_rows)];
499 499
                 $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
500 500
             }
501 501
             $TKT_values = array(
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             // need to make sue that the TKT_price is accurate after saving the prices.
631 631
             $ticket->ensure_TKT_Price_correct();
632 632
             // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
633
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
633
+            if ( ! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
634 634
                 $update_prices = true;
635 635
                 $new_default = clone $ticket;
636 636
                 $new_default->set('TKT_ID', 0);
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 // save new TKT
676 676
                 $new_tkt->save();
677 677
                 // add new ticket to array
678
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
678
+                $saved_tickets[$new_tkt->ID()] = $new_tkt;
679 679
                 do_action(
680 680
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
681 681
                     $new_tkt,
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
                 );
686 686
             } else {
687 687
                 // add tkt to saved tkts
688
-                $saved_tickets[ $ticket->ID() ] = $ticket;
688
+                $saved_tickets[$ticket->ID()] = $ticket;
689 689
                 do_action(
690 690
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
691 691
                     $ticket,
@@ -752,31 +752,31 @@  discard block
 block discarded – undo
752 752
         // to start we have to add the ticket to all the datetimes its supposed to be with,
753 753
         // and removing the ticket from datetimes it got removed from.
754 754
         // first let's add datetimes
755
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
755
+        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
756 756
             foreach ($added_datetimes as $row_id) {
757 757
                 $row_id = (int) $row_id;
758
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
759
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
758
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
759
+                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
760 760
                     // Is this an existing ticket (has an ID) and does it have any sold?
761 761
                     // If so, then we need to add that to the DTT sold because this DTT is getting added.
762 762
                     if ($ticket->ID() && $ticket->sold() > 0) {
763
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
763
+                        $saved_datetimes[$row_id]->increaseSold($ticket->sold(), false);
764 764
                     }
765 765
                 }
766 766
             }
767 767
         }
768 768
         // then remove datetimes
769
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
769
+        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
770 770
             foreach ($removed_datetimes as $row_id) {
771 771
                 $row_id = (int) $row_id;
772 772
                 // its entirely possible that a datetime got deleted (instead of just removed from relationship.
773 773
                 // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
774
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
775
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
774
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
775
+                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
776 776
                     // Is this an existing ticket (has an ID) and does it have any sold?
777 777
                     // If so, then we need to remove it's sold from the DTT_sold.
778 778
                     if ($ticket->ID() && $ticket->sold() > 0) {
779
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
779
+                        $saved_datetimes[$row_id]->decreaseSold($ticket->sold());
780 780
                     }
781 781
                 }
782 782
             }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
             );
890 890
         }
891 891
         // possibly need to save tkt
892
-        if (! $ticket->ID()) {
892
+        if ( ! $ticket->ID()) {
893 893
             $ticket->save();
894 894
         }
895 895
         foreach ($prices as $row => $prc) {
@@ -923,17 +923,17 @@  discard block
 block discarded – undo
923 923
                 }
924 924
             }
925 925
             $price->save();
926
-            $updated_prices[ $price->ID() ] = $price;
926
+            $updated_prices[$price->ID()] = $price;
927 927
             $ticket->_add_relation_to($price, 'Price');
928 928
         }
929 929
         // now let's remove any prices that got removed from the ticket
930
-        if (! empty($current_prices_on_ticket)) {
930
+        if ( ! empty($current_prices_on_ticket)) {
931 931
             $current = array_keys($current_prices_on_ticket);
932 932
             $updated = array_keys($updated_prices);
933 933
             $prices_to_remove = array_diff($current, $updated);
934
-            if (! empty($prices_to_remove)) {
934
+            if ( ! empty($prices_to_remove)) {
935 935
                 foreach ($prices_to_remove as $prc_id) {
936
-                    $p = $current_prices_on_ticket[ $prc_id ];
936
+                    $p = $current_prices_on_ticket[$prc_id];
937 937
                     $ticket->_remove_relation_to($p, 'Price');
938 938
                     // delete permanently the price
939 939
                     $p->delete_permanently();
@@ -1084,17 +1084,17 @@  discard block
 block discarded – undo
1084 1084
                 $TKT_ID = $ticket->get('TKT_ID');
1085 1085
                 $ticket_row = $ticket->get('TKT_row');
1086 1086
                 // we only want unique tickets in our final display!!
1087
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1087
+                if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) {
1088 1088
                     $existing_ticket_ids[] = $TKT_ID;
1089 1089
                     $all_tickets[] = $ticket;
1090 1090
                 }
1091 1091
                 // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1092
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1092
+                $datetime_tickets[$DTT_ID][] = $ticket_row;
1093 1093
                 // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1094
-                if (! isset($ticket_datetimes[ $TKT_ID ])
1095
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1094
+                if ( ! isset($ticket_datetimes[$TKT_ID])
1095
+                    || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true)
1096 1096
                 ) {
1097
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1097
+                    $ticket_datetimes[$TKT_ID][] = $datetime_row;
1098 1098
                 }
1099 1099
             }
1100 1100
             $datetime_row++;
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
         // sort $all_tickets by order
1106 1106
         usort(
1107 1107
             $all_tickets,
1108
-            function (EE_Ticket $a, EE_Ticket $b) {
1108
+            function(EE_Ticket $a, EE_Ticket $b) {
1109 1109
                 $a_order = (int) $a->get('TKT_order');
1110 1110
                 $b_order = (int) $b->get('TKT_order');
1111 1111
                 if ($a_order === $b_order) {
@@ -1146,16 +1146,16 @@  discard block
 block discarded – undo
1146 1146
         $status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1147 1147
             'EventEspresso\core\admin\StatusChangeNotice'
1148 1148
         );
1149
-        if (! $status_change_notice->isDismissed()) {
1149
+        if ( ! $status_change_notice->isDismissed()) {
1150 1150
             $main_template_args['status_change_notice'] = EEH_Template::display_template(
1151
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
1151
+                EE_ADMIN_TEMPLATE.'status_change_notice.template.php',
1152 1152
                 ['context' => '__event-editor', 'page_slug' => 'espresso-events'],
1153 1153
                 true
1154 1154
             );
1155 1155
         }
1156 1156
 
1157 1157
         EEH_Template::display_template(
1158
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1158
+            PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php',
1159 1159
             $main_template_args
1160 1160
         );
1161 1161
     }
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
             'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1198 1198
         );
1199 1199
         return EEH_Template::display_template(
1200
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1200
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php',
1201 1201
             $dtt_display_template_args,
1202 1202
             true
1203 1203
         );
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
             $this->_is_creating_event
1267 1267
         );
1268 1268
         return EEH_Template::display_template(
1269
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1269
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php',
1270 1270
             $template_args,
1271 1271
             true
1272 1272
         );
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
             'DTT_ID'                            => $default ? '' : $datetime->ID(),
1308 1308
         );
1309 1309
         // need to setup the list items (but only if this isn't a default skeleton setup)
1310
-        if (! $default) {
1310
+        if ( ! $default) {
1311 1311
             $ticket_row = 1;
1312 1312
             foreach ($all_tickets as $ticket) {
1313 1313
                 $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
             $this->_is_creating_event
1334 1334
         );
1335 1335
         return EEH_Template::display_template(
1336
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1336
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php',
1337 1337
             $template_args,
1338 1338
             true
1339 1339
         );
@@ -1359,8 +1359,8 @@  discard block
 block discarded – undo
1359 1359
         $datetime_tickets = array(),
1360 1360
         $default
1361 1361
     ) {
1362
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1363
-            ? $datetime_tickets[ $datetime->ID() ]
1362
+        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()])
1363
+            ? $datetime_tickets[$datetime->ID()]
1364 1364
             : array();
1365 1365
         $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1366 1366
         $no_ticket = $default && empty($ticket);
@@ -1381,8 +1381,8 @@  discard block
 block discarded – undo
1381 1381
                 ? 'TKTNAME'
1382 1382
                 : $ticket->get('TKT_name'),
1383 1383
             'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1384
-                ? ' tkt-status-' . EE_Ticket::onsale
1385
-                : ' tkt-status-' . $ticket->ticket_status(),
1384
+                ? ' tkt-status-'.EE_Ticket::onsale
1385
+                : ' tkt-status-'.$ticket->ticket_status(),
1386 1386
         );
1387 1387
         // filter template args
1388 1388
         $template_args = apply_filters(
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
             $this->_is_creating_event
1398 1398
         );
1399 1399
         return EEH_Template::display_template(
1400
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1400
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php',
1401 1401
             $template_args,
1402 1402
             true
1403 1403
         );
@@ -1453,19 +1453,19 @@  discard block
 block discarded – undo
1453 1453
         // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1454 1454
         // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1455 1455
         $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1456
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1457
-            ? $ticket_datetimes[ $ticket->ID() ]
1456
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
1457
+            ? $ticket_datetimes[$ticket->ID()]
1458 1458
             : array();
1459 1459
         $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1460 1460
         $base_price = $default ? null : $ticket->base_price();
1461 1461
         $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1462 1462
         // breaking out complicated condition for ticket_status
1463 1463
         if ($default) {
1464
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1464
+            $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1465 1465
         } else {
1466 1466
             $ticket_status_class = $ticket->is_default()
1467
-                ? ' tkt-status-' . EE_Ticket::onsale
1468
-                : ' tkt-status-' . $ticket->ticket_status();
1467
+                ? ' tkt-status-'.EE_Ticket::onsale
1468
+                : ' tkt-status-'.$ticket->ticket_status();
1469 1469
         }
1470 1470
         // breaking out complicated condition for TKT_taxable
1471 1471
         if ($default) {
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
                 : ' style="display:none;"',
1558 1558
             'show_price_mod_button'         => count($prices) > 1
1559 1559
                                                || ($default && $count_price_mods > 0)
1560
-                                               || (! $default && $ticket->deleted())
1560
+                                               || ( ! $default && $ticket->deleted())
1561 1561
                 ? ' style="display:none;"'
1562 1562
                 : '',
1563 1563
             'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
                 $this->_date_time_format,
1602 1602
                 current_time('timestamp')
1603 1603
             );
1604
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1604
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1605 1605
         }
1606 1606
         if (empty($template_args['TKT_end_date'])) {
1607 1607
             // get the earliest datetime (if present);
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
                     array('order_by' => array('DTT_EVT_start' => 'ASC'))
1612 1612
                 )
1613 1613
                 : null;
1614
-            if (! empty($earliest_dtt)) {
1614
+            if ( ! empty($earliest_dtt)) {
1615 1615
                 $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1616 1616
                     'DTT_EVT_start',
1617 1617
                     $this->_date_time_format
@@ -1630,10 +1630,10 @@  discard block
 block discarded – undo
1630 1630
                     )
1631 1631
                 );
1632 1632
             }
1633
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1633
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1634 1634
         }
1635 1635
         // generate ticket_datetime items
1636
-        if (! $default) {
1636
+        if ( ! $default) {
1637 1637
             $datetime_row = 1;
1638 1638
             foreach ($all_datetimes as $datetime) {
1639 1639
                 $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
         }
1650 1650
         $price_row = 1;
1651 1651
         foreach ($prices as $price) {
1652
-            if (! $price instanceof EE_Price) {
1652
+            if ( ! $price instanceof EE_Price) {
1653 1653
                 continue;
1654 1654
             }
1655 1655
             if ($price->is_base_price()) {
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
             $this->_is_creating_event
1683 1683
         );
1684 1684
         return EEH_Template::display_template(
1685
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1685
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php',
1686 1686
             $template_args,
1687 1687
             true
1688 1688
         );
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
                 $this->_is_creating_event
1723 1723
             );
1724 1724
             $tax_rows .= EEH_Template::display_template(
1725
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1725
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php',
1726 1726
                 $template_args,
1727 1727
                 true
1728 1728
             );
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
             $this->_is_creating_event
1842 1842
         );
1843 1843
         return EEH_Template::display_template(
1844
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1844
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php',
1845 1845
             $template_args,
1846 1846
             true
1847 1847
         );
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
             $this->_is_creating_event
1912 1912
         );
1913 1913
         return EEH_Template::display_template(
1914
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1914
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php',
1915 1915
             $template_args,
1916 1916
             true
1917 1917
         );
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
     ) {
1942 1942
         $select_name = $default && ! $price instanceof EE_Price
1943 1943
             ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1944
-            : 'edit_prices[' . $ticket_row . '][' . $price_row . '][PRT_ID]';
1944
+            : 'edit_prices['.$ticket_row.']['.$price_row.'][PRT_ID]';
1945 1945
         /** @var EEM_Price_Type $price_type_model */
1946 1946
         $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1947 1947
         $price_types = $price_type_model->get_all(array(
@@ -1959,10 +1959,10 @@  discard block
 block discarded – undo
1959 1959
         $price_option_spans = '';
1960 1960
         // setup price types for selector
1961 1961
         foreach ($price_types as $price_type) {
1962
-            if (! $price_type instanceof EE_Price_Type) {
1962
+            if ( ! $price_type instanceof EE_Price_Type) {
1963 1963
                 continue;
1964 1964
             }
1965
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1965
+            $all_price_types[$price_type->ID()] = $price_type->get('PRT_name');
1966 1966
             // while we're in the loop let's setup the option spans used by js
1967 1967
             $span_args = array(
1968 1968
                 'PRT_ID'         => $price_type->ID(),
@@ -1970,12 +1970,12 @@  discard block
 block discarded – undo
1970 1970
                 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1971 1971
             );
1972 1972
             $price_option_spans .= EEH_Template::display_template(
1973
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1973
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php',
1974 1974
                 $span_args,
1975 1975
                 true
1976 1976
             );
1977 1977
         }
1978
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1978
+        $select_name = $disabled ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]'
1979 1979
             : $select_name;
1980 1980
         $select_input = new EE_Select_Input(
1981 1981
             $all_price_types,
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
             $this->_is_creating_event
2013 2013
         );
2014 2014
         return EEH_Template::display_template(
2015
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2015
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php',
2016 2016
             $template_args,
2017 2017
             true
2018 2018
         );
@@ -2038,8 +2038,8 @@  discard block
 block discarded – undo
2038 2038
         $ticket_datetimes = array(),
2039 2039
         $default
2040 2040
     ) {
2041
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2042
-            ? $ticket_datetimes[ $ticket->ID() ]
2041
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
2042
+            ? $ticket_datetimes[$ticket->ID()]
2043 2043
             : array();
2044 2044
         $template_args = array(
2045 2045
             'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
             $this->_is_creating_event
2072 2072
         );
2073 2073
         return EEH_Template::display_template(
2074
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2074
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2075 2075
             $template_args,
2076 2076
             true
2077 2077
         );
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
         $default_prices = $price_model->get_all_default_prices();
2178 2178
         $price_row = 1;
2179 2179
         foreach ($default_prices as $price) {
2180
-            if (! $price instanceof EE_Price) {
2180
+            if ( ! $price instanceof EE_Price) {
2181 2181
                 continue;
2182 2182
             }
2183 2183
             if ($price->is_base_price()) {
@@ -2214,7 +2214,7 @@  discard block
 block discarded – undo
2214 2214
             $this->_is_creating_event
2215 2215
         );
2216 2216
         return EEH_Template::display_template(
2217
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2217
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php',
2218 2218
             $template_args,
2219 2219
             true
2220 2220
         );
Please login to merge, or discard this patch.
core/admin/StatusChangeNotice.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,51 +15,51 @@
 block discarded – undo
15 15
  */
16 16
 class StatusChangeNotice extends WordPressOption
17 17
 {
18
-    public function __construct()
19
-    {
20
-        parent::__construct('ee_hide_status_change_notices_for_users', [], false);
21
-    }
18
+	public function __construct()
19
+	{
20
+		parent::__construct('ee_hide_status_change_notices_for_users', [], false);
21
+	}
22 22
 
23 23
 
24
-    /**
25
-     * @return int
26
-     * @throws RuntimeException
27
-     */
28
-    public function dismiss(): int
29
-    {
30
-        $user      = $this->getCurrentUser();
31
-        $dismissed = (array) $this->loadOption();
32
-        if (! in_array($user, $dismissed)) {
33
-            $dismissed[] = $user;
34
-        }
35
-        return $this->updateOption($dismissed);
36
-    }
24
+	/**
25
+	 * @return int
26
+	 * @throws RuntimeException
27
+	 */
28
+	public function dismiss(): int
29
+	{
30
+		$user      = $this->getCurrentUser();
31
+		$dismissed = (array) $this->loadOption();
32
+		if (! in_array($user, $dismissed)) {
33
+			$dismissed[] = $user;
34
+		}
35
+		return $this->updateOption($dismissed);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @return bool
41
-     * @throws RuntimeException
42
-     */
43
-    public function isDismissed(): bool
44
-    {
45
-        $user      = $this->getCurrentUser();
46
-        $dismissed = (array) $this->loadOption();
47
-        return in_array($user, $dismissed);
48
-    }
39
+	/**
40
+	 * @return bool
41
+	 * @throws RuntimeException
42
+	 */
43
+	public function isDismissed(): bool
44
+	{
45
+		$user      = $this->getCurrentUser();
46
+		$dismissed = (array) $this->loadOption();
47
+		return in_array($user, $dismissed);
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @return string
53
-     * @throws RuntimeException
54
-     */
55
-    private function getCurrentUser(): string
56
-    {
57
-        $user = wp_get_current_user();
58
-        if (! $user instanceof WP_User || ! $user->exists()) {
59
-            throw new RuntimeException(
60
-                esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
61
-            );
62
-        }
63
-        return $user->user_login;
64
-    }
51
+	/**
52
+	 * @return string
53
+	 * @throws RuntimeException
54
+	 */
55
+	private function getCurrentUser(): string
56
+	{
57
+		$user = wp_get_current_user();
58
+		if (! $user instanceof WP_User || ! $user->exists()) {
59
+			throw new RuntimeException(
60
+				esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
61
+			);
62
+		}
63
+		return $user->user_login;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $user      = $this->getCurrentUser();
31 31
         $dismissed = (array) $this->loadOption();
32
-        if (! in_array($user, $dismissed)) {
32
+        if ( ! in_array($user, $dismissed)) {
33 33
             $dismissed[] = $user;
34 34
         }
35 35
         return $this->updateOption($dismissed);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     private function getCurrentUser(): string
56 56
     {
57 57
         $user = wp_get_current_user();
58
-        if (! $user instanceof WP_User || ! $user->exists()) {
58
+        if ( ! $user instanceof WP_User || ! $user->exists()) {
59 59
             throw new RuntimeException(
60 60
                 esc_html__('A valid WP User could not be retrieved.', 'event_espresso')
61 61
             );
Please login to merge, or discard this patch.