Completed
Branch FET/update-reg-admin-request-p... (8854c6)
by
unknown
06:01 queued 04:18
created
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4111 added lines, -4111 removed lines patch added patch discarded remove patch
@@ -18,4187 +18,4187 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    /**
132
-     * unprocessed value for the 'action' request param (default '')
133
-     *
134
-     * @var string
135
-     */
136
-    protected $raw_req_action = '';
137
-
138
-    /**
139
-     * unprocessed value for the 'page' request param (default '')
140
-     *
141
-     * @var string
142
-     */
143
-    protected $raw_req_page = '';
144
-
145
-    /**
146
-     * sanitized request action (and nonce)
147
-     *
148
-     * @var string
149
-     */
150
-    protected $_req_action = '';
151
-
152
-    /**
153
-     * sanitized request action nonce
154
-     *
155
-     * @var string
156
-     */
157
-    protected $_req_nonce = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_btn_label = '';
163
-
164
-    /**
165
-     * @var string
166
-     */
167
-    protected $_search_box_callback = '';
168
-
169
-    /**
170
-     * @var WP_Screen
171
-     */
172
-    protected $_current_screen;
173
-
174
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
-    protected $_hook_obj;
176
-
177
-    // for holding incoming request data
178
-    protected $_req_data = [];
179
-
180
-    // yes / no array for admin form fields
181
-    protected $_yes_no_values = [];
182
-
183
-    // some default things shared by all child classes
184
-    protected $_default_espresso_metaboxes;
185
-
186
-    /**
187
-     * @var EE_Registry
188
-     */
189
-    protected $EE = null;
190
-
191
-
192
-    /**
193
-     * This is just a property that flags whether the given route is a caffeinated route or not.
194
-     *
195
-     * @var boolean
196
-     */
197
-    protected $_is_caf = false;
198
-
199
-
200
-    /**
201
-     * @Constructor
202
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    public function __construct($routing = true)
210
-    {
211
-        $this->loader  = LoaderFactory::getLoader();
212
-        $this->request = $this->loader->getShared(RequestInterface::class);
213
-        $this->_routing = $routing;
214
-
215
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
-            $this->_is_caf = true;
217
-        }
218
-        $this->_yes_no_values = [
219
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
-        ];
222
-        // set the _req_data property.
223
-        $this->_req_data = $this->request->requestParams();
224
-        // set initial page props (child method)
225
-        $this->_init_page_props();
226
-        // set global defaults
227
-        $this->_set_defaults();
228
-        // set early because incoming requests could be ajax related and we need to register those hooks.
229
-        $this->_global_ajax_hooks();
230
-        $this->_ajax_hooks();
231
-        // other_page_hooks have to be early too.
232
-        $this->_do_other_page_hooks();
233
-        // set up page dependencies
234
-        $this->_before_page_setup();
235
-        $this->_page_setup();
236
-        // die();
237
-    }
238
-
239
-
240
-    /**
241
-     * _init_page_props
242
-     * Child classes use to set at least the following properties:
243
-     * $page_slug.
244
-     * $page_label.
245
-     *
246
-     * @abstract
247
-     * @return void
248
-     */
249
-    abstract protected function _init_page_props();
250
-
251
-
252
-    /**
253
-     * _ajax_hooks
254
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
-     * Note: within the ajax callback methods.
256
-     *
257
-     * @abstract
258
-     * @return void
259
-     */
260
-    abstract protected function _ajax_hooks();
261
-
262
-
263
-    /**
264
-     * _define_page_props
265
-     * child classes define page properties in here.  Must include at least:
266
-     * $_admin_base_url = base_url for all admin pages
267
-     * $_admin_page_title = default admin_page_title for admin pages
268
-     * $_labels = array of default labels for various automatically generated elements:
269
-     *    array(
270
-     *        'buttons' => array(
271
-     *            'add' => esc_html__('label for add new button'),
272
-     *            'edit' => esc_html__('label for edit button'),
273
-     *            'delete' => esc_html__('label for delete button')
274
-     *            )
275
-     *        )
276
-     *
277
-     * @abstract
278
-     * @return void
279
-     */
280
-    abstract protected function _define_page_props();
281
-
282
-
283
-    /**
284
-     * _set_page_routes
285
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
-     * have a 'default' route. Here's the format
288
-     * $this->_page_routes = array(
289
-     *        'default' => array(
290
-     *            'func' => '_default_method_handling_route',
291
-     *            'args' => array('array','of','args'),
292
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
-     *            ajax request, backend processing)
294
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
-     *            headers route after.  The string you enter here should match the defined route reference for a
296
-     *            headers sent route.
297
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
-     *            this route.
299
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
-     *            checks).
301
-     *        ),
302
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
-     *        handling method.
304
-     *        )
305
-     * )
306
-     *
307
-     * @abstract
308
-     * @return void
309
-     */
310
-    abstract protected function _set_page_routes();
311
-
312
-
313
-    /**
314
-     * _set_page_config
315
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
-     * array corresponds to the page_route for the loaded page. Format:
317
-     * $this->_page_config = array(
318
-     *        'default' => array(
319
-     *            'labels' => array(
320
-     *                'buttons' => array(
321
-     *                    'add' => esc_html__('label for adding item'),
322
-     *                    'edit' => esc_html__('label for editing item'),
323
-     *                    'delete' => esc_html__('label for deleting item')
324
-     *                ),
325
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
-     *            _define_page_props() method
329
-     *            'nav' => array(
330
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
-     *                'order' => 10, //required to indicate tab position.
334
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
-     *                displayed then add this parameter.
336
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
-     *            metaboxes set for eventespresso admin pages.
339
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
-     *            want to display.
348
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
349
-     *                'tab_id' => array(
350
-     *                    'title' => 'tab_title',
351
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
-     *                    attempt to use the callback which should match the name of a method in the class
357
-     *                    ),
358
-     *                'tab2_id' => array(
359
-     *                    'title' => 'tab2 title',
360
-     *                    'filename' => 'file_name_2'
361
-     *                    'callback' => 'callback_method_for_content',
362
-     *                 ),
363
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
-     *            help tab area on an admin page. @return void
365
-     *
366
-     * @link
367
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
-     *                'help_tour' => array(
369
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
-     *                ),
373
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
-     *                visited just set
376
-     *                'require_nonce' to FALSE
377
-     *                )
378
-     *                )
379
-     *
380
-     * @abstract
381
-     */
382
-    abstract protected function _set_page_config();
383
-
384
-
385
-
386
-
387
-
388
-    /** end sample help_tour methods **/
389
-    /**
390
-     * _add_screen_options
391
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
-     * to a particular view.
394
-     *
395
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
-     *         see also WP_Screen object documents...
397
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
-     * @abstract
399
-     * @return void
400
-     */
401
-    abstract protected function _add_screen_options();
402
-
403
-
404
-    /**
405
-     * _add_feature_pointers
406
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
-     * extended) also see:
411
-     *
412
-     * @link   http://eamann.com/tech/wordpress-portland/
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract protected function _add_feature_pointers();
417
-
418
-
419
-    /**
420
-     * load_scripts_styles
421
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
-     * scripts/styles per view by putting them in a dynamic function in this format
424
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function load_scripts_styles();
430
-
431
-
432
-    /**
433
-     * admin_init
434
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
-     * all pages/views loaded by child class.
436
-     *
437
-     * @abstract
438
-     * @return void
439
-     */
440
-    abstract public function admin_init();
441
-
442
-
443
-    /**
444
-     * admin_notices
445
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
-     * all pages/views loaded by child class.
447
-     *
448
-     * @abstract
449
-     * @return void
450
-     */
451
-    abstract public function admin_notices();
452
-
453
-
454
-    /**
455
-     * admin_footer_scripts
456
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
-     * will apply to all pages/views loaded by child class.
458
-     *
459
-     * @return void
460
-     */
461
-    abstract public function admin_footer_scripts();
462
-
463
-
464
-    /**
465
-     * admin_footer
466
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
-     * apply to all pages/views loaded by child class.
468
-     *
469
-     * @return void
470
-     */
471
-    public function admin_footer()
472
-    {
473
-    }
474
-
475
-
476
-    /**
477
-     * _global_ajax_hooks
478
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
-     * Note: within the ajax callback methods.
480
-     *
481
-     * @abstract
482
-     * @return void
483
-     */
484
-    protected function _global_ajax_hooks()
485
-    {
486
-        // for lazy loading of metabox content
487
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
-    }
489
-
490
-
491
-    public function ajax_metabox_content()
492
-    {
493
-        $content_id  = $this->request->getRequestParam('contentid', '');
494
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
-        self::cached_rss_display($content_id, $content_url);
496
-        wp_die();
497
-    }
498
-
499
-
500
-    /**
501
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
502
-     *
503
-     * @return void
504
-     */
505
-    protected function _before_page_setup()
506
-    {
507
-        // default is to do nothing
508
-    }
509
-
510
-
511
-    /**
512
-     * Makes sure any things that need to be loaded early get handled.
513
-     * We also escape early here if the page requested doesn't match the object.
514
-     *
515
-     * @final
516
-     * @return void
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     * @throws ReflectionException
520
-     * @throws InvalidDataTypeException
521
-     * @throws InvalidInterfaceException
522
-     */
523
-    final protected function _page_setup()
524
-    {
525
-        // requires?
526
-        // admin_init stuff - global - we're setting this REALLY early
527
-        // so if EE_Admin pages have to hook into other WP pages they can.
528
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
530
-        // next verify if we need to load anything...
531
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
-        $this->page_folder   = strtolower(
533
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
-        );
535
-        global $ee_menu_slugs;
536
-        $ee_menu_slugs = (array) $ee_menu_slugs;
537
-        if (
538
-            ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
-        ) {
541
-            return;
542
-        }
543
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
544
-        // we need to copy the action from the second to the first
545
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
546
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
-        $action     = $action !== '-1' ? $action : $action2;
548
-        $req_action = $action !== '-1' ? $action : 'default';
549
-
550
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
-        // then let's use the route as the action.
552
-        // This covers cases where we're coming in from a list table that isn't on the default route.
553
-        $route = $this->request->getRequestParam('route');
554
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
-            ? $route
556
-            : $req_action;
557
-
558
-        $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
560
-        $this->_define_page_props();
561
-        $this->_current_page_view_url = add_query_arg(
562
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
563
-            $this->_admin_base_url
564
-        );
565
-        // default things
566
-        $this->_default_espresso_metaboxes = [
567
-            '_espresso_news_post_box',
568
-            '_espresso_links_post_box',
569
-            '_espresso_ratings_request',
570
-            '_espresso_sponsors_post_box',
571
-        ];
572
-        // set page configs
573
-        $this->_set_page_routes();
574
-        $this->_set_page_config();
575
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
576
-        if ($this->request->requestParamIsSet('wp_referer')) {
577
-            $wp_referer = $this->request->getRequestParam('wp_referer');
578
-            if ($wp_referer) {
579
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
580
-            }
581
-        }
582
-        // for caffeinated and other extended functionality.
583
-        //  If there is a _extend_page_config method
584
-        // then let's run that to modify the all the various page configuration arrays
585
-        if (method_exists($this, '_extend_page_config')) {
586
-            $this->_extend_page_config();
587
-        }
588
-        // for CPT and other extended functionality.
589
-        // If there is an _extend_page_config_for_cpt
590
-        // then let's run that to modify all the various page configuration arrays.
591
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
592
-            $this->_extend_page_config_for_cpt();
593
-        }
594
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
595
-        $this->_page_routes = apply_filters(
596
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
-            $this->_page_routes,
598
-            $this
599
-        );
600
-        $this->_page_config = apply_filters(
601
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
602
-            $this->_page_config,
603
-            $this
604
-        );
605
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
-            add_action(
609
-                'AHEE__EE_Admin_Page__route_admin_request',
610
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
-                10,
612
-                2
613
-            );
614
-        }
615
-        // next route only if routing enabled
616
-        if ($this->_routing && ! $this->request->isAjax()) {
617
-            $this->_verify_routes();
618
-            // next let's just check user_access and kill if no access
619
-            $this->check_user_access();
620
-            if ($this->_is_UI_request) {
621
-                // admin_init stuff - global, all views for this page class, specific view
622
-                add_action('admin_init', [$this, 'admin_init'], 10);
623
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
-                }
626
-            } else {
627
-                // hijack regular WP loading and route admin request immediately
628
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
-                $this->route_admin_request();
630
-            }
631
-        }
632
-    }
633
-
634
-
635
-    /**
636
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
-     *
638
-     * @return void
639
-     * @throws EE_Error
640
-     */
641
-    private function _do_other_page_hooks()
642
-    {
643
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
-        foreach ($registered_pages as $page) {
645
-            // now let's setup the file name and class that should be present
646
-            $classname = str_replace('.class.php', '', $page);
647
-            // autoloaders should take care of loading file
648
-            if (! class_exists($classname)) {
649
-                $error_msg[] = sprintf(
650
-                    esc_html__(
651
-                        'Something went wrong with loading the %s admin hooks page.',
652
-                        'event_espresso'
653
-                    ),
654
-                    $page
655
-                );
656
-                $error_msg[] = $error_msg[0]
657
-                               . "\r\n"
658
-                               . sprintf(
659
-                                   esc_html__(
660
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
661
-                                       'event_espresso'
662
-                                   ),
663
-                                   $page,
664
-                                   '<br />',
665
-                                   '<strong>' . $classname . '</strong>'
666
-                               );
667
-                throw new EE_Error(implode('||', $error_msg));
668
-            }
669
-            // notice we are passing the instance of this class to the hook object.
670
-            $this->loader->getShared($classname, [$this]);
671
-        }
672
-    }
673
-
674
-
675
-    /**
676
-     * @throws ReflectionException
677
-     * @throws EE_Error
678
-     */
679
-    public function load_page_dependencies()
680
-    {
681
-        try {
682
-            $this->_load_page_dependencies();
683
-        } catch (EE_Error $e) {
684
-            $e->get_error();
685
-        }
686
-    }
687
-
688
-
689
-    /**
690
-     * load_page_dependencies
691
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
-     *
693
-     * @return void
694
-     * @throws DomainException
695
-     * @throws EE_Error
696
-     * @throws InvalidArgumentException
697
-     * @throws InvalidDataTypeException
698
-     * @throws InvalidInterfaceException
699
-     */
700
-    protected function _load_page_dependencies()
701
-    {
702
-        // let's set the current_screen and screen options to override what WP set
703
-        $this->_current_screen = get_current_screen();
704
-        // load admin_notices - global, page class, and view specific
705
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
707
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
-        }
710
-        // load network admin_notices - global, page class, and view specific
711
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
-        }
715
-        // this will save any per_page screen options if they are present
716
-        $this->_set_per_page_screen_options();
717
-        // setup list table properties
718
-        $this->_set_list_table();
719
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
-        // However in some cases the metaboxes will need to be added within a route handling callback.
721
-        $this->_add_registered_meta_boxes();
722
-        $this->_add_screen_columns();
723
-        // add screen options - global, page child class, and view specific
724
-        $this->_add_global_screen_options();
725
-        $this->_add_screen_options();
726
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
727
-        if (method_exists($this, $add_screen_options)) {
728
-            $this->{$add_screen_options}();
729
-        }
730
-        // add help tab(s) and tours- set via page_config and qtips.
731
-        // $this->_add_help_tour();
732
-        $this->_add_help_tabs();
733
-        $this->_add_qtips();
734
-        // add feature_pointers - global, page child class, and view specific
735
-        $this->_add_feature_pointers();
736
-        $this->_add_global_feature_pointers();
737
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
-        if (method_exists($this, $add_feature_pointer)) {
739
-            $this->{$add_feature_pointer}();
740
-        }
741
-        // enqueue scripts/styles - global, page class, and view specific
742
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
-        }
747
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
-        // admin_print_footer_scripts - global, page child class, and view specific.
749
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
-        // is a good use case. Notice the late priority we're giving these
752
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
-        }
757
-        // admin footer scripts
758
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
760
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
-        }
763
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
-        // targeted hook
765
-        do_action(
766
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
-        );
768
-    }
769
-
770
-
771
-    /**
772
-     * _set_defaults
773
-     * This sets some global defaults for class properties.
774
-     */
775
-    private function _set_defaults()
776
-    {
777
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
779
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
-        $this->_page_config          = $this->_default_route_query_args = [];
781
-        $this->_default_nav_tab_name = 'overview';
782
-        // init template args
783
-        $this->_template_args = [
784
-            'admin_page_header'  => '',
785
-            'admin_page_content' => '',
786
-            'post_body_content'  => '',
787
-            'before_list_table'  => '',
788
-            'after_list_table'   => '',
789
-        ];
790
-    }
791
-
792
-
793
-    /**
794
-     * route_admin_request
795
-     *
796
-     * @return void
797
-     * @throws InvalidArgumentException
798
-     * @throws InvalidInterfaceException
799
-     * @throws InvalidDataTypeException
800
-     * @throws EE_Error
801
-     * @throws ReflectionException
802
-     * @see    _route_admin_request()
803
-     */
804
-    public function route_admin_request()
805
-    {
806
-        try {
807
-            $this->_route_admin_request();
808
-        } catch (EE_Error $e) {
809
-            $e->get_error();
810
-        }
811
-    }
812
-
813
-
814
-    public function set_wp_page_slug($wp_page_slug)
815
-    {
816
-        $this->_wp_page_slug = $wp_page_slug;
817
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
-        if (is_network_admin()) {
819
-            $this->_wp_page_slug .= '-network';
820
-        }
821
-    }
822
-
823
-
824
-    /**
825
-     * _verify_routes
826
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
-     * we know if we need to drop out.
828
-     *
829
-     * @return bool
830
-     * @throws EE_Error
831
-     */
832
-    protected function _verify_routes()
833
-    {
834
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
-        if (! $this->_current_page && ! $this->request->isAjax()) {
836
-            return false;
837
-        }
838
-        $this->_route = false;
839
-        // check that the page_routes array is not empty
840
-        if (empty($this->_page_routes)) {
841
-            // user error msg
842
-            $error_msg = sprintf(
843
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
-                $this->_admin_page_title
845
-            );
846
-            // developer error msg
847
-            $error_msg .= '||' . $error_msg
848
-                          . esc_html__(
849
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
-                              'event_espresso'
851
-                          );
852
-            throw new EE_Error($error_msg);
853
-        }
854
-        // and that the requested page route exists
855
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
857
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
-                ? $this->_page_config[ $this->_req_action ]
859
-                : [];
860
-        } else {
861
-            // user error msg
862
-            $error_msg = sprintf(
863
-                esc_html__(
864
-                    'The requested page route does not exist for the %s admin page.',
865
-                    'event_espresso'
866
-                ),
867
-                $this->_admin_page_title
868
-            );
869
-            // developer error msg
870
-            $error_msg .= '||' . $error_msg
871
-                          . sprintf(
872
-                              esc_html__(
873
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
-                                  'event_espresso'
875
-                              ),
876
-                              $this->_req_action
877
-                          );
878
-            throw new EE_Error($error_msg);
879
-        }
880
-        // and that a default route exists
881
-        if (! array_key_exists('default', $this->_page_routes)) {
882
-            // user error msg
883
-            $error_msg = sprintf(
884
-                esc_html__(
885
-                    'A default page route has not been set for the % admin page.',
886
-                    'event_espresso'
887
-                ),
888
-                $this->_admin_page_title
889
-            );
890
-            // developer error msg
891
-            $error_msg .= '||' . $error_msg
892
-                          . esc_html__(
893
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
-                              'event_espresso'
895
-                          );
896
-            throw new EE_Error($error_msg);
897
-        }
898
-        // first lets' catch if the UI request has EVER been set.
899
-        if ($this->_is_UI_request === null) {
900
-            // lets set if this is a UI request or not.
901
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
-            // wait a minute... we might have a noheader in the route array
903
-            $this->_is_UI_request = ! (
904
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
-            )
906
-                ? $this->_is_UI_request
907
-                : false;
908
-        }
909
-        $this->_set_current_labels();
910
-        return true;
911
-    }
912
-
913
-
914
-    /**
915
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
-     *
917
-     * @param string $route the route name we're verifying
918
-     * @return bool we'll throw an exception if this isn't a valid route.
919
-     * @throws EE_Error
920
-     */
921
-    protected function _verify_route($route)
922
-    {
923
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
-            return true;
925
-        }
926
-        // user error msg
927
-        $error_msg = sprintf(
928
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
-            $this->_admin_page_title
930
-        );
931
-        // developer error msg
932
-        $error_msg .= '||' . $error_msg
933
-                      . sprintf(
934
-                          esc_html__(
935
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
-                              'event_espresso'
937
-                          ),
938
-                          $route
939
-                      );
940
-        throw new EE_Error($error_msg);
941
-    }
942
-
943
-
944
-    /**
945
-     * perform nonce verification
946
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
-     * using this method (and save retyping!)
948
-     *
949
-     * @param string $nonce     The nonce sent
950
-     * @param string $nonce_ref The nonce reference string (name0)
951
-     * @return void
952
-     * @throws EE_Error
953
-     */
954
-    protected function _verify_nonce($nonce, $nonce_ref)
955
-    {
956
-        // verify nonce against expected value
957
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
-            // these are not the droids you are looking for !!!
959
-            $msg = sprintf(
960
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
-                '</a>'
963
-            );
964
-            if (WP_DEBUG) {
965
-                $msg .= "\n  ";
966
-                $msg .= sprintf(
967
-                    esc_html__(
968
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
-                        'event_espresso'
970
-                    ),
971
-                    __CLASS__
972
-                );
973
-            }
974
-            if (! $this->request->isAjax()) {
975
-                wp_die($msg);
976
-            }
977
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
-            $this->_return_json();
979
-        }
980
-    }
981
-
982
-
983
-    /**
984
-     * _route_admin_request()
985
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
-     * in the page routes and then will try to load the corresponding method.
988
-     *
989
-     * @return void
990
-     * @throws EE_Error
991
-     * @throws InvalidArgumentException
992
-     * @throws InvalidDataTypeException
993
-     * @throws InvalidInterfaceException
994
-     * @throws ReflectionException
995
-     */
996
-    protected function _route_admin_request()
997
-    {
998
-        if (! $this->_is_UI_request) {
999
-            $this->_verify_routes();
1000
-        }
1001
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
-        if ($this->_req_action !== 'default' && $nonce_check) {
1003
-            // set nonce from post data
1004
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1006
-        }
1007
-        // set the nav_tabs array but ONLY if this is  UI_request
1008
-        if ($this->_is_UI_request) {
1009
-            $this->_set_nav_tabs();
1010
-        }
1011
-        // grab callback function
1012
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
-        // check if callback has args
1014
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
-        $error_msg = '';
1016
-        // action right before calling route
1017
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
-        }
1021
-        // right before calling the route, let's clean the _wp_http_referer
1022
-        $this->request->setServerParam(
1023
-            'REQUEST_URI',
1024
-            remove_query_arg(
1025
-                '_wp_http_referer',
1026
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
-            )
1028
-        );
1029
-        if (! empty($func)) {
1030
-            if (is_array($func)) {
1031
-                list($class, $method) = $func;
1032
-            } elseif (strpos($func, '::') !== false) {
1033
-                list($class, $method) = explode('::', $func);
1034
-            } else {
1035
-                $class  = $this;
1036
-                $method = $func;
1037
-            }
1038
-            if (! (is_object($class) && $class === $this)) {
1039
-                // send along this admin page object for access by addons.
1040
-                $args['admin_page_object'] = $this;
1041
-            }
1042
-            if (
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	/**
132
+	 * unprocessed value for the 'action' request param (default '')
133
+	 *
134
+	 * @var string
135
+	 */
136
+	protected $raw_req_action = '';
137
+
138
+	/**
139
+	 * unprocessed value for the 'page' request param (default '')
140
+	 *
141
+	 * @var string
142
+	 */
143
+	protected $raw_req_page = '';
144
+
145
+	/**
146
+	 * sanitized request action (and nonce)
147
+	 *
148
+	 * @var string
149
+	 */
150
+	protected $_req_action = '';
151
+
152
+	/**
153
+	 * sanitized request action nonce
154
+	 *
155
+	 * @var string
156
+	 */
157
+	protected $_req_nonce = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_btn_label = '';
163
+
164
+	/**
165
+	 * @var string
166
+	 */
167
+	protected $_search_box_callback = '';
168
+
169
+	/**
170
+	 * @var WP_Screen
171
+	 */
172
+	protected $_current_screen;
173
+
174
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
+	protected $_hook_obj;
176
+
177
+	// for holding incoming request data
178
+	protected $_req_data = [];
179
+
180
+	// yes / no array for admin form fields
181
+	protected $_yes_no_values = [];
182
+
183
+	// some default things shared by all child classes
184
+	protected $_default_espresso_metaboxes;
185
+
186
+	/**
187
+	 * @var EE_Registry
188
+	 */
189
+	protected $EE = null;
190
+
191
+
192
+	/**
193
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
194
+	 *
195
+	 * @var boolean
196
+	 */
197
+	protected $_is_caf = false;
198
+
199
+
200
+	/**
201
+	 * @Constructor
202
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	public function __construct($routing = true)
210
+	{
211
+		$this->loader  = LoaderFactory::getLoader();
212
+		$this->request = $this->loader->getShared(RequestInterface::class);
213
+		$this->_routing = $routing;
214
+
215
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
+			$this->_is_caf = true;
217
+		}
218
+		$this->_yes_no_values = [
219
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
+		];
222
+		// set the _req_data property.
223
+		$this->_req_data = $this->request->requestParams();
224
+		// set initial page props (child method)
225
+		$this->_init_page_props();
226
+		// set global defaults
227
+		$this->_set_defaults();
228
+		// set early because incoming requests could be ajax related and we need to register those hooks.
229
+		$this->_global_ajax_hooks();
230
+		$this->_ajax_hooks();
231
+		// other_page_hooks have to be early too.
232
+		$this->_do_other_page_hooks();
233
+		// set up page dependencies
234
+		$this->_before_page_setup();
235
+		$this->_page_setup();
236
+		// die();
237
+	}
238
+
239
+
240
+	/**
241
+	 * _init_page_props
242
+	 * Child classes use to set at least the following properties:
243
+	 * $page_slug.
244
+	 * $page_label.
245
+	 *
246
+	 * @abstract
247
+	 * @return void
248
+	 */
249
+	abstract protected function _init_page_props();
250
+
251
+
252
+	/**
253
+	 * _ajax_hooks
254
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
+	 * Note: within the ajax callback methods.
256
+	 *
257
+	 * @abstract
258
+	 * @return void
259
+	 */
260
+	abstract protected function _ajax_hooks();
261
+
262
+
263
+	/**
264
+	 * _define_page_props
265
+	 * child classes define page properties in here.  Must include at least:
266
+	 * $_admin_base_url = base_url for all admin pages
267
+	 * $_admin_page_title = default admin_page_title for admin pages
268
+	 * $_labels = array of default labels for various automatically generated elements:
269
+	 *    array(
270
+	 *        'buttons' => array(
271
+	 *            'add' => esc_html__('label for add new button'),
272
+	 *            'edit' => esc_html__('label for edit button'),
273
+	 *            'delete' => esc_html__('label for delete button')
274
+	 *            )
275
+	 *        )
276
+	 *
277
+	 * @abstract
278
+	 * @return void
279
+	 */
280
+	abstract protected function _define_page_props();
281
+
282
+
283
+	/**
284
+	 * _set_page_routes
285
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
+	 * have a 'default' route. Here's the format
288
+	 * $this->_page_routes = array(
289
+	 *        'default' => array(
290
+	 *            'func' => '_default_method_handling_route',
291
+	 *            'args' => array('array','of','args'),
292
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
+	 *            ajax request, backend processing)
294
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
+	 *            headers route after.  The string you enter here should match the defined route reference for a
296
+	 *            headers sent route.
297
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
+	 *            this route.
299
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
+	 *            checks).
301
+	 *        ),
302
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
+	 *        handling method.
304
+	 *        )
305
+	 * )
306
+	 *
307
+	 * @abstract
308
+	 * @return void
309
+	 */
310
+	abstract protected function _set_page_routes();
311
+
312
+
313
+	/**
314
+	 * _set_page_config
315
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
+	 * array corresponds to the page_route for the loaded page. Format:
317
+	 * $this->_page_config = array(
318
+	 *        'default' => array(
319
+	 *            'labels' => array(
320
+	 *                'buttons' => array(
321
+	 *                    'add' => esc_html__('label for adding item'),
322
+	 *                    'edit' => esc_html__('label for editing item'),
323
+	 *                    'delete' => esc_html__('label for deleting item')
324
+	 *                ),
325
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
+	 *            _define_page_props() method
329
+	 *            'nav' => array(
330
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
+	 *                'order' => 10, //required to indicate tab position.
334
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
+	 *                displayed then add this parameter.
336
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
+	 *            metaboxes set for eventespresso admin pages.
339
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
+	 *            want to display.
348
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
349
+	 *                'tab_id' => array(
350
+	 *                    'title' => 'tab_title',
351
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
+	 *                    attempt to use the callback which should match the name of a method in the class
357
+	 *                    ),
358
+	 *                'tab2_id' => array(
359
+	 *                    'title' => 'tab2 title',
360
+	 *                    'filename' => 'file_name_2'
361
+	 *                    'callback' => 'callback_method_for_content',
362
+	 *                 ),
363
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
+	 *            help tab area on an admin page. @return void
365
+	 *
366
+	 * @link
367
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
+	 *                'help_tour' => array(
369
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
+	 *                ),
373
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
+	 *                visited just set
376
+	 *                'require_nonce' to FALSE
377
+	 *                )
378
+	 *                )
379
+	 *
380
+	 * @abstract
381
+	 */
382
+	abstract protected function _set_page_config();
383
+
384
+
385
+
386
+
387
+
388
+	/** end sample help_tour methods **/
389
+	/**
390
+	 * _add_screen_options
391
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
+	 * to a particular view.
394
+	 *
395
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
+	 *         see also WP_Screen object documents...
397
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
+	 * @abstract
399
+	 * @return void
400
+	 */
401
+	abstract protected function _add_screen_options();
402
+
403
+
404
+	/**
405
+	 * _add_feature_pointers
406
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
+	 * extended) also see:
411
+	 *
412
+	 * @link   http://eamann.com/tech/wordpress-portland/
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract protected function _add_feature_pointers();
417
+
418
+
419
+	/**
420
+	 * load_scripts_styles
421
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
+	 * scripts/styles per view by putting them in a dynamic function in this format
424
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function load_scripts_styles();
430
+
431
+
432
+	/**
433
+	 * admin_init
434
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
+	 * all pages/views loaded by child class.
436
+	 *
437
+	 * @abstract
438
+	 * @return void
439
+	 */
440
+	abstract public function admin_init();
441
+
442
+
443
+	/**
444
+	 * admin_notices
445
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
+	 * all pages/views loaded by child class.
447
+	 *
448
+	 * @abstract
449
+	 * @return void
450
+	 */
451
+	abstract public function admin_notices();
452
+
453
+
454
+	/**
455
+	 * admin_footer_scripts
456
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
+	 * will apply to all pages/views loaded by child class.
458
+	 *
459
+	 * @return void
460
+	 */
461
+	abstract public function admin_footer_scripts();
462
+
463
+
464
+	/**
465
+	 * admin_footer
466
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
+	 * apply to all pages/views loaded by child class.
468
+	 *
469
+	 * @return void
470
+	 */
471
+	public function admin_footer()
472
+	{
473
+	}
474
+
475
+
476
+	/**
477
+	 * _global_ajax_hooks
478
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
+	 * Note: within the ajax callback methods.
480
+	 *
481
+	 * @abstract
482
+	 * @return void
483
+	 */
484
+	protected function _global_ajax_hooks()
485
+	{
486
+		// for lazy loading of metabox content
487
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
+	}
489
+
490
+
491
+	public function ajax_metabox_content()
492
+	{
493
+		$content_id  = $this->request->getRequestParam('contentid', '');
494
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
+		self::cached_rss_display($content_id, $content_url);
496
+		wp_die();
497
+	}
498
+
499
+
500
+	/**
501
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
502
+	 *
503
+	 * @return void
504
+	 */
505
+	protected function _before_page_setup()
506
+	{
507
+		// default is to do nothing
508
+	}
509
+
510
+
511
+	/**
512
+	 * Makes sure any things that need to be loaded early get handled.
513
+	 * We also escape early here if the page requested doesn't match the object.
514
+	 *
515
+	 * @final
516
+	 * @return void
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 * @throws ReflectionException
520
+	 * @throws InvalidDataTypeException
521
+	 * @throws InvalidInterfaceException
522
+	 */
523
+	final protected function _page_setup()
524
+	{
525
+		// requires?
526
+		// admin_init stuff - global - we're setting this REALLY early
527
+		// so if EE_Admin pages have to hook into other WP pages they can.
528
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
530
+		// next verify if we need to load anything...
531
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
+		$this->page_folder   = strtolower(
533
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
+		);
535
+		global $ee_menu_slugs;
536
+		$ee_menu_slugs = (array) $ee_menu_slugs;
537
+		if (
538
+			! $this->request->isAjax()
539
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
+		) {
541
+			return;
542
+		}
543
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
544
+		// we need to copy the action from the second to the first
545
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
546
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
+		$action     = $action !== '-1' ? $action : $action2;
548
+		$req_action = $action !== '-1' ? $action : 'default';
549
+
550
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
+		// then let's use the route as the action.
552
+		// This covers cases where we're coming in from a list table that isn't on the default route.
553
+		$route = $this->request->getRequestParam('route');
554
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
+			? $route
556
+			: $req_action;
557
+
558
+		$this->_current_view = $this->_req_action;
559
+		$this->_req_nonce    = $this->_req_action . '_nonce';
560
+		$this->_define_page_props();
561
+		$this->_current_page_view_url = add_query_arg(
562
+			['page' => $this->_current_page, 'action' => $this->_current_view],
563
+			$this->_admin_base_url
564
+		);
565
+		// default things
566
+		$this->_default_espresso_metaboxes = [
567
+			'_espresso_news_post_box',
568
+			'_espresso_links_post_box',
569
+			'_espresso_ratings_request',
570
+			'_espresso_sponsors_post_box',
571
+		];
572
+		// set page configs
573
+		$this->_set_page_routes();
574
+		$this->_set_page_config();
575
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
576
+		if ($this->request->requestParamIsSet('wp_referer')) {
577
+			$wp_referer = $this->request->getRequestParam('wp_referer');
578
+			if ($wp_referer) {
579
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
580
+			}
581
+		}
582
+		// for caffeinated and other extended functionality.
583
+		//  If there is a _extend_page_config method
584
+		// then let's run that to modify the all the various page configuration arrays
585
+		if (method_exists($this, '_extend_page_config')) {
586
+			$this->_extend_page_config();
587
+		}
588
+		// for CPT and other extended functionality.
589
+		// If there is an _extend_page_config_for_cpt
590
+		// then let's run that to modify all the various page configuration arrays.
591
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
592
+			$this->_extend_page_config_for_cpt();
593
+		}
594
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
595
+		$this->_page_routes = apply_filters(
596
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
+			$this->_page_routes,
598
+			$this
599
+		);
600
+		$this->_page_config = apply_filters(
601
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
602
+			$this->_page_config,
603
+			$this
604
+		);
605
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
+			add_action(
609
+				'AHEE__EE_Admin_Page__route_admin_request',
610
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
+				10,
612
+				2
613
+			);
614
+		}
615
+		// next route only if routing enabled
616
+		if ($this->_routing && ! $this->request->isAjax()) {
617
+			$this->_verify_routes();
618
+			// next let's just check user_access and kill if no access
619
+			$this->check_user_access();
620
+			if ($this->_is_UI_request) {
621
+				// admin_init stuff - global, all views for this page class, specific view
622
+				add_action('admin_init', [$this, 'admin_init'], 10);
623
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
+				}
626
+			} else {
627
+				// hijack regular WP loading and route admin request immediately
628
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
+				$this->route_admin_request();
630
+			}
631
+		}
632
+	}
633
+
634
+
635
+	/**
636
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
+	 *
638
+	 * @return void
639
+	 * @throws EE_Error
640
+	 */
641
+	private function _do_other_page_hooks()
642
+	{
643
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
+		foreach ($registered_pages as $page) {
645
+			// now let's setup the file name and class that should be present
646
+			$classname = str_replace('.class.php', '', $page);
647
+			// autoloaders should take care of loading file
648
+			if (! class_exists($classname)) {
649
+				$error_msg[] = sprintf(
650
+					esc_html__(
651
+						'Something went wrong with loading the %s admin hooks page.',
652
+						'event_espresso'
653
+					),
654
+					$page
655
+				);
656
+				$error_msg[] = $error_msg[0]
657
+							   . "\r\n"
658
+							   . sprintf(
659
+								   esc_html__(
660
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
661
+									   'event_espresso'
662
+								   ),
663
+								   $page,
664
+								   '<br />',
665
+								   '<strong>' . $classname . '</strong>'
666
+							   );
667
+				throw new EE_Error(implode('||', $error_msg));
668
+			}
669
+			// notice we are passing the instance of this class to the hook object.
670
+			$this->loader->getShared($classname, [$this]);
671
+		}
672
+	}
673
+
674
+
675
+	/**
676
+	 * @throws ReflectionException
677
+	 * @throws EE_Error
678
+	 */
679
+	public function load_page_dependencies()
680
+	{
681
+		try {
682
+			$this->_load_page_dependencies();
683
+		} catch (EE_Error $e) {
684
+			$e->get_error();
685
+		}
686
+	}
687
+
688
+
689
+	/**
690
+	 * load_page_dependencies
691
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
+	 *
693
+	 * @return void
694
+	 * @throws DomainException
695
+	 * @throws EE_Error
696
+	 * @throws InvalidArgumentException
697
+	 * @throws InvalidDataTypeException
698
+	 * @throws InvalidInterfaceException
699
+	 */
700
+	protected function _load_page_dependencies()
701
+	{
702
+		// let's set the current_screen and screen options to override what WP set
703
+		$this->_current_screen = get_current_screen();
704
+		// load admin_notices - global, page class, and view specific
705
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
707
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
+		}
710
+		// load network admin_notices - global, page class, and view specific
711
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
+		}
715
+		// this will save any per_page screen options if they are present
716
+		$this->_set_per_page_screen_options();
717
+		// setup list table properties
718
+		$this->_set_list_table();
719
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
+		// However in some cases the metaboxes will need to be added within a route handling callback.
721
+		$this->_add_registered_meta_boxes();
722
+		$this->_add_screen_columns();
723
+		// add screen options - global, page child class, and view specific
724
+		$this->_add_global_screen_options();
725
+		$this->_add_screen_options();
726
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
727
+		if (method_exists($this, $add_screen_options)) {
728
+			$this->{$add_screen_options}();
729
+		}
730
+		// add help tab(s) and tours- set via page_config and qtips.
731
+		// $this->_add_help_tour();
732
+		$this->_add_help_tabs();
733
+		$this->_add_qtips();
734
+		// add feature_pointers - global, page child class, and view specific
735
+		$this->_add_feature_pointers();
736
+		$this->_add_global_feature_pointers();
737
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
+		if (method_exists($this, $add_feature_pointer)) {
739
+			$this->{$add_feature_pointer}();
740
+		}
741
+		// enqueue scripts/styles - global, page class, and view specific
742
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
+		}
747
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
+		// admin_print_footer_scripts - global, page child class, and view specific.
749
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
+		// is a good use case. Notice the late priority we're giving these
752
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
+		}
757
+		// admin footer scripts
758
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
760
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
+		}
763
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
+		// targeted hook
765
+		do_action(
766
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
+		);
768
+	}
769
+
770
+
771
+	/**
772
+	 * _set_defaults
773
+	 * This sets some global defaults for class properties.
774
+	 */
775
+	private function _set_defaults()
776
+	{
777
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
779
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
+		$this->_page_config          = $this->_default_route_query_args = [];
781
+		$this->_default_nav_tab_name = 'overview';
782
+		// init template args
783
+		$this->_template_args = [
784
+			'admin_page_header'  => '',
785
+			'admin_page_content' => '',
786
+			'post_body_content'  => '',
787
+			'before_list_table'  => '',
788
+			'after_list_table'   => '',
789
+		];
790
+	}
791
+
792
+
793
+	/**
794
+	 * route_admin_request
795
+	 *
796
+	 * @return void
797
+	 * @throws InvalidArgumentException
798
+	 * @throws InvalidInterfaceException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws EE_Error
801
+	 * @throws ReflectionException
802
+	 * @see    _route_admin_request()
803
+	 */
804
+	public function route_admin_request()
805
+	{
806
+		try {
807
+			$this->_route_admin_request();
808
+		} catch (EE_Error $e) {
809
+			$e->get_error();
810
+		}
811
+	}
812
+
813
+
814
+	public function set_wp_page_slug($wp_page_slug)
815
+	{
816
+		$this->_wp_page_slug = $wp_page_slug;
817
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
+		if (is_network_admin()) {
819
+			$this->_wp_page_slug .= '-network';
820
+		}
821
+	}
822
+
823
+
824
+	/**
825
+	 * _verify_routes
826
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
+	 * we know if we need to drop out.
828
+	 *
829
+	 * @return bool
830
+	 * @throws EE_Error
831
+	 */
832
+	protected function _verify_routes()
833
+	{
834
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
+		if (! $this->_current_page && ! $this->request->isAjax()) {
836
+			return false;
837
+		}
838
+		$this->_route = false;
839
+		// check that the page_routes array is not empty
840
+		if (empty($this->_page_routes)) {
841
+			// user error msg
842
+			$error_msg = sprintf(
843
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
+				$this->_admin_page_title
845
+			);
846
+			// developer error msg
847
+			$error_msg .= '||' . $error_msg
848
+						  . esc_html__(
849
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
+							  'event_espresso'
851
+						  );
852
+			throw new EE_Error($error_msg);
853
+		}
854
+		// and that the requested page route exists
855
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
857
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
+				? $this->_page_config[ $this->_req_action ]
859
+				: [];
860
+		} else {
861
+			// user error msg
862
+			$error_msg = sprintf(
863
+				esc_html__(
864
+					'The requested page route does not exist for the %s admin page.',
865
+					'event_espresso'
866
+				),
867
+				$this->_admin_page_title
868
+			);
869
+			// developer error msg
870
+			$error_msg .= '||' . $error_msg
871
+						  . sprintf(
872
+							  esc_html__(
873
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
+								  'event_espresso'
875
+							  ),
876
+							  $this->_req_action
877
+						  );
878
+			throw new EE_Error($error_msg);
879
+		}
880
+		// and that a default route exists
881
+		if (! array_key_exists('default', $this->_page_routes)) {
882
+			// user error msg
883
+			$error_msg = sprintf(
884
+				esc_html__(
885
+					'A default page route has not been set for the % admin page.',
886
+					'event_espresso'
887
+				),
888
+				$this->_admin_page_title
889
+			);
890
+			// developer error msg
891
+			$error_msg .= '||' . $error_msg
892
+						  . esc_html__(
893
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
+							  'event_espresso'
895
+						  );
896
+			throw new EE_Error($error_msg);
897
+		}
898
+		// first lets' catch if the UI request has EVER been set.
899
+		if ($this->_is_UI_request === null) {
900
+			// lets set if this is a UI request or not.
901
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
+			// wait a minute... we might have a noheader in the route array
903
+			$this->_is_UI_request = ! (
904
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
+			)
906
+				? $this->_is_UI_request
907
+				: false;
908
+		}
909
+		$this->_set_current_labels();
910
+		return true;
911
+	}
912
+
913
+
914
+	/**
915
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
+	 *
917
+	 * @param string $route the route name we're verifying
918
+	 * @return bool we'll throw an exception if this isn't a valid route.
919
+	 * @throws EE_Error
920
+	 */
921
+	protected function _verify_route($route)
922
+	{
923
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
+			return true;
925
+		}
926
+		// user error msg
927
+		$error_msg = sprintf(
928
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
+			$this->_admin_page_title
930
+		);
931
+		// developer error msg
932
+		$error_msg .= '||' . $error_msg
933
+					  . sprintf(
934
+						  esc_html__(
935
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
+							  'event_espresso'
937
+						  ),
938
+						  $route
939
+					  );
940
+		throw new EE_Error($error_msg);
941
+	}
942
+
943
+
944
+	/**
945
+	 * perform nonce verification
946
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
+	 * using this method (and save retyping!)
948
+	 *
949
+	 * @param string $nonce     The nonce sent
950
+	 * @param string $nonce_ref The nonce reference string (name0)
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 */
954
+	protected function _verify_nonce($nonce, $nonce_ref)
955
+	{
956
+		// verify nonce against expected value
957
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
+			// these are not the droids you are looking for !!!
959
+			$msg = sprintf(
960
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
+				'</a>'
963
+			);
964
+			if (WP_DEBUG) {
965
+				$msg .= "\n  ";
966
+				$msg .= sprintf(
967
+					esc_html__(
968
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
+						'event_espresso'
970
+					),
971
+					__CLASS__
972
+				);
973
+			}
974
+			if (! $this->request->isAjax()) {
975
+				wp_die($msg);
976
+			}
977
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
+			$this->_return_json();
979
+		}
980
+	}
981
+
982
+
983
+	/**
984
+	 * _route_admin_request()
985
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
+	 * in the page routes and then will try to load the corresponding method.
988
+	 *
989
+	 * @return void
990
+	 * @throws EE_Error
991
+	 * @throws InvalidArgumentException
992
+	 * @throws InvalidDataTypeException
993
+	 * @throws InvalidInterfaceException
994
+	 * @throws ReflectionException
995
+	 */
996
+	protected function _route_admin_request()
997
+	{
998
+		if (! $this->_is_UI_request) {
999
+			$this->_verify_routes();
1000
+		}
1001
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
+		if ($this->_req_action !== 'default' && $nonce_check) {
1003
+			// set nonce from post data
1004
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1006
+		}
1007
+		// set the nav_tabs array but ONLY if this is  UI_request
1008
+		if ($this->_is_UI_request) {
1009
+			$this->_set_nav_tabs();
1010
+		}
1011
+		// grab callback function
1012
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
+		// check if callback has args
1014
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
+		$error_msg = '';
1016
+		// action right before calling route
1017
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
+		}
1021
+		// right before calling the route, let's clean the _wp_http_referer
1022
+		$this->request->setServerParam(
1023
+			'REQUEST_URI',
1024
+			remove_query_arg(
1025
+				'_wp_http_referer',
1026
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
+			)
1028
+		);
1029
+		if (! empty($func)) {
1030
+			if (is_array($func)) {
1031
+				list($class, $method) = $func;
1032
+			} elseif (strpos($func, '::') !== false) {
1033
+				list($class, $method) = explode('::', $func);
1034
+			} else {
1035
+				$class  = $this;
1036
+				$method = $func;
1037
+			}
1038
+			if (! (is_object($class) && $class === $this)) {
1039
+				// send along this admin page object for access by addons.
1040
+				$args['admin_page_object'] = $this;
1041
+			}
1042
+			if (
1043 1043
 // is it a method on a class that doesn't work?
1044
-                (
1045
-                    (
1046
-                        method_exists($class, $method)
1047
-                        && call_user_func_array([$class, $method], $args) === false
1048
-                    )
1049
-                    && (
1050
-                        // is it a standalone function that doesn't work?
1051
-                        function_exists($method)
1052
-                        && call_user_func_array(
1053
-                            $func,
1054
-                            array_merge(['admin_page_object' => $this], $args)
1055
-                        ) === false
1056
-                    )
1057
-                )
1058
-                || (
1059
-                    // is it neither a class method NOR a standalone function?
1060
-                    ! method_exists($class, $method)
1061
-                    && ! function_exists($method)
1062
-                )
1063
-            ) {
1064
-                // user error msg
1065
-                $error_msg = esc_html__(
1066
-                    'An error occurred. The  requested page route could not be found.',
1067
-                    'event_espresso'
1068
-                );
1069
-                // developer error msg
1070
-                $error_msg .= '||';
1071
-                $error_msg .= sprintf(
1072
-                    esc_html__(
1073
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
-                        'event_espresso'
1075
-                    ),
1076
-                    $method
1077
-                );
1078
-            }
1079
-            if (! empty($error_msg)) {
1080
-                throw new EE_Error($error_msg);
1081
-            }
1082
-        }
1083
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1084
-        // then we need to reset the routing properties to the new route.
1085
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1086
-        if (
1087
-            $this->_is_UI_request === false
1088
-            && is_array($this->_route)
1089
-            && ! empty($this->_route['headers_sent_route'])
1090
-        ) {
1091
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * This method just allows the resetting of page properties in the case where a no headers
1098
-     * route redirects to a headers route in its route config.
1099
-     *
1100
-     * @param string $new_route New (non header) route to redirect to.
1101
-     * @return   void
1102
-     * @throws ReflectionException
1103
-     * @throws InvalidArgumentException
1104
-     * @throws InvalidInterfaceException
1105
-     * @throws InvalidDataTypeException
1106
-     * @throws EE_Error
1107
-     * @since   4.3.0
1108
-     */
1109
-    protected function _reset_routing_properties($new_route)
1110
-    {
1111
-        $this->_is_UI_request = true;
1112
-        // now we set the current route to whatever the headers_sent_route is set at
1113
-        $this->request->setRequestParam('action', $new_route);
1114
-        // rerun page setup
1115
-        $this->_page_setup();
1116
-    }
1117
-
1118
-
1119
-    /**
1120
-     * _add_query_arg
1121
-     * adds nonce to array of arguments then calls WP add_query_arg function
1122
-     *(internally just uses EEH_URL's function with the same name)
1123
-     *
1124
-     * @param array  $args
1125
-     * @param string $url
1126
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
-     *                                        Example usage: If the current page is:
1129
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
-     *                                        &action=default&event_id=20&month_range=March%202015
1131
-     *                                        &_wpnonce=5467821
1132
-     *                                        and you call:
1133
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
-     *                                        array(
1135
-     *                                        'action' => 'resend_something',
1136
-     *                                        'page=>espresso_registrations'
1137
-     *                                        ),
1138
-     *                                        $some_url,
1139
-     *                                        true
1140
-     *                                        );
1141
-     *                                        It will produce a url in this structure:
1142
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
-     *                                        month_range]=March%202015
1145
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
-     * @return string
1147
-     */
1148
-    public static function add_query_args_and_nonce(
1149
-        $args = [],
1150
-        $url = false,
1151
-        $sticky = false,
1152
-        $exclude_nonce = false
1153
-    ) {
1154
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
-        if ($sticky) {
1156
-            /** @var RequestInterface $request */
1157
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
-            foreach ($request->requestParams() as $key => $value) {
1160
-                // do not add nonces
1161
-                if (strpos($key, 'nonce') !== false) {
1162
-                    continue;
1163
-                }
1164
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1165
-            }
1166
-        }
1167
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * This returns a generated link that will load the related help tab.
1173
-     *
1174
-     * @param string $help_tab_id the id for the connected help tab
1175
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
-     * @return string              generated link
1178
-     * @uses EEH_Template::get_help_tab_link()
1179
-     */
1180
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
-    {
1182
-        return EEH_Template::get_help_tab_link(
1183
-            $help_tab_id,
1184
-            $this->page_slug,
1185
-            $this->_req_action,
1186
-            $icon_style,
1187
-            $help_text
1188
-        );
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * _add_help_tabs
1194
-     * Note child classes define their help tabs within the page_config array.
1195
-     *
1196
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
-     * @return void
1198
-     * @throws DomainException
1199
-     * @throws EE_Error
1200
-     */
1201
-    protected function _add_help_tabs()
1202
-    {
1203
-        $tour_buttons = '';
1204
-        if (isset($this->_page_config[ $this->_req_action ])) {
1205
-            $config = $this->_page_config[ $this->_req_action ];
1206
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1208
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1209
-            //     $tb = array();
1210
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1212
-            //         // if this is the end tour then we don't need to setup a button
1213
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
-            //             continue;
1215
-            //         }
1216
-            //         $tb[] = '<button id="trigger-tour-'
1217
-            //                 . $tour->get_slug()
1218
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1219
-            //                 . $tour->get_label()
1220
-            //                 . '</button>';
1221
-            //     }
1222
-            //     $tour_buttons .= implode('<br />', $tb);
1223
-            //     $tour_buttons .= '</div></div>';
1224
-            // }
1225
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
-            if (is_array($config) && isset($config['help_sidebar'])) {
1227
-                // check that the callback given is valid
1228
-                if (! method_exists($this, $config['help_sidebar'])) {
1229
-                    throw new EE_Error(
1230
-                        sprintf(
1231
-                            esc_html__(
1232
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1233
-                                'event_espresso'
1234
-                            ),
1235
-                            $config['help_sidebar'],
1236
-                            get_class($this)
1237
-                        )
1238
-                    );
1239
-                }
1240
-                $content = apply_filters(
1241
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
-                    $this->{$config['help_sidebar']}()
1243
-                );
1244
-                $content .= $tour_buttons; // add help tour buttons.
1245
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1246
-                $this->_current_screen->set_help_sidebar($content);
1247
-            }
1248
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1251
-            }
1252
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
-                $_ht['id']      = $this->page_slug;
1255
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
-                $_ht['content'] = '<p>'
1257
-                                  . esc_html__(
1258
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1259
-                                      'event_espresso'
1260
-                                  ) . '</p>';
1261
-                $this->_current_screen->add_help_tab($_ht);
1262
-            }
1263
-            if (! isset($config['help_tabs'])) {
1264
-                return;
1265
-            } //no help tabs for this route
1266
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
-                // we're here so there ARE help tabs!
1268
-                // make sure we've got what we need
1269
-                if (! isset($cfg['title'])) {
1270
-                    throw new EE_Error(
1271
-                        esc_html__(
1272
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
-                            'event_espresso'
1274
-                        )
1275
-                    );
1276
-                }
1277
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
-                    throw new EE_Error(
1279
-                        esc_html__(
1280
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1281
-                            'event_espresso'
1282
-                        )
1283
-                    );
1284
-                }
1285
-                // first priority goes to content.
1286
-                if (! empty($cfg['content'])) {
1287
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
-                    // second priority goes to filename
1289
-                } elseif (! empty($cfg['filename'])) {
1290
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1292
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
-                                                             . basename($this->_get_dir())
1294
-                                                             . '/help_tabs/'
1295
-                                                             . $cfg['filename']
1296
-                                                             . '.help_tab.php' : $file_path;
1297
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
-                        EE_Error::add_error(
1300
-                            sprintf(
1301
-                                esc_html__(
1302
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1303
-                                    'event_espresso'
1304
-                                ),
1305
-                                $tab_id,
1306
-                                key($config),
1307
-                                $file_path
1308
-                            ),
1309
-                            __FILE__,
1310
-                            __FUNCTION__,
1311
-                            __LINE__
1312
-                        );
1313
-                        return;
1314
-                    }
1315
-                    $template_args['admin_page_obj'] = $this;
1316
-                    $content                         = EEH_Template::display_template(
1317
-                        $file_path,
1318
-                        $template_args,
1319
-                        true
1320
-                    );
1321
-                } else {
1322
-                    $content = '';
1323
-                }
1324
-                // check if callback is valid
1325
-                if (
1326
-                    empty($content)
1327
-                    && (
1328
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
-                    )
1330
-                ) {
1331
-                    EE_Error::add_error(
1332
-                        sprintf(
1333
-                            esc_html__(
1334
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1335
-                                'event_espresso'
1336
-                            ),
1337
-                            $cfg['title']
1338
-                        ),
1339
-                        __FILE__,
1340
-                        __FUNCTION__,
1341
-                        __LINE__
1342
-                    );
1343
-                    return;
1344
-                }
1345
-                // setup config array for help tab method
1346
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
-                $_ht = [
1348
-                    'id'       => $id,
1349
-                    'title'    => $cfg['title'],
1350
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
-                    'content'  => $content,
1352
-                ];
1353
-                $this->_current_screen->add_help_tab($_ht);
1354
-            }
1355
-        }
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
-     * an array with properties for setting up usage of the joyride plugin
1362
-     *
1363
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
-     *         _set_page_config() comments
1366
-     * @return void
1367
-     * @throws InvalidArgumentException
1368
-     * @throws InvalidDataTypeException
1369
-     * @throws InvalidInterfaceException
1370
-     */
1371
-    protected function _add_help_tour()
1372
-    {
1373
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
-        // $tours = array();
1375
-        // $this->_help_tour = array();
1376
-        // // exit early if help tours are turned off globally
1377
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
-        // ) {
1380
-        //     return;
1381
-        // }
1382
-        // // loop through _page_config to find any help_tour defined
1383
-        // foreach ($this->_page_config as $route => $config) {
1384
-        //     // we're only going to set things up for this route
1385
-        //     if ($route !== $this->_req_action) {
1386
-        //         continue;
1387
-        //     }
1388
-        //     if (isset($config['help_tour'])) {
1389
-        //         foreach ($config['help_tour'] as $tour) {
1390
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
-        //             // let's see if we can get that file...
1392
-        //             // if not its possible this is a decaf route not set in caffeinated
1393
-        //             // so lets try and get the caffeinated equivalent
1394
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
-        //                                                      . basename($this->_get_dir())
1396
-        //                                                      . '/help_tours/'
1397
-        //                                                      . $tour
1398
-        //                                                      . '.class.php' : $file_path;
1399
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
-        //             if (! is_readable($file_path)) {
1401
-        //                 EE_Error::add_error(
1402
-        //                     sprintf(
1403
-        //                         esc_html__(
1404
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
-        //                             'event_espresso'
1406
-        //                         ),
1407
-        //                         $file_path,
1408
-        //                         $tour
1409
-        //                     ),
1410
-        //                     __FILE__,
1411
-        //                     __FUNCTION__,
1412
-        //                     __LINE__
1413
-        //                 );
1414
-        //                 return;
1415
-        //             }
1416
-        //             require_once $file_path;
1417
-        //             if (! class_exists($tour)) {
1418
-        //                 $error_msg[] = sprintf(
1419
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
-        //                     $tour
1421
-        //                 );
1422
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1423
-        //                                . sprintf(
1424
-        //                                    esc_html__(
1425
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
-        //                                        'event_espresso'
1427
-        //                                    ),
1428
-        //                                    $tour,
1429
-        //                                    '<br />',
1430
-        //                                    $tour,
1431
-        //                                    $this->_req_action,
1432
-        //                                    get_class($this)
1433
-        //                                );
1434
-        //                 throw new EE_Error(implode('||', $error_msg));
1435
-        //             }
1436
-        //             $tour_obj = new $tour($this->_is_caf);
1437
-        //             $tours[] = $tour_obj;
1438
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
-        //         }
1440
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
-        //         $tours[] = $end_stop_tour;
1443
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
-        //     }
1445
-        // }
1446
-        //
1447
-        // if (! empty($tours)) {
1448
-        //     $this->_help_tour['tours'] = $tours;
1449
-        // }
1450
-        // // that's it!  Now that the $_help_tours property is set (or not)
1451
-        // // the scripts and html should be taken care of automatically.
1452
-        //
1453
-        // /**
1454
-        //  * Allow extending the help tours variable.
1455
-        //  *
1456
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
-        //  */
1458
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
-    }
1460
-
1461
-
1462
-    /**
1463
-     * This simply sets up any qtips that have been defined in the page config
1464
-     *
1465
-     * @return void
1466
-     */
1467
-    protected function _add_qtips()
1468
-    {
1469
-        if (isset($this->_route_config['qtips'])) {
1470
-            $qtips = (array) $this->_route_config['qtips'];
1471
-            // load qtip loader
1472
-            $path = [
1473
-                $this->_get_dir() . '/qtips/',
1474
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
-            ];
1476
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
-        }
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * _set_nav_tabs
1483
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
-     * wish to add additional tabs or modify accordingly.
1485
-     *
1486
-     * @return void
1487
-     * @throws InvalidArgumentException
1488
-     * @throws InvalidInterfaceException
1489
-     * @throws InvalidDataTypeException
1490
-     */
1491
-    protected function _set_nav_tabs()
1492
-    {
1493
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
-        $i = 0;
1495
-        foreach ($this->_page_config as $slug => $config) {
1496
-            if (! is_array($config) || empty($config['nav'])) {
1497
-                continue;
1498
-            }
1499
-            // no nav tab for this config
1500
-            // check for persistent flag
1501
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
-                // nav tab is only to appear when route requested.
1503
-                continue;
1504
-            }
1505
-            if (! $this->check_user_access($slug, true)) {
1506
-                // no nav tab because current user does not have access.
1507
-                continue;
1508
-            }
1509
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
-            $this->_nav_tabs[ $slug ] = [
1511
-                'url'       => isset($config['nav']['url'])
1512
-                    ? $config['nav']['url']
1513
-                    : self::add_query_args_and_nonce(
1514
-                        ['action' => $slug],
1515
-                        $this->_admin_base_url
1516
-                    ),
1517
-                'link_text' => isset($config['nav']['label'])
1518
-                    ? $config['nav']['label']
1519
-                    : ucwords(
1520
-                        str_replace('_', ' ', $slug)
1521
-                    ),
1522
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
-            ];
1525
-            $i++;
1526
-        }
1527
-        // if $this->_nav_tabs is empty then lets set the default
1528
-        if (empty($this->_nav_tabs)) {
1529
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
-                'url'       => $this->_admin_base_url,
1531
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
-                'css_class' => 'nav-tab-active',
1533
-                'order'     => 10,
1534
-            ];
1535
-        }
1536
-        // now let's sort the tabs according to order
1537
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
-    }
1539
-
1540
-
1541
-    /**
1542
-     * _set_current_labels
1543
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
-     * property array
1545
-     *
1546
-     * @return void
1547
-     */
1548
-    private function _set_current_labels()
1549
-    {
1550
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
-            foreach ($this->_route_config['labels'] as $label => $text) {
1552
-                if (is_array($text)) {
1553
-                    foreach ($text as $sublabel => $subtext) {
1554
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1555
-                    }
1556
-                } else {
1557
-                    $this->_labels[ $label ] = $text;
1558
-                }
1559
-            }
1560
-        }
1561
-    }
1562
-
1563
-
1564
-    /**
1565
-     *        verifies user access for this admin page
1566
-     *
1567
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
-     *                               return false if verify fail.
1570
-     * @return bool
1571
-     * @throws InvalidArgumentException
1572
-     * @throws InvalidDataTypeException
1573
-     * @throws InvalidInterfaceException
1574
-     */
1575
-    public function check_user_access($route_to_check = '', $verify_only = false)
1576
-    {
1577
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
-                          && is_array(
1581
-                              $this->_page_routes[ $route_to_check ]
1582
-                          )
1583
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
-        if (empty($capability) && empty($route_to_check)) {
1586
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
-                : $this->_route['capability'];
1588
-        } else {
1589
-            $capability = empty($capability) ? 'manage_options' : $capability;
1590
-        }
1591
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
-        if (
1593
-            ! $this->request->isAjax()
1594
-            && (
1595
-                ! function_exists('is_admin')
1596
-                || ! EE_Registry::instance()->CAP->current_user_can(
1597
-                    $capability,
1598
-                    $this->page_slug
1599
-                    . '_'
1600
-                    . $route_to_check,
1601
-                    $id
1602
-                )
1603
-            )
1604
-        ) {
1605
-            if ($verify_only) {
1606
-                return false;
1607
-            }
1608
-            if (is_user_logged_in()) {
1609
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
-            } else {
1611
-                return false;
1612
-            }
1613
-        }
1614
-        return true;
1615
-    }
1616
-
1617
-
1618
-    /**
1619
-     * admin_init_global
1620
-     * This runs all the code that we want executed within the WP admin_init hook.
1621
-     * This method executes for ALL EE Admin pages.
1622
-     *
1623
-     * @return void
1624
-     */
1625
-    public function admin_init_global()
1626
-    {
1627
-    }
1628
-
1629
-
1630
-    /**
1631
-     * wp_loaded_global
1632
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
-     * EE_Admin page and will execute on every EE Admin Page load
1634
-     *
1635
-     * @return void
1636
-     */
1637
-    public function wp_loaded()
1638
-    {
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * admin_notices
1644
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
-     * ALL EE_Admin pages.
1646
-     *
1647
-     * @return void
1648
-     */
1649
-    public function admin_notices_global()
1650
-    {
1651
-        $this->_display_no_javascript_warning();
1652
-        $this->_display_espresso_notices();
1653
-    }
1654
-
1655
-
1656
-    public function network_admin_notices_global()
1657
-    {
1658
-        $this->_display_no_javascript_warning();
1659
-        $this->_display_espresso_notices();
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     * admin_footer_scripts_global
1665
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
-     * will apply on ALL EE_Admin pages.
1667
-     *
1668
-     * @return void
1669
-     */
1670
-    public function admin_footer_scripts_global()
1671
-    {
1672
-        $this->_add_admin_page_ajax_loading_img();
1673
-        $this->_add_admin_page_overlay();
1674
-        // if metaboxes are present we need to add the nonce field
1675
-        if (
1676
-            isset($this->_route_config['metaboxes'])
1677
-            || isset($this->_route_config['list_table'])
1678
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
-        ) {
1680
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
-        }
1683
-    }
1684
-
1685
-
1686
-    /**
1687
-     * admin_footer_global
1688
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
-     * ALL EE_Admin Pages.
1690
-     *
1691
-     * @return void
1692
-     */
1693
-    public function admin_footer_global()
1694
-    {
1695
-        // dialog container for dialog helper
1696
-        echo '
1044
+				(
1045
+					(
1046
+						method_exists($class, $method)
1047
+						&& call_user_func_array([$class, $method], $args) === false
1048
+					)
1049
+					&& (
1050
+						// is it a standalone function that doesn't work?
1051
+						function_exists($method)
1052
+						&& call_user_func_array(
1053
+							$func,
1054
+							array_merge(['admin_page_object' => $this], $args)
1055
+						) === false
1056
+					)
1057
+				)
1058
+				|| (
1059
+					// is it neither a class method NOR a standalone function?
1060
+					! method_exists($class, $method)
1061
+					&& ! function_exists($method)
1062
+				)
1063
+			) {
1064
+				// user error msg
1065
+				$error_msg = esc_html__(
1066
+					'An error occurred. The  requested page route could not be found.',
1067
+					'event_espresso'
1068
+				);
1069
+				// developer error msg
1070
+				$error_msg .= '||';
1071
+				$error_msg .= sprintf(
1072
+					esc_html__(
1073
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
+						'event_espresso'
1075
+					),
1076
+					$method
1077
+				);
1078
+			}
1079
+			if (! empty($error_msg)) {
1080
+				throw new EE_Error($error_msg);
1081
+			}
1082
+		}
1083
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1084
+		// then we need to reset the routing properties to the new route.
1085
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1086
+		if (
1087
+			$this->_is_UI_request === false
1088
+			&& is_array($this->_route)
1089
+			&& ! empty($this->_route['headers_sent_route'])
1090
+		) {
1091
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * This method just allows the resetting of page properties in the case where a no headers
1098
+	 * route redirects to a headers route in its route config.
1099
+	 *
1100
+	 * @param string $new_route New (non header) route to redirect to.
1101
+	 * @return   void
1102
+	 * @throws ReflectionException
1103
+	 * @throws InvalidArgumentException
1104
+	 * @throws InvalidInterfaceException
1105
+	 * @throws InvalidDataTypeException
1106
+	 * @throws EE_Error
1107
+	 * @since   4.3.0
1108
+	 */
1109
+	protected function _reset_routing_properties($new_route)
1110
+	{
1111
+		$this->_is_UI_request = true;
1112
+		// now we set the current route to whatever the headers_sent_route is set at
1113
+		$this->request->setRequestParam('action', $new_route);
1114
+		// rerun page setup
1115
+		$this->_page_setup();
1116
+	}
1117
+
1118
+
1119
+	/**
1120
+	 * _add_query_arg
1121
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1122
+	 *(internally just uses EEH_URL's function with the same name)
1123
+	 *
1124
+	 * @param array  $args
1125
+	 * @param string $url
1126
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
+	 *                                        Example usage: If the current page is:
1129
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
+	 *                                        &action=default&event_id=20&month_range=March%202015
1131
+	 *                                        &_wpnonce=5467821
1132
+	 *                                        and you call:
1133
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
+	 *                                        array(
1135
+	 *                                        'action' => 'resend_something',
1136
+	 *                                        'page=>espresso_registrations'
1137
+	 *                                        ),
1138
+	 *                                        $some_url,
1139
+	 *                                        true
1140
+	 *                                        );
1141
+	 *                                        It will produce a url in this structure:
1142
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
+	 *                                        month_range]=March%202015
1145
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
+	 * @return string
1147
+	 */
1148
+	public static function add_query_args_and_nonce(
1149
+		$args = [],
1150
+		$url = false,
1151
+		$sticky = false,
1152
+		$exclude_nonce = false
1153
+	) {
1154
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
+		if ($sticky) {
1156
+			/** @var RequestInterface $request */
1157
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
+			foreach ($request->requestParams() as $key => $value) {
1160
+				// do not add nonces
1161
+				if (strpos($key, 'nonce') !== false) {
1162
+					continue;
1163
+				}
1164
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1165
+			}
1166
+		}
1167
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * This returns a generated link that will load the related help tab.
1173
+	 *
1174
+	 * @param string $help_tab_id the id for the connected help tab
1175
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
+	 * @return string              generated link
1178
+	 * @uses EEH_Template::get_help_tab_link()
1179
+	 */
1180
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
+	{
1182
+		return EEH_Template::get_help_tab_link(
1183
+			$help_tab_id,
1184
+			$this->page_slug,
1185
+			$this->_req_action,
1186
+			$icon_style,
1187
+			$help_text
1188
+		);
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * _add_help_tabs
1194
+	 * Note child classes define their help tabs within the page_config array.
1195
+	 *
1196
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
+	 * @return void
1198
+	 * @throws DomainException
1199
+	 * @throws EE_Error
1200
+	 */
1201
+	protected function _add_help_tabs()
1202
+	{
1203
+		$tour_buttons = '';
1204
+		if (isset($this->_page_config[ $this->_req_action ])) {
1205
+			$config = $this->_page_config[ $this->_req_action ];
1206
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1208
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1209
+			//     $tb = array();
1210
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1212
+			//         // if this is the end tour then we don't need to setup a button
1213
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
+			//             continue;
1215
+			//         }
1216
+			//         $tb[] = '<button id="trigger-tour-'
1217
+			//                 . $tour->get_slug()
1218
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1219
+			//                 . $tour->get_label()
1220
+			//                 . '</button>';
1221
+			//     }
1222
+			//     $tour_buttons .= implode('<br />', $tb);
1223
+			//     $tour_buttons .= '</div></div>';
1224
+			// }
1225
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
+			if (is_array($config) && isset($config['help_sidebar'])) {
1227
+				// check that the callback given is valid
1228
+				if (! method_exists($this, $config['help_sidebar'])) {
1229
+					throw new EE_Error(
1230
+						sprintf(
1231
+							esc_html__(
1232
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1233
+								'event_espresso'
1234
+							),
1235
+							$config['help_sidebar'],
1236
+							get_class($this)
1237
+						)
1238
+					);
1239
+				}
1240
+				$content = apply_filters(
1241
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
+					$this->{$config['help_sidebar']}()
1243
+				);
1244
+				$content .= $tour_buttons; // add help tour buttons.
1245
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1246
+				$this->_current_screen->set_help_sidebar($content);
1247
+			}
1248
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1251
+			}
1252
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
+				$_ht['id']      = $this->page_slug;
1255
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
+				$_ht['content'] = '<p>'
1257
+								  . esc_html__(
1258
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1259
+									  'event_espresso'
1260
+								  ) . '</p>';
1261
+				$this->_current_screen->add_help_tab($_ht);
1262
+			}
1263
+			if (! isset($config['help_tabs'])) {
1264
+				return;
1265
+			} //no help tabs for this route
1266
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
+				// we're here so there ARE help tabs!
1268
+				// make sure we've got what we need
1269
+				if (! isset($cfg['title'])) {
1270
+					throw new EE_Error(
1271
+						esc_html__(
1272
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
+							'event_espresso'
1274
+						)
1275
+					);
1276
+				}
1277
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
+					throw new EE_Error(
1279
+						esc_html__(
1280
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1281
+							'event_espresso'
1282
+						)
1283
+					);
1284
+				}
1285
+				// first priority goes to content.
1286
+				if (! empty($cfg['content'])) {
1287
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
+					// second priority goes to filename
1289
+				} elseif (! empty($cfg['filename'])) {
1290
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1292
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
+															 . basename($this->_get_dir())
1294
+															 . '/help_tabs/'
1295
+															 . $cfg['filename']
1296
+															 . '.help_tab.php' : $file_path;
1297
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
+						EE_Error::add_error(
1300
+							sprintf(
1301
+								esc_html__(
1302
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1303
+									'event_espresso'
1304
+								),
1305
+								$tab_id,
1306
+								key($config),
1307
+								$file_path
1308
+							),
1309
+							__FILE__,
1310
+							__FUNCTION__,
1311
+							__LINE__
1312
+						);
1313
+						return;
1314
+					}
1315
+					$template_args['admin_page_obj'] = $this;
1316
+					$content                         = EEH_Template::display_template(
1317
+						$file_path,
1318
+						$template_args,
1319
+						true
1320
+					);
1321
+				} else {
1322
+					$content = '';
1323
+				}
1324
+				// check if callback is valid
1325
+				if (
1326
+					empty($content)
1327
+					&& (
1328
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
+					)
1330
+				) {
1331
+					EE_Error::add_error(
1332
+						sprintf(
1333
+							esc_html__(
1334
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1335
+								'event_espresso'
1336
+							),
1337
+							$cfg['title']
1338
+						),
1339
+						__FILE__,
1340
+						__FUNCTION__,
1341
+						__LINE__
1342
+					);
1343
+					return;
1344
+				}
1345
+				// setup config array for help tab method
1346
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
+				$_ht = [
1348
+					'id'       => $id,
1349
+					'title'    => $cfg['title'],
1350
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
+					'content'  => $content,
1352
+				];
1353
+				$this->_current_screen->add_help_tab($_ht);
1354
+			}
1355
+		}
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
+	 * an array with properties for setting up usage of the joyride plugin
1362
+	 *
1363
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
+	 *         _set_page_config() comments
1366
+	 * @return void
1367
+	 * @throws InvalidArgumentException
1368
+	 * @throws InvalidDataTypeException
1369
+	 * @throws InvalidInterfaceException
1370
+	 */
1371
+	protected function _add_help_tour()
1372
+	{
1373
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
+		// $tours = array();
1375
+		// $this->_help_tour = array();
1376
+		// // exit early if help tours are turned off globally
1377
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
+		// ) {
1380
+		//     return;
1381
+		// }
1382
+		// // loop through _page_config to find any help_tour defined
1383
+		// foreach ($this->_page_config as $route => $config) {
1384
+		//     // we're only going to set things up for this route
1385
+		//     if ($route !== $this->_req_action) {
1386
+		//         continue;
1387
+		//     }
1388
+		//     if (isset($config['help_tour'])) {
1389
+		//         foreach ($config['help_tour'] as $tour) {
1390
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
+		//             // let's see if we can get that file...
1392
+		//             // if not its possible this is a decaf route not set in caffeinated
1393
+		//             // so lets try and get the caffeinated equivalent
1394
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
+		//                                                      . basename($this->_get_dir())
1396
+		//                                                      . '/help_tours/'
1397
+		//                                                      . $tour
1398
+		//                                                      . '.class.php' : $file_path;
1399
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
+		//             if (! is_readable($file_path)) {
1401
+		//                 EE_Error::add_error(
1402
+		//                     sprintf(
1403
+		//                         esc_html__(
1404
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
+		//                             'event_espresso'
1406
+		//                         ),
1407
+		//                         $file_path,
1408
+		//                         $tour
1409
+		//                     ),
1410
+		//                     __FILE__,
1411
+		//                     __FUNCTION__,
1412
+		//                     __LINE__
1413
+		//                 );
1414
+		//                 return;
1415
+		//             }
1416
+		//             require_once $file_path;
1417
+		//             if (! class_exists($tour)) {
1418
+		//                 $error_msg[] = sprintf(
1419
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
+		//                     $tour
1421
+		//                 );
1422
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1423
+		//                                . sprintf(
1424
+		//                                    esc_html__(
1425
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
+		//                                        'event_espresso'
1427
+		//                                    ),
1428
+		//                                    $tour,
1429
+		//                                    '<br />',
1430
+		//                                    $tour,
1431
+		//                                    $this->_req_action,
1432
+		//                                    get_class($this)
1433
+		//                                );
1434
+		//                 throw new EE_Error(implode('||', $error_msg));
1435
+		//             }
1436
+		//             $tour_obj = new $tour($this->_is_caf);
1437
+		//             $tours[] = $tour_obj;
1438
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
+		//         }
1440
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
+		//         $tours[] = $end_stop_tour;
1443
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
+		//     }
1445
+		// }
1446
+		//
1447
+		// if (! empty($tours)) {
1448
+		//     $this->_help_tour['tours'] = $tours;
1449
+		// }
1450
+		// // that's it!  Now that the $_help_tours property is set (or not)
1451
+		// // the scripts and html should be taken care of automatically.
1452
+		//
1453
+		// /**
1454
+		//  * Allow extending the help tours variable.
1455
+		//  *
1456
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
+		//  */
1458
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
+	}
1460
+
1461
+
1462
+	/**
1463
+	 * This simply sets up any qtips that have been defined in the page config
1464
+	 *
1465
+	 * @return void
1466
+	 */
1467
+	protected function _add_qtips()
1468
+	{
1469
+		if (isset($this->_route_config['qtips'])) {
1470
+			$qtips = (array) $this->_route_config['qtips'];
1471
+			// load qtip loader
1472
+			$path = [
1473
+				$this->_get_dir() . '/qtips/',
1474
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
+			];
1476
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
+		}
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * _set_nav_tabs
1483
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
+	 * wish to add additional tabs or modify accordingly.
1485
+	 *
1486
+	 * @return void
1487
+	 * @throws InvalidArgumentException
1488
+	 * @throws InvalidInterfaceException
1489
+	 * @throws InvalidDataTypeException
1490
+	 */
1491
+	protected function _set_nav_tabs()
1492
+	{
1493
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
+		$i = 0;
1495
+		foreach ($this->_page_config as $slug => $config) {
1496
+			if (! is_array($config) || empty($config['nav'])) {
1497
+				continue;
1498
+			}
1499
+			// no nav tab for this config
1500
+			// check for persistent flag
1501
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
+				// nav tab is only to appear when route requested.
1503
+				continue;
1504
+			}
1505
+			if (! $this->check_user_access($slug, true)) {
1506
+				// no nav tab because current user does not have access.
1507
+				continue;
1508
+			}
1509
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
+			$this->_nav_tabs[ $slug ] = [
1511
+				'url'       => isset($config['nav']['url'])
1512
+					? $config['nav']['url']
1513
+					: self::add_query_args_and_nonce(
1514
+						['action' => $slug],
1515
+						$this->_admin_base_url
1516
+					),
1517
+				'link_text' => isset($config['nav']['label'])
1518
+					? $config['nav']['label']
1519
+					: ucwords(
1520
+						str_replace('_', ' ', $slug)
1521
+					),
1522
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
+			];
1525
+			$i++;
1526
+		}
1527
+		// if $this->_nav_tabs is empty then lets set the default
1528
+		if (empty($this->_nav_tabs)) {
1529
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
+				'url'       => $this->_admin_base_url,
1531
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
+				'css_class' => 'nav-tab-active',
1533
+				'order'     => 10,
1534
+			];
1535
+		}
1536
+		// now let's sort the tabs according to order
1537
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
+	}
1539
+
1540
+
1541
+	/**
1542
+	 * _set_current_labels
1543
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
+	 * property array
1545
+	 *
1546
+	 * @return void
1547
+	 */
1548
+	private function _set_current_labels()
1549
+	{
1550
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
+			foreach ($this->_route_config['labels'] as $label => $text) {
1552
+				if (is_array($text)) {
1553
+					foreach ($text as $sublabel => $subtext) {
1554
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1555
+					}
1556
+				} else {
1557
+					$this->_labels[ $label ] = $text;
1558
+				}
1559
+			}
1560
+		}
1561
+	}
1562
+
1563
+
1564
+	/**
1565
+	 *        verifies user access for this admin page
1566
+	 *
1567
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
+	 *                               return false if verify fail.
1570
+	 * @return bool
1571
+	 * @throws InvalidArgumentException
1572
+	 * @throws InvalidDataTypeException
1573
+	 * @throws InvalidInterfaceException
1574
+	 */
1575
+	public function check_user_access($route_to_check = '', $verify_only = false)
1576
+	{
1577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
+						  && is_array(
1581
+							  $this->_page_routes[ $route_to_check ]
1582
+						  )
1583
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
+		if (empty($capability) && empty($route_to_check)) {
1586
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
+				: $this->_route['capability'];
1588
+		} else {
1589
+			$capability = empty($capability) ? 'manage_options' : $capability;
1590
+		}
1591
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
+		if (
1593
+			! $this->request->isAjax()
1594
+			&& (
1595
+				! function_exists('is_admin')
1596
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1597
+					$capability,
1598
+					$this->page_slug
1599
+					. '_'
1600
+					. $route_to_check,
1601
+					$id
1602
+				)
1603
+			)
1604
+		) {
1605
+			if ($verify_only) {
1606
+				return false;
1607
+			}
1608
+			if (is_user_logged_in()) {
1609
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
+			} else {
1611
+				return false;
1612
+			}
1613
+		}
1614
+		return true;
1615
+	}
1616
+
1617
+
1618
+	/**
1619
+	 * admin_init_global
1620
+	 * This runs all the code that we want executed within the WP admin_init hook.
1621
+	 * This method executes for ALL EE Admin pages.
1622
+	 *
1623
+	 * @return void
1624
+	 */
1625
+	public function admin_init_global()
1626
+	{
1627
+	}
1628
+
1629
+
1630
+	/**
1631
+	 * wp_loaded_global
1632
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
+	 * EE_Admin page and will execute on every EE Admin Page load
1634
+	 *
1635
+	 * @return void
1636
+	 */
1637
+	public function wp_loaded()
1638
+	{
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * admin_notices
1644
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
+	 * ALL EE_Admin pages.
1646
+	 *
1647
+	 * @return void
1648
+	 */
1649
+	public function admin_notices_global()
1650
+	{
1651
+		$this->_display_no_javascript_warning();
1652
+		$this->_display_espresso_notices();
1653
+	}
1654
+
1655
+
1656
+	public function network_admin_notices_global()
1657
+	{
1658
+		$this->_display_no_javascript_warning();
1659
+		$this->_display_espresso_notices();
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 * admin_footer_scripts_global
1665
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
+	 * will apply on ALL EE_Admin pages.
1667
+	 *
1668
+	 * @return void
1669
+	 */
1670
+	public function admin_footer_scripts_global()
1671
+	{
1672
+		$this->_add_admin_page_ajax_loading_img();
1673
+		$this->_add_admin_page_overlay();
1674
+		// if metaboxes are present we need to add the nonce field
1675
+		if (
1676
+			isset($this->_route_config['metaboxes'])
1677
+			|| isset($this->_route_config['list_table'])
1678
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
+		) {
1680
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
+		}
1683
+	}
1684
+
1685
+
1686
+	/**
1687
+	 * admin_footer_global
1688
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
+	 * ALL EE_Admin Pages.
1690
+	 *
1691
+	 * @return void
1692
+	 */
1693
+	public function admin_footer_global()
1694
+	{
1695
+		// dialog container for dialog helper
1696
+		echo '
1697 1697
         <div class="ee-admin-dialog-container auto-hide hidden">
1698 1698
             <div class="ee-notices"></div>
1699 1699
             <div class="ee-admin-dialog-container-inner-content"></div>
1700 1700
         </div>
1701 1701
         ';
1702 1702
 
1703
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
-        // help tour stuff?
1705
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1706
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
-        // }
1708
-        // current set timezone for timezone js
1709
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
-    }
1711
-
1712
-
1713
-    /**
1714
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
-     * help popups then in your templates or your content you set "triggers" for the content using the
1717
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
-     * for the
1721
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
-     *    'help_trigger_id' => array(
1724
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
-     *    )
1727
-     * );
1728
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
-     *
1730
-     * @param array $help_array
1731
-     * @param bool  $display
1732
-     * @return string content
1733
-     * @throws DomainException
1734
-     * @throws EE_Error
1735
-     */
1736
-    protected function _set_help_popup_content($help_array = [], $display = false)
1737
-    {
1738
-        $content    = '';
1739
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
-        // loop through the array and setup content
1741
-        foreach ($help_array as $trigger => $help) {
1742
-            // make sure the array is setup properly
1743
-            if (! isset($help['title']) || ! isset($help['content'])) {
1744
-                throw new EE_Error(
1745
-                    esc_html__(
1746
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1747
-                        'event_espresso'
1748
-                    )
1749
-                );
1750
-            }
1751
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1752
-            $template_args = [
1753
-                'help_popup_id'      => $trigger,
1754
-                'help_popup_title'   => $help['title'],
1755
-                'help_popup_content' => $help['content'],
1756
-            ];
1757
-            $content       .= EEH_Template::display_template(
1758
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
-                $template_args,
1760
-                true
1761
-            );
1762
-        }
1763
-        if ($display) {
1764
-            echo $content; // already escaped
1765
-            return '';
1766
-        }
1767
-        return $content;
1768
-    }
1769
-
1770
-
1771
-    /**
1772
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
-     *
1774
-     * @return array properly formatted array for help popup content
1775
-     * @throws EE_Error
1776
-     */
1777
-    private function _get_help_content()
1778
-    {
1779
-        // what is the method we're looking for?
1780
-        $method_name = '_help_popup_content_' . $this->_req_action;
1781
-        // if method doesn't exist let's get out.
1782
-        if (! method_exists($this, $method_name)) {
1783
-            return [];
1784
-        }
1785
-        // k we're good to go let's retrieve the help array
1786
-        $help_array = call_user_func([$this, $method_name]);
1787
-        // make sure we've got an array!
1788
-        if (! is_array($help_array)) {
1789
-            throw new EE_Error(
1790
-                esc_html__(
1791
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
-                    'event_espresso'
1793
-                )
1794
-            );
1795
-        }
1796
-        return $help_array;
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
-     *
1805
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
-     * @param boolean $display    if false then we return the trigger string
1807
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
-     * @return string
1809
-     * @throws DomainException
1810
-     * @throws EE_Error
1811
-     */
1812
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
-    {
1814
-        if ($this->request->isAjax()) {
1815
-            return '';
1816
-        }
1817
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1818
-        $help_array   = $this->_get_help_content();
1819
-        $help_content = '';
1820
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
-            $help_array[ $trigger_id ] = [
1822
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
-                'content' => esc_html__(
1824
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1825
-                    'event_espresso'
1826
-                ),
1827
-            ];
1828
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1829
-        }
1830
-        // let's setup the trigger
1831
-        $content = '<a class="ee-dialog" href="?height='
1832
-                   . esc_attr($dimensions[0])
1833
-                   . '&width='
1834
-                   . esc_attr($dimensions[1])
1835
-                   . '&inlineId='
1836
-                   . esc_attr($trigger_id)
1837
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
-        $content .= $help_content;
1839
-        if ($display) {
1840
-            echo $content; // already escaped
1841
-            return '';
1842
-        }
1843
-        return $content;
1844
-    }
1845
-
1846
-
1847
-    /**
1848
-     * _add_global_screen_options
1849
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1851
-     *
1852
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
-     *         see also WP_Screen object documents...
1854
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
-     * @abstract
1856
-     * @return void
1857
-     */
1858
-    private function _add_global_screen_options()
1859
-    {
1860
-    }
1861
-
1862
-
1863
-    /**
1864
-     * _add_global_feature_pointers
1865
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1868
-     *
1869
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
-     *         extended) also see:
1871
-     * @link   http://eamann.com/tech/wordpress-portland/
1872
-     * @abstract
1873
-     * @return void
1874
-     */
1875
-    private function _add_global_feature_pointers()
1876
-    {
1877
-    }
1878
-
1879
-
1880
-    /**
1881
-     * load_global_scripts_styles
1882
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
-     *
1884
-     * @return void
1885
-     */
1886
-    public function load_global_scripts_styles()
1887
-    {
1888
-        /** STYLES **/
1889
-        // add debugging styles
1890
-        if (WP_DEBUG) {
1891
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1892
-        }
1893
-        // register all styles
1894
-        wp_register_style(
1895
-            'espresso-ui-theme',
1896
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
-            [],
1898
-            EVENT_ESPRESSO_VERSION
1899
-        );
1900
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
-        // helpers styles
1902
-        wp_register_style(
1903
-            'ee-text-links',
1904
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
-            [],
1906
-            EVENT_ESPRESSO_VERSION
1907
-        );
1908
-        /** SCRIPTS **/
1909
-        // register all scripts
1910
-        wp_register_script(
1911
-            'ee-dialog',
1912
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
-            ['jquery', 'jquery-ui-draggable'],
1914
-            EVENT_ESPRESSO_VERSION,
1915
-            true
1916
-        );
1917
-        wp_register_script(
1918
-            'ee_admin_js',
1919
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
-            EVENT_ESPRESSO_VERSION,
1922
-            true
1923
-        );
1924
-        wp_register_script(
1925
-            'jquery-ui-timepicker-addon',
1926
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
-            EVENT_ESPRESSO_VERSION,
1929
-            true
1930
-        );
1931
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
-        //     add_filter('FHEE_load_joyride', '__return_true');
1934
-        // }
1935
-        // script for sorting tables
1936
-        wp_register_script(
1937
-            'espresso_ajax_table_sorting',
1938
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
-            ['ee_admin_js', 'jquery-ui-sortable'],
1940
-            EVENT_ESPRESSO_VERSION,
1941
-            true
1942
-        );
1943
-        // script for parsing uri's
1944
-        wp_register_script(
1945
-            'ee-parse-uri',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
-            [],
1948
-            EVENT_ESPRESSO_VERSION,
1949
-            true
1950
-        );
1951
-        // and parsing associative serialized form elements
1952
-        wp_register_script(
1953
-            'ee-serialize-full-array',
1954
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
-            ['jquery'],
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            true
1958
-        );
1959
-        // helpers scripts
1960
-        wp_register_script(
1961
-            'ee-text-links',
1962
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
-            ['jquery'],
1964
-            EVENT_ESPRESSO_VERSION,
1965
-            true
1966
-        );
1967
-        wp_register_script(
1968
-            'ee-moment-core',
1969
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
-            [],
1971
-            EVENT_ESPRESSO_VERSION,
1972
-            true
1973
-        );
1974
-        wp_register_script(
1975
-            'ee-moment',
1976
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
-            ['ee-moment-core'],
1978
-            EVENT_ESPRESSO_VERSION,
1979
-            true
1980
-        );
1981
-        wp_register_script(
1982
-            'ee-datepicker',
1983
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1985
-            EVENT_ESPRESSO_VERSION,
1986
-            true
1987
-        );
1988
-        // google charts
1989
-        wp_register_script(
1990
-            'google-charts',
1991
-            'https://www.gstatic.com/charts/loader.js',
1992
-            [],
1993
-            EVENT_ESPRESSO_VERSION,
1994
-            false
1995
-        );
1996
-        // ENQUEUE ALL BASICS BY DEFAULT
1997
-        wp_enqueue_style('ee-admin-css');
1998
-        wp_enqueue_script('ee_admin_js');
1999
-        wp_enqueue_script('ee-accounting');
2000
-        wp_enqueue_script('jquery-validate');
2001
-        // taking care of metaboxes
2002
-        if (
2003
-            empty($this->_cpt_route)
2004
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
-        ) {
2006
-            wp_enqueue_script('dashboard');
2007
-        }
2008
-        // LOCALIZED DATA
2009
-        // localize script for ajax lazy loading
2010
-        $lazy_loader_container_ids = apply_filters(
2011
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
-            ['espresso_news_post_box_content']
2013
-        );
2014
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
-        // /**
2017
-        //  * help tour stuff
2018
-        //  */
2019
-        // if (! empty($this->_help_tour)) {
2020
-        //     // register the js for kicking things off
2021
-        //     wp_enqueue_script(
2022
-        //         'ee-help-tour',
2023
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
-        //         array('jquery-joyride'),
2025
-        //         EVENT_ESPRESSO_VERSION,
2026
-        //         true
2027
-        //     );
2028
-        //     $tours = array();
2029
-        //     // setup tours for the js tour object
2030
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2031
-        //         if ($tour instanceof EE_Help_Tour) {
2032
-        //             $tours[] = array(
2033
-        //                 'id'      => $tour->get_slug(),
2034
-        //                 'options' => $tour->get_options(),
2035
-        //             );
2036
-        //         }
2037
-        //     }
2038
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
-        // }
2041
-
2042
-        add_filter(
2043
-            'admin_body_class',
2044
-            function ($classes) {
2045
-                if (strpos($classes, 'espresso-admin') === false) {
2046
-                    $classes .= ' espresso-admin';
2047
-                }
2048
-                return $classes;
2049
-            }
2050
-        );
2051
-    }
2052
-
2053
-
2054
-    /**
2055
-     *        admin_footer_scripts_eei18n_js_strings
2056
-     *
2057
-     * @return        void
2058
-     */
2059
-    public function admin_footer_scripts_eei18n_js_strings()
2060
-    {
2061
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
-            __(
2064
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2065
-                'event_espresso'
2066
-            )
2067
-        );
2068
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
-    }
2107
-
2108
-
2109
-    /**
2110
-     *        load enhanced xdebug styles for ppl with failing eyesight
2111
-     *
2112
-     * @return        void
2113
-     */
2114
-    public function add_xdebug_style()
2115
-    {
2116
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
-    }
2118
-
2119
-
2120
-    /************************/
2121
-    /** LIST TABLE METHODS **/
2122
-    /************************/
2123
-    /**
2124
-     * this sets up the list table if the current view requires it.
2125
-     *
2126
-     * @return void
2127
-     * @throws EE_Error
2128
-     */
2129
-    protected function _set_list_table()
2130
-    {
2131
-        // first is this a list_table view?
2132
-        if (! isset($this->_route_config['list_table'])) {
2133
-            return;
2134
-        } //not a list_table view so get out.
2135
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2136
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
-            // user error msg
2139
-            $error_msg = esc_html__(
2140
-                'An error occurred. The requested list table views could not be found.',
2141
-                'event_espresso'
2142
-            );
2143
-            // developer error msg
2144
-            $error_msg .= '||'
2145
-                          . sprintf(
2146
-                              esc_html__(
2147
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2148
-                                  'event_espresso'
2149
-                              ),
2150
-                              $this->_req_action,
2151
-                              $list_table_view
2152
-                          );
2153
-            throw new EE_Error($error_msg);
2154
-        }
2155
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
-        $this->_views = apply_filters(
2157
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
-            $this->_views
2159
-        );
2160
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
-        $this->_set_list_table_view();
2163
-        $this->_set_list_table_object();
2164
-    }
2165
-
2166
-
2167
-    /**
2168
-     * set current view for List Table
2169
-     *
2170
-     * @return void
2171
-     */
2172
-    protected function _set_list_table_view()
2173
-    {
2174
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
-        $status = $this->request->getRequestParam('status', null, 'key');
2176
-        $this->_view = $status && array_key_exists($status, $this->_views)
2177
-            ? $status
2178
-            : $this->_view;
2179
-    }
2180
-
2181
-
2182
-    /**
2183
-     * _set_list_table_object
2184
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
-     *
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws InvalidArgumentException
2188
-     * @throws InvalidDataTypeException
2189
-     * @throws EE_Error
2190
-     * @throws InvalidInterfaceException
2191
-     */
2192
-    protected function _set_list_table_object()
2193
-    {
2194
-        if (isset($this->_route_config['list_table'])) {
2195
-            if (! class_exists($this->_route_config['list_table'])) {
2196
-                throw new EE_Error(
2197
-                    sprintf(
2198
-                        esc_html__(
2199
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2200
-                            'event_espresso'
2201
-                        ),
2202
-                        $this->_route_config['list_table'],
2203
-                        get_class($this)
2204
-                    )
2205
-                );
2206
-            }
2207
-            $this->_list_table_object = $this->loader->getShared(
2208
-                $this->_route_config['list_table'],
2209
-                [$this]
2210
-            );
2211
-        }
2212
-    }
2213
-
2214
-
2215
-    /**
2216
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
-     *
2218
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
-     *                                                    urls.  The array should be indexed by the view it is being
2220
-     *                                                    added to.
2221
-     * @return array
2222
-     */
2223
-    public function get_list_table_view_RLs($extra_query_args = [])
2224
-    {
2225
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
-        if (empty($this->_views)) {
2227
-            $this->_views = [];
2228
-        }
2229
-        // cycle thru views
2230
-        foreach ($this->_views as $key => $view) {
2231
-            $query_args = [];
2232
-            // check for current view
2233
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
-            $query_args['action']                        = $this->_req_action;
2235
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
-            $query_args['status']                        = $view['slug'];
2237
-            // merge any other arguments sent in.
2238
-            if (isset($extra_query_args[ $view['slug'] ])) {
2239
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
-            }
2241
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
-        }
2243
-        return $this->_views;
2244
-    }
2245
-
2246
-
2247
-    /**
2248
-     * _entries_per_page_dropdown
2249
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
-     *
2251
-     * @param int $max_entries total number of rows in the table
2252
-     * @return string
2253
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
-     *         WP does it.
2255
-     */
2256
-    protected function _entries_per_page_dropdown($max_entries = 0)
2257
-    {
2258
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
-        $values   = [10, 25, 50, 100];
2260
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
-        if ($max_entries) {
2262
-            $values[] = $max_entries;
2263
-            sort($values);
2264
-        }
2265
-        $entries_per_page_dropdown = '
1703
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
+		// help tour stuff?
1705
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1706
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
+		// }
1708
+		// current set timezone for timezone js
1709
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
+	}
1711
+
1712
+
1713
+	/**
1714
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1717
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
+	 * for the
1721
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
+	 *    'help_trigger_id' => array(
1724
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
+	 *    )
1727
+	 * );
1728
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
+	 *
1730
+	 * @param array $help_array
1731
+	 * @param bool  $display
1732
+	 * @return string content
1733
+	 * @throws DomainException
1734
+	 * @throws EE_Error
1735
+	 */
1736
+	protected function _set_help_popup_content($help_array = [], $display = false)
1737
+	{
1738
+		$content    = '';
1739
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
+		// loop through the array and setup content
1741
+		foreach ($help_array as $trigger => $help) {
1742
+			// make sure the array is setup properly
1743
+			if (! isset($help['title']) || ! isset($help['content'])) {
1744
+				throw new EE_Error(
1745
+					esc_html__(
1746
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1747
+						'event_espresso'
1748
+					)
1749
+				);
1750
+			}
1751
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1752
+			$template_args = [
1753
+				'help_popup_id'      => $trigger,
1754
+				'help_popup_title'   => $help['title'],
1755
+				'help_popup_content' => $help['content'],
1756
+			];
1757
+			$content       .= EEH_Template::display_template(
1758
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
+				$template_args,
1760
+				true
1761
+			);
1762
+		}
1763
+		if ($display) {
1764
+			echo $content; // already escaped
1765
+			return '';
1766
+		}
1767
+		return $content;
1768
+	}
1769
+
1770
+
1771
+	/**
1772
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
+	 *
1774
+	 * @return array properly formatted array for help popup content
1775
+	 * @throws EE_Error
1776
+	 */
1777
+	private function _get_help_content()
1778
+	{
1779
+		// what is the method we're looking for?
1780
+		$method_name = '_help_popup_content_' . $this->_req_action;
1781
+		// if method doesn't exist let's get out.
1782
+		if (! method_exists($this, $method_name)) {
1783
+			return [];
1784
+		}
1785
+		// k we're good to go let's retrieve the help array
1786
+		$help_array = call_user_func([$this, $method_name]);
1787
+		// make sure we've got an array!
1788
+		if (! is_array($help_array)) {
1789
+			throw new EE_Error(
1790
+				esc_html__(
1791
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
+					'event_espresso'
1793
+				)
1794
+			);
1795
+		}
1796
+		return $help_array;
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
+	 *
1805
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
+	 * @param boolean $display    if false then we return the trigger string
1807
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
+	 * @return string
1809
+	 * @throws DomainException
1810
+	 * @throws EE_Error
1811
+	 */
1812
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
+	{
1814
+		if ($this->request->isAjax()) {
1815
+			return '';
1816
+		}
1817
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1818
+		$help_array   = $this->_get_help_content();
1819
+		$help_content = '';
1820
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
+			$help_array[ $trigger_id ] = [
1822
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
+				'content' => esc_html__(
1824
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1825
+					'event_espresso'
1826
+				),
1827
+			];
1828
+			$help_content              = $this->_set_help_popup_content($help_array, false);
1829
+		}
1830
+		// let's setup the trigger
1831
+		$content = '<a class="ee-dialog" href="?height='
1832
+				   . esc_attr($dimensions[0])
1833
+				   . '&width='
1834
+				   . esc_attr($dimensions[1])
1835
+				   . '&inlineId='
1836
+				   . esc_attr($trigger_id)
1837
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
+		$content .= $help_content;
1839
+		if ($display) {
1840
+			echo $content; // already escaped
1841
+			return '';
1842
+		}
1843
+		return $content;
1844
+	}
1845
+
1846
+
1847
+	/**
1848
+	 * _add_global_screen_options
1849
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1851
+	 *
1852
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
+	 *         see also WP_Screen object documents...
1854
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
+	 * @abstract
1856
+	 * @return void
1857
+	 */
1858
+	private function _add_global_screen_options()
1859
+	{
1860
+	}
1861
+
1862
+
1863
+	/**
1864
+	 * _add_global_feature_pointers
1865
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1868
+	 *
1869
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
+	 *         extended) also see:
1871
+	 * @link   http://eamann.com/tech/wordpress-portland/
1872
+	 * @abstract
1873
+	 * @return void
1874
+	 */
1875
+	private function _add_global_feature_pointers()
1876
+	{
1877
+	}
1878
+
1879
+
1880
+	/**
1881
+	 * load_global_scripts_styles
1882
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
+	 *
1884
+	 * @return void
1885
+	 */
1886
+	public function load_global_scripts_styles()
1887
+	{
1888
+		/** STYLES **/
1889
+		// add debugging styles
1890
+		if (WP_DEBUG) {
1891
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1892
+		}
1893
+		// register all styles
1894
+		wp_register_style(
1895
+			'espresso-ui-theme',
1896
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
+			[],
1898
+			EVENT_ESPRESSO_VERSION
1899
+		);
1900
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
+		// helpers styles
1902
+		wp_register_style(
1903
+			'ee-text-links',
1904
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
+			[],
1906
+			EVENT_ESPRESSO_VERSION
1907
+		);
1908
+		/** SCRIPTS **/
1909
+		// register all scripts
1910
+		wp_register_script(
1911
+			'ee-dialog',
1912
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
+			['jquery', 'jquery-ui-draggable'],
1914
+			EVENT_ESPRESSO_VERSION,
1915
+			true
1916
+		);
1917
+		wp_register_script(
1918
+			'ee_admin_js',
1919
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
+			EVENT_ESPRESSO_VERSION,
1922
+			true
1923
+		);
1924
+		wp_register_script(
1925
+			'jquery-ui-timepicker-addon',
1926
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
+			EVENT_ESPRESSO_VERSION,
1929
+			true
1930
+		);
1931
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
+		//     add_filter('FHEE_load_joyride', '__return_true');
1934
+		// }
1935
+		// script for sorting tables
1936
+		wp_register_script(
1937
+			'espresso_ajax_table_sorting',
1938
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
+			['ee_admin_js', 'jquery-ui-sortable'],
1940
+			EVENT_ESPRESSO_VERSION,
1941
+			true
1942
+		);
1943
+		// script for parsing uri's
1944
+		wp_register_script(
1945
+			'ee-parse-uri',
1946
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
+			[],
1948
+			EVENT_ESPRESSO_VERSION,
1949
+			true
1950
+		);
1951
+		// and parsing associative serialized form elements
1952
+		wp_register_script(
1953
+			'ee-serialize-full-array',
1954
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
+			['jquery'],
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			true
1958
+		);
1959
+		// helpers scripts
1960
+		wp_register_script(
1961
+			'ee-text-links',
1962
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
+			['jquery'],
1964
+			EVENT_ESPRESSO_VERSION,
1965
+			true
1966
+		);
1967
+		wp_register_script(
1968
+			'ee-moment-core',
1969
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
+			[],
1971
+			EVENT_ESPRESSO_VERSION,
1972
+			true
1973
+		);
1974
+		wp_register_script(
1975
+			'ee-moment',
1976
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
+			['ee-moment-core'],
1978
+			EVENT_ESPRESSO_VERSION,
1979
+			true
1980
+		);
1981
+		wp_register_script(
1982
+			'ee-datepicker',
1983
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1985
+			EVENT_ESPRESSO_VERSION,
1986
+			true
1987
+		);
1988
+		// google charts
1989
+		wp_register_script(
1990
+			'google-charts',
1991
+			'https://www.gstatic.com/charts/loader.js',
1992
+			[],
1993
+			EVENT_ESPRESSO_VERSION,
1994
+			false
1995
+		);
1996
+		// ENQUEUE ALL BASICS BY DEFAULT
1997
+		wp_enqueue_style('ee-admin-css');
1998
+		wp_enqueue_script('ee_admin_js');
1999
+		wp_enqueue_script('ee-accounting');
2000
+		wp_enqueue_script('jquery-validate');
2001
+		// taking care of metaboxes
2002
+		if (
2003
+			empty($this->_cpt_route)
2004
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
+		) {
2006
+			wp_enqueue_script('dashboard');
2007
+		}
2008
+		// LOCALIZED DATA
2009
+		// localize script for ajax lazy loading
2010
+		$lazy_loader_container_ids = apply_filters(
2011
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
+			['espresso_news_post_box_content']
2013
+		);
2014
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
+		// /**
2017
+		//  * help tour stuff
2018
+		//  */
2019
+		// if (! empty($this->_help_tour)) {
2020
+		//     // register the js for kicking things off
2021
+		//     wp_enqueue_script(
2022
+		//         'ee-help-tour',
2023
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
+		//         array('jquery-joyride'),
2025
+		//         EVENT_ESPRESSO_VERSION,
2026
+		//         true
2027
+		//     );
2028
+		//     $tours = array();
2029
+		//     // setup tours for the js tour object
2030
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2031
+		//         if ($tour instanceof EE_Help_Tour) {
2032
+		//             $tours[] = array(
2033
+		//                 'id'      => $tour->get_slug(),
2034
+		//                 'options' => $tour->get_options(),
2035
+		//             );
2036
+		//         }
2037
+		//     }
2038
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
+		// }
2041
+
2042
+		add_filter(
2043
+			'admin_body_class',
2044
+			function ($classes) {
2045
+				if (strpos($classes, 'espresso-admin') === false) {
2046
+					$classes .= ' espresso-admin';
2047
+				}
2048
+				return $classes;
2049
+			}
2050
+		);
2051
+	}
2052
+
2053
+
2054
+	/**
2055
+	 *        admin_footer_scripts_eei18n_js_strings
2056
+	 *
2057
+	 * @return        void
2058
+	 */
2059
+	public function admin_footer_scripts_eei18n_js_strings()
2060
+	{
2061
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
+			__(
2064
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2065
+				'event_espresso'
2066
+			)
2067
+		);
2068
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
+	}
2107
+
2108
+
2109
+	/**
2110
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2111
+	 *
2112
+	 * @return        void
2113
+	 */
2114
+	public function add_xdebug_style()
2115
+	{
2116
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
+	}
2118
+
2119
+
2120
+	/************************/
2121
+	/** LIST TABLE METHODS **/
2122
+	/************************/
2123
+	/**
2124
+	 * this sets up the list table if the current view requires it.
2125
+	 *
2126
+	 * @return void
2127
+	 * @throws EE_Error
2128
+	 */
2129
+	protected function _set_list_table()
2130
+	{
2131
+		// first is this a list_table view?
2132
+		if (! isset($this->_route_config['list_table'])) {
2133
+			return;
2134
+		} //not a list_table view so get out.
2135
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2136
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
+			// user error msg
2139
+			$error_msg = esc_html__(
2140
+				'An error occurred. The requested list table views could not be found.',
2141
+				'event_espresso'
2142
+			);
2143
+			// developer error msg
2144
+			$error_msg .= '||'
2145
+						  . sprintf(
2146
+							  esc_html__(
2147
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2148
+								  'event_espresso'
2149
+							  ),
2150
+							  $this->_req_action,
2151
+							  $list_table_view
2152
+						  );
2153
+			throw new EE_Error($error_msg);
2154
+		}
2155
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
+		$this->_views = apply_filters(
2157
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
+			$this->_views
2159
+		);
2160
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
+		$this->_set_list_table_view();
2163
+		$this->_set_list_table_object();
2164
+	}
2165
+
2166
+
2167
+	/**
2168
+	 * set current view for List Table
2169
+	 *
2170
+	 * @return void
2171
+	 */
2172
+	protected function _set_list_table_view()
2173
+	{
2174
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
+		$status = $this->request->getRequestParam('status', null, 'key');
2176
+		$this->_view = $status && array_key_exists($status, $this->_views)
2177
+			? $status
2178
+			: $this->_view;
2179
+	}
2180
+
2181
+
2182
+	/**
2183
+	 * _set_list_table_object
2184
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
+	 *
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws InvalidArgumentException
2188
+	 * @throws InvalidDataTypeException
2189
+	 * @throws EE_Error
2190
+	 * @throws InvalidInterfaceException
2191
+	 */
2192
+	protected function _set_list_table_object()
2193
+	{
2194
+		if (isset($this->_route_config['list_table'])) {
2195
+			if (! class_exists($this->_route_config['list_table'])) {
2196
+				throw new EE_Error(
2197
+					sprintf(
2198
+						esc_html__(
2199
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2200
+							'event_espresso'
2201
+						),
2202
+						$this->_route_config['list_table'],
2203
+						get_class($this)
2204
+					)
2205
+				);
2206
+			}
2207
+			$this->_list_table_object = $this->loader->getShared(
2208
+				$this->_route_config['list_table'],
2209
+				[$this]
2210
+			);
2211
+		}
2212
+	}
2213
+
2214
+
2215
+	/**
2216
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
+	 *
2218
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
+	 *                                                    urls.  The array should be indexed by the view it is being
2220
+	 *                                                    added to.
2221
+	 * @return array
2222
+	 */
2223
+	public function get_list_table_view_RLs($extra_query_args = [])
2224
+	{
2225
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
+		if (empty($this->_views)) {
2227
+			$this->_views = [];
2228
+		}
2229
+		// cycle thru views
2230
+		foreach ($this->_views as $key => $view) {
2231
+			$query_args = [];
2232
+			// check for current view
2233
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
+			$query_args['action']                        = $this->_req_action;
2235
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
+			$query_args['status']                        = $view['slug'];
2237
+			// merge any other arguments sent in.
2238
+			if (isset($extra_query_args[ $view['slug'] ])) {
2239
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
+			}
2241
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
+		}
2243
+		return $this->_views;
2244
+	}
2245
+
2246
+
2247
+	/**
2248
+	 * _entries_per_page_dropdown
2249
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
+	 *
2251
+	 * @param int $max_entries total number of rows in the table
2252
+	 * @return string
2253
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
+	 *         WP does it.
2255
+	 */
2256
+	protected function _entries_per_page_dropdown($max_entries = 0)
2257
+	{
2258
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
+		$values   = [10, 25, 50, 100];
2260
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
+		if ($max_entries) {
2262
+			$values[] = $max_entries;
2263
+			sort($values);
2264
+		}
2265
+		$entries_per_page_dropdown = '
2266 2266
 			<div id="entries-per-page-dv" class="alignleft actions">
2267 2267
 				<label class="hide-if-no-js">
2268 2268
 					Show
2269 2269
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2270
-        foreach ($values as $value) {
2271
-            if ($value < $max_entries) {
2272
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
-                $entries_per_page_dropdown .= '
2270
+		foreach ($values as $value) {
2271
+			if ($value < $max_entries) {
2272
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
+				$entries_per_page_dropdown .= '
2274 2274
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2275
-            }
2276
-        }
2277
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
-        $entries_per_page_dropdown .= '
2275
+			}
2276
+		}
2277
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
+		$entries_per_page_dropdown .= '
2279 2279
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2280
-        $entries_per_page_dropdown .= '
2280
+		$entries_per_page_dropdown .= '
2281 2281
 					</select>
2282 2282
 					entries
2283 2283
 				</label>
2284 2284
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2285 2285
 			</div>
2286 2286
 		';
2287
-        return $entries_per_page_dropdown;
2288
-    }
2289
-
2290
-
2291
-    /**
2292
-     *        _set_search_attributes
2293
-     *
2294
-     * @return        void
2295
-     */
2296
-    public function _set_search_attributes()
2297
-    {
2298
-        $this->_template_args['search']['btn_label'] = sprintf(
2299
-            esc_html__('Search %s', 'event_espresso'),
2300
-            empty($this->_search_btn_label) ? $this->page_label
2301
-                : $this->_search_btn_label
2302
-        );
2303
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
-    }
2305
-
2306
-
2307
-
2308
-    /*** END LIST TABLE METHODS **/
2309
-
2310
-
2311
-    /**
2312
-     * _add_registered_metaboxes
2313
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
-     *
2315
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
-     * @return void
2317
-     * @throws EE_Error
2318
-     */
2319
-    private function _add_registered_meta_boxes()
2320
-    {
2321
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
-        // we only add meta boxes if the page_route calls for it
2323
-        if (
2324
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
-            && is_array(
2326
-                $this->_route_config['metaboxes']
2327
-            )
2328
-        ) {
2329
-            // this simply loops through the callbacks provided
2330
-            // and checks if there is a corresponding callback registered by the child
2331
-            // if there is then we go ahead and process the metabox loader.
2332
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
-                // first check for Closures
2334
-                if ($metabox_callback instanceof Closure) {
2335
-                    $result = $metabox_callback();
2336
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
-                } else {
2339
-                    $result = call_user_func([$this, &$metabox_callback]);
2340
-                }
2341
-                if ($result === false) {
2342
-                    // user error msg
2343
-                    $error_msg = esc_html__(
2344
-                        'An error occurred. The  requested metabox could not be found.',
2345
-                        'event_espresso'
2346
-                    );
2347
-                    // developer error msg
2348
-                    $error_msg .= '||'
2349
-                                  . sprintf(
2350
-                                      esc_html__(
2351
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2352
-                                          'event_espresso'
2353
-                                      ),
2354
-                                      $metabox_callback
2355
-                                  );
2356
-                    throw new EE_Error($error_msg);
2357
-                }
2358
-            }
2359
-        }
2360
-    }
2361
-
2362
-
2363
-    /**
2364
-     * _add_screen_columns
2365
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
-     * the dynamic column template and we'll setup the column options for the page.
2367
-     *
2368
-     * @return void
2369
-     */
2370
-    private function _add_screen_columns()
2371
-    {
2372
-        if (
2373
-            is_array($this->_route_config)
2374
-            && isset($this->_route_config['columns'])
2375
-            && is_array($this->_route_config['columns'])
2376
-            && count($this->_route_config['columns']) === 2
2377
-        ) {
2378
-            add_screen_option(
2379
-                'layout_columns',
2380
-                [
2381
-                    'max'     => (int) $this->_route_config['columns'][0],
2382
-                    'default' => (int) $this->_route_config['columns'][1],
2383
-                ]
2384
-            );
2385
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
-            $screen_id                                           = $this->_current_screen->id;
2387
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
-            $total_columns                                       = ! empty($screen_columns)
2389
-                ? $screen_columns
2390
-                : $this->_route_config['columns'][1];
2391
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2393
-            $this->_template_args['screen']                      = $this->_current_screen;
2394
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2396
-            // finally if we don't have has_metaboxes set in the route config
2397
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
-            $this->_route_config['has_metaboxes'] = true;
2399
-        }
2400
-    }
2401
-
2402
-
2403
-
2404
-    /** GLOBALLY AVAILABLE METABOXES **/
2405
-
2406
-
2407
-    /**
2408
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
-     * these get loaded on.
2411
-     */
2412
-    private function _espresso_news_post_box()
2413
-    {
2414
-        $news_box_title = apply_filters(
2415
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
-            esc_html__('New @ Event Espresso', 'event_espresso')
2417
-        );
2418
-        add_meta_box(
2419
-            'espresso_news_post_box',
2420
-            $news_box_title,
2421
-            [
2422
-                $this,
2423
-                'espresso_news_post_box',
2424
-            ],
2425
-            $this->_wp_page_slug,
2426
-            'side'
2427
-        );
2428
-    }
2429
-
2430
-
2431
-    /**
2432
-     * Code for setting up espresso ratings request metabox.
2433
-     */
2434
-    protected function _espresso_ratings_request()
2435
-    {
2436
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
-            return;
2438
-        }
2439
-        $ratings_box_title = apply_filters(
2440
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
-        );
2443
-        add_meta_box(
2444
-            'espresso_ratings_request',
2445
-            $ratings_box_title,
2446
-            [
2447
-                $this,
2448
-                'espresso_ratings_request',
2449
-            ],
2450
-            $this->_wp_page_slug,
2451
-            'side'
2452
-        );
2453
-    }
2454
-
2455
-
2456
-    /**
2457
-     * Code for setting up espresso ratings request metabox content.
2458
-     *
2459
-     * @throws DomainException
2460
-     */
2461
-    public function espresso_ratings_request()
2462
-    {
2463
-        EEH_Template::display_template(
2464
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
-            []
2466
-        );
2467
-    }
2468
-
2469
-
2470
-    public static function cached_rss_display($rss_id, $url)
2471
-    {
2472
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2473
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2474
-                     . '</p><p class="hide-if-js">'
2475
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
-                     . '</p>';
2477
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
-        $post      = '</div>' . "\n";
2480
-        $cache_key = 'ee_rss_' . md5($rss_id);
2481
-        $output    = get_transient($cache_key);
2482
-        if ($output !== false) {
2483
-            echo $pre . $output . $post; // already escaped
2484
-            return true;
2485
-        }
2486
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
-            echo $pre . $loading . $post; // already escaped
2488
-            return false;
2489
-        }
2490
-        ob_start();
2491
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
-        return true;
2494
-    }
2495
-
2496
-
2497
-    public function espresso_news_post_box()
2498
-    {
2499
-        ?>
2287
+		return $entries_per_page_dropdown;
2288
+	}
2289
+
2290
+
2291
+	/**
2292
+	 *        _set_search_attributes
2293
+	 *
2294
+	 * @return        void
2295
+	 */
2296
+	public function _set_search_attributes()
2297
+	{
2298
+		$this->_template_args['search']['btn_label'] = sprintf(
2299
+			esc_html__('Search %s', 'event_espresso'),
2300
+			empty($this->_search_btn_label) ? $this->page_label
2301
+				: $this->_search_btn_label
2302
+		);
2303
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
+	}
2305
+
2306
+
2307
+
2308
+	/*** END LIST TABLE METHODS **/
2309
+
2310
+
2311
+	/**
2312
+	 * _add_registered_metaboxes
2313
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
+	 *
2315
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
+	 * @return void
2317
+	 * @throws EE_Error
2318
+	 */
2319
+	private function _add_registered_meta_boxes()
2320
+	{
2321
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
+		// we only add meta boxes if the page_route calls for it
2323
+		if (
2324
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
+			&& is_array(
2326
+				$this->_route_config['metaboxes']
2327
+			)
2328
+		) {
2329
+			// this simply loops through the callbacks provided
2330
+			// and checks if there is a corresponding callback registered by the child
2331
+			// if there is then we go ahead and process the metabox loader.
2332
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
+				// first check for Closures
2334
+				if ($metabox_callback instanceof Closure) {
2335
+					$result = $metabox_callback();
2336
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
+				} else {
2339
+					$result = call_user_func([$this, &$metabox_callback]);
2340
+				}
2341
+				if ($result === false) {
2342
+					// user error msg
2343
+					$error_msg = esc_html__(
2344
+						'An error occurred. The  requested metabox could not be found.',
2345
+						'event_espresso'
2346
+					);
2347
+					// developer error msg
2348
+					$error_msg .= '||'
2349
+								  . sprintf(
2350
+									  esc_html__(
2351
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2352
+										  'event_espresso'
2353
+									  ),
2354
+									  $metabox_callback
2355
+								  );
2356
+					throw new EE_Error($error_msg);
2357
+				}
2358
+			}
2359
+		}
2360
+	}
2361
+
2362
+
2363
+	/**
2364
+	 * _add_screen_columns
2365
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
+	 * the dynamic column template and we'll setup the column options for the page.
2367
+	 *
2368
+	 * @return void
2369
+	 */
2370
+	private function _add_screen_columns()
2371
+	{
2372
+		if (
2373
+			is_array($this->_route_config)
2374
+			&& isset($this->_route_config['columns'])
2375
+			&& is_array($this->_route_config['columns'])
2376
+			&& count($this->_route_config['columns']) === 2
2377
+		) {
2378
+			add_screen_option(
2379
+				'layout_columns',
2380
+				[
2381
+					'max'     => (int) $this->_route_config['columns'][0],
2382
+					'default' => (int) $this->_route_config['columns'][1],
2383
+				]
2384
+			);
2385
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
+			$screen_id                                           = $this->_current_screen->id;
2387
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
+			$total_columns                                       = ! empty($screen_columns)
2389
+				? $screen_columns
2390
+				: $this->_route_config['columns'][1];
2391
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2393
+			$this->_template_args['screen']                      = $this->_current_screen;
2394
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
+																   . 'admin_details_metabox_column_wrapper.template.php';
2396
+			// finally if we don't have has_metaboxes set in the route config
2397
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
+			$this->_route_config['has_metaboxes'] = true;
2399
+		}
2400
+	}
2401
+
2402
+
2403
+
2404
+	/** GLOBALLY AVAILABLE METABOXES **/
2405
+
2406
+
2407
+	/**
2408
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
+	 * these get loaded on.
2411
+	 */
2412
+	private function _espresso_news_post_box()
2413
+	{
2414
+		$news_box_title = apply_filters(
2415
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
+			esc_html__('New @ Event Espresso', 'event_espresso')
2417
+		);
2418
+		add_meta_box(
2419
+			'espresso_news_post_box',
2420
+			$news_box_title,
2421
+			[
2422
+				$this,
2423
+				'espresso_news_post_box',
2424
+			],
2425
+			$this->_wp_page_slug,
2426
+			'side'
2427
+		);
2428
+	}
2429
+
2430
+
2431
+	/**
2432
+	 * Code for setting up espresso ratings request metabox.
2433
+	 */
2434
+	protected function _espresso_ratings_request()
2435
+	{
2436
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
+			return;
2438
+		}
2439
+		$ratings_box_title = apply_filters(
2440
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
+		);
2443
+		add_meta_box(
2444
+			'espresso_ratings_request',
2445
+			$ratings_box_title,
2446
+			[
2447
+				$this,
2448
+				'espresso_ratings_request',
2449
+			],
2450
+			$this->_wp_page_slug,
2451
+			'side'
2452
+		);
2453
+	}
2454
+
2455
+
2456
+	/**
2457
+	 * Code for setting up espresso ratings request metabox content.
2458
+	 *
2459
+	 * @throws DomainException
2460
+	 */
2461
+	public function espresso_ratings_request()
2462
+	{
2463
+		EEH_Template::display_template(
2464
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
+			[]
2466
+		);
2467
+	}
2468
+
2469
+
2470
+	public static function cached_rss_display($rss_id, $url)
2471
+	{
2472
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2473
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2474
+					 . '</p><p class="hide-if-js">'
2475
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
+					 . '</p>';
2477
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
+		$post      = '</div>' . "\n";
2480
+		$cache_key = 'ee_rss_' . md5($rss_id);
2481
+		$output    = get_transient($cache_key);
2482
+		if ($output !== false) {
2483
+			echo $pre . $output . $post; // already escaped
2484
+			return true;
2485
+		}
2486
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
+			echo $pre . $loading . $post; // already escaped
2488
+			return false;
2489
+		}
2490
+		ob_start();
2491
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
+		return true;
2494
+	}
2495
+
2496
+
2497
+	public function espresso_news_post_box()
2498
+	{
2499
+		?>
2500 2500
         <div class="padding">
2501 2501
             <div id="espresso_news_post_box_content" class="infolinks">
2502 2502
                 <?php
2503
-                // Get RSS Feed(s)
2504
-                self::cached_rss_display(
2505
-                    'espresso_news_post_box_content',
2506
-                    esc_url_raw(
2507
-                        apply_filters(
2508
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
-                            'https://eventespresso.com/feed/'
2510
-                        )
2511
-                    )
2512
-                );
2513
-                ?>
2503
+				// Get RSS Feed(s)
2504
+				self::cached_rss_display(
2505
+					'espresso_news_post_box_content',
2506
+					esc_url_raw(
2507
+						apply_filters(
2508
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
+							'https://eventespresso.com/feed/'
2510
+						)
2511
+					)
2512
+				);
2513
+				?>
2514 2514
             </div>
2515 2515
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2516 2516
         </div>
2517 2517
         <?php
2518
-    }
2519
-
2520
-
2521
-    private function _espresso_links_post_box()
2522
-    {
2523
-        // Hiding until we actually have content to put in here...
2524
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2525
-    }
2526
-
2527
-
2528
-    public function espresso_links_post_box()
2529
-    {
2530
-        // Hiding until we actually have content to put in here...
2531
-        // EEH_Template::display_template(
2532
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
-        // );
2534
-    }
2535
-
2536
-
2537
-    protected function _espresso_sponsors_post_box()
2538
-    {
2539
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
-            add_meta_box(
2541
-                'espresso_sponsors_post_box',
2542
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
-                [$this, 'espresso_sponsors_post_box'],
2544
-                $this->_wp_page_slug,
2545
-                'side'
2546
-            );
2547
-        }
2548
-    }
2549
-
2550
-
2551
-    public function espresso_sponsors_post_box()
2552
-    {
2553
-        EEH_Template::display_template(
2554
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
-        );
2556
-    }
2557
-
2558
-
2559
-    private function _publish_post_box()
2560
-    {
2561
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
-        // then we'll use that for the metabox label.
2564
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
-        if (! empty($this->_labels['publishbox'])) {
2566
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
-                : $this->_labels['publishbox'];
2568
-        } else {
2569
-            $box_label = esc_html__('Publish', 'event_espresso');
2570
-        }
2571
-        $box_label = apply_filters(
2572
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
-            $box_label,
2574
-            $this->_req_action,
2575
-            $this
2576
-        );
2577
-        add_meta_box(
2578
-            $meta_box_ref,
2579
-            $box_label,
2580
-            [$this, 'editor_overview'],
2581
-            $this->_current_screen->id,
2582
-            'side',
2583
-            'high'
2584
-        );
2585
-    }
2586
-
2587
-
2588
-    public function editor_overview()
2589
-    {
2590
-        // if we have extra content set let's add it in if not make sure its empty
2591
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
-            ? $this->_template_args['publish_box_extra_content']
2593
-            : '';
2594
-        echo EEH_Template::display_template(
2595
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
-            $this->_template_args,
2597
-            true
2598
-        );
2599
-    }
2600
-
2601
-
2602
-    /** end of globally available metaboxes section **/
2603
-
2604
-
2605
-    /**
2606
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
-     * protected method.
2608
-     *
2609
-     * @param string $name
2610
-     * @param int    $id
2611
-     * @param bool   $delete
2612
-     * @param string $save_close_redirect_URL
2613
-     * @param bool   $both_btns
2614
-     * @throws EE_Error
2615
-     * @throws InvalidArgumentException
2616
-     * @throws InvalidDataTypeException
2617
-     * @throws InvalidInterfaceException
2618
-     * @see   $this->_set_publish_post_box_vars for param details
2619
-     * @since 4.6.0
2620
-     */
2621
-    public function set_publish_post_box_vars(
2622
-        $name = '',
2623
-        $id = 0,
2624
-        $delete = false,
2625
-        $save_close_redirect_URL = '',
2626
-        $both_btns = true
2627
-    ) {
2628
-        $this->_set_publish_post_box_vars(
2629
-            $name,
2630
-            $id,
2631
-            $delete,
2632
-            $save_close_redirect_URL,
2633
-            $both_btns
2634
-        );
2635
-    }
2636
-
2637
-
2638
-    /**
2639
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2641
-     * save, and save and close buttons to work properly, then you will want to include a
2642
-     * values for the name and id arguments.
2643
-     *
2644
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2645
-     * @param int     $id                         id attached to the item published
2646
-     * @param string  $delete                     page route callback for the delete action
2647
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
-     *                                            the Save button
2650
-     * @throws EE_Error
2651
-     * @throws InvalidArgumentException
2652
-     * @throws InvalidDataTypeException
2653
-     * @throws InvalidInterfaceException
2654
-     * @todo  Add in validation for name/id arguments.
2655
-     */
2656
-    protected function _set_publish_post_box_vars(
2657
-        $name = '',
2658
-        $id = 0,
2659
-        $delete = '',
2660
-        $save_close_redirect_URL = '',
2661
-        $both_btns = true
2662
-    ) {
2663
-        // if Save & Close, use a custom redirect URL or default to the main page?
2664
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
-            ? $save_close_redirect_URL
2666
-            : $this->_admin_base_url;
2667
-        // create the Save & Close and Save buttons
2668
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
-        // if we have extra content set let's add it in if not make sure its empty
2670
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
-            ? $this->_template_args['publish_box_extra_content']
2672
-            : '';
2673
-        if ($delete && ! empty($id)) {
2674
-            // make sure we have a default if just true is sent.
2675
-            $delete           = ! empty($delete) ? $delete : 'delete';
2676
-            $delete_link_args = [$name => $id];
2677
-            $delete           = $this->get_action_link_or_button(
2678
-                $delete,
2679
-                $delete,
2680
-                $delete_link_args,
2681
-                'submitdelete deletion',
2682
-                '',
2683
-                false
2684
-            );
2685
-        }
2686
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
-        if (! empty($name) && ! empty($id)) {
2688
-            $hidden_field_arr[ $name ] = [
2689
-                'type'  => 'hidden',
2690
-                'value' => $id,
2691
-            ];
2692
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
-        } else {
2694
-            $hf = '';
2695
-        }
2696
-        // add hidden field
2697
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
-            ? $hf[ $name ]['field']
2699
-            : $hf;
2700
-    }
2701
-
2702
-
2703
-    /**
2704
-     * displays an error message to ppl who have javascript disabled
2705
-     *
2706
-     * @return void
2707
-     */
2708
-    private function _display_no_javascript_warning()
2709
-    {
2710
-        ?>
2518
+	}
2519
+
2520
+
2521
+	private function _espresso_links_post_box()
2522
+	{
2523
+		// Hiding until we actually have content to put in here...
2524
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2525
+	}
2526
+
2527
+
2528
+	public function espresso_links_post_box()
2529
+	{
2530
+		// Hiding until we actually have content to put in here...
2531
+		// EEH_Template::display_template(
2532
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
+		// );
2534
+	}
2535
+
2536
+
2537
+	protected function _espresso_sponsors_post_box()
2538
+	{
2539
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
+			add_meta_box(
2541
+				'espresso_sponsors_post_box',
2542
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
+				[$this, 'espresso_sponsors_post_box'],
2544
+				$this->_wp_page_slug,
2545
+				'side'
2546
+			);
2547
+		}
2548
+	}
2549
+
2550
+
2551
+	public function espresso_sponsors_post_box()
2552
+	{
2553
+		EEH_Template::display_template(
2554
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
+		);
2556
+	}
2557
+
2558
+
2559
+	private function _publish_post_box()
2560
+	{
2561
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
+		// then we'll use that for the metabox label.
2564
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
+		if (! empty($this->_labels['publishbox'])) {
2566
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
+				: $this->_labels['publishbox'];
2568
+		} else {
2569
+			$box_label = esc_html__('Publish', 'event_espresso');
2570
+		}
2571
+		$box_label = apply_filters(
2572
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
+			$box_label,
2574
+			$this->_req_action,
2575
+			$this
2576
+		);
2577
+		add_meta_box(
2578
+			$meta_box_ref,
2579
+			$box_label,
2580
+			[$this, 'editor_overview'],
2581
+			$this->_current_screen->id,
2582
+			'side',
2583
+			'high'
2584
+		);
2585
+	}
2586
+
2587
+
2588
+	public function editor_overview()
2589
+	{
2590
+		// if we have extra content set let's add it in if not make sure its empty
2591
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
+			? $this->_template_args['publish_box_extra_content']
2593
+			: '';
2594
+		echo EEH_Template::display_template(
2595
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
+			$this->_template_args,
2597
+			true
2598
+		);
2599
+	}
2600
+
2601
+
2602
+	/** end of globally available metaboxes section **/
2603
+
2604
+
2605
+	/**
2606
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
+	 * protected method.
2608
+	 *
2609
+	 * @param string $name
2610
+	 * @param int    $id
2611
+	 * @param bool   $delete
2612
+	 * @param string $save_close_redirect_URL
2613
+	 * @param bool   $both_btns
2614
+	 * @throws EE_Error
2615
+	 * @throws InvalidArgumentException
2616
+	 * @throws InvalidDataTypeException
2617
+	 * @throws InvalidInterfaceException
2618
+	 * @see   $this->_set_publish_post_box_vars for param details
2619
+	 * @since 4.6.0
2620
+	 */
2621
+	public function set_publish_post_box_vars(
2622
+		$name = '',
2623
+		$id = 0,
2624
+		$delete = false,
2625
+		$save_close_redirect_URL = '',
2626
+		$both_btns = true
2627
+	) {
2628
+		$this->_set_publish_post_box_vars(
2629
+			$name,
2630
+			$id,
2631
+			$delete,
2632
+			$save_close_redirect_URL,
2633
+			$both_btns
2634
+		);
2635
+	}
2636
+
2637
+
2638
+	/**
2639
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2641
+	 * save, and save and close buttons to work properly, then you will want to include a
2642
+	 * values for the name and id arguments.
2643
+	 *
2644
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2645
+	 * @param int     $id                         id attached to the item published
2646
+	 * @param string  $delete                     page route callback for the delete action
2647
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
+	 *                                            the Save button
2650
+	 * @throws EE_Error
2651
+	 * @throws InvalidArgumentException
2652
+	 * @throws InvalidDataTypeException
2653
+	 * @throws InvalidInterfaceException
2654
+	 * @todo  Add in validation for name/id arguments.
2655
+	 */
2656
+	protected function _set_publish_post_box_vars(
2657
+		$name = '',
2658
+		$id = 0,
2659
+		$delete = '',
2660
+		$save_close_redirect_URL = '',
2661
+		$both_btns = true
2662
+	) {
2663
+		// if Save & Close, use a custom redirect URL or default to the main page?
2664
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
+			? $save_close_redirect_URL
2666
+			: $this->_admin_base_url;
2667
+		// create the Save & Close and Save buttons
2668
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
+		// if we have extra content set let's add it in if not make sure its empty
2670
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
+			? $this->_template_args['publish_box_extra_content']
2672
+			: '';
2673
+		if ($delete && ! empty($id)) {
2674
+			// make sure we have a default if just true is sent.
2675
+			$delete           = ! empty($delete) ? $delete : 'delete';
2676
+			$delete_link_args = [$name => $id];
2677
+			$delete           = $this->get_action_link_or_button(
2678
+				$delete,
2679
+				$delete,
2680
+				$delete_link_args,
2681
+				'submitdelete deletion',
2682
+				'',
2683
+				false
2684
+			);
2685
+		}
2686
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
+		if (! empty($name) && ! empty($id)) {
2688
+			$hidden_field_arr[ $name ] = [
2689
+				'type'  => 'hidden',
2690
+				'value' => $id,
2691
+			];
2692
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
+		} else {
2694
+			$hf = '';
2695
+		}
2696
+		// add hidden field
2697
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
+			? $hf[ $name ]['field']
2699
+			: $hf;
2700
+	}
2701
+
2702
+
2703
+	/**
2704
+	 * displays an error message to ppl who have javascript disabled
2705
+	 *
2706
+	 * @return void
2707
+	 */
2708
+	private function _display_no_javascript_warning()
2709
+	{
2710
+		?>
2711 2711
         <noscript>
2712 2712
             <div id="no-js-message" class="error">
2713 2713
                 <p style="font-size:1.3em;">
2714 2714
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2715 2715
                     <?php esc_html_e(
2716
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
-                        'event_espresso'
2718
-                    ); ?>
2716
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
+						'event_espresso'
2718
+					); ?>
2719 2719
                 </p>
2720 2720
             </div>
2721 2721
         </noscript>
2722 2722
         <?php
2723
-    }
2724
-
2725
-
2726
-    /**
2727
-     * displays espresso success and/or error notices
2728
-     *
2729
-     * @return void
2730
-     */
2731
-    private function _display_espresso_notices()
2732
-    {
2733
-        $notices = $this->_get_transient(true);
2734
-        echo stripslashes($notices);
2735
-    }
2736
-
2737
-
2738
-    /**
2739
-     * spinny things pacify the masses
2740
-     *
2741
-     * @return void
2742
-     */
2743
-    protected function _add_admin_page_ajax_loading_img()
2744
-    {
2745
-        ?>
2723
+	}
2724
+
2725
+
2726
+	/**
2727
+	 * displays espresso success and/or error notices
2728
+	 *
2729
+	 * @return void
2730
+	 */
2731
+	private function _display_espresso_notices()
2732
+	{
2733
+		$notices = $this->_get_transient(true);
2734
+		echo stripslashes($notices);
2735
+	}
2736
+
2737
+
2738
+	/**
2739
+	 * spinny things pacify the masses
2740
+	 *
2741
+	 * @return void
2742
+	 */
2743
+	protected function _add_admin_page_ajax_loading_img()
2744
+	{
2745
+		?>
2746 2746
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2747 2747
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2748
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2748
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2749 2749
         </div>
2750 2750
         <?php
2751
-    }
2751
+	}
2752 2752
 
2753 2753
 
2754
-    /**
2755
-     * add admin page overlay for modal boxes
2756
-     *
2757
-     * @return void
2758
-     */
2759
-    protected function _add_admin_page_overlay()
2760
-    {
2761
-        ?>
2754
+	/**
2755
+	 * add admin page overlay for modal boxes
2756
+	 *
2757
+	 * @return void
2758
+	 */
2759
+	protected function _add_admin_page_overlay()
2760
+	{
2761
+		?>
2762 2762
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2763 2763
         <?php
2764
-    }
2765
-
2766
-
2767
-    /**
2768
-     * facade for add_meta_box
2769
-     *
2770
-     * @param string  $action        where the metabox get's displayed
2771
-     * @param string  $title         Title of Metabox (output in metabox header)
2772
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
-     *                               instead of the one created in here.
2774
-     * @param array   $callback_args an array of args supplied for the metabox
2775
-     * @param string  $column        what metabox column
2776
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
-     *                               created but just set our own callback for wp's add_meta_box.
2779
-     * @throws DomainException
2780
-     */
2781
-    public function _add_admin_page_meta_box(
2782
-        $action,
2783
-        $title,
2784
-        $callback,
2785
-        $callback_args,
2786
-        $column = 'normal',
2787
-        $priority = 'high',
2788
-        $create_func = true
2789
-    ) {
2790
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2792
-        if (empty($callback_args) && $create_func) {
2793
-            $callback_args = [
2794
-                'template_path' => $this->_template_path,
2795
-                'template_args' => $this->_template_args,
2796
-            ];
2797
-        }
2798
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2799
-        $call_back_func = $create_func
2800
-            ? function ($post, $metabox) {
2801
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
-                echo EEH_Template::display_template(
2803
-                    $metabox['args']['template_path'],
2804
-                    $metabox['args']['template_args'],
2805
-                    true
2806
-                );
2807
-            }
2808
-            : $callback;
2809
-        add_meta_box(
2810
-            str_replace('_', '-', $action) . '-mbox',
2811
-            $title,
2812
-            $call_back_func,
2813
-            $this->_wp_page_slug,
2814
-            $column,
2815
-            $priority,
2816
-            $callback_args
2817
-        );
2818
-    }
2819
-
2820
-
2821
-    /**
2822
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
-     *
2824
-     * @throws DomainException
2825
-     * @throws EE_Error
2826
-     */
2827
-    public function display_admin_page_with_metabox_columns()
2828
-    {
2829
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
-            $this->_column_template_path,
2832
-            $this->_template_args,
2833
-            true
2834
-        );
2835
-        // the final wrapper
2836
-        $this->admin_page_wrapper();
2837
-    }
2838
-
2839
-
2840
-    /**
2841
-     * generates  HTML wrapper for an admin details page
2842
-     *
2843
-     * @return void
2844
-     * @throws EE_Error
2845
-     * @throws DomainException
2846
-     */
2847
-    public function display_admin_page_with_sidebar()
2848
-    {
2849
-        $this->_display_admin_page(true);
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2855
-     *
2856
-     * @return void
2857
-     * @throws EE_Error
2858
-     * @throws DomainException
2859
-     */
2860
-    public function display_admin_page_with_no_sidebar()
2861
-    {
2862
-        $this->_display_admin_page();
2863
-    }
2864
-
2865
-
2866
-    /**
2867
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2868
-     *
2869
-     * @return void
2870
-     * @throws EE_Error
2871
-     * @throws DomainException
2872
-     */
2873
-    public function display_about_admin_page()
2874
-    {
2875
-        $this->_display_admin_page(false, true);
2876
-    }
2877
-
2878
-
2879
-    /**
2880
-     * display_admin_page
2881
-     * contains the code for actually displaying an admin page
2882
-     *
2883
-     * @param boolean $sidebar true with sidebar, false without
2884
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
-     * @return void
2886
-     * @throws DomainException
2887
-     * @throws EE_Error
2888
-     */
2889
-    private function _display_admin_page($sidebar = false, $about = false)
2890
-    {
2891
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2895
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2897
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
-            ? 'poststuff'
2899
-            : 'espresso-default-admin';
2900
-        $template_path                                     = $sidebar
2901
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
-        if ($this->request->isAjax()) {
2904
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
-        }
2906
-        $template_path                                     = ! empty($this->_column_template_path)
2907
-            ? $this->_column_template_path : $template_path;
2908
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
-            ? $this->_template_args['admin_page_content']
2910
-            : '';
2911
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
-            ? $this->_template_args['before_admin_page_content']
2913
-            : '';
2914
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
-            ? $this->_template_args['after_admin_page_content']
2916
-            : '';
2917
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
-            $template_path,
2919
-            $this->_template_args,
2920
-            true
2921
-        );
2922
-        // the final template wrapper
2923
-        $this->admin_page_wrapper($about);
2924
-    }
2925
-
2926
-
2927
-    /**
2928
-     * This is used to display caf preview pages.
2929
-     *
2930
-     * @param string $utm_campaign_source what is the key used for google analytics link
2931
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
-     * @return void
2934
-     * @throws DomainException
2935
-     * @throws EE_Error
2936
-     * @throws InvalidArgumentException
2937
-     * @throws InvalidDataTypeException
2938
-     * @throws InvalidInterfaceException
2939
-     * @since 4.3.2
2940
-     */
2941
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
-    {
2943
-        // let's generate a default preview action button if there isn't one already present.
2944
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2945
-            'Upgrade to Event Espresso 4 Right Now',
2946
-            'event_espresso'
2947
-        );
2948
-        $buy_now_url                                   = add_query_arg(
2949
-            [
2950
-                'ee_ver'       => 'ee4',
2951
-                'utm_source'   => 'ee4_plugin_admin',
2952
-                'utm_medium'   => 'link',
2953
-                'utm_campaign' => $utm_campaign_source,
2954
-                'utm_content'  => 'buy_now_button',
2955
-            ],
2956
-            'https://eventespresso.com/pricing/'
2957
-        );
2958
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
-            ? $this->get_action_link_or_button(
2960
-                '',
2961
-                'buy_now',
2962
-                [],
2963
-                'button-primary button-large',
2964
-                esc_url_raw($buy_now_url),
2965
-                true
2966
-            )
2967
-            : $this->_template_args['preview_action_button'];
2968
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
-            $this->_template_args,
2971
-            true
2972
-        );
2973
-        $this->_display_admin_page($display_sidebar);
2974
-    }
2975
-
2976
-
2977
-    /**
2978
-     * display_admin_list_table_page_with_sidebar
2979
-     * generates HTML wrapper for an admin_page with list_table
2980
-     *
2981
-     * @return void
2982
-     * @throws EE_Error
2983
-     * @throws DomainException
2984
-     */
2985
-    public function display_admin_list_table_page_with_sidebar()
2986
-    {
2987
-        $this->_display_admin_list_table_page(true);
2988
-    }
2989
-
2990
-
2991
-    /**
2992
-     * display_admin_list_table_page_with_no_sidebar
2993
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
-     *
2995
-     * @return void
2996
-     * @throws EE_Error
2997
-     * @throws DomainException
2998
-     */
2999
-    public function display_admin_list_table_page_with_no_sidebar()
3000
-    {
3001
-        $this->_display_admin_list_table_page();
3002
-    }
3003
-
3004
-
3005
-    /**
3006
-     * generates html wrapper for an admin_list_table page
3007
-     *
3008
-     * @param boolean $sidebar whether to display with sidebar or not.
3009
-     * @return void
3010
-     * @throws DomainException
3011
-     * @throws EE_Error
3012
-     */
3013
-    private function _display_admin_list_table_page($sidebar = false)
3014
-    {
3015
-        // setup search attributes
3016
-        $this->_set_search_attributes();
3017
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3018
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
-        $this->_template_args['table_url']        = $this->request->isAjax()
3020
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
-        $this->_template_args['list_table']       = $this->_list_table_object;
3023
-        $this->_template_args['current_route']    = $this->_req_action;
3024
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3027
-            $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                false,
3031
-                false
3032
-            );
3033
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
-                                                . $this->page_slug
3035
-                                                . '" />';
3036
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
-                                                . $ajax_sorting_callback
3038
-                                                . '" />';
3039
-        } else {
3040
-            $sortable_list_table_form_fields = '';
3041
-        }
3042
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
-        $hidden_form_fields                                      =
3044
-            isset($this->_template_args['list_table_hidden_fields'])
3045
-                ? $this->_template_args['list_table_hidden_fields']
3046
-                : '';
3047
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3048
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3049
-                                                                    . $nonce_ref
3050
-                                                                    . '" value="'
3051
-                                                                    . wp_create_nonce($nonce_ref)
3052
-                                                                    . '">';
3053
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
-        // display message about search results?
3055
-        $search = $this->request->getRequestParam('s');
3056
-        $this->_template_args['before_list_table'] .= ! empty($search)
3057
-            ? '<p class="ee-search-results">' . sprintf(
3058
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
-                trim($search, '%')
3060
-            ) . '</p>'
3061
-            : '';
3062
-        // filter before_list_table template arg
3063
-        $this->_template_args['before_list_table'] = apply_filters(
3064
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
-            $this->_template_args['before_list_table'],
3066
-            $this->page_slug,
3067
-            $this->request->requestParams(),
3068
-            $this->_req_action
3069
-        );
3070
-        // convert to array and filter again
3071
-        // arrays are easier to inject new items in a specific location,
3072
-        // but would not be backwards compatible, so we have to add a new filter
3073
-        $this->_template_args['before_list_table'] = implode(
3074
-            " \n",
3075
-            (array) apply_filters(
3076
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
-                (array) $this->_template_args['before_list_table'],
3078
-                $this->page_slug,
3079
-                $this->request->requestParams(),
3080
-                $this->_req_action
3081
-            )
3082
-        );
3083
-        // filter after_list_table template arg
3084
-        $this->_template_args['after_list_table'] = apply_filters(
3085
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
-            $this->_template_args['after_list_table'],
3087
-            $this->page_slug,
3088
-            $this->request->requestParams(),
3089
-            $this->_req_action
3090
-        );
3091
-        // convert to array and filter again
3092
-        // arrays are easier to inject new items in a specific location,
3093
-        // but would not be backwards compatible, so we have to add a new filter
3094
-        $this->_template_args['after_list_table']   = implode(
3095
-            " \n",
3096
-            (array) apply_filters(
3097
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
-                (array) $this->_template_args['after_list_table'],
3099
-                $this->page_slug,
3100
-                $this->request->requestParams(),
3101
-                $this->_req_action
3102
-            )
3103
-        );
3104
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
-            $template_path,
3106
-            $this->_template_args,
3107
-            true
3108
-        );
3109
-        // the final template wrapper
3110
-        if ($sidebar) {
3111
-            $this->display_admin_page_with_sidebar();
3112
-        } else {
3113
-            $this->display_admin_page_with_no_sidebar();
3114
-        }
3115
-    }
3116
-
3117
-
3118
-    /**
3119
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
-     * html string for the legend.
3121
-     * $items are expected in an array in the following format:
3122
-     * $legend_items = array(
3123
-     *        'item_id' => array(
3124
-     *            'icon' => 'http://url_to_icon_being_described.png',
3125
-     *            'desc' => esc_html__('localized description of item');
3126
-     *        )
3127
-     * );
3128
-     *
3129
-     * @param array $items see above for format of array
3130
-     * @return string html string of legend
3131
-     * @throws DomainException
3132
-     */
3133
-    protected function _display_legend($items)
3134
-    {
3135
-        $this->_template_args['items'] = apply_filters(
3136
-            'FHEE__EE_Admin_Page___display_legend__items',
3137
-            (array) $items,
3138
-            $this
3139
-        );
3140
-        return EEH_Template::display_template(
3141
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
-            $this->_template_args,
3143
-            true
3144
-        );
3145
-    }
3146
-
3147
-
3148
-    /**
3149
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
-     * The returned json object is created from an array in the following format:
3151
-     * array(
3152
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
-     *  'notices' => '', // - contains any EE_Error formatted notices
3155
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
-     *  that might be included in here)
3159
-     * )
3160
-     * The json object is populated by whatever is set in the $_template_args property.
3161
-     *
3162
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
-     *                                 instead of displayed.
3164
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
-     * @return void
3166
-     * @throws EE_Error
3167
-     */
3168
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
-    {
3170
-        // make sure any EE_Error notices have been handled.
3171
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3172
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
-        unset($this->_template_args['data']);
3174
-        $json = [
3175
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
-            'notices'   => EE_Error::get_notices(),
3180
-            'content'   => isset($this->_template_args['admin_page_content'])
3181
-                ? $this->_template_args['admin_page_content'] : '',
3182
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
-            'isEEajax'  => true
3184
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
-        ];
3186
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
-        if (null === error_get_last() || ! headers_sent()) {
3188
-            header('Content-Type: application/json; charset=UTF-8');
3189
-        }
3190
-        echo wp_json_encode($json);
3191
-        exit();
3192
-    }
3193
-
3194
-
3195
-    /**
3196
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
-     *
3198
-     * @return void
3199
-     * @throws EE_Error
3200
-     */
3201
-    public function return_json()
3202
-    {
3203
-        if ($this->request->isAjax()) {
3204
-            $this->_return_json();
3205
-        } else {
3206
-            throw new EE_Error(
3207
-                sprintf(
3208
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
-                    __FUNCTION__
3210
-                )
3211
-            );
3212
-        }
3213
-    }
3214
-
3215
-
3216
-    /**
3217
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
-     *
3220
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
-     */
3222
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
-    {
3224
-        $this->_hook_obj = $hook_obj;
3225
-    }
3226
-
3227
-
3228
-    /**
3229
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3230
-     *
3231
-     * @param boolean $about whether to use the special about page wrapper or default.
3232
-     * @return void
3233
-     * @throws DomainException
3234
-     * @throws EE_Error
3235
-     */
3236
-    public function admin_page_wrapper($about = false)
3237
-    {
3238
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3242
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3243
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
-            isset($this->_template_args['before_admin_page_content'])
3245
-                ? $this->_template_args['before_admin_page_content']
3246
-                : ''
3247
-        );
3248
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3249
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
-            isset($this->_template_args['after_admin_page_content'])
3251
-                ? $this->_template_args['after_admin_page_content']
3252
-                : ''
3253
-        );
3254
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
-        // load settings page wrapper template
3256
-        $template_path = ! $this->request->isAjax()
3257
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
-        // about page?
3260
-        $template_path = $about
3261
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
-            : $template_path;
3263
-        if ($this->request->isAjax()) {
3264
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
-                $template_path,
3266
-                $this->_template_args,
3267
-                true
3268
-            );
3269
-            $this->_return_json();
3270
-        } else {
3271
-            EEH_Template::display_template($template_path, $this->_template_args);
3272
-        }
3273
-    }
3274
-
3275
-
3276
-    /**
3277
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
-     *
3279
-     * @return string html
3280
-     * @throws EE_Error
3281
-     */
3282
-    protected function _get_main_nav_tabs()
3283
-    {
3284
-        // let's generate the html using the EEH_Tabbed_Content helper.
3285
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
-        // (rather than setting in the page_routes array)
3287
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *        sort nav tabs
3293
-     *
3294
-     * @param $a
3295
-     * @param $b
3296
-     * @return int
3297
-     */
3298
-    private function _sort_nav_tabs($a, $b)
3299
-    {
3300
-        if ($a['order'] === $b['order']) {
3301
-            return 0;
3302
-        }
3303
-        return ($a['order'] < $b['order']) ? -1 : 1;
3304
-    }
3305
-
3306
-
3307
-    /**
3308
-     *    generates HTML for the forms used on admin pages
3309
-     *
3310
-     * @param array  $input_vars   - array of input field details
3311
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
-     *                             use)
3313
-     * @param bool   $id
3314
-     * @return string
3315
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
-     */
3318
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
-    {
3320
-        return $generator === 'string'
3321
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3323
-    }
3324
-
3325
-
3326
-    /**
3327
-     * generates the "Save" and "Save & Close" buttons for edit forms
3328
-     *
3329
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
-     *                                   Close" button.
3331
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
-     *                                   'Save', [1] => 'save & close')
3333
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
-     *                                   via the "name" value in the button).  We can also use this to just dump
3335
-     *                                   default actions by submitting some other value.
3336
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
-     *                                   close (normal form handling).
3339
-     */
3340
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
-    {
3342
-        // make sure $text and $actions are in an array
3343
-        $text          = (array) $text;
3344
-        $actions       = (array) $actions;
3345
-        $referrer_url  = empty($referrer)
3346
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
-              . $this->request->getServerParam('REQUEST_URI')
3348
-              . '" />'
3349
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
-              . $referrer
3351
-              . '" />';
3352
-        $button_text   = ! empty($text)
3353
-            ? $text
3354
-            : [
3355
-                esc_html__('Save', 'event_espresso'),
3356
-                esc_html__('Save and Close', 'event_espresso'),
3357
-            ];
3358
-        $default_names = ['save', 'save_and_close'];
3359
-        // add in a hidden index for the current page (so save and close redirects properly)
3360
-        $this->_template_args['save_buttons'] = $referrer_url;
3361
-        foreach ($button_text as $key => $button) {
3362
-            $ref                                  = $default_names[ $key ];
3363
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
-                                                     . $ref
3365
-                                                     . '" value="'
3366
-                                                     . $button
3367
-                                                     . '" name="'
3368
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3369
-                                                     . '" id="'
3370
-                                                     . $this->_current_view . '_' . $ref
3371
-                                                     . '" />';
3372
-            if (! $both) {
3373
-                break;
3374
-            }
3375
-        }
3376
-    }
3377
-
3378
-
3379
-    /**
3380
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
-     *
3382
-     * @param string $route
3383
-     * @param array  $additional_hidden_fields
3384
-     * @see   $this->_set_add_edit_form_tags() for details on params
3385
-     * @since 4.6.0
3386
-     */
3387
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
-    {
3389
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
-    }
3391
-
3392
-
3393
-    /**
3394
-     * set form open and close tags on add/edit pages.
3395
-     *
3396
-     * @param string $route                    the route you want the form to direct to
3397
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
-     * @return void
3399
-     */
3400
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
-    {
3402
-        if (empty($route)) {
3403
-            $user_msg = esc_html__(
3404
-                'An error occurred. No action was set for this page\'s form.',
3405
-                'event_espresso'
3406
-            );
3407
-            $dev_msg  = $user_msg . "\n"
3408
-                        . sprintf(
3409
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
-                            __FUNCTION__,
3411
-                            __CLASS__
3412
-                        );
3413
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
-        }
3415
-        // open form
3416
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
-                                                             . $this->_admin_base_url
3418
-                                                             . '" id="'
3419
-                                                             . $route
3420
-                                                             . '_event_form" >';
3421
-        // add nonce
3422
-        $nonce                                             =
3423
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
-        // add REQUIRED form action
3426
-        $hidden_fields = [
3427
-            'action' => ['type' => 'hidden', 'value' => $route],
3428
-        ];
3429
-        // merge arrays
3430
-        $hidden_fields = is_array($additional_hidden_fields)
3431
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3432
-            : $hidden_fields;
3433
-        // generate form fields
3434
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
-        // add fields to form
3436
-        foreach ((array) $form_fields as $field_name => $form_field) {
3437
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
-        }
3439
-        // close form
3440
-        $this->_template_args['after_admin_page_content'] = '</form>';
3441
-    }
3442
-
3443
-
3444
-    /**
3445
-     * Public Wrapper for _redirect_after_action() method since its
3446
-     * discovered it would be useful for external code to have access.
3447
-     *
3448
-     * @param bool   $success
3449
-     * @param string $what
3450
-     * @param string $action_desc
3451
-     * @param array  $query_args
3452
-     * @param bool   $override_overwrite
3453
-     * @throws EE_Error
3454
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
-     * @since 4.5.0
3456
-     */
3457
-    public function redirect_after_action(
3458
-        $success = false,
3459
-        $what = 'item',
3460
-        $action_desc = 'processed',
3461
-        $query_args = [],
3462
-        $override_overwrite = false
3463
-    ) {
3464
-        $this->_redirect_after_action(
3465
-            $success,
3466
-            $what,
3467
-            $action_desc,
3468
-            $query_args,
3469
-            $override_overwrite
3470
-        );
3471
-    }
3472
-
3473
-
3474
-    /**
3475
-     * Helper method for merging existing request data with the returned redirect url.
3476
-     *
3477
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
-     * filters are still applied.
3479
-     *
3480
-     * @param array $new_route_data
3481
-     * @return array
3482
-     */
3483
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
-    {
3485
-        foreach ($this->request->requestParams() as $ref => $value) {
3486
-            // unset nonces
3487
-            if (strpos($ref, 'nonce') !== false) {
3488
-                $this->request->unSetRequestParam($ref);
3489
-                continue;
3490
-            }
3491
-            // urlencode values.
3492
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
-            $this->request->setRequestParam($ref, $value);
3494
-        }
3495
-        return array_merge($this->request->requestParams(), $new_route_data);
3496
-    }
3497
-
3498
-
3499
-    /**
3500
-     *    _redirect_after_action
3501
-     *
3502
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3503
-     * @param string $what               - what the action was performed on
3504
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
-     *                                   action is completed
3507
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
-     *                                   override this so that they show.
3509
-     * @return void
3510
-     * @throws EE_Error
3511
-     */
3512
-    protected function _redirect_after_action(
3513
-        $success = 0,
3514
-        $what = 'item',
3515
-        $action_desc = 'processed',
3516
-        $query_args = [],
3517
-        $override_overwrite = false
3518
-    ) {
3519
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
-        // class name for actions/filters.
3521
-        $classname = get_class($this);
3522
-        // set redirect url.
3523
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
-        // otherwise we go with whatever is set as the _admin_base_url
3525
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
-        $notices      = EE_Error::get_notices(false);
3527
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3528
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3529
-            EE_Error::overwrite_success();
3530
-        }
3531
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
-            // how many records affected ? more than one record ? or just one ?
3533
-            if ($success > 1) {
3534
-                // set plural msg
3535
-                EE_Error::add_success(
3536
-                    sprintf(
3537
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
-                        $what,
3539
-                        $action_desc
3540
-                    ),
3541
-                    __FILE__,
3542
-                    __FUNCTION__,
3543
-                    __LINE__
3544
-                );
3545
-            } elseif ($success === 1) {
3546
-                // set singular msg
3547
-                EE_Error::add_success(
3548
-                    sprintf(
3549
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
-                        $what,
3551
-                        $action_desc
3552
-                    ),
3553
-                    __FILE__,
3554
-                    __FUNCTION__,
3555
-                    __LINE__
3556
-                );
3557
-            }
3558
-        }
3559
-        // check that $query_args isn't something crazy
3560
-        if (! is_array($query_args)) {
3561
-            $query_args = [];
3562
-        }
3563
-        /**
3564
-         * Allow injecting actions before the query_args are modified for possible different
3565
-         * redirections on save and close actions
3566
-         *
3567
-         * @param array $query_args       The original query_args array coming into the
3568
-         *                                method.
3569
-         * @since 4.2.0
3570
-         */
3571
-        do_action(
3572
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
-            $query_args
3574
-        );
3575
-        // calculate where we're going (if we have a "save and close" button pushed)
3576
-
3577
-        if (
3578
-            $this->request->requestParamIsSet('save_and_close')
3579
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3580
-        ) {
3581
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
-            // regenerate query args array from referrer URL
3584
-            parse_str($parsed_url['query'], $query_args);
3585
-            // correct page and action will be in the query args now
3586
-            $redirect_url = admin_url('admin.php');
3587
-        }
3588
-        // merge any default query_args set in _default_route_query_args property
3589
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
-            $args_to_merge = [];
3591
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
-                // is there a wp_referer array in our _default_route_query_args property?
3593
-                if ($query_param === 'wp_referer') {
3594
-                    $query_value = (array) $query_value;
3595
-                    foreach ($query_value as $reference => $value) {
3596
-                        if (strpos($reference, 'nonce') !== false) {
3597
-                            continue;
3598
-                        }
3599
-                        // finally we will override any arguments in the referer with
3600
-                        // what might be set on the _default_route_query_args array.
3601
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3602
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
-                        } else {
3604
-                            $args_to_merge[ $reference ] = urlencode($value);
3605
-                        }
3606
-                    }
3607
-                    continue;
3608
-                }
3609
-                $args_to_merge[ $query_param ] = $query_value;
3610
-            }
3611
-            // now let's merge these arguments but override with what was specifically sent in to the
3612
-            // redirect.
3613
-            $query_args = array_merge($args_to_merge, $query_args);
3614
-        }
3615
-        $this->_process_notices($query_args);
3616
-        // generate redirect url
3617
-        // if redirecting to anything other than the main page, add a nonce
3618
-        if (isset($query_args['action'])) {
3619
-            // manually generate wp_nonce and merge that with the query vars
3620
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3621
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
-        }
3623
-        // we're adding some hooks and filters in here for processing any things just before redirects
3624
-        // (example: an admin page has done an insert or update and we want to run something after that).
3625
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
-        $redirect_url = apply_filters(
3627
-            'FHEE_redirect_' . $classname . $this->_req_action,
3628
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3629
-            $query_args
3630
-        );
3631
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
-        if ($this->request->isAjax()) {
3633
-            $default_data                    = [
3634
-                'close'        => true,
3635
-                'redirect_url' => $redirect_url,
3636
-                'where'        => 'main',
3637
-                'what'         => 'append',
3638
-            ];
3639
-            $this->_template_args['success'] = $success;
3640
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
-                $default_data,
3642
-                $this->_template_args['data']
3643
-            ) : $default_data;
3644
-            $this->_return_json();
3645
-        }
3646
-        wp_safe_redirect($redirect_url);
3647
-        exit();
3648
-    }
3649
-
3650
-
3651
-    /**
3652
-     * process any notices before redirecting (or returning ajax request)
3653
-     * This method sets the $this->_template_args['notices'] attribute;
3654
-     *
3655
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
-     *                                  page_routes haven't been defined yet.
3658
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
-     *                                  still save a transient for the notice.
3660
-     * @return void
3661
-     * @throws EE_Error
3662
-     */
3663
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
-    {
3665
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
-        if ($this->request->isAjax()) {
3667
-            $notices = EE_Error::get_notices(false);
3668
-            if (empty($this->_template_args['success'])) {
3669
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
-            }
3671
-            if (empty($this->_template_args['errors'])) {
3672
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
-            }
3674
-            if (empty($this->_template_args['attention'])) {
3675
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
-            }
3677
-        }
3678
-        $this->_template_args['notices'] = EE_Error::get_notices();
3679
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
-        if (! $this->request->isAjax() || $sticky_notices) {
3681
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
-            $this->_add_transient(
3683
-                $route,
3684
-                $this->_template_args['notices'],
3685
-                true,
3686
-                $skip_route_verify
3687
-            );
3688
-        }
3689
-    }
3690
-
3691
-
3692
-    /**
3693
-     * get_action_link_or_button
3694
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
-     *
3696
-     * @param string $action        use this to indicate which action the url is generated with.
3697
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
-     *                              property.
3699
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
-     * @param string $base_url      If this is not provided
3702
-     *                              the _admin_base_url will be used as the default for the button base_url.
3703
-     *                              Otherwise this value will be used.
3704
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
-     * @return string
3706
-     * @throws InvalidArgumentException
3707
-     * @throws InvalidInterfaceException
3708
-     * @throws InvalidDataTypeException
3709
-     * @throws EE_Error
3710
-     */
3711
-    public function get_action_link_or_button(
3712
-        $action,
3713
-        $type = 'add',
3714
-        $extra_request = [],
3715
-        $class = 'button-primary',
3716
-        $base_url = '',
3717
-        $exclude_nonce = false
3718
-    ) {
3719
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
-            throw new EE_Error(
3722
-                sprintf(
3723
-                    esc_html__(
3724
-                        'There is no page route for given action for the button.  This action was given: %s',
3725
-                        'event_espresso'
3726
-                    ),
3727
-                    $action
3728
-                )
3729
-            );
3730
-        }
3731
-        if (! isset($this->_labels['buttons'][ $type ])) {
3732
-            throw new EE_Error(
3733
-                sprintf(
3734
-                    esc_html__(
3735
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
-                        'event_espresso'
3737
-                    ),
3738
-                    $type
3739
-                )
3740
-            );
3741
-        }
3742
-        // finally check user access for this button.
3743
-        $has_access = $this->check_user_access($action, true);
3744
-        if (! $has_access) {
3745
-            return '';
3746
-        }
3747
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
-        $query_args = [
3749
-            'action' => $action,
3750
-        ];
3751
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
-        if (! empty($extra_request)) {
3753
-            $query_args = array_merge($extra_request, $query_args);
3754
-        }
3755
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
-    }
3758
-
3759
-
3760
-    /**
3761
-     * _per_page_screen_option
3762
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
-     *
3764
-     * @return void
3765
-     * @throws InvalidArgumentException
3766
-     * @throws InvalidInterfaceException
3767
-     * @throws InvalidDataTypeException
3768
-     */
3769
-    protected function _per_page_screen_option()
3770
-    {
3771
-        $option = 'per_page';
3772
-        $args   = [
3773
-            'label'   => apply_filters(
3774
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
-                $this->_admin_page_title,
3776
-                $this
3777
-            ),
3778
-            'default' => (int) apply_filters(
3779
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
-                20
3781
-            ),
3782
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
-        ];
3784
-        // ONLY add the screen option if the user has access to it.
3785
-        if ($this->check_user_access($this->_current_view, true)) {
3786
-            add_screen_option($option, $args);
3787
-        }
3788
-    }
3789
-
3790
-
3791
-    /**
3792
-     * set_per_page_screen_option
3793
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
-     * admin_menu.
3796
-     *
3797
-     * @return void
3798
-     */
3799
-    private function _set_per_page_screen_options()
3800
-    {
3801
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
-            if (! $user = wp_get_current_user()) {
3804
-                return;
3805
-            }
3806
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
-            if (! $option) {
3808
-                return;
3809
-            }
3810
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
-            $map_option = $option;
3812
-            $option     = str_replace('-', '_', $option);
3813
-            switch ($map_option) {
3814
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
-                    $max_value = apply_filters(
3816
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
-                        999,
3818
-                        $this->_current_page,
3819
-                        $this->_current_view
3820
-                    );
3821
-                    if ($value < 1) {
3822
-                        return;
3823
-                    }
3824
-                    $value = min($value, $max_value);
3825
-                    break;
3826
-                default:
3827
-                    $value = apply_filters(
3828
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
-                        false,
3830
-                        $option,
3831
-                        $value
3832
-                    );
3833
-                    if (false === $value) {
3834
-                        return;
3835
-                    }
3836
-                    break;
3837
-            }
3838
-            update_user_meta($user->ID, $option, $value);
3839
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
-            exit;
3841
-        }
3842
-    }
3843
-
3844
-
3845
-    /**
3846
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
-     *
3848
-     * @param array $data array that will be assigned to template args.
3849
-     */
3850
-    public function set_template_args($data)
3851
-    {
3852
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3853
-    }
3854
-
3855
-
3856
-    /**
3857
-     * This makes available the WP transient system for temporarily moving data between routes
3858
-     *
3859
-     * @param string $route             the route that should receive the transient
3860
-     * @param array  $data              the data that gets sent
3861
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
-     *                                  normal route transient.
3863
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
-     *                                  when we are adding a transient before page_routes have been defined.
3865
-     * @return void
3866
-     * @throws EE_Error
3867
-     */
3868
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
-    {
3870
-        $user_id = get_current_user_id();
3871
-        if (! $skip_route_verify) {
3872
-            $this->_verify_route($route);
3873
-        }
3874
-        // now let's set the string for what kind of transient we're setting
3875
-        $transient = $notices
3876
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
-            : 'rte_tx_' . $route . '_' . $user_id;
3878
-        $data      = $notices ? ['notices' => $data] : $data;
3879
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3880
-        $existing = is_multisite() && is_network_admin()
3881
-            ? get_site_transient($transient)
3882
-            : get_transient($transient);
3883
-        if ($existing) {
3884
-            $data = array_merge((array) $data, (array) $existing);
3885
-        }
3886
-        if (is_multisite() && is_network_admin()) {
3887
-            set_site_transient($transient, $data, 8);
3888
-        } else {
3889
-            set_transient($transient, $data, 8);
3890
-        }
3891
-    }
3892
-
3893
-
3894
-    /**
3895
-     * this retrieves the temporary transient that has been set for moving data between routes.
3896
-     *
3897
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
-     * @param string $route
3899
-     * @return mixed data
3900
-     */
3901
-    protected function _get_transient($notices = false, $route = '')
3902
-    {
3903
-        $user_id   = get_current_user_id();
3904
-        $route     = ! $route ? $this->_req_action : $route;
3905
-        $transient = $notices
3906
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
-            : 'rte_tx_' . $route . '_' . $user_id;
3908
-        $data      = is_multisite() && is_network_admin()
3909
-            ? get_site_transient($transient)
3910
-            : get_transient($transient);
3911
-        // delete transient after retrieval (just in case it hasn't expired);
3912
-        if (is_multisite() && is_network_admin()) {
3913
-            delete_site_transient($transient);
3914
-        } else {
3915
-            delete_transient($transient);
3916
-        }
3917
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
-     * default route callback on the EE_Admin page you want it run.)
3925
-     *
3926
-     * @return void
3927
-     */
3928
-    protected function _transient_garbage_collection()
3929
-    {
3930
-        global $wpdb;
3931
-        // retrieve all existing transients
3932
-        $query =
3933
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
-        if ($results = $wpdb->get_results($query)) {
3935
-            foreach ($results as $result) {
3936
-                $transient = str_replace('_transient_', '', $result->option_name);
3937
-                get_transient($transient);
3938
-                if (is_multisite() && is_network_admin()) {
3939
-                    get_site_transient($transient);
3940
-                }
3941
-            }
3942
-        }
3943
-    }
3944
-
3945
-
3946
-    /**
3947
-     * get_view
3948
-     *
3949
-     * @return string content of _view property
3950
-     */
3951
-    public function get_view()
3952
-    {
3953
-        return $this->_view;
3954
-    }
3955
-
3956
-
3957
-    /**
3958
-     * getter for the protected $_views property
3959
-     *
3960
-     * @return array
3961
-     */
3962
-    public function get_views()
3963
-    {
3964
-        return $this->_views;
3965
-    }
3966
-
3967
-
3968
-    /**
3969
-     * get_current_page
3970
-     *
3971
-     * @return string _current_page property value
3972
-     */
3973
-    public function get_current_page()
3974
-    {
3975
-        return $this->_current_page;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * get_current_view
3981
-     *
3982
-     * @return string _current_view property value
3983
-     */
3984
-    public function get_current_view()
3985
-    {
3986
-        return $this->_current_view;
3987
-    }
3988
-
3989
-
3990
-    /**
3991
-     * get_current_screen
3992
-     *
3993
-     * @return object The current WP_Screen object
3994
-     */
3995
-    public function get_current_screen()
3996
-    {
3997
-        return $this->_current_screen;
3998
-    }
3999
-
4000
-
4001
-    /**
4002
-     * get_current_page_view_url
4003
-     *
4004
-     * @return string This returns the url for the current_page_view.
4005
-     */
4006
-    public function get_current_page_view_url()
4007
-    {
4008
-        return $this->_current_page_view_url;
4009
-    }
4010
-
4011
-
4012
-    /**
4013
-     * just returns the Request
4014
-     *
4015
-     * @return RequestInterface
4016
-     */
4017
-    public function get_request()
4018
-    {
4019
-        return $this->request;
4020
-    }
4021
-
4022
-
4023
-    /**
4024
-     * just returns the _req_data property
4025
-     *
4026
-     * @return array
4027
-     */
4028
-    public function get_request_data()
4029
-    {
4030
-        return $this->request->requestParams();
4031
-    }
4032
-
4033
-
4034
-    /**
4035
-     * returns the _req_data protected property
4036
-     *
4037
-     * @return string
4038
-     */
4039
-    public function get_req_action()
4040
-    {
4041
-        return $this->_req_action;
4042
-    }
4043
-
4044
-
4045
-    /**
4046
-     * @return bool  value of $_is_caf property
4047
-     */
4048
-    public function is_caf()
4049
-    {
4050
-        return $this->_is_caf;
4051
-    }
4052
-
4053
-
4054
-    /**
4055
-     * @return mixed
4056
-     */
4057
-    public function default_espresso_metaboxes()
4058
-    {
4059
-        return $this->_default_espresso_metaboxes;
4060
-    }
4061
-
4062
-
4063
-    /**
4064
-     * @return mixed
4065
-     */
4066
-    public function admin_base_url()
4067
-    {
4068
-        return $this->_admin_base_url;
4069
-    }
4070
-
4071
-
4072
-    /**
4073
-     * @return mixed
4074
-     */
4075
-    public function wp_page_slug()
4076
-    {
4077
-        return $this->_wp_page_slug;
4078
-    }
4079
-
4080
-
4081
-    /**
4082
-     * updates  espresso configuration settings
4083
-     *
4084
-     * @param string                   $tab
4085
-     * @param EE_Config_Base|EE_Config $config
4086
-     * @param string                   $file file where error occurred
4087
-     * @param string                   $func function  where error occurred
4088
-     * @param string                   $line line no where error occurred
4089
-     * @return boolean
4090
-     */
4091
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
-    {
4093
-        // remove any options that are NOT going to be saved with the config settings.
4094
-        if (isset($config->core->ee_ueip_optin)) {
4095
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4096
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
-            update_option('ee_ueip_has_notified', true);
4098
-        }
4099
-        // and save it (note we're also doing the network save here)
4100
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
-        if ($config_saved && $net_saved) {
4103
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
-            return true;
4105
-        }
4106
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
-        return false;
4108
-    }
4109
-
4110
-
4111
-    /**
4112
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
-     *
4114
-     * @return array
4115
-     */
4116
-    public function get_yes_no_values()
4117
-    {
4118
-        return $this->_yes_no_values;
4119
-    }
4120
-
4121
-
4122
-    protected function _get_dir()
4123
-    {
4124
-        $reflector = new ReflectionClass(get_class($this));
4125
-        return dirname($reflector->getFileName());
4126
-    }
4127
-
4128
-
4129
-    /**
4130
-     * A helper for getting a "next link".
4131
-     *
4132
-     * @param string $url   The url to link to
4133
-     * @param string $class The class to use.
4134
-     * @return string
4135
-     */
4136
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
-    {
4138
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
-    }
4140
-
4141
-
4142
-    /**
4143
-     * A helper for getting a "previous link".
4144
-     *
4145
-     * @param string $url   The url to link to
4146
-     * @param string $class The class to use.
4147
-     * @return string
4148
-     */
4149
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
-    {
4151
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
-    }
4153
-
4154
-
4155
-
4156
-
4157
-
4158
-
4159
-
4160
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
-
4162
-
4163
-    /**
4164
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4166
-     * _req_data array.
4167
-     *
4168
-     * @return bool success/fail
4169
-     * @throws EE_Error
4170
-     * @throws InvalidArgumentException
4171
-     * @throws ReflectionException
4172
-     * @throws InvalidDataTypeException
4173
-     * @throws InvalidInterfaceException
4174
-     */
4175
-    protected function _process_resend_registration()
4176
-    {
4177
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
-        do_action(
4179
-            'AHEE__EE_Admin_Page___process_resend_registration',
4180
-            $this->_template_args['success'],
4181
-            $this->request->requestParams()
4182
-        );
4183
-        return $this->_template_args['success'];
4184
-    }
4185
-
4186
-
4187
-    /**
4188
-     * This automatically processes any payment message notifications when manual payment has been applied.
4189
-     *
4190
-     * @param EE_Payment $payment
4191
-     * @return bool success/fail
4192
-     */
4193
-    protected function _process_payment_notification(EE_Payment $payment)
4194
-    {
4195
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
-        $this->_template_args['success'] = apply_filters(
4198
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
-            false,
4200
-            $payment
4201
-        );
4202
-        return $this->_template_args['success'];
4203
-    }
2764
+	}
2765
+
2766
+
2767
+	/**
2768
+	 * facade for add_meta_box
2769
+	 *
2770
+	 * @param string  $action        where the metabox get's displayed
2771
+	 * @param string  $title         Title of Metabox (output in metabox header)
2772
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
+	 *                               instead of the one created in here.
2774
+	 * @param array   $callback_args an array of args supplied for the metabox
2775
+	 * @param string  $column        what metabox column
2776
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
+	 *                               created but just set our own callback for wp's add_meta_box.
2779
+	 * @throws DomainException
2780
+	 */
2781
+	public function _add_admin_page_meta_box(
2782
+		$action,
2783
+		$title,
2784
+		$callback,
2785
+		$callback_args,
2786
+		$column = 'normal',
2787
+		$priority = 'high',
2788
+		$create_func = true
2789
+	) {
2790
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2792
+		if (empty($callback_args) && $create_func) {
2793
+			$callback_args = [
2794
+				'template_path' => $this->_template_path,
2795
+				'template_args' => $this->_template_args,
2796
+			];
2797
+		}
2798
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2799
+		$call_back_func = $create_func
2800
+			? function ($post, $metabox) {
2801
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
+				echo EEH_Template::display_template(
2803
+					$metabox['args']['template_path'],
2804
+					$metabox['args']['template_args'],
2805
+					true
2806
+				);
2807
+			}
2808
+			: $callback;
2809
+		add_meta_box(
2810
+			str_replace('_', '-', $action) . '-mbox',
2811
+			$title,
2812
+			$call_back_func,
2813
+			$this->_wp_page_slug,
2814
+			$column,
2815
+			$priority,
2816
+			$callback_args
2817
+		);
2818
+	}
2819
+
2820
+
2821
+	/**
2822
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
+	 *
2824
+	 * @throws DomainException
2825
+	 * @throws EE_Error
2826
+	 */
2827
+	public function display_admin_page_with_metabox_columns()
2828
+	{
2829
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
+			$this->_column_template_path,
2832
+			$this->_template_args,
2833
+			true
2834
+		);
2835
+		// the final wrapper
2836
+		$this->admin_page_wrapper();
2837
+	}
2838
+
2839
+
2840
+	/**
2841
+	 * generates  HTML wrapper for an admin details page
2842
+	 *
2843
+	 * @return void
2844
+	 * @throws EE_Error
2845
+	 * @throws DomainException
2846
+	 */
2847
+	public function display_admin_page_with_sidebar()
2848
+	{
2849
+		$this->_display_admin_page(true);
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2855
+	 *
2856
+	 * @return void
2857
+	 * @throws EE_Error
2858
+	 * @throws DomainException
2859
+	 */
2860
+	public function display_admin_page_with_no_sidebar()
2861
+	{
2862
+		$this->_display_admin_page();
2863
+	}
2864
+
2865
+
2866
+	/**
2867
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2868
+	 *
2869
+	 * @return void
2870
+	 * @throws EE_Error
2871
+	 * @throws DomainException
2872
+	 */
2873
+	public function display_about_admin_page()
2874
+	{
2875
+		$this->_display_admin_page(false, true);
2876
+	}
2877
+
2878
+
2879
+	/**
2880
+	 * display_admin_page
2881
+	 * contains the code for actually displaying an admin page
2882
+	 *
2883
+	 * @param boolean $sidebar true with sidebar, false without
2884
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
+	 * @return void
2886
+	 * @throws DomainException
2887
+	 * @throws EE_Error
2888
+	 */
2889
+	private function _display_admin_page($sidebar = false, $about = false)
2890
+	{
2891
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2895
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2897
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
+			? 'poststuff'
2899
+			: 'espresso-default-admin';
2900
+		$template_path                                     = $sidebar
2901
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
+		if ($this->request->isAjax()) {
2904
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
+		}
2906
+		$template_path                                     = ! empty($this->_column_template_path)
2907
+			? $this->_column_template_path : $template_path;
2908
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
+			? $this->_template_args['admin_page_content']
2910
+			: '';
2911
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
+			? $this->_template_args['before_admin_page_content']
2913
+			: '';
2914
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
+			? $this->_template_args['after_admin_page_content']
2916
+			: '';
2917
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
+			$template_path,
2919
+			$this->_template_args,
2920
+			true
2921
+		);
2922
+		// the final template wrapper
2923
+		$this->admin_page_wrapper($about);
2924
+	}
2925
+
2926
+
2927
+	/**
2928
+	 * This is used to display caf preview pages.
2929
+	 *
2930
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2931
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
+	 * @return void
2934
+	 * @throws DomainException
2935
+	 * @throws EE_Error
2936
+	 * @throws InvalidArgumentException
2937
+	 * @throws InvalidDataTypeException
2938
+	 * @throws InvalidInterfaceException
2939
+	 * @since 4.3.2
2940
+	 */
2941
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
+	{
2943
+		// let's generate a default preview action button if there isn't one already present.
2944
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2945
+			'Upgrade to Event Espresso 4 Right Now',
2946
+			'event_espresso'
2947
+		);
2948
+		$buy_now_url                                   = add_query_arg(
2949
+			[
2950
+				'ee_ver'       => 'ee4',
2951
+				'utm_source'   => 'ee4_plugin_admin',
2952
+				'utm_medium'   => 'link',
2953
+				'utm_campaign' => $utm_campaign_source,
2954
+				'utm_content'  => 'buy_now_button',
2955
+			],
2956
+			'https://eventespresso.com/pricing/'
2957
+		);
2958
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
+			? $this->get_action_link_or_button(
2960
+				'',
2961
+				'buy_now',
2962
+				[],
2963
+				'button-primary button-large',
2964
+				esc_url_raw($buy_now_url),
2965
+				true
2966
+			)
2967
+			: $this->_template_args['preview_action_button'];
2968
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
+			$this->_template_args,
2971
+			true
2972
+		);
2973
+		$this->_display_admin_page($display_sidebar);
2974
+	}
2975
+
2976
+
2977
+	/**
2978
+	 * display_admin_list_table_page_with_sidebar
2979
+	 * generates HTML wrapper for an admin_page with list_table
2980
+	 *
2981
+	 * @return void
2982
+	 * @throws EE_Error
2983
+	 * @throws DomainException
2984
+	 */
2985
+	public function display_admin_list_table_page_with_sidebar()
2986
+	{
2987
+		$this->_display_admin_list_table_page(true);
2988
+	}
2989
+
2990
+
2991
+	/**
2992
+	 * display_admin_list_table_page_with_no_sidebar
2993
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
+	 *
2995
+	 * @return void
2996
+	 * @throws EE_Error
2997
+	 * @throws DomainException
2998
+	 */
2999
+	public function display_admin_list_table_page_with_no_sidebar()
3000
+	{
3001
+		$this->_display_admin_list_table_page();
3002
+	}
3003
+
3004
+
3005
+	/**
3006
+	 * generates html wrapper for an admin_list_table page
3007
+	 *
3008
+	 * @param boolean $sidebar whether to display with sidebar or not.
3009
+	 * @return void
3010
+	 * @throws DomainException
3011
+	 * @throws EE_Error
3012
+	 */
3013
+	private function _display_admin_list_table_page($sidebar = false)
3014
+	{
3015
+		// setup search attributes
3016
+		$this->_set_search_attributes();
3017
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3018
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
+		$this->_template_args['table_url']        = $this->request->isAjax()
3020
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
+		$this->_template_args['list_table']       = $this->_list_table_object;
3023
+		$this->_template_args['current_route']    = $this->_req_action;
3024
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
+		if (! empty($ajax_sorting_callback)) {
3027
+			$sortable_list_table_form_fields = wp_nonce_field(
3028
+				$ajax_sorting_callback . '_nonce',
3029
+				$ajax_sorting_callback . '_nonce',
3030
+				false,
3031
+				false
3032
+			);
3033
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
+												. $this->page_slug
3035
+												. '" />';
3036
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
+												. $ajax_sorting_callback
3038
+												. '" />';
3039
+		} else {
3040
+			$sortable_list_table_form_fields = '';
3041
+		}
3042
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
+		$hidden_form_fields                                      =
3044
+			isset($this->_template_args['list_table_hidden_fields'])
3045
+				? $this->_template_args['list_table_hidden_fields']
3046
+				: '';
3047
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3048
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3049
+																	. $nonce_ref
3050
+																	. '" value="'
3051
+																	. wp_create_nonce($nonce_ref)
3052
+																	. '">';
3053
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
+		// display message about search results?
3055
+		$search = $this->request->getRequestParam('s');
3056
+		$this->_template_args['before_list_table'] .= ! empty($search)
3057
+			? '<p class="ee-search-results">' . sprintf(
3058
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
+				trim($search, '%')
3060
+			) . '</p>'
3061
+			: '';
3062
+		// filter before_list_table template arg
3063
+		$this->_template_args['before_list_table'] = apply_filters(
3064
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
+			$this->_template_args['before_list_table'],
3066
+			$this->page_slug,
3067
+			$this->request->requestParams(),
3068
+			$this->_req_action
3069
+		);
3070
+		// convert to array and filter again
3071
+		// arrays are easier to inject new items in a specific location,
3072
+		// but would not be backwards compatible, so we have to add a new filter
3073
+		$this->_template_args['before_list_table'] = implode(
3074
+			" \n",
3075
+			(array) apply_filters(
3076
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
+				(array) $this->_template_args['before_list_table'],
3078
+				$this->page_slug,
3079
+				$this->request->requestParams(),
3080
+				$this->_req_action
3081
+			)
3082
+		);
3083
+		// filter after_list_table template arg
3084
+		$this->_template_args['after_list_table'] = apply_filters(
3085
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
+			$this->_template_args['after_list_table'],
3087
+			$this->page_slug,
3088
+			$this->request->requestParams(),
3089
+			$this->_req_action
3090
+		);
3091
+		// convert to array and filter again
3092
+		// arrays are easier to inject new items in a specific location,
3093
+		// but would not be backwards compatible, so we have to add a new filter
3094
+		$this->_template_args['after_list_table']   = implode(
3095
+			" \n",
3096
+			(array) apply_filters(
3097
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
+				(array) $this->_template_args['after_list_table'],
3099
+				$this->page_slug,
3100
+				$this->request->requestParams(),
3101
+				$this->_req_action
3102
+			)
3103
+		);
3104
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
+			$template_path,
3106
+			$this->_template_args,
3107
+			true
3108
+		);
3109
+		// the final template wrapper
3110
+		if ($sidebar) {
3111
+			$this->display_admin_page_with_sidebar();
3112
+		} else {
3113
+			$this->display_admin_page_with_no_sidebar();
3114
+		}
3115
+	}
3116
+
3117
+
3118
+	/**
3119
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
+	 * html string for the legend.
3121
+	 * $items are expected in an array in the following format:
3122
+	 * $legend_items = array(
3123
+	 *        'item_id' => array(
3124
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3125
+	 *            'desc' => esc_html__('localized description of item');
3126
+	 *        )
3127
+	 * );
3128
+	 *
3129
+	 * @param array $items see above for format of array
3130
+	 * @return string html string of legend
3131
+	 * @throws DomainException
3132
+	 */
3133
+	protected function _display_legend($items)
3134
+	{
3135
+		$this->_template_args['items'] = apply_filters(
3136
+			'FHEE__EE_Admin_Page___display_legend__items',
3137
+			(array) $items,
3138
+			$this
3139
+		);
3140
+		return EEH_Template::display_template(
3141
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
+			$this->_template_args,
3143
+			true
3144
+		);
3145
+	}
3146
+
3147
+
3148
+	/**
3149
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
+	 * The returned json object is created from an array in the following format:
3151
+	 * array(
3152
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3155
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
+	 *  that might be included in here)
3159
+	 * )
3160
+	 * The json object is populated by whatever is set in the $_template_args property.
3161
+	 *
3162
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
+	 *                                 instead of displayed.
3164
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
+	 * @return void
3166
+	 * @throws EE_Error
3167
+	 */
3168
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
+	{
3170
+		// make sure any EE_Error notices have been handled.
3171
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3172
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
+		unset($this->_template_args['data']);
3174
+		$json = [
3175
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
+			'notices'   => EE_Error::get_notices(),
3180
+			'content'   => isset($this->_template_args['admin_page_content'])
3181
+				? $this->_template_args['admin_page_content'] : '',
3182
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
+			'isEEajax'  => true
3184
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
+		];
3186
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
+		if (null === error_get_last() || ! headers_sent()) {
3188
+			header('Content-Type: application/json; charset=UTF-8');
3189
+		}
3190
+		echo wp_json_encode($json);
3191
+		exit();
3192
+	}
3193
+
3194
+
3195
+	/**
3196
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
+	 *
3198
+	 * @return void
3199
+	 * @throws EE_Error
3200
+	 */
3201
+	public function return_json()
3202
+	{
3203
+		if ($this->request->isAjax()) {
3204
+			$this->_return_json();
3205
+		} else {
3206
+			throw new EE_Error(
3207
+				sprintf(
3208
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
+					__FUNCTION__
3210
+				)
3211
+			);
3212
+		}
3213
+	}
3214
+
3215
+
3216
+	/**
3217
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
+	 *
3220
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
+	 */
3222
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
+	{
3224
+		$this->_hook_obj = $hook_obj;
3225
+	}
3226
+
3227
+
3228
+	/**
3229
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3230
+	 *
3231
+	 * @param boolean $about whether to use the special about page wrapper or default.
3232
+	 * @return void
3233
+	 * @throws DomainException
3234
+	 * @throws EE_Error
3235
+	 */
3236
+	public function admin_page_wrapper($about = false)
3237
+	{
3238
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3242
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3243
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
+			isset($this->_template_args['before_admin_page_content'])
3245
+				? $this->_template_args['before_admin_page_content']
3246
+				: ''
3247
+		);
3248
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3249
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
+			isset($this->_template_args['after_admin_page_content'])
3251
+				? $this->_template_args['after_admin_page_content']
3252
+				: ''
3253
+		);
3254
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
+		// load settings page wrapper template
3256
+		$template_path = ! $this->request->isAjax()
3257
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
+		// about page?
3260
+		$template_path = $about
3261
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
+			: $template_path;
3263
+		if ($this->request->isAjax()) {
3264
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
+				$template_path,
3266
+				$this->_template_args,
3267
+				true
3268
+			);
3269
+			$this->_return_json();
3270
+		} else {
3271
+			EEH_Template::display_template($template_path, $this->_template_args);
3272
+		}
3273
+	}
3274
+
3275
+
3276
+	/**
3277
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
+	 *
3279
+	 * @return string html
3280
+	 * @throws EE_Error
3281
+	 */
3282
+	protected function _get_main_nav_tabs()
3283
+	{
3284
+		// let's generate the html using the EEH_Tabbed_Content helper.
3285
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
+		// (rather than setting in the page_routes array)
3287
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *        sort nav tabs
3293
+	 *
3294
+	 * @param $a
3295
+	 * @param $b
3296
+	 * @return int
3297
+	 */
3298
+	private function _sort_nav_tabs($a, $b)
3299
+	{
3300
+		if ($a['order'] === $b['order']) {
3301
+			return 0;
3302
+		}
3303
+		return ($a['order'] < $b['order']) ? -1 : 1;
3304
+	}
3305
+
3306
+
3307
+	/**
3308
+	 *    generates HTML for the forms used on admin pages
3309
+	 *
3310
+	 * @param array  $input_vars   - array of input field details
3311
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
+	 *                             use)
3313
+	 * @param bool   $id
3314
+	 * @return string
3315
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
+	 */
3318
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
+	{
3320
+		return $generator === 'string'
3321
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3323
+	}
3324
+
3325
+
3326
+	/**
3327
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3328
+	 *
3329
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
+	 *                                   Close" button.
3331
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
+	 *                                   'Save', [1] => 'save & close')
3333
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3335
+	 *                                   default actions by submitting some other value.
3336
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
+	 *                                   close (normal form handling).
3339
+	 */
3340
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
+	{
3342
+		// make sure $text and $actions are in an array
3343
+		$text          = (array) $text;
3344
+		$actions       = (array) $actions;
3345
+		$referrer_url  = empty($referrer)
3346
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
+			  . $this->request->getServerParam('REQUEST_URI')
3348
+			  . '" />'
3349
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
+			  . $referrer
3351
+			  . '" />';
3352
+		$button_text   = ! empty($text)
3353
+			? $text
3354
+			: [
3355
+				esc_html__('Save', 'event_espresso'),
3356
+				esc_html__('Save and Close', 'event_espresso'),
3357
+			];
3358
+		$default_names = ['save', 'save_and_close'];
3359
+		// add in a hidden index for the current page (so save and close redirects properly)
3360
+		$this->_template_args['save_buttons'] = $referrer_url;
3361
+		foreach ($button_text as $key => $button) {
3362
+			$ref                                  = $default_names[ $key ];
3363
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
+													 . $ref
3365
+													 . '" value="'
3366
+													 . $button
3367
+													 . '" name="'
3368
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3369
+													 . '" id="'
3370
+													 . $this->_current_view . '_' . $ref
3371
+													 . '" />';
3372
+			if (! $both) {
3373
+				break;
3374
+			}
3375
+		}
3376
+	}
3377
+
3378
+
3379
+	/**
3380
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
+	 *
3382
+	 * @param string $route
3383
+	 * @param array  $additional_hidden_fields
3384
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3385
+	 * @since 4.6.0
3386
+	 */
3387
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
+	{
3389
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
+	}
3391
+
3392
+
3393
+	/**
3394
+	 * set form open and close tags on add/edit pages.
3395
+	 *
3396
+	 * @param string $route                    the route you want the form to direct to
3397
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
+	 * @return void
3399
+	 */
3400
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
+	{
3402
+		if (empty($route)) {
3403
+			$user_msg = esc_html__(
3404
+				'An error occurred. No action was set for this page\'s form.',
3405
+				'event_espresso'
3406
+			);
3407
+			$dev_msg  = $user_msg . "\n"
3408
+						. sprintf(
3409
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
+							__FUNCTION__,
3411
+							__CLASS__
3412
+						);
3413
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
+		}
3415
+		// open form
3416
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
+															 . $this->_admin_base_url
3418
+															 . '" id="'
3419
+															 . $route
3420
+															 . '_event_form" >';
3421
+		// add nonce
3422
+		$nonce                                             =
3423
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
+		// add REQUIRED form action
3426
+		$hidden_fields = [
3427
+			'action' => ['type' => 'hidden', 'value' => $route],
3428
+		];
3429
+		// merge arrays
3430
+		$hidden_fields = is_array($additional_hidden_fields)
3431
+			? array_merge($hidden_fields, $additional_hidden_fields)
3432
+			: $hidden_fields;
3433
+		// generate form fields
3434
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
+		// add fields to form
3436
+		foreach ((array) $form_fields as $field_name => $form_field) {
3437
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
+		}
3439
+		// close form
3440
+		$this->_template_args['after_admin_page_content'] = '</form>';
3441
+	}
3442
+
3443
+
3444
+	/**
3445
+	 * Public Wrapper for _redirect_after_action() method since its
3446
+	 * discovered it would be useful for external code to have access.
3447
+	 *
3448
+	 * @param bool   $success
3449
+	 * @param string $what
3450
+	 * @param string $action_desc
3451
+	 * @param array  $query_args
3452
+	 * @param bool   $override_overwrite
3453
+	 * @throws EE_Error
3454
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
+	 * @since 4.5.0
3456
+	 */
3457
+	public function redirect_after_action(
3458
+		$success = false,
3459
+		$what = 'item',
3460
+		$action_desc = 'processed',
3461
+		$query_args = [],
3462
+		$override_overwrite = false
3463
+	) {
3464
+		$this->_redirect_after_action(
3465
+			$success,
3466
+			$what,
3467
+			$action_desc,
3468
+			$query_args,
3469
+			$override_overwrite
3470
+		);
3471
+	}
3472
+
3473
+
3474
+	/**
3475
+	 * Helper method for merging existing request data with the returned redirect url.
3476
+	 *
3477
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
+	 * filters are still applied.
3479
+	 *
3480
+	 * @param array $new_route_data
3481
+	 * @return array
3482
+	 */
3483
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
+	{
3485
+		foreach ($this->request->requestParams() as $ref => $value) {
3486
+			// unset nonces
3487
+			if (strpos($ref, 'nonce') !== false) {
3488
+				$this->request->unSetRequestParam($ref);
3489
+				continue;
3490
+			}
3491
+			// urlencode values.
3492
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
+			$this->request->setRequestParam($ref, $value);
3494
+		}
3495
+		return array_merge($this->request->requestParams(), $new_route_data);
3496
+	}
3497
+
3498
+
3499
+	/**
3500
+	 *    _redirect_after_action
3501
+	 *
3502
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3503
+	 * @param string $what               - what the action was performed on
3504
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
+	 *                                   action is completed
3507
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
+	 *                                   override this so that they show.
3509
+	 * @return void
3510
+	 * @throws EE_Error
3511
+	 */
3512
+	protected function _redirect_after_action(
3513
+		$success = 0,
3514
+		$what = 'item',
3515
+		$action_desc = 'processed',
3516
+		$query_args = [],
3517
+		$override_overwrite = false
3518
+	) {
3519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
+		// class name for actions/filters.
3521
+		$classname = get_class($this);
3522
+		// set redirect url.
3523
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
+		// otherwise we go with whatever is set as the _admin_base_url
3525
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
+		$notices      = EE_Error::get_notices(false);
3527
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3528
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3529
+			EE_Error::overwrite_success();
3530
+		}
3531
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
+			// how many records affected ? more than one record ? or just one ?
3533
+			if ($success > 1) {
3534
+				// set plural msg
3535
+				EE_Error::add_success(
3536
+					sprintf(
3537
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
+						$what,
3539
+						$action_desc
3540
+					),
3541
+					__FILE__,
3542
+					__FUNCTION__,
3543
+					__LINE__
3544
+				);
3545
+			} elseif ($success === 1) {
3546
+				// set singular msg
3547
+				EE_Error::add_success(
3548
+					sprintf(
3549
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
+						$what,
3551
+						$action_desc
3552
+					),
3553
+					__FILE__,
3554
+					__FUNCTION__,
3555
+					__LINE__
3556
+				);
3557
+			}
3558
+		}
3559
+		// check that $query_args isn't something crazy
3560
+		if (! is_array($query_args)) {
3561
+			$query_args = [];
3562
+		}
3563
+		/**
3564
+		 * Allow injecting actions before the query_args are modified for possible different
3565
+		 * redirections on save and close actions
3566
+		 *
3567
+		 * @param array $query_args       The original query_args array coming into the
3568
+		 *                                method.
3569
+		 * @since 4.2.0
3570
+		 */
3571
+		do_action(
3572
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
+			$query_args
3574
+		);
3575
+		// calculate where we're going (if we have a "save and close" button pushed)
3576
+
3577
+		if (
3578
+			$this->request->requestParamIsSet('save_and_close')
3579
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3580
+		) {
3581
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
+			// regenerate query args array from referrer URL
3584
+			parse_str($parsed_url['query'], $query_args);
3585
+			// correct page and action will be in the query args now
3586
+			$redirect_url = admin_url('admin.php');
3587
+		}
3588
+		// merge any default query_args set in _default_route_query_args property
3589
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
+			$args_to_merge = [];
3591
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
+				// is there a wp_referer array in our _default_route_query_args property?
3593
+				if ($query_param === 'wp_referer') {
3594
+					$query_value = (array) $query_value;
3595
+					foreach ($query_value as $reference => $value) {
3596
+						if (strpos($reference, 'nonce') !== false) {
3597
+							continue;
3598
+						}
3599
+						// finally we will override any arguments in the referer with
3600
+						// what might be set on the _default_route_query_args array.
3601
+						if (isset($this->_default_route_query_args[ $reference ])) {
3602
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
+						} else {
3604
+							$args_to_merge[ $reference ] = urlencode($value);
3605
+						}
3606
+					}
3607
+					continue;
3608
+				}
3609
+				$args_to_merge[ $query_param ] = $query_value;
3610
+			}
3611
+			// now let's merge these arguments but override with what was specifically sent in to the
3612
+			// redirect.
3613
+			$query_args = array_merge($args_to_merge, $query_args);
3614
+		}
3615
+		$this->_process_notices($query_args);
3616
+		// generate redirect url
3617
+		// if redirecting to anything other than the main page, add a nonce
3618
+		if (isset($query_args['action'])) {
3619
+			// manually generate wp_nonce and merge that with the query vars
3620
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3621
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
+		}
3623
+		// we're adding some hooks and filters in here for processing any things just before redirects
3624
+		// (example: an admin page has done an insert or update and we want to run something after that).
3625
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
+		$redirect_url = apply_filters(
3627
+			'FHEE_redirect_' . $classname . $this->_req_action,
3628
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3629
+			$query_args
3630
+		);
3631
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
+		if ($this->request->isAjax()) {
3633
+			$default_data                    = [
3634
+				'close'        => true,
3635
+				'redirect_url' => $redirect_url,
3636
+				'where'        => 'main',
3637
+				'what'         => 'append',
3638
+			];
3639
+			$this->_template_args['success'] = $success;
3640
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
+				$default_data,
3642
+				$this->_template_args['data']
3643
+			) : $default_data;
3644
+			$this->_return_json();
3645
+		}
3646
+		wp_safe_redirect($redirect_url);
3647
+		exit();
3648
+	}
3649
+
3650
+
3651
+	/**
3652
+	 * process any notices before redirecting (or returning ajax request)
3653
+	 * This method sets the $this->_template_args['notices'] attribute;
3654
+	 *
3655
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
+	 *                                  page_routes haven't been defined yet.
3658
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
+	 *                                  still save a transient for the notice.
3660
+	 * @return void
3661
+	 * @throws EE_Error
3662
+	 */
3663
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
+	{
3665
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
+		if ($this->request->isAjax()) {
3667
+			$notices = EE_Error::get_notices(false);
3668
+			if (empty($this->_template_args['success'])) {
3669
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
+			}
3671
+			if (empty($this->_template_args['errors'])) {
3672
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
+			}
3674
+			if (empty($this->_template_args['attention'])) {
3675
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
+			}
3677
+		}
3678
+		$this->_template_args['notices'] = EE_Error::get_notices();
3679
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
+		if (! $this->request->isAjax() || $sticky_notices) {
3681
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
+			$this->_add_transient(
3683
+				$route,
3684
+				$this->_template_args['notices'],
3685
+				true,
3686
+				$skip_route_verify
3687
+			);
3688
+		}
3689
+	}
3690
+
3691
+
3692
+	/**
3693
+	 * get_action_link_or_button
3694
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
+	 *
3696
+	 * @param string $action        use this to indicate which action the url is generated with.
3697
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
+	 *                              property.
3699
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
+	 * @param string $base_url      If this is not provided
3702
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3703
+	 *                              Otherwise this value will be used.
3704
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
+	 * @return string
3706
+	 * @throws InvalidArgumentException
3707
+	 * @throws InvalidInterfaceException
3708
+	 * @throws InvalidDataTypeException
3709
+	 * @throws EE_Error
3710
+	 */
3711
+	public function get_action_link_or_button(
3712
+		$action,
3713
+		$type = 'add',
3714
+		$extra_request = [],
3715
+		$class = 'button-primary',
3716
+		$base_url = '',
3717
+		$exclude_nonce = false
3718
+	) {
3719
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
+			throw new EE_Error(
3722
+				sprintf(
3723
+					esc_html__(
3724
+						'There is no page route for given action for the button.  This action was given: %s',
3725
+						'event_espresso'
3726
+					),
3727
+					$action
3728
+				)
3729
+			);
3730
+		}
3731
+		if (! isset($this->_labels['buttons'][ $type ])) {
3732
+			throw new EE_Error(
3733
+				sprintf(
3734
+					esc_html__(
3735
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
+						'event_espresso'
3737
+					),
3738
+					$type
3739
+				)
3740
+			);
3741
+		}
3742
+		// finally check user access for this button.
3743
+		$has_access = $this->check_user_access($action, true);
3744
+		if (! $has_access) {
3745
+			return '';
3746
+		}
3747
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
+		$query_args = [
3749
+			'action' => $action,
3750
+		];
3751
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
+		if (! empty($extra_request)) {
3753
+			$query_args = array_merge($extra_request, $query_args);
3754
+		}
3755
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
+	}
3758
+
3759
+
3760
+	/**
3761
+	 * _per_page_screen_option
3762
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
+	 *
3764
+	 * @return void
3765
+	 * @throws InvalidArgumentException
3766
+	 * @throws InvalidInterfaceException
3767
+	 * @throws InvalidDataTypeException
3768
+	 */
3769
+	protected function _per_page_screen_option()
3770
+	{
3771
+		$option = 'per_page';
3772
+		$args   = [
3773
+			'label'   => apply_filters(
3774
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
+				$this->_admin_page_title,
3776
+				$this
3777
+			),
3778
+			'default' => (int) apply_filters(
3779
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
+				20
3781
+			),
3782
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
+		];
3784
+		// ONLY add the screen option if the user has access to it.
3785
+		if ($this->check_user_access($this->_current_view, true)) {
3786
+			add_screen_option($option, $args);
3787
+		}
3788
+	}
3789
+
3790
+
3791
+	/**
3792
+	 * set_per_page_screen_option
3793
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
+	 * admin_menu.
3796
+	 *
3797
+	 * @return void
3798
+	 */
3799
+	private function _set_per_page_screen_options()
3800
+	{
3801
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
+			if (! $user = wp_get_current_user()) {
3804
+				return;
3805
+			}
3806
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
+			if (! $option) {
3808
+				return;
3809
+			}
3810
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
+			$map_option = $option;
3812
+			$option     = str_replace('-', '_', $option);
3813
+			switch ($map_option) {
3814
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
+					$max_value = apply_filters(
3816
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
+						999,
3818
+						$this->_current_page,
3819
+						$this->_current_view
3820
+					);
3821
+					if ($value < 1) {
3822
+						return;
3823
+					}
3824
+					$value = min($value, $max_value);
3825
+					break;
3826
+				default:
3827
+					$value = apply_filters(
3828
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
+						false,
3830
+						$option,
3831
+						$value
3832
+					);
3833
+					if (false === $value) {
3834
+						return;
3835
+					}
3836
+					break;
3837
+			}
3838
+			update_user_meta($user->ID, $option, $value);
3839
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
+			exit;
3841
+		}
3842
+	}
3843
+
3844
+
3845
+	/**
3846
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
+	 *
3848
+	 * @param array $data array that will be assigned to template args.
3849
+	 */
3850
+	public function set_template_args($data)
3851
+	{
3852
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3853
+	}
3854
+
3855
+
3856
+	/**
3857
+	 * This makes available the WP transient system for temporarily moving data between routes
3858
+	 *
3859
+	 * @param string $route             the route that should receive the transient
3860
+	 * @param array  $data              the data that gets sent
3861
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
+	 *                                  normal route transient.
3863
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
+	 *                                  when we are adding a transient before page_routes have been defined.
3865
+	 * @return void
3866
+	 * @throws EE_Error
3867
+	 */
3868
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
+	{
3870
+		$user_id = get_current_user_id();
3871
+		if (! $skip_route_verify) {
3872
+			$this->_verify_route($route);
3873
+		}
3874
+		// now let's set the string for what kind of transient we're setting
3875
+		$transient = $notices
3876
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
+			: 'rte_tx_' . $route . '_' . $user_id;
3878
+		$data      = $notices ? ['notices' => $data] : $data;
3879
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3880
+		$existing = is_multisite() && is_network_admin()
3881
+			? get_site_transient($transient)
3882
+			: get_transient($transient);
3883
+		if ($existing) {
3884
+			$data = array_merge((array) $data, (array) $existing);
3885
+		}
3886
+		if (is_multisite() && is_network_admin()) {
3887
+			set_site_transient($transient, $data, 8);
3888
+		} else {
3889
+			set_transient($transient, $data, 8);
3890
+		}
3891
+	}
3892
+
3893
+
3894
+	/**
3895
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3896
+	 *
3897
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
+	 * @param string $route
3899
+	 * @return mixed data
3900
+	 */
3901
+	protected function _get_transient($notices = false, $route = '')
3902
+	{
3903
+		$user_id   = get_current_user_id();
3904
+		$route     = ! $route ? $this->_req_action : $route;
3905
+		$transient = $notices
3906
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
+			: 'rte_tx_' . $route . '_' . $user_id;
3908
+		$data      = is_multisite() && is_network_admin()
3909
+			? get_site_transient($transient)
3910
+			: get_transient($transient);
3911
+		// delete transient after retrieval (just in case it hasn't expired);
3912
+		if (is_multisite() && is_network_admin()) {
3913
+			delete_site_transient($transient);
3914
+		} else {
3915
+			delete_transient($transient);
3916
+		}
3917
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
+	 * default route callback on the EE_Admin page you want it run.)
3925
+	 *
3926
+	 * @return void
3927
+	 */
3928
+	protected function _transient_garbage_collection()
3929
+	{
3930
+		global $wpdb;
3931
+		// retrieve all existing transients
3932
+		$query =
3933
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
+		if ($results = $wpdb->get_results($query)) {
3935
+			foreach ($results as $result) {
3936
+				$transient = str_replace('_transient_', '', $result->option_name);
3937
+				get_transient($transient);
3938
+				if (is_multisite() && is_network_admin()) {
3939
+					get_site_transient($transient);
3940
+				}
3941
+			}
3942
+		}
3943
+	}
3944
+
3945
+
3946
+	/**
3947
+	 * get_view
3948
+	 *
3949
+	 * @return string content of _view property
3950
+	 */
3951
+	public function get_view()
3952
+	{
3953
+		return $this->_view;
3954
+	}
3955
+
3956
+
3957
+	/**
3958
+	 * getter for the protected $_views property
3959
+	 *
3960
+	 * @return array
3961
+	 */
3962
+	public function get_views()
3963
+	{
3964
+		return $this->_views;
3965
+	}
3966
+
3967
+
3968
+	/**
3969
+	 * get_current_page
3970
+	 *
3971
+	 * @return string _current_page property value
3972
+	 */
3973
+	public function get_current_page()
3974
+	{
3975
+		return $this->_current_page;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * get_current_view
3981
+	 *
3982
+	 * @return string _current_view property value
3983
+	 */
3984
+	public function get_current_view()
3985
+	{
3986
+		return $this->_current_view;
3987
+	}
3988
+
3989
+
3990
+	/**
3991
+	 * get_current_screen
3992
+	 *
3993
+	 * @return object The current WP_Screen object
3994
+	 */
3995
+	public function get_current_screen()
3996
+	{
3997
+		return $this->_current_screen;
3998
+	}
3999
+
4000
+
4001
+	/**
4002
+	 * get_current_page_view_url
4003
+	 *
4004
+	 * @return string This returns the url for the current_page_view.
4005
+	 */
4006
+	public function get_current_page_view_url()
4007
+	{
4008
+		return $this->_current_page_view_url;
4009
+	}
4010
+
4011
+
4012
+	/**
4013
+	 * just returns the Request
4014
+	 *
4015
+	 * @return RequestInterface
4016
+	 */
4017
+	public function get_request()
4018
+	{
4019
+		return $this->request;
4020
+	}
4021
+
4022
+
4023
+	/**
4024
+	 * just returns the _req_data property
4025
+	 *
4026
+	 * @return array
4027
+	 */
4028
+	public function get_request_data()
4029
+	{
4030
+		return $this->request->requestParams();
4031
+	}
4032
+
4033
+
4034
+	/**
4035
+	 * returns the _req_data protected property
4036
+	 *
4037
+	 * @return string
4038
+	 */
4039
+	public function get_req_action()
4040
+	{
4041
+		return $this->_req_action;
4042
+	}
4043
+
4044
+
4045
+	/**
4046
+	 * @return bool  value of $_is_caf property
4047
+	 */
4048
+	public function is_caf()
4049
+	{
4050
+		return $this->_is_caf;
4051
+	}
4052
+
4053
+
4054
+	/**
4055
+	 * @return mixed
4056
+	 */
4057
+	public function default_espresso_metaboxes()
4058
+	{
4059
+		return $this->_default_espresso_metaboxes;
4060
+	}
4061
+
4062
+
4063
+	/**
4064
+	 * @return mixed
4065
+	 */
4066
+	public function admin_base_url()
4067
+	{
4068
+		return $this->_admin_base_url;
4069
+	}
4070
+
4071
+
4072
+	/**
4073
+	 * @return mixed
4074
+	 */
4075
+	public function wp_page_slug()
4076
+	{
4077
+		return $this->_wp_page_slug;
4078
+	}
4079
+
4080
+
4081
+	/**
4082
+	 * updates  espresso configuration settings
4083
+	 *
4084
+	 * @param string                   $tab
4085
+	 * @param EE_Config_Base|EE_Config $config
4086
+	 * @param string                   $file file where error occurred
4087
+	 * @param string                   $func function  where error occurred
4088
+	 * @param string                   $line line no where error occurred
4089
+	 * @return boolean
4090
+	 */
4091
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
+	{
4093
+		// remove any options that are NOT going to be saved with the config settings.
4094
+		if (isset($config->core->ee_ueip_optin)) {
4095
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4096
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
+			update_option('ee_ueip_has_notified', true);
4098
+		}
4099
+		// and save it (note we're also doing the network save here)
4100
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
+		if ($config_saved && $net_saved) {
4103
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
+			return true;
4105
+		}
4106
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
+		return false;
4108
+	}
4109
+
4110
+
4111
+	/**
4112
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
+	 *
4114
+	 * @return array
4115
+	 */
4116
+	public function get_yes_no_values()
4117
+	{
4118
+		return $this->_yes_no_values;
4119
+	}
4120
+
4121
+
4122
+	protected function _get_dir()
4123
+	{
4124
+		$reflector = new ReflectionClass(get_class($this));
4125
+		return dirname($reflector->getFileName());
4126
+	}
4127
+
4128
+
4129
+	/**
4130
+	 * A helper for getting a "next link".
4131
+	 *
4132
+	 * @param string $url   The url to link to
4133
+	 * @param string $class The class to use.
4134
+	 * @return string
4135
+	 */
4136
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
+	{
4138
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
+	}
4140
+
4141
+
4142
+	/**
4143
+	 * A helper for getting a "previous link".
4144
+	 *
4145
+	 * @param string $url   The url to link to
4146
+	 * @param string $class The class to use.
4147
+	 * @return string
4148
+	 */
4149
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
+	{
4151
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
+	}
4153
+
4154
+
4155
+
4156
+
4157
+
4158
+
4159
+
4160
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
+
4162
+
4163
+	/**
4164
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4166
+	 * _req_data array.
4167
+	 *
4168
+	 * @return bool success/fail
4169
+	 * @throws EE_Error
4170
+	 * @throws InvalidArgumentException
4171
+	 * @throws ReflectionException
4172
+	 * @throws InvalidDataTypeException
4173
+	 * @throws InvalidInterfaceException
4174
+	 */
4175
+	protected function _process_resend_registration()
4176
+	{
4177
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
+		do_action(
4179
+			'AHEE__EE_Admin_Page___process_resend_registration',
4180
+			$this->_template_args['success'],
4181
+			$this->request->requestParams()
4182
+		);
4183
+		return $this->_template_args['success'];
4184
+	}
4185
+
4186
+
4187
+	/**
4188
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4189
+	 *
4190
+	 * @param EE_Payment $payment
4191
+	 * @return bool success/fail
4192
+	 */
4193
+	protected function _process_payment_notification(EE_Payment $payment)
4194
+	{
4195
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
+		$this->_template_args['success'] = apply_filters(
4198
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
+			false,
4200
+			$payment
4201
+		);
4202
+		return $this->_template_args['success'];
4203
+	}
4204 4204
 }
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 2 patches
Indentation   +1334 added lines, -1334 removed lines patch added patch discarded remove patch
@@ -16,1347 +16,1347 @@
 block discarded – undo
16 16
 class EED_Messages extends EED_Module
17 17
 {
18 18
 
19
-    /**
20
-     * This holds the EE_messages controller
21
-     *
22
-     * @deprecated 4.9.0
23
-     * @var EE_messages $_EEMSG
24
-     */
25
-    protected static $_EEMSG;
26
-
27
-    /**
28
-     * @type EE_Message_Resource_Manager $_message_resource_manager
29
-     */
30
-    protected static $_message_resource_manager;
31
-
32
-    /**
33
-     * This holds the EE_Messages_Processor business class.
34
-     *
35
-     * @type EE_Messages_Processor
36
-     */
37
-    protected static $_MSG_PROCESSOR;
38
-
39
-    /**
40
-     * holds all the paths for various messages components.
41
-     * Utilized by autoloader registry
42
-     *
43
-     * @var array
44
-     */
45
-    protected static $_MSG_PATHS;
46
-
47
-
48
-    /**
49
-     * This will hold an array of messages template packs that are registered in the messages system.
50
-     * Format is:
51
-     * array(
52
-     *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
53
-     * )
54
-     *
55
-     * @var EE_Messages_Template_Pack[]
56
-     */
57
-    protected static $_TMP_PACKS = array();
58
-
59
-
60
-    /**
61
-     * @return EED_Messages|EED_Module
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public static function instance()
66
-    {
67
-        return parent::get_instance(__CLASS__);
68
-    }
69
-
70
-
71
-    /**
72
-     *  set_hooks - for hooking into EE Core, other modules, etc
73
-     *
74
-     * @since 4.5.0
75
-     * @return    void
76
-     */
77
-    public static function set_hooks()
78
-    {
79
-        // actions
80
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
81
-        add_action(
82
-            'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
83
-            array('EED_Messages', 'maybe_registration'),
84
-            10,
85
-            2
86
-        );
87
-        // filters
88
-        add_filter(
89
-            'FHEE__EE_Registration__receipt_url__receipt_url',
90
-            array('EED_Messages', 'registration_message_trigger_url'),
91
-            10,
92
-            4
93
-        );
94
-        add_filter(
95
-            'FHEE__EE_Registration__invoice_url__invoice_url',
96
-            array('EED_Messages', 'registration_message_trigger_url'),
97
-            10,
98
-            4
99
-        );
100
-        // register routes
101
-        self::_register_routes();
102
-    }
103
-
104
-    /**
105
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
106
-     *
107
-     * @access    public
108
-     * @return    void
109
-     */
110
-    public static function set_hooks_admin()
111
-    {
112
-        // actions
113
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
114
-        add_action(
115
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
116
-            array('EED_Messages', 'payment_reminder'),
117
-            10
118
-        );
119
-        add_action(
120
-            'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
121
-            array('EED_Messages', 'maybe_registration'),
122
-            10,
123
-            3
124
-        );
125
-        add_action(
126
-            'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
127
-            array('EED_Messages', 'send_newsletter_message'),
128
-            10,
129
-            2
130
-        );
131
-        add_action(
132
-            'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
133
-            array('EED_Messages', 'cancelled_registration'),
134
-            10
135
-        );
136
-        add_action(
137
-            'AHEE__EE_Admin_Page___process_admin_payment_notification',
138
-            array('EED_Messages', 'process_admin_payment'),
139
-            10,
140
-            1
141
-        );
142
-        // filters
143
-        add_filter(
144
-            'FHEE__EE_Admin_Page___process_resend_registration__success',
145
-            array('EED_Messages', 'process_resend'),
146
-            10,
147
-            2
148
-        );
149
-        add_filter(
150
-            'FHEE__EE_Registration__receipt_url__receipt_url',
151
-            array('EED_Messages', 'registration_message_trigger_url'),
152
-            10,
153
-            4
154
-        );
155
-        add_filter(
156
-            'FHEE__EE_Registration__invoice_url__invoice_url',
157
-            array('EED_Messages', 'registration_message_trigger_url'),
158
-            10,
159
-            4
160
-        );
161
-    }
162
-
163
-
164
-    /**
165
-     * All the message triggers done by route go in here.
166
-     *
167
-     * @since 4.5.0
168
-     * @return void
169
-     */
170
-    protected static function _register_routes()
171
-    {
172
-        EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
173
-        EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
174
-        EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
175
-        EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
176
-        do_action('AHEE__EED_Messages___register_routes');
177
-    }
178
-
179
-
180
-    /**
181
-     * This is called when a browser display trigger is executed.
182
-     * The browser display trigger is typically used when a already generated message is displayed directly in the
183
-     * browser.
184
-     *
185
-     * @since 4.9.0
186
-     * @param WP $WP
187
-     * @throws EE_Error
188
-     * @throws InvalidArgumentException
189
-     * @throws ReflectionException
190
-     * @throws InvalidDataTypeException
191
-     * @throws InvalidInterfaceException
192
-     */
193
-    public function browser_trigger($WP)
194
-    {
195
-        // ensure controller is loaded
196
-        self::_load_controller();
197
-        $token = self::getRequest()->getRequestParam('token');
198
-        try {
199
-            $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
200
-            self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
201
-        } catch (EE_Error $e) {
202
-            $error_msg = esc_html__(
203
-                'Please note that a system message failed to send due to a technical issue.',
204
-                'event_espresso'
205
-            );
206
-            // add specific message for developers if WP_DEBUG in on
207
-            $error_msg .= '||' . $e->getMessage();
208
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
209
-        }
210
-    }
211
-
212
-
213
-    /**
214
-     * This is called when a browser error trigger is executed.
215
-     * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
216
-     * message and display it.
217
-     *
218
-     * @since 4.9.0
219
-     * @param $WP
220
-     * @throws EE_Error
221
-     * @throws InvalidArgumentException
222
-     * @throws InvalidDataTypeException
223
-     * @throws InvalidInterfaceException
224
-     */
225
-    public function browser_error_trigger($WP)
226
-    {
227
-        $token = self::getRequest()->getRequestParam('token');
228
-        if ($token) {
229
-            $message = EEM_Message::instance()->get_one_by_token($token);
230
-            if ($message instanceof EE_Message) {
231
-                header('HTTP/1.1 200 OK');
232
-                $error_msg = nl2br($message->error_message());
233
-                ?>
19
+	/**
20
+	 * This holds the EE_messages controller
21
+	 *
22
+	 * @deprecated 4.9.0
23
+	 * @var EE_messages $_EEMSG
24
+	 */
25
+	protected static $_EEMSG;
26
+
27
+	/**
28
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
29
+	 */
30
+	protected static $_message_resource_manager;
31
+
32
+	/**
33
+	 * This holds the EE_Messages_Processor business class.
34
+	 *
35
+	 * @type EE_Messages_Processor
36
+	 */
37
+	protected static $_MSG_PROCESSOR;
38
+
39
+	/**
40
+	 * holds all the paths for various messages components.
41
+	 * Utilized by autoloader registry
42
+	 *
43
+	 * @var array
44
+	 */
45
+	protected static $_MSG_PATHS;
46
+
47
+
48
+	/**
49
+	 * This will hold an array of messages template packs that are registered in the messages system.
50
+	 * Format is:
51
+	 * array(
52
+	 *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
53
+	 * )
54
+	 *
55
+	 * @var EE_Messages_Template_Pack[]
56
+	 */
57
+	protected static $_TMP_PACKS = array();
58
+
59
+
60
+	/**
61
+	 * @return EED_Messages|EED_Module
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public static function instance()
66
+	{
67
+		return parent::get_instance(__CLASS__);
68
+	}
69
+
70
+
71
+	/**
72
+	 *  set_hooks - for hooking into EE Core, other modules, etc
73
+	 *
74
+	 * @since 4.5.0
75
+	 * @return    void
76
+	 */
77
+	public static function set_hooks()
78
+	{
79
+		// actions
80
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
81
+		add_action(
82
+			'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
83
+			array('EED_Messages', 'maybe_registration'),
84
+			10,
85
+			2
86
+		);
87
+		// filters
88
+		add_filter(
89
+			'FHEE__EE_Registration__receipt_url__receipt_url',
90
+			array('EED_Messages', 'registration_message_trigger_url'),
91
+			10,
92
+			4
93
+		);
94
+		add_filter(
95
+			'FHEE__EE_Registration__invoice_url__invoice_url',
96
+			array('EED_Messages', 'registration_message_trigger_url'),
97
+			10,
98
+			4
99
+		);
100
+		// register routes
101
+		self::_register_routes();
102
+	}
103
+
104
+	/**
105
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
106
+	 *
107
+	 * @access    public
108
+	 * @return    void
109
+	 */
110
+	public static function set_hooks_admin()
111
+	{
112
+		// actions
113
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
114
+		add_action(
115
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
116
+			array('EED_Messages', 'payment_reminder'),
117
+			10
118
+		);
119
+		add_action(
120
+			'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
121
+			array('EED_Messages', 'maybe_registration'),
122
+			10,
123
+			3
124
+		);
125
+		add_action(
126
+			'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
127
+			array('EED_Messages', 'send_newsletter_message'),
128
+			10,
129
+			2
130
+		);
131
+		add_action(
132
+			'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
133
+			array('EED_Messages', 'cancelled_registration'),
134
+			10
135
+		);
136
+		add_action(
137
+			'AHEE__EE_Admin_Page___process_admin_payment_notification',
138
+			array('EED_Messages', 'process_admin_payment'),
139
+			10,
140
+			1
141
+		);
142
+		// filters
143
+		add_filter(
144
+			'FHEE__EE_Admin_Page___process_resend_registration__success',
145
+			array('EED_Messages', 'process_resend'),
146
+			10,
147
+			2
148
+		);
149
+		add_filter(
150
+			'FHEE__EE_Registration__receipt_url__receipt_url',
151
+			array('EED_Messages', 'registration_message_trigger_url'),
152
+			10,
153
+			4
154
+		);
155
+		add_filter(
156
+			'FHEE__EE_Registration__invoice_url__invoice_url',
157
+			array('EED_Messages', 'registration_message_trigger_url'),
158
+			10,
159
+			4
160
+		);
161
+	}
162
+
163
+
164
+	/**
165
+	 * All the message triggers done by route go in here.
166
+	 *
167
+	 * @since 4.5.0
168
+	 * @return void
169
+	 */
170
+	protected static function _register_routes()
171
+	{
172
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
173
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
174
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
175
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
176
+		do_action('AHEE__EED_Messages___register_routes');
177
+	}
178
+
179
+
180
+	/**
181
+	 * This is called when a browser display trigger is executed.
182
+	 * The browser display trigger is typically used when a already generated message is displayed directly in the
183
+	 * browser.
184
+	 *
185
+	 * @since 4.9.0
186
+	 * @param WP $WP
187
+	 * @throws EE_Error
188
+	 * @throws InvalidArgumentException
189
+	 * @throws ReflectionException
190
+	 * @throws InvalidDataTypeException
191
+	 * @throws InvalidInterfaceException
192
+	 */
193
+	public function browser_trigger($WP)
194
+	{
195
+		// ensure controller is loaded
196
+		self::_load_controller();
197
+		$token = self::getRequest()->getRequestParam('token');
198
+		try {
199
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
200
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
201
+		} catch (EE_Error $e) {
202
+			$error_msg = esc_html__(
203
+				'Please note that a system message failed to send due to a technical issue.',
204
+				'event_espresso'
205
+			);
206
+			// add specific message for developers if WP_DEBUG in on
207
+			$error_msg .= '||' . $e->getMessage();
208
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
209
+		}
210
+	}
211
+
212
+
213
+	/**
214
+	 * This is called when a browser error trigger is executed.
215
+	 * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
216
+	 * message and display it.
217
+	 *
218
+	 * @since 4.9.0
219
+	 * @param $WP
220
+	 * @throws EE_Error
221
+	 * @throws InvalidArgumentException
222
+	 * @throws InvalidDataTypeException
223
+	 * @throws InvalidInterfaceException
224
+	 */
225
+	public function browser_error_trigger($WP)
226
+	{
227
+		$token = self::getRequest()->getRequestParam('token');
228
+		if ($token) {
229
+			$message = EEM_Message::instance()->get_one_by_token($token);
230
+			if ($message instanceof EE_Message) {
231
+				header('HTTP/1.1 200 OK');
232
+				$error_msg = nl2br($message->error_message());
233
+				?>
234 234
                 <!DOCTYPE html>
235 235
                 <html>
236 236
                 <head></head>
237 237
                 <body>
238 238
                 <?php echo empty($error_msg)
239
-                    ? esc_html__(
240
-                        'Unfortunately, we were unable to capture the error message for this message.',
241
-                        'event_espresso'
242
-                    )
243
-                    : wp_kses(
244
-                        $error_msg,
245
-                        array(
246
-                            'a'      => array(
247
-                                'href'  => array(),
248
-                                'title' => array(),
249
-                            ),
250
-                            'span'   => array(),
251
-                            'div'    => array(),
252
-                            'p'      => array(),
253
-                            'strong' => array(),
254
-                            'em'     => array(),
255
-                            'br'     => array(),
256
-                        )
257
-                    ); ?>
239
+					? esc_html__(
240
+						'Unfortunately, we were unable to capture the error message for this message.',
241
+						'event_espresso'
242
+					)
243
+					: wp_kses(
244
+						$error_msg,
245
+						array(
246
+							'a'      => array(
247
+								'href'  => array(),
248
+								'title' => array(),
249
+							),
250
+							'span'   => array(),
251
+							'div'    => array(),
252
+							'p'      => array(),
253
+							'strong' => array(),
254
+							'em'     => array(),
255
+							'br'     => array(),
256
+						)
257
+					); ?>
258 258
                 </body>
259 259
                 </html>
260 260
                 <?php
261
-                exit;
262
-            }
263
-        }
264
-    }
265
-
266
-
267
-    /**
268
-     *  This runs when the msg_url_trigger route has initiated.
269
-     *
270
-     * @since 4.5.0
271
-     * @param WP $WP
272
-     * @throws EE_Error
273
-     * @throws InvalidArgumentException
274
-     * @throws ReflectionException
275
-     * @throws InvalidDataTypeException
276
-     * @throws InvalidInterfaceException
277
-     */
278
-    public function run($WP)
279
-    {
280
-        // ensure controller is loaded
281
-        self::_load_controller();
282
-        // attempt to process message
283
-        try {
284
-            /** @type EE_Message_To_Generate_From_Request $message_to_generate */
285
-            $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
286
-            self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
287
-        } catch (EE_Error $e) {
288
-            $error_msg = esc_html__(
289
-                'Please note that a system message failed to send due to a technical issue.',
290
-                'event_espresso'
291
-            );
292
-            // add specific message for developers if WP_DEBUG in on
293
-            $error_msg .= '||' . $e->getMessage();
294
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
295
-        }
296
-    }
297
-
298
-
299
-    /**
300
-     * This is triggered by the 'msg_cron_trigger' route.
301
-     *
302
-     * @param WP $WP
303
-     */
304
-    public function execute_batch_request($WP)
305
-    {
306
-        $this->run_cron();
307
-        header('HTTP/1.1 200 OK');
308
-        exit();
309
-    }
310
-
311
-
312
-    /**
313
-     * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
314
-     * request.
315
-     */
316
-    public function run_cron()
317
-    {
318
-        self::_load_controller();
319
-        $request = self::getRequest();
320
-        // get required vars
321
-        $cron_type = $request->getRequestParam('type');
322
-        $transient_key = $request->getRequestParam('key');
323
-
324
-        // now let's verify transient, if not valid exit immediately
325
-        if (! get_transient($transient_key)) {
326
-            /**
327
-             * trigger error so this gets in the error logs.  This is important because it happens on a non-user
328
-             * request.
329
-             */
330
-            trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
331
-        }
332
-
333
-        // if made it here, lets' delete the transient to keep the db clean
334
-        delete_transient($transient_key);
335
-
336
-        if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
337
-            $method = 'batch_' . $cron_type . '_from_queue';
338
-            if (method_exists(self::$_MSG_PROCESSOR, $method)) {
339
-                self::$_MSG_PROCESSOR->$method();
340
-            } else {
341
-                // no matching task
342
-                /**
343
-                 * trigger error so this gets in the error logs.  This is important because it happens on a non user
344
-                 * request.
345
-                 */
346
-                trigger_error(
347
-                    esc_attr(
348
-                        sprintf(
349
-                            esc_html__('There is no task corresponding to this route %s', 'event_espresso'),
350
-                            $cron_type
351
-                        )
352
-                    )
353
-                );
354
-            }
355
-        }
356
-
357
-        do_action('FHEE__EED_Messages__run_cron__end');
358
-    }
359
-
360
-
361
-    /**
362
-     * This is used to retrieve the template pack for the given name.
363
-     * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
364
-     * the default template pack is returned.
365
-     *
366
-     * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
367
-     * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
368
-     *                                   in generating the Pack class name).
369
-     * @return EE_Messages_Template_Pack
370
-     * @throws EE_Error
371
-     * @throws InvalidArgumentException
372
-     * @throws ReflectionException
373
-     * @throws InvalidDataTypeException
374
-     * @throws InvalidInterfaceException
375
-     */
376
-    public static function get_template_pack($template_pack_name)
377
-    {
378
-        EE_Registry::instance()->load_helper('MSG_Template');
379
-        return EEH_MSG_Template::get_template_pack($template_pack_name);
380
-    }
381
-
382
-
383
-    /**
384
-     * Retrieves an array of all template packs.
385
-     * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
386
-     *
387
-     * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
388
-     * @return EE_Messages_Template_Pack[]
389
-     * @throws EE_Error
390
-     * @throws InvalidArgumentException
391
-     * @throws ReflectionException
392
-     * @throws InvalidDataTypeException
393
-     * @throws InvalidInterfaceException
394
-     */
395
-    public static function get_template_packs()
396
-    {
397
-        EE_Registry::instance()->load_helper('MSG_Template');
398
-
399
-        // for backward compat, let's make sure this returns in the same format as originally.
400
-        $template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
401
-        $template_pack_collection->rewind();
402
-        $template_packs = array();
403
-        while ($template_pack_collection->valid()) {
404
-            $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
405
-            $template_pack_collection->next();
406
-        }
407
-        return $template_packs;
408
-    }
409
-
410
-
411
-    /**
412
-     * This simply makes sure the autoloaders are registered for the EE_messages system.
413
-     *
414
-     * @since 4.5.0
415
-     * @return void
416
-     * @throws EE_Error
417
-     */
418
-    public static function set_autoloaders()
419
-    {
420
-        if (empty(self::$_MSG_PATHS)) {
421
-            self::_set_messages_paths();
422
-            foreach (self::$_MSG_PATHS as $path) {
423
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
424
-            }
425
-            // add aliases
426
-            EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
427
-            EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
428
-        }
429
-    }
430
-
431
-
432
-    /**
433
-     * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
434
-     * for use by the Messages Autoloaders
435
-     *
436
-     * @since 4.5.0
437
-     * @return void.
438
-     */
439
-    protected static function _set_messages_paths()
440
-    {
441
-        $dir_ref = array(
442
-            'messages/message_type',
443
-            'messages/messenger',
444
-            'messages/defaults',
445
-            'messages/defaults/email',
446
-            'messages/data_class',
447
-            'messages/validators',
448
-            'messages/validators/email',
449
-            'messages/validators/html',
450
-            'shortcodes',
451
-        );
452
-        $paths = array();
453
-        foreach ($dir_ref as $index => $dir) {
454
-            $paths[ $index ] = EE_LIBRARIES . $dir;
455
-        }
456
-        self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
457
-    }
458
-
459
-
460
-    /**
461
-     * Takes care of loading dependencies
462
-     *
463
-     * @since 4.5.0
464
-     * @return void
465
-     * @throws EE_Error
466
-     * @throws InvalidArgumentException
467
-     * @throws ReflectionException
468
-     * @throws InvalidDataTypeException
469
-     * @throws InvalidInterfaceException
470
-     */
471
-    protected static function _load_controller()
472
-    {
473
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
474
-            EE_Registry::instance()->load_core('Request_Handler');
475
-            self::set_autoloaders();
476
-            self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
477
-            self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor');
478
-            self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
479
-        }
480
-    }
481
-
482
-
483
-    /**
484
-     * @param EE_Transaction $transaction
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws InvalidDataTypeException
488
-     * @throws InvalidInterfaceException
489
-     * @throws ReflectionException
490
-     */
491
-    public static function payment_reminder(EE_Transaction $transaction)
492
-    {
493
-        self::_load_controller();
494
-        $data = array($transaction, null);
495
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
496
-    }
497
-
498
-
499
-    /**
500
-     * Any messages triggers for after successful gateway payments should go in here.
501
-     *
502
-     * @param EE_Transaction  $transaction object
503
-     * @param EE_Payment|null $payment     object
504
-     * @return void
505
-     * @throws EE_Error
506
-     * @throws InvalidArgumentException
507
-     * @throws ReflectionException
508
-     * @throws InvalidDataTypeException
509
-     * @throws InvalidInterfaceException
510
-     */
511
-    public static function payment(EE_Transaction $transaction, EE_Payment $payment = null)
512
-    {
513
-        // if there's no payment object, then we cannot do a payment type message!
514
-        if (! $payment instanceof EE_Payment) {
515
-            return;
516
-        }
517
-        self::_load_controller();
518
-        $data = array($transaction, $payment);
519
-        EE_Registry::instance()->load_helper('MSG_Template');
520
-        $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
521
-        // if payment amount is less than 0 then switch to payment_refund message type.
522
-        $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
523
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
524
-    }
525
-
526
-
527
-    /**
528
-     * @param EE_Transaction $transaction
529
-     * @throws EE_Error
530
-     * @throws InvalidArgumentException
531
-     * @throws InvalidDataTypeException
532
-     * @throws InvalidInterfaceException
533
-     * @throws ReflectionException
534
-     */
535
-    public static function cancelled_registration(EE_Transaction $transaction)
536
-    {
537
-        self::_load_controller();
538
-        $data = array($transaction, null);
539
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
540
-    }
541
-
542
-
543
-    /**
544
-     * Trigger for Registration messages
545
-     * Note that what registration message type is sent depends on what the reg status is for the registrations on the
546
-     * incoming transaction.
547
-     *
548
-     * @param EE_Registration $registration
549
-     * @param array           $extra_details
550
-     * @return void
551
-     * @throws EE_Error
552
-     * @throws InvalidArgumentException
553
-     * @throws InvalidDataTypeException
554
-     * @throws InvalidInterfaceException
555
-     * @throws ReflectionException
556
-     * @throws EntityNotFoundException
557
-     */
558
-    public static function maybe_registration(EE_Registration $registration, $extra_details = array())
559
-    {
560
-
561
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
562
-            // no messages please
563
-            return;
564
-        }
565
-
566
-        // get all non-trashed registrations so we make sure we send messages for the right status.
567
-        $all_registrations = $registration->transaction()->registrations(
568
-            array(
569
-                array('REG_deleted' => false),
570
-                'order_by' => array(
571
-                    'Event.EVT_name'     => 'ASC',
572
-                    'Attendee.ATT_lname' => 'ASC',
573
-                    'Attendee.ATT_fname' => 'ASC',
574
-                ),
575
-            )
576
-        );
577
-        // cached array of statuses so we only trigger messages once per status.
578
-        $statuses_sent = array();
579
-        self::_load_controller();
580
-        $mtgs = array();
581
-
582
-        // loop through registrations and trigger messages once per status.
583
-        foreach ($all_registrations as $reg) {
584
-            // already triggered?
585
-            if (in_array($reg->status_ID(), $statuses_sent)) {
586
-                continue;
587
-            }
588
-
589
-            $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
590
-            $mtgs = array_merge(
591
-                $mtgs,
592
-                self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
593
-                    $message_type,
594
-                    array($registration->transaction(), null, $reg->status_ID())
595
-                )
596
-            );
597
-            $statuses_sent[] = $reg->status_ID();
598
-        }
599
-
600
-        if (count($statuses_sent) > 1) {
601
-            $mtgs = array_merge(
602
-                $mtgs,
603
-                self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
604
-                    'registration_summary',
605
-                    array($registration->transaction(), null)
606
-                )
607
-            );
608
-        }
609
-
610
-        // batch queue and initiate request
611
-        self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
612
-        self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
613
-    }
614
-
615
-
616
-    /**
617
-     * This is a helper method used to very whether a registration notification should be sent or
618
-     * not.  Prevents duplicate notifications going out for registration context notifications.
619
-     *
620
-     * @param EE_Registration $registration  [description]
621
-     * @param array           $extra_details [description]
622
-     * @return bool          true = send away, false = nope halt the presses.
623
-     */
624
-    protected static function _verify_registration_notification_send(
625
-        EE_Registration $registration,
626
-        $extra_details = array()
627
-    ) {
628
-        if (! $registration->is_primary_registrant()) {
629
-            return false;
630
-        }
631
-        $request = self::getRequest();
632
-        // first we check if we're in admin and not doing front ajax
633
-        if (
634
-            ($request->isAdmin() || $request->isAdminAjax())
635
-            && ! $request->isFrontAjax()
636
-        ) {
637
-            $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true);
638
-            // make sure appropriate admin params are set for sending messages
639
-            if (! $status_change['send_notifications']) {
640
-                // no messages sent please.
641
-                return false;
642
-            }
643
-        } else {
644
-            // frontend request (either regular or via AJAX)
645
-            // TXN is NOT finalized ?
646
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
647
-                return false;
648
-            }
649
-            // return visit but nothing changed ???
650
-            if (
651
-                isset($extra_details['revisit'], $extra_details['status_updates']) &&
652
-                $extra_details['revisit'] && ! $extra_details['status_updates']
653
-            ) {
654
-                return false;
655
-            }
656
-            // NOT sending messages && reg status is something other than "Not-Approved"
657
-            if (
658
-                ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
659
-                $registration->status_ID() !== EEM_Registration::status_id_not_approved
660
-            ) {
661
-                return false;
662
-            }
663
-        }
664
-        // release the kraken
665
-        return true;
666
-    }
667
-
668
-
669
-    /**
670
-     * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
671
-     * status id.
672
-     *
673
-     * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
674
-     *                    or EEH_MSG_Template::convert_reg_status_to_message_type
675
-     * @param string $reg_status
676
-     * @return array
677
-     * @throws EE_Error
678
-     * @throws InvalidArgumentException
679
-     * @throws ReflectionException
680
-     * @throws InvalidDataTypeException
681
-     * @throws InvalidInterfaceException
682
-     */
683
-    protected static function _get_reg_status_array($reg_status = '')
684
-    {
685
-        EE_Registry::instance()->load_helper('MSG_Template');
686
-        return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
687
-            ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
688
-            : EEH_MSG_Template::reg_status_to_message_type_array();
689
-    }
690
-
691
-
692
-    /**
693
-     * Simply returns the payment message type for the given payment status.
694
-     *
695
-     * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
696
-     *                   or EEH_MSG_Template::convert_payment_status_to_message_type
697
-     * @param string $payment_status The payment status being matched.
698
-     * @return bool|string The payment message type slug matching the status or false if no match.
699
-     * @throws EE_Error
700
-     * @throws InvalidArgumentException
701
-     * @throws ReflectionException
702
-     * @throws InvalidDataTypeException
703
-     * @throws InvalidInterfaceException
704
-     */
705
-    protected static function _get_payment_message_type($payment_status)
706
-    {
707
-        EE_Registry::instance()->load_helper('MSG_Template');
708
-        return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
709
-            ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
710
-            : false;
711
-    }
712
-
713
-
714
-    /**
715
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
716
-     *
717
-     * @access public
718
-     * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
719
-     * @return bool success/fail
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws InvalidDataTypeException
723
-     * @throws InvalidInterfaceException
724
-     * @throws ReflectionException
725
-     */
726
-    public static function process_resend(array $req_data = [])
727
-    {
728
-        self::_load_controller();
729
-        $request = self::getRequest();
730
-        // if $msgID in this request then skip to the new resend_message
731
-        if ($request->getRequestParam('MSG_ID')) {
732
-            return self::resend_message();
733
-        }
734
-
735
-        // make sure any incoming request data is set on the request so that it gets picked up later.
736
-        foreach ((array) $req_data as $request_key => $request_value) {
737
-            if (! $request->requestParamIsSet($request_key)) {
738
-                $request->setRequestParam($request_key, $request_value);
739
-            }
740
-        }
741
-
742
-        if (
743
-            ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()
744
-        ) {
745
-            return false;
746
-        }
747
-
748
-        try {
749
-            self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
750
-            self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
751
-        } catch (EE_Error $e) {
752
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
753
-            return false;
754
-        }
755
-        EE_Error::add_success(
756
-            esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso')
757
-        );
758
-        return true; // everything got queued.
759
-    }
760
-
761
-
762
-    /**
763
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
764
-     *
765
-     * @return bool
766
-     * @throws EE_Error
767
-     * @throws InvalidArgumentException
768
-     * @throws InvalidDataTypeException
769
-     * @throws InvalidInterfaceException
770
-     * @throws ReflectionException
771
-     */
772
-    public static function resend_message()
773
-    {
774
-        self::_load_controller();
775
-
776
-        $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int');
777
-        if (! $msgID) {
778
-            EE_Error::add_error(
779
-                esc_html__(
780
-                    'Something went wrong because there is no "MSG_ID" value in the request',
781
-                    'event_espresso'
782
-                ),
783
-                __FILE__,
784
-                __FUNCTION__,
785
-                __LINE__
786
-            );
787
-            return false;
788
-        }
789
-
790
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
791
-
792
-        // setup success message.
793
-        $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
794
-        EE_Error::add_success(
795
-            sprintf(
796
-                _n(
797
-                    'There was %d message queued for resending.',
798
-                    'There were %d messages queued for resending.',
799
-                    $count_ready_for_resend,
800
-                    'event_espresso'
801
-                ),
802
-                $count_ready_for_resend
803
-            )
804
-        );
805
-        return true;
806
-    }
807
-
808
-
809
-    /**
810
-     * Message triggers for manual payment applied by admin
811
-     *
812
-     * @param  EE_Payment $payment EE_payment object
813
-     * @return bool success/fail
814
-     * @throws EE_Error
815
-     * @throws InvalidArgumentException
816
-     * @throws ReflectionException
817
-     * @throws InvalidDataTypeException
818
-     * @throws InvalidInterfaceException
819
-     */
820
-    public static function process_admin_payment(EE_Payment $payment)
821
-    {
822
-        EE_Registry::instance()->load_helper('MSG_Template');
823
-        // we need to get the transaction object
824
-        $transaction = $payment->transaction();
825
-        if ($transaction instanceof EE_Transaction) {
826
-            $data = array($transaction, $payment);
827
-            $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
828
-
829
-            // if payment amount is less than 0 then switch to payment_refund message type.
830
-            $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
831
-
832
-            // if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
833
-            $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved
834
-                ? false : $message_type;
835
-
836
-            self::_load_controller();
837
-
838
-            self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
839
-
840
-            // get count of queued for generation
841
-            $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
842
-                array(
843
-                    EEM_Message::status_incomplete,
844
-                    EEM_Message::status_idle,
845
-                )
846
-            );
847
-
848
-            if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
849
-                add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
850
-                return true;
851
-            } else {
852
-                $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
853
-                    EEM_Message::instance()->stati_indicating_failed_sending()
854
-                );
855
-                /**
856
-                 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
857
-                 * IMMEDIATE generation.
858
-                 */
859
-                if ($count_failed > 0) {
860
-                    EE_Error::add_error(
861
-                        sprintf(
862
-                            _n(
863
-                                'The payment notification generation failed.',
864
-                                '%d payment notifications failed being sent.',
865
-                                $count_failed,
866
-                                'event_espresso'
867
-                            ),
868
-                            $count_failed
869
-                        ),
870
-                        __FILE__,
871
-                        __FUNCTION__,
872
-                        __LINE__
873
-                    );
874
-
875
-                    return false;
876
-                } else {
877
-                    add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
878
-                    return true;
879
-                }
880
-            }
881
-        } else {
882
-            EE_Error::add_error(
883
-                'Unable to generate the payment notification because the given value for the transaction is invalid.',
884
-                'event_espresso'
885
-            );
886
-            return false;
887
-        }
888
-    }
889
-
890
-
891
-    /**
892
-     * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
893
-     *
894
-     * @since   4.3.0
895
-     * @param  EE_Registration[] $registrations an array of EE_Registration objects
896
-     * @param  int               $grp_id        a specific message template group id.
897
-     * @return void
898
-     * @throws EE_Error
899
-     * @throws InvalidArgumentException
900
-     * @throws InvalidDataTypeException
901
-     * @throws InvalidInterfaceException
902
-     * @throws ReflectionException
903
-     */
904
-    public static function send_newsletter_message($registrations, $grp_id)
905
-    {
906
-        // make sure mtp is id and set it in the request later messages setup.
907
-        self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id);
908
-        self::_load_controller();
909
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
910
-    }
911
-
912
-
913
-    /**
914
-     * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
915
-     *
916
-     * @since   4.3.0
917
-     * @param    string          $registration_message_trigger_url
918
-     * @param    EE_Registration $registration
919
-     * @param string             $messenger
920
-     * @param string             $message_type
921
-     * @return string
922
-     * @throws EE_Error
923
-     * @throws InvalidArgumentException
924
-     * @throws InvalidDataTypeException
925
-     * @throws InvalidInterfaceException
926
-     */
927
-    public static function registration_message_trigger_url(
928
-        $registration_message_trigger_url,
929
-        EE_Registration $registration,
930
-        $messenger = 'html',
931
-        $message_type = 'invoice'
932
-    ) {
933
-        // whitelist $messenger
934
-        switch ($messenger) {
935
-            case 'pdf':
936
-                $sending_messenger = 'pdf';
937
-                $generating_messenger = 'html';
938
-                break;
939
-            case 'html':
940
-            default:
941
-                $sending_messenger = 'html';
942
-                $generating_messenger = 'html';
943
-                break;
944
-        }
945
-        // whitelist $message_type
946
-        switch ($message_type) {
947
-            case 'receipt':
948
-                $message_type = 'receipt';
949
-                break;
950
-            case 'invoice':
951
-            default:
952
-                $message_type = 'invoice';
953
-                break;
954
-        }
955
-        // verify that both the messenger AND the message type are active
956
-        if (
957
-            EEH_MSG_Template::is_messenger_active($sending_messenger)
958
-            && EEH_MSG_Template::is_mt_active($message_type)
959
-        ) {
960
-            // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
961
-            $template_query_params = array(
962
-                'MTP_is_active'    => true,
963
-                'MTP_messenger'    => $generating_messenger,
964
-                'MTP_message_type' => $message_type,
965
-                'Event.EVT_ID'     => $registration->event_ID(),
966
-            );
967
-            // get the message template group.
968
-            $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
969
-            // if we don't have an EE_Message_Template_Group then return
970
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
971
-                // remove EVT_ID from query params so that global templates get picked up
972
-                unset($template_query_params['Event.EVT_ID']);
973
-                // get global template as the fallback
974
-                $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
975
-            }
976
-            // if we don't have an EE_Message_Template_Group then return
977
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
978
-                return '';
979
-            }
980
-            // generate the URL
981
-            $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
982
-                $sending_messenger,
983
-                $generating_messenger,
984
-                'purchaser',
985
-                $message_type,
986
-                $registration,
987
-                $msg_template_group->ID(),
988
-                $registration->transaction_ID()
989
-            );
990
-        }
991
-        return $registration_message_trigger_url;
992
-    }
993
-
994
-
995
-    /**
996
-     * Use to generate and return a message preview!
997
-     *
998
-     * @param  string $type      This should correspond with a valid message type
999
-     * @param  string $context   This should correspond with a valid context for the message type
1000
-     * @param  string $messenger This should correspond with a valid messenger.
1001
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
1002
-     *                           preview
1003
-     * @return bool|string The body of the message or if send is requested, sends.
1004
-     * @throws EE_Error
1005
-     * @throws InvalidArgumentException
1006
-     * @throws InvalidDataTypeException
1007
-     * @throws InvalidInterfaceException
1008
-     * @throws ReflectionException
1009
-     */
1010
-    public static function preview_message($type, $context, $messenger, $send = false)
1011
-    {
1012
-        self::_load_controller();
1013
-        $mtg = new EE_Message_To_Generate(
1014
-            $messenger,
1015
-            $type,
1016
-            array(),
1017
-            $context,
1018
-            true
1019
-        );
1020
-        $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
1021
-        if ($generated_preview_queue instanceof EE_Messages_Queue) {
1022
-            // loop through all content for the preview and remove any persisted records.
1023
-            $content = '';
1024
-            foreach ($generated_preview_queue->get_message_repository() as $message) {
1025
-                $content = $message->content();
1026
-                if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
1027
-                    $message->delete();
1028
-                }
1029
-            }
1030
-            return $content;
1031
-        } else {
1032
-            return $generated_preview_queue;
1033
-        }
1034
-    }
1035
-
1036
-
1037
-    /**
1038
-     * This is a method that allows for sending a message using a messenger matching the string given and the provided
1039
-     * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
1040
-     * content found in the EE_Message objects in the queue.
1041
-     *
1042
-     * @since 4.9.0
1043
-     * @param string            $messenger            a string matching a valid active messenger in the system
1044
-     * @param string            $message_type         Although it seems contrary to the name of the method, a message
1045
-     *                                                type name is still required to send along the message type to the
1046
-     *                                                messenger because this is used for determining what specific
1047
-     *                                                variations might be loaded for the generated message.
1048
-     * @param EE_Messages_Queue $queue
1049
-     * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
1050
-     *                                                aggregate EE_Message object.
1051
-     * @return bool success or fail.
1052
-     * @throws EE_Error
1053
-     * @throws InvalidArgumentException
1054
-     * @throws ReflectionException
1055
-     * @throws InvalidDataTypeException
1056
-     * @throws InvalidInterfaceException
1057
-     */
1058
-    public static function send_message_with_messenger_only(
1059
-        $messenger,
1060
-        $message_type,
1061
-        EE_Messages_Queue $queue,
1062
-        $custom_subject = ''
1063
-    ) {
1064
-        self::_load_controller();
1065
-        /** @type EE_Message_To_Generate_From_Queue $message_to_generate */
1066
-        $message_to_generate = EE_Registry::instance()->load_lib(
1067
-            'Message_To_Generate_From_Queue',
1068
-            array(
1069
-                $messenger,
1070
-                $message_type,
1071
-                $queue,
1072
-                $custom_subject,
1073
-            )
1074
-        );
1075
-        return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1081
-     *
1082
-     * @since 4.9.0
1083
-     * @param array $message_ids An array of message ids
1084
-     * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1085
-     *                           messages.
1086
-     * @throws EE_Error
1087
-     * @throws InvalidArgumentException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws InvalidInterfaceException
1090
-     * @throws ReflectionException
1091
-     */
1092
-    public static function generate_now($message_ids)
1093
-    {
1094
-        self::_load_controller();
1095
-        $messages = EEM_Message::instance()->get_all(
1096
-            array(
1097
-                0 => array(
1098
-                    'MSG_ID' => array('IN', $message_ids),
1099
-                    'STS_ID' => EEM_Message::status_incomplete,
1100
-                ),
1101
-            )
1102
-        );
1103
-        $generated_queue = false;
1104
-        if ($messages) {
1105
-            $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1106
-        }
1107
-
1108
-        if (! $generated_queue instanceof EE_Messages_Queue) {
1109
-            EE_Error::add_error(
1110
-                esc_html__(
1111
-                    'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1112
-                    'event_espresso'
1113
-                ),
1114
-                __FILE__,
1115
-                __FUNCTION__,
1116
-                __LINE__
1117
-            );
1118
-        }
1119
-        return $generated_queue;
1120
-    }
1121
-
1122
-
1123
-    /**
1124
-     * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1125
-     * EEM_Message::status_idle
1126
-     *
1127
-     * @since 4.9.0
1128
-     * @param $message_ids
1129
-     * @return bool|EE_Messages_Queue false if no messages sent.
1130
-     * @throws EE_Error
1131
-     * @throws InvalidArgumentException
1132
-     * @throws InvalidDataTypeException
1133
-     * @throws InvalidInterfaceException
1134
-     * @throws ReflectionException
1135
-     */
1136
-    public static function send_now($message_ids)
1137
-    {
1138
-        self::_load_controller();
1139
-        $messages = EEM_Message::instance()->get_all(
1140
-            array(
1141
-                0 => array(
1142
-                    'MSG_ID' => array('IN', $message_ids),
1143
-                    'STS_ID' => array(
1144
-                        'IN',
1145
-                        array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1146
-                    ),
1147
-                ),
1148
-            )
1149
-        );
1150
-        $sent_queue = false;
1151
-        if ($messages) {
1152
-            $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1153
-        }
1154
-
1155
-        if (! $sent_queue instanceof EE_Messages_Queue) {
1156
-            EE_Error::add_error(
1157
-                esc_html__(
1158
-                    'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1159
-                    'event_espresso'
1160
-                ),
1161
-                __FILE__,
1162
-                __FUNCTION__,
1163
-                __LINE__
1164
-            );
1165
-        } else {
1166
-            // can count how many sent by using the messages in the queue
1167
-            $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1168
-            if ($sent_count > 0) {
1169
-                EE_Error::add_success(
1170
-                    sprintf(
1171
-                        _n(
1172
-                            'There was %d message successfully sent.',
1173
-                            'There were %d messages successfully sent.',
1174
-                            $sent_count,
1175
-                            'event_espresso'
1176
-                        ),
1177
-                        $sent_count
1178
-                    )
1179
-                );
1180
-            } else {
1181
-                EE_Error::overwrite_errors();
1182
-                EE_Error::add_error(
1183
-                    esc_html__(
1184
-                        'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
261
+				exit;
262
+			}
263
+		}
264
+	}
265
+
266
+
267
+	/**
268
+	 *  This runs when the msg_url_trigger route has initiated.
269
+	 *
270
+	 * @since 4.5.0
271
+	 * @param WP $WP
272
+	 * @throws EE_Error
273
+	 * @throws InvalidArgumentException
274
+	 * @throws ReflectionException
275
+	 * @throws InvalidDataTypeException
276
+	 * @throws InvalidInterfaceException
277
+	 */
278
+	public function run($WP)
279
+	{
280
+		// ensure controller is loaded
281
+		self::_load_controller();
282
+		// attempt to process message
283
+		try {
284
+			/** @type EE_Message_To_Generate_From_Request $message_to_generate */
285
+			$message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
286
+			self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
287
+		} catch (EE_Error $e) {
288
+			$error_msg = esc_html__(
289
+				'Please note that a system message failed to send due to a technical issue.',
290
+				'event_espresso'
291
+			);
292
+			// add specific message for developers if WP_DEBUG in on
293
+			$error_msg .= '||' . $e->getMessage();
294
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
295
+		}
296
+	}
297
+
298
+
299
+	/**
300
+	 * This is triggered by the 'msg_cron_trigger' route.
301
+	 *
302
+	 * @param WP $WP
303
+	 */
304
+	public function execute_batch_request($WP)
305
+	{
306
+		$this->run_cron();
307
+		header('HTTP/1.1 200 OK');
308
+		exit();
309
+	}
310
+
311
+
312
+	/**
313
+	 * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
314
+	 * request.
315
+	 */
316
+	public function run_cron()
317
+	{
318
+		self::_load_controller();
319
+		$request = self::getRequest();
320
+		// get required vars
321
+		$cron_type = $request->getRequestParam('type');
322
+		$transient_key = $request->getRequestParam('key');
323
+
324
+		// now let's verify transient, if not valid exit immediately
325
+		if (! get_transient($transient_key)) {
326
+			/**
327
+			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user
328
+			 * request.
329
+			 */
330
+			trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
331
+		}
332
+
333
+		// if made it here, lets' delete the transient to keep the db clean
334
+		delete_transient($transient_key);
335
+
336
+		if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
337
+			$method = 'batch_' . $cron_type . '_from_queue';
338
+			if (method_exists(self::$_MSG_PROCESSOR, $method)) {
339
+				self::$_MSG_PROCESSOR->$method();
340
+			} else {
341
+				// no matching task
342
+				/**
343
+				 * trigger error so this gets in the error logs.  This is important because it happens on a non user
344
+				 * request.
345
+				 */
346
+				trigger_error(
347
+					esc_attr(
348
+						sprintf(
349
+							esc_html__('There is no task corresponding to this route %s', 'event_espresso'),
350
+							$cron_type
351
+						)
352
+					)
353
+				);
354
+			}
355
+		}
356
+
357
+		do_action('FHEE__EED_Messages__run_cron__end');
358
+	}
359
+
360
+
361
+	/**
362
+	 * This is used to retrieve the template pack for the given name.
363
+	 * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
364
+	 * the default template pack is returned.
365
+	 *
366
+	 * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
367
+	 * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
368
+	 *                                   in generating the Pack class name).
369
+	 * @return EE_Messages_Template_Pack
370
+	 * @throws EE_Error
371
+	 * @throws InvalidArgumentException
372
+	 * @throws ReflectionException
373
+	 * @throws InvalidDataTypeException
374
+	 * @throws InvalidInterfaceException
375
+	 */
376
+	public static function get_template_pack($template_pack_name)
377
+	{
378
+		EE_Registry::instance()->load_helper('MSG_Template');
379
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
380
+	}
381
+
382
+
383
+	/**
384
+	 * Retrieves an array of all template packs.
385
+	 * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
386
+	 *
387
+	 * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
388
+	 * @return EE_Messages_Template_Pack[]
389
+	 * @throws EE_Error
390
+	 * @throws InvalidArgumentException
391
+	 * @throws ReflectionException
392
+	 * @throws InvalidDataTypeException
393
+	 * @throws InvalidInterfaceException
394
+	 */
395
+	public static function get_template_packs()
396
+	{
397
+		EE_Registry::instance()->load_helper('MSG_Template');
398
+
399
+		// for backward compat, let's make sure this returns in the same format as originally.
400
+		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
401
+		$template_pack_collection->rewind();
402
+		$template_packs = array();
403
+		while ($template_pack_collection->valid()) {
404
+			$template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
405
+			$template_pack_collection->next();
406
+		}
407
+		return $template_packs;
408
+	}
409
+
410
+
411
+	/**
412
+	 * This simply makes sure the autoloaders are registered for the EE_messages system.
413
+	 *
414
+	 * @since 4.5.0
415
+	 * @return void
416
+	 * @throws EE_Error
417
+	 */
418
+	public static function set_autoloaders()
419
+	{
420
+		if (empty(self::$_MSG_PATHS)) {
421
+			self::_set_messages_paths();
422
+			foreach (self::$_MSG_PATHS as $path) {
423
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
424
+			}
425
+			// add aliases
426
+			EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
427
+			EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
428
+		}
429
+	}
430
+
431
+
432
+	/**
433
+	 * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
434
+	 * for use by the Messages Autoloaders
435
+	 *
436
+	 * @since 4.5.0
437
+	 * @return void.
438
+	 */
439
+	protected static function _set_messages_paths()
440
+	{
441
+		$dir_ref = array(
442
+			'messages/message_type',
443
+			'messages/messenger',
444
+			'messages/defaults',
445
+			'messages/defaults/email',
446
+			'messages/data_class',
447
+			'messages/validators',
448
+			'messages/validators/email',
449
+			'messages/validators/html',
450
+			'shortcodes',
451
+		);
452
+		$paths = array();
453
+		foreach ($dir_ref as $index => $dir) {
454
+			$paths[ $index ] = EE_LIBRARIES . $dir;
455
+		}
456
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
457
+	}
458
+
459
+
460
+	/**
461
+	 * Takes care of loading dependencies
462
+	 *
463
+	 * @since 4.5.0
464
+	 * @return void
465
+	 * @throws EE_Error
466
+	 * @throws InvalidArgumentException
467
+	 * @throws ReflectionException
468
+	 * @throws InvalidDataTypeException
469
+	 * @throws InvalidInterfaceException
470
+	 */
471
+	protected static function _load_controller()
472
+	{
473
+		if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
474
+			EE_Registry::instance()->load_core('Request_Handler');
475
+			self::set_autoloaders();
476
+			self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
477
+			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor');
478
+			self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
479
+		}
480
+	}
481
+
482
+
483
+	/**
484
+	 * @param EE_Transaction $transaction
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws InvalidDataTypeException
488
+	 * @throws InvalidInterfaceException
489
+	 * @throws ReflectionException
490
+	 */
491
+	public static function payment_reminder(EE_Transaction $transaction)
492
+	{
493
+		self::_load_controller();
494
+		$data = array($transaction, null);
495
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
496
+	}
497
+
498
+
499
+	/**
500
+	 * Any messages triggers for after successful gateway payments should go in here.
501
+	 *
502
+	 * @param EE_Transaction  $transaction object
503
+	 * @param EE_Payment|null $payment     object
504
+	 * @return void
505
+	 * @throws EE_Error
506
+	 * @throws InvalidArgumentException
507
+	 * @throws ReflectionException
508
+	 * @throws InvalidDataTypeException
509
+	 * @throws InvalidInterfaceException
510
+	 */
511
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment = null)
512
+	{
513
+		// if there's no payment object, then we cannot do a payment type message!
514
+		if (! $payment instanceof EE_Payment) {
515
+			return;
516
+		}
517
+		self::_load_controller();
518
+		$data = array($transaction, $payment);
519
+		EE_Registry::instance()->load_helper('MSG_Template');
520
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
521
+		// if payment amount is less than 0 then switch to payment_refund message type.
522
+		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
523
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
524
+	}
525
+
526
+
527
+	/**
528
+	 * @param EE_Transaction $transaction
529
+	 * @throws EE_Error
530
+	 * @throws InvalidArgumentException
531
+	 * @throws InvalidDataTypeException
532
+	 * @throws InvalidInterfaceException
533
+	 * @throws ReflectionException
534
+	 */
535
+	public static function cancelled_registration(EE_Transaction $transaction)
536
+	{
537
+		self::_load_controller();
538
+		$data = array($transaction, null);
539
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
540
+	}
541
+
542
+
543
+	/**
544
+	 * Trigger for Registration messages
545
+	 * Note that what registration message type is sent depends on what the reg status is for the registrations on the
546
+	 * incoming transaction.
547
+	 *
548
+	 * @param EE_Registration $registration
549
+	 * @param array           $extra_details
550
+	 * @return void
551
+	 * @throws EE_Error
552
+	 * @throws InvalidArgumentException
553
+	 * @throws InvalidDataTypeException
554
+	 * @throws InvalidInterfaceException
555
+	 * @throws ReflectionException
556
+	 * @throws EntityNotFoundException
557
+	 */
558
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array())
559
+	{
560
+
561
+		if (! self::_verify_registration_notification_send($registration, $extra_details)) {
562
+			// no messages please
563
+			return;
564
+		}
565
+
566
+		// get all non-trashed registrations so we make sure we send messages for the right status.
567
+		$all_registrations = $registration->transaction()->registrations(
568
+			array(
569
+				array('REG_deleted' => false),
570
+				'order_by' => array(
571
+					'Event.EVT_name'     => 'ASC',
572
+					'Attendee.ATT_lname' => 'ASC',
573
+					'Attendee.ATT_fname' => 'ASC',
574
+				),
575
+			)
576
+		);
577
+		// cached array of statuses so we only trigger messages once per status.
578
+		$statuses_sent = array();
579
+		self::_load_controller();
580
+		$mtgs = array();
581
+
582
+		// loop through registrations and trigger messages once per status.
583
+		foreach ($all_registrations as $reg) {
584
+			// already triggered?
585
+			if (in_array($reg->status_ID(), $statuses_sent)) {
586
+				continue;
587
+			}
588
+
589
+			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
590
+			$mtgs = array_merge(
591
+				$mtgs,
592
+				self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
593
+					$message_type,
594
+					array($registration->transaction(), null, $reg->status_ID())
595
+				)
596
+			);
597
+			$statuses_sent[] = $reg->status_ID();
598
+		}
599
+
600
+		if (count($statuses_sent) > 1) {
601
+			$mtgs = array_merge(
602
+				$mtgs,
603
+				self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
604
+					'registration_summary',
605
+					array($registration->transaction(), null)
606
+				)
607
+			);
608
+		}
609
+
610
+		// batch queue and initiate request
611
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
612
+		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
613
+	}
614
+
615
+
616
+	/**
617
+	 * This is a helper method used to very whether a registration notification should be sent or
618
+	 * not.  Prevents duplicate notifications going out for registration context notifications.
619
+	 *
620
+	 * @param EE_Registration $registration  [description]
621
+	 * @param array           $extra_details [description]
622
+	 * @return bool          true = send away, false = nope halt the presses.
623
+	 */
624
+	protected static function _verify_registration_notification_send(
625
+		EE_Registration $registration,
626
+		$extra_details = array()
627
+	) {
628
+		if (! $registration->is_primary_registrant()) {
629
+			return false;
630
+		}
631
+		$request = self::getRequest();
632
+		// first we check if we're in admin and not doing front ajax
633
+		if (
634
+			($request->isAdmin() || $request->isAdminAjax())
635
+			&& ! $request->isFrontAjax()
636
+		) {
637
+			$status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true);
638
+			// make sure appropriate admin params are set for sending messages
639
+			if (! $status_change['send_notifications']) {
640
+				// no messages sent please.
641
+				return false;
642
+			}
643
+		} else {
644
+			// frontend request (either regular or via AJAX)
645
+			// TXN is NOT finalized ?
646
+			if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
647
+				return false;
648
+			}
649
+			// return visit but nothing changed ???
650
+			if (
651
+				isset($extra_details['revisit'], $extra_details['status_updates']) &&
652
+				$extra_details['revisit'] && ! $extra_details['status_updates']
653
+			) {
654
+				return false;
655
+			}
656
+			// NOT sending messages && reg status is something other than "Not-Approved"
657
+			if (
658
+				! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
659
+				$registration->status_ID() !== EEM_Registration::status_id_not_approved
660
+			) {
661
+				return false;
662
+			}
663
+		}
664
+		// release the kraken
665
+		return true;
666
+	}
667
+
668
+
669
+	/**
670
+	 * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
671
+	 * status id.
672
+	 *
673
+	 * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
674
+	 *                    or EEH_MSG_Template::convert_reg_status_to_message_type
675
+	 * @param string $reg_status
676
+	 * @return array
677
+	 * @throws EE_Error
678
+	 * @throws InvalidArgumentException
679
+	 * @throws ReflectionException
680
+	 * @throws InvalidDataTypeException
681
+	 * @throws InvalidInterfaceException
682
+	 */
683
+	protected static function _get_reg_status_array($reg_status = '')
684
+	{
685
+		EE_Registry::instance()->load_helper('MSG_Template');
686
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
687
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
688
+			: EEH_MSG_Template::reg_status_to_message_type_array();
689
+	}
690
+
691
+
692
+	/**
693
+	 * Simply returns the payment message type for the given payment status.
694
+	 *
695
+	 * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
696
+	 *                   or EEH_MSG_Template::convert_payment_status_to_message_type
697
+	 * @param string $payment_status The payment status being matched.
698
+	 * @return bool|string The payment message type slug matching the status or false if no match.
699
+	 * @throws EE_Error
700
+	 * @throws InvalidArgumentException
701
+	 * @throws ReflectionException
702
+	 * @throws InvalidDataTypeException
703
+	 * @throws InvalidInterfaceException
704
+	 */
705
+	protected static function _get_payment_message_type($payment_status)
706
+	{
707
+		EE_Registry::instance()->load_helper('MSG_Template');
708
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
709
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
710
+			: false;
711
+	}
712
+
713
+
714
+	/**
715
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
716
+	 *
717
+	 * @access public
718
+	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
719
+	 * @return bool success/fail
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws InvalidDataTypeException
723
+	 * @throws InvalidInterfaceException
724
+	 * @throws ReflectionException
725
+	 */
726
+	public static function process_resend(array $req_data = [])
727
+	{
728
+		self::_load_controller();
729
+		$request = self::getRequest();
730
+		// if $msgID in this request then skip to the new resend_message
731
+		if ($request->getRequestParam('MSG_ID')) {
732
+			return self::resend_message();
733
+		}
734
+
735
+		// make sure any incoming request data is set on the request so that it gets picked up later.
736
+		foreach ((array) $req_data as $request_key => $request_value) {
737
+			if (! $request->requestParamIsSet($request_key)) {
738
+				$request->setRequestParam($request_key, $request_value);
739
+			}
740
+		}
741
+
742
+		if (
743
+			! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()
744
+		) {
745
+			return false;
746
+		}
747
+
748
+		try {
749
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
750
+			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
751
+		} catch (EE_Error $e) {
752
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
753
+			return false;
754
+		}
755
+		EE_Error::add_success(
756
+			esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso')
757
+		);
758
+		return true; // everything got queued.
759
+	}
760
+
761
+
762
+	/**
763
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
764
+	 *
765
+	 * @return bool
766
+	 * @throws EE_Error
767
+	 * @throws InvalidArgumentException
768
+	 * @throws InvalidDataTypeException
769
+	 * @throws InvalidInterfaceException
770
+	 * @throws ReflectionException
771
+	 */
772
+	public static function resend_message()
773
+	{
774
+		self::_load_controller();
775
+
776
+		$msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int');
777
+		if (! $msgID) {
778
+			EE_Error::add_error(
779
+				esc_html__(
780
+					'Something went wrong because there is no "MSG_ID" value in the request',
781
+					'event_espresso'
782
+				),
783
+				__FILE__,
784
+				__FUNCTION__,
785
+				__LINE__
786
+			);
787
+			return false;
788
+		}
789
+
790
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
791
+
792
+		// setup success message.
793
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
794
+		EE_Error::add_success(
795
+			sprintf(
796
+				_n(
797
+					'There was %d message queued for resending.',
798
+					'There were %d messages queued for resending.',
799
+					$count_ready_for_resend,
800
+					'event_espresso'
801
+				),
802
+				$count_ready_for_resend
803
+			)
804
+		);
805
+		return true;
806
+	}
807
+
808
+
809
+	/**
810
+	 * Message triggers for manual payment applied by admin
811
+	 *
812
+	 * @param  EE_Payment $payment EE_payment object
813
+	 * @return bool success/fail
814
+	 * @throws EE_Error
815
+	 * @throws InvalidArgumentException
816
+	 * @throws ReflectionException
817
+	 * @throws InvalidDataTypeException
818
+	 * @throws InvalidInterfaceException
819
+	 */
820
+	public static function process_admin_payment(EE_Payment $payment)
821
+	{
822
+		EE_Registry::instance()->load_helper('MSG_Template');
823
+		// we need to get the transaction object
824
+		$transaction = $payment->transaction();
825
+		if ($transaction instanceof EE_Transaction) {
826
+			$data = array($transaction, $payment);
827
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
828
+
829
+			// if payment amount is less than 0 then switch to payment_refund message type.
830
+			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
831
+
832
+			// if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
833
+			$message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved
834
+				? false : $message_type;
835
+
836
+			self::_load_controller();
837
+
838
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
839
+
840
+			// get count of queued for generation
841
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
842
+				array(
843
+					EEM_Message::status_incomplete,
844
+					EEM_Message::status_idle,
845
+				)
846
+			);
847
+
848
+			if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
849
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
850
+				return true;
851
+			} else {
852
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(
853
+					EEM_Message::instance()->stati_indicating_failed_sending()
854
+				);
855
+				/**
856
+				 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
857
+				 * IMMEDIATE generation.
858
+				 */
859
+				if ($count_failed > 0) {
860
+					EE_Error::add_error(
861
+						sprintf(
862
+							_n(
863
+								'The payment notification generation failed.',
864
+								'%d payment notifications failed being sent.',
865
+								$count_failed,
866
+								'event_espresso'
867
+							),
868
+							$count_failed
869
+						),
870
+						__FILE__,
871
+						__FUNCTION__,
872
+						__LINE__
873
+					);
874
+
875
+					return false;
876
+				} else {
877
+					add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
878
+					return true;
879
+				}
880
+			}
881
+		} else {
882
+			EE_Error::add_error(
883
+				'Unable to generate the payment notification because the given value for the transaction is invalid.',
884
+				'event_espresso'
885
+			);
886
+			return false;
887
+		}
888
+	}
889
+
890
+
891
+	/**
892
+	 * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
893
+	 *
894
+	 * @since   4.3.0
895
+	 * @param  EE_Registration[] $registrations an array of EE_Registration objects
896
+	 * @param  int               $grp_id        a specific message template group id.
897
+	 * @return void
898
+	 * @throws EE_Error
899
+	 * @throws InvalidArgumentException
900
+	 * @throws InvalidDataTypeException
901
+	 * @throws InvalidInterfaceException
902
+	 * @throws ReflectionException
903
+	 */
904
+	public static function send_newsletter_message($registrations, $grp_id)
905
+	{
906
+		// make sure mtp is id and set it in the request later messages setup.
907
+		self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id);
908
+		self::_load_controller();
909
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
910
+	}
911
+
912
+
913
+	/**
914
+	 * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
915
+	 *
916
+	 * @since   4.3.0
917
+	 * @param    string          $registration_message_trigger_url
918
+	 * @param    EE_Registration $registration
919
+	 * @param string             $messenger
920
+	 * @param string             $message_type
921
+	 * @return string
922
+	 * @throws EE_Error
923
+	 * @throws InvalidArgumentException
924
+	 * @throws InvalidDataTypeException
925
+	 * @throws InvalidInterfaceException
926
+	 */
927
+	public static function registration_message_trigger_url(
928
+		$registration_message_trigger_url,
929
+		EE_Registration $registration,
930
+		$messenger = 'html',
931
+		$message_type = 'invoice'
932
+	) {
933
+		// whitelist $messenger
934
+		switch ($messenger) {
935
+			case 'pdf':
936
+				$sending_messenger = 'pdf';
937
+				$generating_messenger = 'html';
938
+				break;
939
+			case 'html':
940
+			default:
941
+				$sending_messenger = 'html';
942
+				$generating_messenger = 'html';
943
+				break;
944
+		}
945
+		// whitelist $message_type
946
+		switch ($message_type) {
947
+			case 'receipt':
948
+				$message_type = 'receipt';
949
+				break;
950
+			case 'invoice':
951
+			default:
952
+				$message_type = 'invoice';
953
+				break;
954
+		}
955
+		// verify that both the messenger AND the message type are active
956
+		if (
957
+			EEH_MSG_Template::is_messenger_active($sending_messenger)
958
+			&& EEH_MSG_Template::is_mt_active($message_type)
959
+		) {
960
+			// need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
961
+			$template_query_params = array(
962
+				'MTP_is_active'    => true,
963
+				'MTP_messenger'    => $generating_messenger,
964
+				'MTP_message_type' => $message_type,
965
+				'Event.EVT_ID'     => $registration->event_ID(),
966
+			);
967
+			// get the message template group.
968
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
969
+			// if we don't have an EE_Message_Template_Group then return
970
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
971
+				// remove EVT_ID from query params so that global templates get picked up
972
+				unset($template_query_params['Event.EVT_ID']);
973
+				// get global template as the fallback
974
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
975
+			}
976
+			// if we don't have an EE_Message_Template_Group then return
977
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
978
+				return '';
979
+			}
980
+			// generate the URL
981
+			$registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
982
+				$sending_messenger,
983
+				$generating_messenger,
984
+				'purchaser',
985
+				$message_type,
986
+				$registration,
987
+				$msg_template_group->ID(),
988
+				$registration->transaction_ID()
989
+			);
990
+		}
991
+		return $registration_message_trigger_url;
992
+	}
993
+
994
+
995
+	/**
996
+	 * Use to generate and return a message preview!
997
+	 *
998
+	 * @param  string $type      This should correspond with a valid message type
999
+	 * @param  string $context   This should correspond with a valid context for the message type
1000
+	 * @param  string $messenger This should correspond with a valid messenger.
1001
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
1002
+	 *                           preview
1003
+	 * @return bool|string The body of the message or if send is requested, sends.
1004
+	 * @throws EE_Error
1005
+	 * @throws InvalidArgumentException
1006
+	 * @throws InvalidDataTypeException
1007
+	 * @throws InvalidInterfaceException
1008
+	 * @throws ReflectionException
1009
+	 */
1010
+	public static function preview_message($type, $context, $messenger, $send = false)
1011
+	{
1012
+		self::_load_controller();
1013
+		$mtg = new EE_Message_To_Generate(
1014
+			$messenger,
1015
+			$type,
1016
+			array(),
1017
+			$context,
1018
+			true
1019
+		);
1020
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
1021
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
1022
+			// loop through all content for the preview and remove any persisted records.
1023
+			$content = '';
1024
+			foreach ($generated_preview_queue->get_message_repository() as $message) {
1025
+				$content = $message->content();
1026
+				if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
1027
+					$message->delete();
1028
+				}
1029
+			}
1030
+			return $content;
1031
+		} else {
1032
+			return $generated_preview_queue;
1033
+		}
1034
+	}
1035
+
1036
+
1037
+	/**
1038
+	 * This is a method that allows for sending a message using a messenger matching the string given and the provided
1039
+	 * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
1040
+	 * content found in the EE_Message objects in the queue.
1041
+	 *
1042
+	 * @since 4.9.0
1043
+	 * @param string            $messenger            a string matching a valid active messenger in the system
1044
+	 * @param string            $message_type         Although it seems contrary to the name of the method, a message
1045
+	 *                                                type name is still required to send along the message type to the
1046
+	 *                                                messenger because this is used for determining what specific
1047
+	 *                                                variations might be loaded for the generated message.
1048
+	 * @param EE_Messages_Queue $queue
1049
+	 * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
1050
+	 *                                                aggregate EE_Message object.
1051
+	 * @return bool success or fail.
1052
+	 * @throws EE_Error
1053
+	 * @throws InvalidArgumentException
1054
+	 * @throws ReflectionException
1055
+	 * @throws InvalidDataTypeException
1056
+	 * @throws InvalidInterfaceException
1057
+	 */
1058
+	public static function send_message_with_messenger_only(
1059
+		$messenger,
1060
+		$message_type,
1061
+		EE_Messages_Queue $queue,
1062
+		$custom_subject = ''
1063
+	) {
1064
+		self::_load_controller();
1065
+		/** @type EE_Message_To_Generate_From_Queue $message_to_generate */
1066
+		$message_to_generate = EE_Registry::instance()->load_lib(
1067
+			'Message_To_Generate_From_Queue',
1068
+			array(
1069
+				$messenger,
1070
+				$message_type,
1071
+				$queue,
1072
+				$custom_subject,
1073
+			)
1074
+		);
1075
+		return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1081
+	 *
1082
+	 * @since 4.9.0
1083
+	 * @param array $message_ids An array of message ids
1084
+	 * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1085
+	 *                           messages.
1086
+	 * @throws EE_Error
1087
+	 * @throws InvalidArgumentException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws InvalidInterfaceException
1090
+	 * @throws ReflectionException
1091
+	 */
1092
+	public static function generate_now($message_ids)
1093
+	{
1094
+		self::_load_controller();
1095
+		$messages = EEM_Message::instance()->get_all(
1096
+			array(
1097
+				0 => array(
1098
+					'MSG_ID' => array('IN', $message_ids),
1099
+					'STS_ID' => EEM_Message::status_incomplete,
1100
+				),
1101
+			)
1102
+		);
1103
+		$generated_queue = false;
1104
+		if ($messages) {
1105
+			$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1106
+		}
1107
+
1108
+		if (! $generated_queue instanceof EE_Messages_Queue) {
1109
+			EE_Error::add_error(
1110
+				esc_html__(
1111
+					'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1112
+					'event_espresso'
1113
+				),
1114
+				__FILE__,
1115
+				__FUNCTION__,
1116
+				__LINE__
1117
+			);
1118
+		}
1119
+		return $generated_queue;
1120
+	}
1121
+
1122
+
1123
+	/**
1124
+	 * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1125
+	 * EEM_Message::status_idle
1126
+	 *
1127
+	 * @since 4.9.0
1128
+	 * @param $message_ids
1129
+	 * @return bool|EE_Messages_Queue false if no messages sent.
1130
+	 * @throws EE_Error
1131
+	 * @throws InvalidArgumentException
1132
+	 * @throws InvalidDataTypeException
1133
+	 * @throws InvalidInterfaceException
1134
+	 * @throws ReflectionException
1135
+	 */
1136
+	public static function send_now($message_ids)
1137
+	{
1138
+		self::_load_controller();
1139
+		$messages = EEM_Message::instance()->get_all(
1140
+			array(
1141
+				0 => array(
1142
+					'MSG_ID' => array('IN', $message_ids),
1143
+					'STS_ID' => array(
1144
+						'IN',
1145
+						array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1146
+					),
1147
+				),
1148
+			)
1149
+		);
1150
+		$sent_queue = false;
1151
+		if ($messages) {
1152
+			$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1153
+		}
1154
+
1155
+		if (! $sent_queue instanceof EE_Messages_Queue) {
1156
+			EE_Error::add_error(
1157
+				esc_html__(
1158
+					'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1159
+					'event_espresso'
1160
+				),
1161
+				__FILE__,
1162
+				__FUNCTION__,
1163
+				__LINE__
1164
+			);
1165
+		} else {
1166
+			// can count how many sent by using the messages in the queue
1167
+			$sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1168
+			if ($sent_count > 0) {
1169
+				EE_Error::add_success(
1170
+					sprintf(
1171
+						_n(
1172
+							'There was %d message successfully sent.',
1173
+							'There were %d messages successfully sent.',
1174
+							$sent_count,
1175
+							'event_espresso'
1176
+						),
1177
+						$sent_count
1178
+					)
1179
+				);
1180
+			} else {
1181
+				EE_Error::overwrite_errors();
1182
+				EE_Error::add_error(
1183
+					esc_html__(
1184
+						'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
1185 1185
 					If there was an error, you can look at the messages in the message activity list table for any error messages.',
1186
-                        'event_espresso'
1187
-                    ),
1188
-                    __FILE__,
1189
-                    __FUNCTION__,
1190
-                    __LINE__
1191
-                );
1192
-            }
1193
-        }
1194
-        return $sent_queue;
1195
-    }
1196
-
1197
-
1198
-    /**
1199
-     * Generate and send immediately from the given $message_ids
1200
-     *
1201
-     * @param array $message_ids EE_Message entity ids.
1202
-     * @throws EE_Error
1203
-     * @throws InvalidArgumentException
1204
-     * @throws InvalidDataTypeException
1205
-     * @throws InvalidInterfaceException
1206
-     * @throws ReflectionException
1207
-     */
1208
-    public static function generate_and_send_now(array $message_ids)
1209
-    {
1210
-        $generated_queue = self::generate_now($message_ids);
1211
-        // now let's just trigger sending immediately from this queue.
1212
-        $messages_sent = $generated_queue instanceof EE_Messages_Queue
1213
-            ? $generated_queue->execute()
1214
-            : 0;
1215
-        if ($messages_sent) {
1216
-            EE_Error::add_success(
1217
-                esc_html(
1218
-                    sprintf(
1219
-                        _n(
1220
-                            'There was %d message successfully generated and sent.',
1221
-                            'There were %d messages successfully generated and sent.',
1222
-                            $messages_sent,
1223
-                            'event_espresso'
1224
-                        ),
1225
-                        $messages_sent
1226
-                    )
1227
-                )
1228
-            );
1229
-            // errors would be added via the generate_now method.
1230
-        }
1231
-    }
1232
-
1233
-
1234
-    /**
1235
-     * This will queue the incoming message ids for resending.
1236
-     * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1237
-     *
1238
-     * @since 4.9.0
1239
-     * @param array $message_ids An array of EE_Message IDs
1240
-     * @return bool true means messages were successfully queued for resending, false means none were queued for
1241
-     *                           resending.
1242
-     * @throws EE_Error
1243
-     * @throws InvalidArgumentException
1244
-     * @throws InvalidDataTypeException
1245
-     * @throws InvalidInterfaceException
1246
-     * @throws ReflectionException
1247
-     */
1248
-    public static function queue_for_resending($message_ids)
1249
-    {
1250
-        self::_load_controller();
1251
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1252
-
1253
-        // get queue and count
1254
-        $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1255
-
1256
-        if (
1257
-            $queue_count > 0
1258
-        ) {
1259
-            EE_Error::add_success(
1260
-                sprintf(
1261
-                    _n(
1262
-                        '%d message successfully queued for resending.',
1263
-                        '%d messages successfully queued for resending.',
1264
-                        $queue_count,
1265
-                        'event_espresso'
1266
-                    ),
1267
-                    $queue_count
1268
-                )
1269
-            );
1270
-            /**
1271
-             * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1272
-             */
1273
-        } elseif (
1274
-            apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1275
-            || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1276
-        ) {
1277
-            $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1278
-            if ($queue_count > 0) {
1279
-                EE_Error::add_success(
1280
-                    sprintf(
1281
-                        _n(
1282
-                            '%d message successfully sent.',
1283
-                            '%d messages successfully sent.',
1284
-                            $queue_count,
1285
-                            'event_espresso'
1286
-                        ),
1287
-                        $queue_count
1288
-                    )
1289
-                );
1290
-            } else {
1291
-                EE_Error::add_error(
1292
-                    esc_html__(
1293
-                        'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1294
-                        'event_espresso'
1295
-                    ),
1296
-                    __FILE__,
1297
-                    __FUNCTION__,
1298
-                    __LINE__
1299
-                );
1300
-            }
1301
-        } else {
1302
-            EE_Error::add_error(
1303
-                esc_html__(
1304
-                    'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1305
-                    'event_espresso'
1306
-                ),
1307
-                __FILE__,
1308
-                __FUNCTION__,
1309
-                __LINE__
1310
-            );
1311
-        }
1312
-        return (bool) $queue_count;
1313
-    }
1314
-
1315
-
1316
-    /**
1317
-     * debug
1318
-     *
1319
-     * @param string          $class
1320
-     * @param string          $func
1321
-     * @param string          $line
1322
-     * @param \EE_Transaction $transaction
1323
-     * @param array           $info
1324
-     * @param bool            $display_request
1325
-     * @throws EE_Error
1326
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1327
-     */
1328
-    protected static function log(
1329
-        $class = '',
1330
-        $func = '',
1331
-        $line = '',
1332
-        EE_Transaction $transaction,
1333
-        $info = array(),
1334
-        $display_request = false
1335
-    ) {
1336
-        if (defined('EE_DEBUG') && EE_DEBUG) {
1337
-            if ($transaction instanceof EE_Transaction) {
1338
-                // don't serialize objects
1339
-                $info = EEH_Debug_Tools::strip_objects($info);
1340
-                $info['TXN_status'] = $transaction->status_ID();
1341
-                $info['TXN_reg_steps'] = $transaction->reg_steps();
1342
-                if ($transaction->ID()) {
1343
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1344
-                    EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1345
-                }
1346
-            }
1347
-        }
1348
-    }
1349
-
1350
-
1351
-    /**
1352
-     *  Resets all the static properties in this class when called.
1353
-     */
1354
-    public static function reset()
1355
-    {
1356
-        self::$_EEMSG = null;
1357
-        self::$_message_resource_manager = null;
1358
-        self::$_MSG_PROCESSOR = null;
1359
-        self::$_MSG_PATHS = null;
1360
-        self::$_TMP_PACKS = array();
1361
-    }
1186
+						'event_espresso'
1187
+					),
1188
+					__FILE__,
1189
+					__FUNCTION__,
1190
+					__LINE__
1191
+				);
1192
+			}
1193
+		}
1194
+		return $sent_queue;
1195
+	}
1196
+
1197
+
1198
+	/**
1199
+	 * Generate and send immediately from the given $message_ids
1200
+	 *
1201
+	 * @param array $message_ids EE_Message entity ids.
1202
+	 * @throws EE_Error
1203
+	 * @throws InvalidArgumentException
1204
+	 * @throws InvalidDataTypeException
1205
+	 * @throws InvalidInterfaceException
1206
+	 * @throws ReflectionException
1207
+	 */
1208
+	public static function generate_and_send_now(array $message_ids)
1209
+	{
1210
+		$generated_queue = self::generate_now($message_ids);
1211
+		// now let's just trigger sending immediately from this queue.
1212
+		$messages_sent = $generated_queue instanceof EE_Messages_Queue
1213
+			? $generated_queue->execute()
1214
+			: 0;
1215
+		if ($messages_sent) {
1216
+			EE_Error::add_success(
1217
+				esc_html(
1218
+					sprintf(
1219
+						_n(
1220
+							'There was %d message successfully generated and sent.',
1221
+							'There were %d messages successfully generated and sent.',
1222
+							$messages_sent,
1223
+							'event_espresso'
1224
+						),
1225
+						$messages_sent
1226
+					)
1227
+				)
1228
+			);
1229
+			// errors would be added via the generate_now method.
1230
+		}
1231
+	}
1232
+
1233
+
1234
+	/**
1235
+	 * This will queue the incoming message ids for resending.
1236
+	 * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1237
+	 *
1238
+	 * @since 4.9.0
1239
+	 * @param array $message_ids An array of EE_Message IDs
1240
+	 * @return bool true means messages were successfully queued for resending, false means none were queued for
1241
+	 *                           resending.
1242
+	 * @throws EE_Error
1243
+	 * @throws InvalidArgumentException
1244
+	 * @throws InvalidDataTypeException
1245
+	 * @throws InvalidInterfaceException
1246
+	 * @throws ReflectionException
1247
+	 */
1248
+	public static function queue_for_resending($message_ids)
1249
+	{
1250
+		self::_load_controller();
1251
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1252
+
1253
+		// get queue and count
1254
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1255
+
1256
+		if (
1257
+			$queue_count > 0
1258
+		) {
1259
+			EE_Error::add_success(
1260
+				sprintf(
1261
+					_n(
1262
+						'%d message successfully queued for resending.',
1263
+						'%d messages successfully queued for resending.',
1264
+						$queue_count,
1265
+						'event_espresso'
1266
+					),
1267
+					$queue_count
1268
+				)
1269
+			);
1270
+			/**
1271
+			 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1272
+			 */
1273
+		} elseif (
1274
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1275
+			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1276
+		) {
1277
+			$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1278
+			if ($queue_count > 0) {
1279
+				EE_Error::add_success(
1280
+					sprintf(
1281
+						_n(
1282
+							'%d message successfully sent.',
1283
+							'%d messages successfully sent.',
1284
+							$queue_count,
1285
+							'event_espresso'
1286
+						),
1287
+						$queue_count
1288
+					)
1289
+				);
1290
+			} else {
1291
+				EE_Error::add_error(
1292
+					esc_html__(
1293
+						'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1294
+						'event_espresso'
1295
+					),
1296
+					__FILE__,
1297
+					__FUNCTION__,
1298
+					__LINE__
1299
+				);
1300
+			}
1301
+		} else {
1302
+			EE_Error::add_error(
1303
+				esc_html__(
1304
+					'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1305
+					'event_espresso'
1306
+				),
1307
+				__FILE__,
1308
+				__FUNCTION__,
1309
+				__LINE__
1310
+			);
1311
+		}
1312
+		return (bool) $queue_count;
1313
+	}
1314
+
1315
+
1316
+	/**
1317
+	 * debug
1318
+	 *
1319
+	 * @param string          $class
1320
+	 * @param string          $func
1321
+	 * @param string          $line
1322
+	 * @param \EE_Transaction $transaction
1323
+	 * @param array           $info
1324
+	 * @param bool            $display_request
1325
+	 * @throws EE_Error
1326
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1327
+	 */
1328
+	protected static function log(
1329
+		$class = '',
1330
+		$func = '',
1331
+		$line = '',
1332
+		EE_Transaction $transaction,
1333
+		$info = array(),
1334
+		$display_request = false
1335
+	) {
1336
+		if (defined('EE_DEBUG') && EE_DEBUG) {
1337
+			if ($transaction instanceof EE_Transaction) {
1338
+				// don't serialize objects
1339
+				$info = EEH_Debug_Tools::strip_objects($info);
1340
+				$info['TXN_status'] = $transaction->status_ID();
1341
+				$info['TXN_reg_steps'] = $transaction->reg_steps();
1342
+				if ($transaction->ID()) {
1343
+					$index = 'EE_Transaction: ' . $transaction->ID();
1344
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1345
+				}
1346
+			}
1347
+		}
1348
+	}
1349
+
1350
+
1351
+	/**
1352
+	 *  Resets all the static properties in this class when called.
1353
+	 */
1354
+	public static function reset()
1355
+	{
1356
+		self::$_EEMSG = null;
1357
+		self::$_message_resource_manager = null;
1358
+		self::$_MSG_PROCESSOR = null;
1359
+		self::$_MSG_PATHS = null;
1360
+		self::$_TMP_PACKS = array();
1361
+	}
1362 1362
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 'event_espresso'
205 205
             );
206 206
             // add specific message for developers if WP_DEBUG in on
207
-            $error_msg .= '||' . $e->getMessage();
207
+            $error_msg .= '||'.$e->getMessage();
208 208
             EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
209 209
         }
210 210
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 'event_espresso'
291 291
             );
292 292
             // add specific message for developers if WP_DEBUG in on
293
-            $error_msg .= '||' . $e->getMessage();
293
+            $error_msg .= '||'.$e->getMessage();
294 294
             EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
295 295
         }
296 296
     }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         $transient_key = $request->getRequestParam('key');
323 323
 
324 324
         // now let's verify transient, if not valid exit immediately
325
-        if (! get_transient($transient_key)) {
325
+        if ( ! get_transient($transient_key)) {
326 326
             /**
327 327
              * trigger error so this gets in the error logs.  This is important because it happens on a non-user
328 328
              * request.
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         delete_transient($transient_key);
335 335
 
336 336
         if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
337
-            $method = 'batch_' . $cron_type . '_from_queue';
337
+            $method = 'batch_'.$cron_type.'_from_queue';
338 338
             if (method_exists(self::$_MSG_PROCESSOR, $method)) {
339 339
                 self::$_MSG_PROCESSOR->$method();
340 340
             } else {
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $template_pack_collection->rewind();
402 402
         $template_packs = array();
403 403
         while ($template_pack_collection->valid()) {
404
-            $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
404
+            $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
405 405
             $template_pack_collection->next();
406 406
         }
407 407
         return $template_packs;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         );
452 452
         $paths = array();
453 453
         foreach ($dir_ref as $index => $dir) {
454
-            $paths[ $index ] = EE_LIBRARIES . $dir;
454
+            $paths[$index] = EE_LIBRARIES.$dir;
455 455
         }
456 456
         self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
457 457
     }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      */
471 471
     protected static function _load_controller()
472 472
     {
473
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
473
+        if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
474 474
             EE_Registry::instance()->load_core('Request_Handler');
475 475
             self::set_autoloaders();
476 476
             self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
     public static function payment(EE_Transaction $transaction, EE_Payment $payment = null)
512 512
     {
513 513
         // if there's no payment object, then we cannot do a payment type message!
514
-        if (! $payment instanceof EE_Payment) {
514
+        if ( ! $payment instanceof EE_Payment) {
515 515
             return;
516 516
         }
517 517
         self::_load_controller();
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     public static function maybe_registration(EE_Registration $registration, $extra_details = array())
559 559
     {
560 560
 
561
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
561
+        if ( ! self::_verify_registration_notification_send($registration, $extra_details)) {
562 562
             // no messages please
563 563
             return;
564 564
         }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
         EE_Registration $registration,
626 626
         $extra_details = array()
627 627
     ) {
628
-        if (! $registration->is_primary_registrant()) {
628
+        if ( ! $registration->is_primary_registrant()) {
629 629
             return false;
630 630
         }
631 631
         $request = self::getRequest();
@@ -636,14 +636,14 @@  discard block
 block discarded – undo
636 636
         ) {
637 637
             $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true);
638 638
             // make sure appropriate admin params are set for sending messages
639
-            if (! $status_change['send_notifications']) {
639
+            if ( ! $status_change['send_notifications']) {
640 640
                 // no messages sent please.
641 641
                 return false;
642 642
             }
643 643
         } else {
644 644
             // frontend request (either regular or via AJAX)
645 645
             // TXN is NOT finalized ?
646
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
646
+            if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
647 647
                 return false;
648 648
             }
649 649
             // return visit but nothing changed ???
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 
735 735
         // make sure any incoming request data is set on the request so that it gets picked up later.
736 736
         foreach ((array) $req_data as $request_key => $request_value) {
737
-            if (! $request->requestParamIsSet($request_key)) {
737
+            if ( ! $request->requestParamIsSet($request_key)) {
738 738
                 $request->setRequestParam($request_key, $request_value);
739 739
             }
740 740
         }
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
         self::_load_controller();
775 775
 
776 776
         $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int');
777
-        if (! $msgID) {
777
+        if ( ! $msgID) {
778 778
             EE_Error::add_error(
779 779
                 esc_html__(
780 780
                     'Something went wrong because there is no "MSG_ID" value in the request',
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
             // get the message template group.
968 968
             $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
969 969
             // if we don't have an EE_Message_Template_Group then return
970
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
970
+            if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
971 971
                 // remove EVT_ID from query params so that global templates get picked up
972 972
                 unset($template_query_params['Event.EVT_ID']);
973 973
                 // get global template as the fallback
974 974
                 $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
975 975
             }
976 976
             // if we don't have an EE_Message_Template_Group then return
977
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
977
+            if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
978 978
                 return '';
979 979
             }
980 980
             // generate the URL
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
             $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1106 1106
         }
1107 1107
 
1108
-        if (! $generated_queue instanceof EE_Messages_Queue) {
1108
+        if ( ! $generated_queue instanceof EE_Messages_Queue) {
1109 1109
             EE_Error::add_error(
1110 1110
                 esc_html__(
1111 1111
                     'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
             $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1153 1153
         }
1154 1154
 
1155
-        if (! $sent_queue instanceof EE_Messages_Queue) {
1155
+        if ( ! $sent_queue instanceof EE_Messages_Queue) {
1156 1156
             EE_Error::add_error(
1157 1157
                 esc_html__(
1158 1158
                     'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
                 $info['TXN_status'] = $transaction->status_ID();
1341 1341
                 $info['TXN_reg_steps'] = $transaction->reg_steps();
1342 1342
                 if ($transaction->ID()) {
1343
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1343
+                    $index = 'EE_Transaction: '.$transaction->ID();
1344 1344
                     EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1345 1345
                 }
1346 1346
             }
Please login to merge, or discard this patch.
help_tabs/transactions_overview_table_column_headings.help_tab.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@  discard block
 block discarded – undo
6 6
         <p><strong><?php esc_html_e('ID', 'event_espresso'); ?></strong>
7 7
             <br />
8 8
             <?php esc_html_e(
9
-                'This is the transaction ID is that is used throughout the payment process.',
10
-                'event_espresso'
11
-            ); ?>
9
+				'This is the transaction ID is that is used throughout the payment process.',
10
+				'event_espresso'
11
+			); ?>
12 12
         </p>
13 13
     </li>
14 14
     <li><strong><?php esc_html_e('Transaction Date', 'event_espresso'); ?></strong>
15 15
         <br />
16 16
         <?php esc_html_e(
17
-            'This is the date that the transaction occurred on. Clicking the date will take you to another page where you can view the transaction details.',
18
-            'event_espresso'
19
-        ); ?>
17
+			'This is the date that the transaction occurred on. Clicking the date will take you to another page where you can view the transaction details.',
18
+			'event_espresso'
19
+		); ?>
20 20
     </li>
21 21
     <li>
22 22
         <strong><?php esc_html_e('Status', 'event_espresso'); ?></strong>
23 23
         <br />
24 24
         <?php esc_html_e(
25
-            'The status helps you understand if the transaction was successful or not. Below are available statuses for transactions.',
26
-            'event_espresso'
27
-        ); ?>
25
+			'The status helps you understand if the transaction was successful or not. Below are available statuses for transactions.',
26
+			'event_espresso'
27
+		); ?>
28 28
         <ul>
29 29
             <li style="list-style-type: none;">
30 30
                 <strong><?php esc_html_e('Overpaid', 'event_espresso'); ?></strong>
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
                 <strong><?php esc_html_e('Incomplete', 'event_espresso'); ?></strong>
41 41
                 <br />
42 42
                 <?php esc_html_e(
43
-                    'The payment has not yet been completed. This is the status for online payments that have yet to be processed.',
44
-                    'event_espresso'
45
-                ); ?>
43
+					'The payment has not yet been completed. This is the status for online payments that have yet to be processed.',
44
+					'event_espresso'
45
+				); ?>
46 46
             </li>
47 47
             <li style="list-style-type: none;">
48 48
                 <strong><?php esc_html_e('Failed', 'event_espresso'); ?></strong>
@@ -55,69 +55,69 @@  discard block
 block discarded – undo
55 55
         <strong><?php esc_html_e('Total', 'event_espresso'); ?></strong>
56 56
         <br />
57 57
         <?php esc_html_e(
58
-            'This is the total amount for that transaction. It will include the total of every ticket purchased even if from separate events.',
59
-            'event_espresso'
60
-        ); ?>
58
+			'This is the total amount for that transaction. It will include the total of every ticket purchased even if from separate events.',
59
+			'event_espresso'
60
+		); ?>
61 61
     </li>
62 62
     <li>
63 63
         <strong><?php esc_html_e('Paid', 'event_espresso'); ?></strong>
64 64
         <br />
65 65
         <?php esc_html_e(
66
-            'This shows much has been paid. If this column matches the amount in the total column, then the transaction has been paid in full.',
67
-            'event_espresso'
68
-        ); ?>
66
+			'This shows much has been paid. If this column matches the amount in the total column, then the transaction has been paid in full.',
67
+			'event_espresso'
68
+		); ?>
69 69
     </li>
70 70
     <li>
71 71
         <strong><?php esc_html_e('Primary Registrant', 'event_espresso'); ?></strong>
72 72
         <br />
73 73
         <?php esc_html_e(
74
-            'The name of the primary registrant. Clicking the name will take you to the registration details page.',
75
-            'event_espresso'
76
-        ); ?>
74
+			'The name of the primary registrant. Clicking the name will take you to the registration details page.',
75
+			'event_espresso'
76
+		); ?>
77 77
     </li>
78 78
     <li>
79 79
         <strong><?php esc_html_e('Email Address', 'event_espresso'); ?></strong>
80 80
         <br />
81 81
         <?php esc_html_e(
82
-            'This is the email address for the primary registrant. Clicking the email address will open your default email client.',
83
-            'event_espresso'
84
-        ); ?>
82
+			'This is the email address for the primary registrant. Clicking the email address will open your default email client.',
83
+			'event_espresso'
84
+		); ?>
85 85
     </li>
86 86
     <li>
87 87
         <strong><?php esc_html_e('Event', 'event_espresso'); ?></strong>
88 88
         <br />
89 89
         <?php esc_html_e(
90
-            'The name of the events are shown here. Clicking the name will take you the edit event page.',
91
-            'event_espresso'
92
-        ); ?>
90
+			'The name of the events are shown here. Clicking the name will take you the edit event page.',
91
+			'event_espresso'
92
+		); ?>
93 93
     </li>
94 94
     <li>
95 95
         <strong><?php esc_html_e('Actions', 'event_espresso'); ?></strong>
96 96
         <br />
97 97
         <?php esc_html_e(
98
-            'There are several actions that can be done by clicking the icons. These are explained below.',
99
-            'event_espresso'
100
-        ); ?>
98
+			'There are several actions that can be done by clicking the icons. These are explained below.',
99
+			'event_espresso'
100
+		); ?>
101 101
         <ul>
102 102
             <li style="list-style-type: none;">
103 103
                 <strong>
104 104
                     <?php printf(
105
-                        esc_html__('View Transaction Details %1$s', 'event_espresso'),
106
-                        '<span class="dashicons dashicons-cart"></span>'
107
-                    ); ?>
105
+						esc_html__('View Transaction Details %1$s', 'event_espresso'),
106
+						'<span class="dashicons dashicons-cart"></span>'
107
+					); ?>
108 108
                 </strong>
109 109
                 <br />
110 110
                 <?php esc_html_e(
111
-                    'Takes you to the individual transaction page. Clicking the date also takes you to the individual transaction page.',
112
-                    'event_espresso'
113
-                ); ?>
111
+					'Takes you to the individual transaction page. Clicking the date also takes you to the individual transaction page.',
112
+					'event_espresso'
113
+				); ?>
114 114
             </li>
115 115
             <li style="list-style-type: none;">
116 116
                 <strong>
117 117
                     <?php printf(
118
-                        esc_html__('View Invoice for Transaction %1$s', 'event_espresso'),
119
-                        '<span class="dashicons dashicons-media-spreadsheet"></span>'
120
-                    ); ?>
118
+						esc_html__('View Invoice for Transaction %1$s', 'event_espresso'),
119
+						'<span class="dashicons dashicons-media-spreadsheet"></span>'
120
+					); ?>
121 121
                 </strong>
122 122
                 <br />
123 123
                 <?php esc_html_e('Takes you to the invoice for the transaction.', 'event_espresso'); ?>
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
             <li style="list-style-type: none;">
126 126
                 <strong>
127 127
                     <?php printf(
128
-                        esc_html__('View Receipt for Transaction %1$s', 'event_espresso'),
129
-                        '<span class="dashicons dashicons-media-default"></span>'
130
-                    ); ?>
128
+						esc_html__('View Receipt for Transaction %1$s', 'event_espresso'),
129
+						'<span class="dashicons dashicons-media-default"></span>'
130
+					); ?>
131 131
                 </strong>
132 132
                 <br />
133 133
                 <?php esc_html_e('Takes you to the receipt for the transaction.', 'event_espresso'); ?>
@@ -135,36 +135,36 @@  discard block
 block discarded – undo
135 135
             <li style="list-style-type: none;">
136 136
                 <strong>
137 137
                     <?php printf(
138
-                        esc_html__('View Registration Details %1$s', 'event_espresso'),
139
-                        '<span class="dashicons dashicons-clipboard"></span>'
140
-                    ); ?>
138
+						esc_html__('View Registration Details %1$s', 'event_espresso'),
139
+						'<span class="dashicons dashicons-clipboard"></span>'
140
+					); ?>
141 141
                 </strong>
142 142
                 <br />
143 143
                 <?php printf(
144
-                    esc_html__(
145
-                        'Clicking this icon will take you to the registration page for this transaction. You can also get there via the %sRegistrations page%s.',
146
-                        'event_espresso'
147
-                    ),
148
-                    '<a href="admin.php?page=espresso_registrations">',
149
-                    '</a>'
150
-                ); ?>
144
+					esc_html__(
145
+						'Clicking this icon will take you to the registration page for this transaction. You can also get there via the %sRegistrations page%s.',
146
+						'event_espresso'
147
+					),
148
+					'<a href="admin.php?page=espresso_registrations">',
149
+					'</a>'
150
+				); ?>
151 151
             </li>
152 152
             <li style="list-style-type: none;">
153 153
                 <strong>
154 154
                     <?php printf(
155
-                        esc_html__('Send Payment Reminder %1$s', 'event_espresso'),
156
-                        '<span class="dashicons dashicons-email-alt"></span>'
157
-                    ); ?>
155
+						esc_html__('Send Payment Reminder %1$s', 'event_espresso'),
156
+						'<span class="dashicons dashicons-email-alt"></span>'
157
+					); ?>
158 158
                 </strong>
159 159
                 <br />
160 160
                 <?php printf(
161
-                    esc_html__(
162
-                        'Emails the primary registrant the Payment Reminder message. This is set up in the %sMessages page%s.',
163
-                        'event_espresso'
164
-                    ),
165
-                    '<a href="admin.php?page=espresso_messages">',
166
-                    '</a>'
167
-                ); ?>
161
+					esc_html__(
162
+						'Emails the primary registrant the Payment Reminder message. This is set up in the %sMessages page%s.',
163
+						'event_espresso'
164
+					),
165
+					'<a href="admin.php?page=espresso_messages">',
166
+					'</a>'
167
+				); ?>
168 168
             </li>
169 169
         </ul>
170 170
     </li>
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3698 added lines, -3698 removed lines patch added patch discarded remove patch
@@ -19,2233 +19,2233 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    private static $_reg_status;
38
-
39
-    /**
40
-     * Form for displaying the custom questions for this registration.
41
-     * This gets used a few times throughout the request so its best to cache it
42
-     *
43
-     * @var EE_Registration_Custom_Questions_Form
44
-     */
45
-    protected $_reg_custom_questions_form = null;
46
-
47
-    /**
48
-     * @var EEM_Registration $registration_model
49
-     */
50
-    private $registration_model;
51
-
52
-    /**
53
-     * @var EEM_Attendee $attendee_model
54
-     */
55
-    private $attendee_model;
56
-
57
-    /**
58
-     * @var EEM_Event $event_model
59
-     */
60
-    private $event_model;
61
-
62
-    /**
63
-     * @var EEM_Status $status_model
64
-     */
65
-    private $status_model;
66
-
67
-
68
-    /**
69
-     * @param bool $routing
70
-     * @throws EE_Error
71
-     * @throws InvalidArgumentException
72
-     * @throws InvalidDataTypeException
73
-     * @throws InvalidInterfaceException
74
-     * @throws ReflectionException
75
-     */
76
-    public function __construct($routing = true)
77
-    {
78
-        parent::__construct($routing);
79
-        add_action('wp_loaded', array($this, 'wp_loaded'));
80
-    }
81
-
82
-    /**
83
-     * @return EEM_Registration
84
-     * @throws InvalidArgumentException
85
-     * @throws InvalidDataTypeException
86
-     * @throws InvalidInterfaceException
87
-     * @since 4.10.2.p
88
-     */
89
-    protected function getRegistrationModel()
90
-    {
91
-        if (! $this->registration_model instanceof EEM_Registration) {
92
-            $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
93
-        }
94
-        return $this->registration_model;
95
-    }
96
-
97
-    /**
98
-     * @return EEM_Attendee
99
-     * @throws InvalidArgumentException
100
-     * @throws InvalidDataTypeException
101
-     * @throws InvalidInterfaceException
102
-     * @since 4.10.2.p
103
-     */
104
-    protected function getAttendeeModel()
105
-    {
106
-        if (! $this->attendee_model instanceof EEM_Attendee) {
107
-            $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
108
-        }
109
-        return $this->attendee_model;
110
-    }
111
-
112
-
113
-    /**
114
-     * @return EEM_Event
115
-     * @throws InvalidArgumentException
116
-     * @throws InvalidDataTypeException
117
-     * @throws InvalidInterfaceException
118
-     * @since 4.10.2.p
119
-     */
120
-    protected function getEventModel()
121
-    {
122
-        if (! $this->event_model instanceof EEM_Event) {
123
-            $this->event_model = $this->getLoader()->getShared('EEM_Event');
124
-        }
125
-        return $this->event_model;
126
-    }
127
-
128
-    /**
129
-     * @return EEM_Status
130
-     * @throws InvalidArgumentException
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidInterfaceException
133
-     * @since 4.10.2.p
134
-     */
135
-    protected function getStatusModel()
136
-    {
137
-        if (! $this->status_model instanceof EEM_Status) {
138
-            $this->status_model = $this->getLoader()->getShared('EEM_Status');
139
-        }
140
-        return $this->status_model;
141
-    }
142
-
143
-
144
-    public function wp_loaded()
145
-    {
146
-        // when adding a new registration...
147
-        $action = $this->request->getRequestParam('action');
148
-        if ($action === 'new_registration') {
149
-            EE_System::do_not_cache();
150
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
151
-                // and it's NOT the attendee information reg step
152
-                // force cookie expiration by setting time to last week
153
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
154
-                // and update the global
155
-                $_COOKIE['ee_registration_added'] = 0;
156
-            }
157
-        }
158
-    }
159
-
160
-
161
-    protected function _init_page_props()
162
-    {
163
-        $this->page_slug = REG_PG_SLUG;
164
-        $this->_admin_base_url = REG_ADMIN_URL;
165
-        $this->_admin_base_path = REG_ADMIN;
166
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
167
-        $this->_cpt_routes = array(
168
-            'add_new_attendee' => 'espresso_attendees',
169
-            'edit_attendee'    => 'espresso_attendees',
170
-            'insert_attendee'  => 'espresso_attendees',
171
-            'update_attendee'  => 'espresso_attendees',
172
-        );
173
-        $this->_cpt_model_names = array(
174
-            'add_new_attendee' => 'EEM_Attendee',
175
-            'edit_attendee'    => 'EEM_Attendee',
176
-        );
177
-        $this->_cpt_edit_routes = array(
178
-            'espresso_attendees' => 'edit_attendee',
179
-        );
180
-        $this->_pagenow_map = array(
181
-            'add_new_attendee' => 'post-new.php',
182
-            'edit_attendee'    => 'post.php',
183
-            'trash'            => 'post.php',
184
-        );
185
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
186
-        // add filters so that the comment urls don't take users to a confusing 404 page
187
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
188
-    }
189
-
190
-
191
-    public function clear_comment_link($link, $comment, $args)
192
-    {
193
-        // gotta make sure this only happens on this route
194
-        $post_type = get_post_type($comment->comment_post_ID);
195
-        if ($post_type === 'espresso_attendees') {
196
-            return '#commentsdiv';
197
-        }
198
-        return $link;
199
-    }
200
-
201
-
202
-    protected function _ajax_hooks()
203
-    {
204
-        // todo: all hooks for registrations ajax goes in here
205
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
206
-    }
207
-
208
-
209
-    protected function _define_page_props()
210
-    {
211
-        $this->_admin_page_title = $this->page_label;
212
-        $this->_labels = array(
213
-            'buttons'                      => array(
214
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
215
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
216
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
217
-                'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
218
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
219
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
220
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
221
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
222
-            ),
223
-            'publishbox'                   => array(
224
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
225
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
226
-            ),
227
-            'hide_add_button_on_cpt_route' => array(
228
-                'edit_attendee' => true,
229
-            ),
230
-        );
231
-    }
232
-
233
-
234
-    /**
235
-     *        grab url requests and route them
236
-     *
237
-     * @access private
238
-     * @return void
239
-     * @throws EE_Error
240
-     */
241
-    public function _set_page_routes()
242
-    {
243
-        $this->_get_registration_status_array();
244
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
245
-        $REG_ID = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
246
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
247
-        $ATT_ID = $this->request->getRequestParam('post', $ATT_ID, 'int');
248
-        $this->_page_routes = array(
249
-            'default'                             => array(
250
-                'func'       => '_registrations_overview_list_table',
251
-                'capability' => 'ee_read_registrations',
252
-            ),
253
-            'view_registration'                   => array(
254
-                'func'       => '_registration_details',
255
-                'capability' => 'ee_read_registration',
256
-                'obj_id'     => $REG_ID,
257
-            ),
258
-            'edit_registration'                   => array(
259
-                'func'               => '_update_attendee_registration_form',
260
-                'noheader'           => true,
261
-                'headers_sent_route' => 'view_registration',
262
-                'capability'         => 'ee_edit_registration',
263
-                'obj_id'             => $REG_ID,
264
-                '_REG_ID'            => $REG_ID,
265
-            ),
266
-            'trash_registrations'                 => array(
267
-                'func'       => '_trash_or_restore_registrations',
268
-                'args'       => array('trash' => true),
269
-                'noheader'   => true,
270
-                'capability' => 'ee_delete_registrations',
271
-            ),
272
-            'restore_registrations'               => array(
273
-                'func'       => '_trash_or_restore_registrations',
274
-                'args'       => array('trash' => false),
275
-                'noheader'   => true,
276
-                'capability' => 'ee_delete_registrations',
277
-            ),
278
-            'delete_registrations'                => array(
279
-                'func'       => '_delete_registrations',
280
-                'noheader'   => true,
281
-                'capability' => 'ee_delete_registrations',
282
-            ),
283
-            'new_registration'                    => array(
284
-                'func'       => 'new_registration',
285
-                'capability' => 'ee_edit_registrations',
286
-            ),
287
-            'process_reg_step'                    => array(
288
-                'func'       => 'process_reg_step',
289
-                'noheader'   => true,
290
-                'capability' => 'ee_edit_registrations',
291
-            ),
292
-            'redirect_to_txn'                     => array(
293
-                'func'       => 'redirect_to_txn',
294
-                'noheader'   => true,
295
-                'capability' => 'ee_edit_registrations',
296
-            ),
297
-            'change_reg_status'                   => array(
298
-                'func'       => '_change_reg_status',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registration',
301
-                'obj_id'     => $REG_ID,
302
-            ),
303
-            'approve_registration'                => array(
304
-                'func'       => 'approve_registration',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $REG_ID,
308
-            ),
309
-            'approve_and_notify_registration'     => array(
310
-                'func'       => 'approve_registration',
311
-                'noheader'   => true,
312
-                'args'       => array(true),
313
-                'capability' => 'ee_edit_registration',
314
-                'obj_id'     => $REG_ID,
315
-            ),
316
-            'approve_registrations'               => array(
317
-                'func'       => 'bulk_action_on_registrations',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_registrations',
320
-                'args'       => array('approve'),
321
-            ),
322
-            'approve_and_notify_registrations'    => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('approve', true),
327
-            ),
328
-            'decline_registration'                => array(
329
-                'func'       => 'decline_registration',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registration',
332
-                'obj_id'     => $REG_ID,
333
-            ),
334
-            'decline_and_notify_registration'     => array(
335
-                'func'       => 'decline_registration',
336
-                'noheader'   => true,
337
-                'args'       => array(true),
338
-                'capability' => 'ee_edit_registration',
339
-                'obj_id'     => $REG_ID,
340
-            ),
341
-            'decline_registrations'               => array(
342
-                'func'       => 'bulk_action_on_registrations',
343
-                'noheader'   => true,
344
-                'capability' => 'ee_edit_registrations',
345
-                'args'       => array('decline'),
346
-            ),
347
-            'decline_and_notify_registrations'    => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('decline', true),
352
-            ),
353
-            'pending_registration'                => array(
354
-                'func'       => 'pending_registration',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registration',
357
-                'obj_id'     => $REG_ID,
358
-            ),
359
-            'pending_and_notify_registration'     => array(
360
-                'func'       => 'pending_registration',
361
-                'noheader'   => true,
362
-                'args'       => array(true),
363
-                'capability' => 'ee_edit_registration',
364
-                'obj_id'     => $REG_ID,
365
-            ),
366
-            'pending_registrations'               => array(
367
-                'func'       => 'bulk_action_on_registrations',
368
-                'noheader'   => true,
369
-                'capability' => 'ee_edit_registrations',
370
-                'args'       => array('pending'),
371
-            ),
372
-            'pending_and_notify_registrations'    => array(
373
-                'func'       => 'bulk_action_on_registrations',
374
-                'noheader'   => true,
375
-                'capability' => 'ee_edit_registrations',
376
-                'args'       => array('pending', true),
377
-            ),
378
-            'no_approve_registration'             => array(
379
-                'func'       => 'not_approve_registration',
380
-                'noheader'   => true,
381
-                'capability' => 'ee_edit_registration',
382
-                'obj_id'     => $REG_ID,
383
-            ),
384
-            'no_approve_and_notify_registration'  => array(
385
-                'func'       => 'not_approve_registration',
386
-                'noheader'   => true,
387
-                'args'       => array(true),
388
-                'capability' => 'ee_edit_registration',
389
-                'obj_id'     => $REG_ID,
390
-            ),
391
-            'no_approve_registrations'            => array(
392
-                'func'       => 'bulk_action_on_registrations',
393
-                'noheader'   => true,
394
-                'capability' => 'ee_edit_registrations',
395
-                'args'       => array('not_approve'),
396
-            ),
397
-            'no_approve_and_notify_registrations' => array(
398
-                'func'       => 'bulk_action_on_registrations',
399
-                'noheader'   => true,
400
-                'capability' => 'ee_edit_registrations',
401
-                'args'       => array('not_approve', true),
402
-            ),
403
-            'cancel_registration'                 => array(
404
-                'func'       => 'cancel_registration',
405
-                'noheader'   => true,
406
-                'capability' => 'ee_edit_registration',
407
-                'obj_id'     => $REG_ID,
408
-            ),
409
-            'cancel_and_notify_registration'      => array(
410
-                'func'       => 'cancel_registration',
411
-                'noheader'   => true,
412
-                'args'       => array(true),
413
-                'capability' => 'ee_edit_registration',
414
-                'obj_id'     => $REG_ID,
415
-            ),
416
-            'cancel_registrations'                => array(
417
-                'func'       => 'bulk_action_on_registrations',
418
-                'noheader'   => true,
419
-                'capability' => 'ee_edit_registrations',
420
-                'args'       => array('cancel'),
421
-            ),
422
-            'cancel_and_notify_registrations'     => array(
423
-                'func'       => 'bulk_action_on_registrations',
424
-                'noheader'   => true,
425
-                'capability' => 'ee_edit_registrations',
426
-                'args'       => array('cancel', true),
427
-            ),
428
-            'wait_list_registration'              => array(
429
-                'func'       => 'wait_list_registration',
430
-                'noheader'   => true,
431
-                'capability' => 'ee_edit_registration',
432
-                'obj_id'     => $REG_ID,
433
-            ),
434
-            'wait_list_and_notify_registration'   => array(
435
-                'func'       => 'wait_list_registration',
436
-                'noheader'   => true,
437
-                'args'       => array(true),
438
-                'capability' => 'ee_edit_registration',
439
-                'obj_id'     => $REG_ID,
440
-            ),
441
-            'contact_list'                        => array(
442
-                'func'       => '_attendee_contact_list_table',
443
-                'capability' => 'ee_read_contacts',
444
-            ),
445
-            'add_new_attendee'                    => array(
446
-                'func' => '_create_new_cpt_item',
447
-                'args' => array(
448
-                    'new_attendee' => true,
449
-                    'capability'   => 'ee_edit_contacts',
450
-                ),
451
-            ),
452
-            'edit_attendee'                       => array(
453
-                'func'       => '_edit_cpt_item',
454
-                'capability' => 'ee_edit_contacts',
455
-                'obj_id'     => $ATT_ID,
456
-            ),
457
-            'duplicate_attendee'                  => array(
458
-                'func'       => '_duplicate_attendee',
459
-                'noheader'   => true,
460
-                'capability' => 'ee_edit_contacts',
461
-                'obj_id'     => $ATT_ID,
462
-            ),
463
-            'insert_attendee'                     => array(
464
-                'func'       => '_insert_or_update_attendee',
465
-                'args'       => array(
466
-                    'new_attendee' => true,
467
-                ),
468
-                'noheader'   => true,
469
-                'capability' => 'ee_edit_contacts',
470
-            ),
471
-            'update_attendee'                     => array(
472
-                'func'       => '_insert_or_update_attendee',
473
-                'args'       => array(
474
-                    'new_attendee' => false,
475
-                ),
476
-                'noheader'   => true,
477
-                'capability' => 'ee_edit_contacts',
478
-                'obj_id'     => $ATT_ID,
479
-            ),
480
-            'trash_attendees'                     => array(
481
-                'func'       => '_trash_or_restore_attendees',
482
-                'args'       => array(
483
-                    'trash' => 'true',
484
-                ),
485
-                'noheader'   => true,
486
-                'capability' => 'ee_delete_contacts',
487
-            ),
488
-            'trash_attendee'                      => array(
489
-                'func'       => '_trash_or_restore_attendees',
490
-                'args'       => array(
491
-                    'trash' => true,
492
-                ),
493
-                'noheader'   => true,
494
-                'capability' => 'ee_delete_contacts',
495
-                'obj_id'     => $ATT_ID,
496
-            ),
497
-            'restore_attendees'                   => array(
498
-                'func'       => '_trash_or_restore_attendees',
499
-                'args'       => array(
500
-                    'trash' => false,
501
-                ),
502
-                'noheader'   => true,
503
-                'capability' => 'ee_delete_contacts',
504
-                'obj_id'     => $ATT_ID,
505
-            ),
506
-            'resend_registration'                 => array(
507
-                'func'       => '_resend_registration',
508
-                'noheader'   => true,
509
-                'capability' => 'ee_send_message',
510
-            ),
511
-            'registrations_report'                => array(
512
-                'func'       => '_registrations_report',
513
-                'noheader'   => true,
514
-                'capability' => 'ee_read_registrations',
515
-            ),
516
-            'contact_list_export'                 => array(
517
-                'func'       => '_contact_list_export',
518
-                'noheader'   => true,
519
-                'capability' => 'export',
520
-            ),
521
-            'contact_list_report'                 => array(
522
-                'func'       => '_contact_list_report',
523
-                'noheader'   => true,
524
-                'capability' => 'ee_read_contacts',
525
-            ),
526
-        );
527
-    }
528
-
529
-
530
-    protected function _set_page_config()
531
-    {
532
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
533
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
534
-        $this->_page_config = array(
535
-            'default'           => array(
536
-                'nav'           => array(
537
-                    'label' => esc_html__('Overview', 'event_espresso'),
538
-                    'order' => 5,
539
-                ),
540
-                'help_tabs'     => array(
541
-                    'registrations_overview_help_tab'                       => array(
542
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
543
-                        'filename' => 'registrations_overview',
544
-                    ),
545
-                    'registrations_overview_table_column_headings_help_tab' => array(
546
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
547
-                        'filename' => 'registrations_overview_table_column_headings',
548
-                    ),
549
-                    'registrations_overview_filters_help_tab'               => array(
550
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
551
-                        'filename' => 'registrations_overview_filters',
552
-                    ),
553
-                    'registrations_overview_views_help_tab'                 => array(
554
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
555
-                        'filename' => 'registrations_overview_views',
556
-                    ),
557
-                    'registrations_regoverview_other_help_tab'              => array(
558
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
559
-                        'filename' => 'registrations_overview_other',
560
-                    ),
561
-                ),
562
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
563
-                // 'help_tour'     => array('Registration_Overview_Help_Tour'),
564
-                'qtips'         => array('Registration_List_Table_Tips'),
565
-                'list_table'    => 'EE_Registrations_List_Table',
566
-                'require_nonce' => false,
567
-            ),
568
-            'view_registration' => array(
569
-                'nav'           => array(
570
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
571
-                    'order'      => 15,
572
-                    'url'        => $REG_ID
573
-                        ? add_query_arg(array('_REG_ID' => $REG_ID), $this->_current_page_view_url)
574
-                        : $this->_admin_base_url,
575
-                    'persistent' => false,
576
-                ),
577
-                'help_tabs'     => array(
578
-                    'registrations_details_help_tab'                    => array(
579
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
580
-                        'filename' => 'registrations_details',
581
-                    ),
582
-                    'registrations_details_table_help_tab'              => array(
583
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
584
-                        'filename' => 'registrations_details_table',
585
-                    ),
586
-                    'registrations_details_form_answers_help_tab'       => array(
587
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
588
-                        'filename' => 'registrations_details_form_answers',
589
-                    ),
590
-                    'registrations_details_registrant_details_help_tab' => array(
591
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
592
-                        'filename' => 'registrations_details_registrant_details',
593
-                    ),
594
-                ),
595
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
596
-                // 'help_tour'     => array('Registration_Details_Help_Tour'),
597
-                'metaboxes'     => array_merge(
598
-                    $this->_default_espresso_metaboxes,
599
-                    array('_registration_details_metaboxes')
600
-                ),
601
-                'require_nonce' => false,
602
-            ),
603
-            'new_registration'  => array(
604
-                'nav'           => array(
605
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
606
-                    'url'        => '#',
607
-                    'order'      => 15,
608
-                    'persistent' => false,
609
-                ),
610
-                'metaboxes'     => $this->_default_espresso_metaboxes,
611
-                'labels'        => array(
612
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
613
-                ),
614
-                'require_nonce' => false,
615
-            ),
616
-            'add_new_attendee'  => array(
617
-                'nav'           => array(
618
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
619
-                    'order'      => 15,
620
-                    'persistent' => false,
621
-                ),
622
-                'metaboxes'     => array_merge(
623
-                    $this->_default_espresso_metaboxes,
624
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
625
-                ),
626
-                'require_nonce' => false,
627
-            ),
628
-            'edit_attendee'     => array(
629
-                'nav'           => array(
630
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
631
-                    'order'      => 15,
632
-                    'persistent' => false,
633
-                    'url'        => $ATT_ID
634
-                        ? add_query_arg(array('ATT_ID' => $ATT_ID), $this->_current_page_view_url)
635
-                        : $this->_admin_base_url,
636
-                ),
637
-                'metaboxes'     => array('attendee_editor_metaboxes'),
638
-                'require_nonce' => false,
639
-            ),
640
-            'contact_list'      => array(
641
-                'nav'           => array(
642
-                    'label' => esc_html__('Contact List', 'event_espresso'),
643
-                    'order' => 20,
644
-                ),
645
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
646
-                'help_tabs'     => array(
647
-                    'registrations_contact_list_help_tab'                       => array(
648
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
649
-                        'filename' => 'registrations_contact_list',
650
-                    ),
651
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
652
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
653
-                        'filename' => 'registrations_contact_list_table_column_headings',
654
-                    ),
655
-                    'registrations_contact_list_views_help_tab'                 => array(
656
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
657
-                        'filename' => 'registrations_contact_list_views',
658
-                    ),
659
-                    'registrations_contact_list_other_help_tab'                 => array(
660
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
661
-                        'filename' => 'registrations_contact_list_other',
662
-                    ),
663
-                ),
664
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
665
-                // 'help_tour'     => array('Contact_List_Help_Tour'),
666
-                'metaboxes'     => array(),
667
-                'require_nonce' => false,
668
-            ),
669
-            // override default cpt routes
670
-            'create_new'        => '',
671
-            'edit'              => '',
672
-        );
673
-    }
674
-
675
-
676
-    /**
677
-     * The below methods aren't used by this class currently
678
-     */
679
-    protected function _add_screen_options()
680
-    {
681
-    }
682
-
683
-
684
-    protected function _add_feature_pointers()
685
-    {
686
-    }
687
-
688
-
689
-    public function admin_init()
690
-    {
691
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
692
-            'click "Update Registration Questions" to save your changes',
693
-            'event_espresso'
694
-        );
695
-    }
696
-
697
-
698
-    public function admin_notices()
699
-    {
700
-    }
701
-
702
-
703
-    public function admin_footer_scripts()
704
-    {
705
-    }
706
-
707
-
708
-    /**
709
-     *        get list of registration statuses
710
-     *
711
-     * @access private
712
-     * @return void
713
-     * @throws EE_Error
714
-     */
715
-    private function _get_registration_status_array()
716
-    {
717
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
718
-    }
719
-
720
-
721
-    /**
722
-     * @throws InvalidArgumentException
723
-     * @throws InvalidDataTypeException
724
-     * @throws InvalidInterfaceException
725
-     * @since 4.10.2.p
726
-     */
727
-    protected function _add_screen_options_default()
728
-    {
729
-        $this->_per_page_screen_option();
730
-    }
731
-
732
-
733
-    /**
734
-     * @throws InvalidArgumentException
735
-     * @throws InvalidDataTypeException
736
-     * @throws InvalidInterfaceException
737
-     * @since 4.10.2.p
738
-     */
739
-    protected function _add_screen_options_contact_list()
740
-    {
741
-        $page_title = $this->_admin_page_title;
742
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
743
-        $this->_per_page_screen_option();
744
-        $this->_admin_page_title = $page_title;
745
-    }
746
-
747
-
748
-    public function load_scripts_styles()
749
-    {
750
-        // style
751
-        wp_register_style(
752
-            'espresso_reg',
753
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
754
-            array('ee-admin-css'),
755
-            EVENT_ESPRESSO_VERSION
756
-        );
757
-        wp_enqueue_style('espresso_reg');
758
-        // script
759
-        wp_register_script(
760
-            'espresso_reg',
761
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
762
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
763
-            EVENT_ESPRESSO_VERSION,
764
-            true
765
-        );
766
-        wp_enqueue_script('espresso_reg');
767
-    }
768
-
769
-
770
-    /**
771
-     * @throws EE_Error
772
-     * @throws InvalidArgumentException
773
-     * @throws InvalidDataTypeException
774
-     * @throws InvalidInterfaceException
775
-     * @throws ReflectionException
776
-     * @since 4.10.2.p
777
-     */
778
-    public function load_scripts_styles_edit_attendee()
779
-    {
780
-        // stuff to only show up on our attendee edit details page.
781
-        $attendee_details_translations = array(
782
-            'att_publish_text' => sprintf(
783
-                /* translators: The date and time */
784
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
785
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
786
-            ),
787
-        );
788
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
789
-        wp_enqueue_script('jquery-validate');
790
-    }
791
-
792
-
793
-    /**
794
-     * @throws EE_Error
795
-     * @throws InvalidArgumentException
796
-     * @throws InvalidDataTypeException
797
-     * @throws InvalidInterfaceException
798
-     * @throws ReflectionException
799
-     * @since 4.10.2.p
800
-     */
801
-    public function load_scripts_styles_view_registration()
802
-    {
803
-        // styles
804
-        wp_enqueue_style('espresso-ui-theme');
805
-        // scripts
806
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
807
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
808
-    }
809
-
810
-
811
-    public function load_scripts_styles_contact_list()
812
-    {
813
-        wp_dequeue_style('espresso_reg');
814
-        wp_register_style(
815
-            'espresso_att',
816
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
817
-            array('ee-admin-css'),
818
-            EVENT_ESPRESSO_VERSION
819
-        );
820
-        wp_enqueue_style('espresso_att');
821
-    }
822
-
823
-
824
-    public function load_scripts_styles_new_registration()
825
-    {
826
-        wp_register_script(
827
-            'ee-spco-for-admin',
828
-            REG_ASSETS_URL . 'spco_for_admin.js',
829
-            array('underscore', 'jquery'),
830
-            EVENT_ESPRESSO_VERSION,
831
-            true
832
-        );
833
-        wp_enqueue_script('ee-spco-for-admin');
834
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
835
-        EE_Form_Section_Proper::wp_enqueue_scripts();
836
-        EED_Ticket_Selector::load_tckt_slctr_assets();
837
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
838
-    }
839
-
840
-
841
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
842
-    {
843
-        add_filter('FHEE_load_EE_messages', '__return_true');
844
-    }
845
-
846
-
847
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
848
-    {
849
-        add_filter('FHEE_load_EE_messages', '__return_true');
850
-    }
851
-
852
-
853
-    /**
854
-     * @throws EE_Error
855
-     * @throws InvalidArgumentException
856
-     * @throws InvalidDataTypeException
857
-     * @throws InvalidInterfaceException
858
-     * @throws ReflectionException
859
-     * @since 4.10.2.p
860
-     */
861
-    protected function _set_list_table_views_default()
862
-    {
863
-        // for notification related bulk actions we need to make sure only active messengers have an option.
864
-        EED_Messages::set_autoloaders();
865
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
866
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
867
-        $active_mts = $message_resource_manager->list_of_active_message_types();
868
-        // key= bulk_action_slug, value= message type.
869
-        $match_array = array(
870
-            'approve_registrations'    => 'registration',
871
-            'decline_registrations'    => 'declined_registration',
872
-            'pending_registrations'    => 'pending_approval',
873
-            'no_approve_registrations' => 'not_approved_registration',
874
-            'cancel_registrations'     => 'cancelled_registration',
875
-        );
876
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
877
-            'ee_send_message',
878
-            'batch_send_messages'
879
-        );
880
-        /** setup reg status bulk actions **/
881
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
882
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
883
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
884
-                'Approve and Notify Registrations',
885
-                'event_espresso'
886
-            );
887
-        }
888
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
889
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
890
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
891
-                'Decline and Notify Registrations',
892
-                'event_espresso'
893
-            );
894
-        }
895
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
896
-            'Set Registrations to Pending Payment',
897
-            'event_espresso'
898
-        );
899
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
900
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
901
-                'Set Registrations to Pending Payment and Notify',
902
-                'event_espresso'
903
-            );
904
-        }
905
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
906
-            'Set Registrations to Not Approved',
907
-            'event_espresso'
908
-        );
909
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
910
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
911
-                'Set Registrations to Not Approved and Notify',
912
-                'event_espresso'
913
-            );
914
-        }
915
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
916
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
917
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
918
-                'Cancel Registrations and Notify',
919
-                'event_espresso'
920
-            );
921
-        }
922
-        $def_reg_status_actions = apply_filters(
923
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
924
-            $def_reg_status_actions,
925
-            $active_mts,
926
-            $can_send
927
-        );
928
-
929
-        $this->_views = array(
930
-            'all'   => array(
931
-                'slug'        => 'all',
932
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
933
-                'count'       => 0,
934
-                'bulk_action' => array_merge(
935
-                    $def_reg_status_actions,
936
-                    array(
937
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
938
-                    )
939
-                ),
940
-            ),
941
-            'month' => array(
942
-                'slug'        => 'month',
943
-                'label'       => esc_html__('This Month', 'event_espresso'),
944
-                'count'       => 0,
945
-                'bulk_action' => array_merge(
946
-                    $def_reg_status_actions,
947
-                    array(
948
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
949
-                    )
950
-                ),
951
-            ),
952
-            'today' => array(
953
-                'slug'        => 'today',
954
-                'label'       => sprintf(
955
-                    esc_html__('Today - %s', 'event_espresso'),
956
-                    date('M d, Y', current_time('timestamp'))
957
-                ),
958
-                'count'       => 0,
959
-                'bulk_action' => array_merge(
960
-                    $def_reg_status_actions,
961
-                    array(
962
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
963
-                    )
964
-                ),
965
-            ),
966
-        );
967
-        if (
968
-            EE_Registry::instance()->CAP->current_user_can(
969
-                'ee_delete_registrations',
970
-                'espresso_registrations_delete_registration'
971
-            )
972
-        ) {
973
-            $this->_views['incomplete'] = array(
974
-                'slug'        => 'incomplete',
975
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
976
-                'count'       => 0,
977
-                'bulk_action' => array(
978
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
979
-                ),
980
-            );
981
-            $this->_views['trash'] = array(
982
-                'slug'        => 'trash',
983
-                'label'       => esc_html__('Trash', 'event_espresso'),
984
-                'count'       => 0,
985
-                'bulk_action' => array(
986
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
987
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
988
-                ),
989
-            );
990
-        }
991
-    }
992
-
993
-
994
-    protected function _set_list_table_views_contact_list()
995
-    {
996
-        $this->_views = array(
997
-            'in_use' => array(
998
-                'slug'        => 'in_use',
999
-                'label'       => esc_html__('In Use', 'event_espresso'),
1000
-                'count'       => 0,
1001
-                'bulk_action' => array(
1002
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1003
-                ),
1004
-            ),
1005
-        );
1006
-        if (
1007
-            EE_Registry::instance()->CAP->current_user_can(
1008
-                'ee_delete_contacts',
1009
-                'espresso_registrations_trash_attendees'
1010
-            )
1011
-        ) {
1012
-            $this->_views['trash'] = array(
1013
-                'slug'        => 'trash',
1014
-                'label'       => esc_html__('Trash', 'event_espresso'),
1015
-                'count'       => 0,
1016
-                'bulk_action' => array(
1017
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1018
-                ),
1019
-            );
1020
-        }
1021
-    }
1022
-
1023
-
1024
-    protected function _registration_legend_items()
1025
-    {
1026
-        $fc_items = array(
1027
-            'star-icon'        => array(
1028
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1029
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1030
-            ),
1031
-            'view_details'     => array(
1032
-                'class' => 'dashicons dashicons-clipboard',
1033
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1034
-            ),
1035
-            'edit_attendee'    => array(
1036
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1037
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1038
-            ),
1039
-            'view_transaction' => array(
1040
-                'class' => 'dashicons dashicons-cart',
1041
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1042
-            ),
1043
-            'view_invoice'     => array(
1044
-                'class' => 'dashicons dashicons-media-spreadsheet',
1045
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1046
-            ),
1047
-        );
1048
-        if (
1049
-            EE_Registry::instance()->CAP->current_user_can(
1050
-                'ee_send_message',
1051
-                'espresso_registrations_resend_registration'
1052
-            )
1053
-        ) {
1054
-            $fc_items['resend_registration'] = array(
1055
-                'class' => 'dashicons dashicons-email-alt',
1056
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1057
-            );
1058
-        } else {
1059
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
1060
-        }
1061
-        if (
1062
-            EE_Registry::instance()->CAP->current_user_can(
1063
-                'ee_read_global_messages',
1064
-                'view_filtered_messages'
1065
-            )
1066
-        ) {
1067
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1068
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1069
-                $fc_items['view_related_messages'] = array(
1070
-                    'class' => $related_for_icon['css_class'],
1071
-                    'desc'  => $related_for_icon['label'],
1072
-                );
1073
-            }
1074
-        }
1075
-        $sc_items = array(
1076
-            'approved_status'   => array(
1077
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1078
-                'desc'  => EEH_Template::pretty_status(
1079
-                    EEM_Registration::status_id_approved,
1080
-                    false,
1081
-                    'sentence'
1082
-                ),
1083
-            ),
1084
-            'pending_status'    => array(
1085
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1086
-                'desc'  => EEH_Template::pretty_status(
1087
-                    EEM_Registration::status_id_pending_payment,
1088
-                    false,
1089
-                    'sentence'
1090
-                ),
1091
-            ),
1092
-            'wait_list'         => array(
1093
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1094
-                'desc'  => EEH_Template::pretty_status(
1095
-                    EEM_Registration::status_id_wait_list,
1096
-                    false,
1097
-                    'sentence'
1098
-                ),
1099
-            ),
1100
-            'incomplete_status' => array(
1101
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1102
-                'desc'  => EEH_Template::pretty_status(
1103
-                    EEM_Registration::status_id_incomplete,
1104
-                    false,
1105
-                    'sentence'
1106
-                ),
1107
-            ),
1108
-            'not_approved'      => array(
1109
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1110
-                'desc'  => EEH_Template::pretty_status(
1111
-                    EEM_Registration::status_id_not_approved,
1112
-                    false,
1113
-                    'sentence'
1114
-                ),
1115
-            ),
1116
-            'declined_status'   => array(
1117
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1118
-                'desc'  => EEH_Template::pretty_status(
1119
-                    EEM_Registration::status_id_declined,
1120
-                    false,
1121
-                    'sentence'
1122
-                ),
1123
-            ),
1124
-            'cancelled_status'  => array(
1125
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1126
-                'desc'  => EEH_Template::pretty_status(
1127
-                    EEM_Registration::status_id_cancelled,
1128
-                    false,
1129
-                    'sentence'
1130
-                ),
1131
-            ),
1132
-        );
1133
-        return array_merge($fc_items, $sc_items);
1134
-    }
1135
-
1136
-
1137
-
1138
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1139
-
1140
-
1141
-
1142
-    /**
1143
-     * @throws DomainException
1144
-     * @throws EE_Error
1145
-     * @throws InvalidArgumentException
1146
-     * @throws InvalidDataTypeException
1147
-     * @throws InvalidInterfaceException
1148
-     * @throws ReflectionException
1149
-     */
1150
-    protected function _registrations_overview_list_table()
1151
-    {
1152
-        $this->appendAddNewRegistrationButtonToPageTitle();
1153
-        $header_text = '';
1154
-        $admin_page_header_decorators = [
1155
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1156
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1157
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1158
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1159
-        ];
1160
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1161
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1162
-            $header_text = $filter_header_decorator->getHeaderText($header_text);
1163
-        }
1164
-        $this->_template_args['admin_page_header'] = $header_text;
1165
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1166
-        $this->display_admin_list_table_page_with_no_sidebar();
1167
-    }
1168
-
1169
-
1170
-    /**
1171
-     * @throws EE_Error
1172
-     * @throws InvalidArgumentException
1173
-     * @throws InvalidDataTypeException
1174
-     * @throws InvalidInterfaceException
1175
-     */
1176
-    private function appendAddNewRegistrationButtonToPageTitle()
1177
-    {
1178
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1179
-        if (
1180
-            $EVT_ID
1181
-            && EE_Registry::instance()->CAP->current_user_can(
1182
-                'ee_edit_registrations',
1183
-                'espresso_registrations_new_registration',
1184
-                $EVT_ID
1185
-            )
1186
-        ) {
1187
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1188
-                'new_registration',
1189
-                'add-registrant',
1190
-                array('event_id' => $EVT_ID),
1191
-                'add-new-h2'
1192
-            );
1193
-        }
1194
-    }
1195
-
1196
-
1197
-    /**
1198
-     * This sets the _registration property for the registration details screen
1199
-     *
1200
-     * @access private
1201
-     * @return bool
1202
-     * @throws EE_Error
1203
-     * @throws InvalidArgumentException
1204
-     * @throws InvalidDataTypeException
1205
-     * @throws InvalidInterfaceException
1206
-     */
1207
-    private function _set_registration_object()
1208
-    {
1209
-        // get out if we've already set the object
1210
-        if ($this->_registration instanceof EE_Registration) {
1211
-            return true;
1212
-        }
1213
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1214
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1215
-            return true;
1216
-        }
1217
-        $error_msg = sprintf(
1218
-            esc_html__(
1219
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1220
-                'event_espresso'
1221
-            ),
1222
-            $REG_ID
1223
-        );
1224
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1225
-        $this->_registration = null;
1226
-        return false;
1227
-    }
1228
-
1229
-
1230
-    /**
1231
-     * Used to retrieve registrations for the list table.
1232
-     *
1233
-     * @param int  $per_page
1234
-     * @param bool $count
1235
-     * @param bool $this_month
1236
-     * @param bool $today
1237
-     * @return EE_Registration[]|int
1238
-     * @throws EE_Error
1239
-     * @throws InvalidArgumentException
1240
-     * @throws InvalidDataTypeException
1241
-     * @throws InvalidInterfaceException
1242
-     */
1243
-    public function get_registrations(
1244
-        $per_page = 10,
1245
-        $count = false,
1246
-        $this_month = false,
1247
-        $today = false
1248
-    ) {
1249
-        if ($this_month) {
1250
-            $this->request->setRequestParam('status', 'month');
1251
-        }
1252
-        if ($today) {
1253
-            $this->request->setRequestParam('status', 'today');
1254
-        }
1255
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1256
-        /**
1257
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1258
-         *
1259
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1260
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1261
-         *                             or if you have the development copy of EE you can view this at the path:
1262
-         *                             /docs/G--Model-System/model-query-params.md
1263
-         */
1264
-        $query_params['group_by'] = '';
1265
-
1266
-        return $count
1267
-            ? $this->getRegistrationModel()->count($query_params)
1268
-            /** @type EE_Registration[] */
1269
-            : $this->getRegistrationModel()->get_all($query_params);
1270
-    }
1271
-
1272
-
1273
-    /**
1274
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1275
-     * Note: this listens to values on the request for some of the query parameters.
1276
-     *
1277
-     * @param array $request
1278
-     * @param int   $per_page
1279
-     * @param bool  $count
1280
-     * @return array
1281
-     * @throws EE_Error
1282
-     * @throws InvalidArgumentException
1283
-     * @throws InvalidDataTypeException
1284
-     * @throws InvalidInterfaceException
1285
-     */
1286
-    protected function _get_registration_query_parameters(
1287
-        $request = array(),
1288
-        $per_page = 10,
1289
-        $count = false
1290
-    ) {
1291
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1292
-        $list_table_query_builder = $this->getLoader()->getNew(
1293
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1294
-            [ null, null, $request ]
1295
-        );
1296
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1297
-    }
1298
-
1299
-
1300
-    public function get_registration_status_array()
1301
-    {
1302
-        return self::$_reg_status;
1303
-    }
1304
-
1305
-
1306
-
1307
-
1308
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1309
-    /**
1310
-     *        generates HTML for the View Registration Details Admin page
1311
-     *
1312
-     * @access protected
1313
-     * @return void
1314
-     * @throws DomainException
1315
-     * @throws EE_Error
1316
-     * @throws InvalidArgumentException
1317
-     * @throws InvalidDataTypeException
1318
-     * @throws InvalidInterfaceException
1319
-     * @throws EntityNotFoundException
1320
-     * @throws ReflectionException
1321
-     */
1322
-    protected function _registration_details()
1323
-    {
1324
-        $this->_template_args = array();
1325
-        $this->_set_registration_object();
1326
-        if (is_object($this->_registration)) {
1327
-            $transaction = $this->_registration->transaction()
1328
-                ? $this->_registration->transaction()
1329
-                : EE_Transaction::new_instance();
1330
-            $this->_session = $transaction->session_data();
1331
-            $event_id = $this->_registration->event_ID();
1332
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1333
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1334
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1335
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1336
-            $this->_template_args['grand_total'] = $transaction->total();
1337
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1338
-            // link back to overview
1339
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1340
-            $this->_template_args['registration'] = $this->_registration;
1341
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1342
-                array(
1343
-                    'action'   => 'default',
1344
-                    'event_id' => $event_id,
1345
-                ),
1346
-                REG_ADMIN_URL
1347
-            );
1348
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1349
-                array(
1350
-                    'action' => 'default',
1351
-                    'EVT_ID' => $event_id,
1352
-                    'page'   => 'espresso_transactions',
1353
-                ),
1354
-                admin_url('admin.php')
1355
-            );
1356
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1357
-                array(
1358
-                    'page'   => 'espresso_events',
1359
-                    'action' => 'edit',
1360
-                    'post'   => $event_id,
1361
-                ),
1362
-                admin_url('admin.php')
1363
-            );
1364
-            // next and previous links
1365
-            $next_reg = $this->_registration->next(
1366
-                null,
1367
-                array(),
1368
-                'REG_ID'
1369
-            );
1370
-            $this->_template_args['next_registration'] = $next_reg
1371
-                ? $this->_next_link(
1372
-                    EE_Admin_Page::add_query_args_and_nonce(
1373
-                        array(
1374
-                            'action'  => 'view_registration',
1375
-                            '_REG_ID' => $next_reg['REG_ID'],
1376
-                        ),
1377
-                        REG_ADMIN_URL
1378
-                    ),
1379
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1380
-                )
1381
-                : '';
1382
-            $previous_reg = $this->_registration->previous(
1383
-                null,
1384
-                array(),
1385
-                'REG_ID'
1386
-            );
1387
-            $this->_template_args['previous_registration'] = $previous_reg
1388
-                ? $this->_previous_link(
1389
-                    EE_Admin_Page::add_query_args_and_nonce(
1390
-                        array(
1391
-                            'action'  => 'view_registration',
1392
-                            '_REG_ID' => $previous_reg['REG_ID'],
1393
-                        ),
1394
-                        REG_ADMIN_URL
1395
-                    ),
1396
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1397
-                )
1398
-                : '';
1399
-            // grab header
1400
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1401
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1402
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1403
-                $template_path,
1404
-                $this->_template_args,
1405
-                true
1406
-            );
1407
-        } else {
1408
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1409
-        }
1410
-        // the details template wrapper
1411
-        $this->display_admin_page_with_sidebar();
1412
-    }
1413
-
1414
-
1415
-    /**
1416
-     * @throws EE_Error
1417
-     * @throws InvalidArgumentException
1418
-     * @throws InvalidDataTypeException
1419
-     * @throws InvalidInterfaceException
1420
-     * @throws ReflectionException
1421
-     * @since 4.10.2.p
1422
-     */
1423
-    protected function _registration_details_metaboxes()
1424
-    {
1425
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1426
-        $this->_set_registration_object();
1427
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1428
-        add_meta_box(
1429
-            'edit-reg-status-mbox',
1430
-            esc_html__('Registration Status', 'event_espresso'),
1431
-            array($this, 'set_reg_status_buttons_metabox'),
1432
-            $this->wp_page_slug,
1433
-            'normal',
1434
-            'high'
1435
-        );
1436
-        add_meta_box(
1437
-            'edit-reg-details-mbox',
1438
-            esc_html__('Registration Details', 'event_espresso'),
1439
-            array($this, '_reg_details_meta_box'),
1440
-            $this->wp_page_slug,
1441
-            'normal',
1442
-            'high'
1443
-        );
1444
-        if (
1445
-            $attendee instanceof EE_Attendee
1446
-            && EE_Registry::instance()->CAP->current_user_can(
1447
-                'ee_read_registration',
1448
-                'edit-reg-questions-mbox',
1449
-                $this->_registration->ID()
1450
-            )
1451
-        ) {
1452
-            add_meta_box(
1453
-                'edit-reg-questions-mbox',
1454
-                esc_html__('Registration Form Answers', 'event_espresso'),
1455
-                array($this, '_reg_questions_meta_box'),
1456
-                $this->wp_page_slug,
1457
-                'normal',
1458
-                'high'
1459
-            );
1460
-        }
1461
-        add_meta_box(
1462
-            'edit-reg-registrant-mbox',
1463
-            esc_html__('Contact Details', 'event_espresso'),
1464
-            array($this, '_reg_registrant_side_meta_box'),
1465
-            $this->wp_page_slug,
1466
-            'side',
1467
-            'high'
1468
-        );
1469
-        if ($this->_registration->group_size() > 1) {
1470
-            add_meta_box(
1471
-                'edit-reg-attendees-mbox',
1472
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1473
-                array($this, '_reg_attendees_meta_box'),
1474
-                $this->wp_page_slug,
1475
-                'normal',
1476
-                'high'
1477
-            );
1478
-        }
1479
-    }
1480
-
1481
-
1482
-    /**
1483
-     * set_reg_status_buttons_metabox
1484
-     *
1485
-     * @access protected
1486
-     * @return void
1487
-     * @throws EE_Error
1488
-     * @throws EntityNotFoundException
1489
-     * @throws InvalidArgumentException
1490
-     * @throws InvalidDataTypeException
1491
-     * @throws InvalidInterfaceException
1492
-     * @throws ReflectionException
1493
-     */
1494
-    public function set_reg_status_buttons_metabox()
1495
-    {
1496
-        $this->_set_registration_object();
1497
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1498
-        $output = $change_reg_status_form->form_open(
1499
-            self::add_query_args_and_nonce(
1500
-                array(
1501
-                    'action' => 'change_reg_status',
1502
-                ),
1503
-                REG_ADMIN_URL
1504
-            )
1505
-        );
1506
-        $output .= $change_reg_status_form->get_html();
1507
-        $output .= $change_reg_status_form->form_close();
1508
-        echo $output; // already escaped
1509
-    }
1510
-
1511
-
1512
-    /**
1513
-     * @return EE_Form_Section_Proper
1514
-     * @throws EE_Error
1515
-     * @throws InvalidArgumentException
1516
-     * @throws InvalidDataTypeException
1517
-     * @throws InvalidInterfaceException
1518
-     * @throws EntityNotFoundException
1519
-     * @throws ReflectionException
1520
-     */
1521
-    protected function _generate_reg_status_change_form()
1522
-    {
1523
-        $reg_status_change_form_array = array(
1524
-            'name'            => 'reg_status_change_form',
1525
-            'html_id'         => 'reg-status-change-form',
1526
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1527
-            'subsections'     => array(
1528
-                'return'             => new EE_Hidden_Input(
1529
-                    array(
1530
-                        'name'    => 'return',
1531
-                        'default' => 'view_registration',
1532
-                    )
1533
-                ),
1534
-                'REG_ID'             => new EE_Hidden_Input(
1535
-                    array(
1536
-                        'name'    => 'REG_ID',
1537
-                        'default' => $this->_registration->ID(),
1538
-                    )
1539
-                ),
1540
-                'current_status'     => new EE_Form_Section_HTML(
1541
-                    EEH_HTML::table(
1542
-                        EEH_HTML::tr(
1543
-                            EEH_HTML::th(
1544
-                                EEH_HTML::label(
1545
-                                    EEH_HTML::strong(
1546
-                                        esc_html__('Current Registration Status', 'event_espresso')
1547
-                                    )
1548
-                                )
1549
-                            )
1550
-                            . EEH_HTML::td(
1551
-                                EEH_HTML::strong(
1552
-                                    $this->_registration->pretty_status(),
1553
-                                    '',
1554
-                                    'status-' . $this->_registration->status_ID(),
1555
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1556
-                                )
1557
-                            )
1558
-                        )
1559
-                    )
1560
-                )
1561
-            )
1562
-        );
1563
-        if (
1564
-            EE_Registry::instance()->CAP->current_user_can(
1565
-                'ee_edit_registration',
1566
-                'toggle_registration_status',
1567
-                $this->_registration->ID()
1568
-            )
1569
-        ) {
1570
-            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1571
-                $this->_get_reg_statuses(),
1572
-                array(
1573
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1574
-                    'default'         => $this->_registration->status_ID(),
1575
-                )
1576
-            );
1577
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1578
-                array(
1579
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1580
-                    'default'         => false,
1581
-                    'html_help_text'  => esc_html__(
1582
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1583
-                        'event_espresso'
1584
-                    )
1585
-                )
1586
-            );
1587
-            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1588
-                array(
1589
-                    'html_class'      => 'button-primary',
1590
-                    'html_label_text' => '&nbsp;',
1591
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1592
-                )
1593
-            );
1594
-        }
1595
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1596
-    }
1597
-
1598
-
1599
-    /**
1600
-     * Returns an array of all the buttons for the various statuses and switch status actions
1601
-     *
1602
-     * @return array
1603
-     * @throws EE_Error
1604
-     * @throws InvalidArgumentException
1605
-     * @throws InvalidDataTypeException
1606
-     * @throws InvalidInterfaceException
1607
-     * @throws EntityNotFoundException
1608
-     */
1609
-    protected function _get_reg_statuses()
1610
-    {
1611
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1612
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1613
-        // get current reg status
1614
-        $current_status = $this->_registration->status_ID();
1615
-        // is registration for free event? This will determine whether to display the pending payment option
1616
-        if (
1617
-            $current_status !== EEM_Registration::status_id_pending_payment
1618
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1619
-        ) {
1620
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1621
-        }
1622
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1623
-    }
1624
-
1625
-
1626
-    /**
1627
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1628
-     *
1629
-     * @param bool $status REG status given for changing registrations to.
1630
-     * @param bool $notify Whether to send messages notifications or not.
1631
-     * @return array (array with reg_id(s) updated and whether update was successful.
1632
-     * @throws DomainException
1633
-     * @throws EE_Error
1634
-     * @throws EntityNotFoundException
1635
-     * @throws InvalidArgumentException
1636
-     * @throws InvalidDataTypeException
1637
-     * @throws InvalidInterfaceException
1638
-     * @throws ReflectionException
1639
-     * @throws RuntimeException
1640
-     */
1641
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1642
-    {
1643
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1644
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1645
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1646
-
1647
-        // sanitize $REG_IDs
1648
-        $REG_IDs = array_map('absint', $REG_IDs);
1649
-        // and remove empty entries
1650
-        $REG_IDs = array_filter($REG_IDs);
1651
-
1652
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1653
-
1654
-        /**
1655
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1656
-         * Currently this value is used downstream by the _process_resend_registration method.
1657
-         *
1658
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1659
-         * @param bool                     $status           The status registrations were changed to.
1660
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1661
-         * @param Registrations_Admin_Page $admin_page_object
1662
-         */
1663
-        $REG_ID = apply_filters(
1664
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1665
-            $result['REG_ID'],
1666
-            $status,
1667
-            $result['success'],
1668
-            $this
1669
-        );
1670
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1671
-
1672
-        // notify?
1673
-        if (
1674
-            $notify
1675
-            && $result['success']
1676
-            && ! empty($REG_ID)
1677
-            && EE_Registry::instance()->CAP->current_user_can(
1678
-                'ee_send_message',
1679
-                'espresso_registrations_resend_registration'
1680
-            )
1681
-        ) {
1682
-            $this->_process_resend_registration();
1683
-        }
1684
-        return $result;
1685
-    }
1686
-
1687
-
1688
-    /**
1689
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1690
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1691
-     *
1692
-     * @param array  $REG_IDs
1693
-     * @param string $status
1694
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1695
-     *                        slug sent with setting the registration status.
1696
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1697
-     * @throws EE_Error
1698
-     * @throws InvalidArgumentException
1699
-     * @throws InvalidDataTypeException
1700
-     * @throws InvalidInterfaceException
1701
-     * @throws ReflectionException
1702
-     * @throws RuntimeException
1703
-     * @throws EntityNotFoundException
1704
-     * @throws DomainException
1705
-     */
1706
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1707
-    {
1708
-        $success = false;
1709
-        // typecast $REG_IDs
1710
-        $REG_IDs = (array) $REG_IDs;
1711
-        if (! empty($REG_IDs)) {
1712
-            $success = true;
1713
-            // set default status if none is passed
1714
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1715
-            $status_context = $notify
1716
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1717
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1718
-            // loop through REG_ID's and change status
1719
-            foreach ($REG_IDs as $REG_ID) {
1720
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1721
-                if ($registration instanceof EE_Registration) {
1722
-                    $registration->set_status(
1723
-                        $status,
1724
-                        false,
1725
-                        new Context(
1726
-                            $status_context,
1727
-                            esc_html__(
1728
-                                'Manually triggered status change on a Registration Admin Page route.',
1729
-                                'event_espresso'
1730
-                            )
1731
-                        )
1732
-                    );
1733
-                    $result = $registration->save();
1734
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1735
-                    $success = $result !== false ? $success : false;
1736
-                }
1737
-            }
1738
-        }
1739
-
1740
-        // return $success and processed registrations
1741
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * Common logic for setting up success message and redirecting to appropriate route
1747
-     *
1748
-     * @param string $STS_ID status id for the registration changed to
1749
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1750
-     * @return void
1751
-     * @throws DomainException
1752
-     * @throws EE_Error
1753
-     * @throws EntityNotFoundException
1754
-     * @throws InvalidArgumentException
1755
-     * @throws InvalidDataTypeException
1756
-     * @throws InvalidInterfaceException
1757
-     * @throws ReflectionException
1758
-     * @throws RuntimeException
1759
-     */
1760
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1761
-    {
1762
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1763
-            : array('success' => false);
1764
-        $success = isset($result['success']) && $result['success'];
1765
-        // setup success message
1766
-        if ($success) {
1767
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1768
-                $msg = sprintf(
1769
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1770
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1771
-                );
1772
-            } else {
1773
-                $msg = sprintf(
1774
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1775
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1776
-                );
1777
-            }
1778
-            EE_Error::add_success($msg);
1779
-        } else {
1780
-            EE_Error::add_error(
1781
-                esc_html__(
1782
-                    'Something went wrong, and the status was not changed',
1783
-                    'event_espresso'
1784
-                ),
1785
-                __FILE__,
1786
-                __LINE__,
1787
-                __FUNCTION__
1788
-            );
1789
-        }
1790
-        $return = $this->request->getRequestParam('return');
1791
-        $route = $return === 'view_registration'
1792
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1793
-            : ['action' => 'default'];
1794
-        $route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1795
-        $this->_redirect_after_action($success, '', '', $route, true);
1796
-    }
1797
-
1798
-
1799
-    /**
1800
-     * incoming reg status change from reg details page.
1801
-     *
1802
-     * @return void
1803
-     * @throws EE_Error
1804
-     * @throws EntityNotFoundException
1805
-     * @throws InvalidArgumentException
1806
-     * @throws InvalidDataTypeException
1807
-     * @throws InvalidInterfaceException
1808
-     * @throws ReflectionException
1809
-     * @throws RuntimeException
1810
-     * @throws DomainException
1811
-     */
1812
-    protected function _change_reg_status()
1813
-    {
1814
-        $this->request->setRequestParam('return', 'view_registration');
1815
-        // set notify based on whether the send notifications toggle is set or not
1816
-        $notify = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1817
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1818
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1819
-        switch ($reg_status) {
1820
-            case EEM_Registration::status_id_approved:
1821
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1822
-                $this->approve_registration($notify);
1823
-                break;
1824
-            case EEM_Registration::status_id_pending_payment:
1825
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1826
-                $this->pending_registration($notify);
1827
-                break;
1828
-            case EEM_Registration::status_id_not_approved:
1829
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1830
-                $this->not_approve_registration($notify);
1831
-                break;
1832
-            case EEM_Registration::status_id_declined:
1833
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1834
-                $this->decline_registration($notify);
1835
-                break;
1836
-            case EEM_Registration::status_id_cancelled:
1837
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1838
-                $this->cancel_registration($notify);
1839
-                break;
1840
-            case EEM_Registration::status_id_wait_list:
1841
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1842
-                $this->wait_list_registration($notify);
1843
-                break;
1844
-            case EEM_Registration::status_id_incomplete:
1845
-            default:
1846
-                $this->request->unSetRequestParam('return');
1847
-                $this->_reg_status_change_return('');
1848
-                break;
1849
-        }
1850
-    }
1851
-
1852
-
1853
-    /**
1854
-     * Callback for bulk action routes.
1855
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1856
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1857
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1858
-     * when an action is happening on just a single registration).
1859
-     *
1860
-     * @param      $action
1861
-     * @param bool $notify
1862
-     */
1863
-    protected function bulk_action_on_registrations($action, $notify = false)
1864
-    {
1865
-        do_action(
1866
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1867
-            $this,
1868
-            $action,
1869
-            $notify
1870
-        );
1871
-        $method = $action . '_registration';
1872
-        if (method_exists($this, $method)) {
1873
-            $this->$method($notify);
1874
-        }
1875
-    }
1876
-
1877
-
1878
-    /**
1879
-     * approve_registration
1880
-     *
1881
-     * @access protected
1882
-     * @param bool $notify whether or not to notify the registrant about their approval.
1883
-     * @return void
1884
-     * @throws EE_Error
1885
-     * @throws EntityNotFoundException
1886
-     * @throws InvalidArgumentException
1887
-     * @throws InvalidDataTypeException
1888
-     * @throws InvalidInterfaceException
1889
-     * @throws ReflectionException
1890
-     * @throws RuntimeException
1891
-     * @throws DomainException
1892
-     */
1893
-    protected function approve_registration($notify = false)
1894
-    {
1895
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     *        decline_registration
1901
-     *
1902
-     * @access protected
1903
-     * @param bool $notify whether or not to notify the registrant about their status change.
1904
-     * @return void
1905
-     * @throws EE_Error
1906
-     * @throws EntityNotFoundException
1907
-     * @throws InvalidArgumentException
1908
-     * @throws InvalidDataTypeException
1909
-     * @throws InvalidInterfaceException
1910
-     * @throws ReflectionException
1911
-     * @throws RuntimeException
1912
-     * @throws DomainException
1913
-     */
1914
-    protected function decline_registration($notify = false)
1915
-    {
1916
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
-    }
1918
-
1919
-
1920
-    /**
1921
-     *        cancel_registration
1922
-     *
1923
-     * @access protected
1924
-     * @param bool $notify whether or not to notify the registrant about their status change.
1925
-     * @return void
1926
-     * @throws EE_Error
1927
-     * @throws EntityNotFoundException
1928
-     * @throws InvalidArgumentException
1929
-     * @throws InvalidDataTypeException
1930
-     * @throws InvalidInterfaceException
1931
-     * @throws ReflectionException
1932
-     * @throws RuntimeException
1933
-     * @throws DomainException
1934
-     */
1935
-    protected function cancel_registration($notify = false)
1936
-    {
1937
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1938
-    }
1939
-
1940
-
1941
-    /**
1942
-     *        not_approve_registration
1943
-     *
1944
-     * @access protected
1945
-     * @param bool $notify whether or not to notify the registrant about their status change.
1946
-     * @return void
1947
-     * @throws EE_Error
1948
-     * @throws EntityNotFoundException
1949
-     * @throws InvalidArgumentException
1950
-     * @throws InvalidDataTypeException
1951
-     * @throws InvalidInterfaceException
1952
-     * @throws ReflectionException
1953
-     * @throws RuntimeException
1954
-     * @throws DomainException
1955
-     */
1956
-    protected function not_approve_registration($notify = false)
1957
-    {
1958
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1959
-    }
1960
-
1961
-
1962
-    /**
1963
-     *        decline_registration
1964
-     *
1965
-     * @access protected
1966
-     * @param bool $notify whether or not to notify the registrant about their status change.
1967
-     * @return void
1968
-     * @throws EE_Error
1969
-     * @throws EntityNotFoundException
1970
-     * @throws InvalidArgumentException
1971
-     * @throws InvalidDataTypeException
1972
-     * @throws InvalidInterfaceException
1973
-     * @throws ReflectionException
1974
-     * @throws RuntimeException
1975
-     * @throws DomainException
1976
-     */
1977
-    protected function pending_registration($notify = false)
1978
-    {
1979
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1980
-    }
1981
-
1982
-
1983
-    /**
1984
-     * waitlist_registration
1985
-     *
1986
-     * @access protected
1987
-     * @param bool $notify whether or not to notify the registrant about their status change.
1988
-     * @return void
1989
-     * @throws EE_Error
1990
-     * @throws EntityNotFoundException
1991
-     * @throws InvalidArgumentException
1992
-     * @throws InvalidDataTypeException
1993
-     * @throws InvalidInterfaceException
1994
-     * @throws ReflectionException
1995
-     * @throws RuntimeException
1996
-     * @throws DomainException
1997
-     */
1998
-    protected function wait_list_registration($notify = false)
1999
-    {
2000
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2001
-    }
2002
-
2003
-
2004
-    /**
2005
-     *        generates HTML for the Registration main meta box
2006
-     *
2007
-     * @access public
2008
-     * @return void
2009
-     * @throws DomainException
2010
-     * @throws EE_Error
2011
-     * @throws InvalidArgumentException
2012
-     * @throws InvalidDataTypeException
2013
-     * @throws InvalidInterfaceException
2014
-     * @throws ReflectionException
2015
-     * @throws EntityNotFoundException
2016
-     */
2017
-    public function _reg_details_meta_box()
2018
-    {
2019
-        EEH_Autoloader::register_line_item_display_autoloaders();
2020
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2021
-        EE_Registry::instance()->load_helper('Line_Item');
2022
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2023
-            : EE_Transaction::new_instance();
2024
-        $this->_session = $transaction->session_data();
2025
-        $filters = new EE_Line_Item_Filter_Collection();
2026
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2027
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2028
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2029
-            $filters,
2030
-            $transaction->total_line_item()
2031
-        );
2032
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2033
-        $line_item_display = new EE_Line_Item_Display(
2034
-            'reg_admin_table',
2035
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2036
-        );
2037
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2038
-            $filtered_line_item_tree,
2039
-            array('EE_Registration' => $this->_registration)
2040
-        );
2041
-        $attendee = $this->_registration->attendee();
2042
-        if (
2043
-            EE_Registry::instance()->CAP->current_user_can(
2044
-                'ee_read_transaction',
2045
-                'espresso_transactions_view_transaction'
2046
-            )
2047
-        ) {
2048
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2049
-                EE_Admin_Page::add_query_args_and_nonce(
2050
-                    array(
2051
-                        'action' => 'view_transaction',
2052
-                        'TXN_ID' => $transaction->ID(),
2053
-                    ),
2054
-                    TXN_ADMIN_URL
2055
-                ),
2056
-                esc_html__(' View Transaction', 'event_espresso'),
2057
-                'button secondary-button right',
2058
-                'dashicons dashicons-cart'
2059
-            );
2060
-        } else {
2061
-            $this->_template_args['view_transaction_button'] = '';
2062
-        }
2063
-        if (
2064
-            $attendee instanceof EE_Attendee
2065
-            && EE_Registry::instance()->CAP->current_user_can(
2066
-                'ee_send_message',
2067
-                'espresso_registrations_resend_registration'
2068
-            )
2069
-        ) {
2070
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2071
-                EE_Admin_Page::add_query_args_and_nonce(
2072
-                    array(
2073
-                        'action'      => 'resend_registration',
2074
-                        '_REG_ID'     => $this->_registration->ID(),
2075
-                        'redirect_to' => 'view_registration',
2076
-                    ),
2077
-                    REG_ADMIN_URL
2078
-                ),
2079
-                esc_html__(' Resend Registration', 'event_espresso'),
2080
-                'button secondary-button right',
2081
-                'dashicons dashicons-email-alt'
2082
-            );
2083
-        } else {
2084
-            $this->_template_args['resend_registration_button'] = '';
2085
-        }
2086
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2087
-        $payment = $transaction->get_first_related('Payment');
2088
-        $payment = ! $payment instanceof EE_Payment
2089
-            ? EE_Payment::new_instance()
2090
-            : $payment;
2091
-        $payment_method = $payment->get_first_related('Payment_Method');
2092
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2093
-            ? EE_Payment_Method::new_instance()
2094
-            : $payment_method;
2095
-        $reg_details = array(
2096
-            'payment_method'       => $payment_method->name(),
2097
-            'response_msg'         => $payment->gateway_response(),
2098
-            'registration_id'      => $this->_registration->get('REG_code'),
2099
-            'registration_session' => $this->_registration->session_ID(),
2100
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2101
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2102
-        );
2103
-        if (isset($reg_details['registration_id'])) {
2104
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2105
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2106
-                'Registration ID',
2107
-                'event_espresso'
2108
-            );
2109
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2110
-        }
2111
-        if (isset($reg_details['payment_method'])) {
2112
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2113
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2114
-                'Most Recent Payment Method',
2115
-                'event_espresso'
2116
-            );
2117
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2118
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2119
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2120
-                'Payment method response',
2121
-                'event_espresso'
2122
-            );
2123
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2124
-        }
2125
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2126
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2127
-            'Registration Session',
2128
-            'event_espresso'
2129
-        );
2130
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2131
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2132
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2133
-            'Registration placed from IP',
2134
-            'event_espresso'
2135
-        );
2136
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2137
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2138
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2139
-            'Registrant User Agent',
2140
-            'event_espresso'
2141
-        );
2142
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2143
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2144
-            array(
2145
-                'action'   => 'default',
2146
-                'event_id' => $this->_registration->event_ID(),
2147
-            ),
2148
-            REG_ADMIN_URL
2149
-        );
2150
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2151
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2152
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2153
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2154
-    }
2155
-
2156
-
2157
-    /**
2158
-     * generates HTML for the Registration Questions meta box.
2159
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2160
-     * otherwise uses new forms system
2161
-     *
2162
-     * @access public
2163
-     * @return void
2164
-     * @throws DomainException
2165
-     * @throws EE_Error
2166
-     * @throws InvalidArgumentException
2167
-     * @throws InvalidDataTypeException
2168
-     * @throws InvalidInterfaceException
2169
-     * @throws ReflectionException
2170
-     */
2171
-    public function _reg_questions_meta_box()
2172
-    {
2173
-        // allow someone to override this method entirely
2174
-        if (
2175
-            apply_filters(
2176
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2177
-                true,
2178
-                $this,
2179
-                $this->_registration
2180
-            )
2181
-        ) {
2182
-            $form = $this->_get_reg_custom_questions_form(
2183
-                $this->_registration->ID()
2184
-            );
2185
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2186
-                ? $form->get_html_and_js()
2187
-                : '';
2188
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2189
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2190
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2191
-            EEH_Template::display_template($template_path, $this->_template_args);
2192
-        }
2193
-    }
2194
-
2195
-
2196
-    /**
2197
-     * form_before_question_group
2198
-     *
2199
-     * @deprecated    as of 4.8.32.rc.000
2200
-     * @access        public
2201
-     * @param        string $output
2202
-     * @return        string
2203
-     */
2204
-    public function form_before_question_group($output)
2205
-    {
2206
-        EE_Error::doing_it_wrong(
2207
-            __CLASS__ . '::' . __FUNCTION__,
2208
-            esc_html__(
2209
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2210
-                'event_espresso'
2211
-            ),
2212
-            '4.8.32.rc.000'
2213
-        );
2214
-        return '
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	private static $_reg_status;
38
+
39
+	/**
40
+	 * Form for displaying the custom questions for this registration.
41
+	 * This gets used a few times throughout the request so its best to cache it
42
+	 *
43
+	 * @var EE_Registration_Custom_Questions_Form
44
+	 */
45
+	protected $_reg_custom_questions_form = null;
46
+
47
+	/**
48
+	 * @var EEM_Registration $registration_model
49
+	 */
50
+	private $registration_model;
51
+
52
+	/**
53
+	 * @var EEM_Attendee $attendee_model
54
+	 */
55
+	private $attendee_model;
56
+
57
+	/**
58
+	 * @var EEM_Event $event_model
59
+	 */
60
+	private $event_model;
61
+
62
+	/**
63
+	 * @var EEM_Status $status_model
64
+	 */
65
+	private $status_model;
66
+
67
+
68
+	/**
69
+	 * @param bool $routing
70
+	 * @throws EE_Error
71
+	 * @throws InvalidArgumentException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function __construct($routing = true)
77
+	{
78
+		parent::__construct($routing);
79
+		add_action('wp_loaded', array($this, 'wp_loaded'));
80
+	}
81
+
82
+	/**
83
+	 * @return EEM_Registration
84
+	 * @throws InvalidArgumentException
85
+	 * @throws InvalidDataTypeException
86
+	 * @throws InvalidInterfaceException
87
+	 * @since 4.10.2.p
88
+	 */
89
+	protected function getRegistrationModel()
90
+	{
91
+		if (! $this->registration_model instanceof EEM_Registration) {
92
+			$this->registration_model = $this->getLoader()->getShared('EEM_Registration');
93
+		}
94
+		return $this->registration_model;
95
+	}
96
+
97
+	/**
98
+	 * @return EEM_Attendee
99
+	 * @throws InvalidArgumentException
100
+	 * @throws InvalidDataTypeException
101
+	 * @throws InvalidInterfaceException
102
+	 * @since 4.10.2.p
103
+	 */
104
+	protected function getAttendeeModel()
105
+	{
106
+		if (! $this->attendee_model instanceof EEM_Attendee) {
107
+			$this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
108
+		}
109
+		return $this->attendee_model;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return EEM_Event
115
+	 * @throws InvalidArgumentException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws InvalidInterfaceException
118
+	 * @since 4.10.2.p
119
+	 */
120
+	protected function getEventModel()
121
+	{
122
+		if (! $this->event_model instanceof EEM_Event) {
123
+			$this->event_model = $this->getLoader()->getShared('EEM_Event');
124
+		}
125
+		return $this->event_model;
126
+	}
127
+
128
+	/**
129
+	 * @return EEM_Status
130
+	 * @throws InvalidArgumentException
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidInterfaceException
133
+	 * @since 4.10.2.p
134
+	 */
135
+	protected function getStatusModel()
136
+	{
137
+		if (! $this->status_model instanceof EEM_Status) {
138
+			$this->status_model = $this->getLoader()->getShared('EEM_Status');
139
+		}
140
+		return $this->status_model;
141
+	}
142
+
143
+
144
+	public function wp_loaded()
145
+	{
146
+		// when adding a new registration...
147
+		$action = $this->request->getRequestParam('action');
148
+		if ($action === 'new_registration') {
149
+			EE_System::do_not_cache();
150
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
151
+				// and it's NOT the attendee information reg step
152
+				// force cookie expiration by setting time to last week
153
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
154
+				// and update the global
155
+				$_COOKIE['ee_registration_added'] = 0;
156
+			}
157
+		}
158
+	}
159
+
160
+
161
+	protected function _init_page_props()
162
+	{
163
+		$this->page_slug = REG_PG_SLUG;
164
+		$this->_admin_base_url = REG_ADMIN_URL;
165
+		$this->_admin_base_path = REG_ADMIN;
166
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
167
+		$this->_cpt_routes = array(
168
+			'add_new_attendee' => 'espresso_attendees',
169
+			'edit_attendee'    => 'espresso_attendees',
170
+			'insert_attendee'  => 'espresso_attendees',
171
+			'update_attendee'  => 'espresso_attendees',
172
+		);
173
+		$this->_cpt_model_names = array(
174
+			'add_new_attendee' => 'EEM_Attendee',
175
+			'edit_attendee'    => 'EEM_Attendee',
176
+		);
177
+		$this->_cpt_edit_routes = array(
178
+			'espresso_attendees' => 'edit_attendee',
179
+		);
180
+		$this->_pagenow_map = array(
181
+			'add_new_attendee' => 'post-new.php',
182
+			'edit_attendee'    => 'post.php',
183
+			'trash'            => 'post.php',
184
+		);
185
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
186
+		// add filters so that the comment urls don't take users to a confusing 404 page
187
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
188
+	}
189
+
190
+
191
+	public function clear_comment_link($link, $comment, $args)
192
+	{
193
+		// gotta make sure this only happens on this route
194
+		$post_type = get_post_type($comment->comment_post_ID);
195
+		if ($post_type === 'espresso_attendees') {
196
+			return '#commentsdiv';
197
+		}
198
+		return $link;
199
+	}
200
+
201
+
202
+	protected function _ajax_hooks()
203
+	{
204
+		// todo: all hooks for registrations ajax goes in here
205
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
206
+	}
207
+
208
+
209
+	protected function _define_page_props()
210
+	{
211
+		$this->_admin_page_title = $this->page_label;
212
+		$this->_labels = array(
213
+			'buttons'                      => array(
214
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
215
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
216
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
217
+				'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
218
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
219
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
220
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
221
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
222
+			),
223
+			'publishbox'                   => array(
224
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
225
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
226
+			),
227
+			'hide_add_button_on_cpt_route' => array(
228
+				'edit_attendee' => true,
229
+			),
230
+		);
231
+	}
232
+
233
+
234
+	/**
235
+	 *        grab url requests and route them
236
+	 *
237
+	 * @access private
238
+	 * @return void
239
+	 * @throws EE_Error
240
+	 */
241
+	public function _set_page_routes()
242
+	{
243
+		$this->_get_registration_status_array();
244
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
245
+		$REG_ID = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
246
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
247
+		$ATT_ID = $this->request->getRequestParam('post', $ATT_ID, 'int');
248
+		$this->_page_routes = array(
249
+			'default'                             => array(
250
+				'func'       => '_registrations_overview_list_table',
251
+				'capability' => 'ee_read_registrations',
252
+			),
253
+			'view_registration'                   => array(
254
+				'func'       => '_registration_details',
255
+				'capability' => 'ee_read_registration',
256
+				'obj_id'     => $REG_ID,
257
+			),
258
+			'edit_registration'                   => array(
259
+				'func'               => '_update_attendee_registration_form',
260
+				'noheader'           => true,
261
+				'headers_sent_route' => 'view_registration',
262
+				'capability'         => 'ee_edit_registration',
263
+				'obj_id'             => $REG_ID,
264
+				'_REG_ID'            => $REG_ID,
265
+			),
266
+			'trash_registrations'                 => array(
267
+				'func'       => '_trash_or_restore_registrations',
268
+				'args'       => array('trash' => true),
269
+				'noheader'   => true,
270
+				'capability' => 'ee_delete_registrations',
271
+			),
272
+			'restore_registrations'               => array(
273
+				'func'       => '_trash_or_restore_registrations',
274
+				'args'       => array('trash' => false),
275
+				'noheader'   => true,
276
+				'capability' => 'ee_delete_registrations',
277
+			),
278
+			'delete_registrations'                => array(
279
+				'func'       => '_delete_registrations',
280
+				'noheader'   => true,
281
+				'capability' => 'ee_delete_registrations',
282
+			),
283
+			'new_registration'                    => array(
284
+				'func'       => 'new_registration',
285
+				'capability' => 'ee_edit_registrations',
286
+			),
287
+			'process_reg_step'                    => array(
288
+				'func'       => 'process_reg_step',
289
+				'noheader'   => true,
290
+				'capability' => 'ee_edit_registrations',
291
+			),
292
+			'redirect_to_txn'                     => array(
293
+				'func'       => 'redirect_to_txn',
294
+				'noheader'   => true,
295
+				'capability' => 'ee_edit_registrations',
296
+			),
297
+			'change_reg_status'                   => array(
298
+				'func'       => '_change_reg_status',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registration',
301
+				'obj_id'     => $REG_ID,
302
+			),
303
+			'approve_registration'                => array(
304
+				'func'       => 'approve_registration',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $REG_ID,
308
+			),
309
+			'approve_and_notify_registration'     => array(
310
+				'func'       => 'approve_registration',
311
+				'noheader'   => true,
312
+				'args'       => array(true),
313
+				'capability' => 'ee_edit_registration',
314
+				'obj_id'     => $REG_ID,
315
+			),
316
+			'approve_registrations'               => array(
317
+				'func'       => 'bulk_action_on_registrations',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_registrations',
320
+				'args'       => array('approve'),
321
+			),
322
+			'approve_and_notify_registrations'    => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('approve', true),
327
+			),
328
+			'decline_registration'                => array(
329
+				'func'       => 'decline_registration',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registration',
332
+				'obj_id'     => $REG_ID,
333
+			),
334
+			'decline_and_notify_registration'     => array(
335
+				'func'       => 'decline_registration',
336
+				'noheader'   => true,
337
+				'args'       => array(true),
338
+				'capability' => 'ee_edit_registration',
339
+				'obj_id'     => $REG_ID,
340
+			),
341
+			'decline_registrations'               => array(
342
+				'func'       => 'bulk_action_on_registrations',
343
+				'noheader'   => true,
344
+				'capability' => 'ee_edit_registrations',
345
+				'args'       => array('decline'),
346
+			),
347
+			'decline_and_notify_registrations'    => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('decline', true),
352
+			),
353
+			'pending_registration'                => array(
354
+				'func'       => 'pending_registration',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registration',
357
+				'obj_id'     => $REG_ID,
358
+			),
359
+			'pending_and_notify_registration'     => array(
360
+				'func'       => 'pending_registration',
361
+				'noheader'   => true,
362
+				'args'       => array(true),
363
+				'capability' => 'ee_edit_registration',
364
+				'obj_id'     => $REG_ID,
365
+			),
366
+			'pending_registrations'               => array(
367
+				'func'       => 'bulk_action_on_registrations',
368
+				'noheader'   => true,
369
+				'capability' => 'ee_edit_registrations',
370
+				'args'       => array('pending'),
371
+			),
372
+			'pending_and_notify_registrations'    => array(
373
+				'func'       => 'bulk_action_on_registrations',
374
+				'noheader'   => true,
375
+				'capability' => 'ee_edit_registrations',
376
+				'args'       => array('pending', true),
377
+			),
378
+			'no_approve_registration'             => array(
379
+				'func'       => 'not_approve_registration',
380
+				'noheader'   => true,
381
+				'capability' => 'ee_edit_registration',
382
+				'obj_id'     => $REG_ID,
383
+			),
384
+			'no_approve_and_notify_registration'  => array(
385
+				'func'       => 'not_approve_registration',
386
+				'noheader'   => true,
387
+				'args'       => array(true),
388
+				'capability' => 'ee_edit_registration',
389
+				'obj_id'     => $REG_ID,
390
+			),
391
+			'no_approve_registrations'            => array(
392
+				'func'       => 'bulk_action_on_registrations',
393
+				'noheader'   => true,
394
+				'capability' => 'ee_edit_registrations',
395
+				'args'       => array('not_approve'),
396
+			),
397
+			'no_approve_and_notify_registrations' => array(
398
+				'func'       => 'bulk_action_on_registrations',
399
+				'noheader'   => true,
400
+				'capability' => 'ee_edit_registrations',
401
+				'args'       => array('not_approve', true),
402
+			),
403
+			'cancel_registration'                 => array(
404
+				'func'       => 'cancel_registration',
405
+				'noheader'   => true,
406
+				'capability' => 'ee_edit_registration',
407
+				'obj_id'     => $REG_ID,
408
+			),
409
+			'cancel_and_notify_registration'      => array(
410
+				'func'       => 'cancel_registration',
411
+				'noheader'   => true,
412
+				'args'       => array(true),
413
+				'capability' => 'ee_edit_registration',
414
+				'obj_id'     => $REG_ID,
415
+			),
416
+			'cancel_registrations'                => array(
417
+				'func'       => 'bulk_action_on_registrations',
418
+				'noheader'   => true,
419
+				'capability' => 'ee_edit_registrations',
420
+				'args'       => array('cancel'),
421
+			),
422
+			'cancel_and_notify_registrations'     => array(
423
+				'func'       => 'bulk_action_on_registrations',
424
+				'noheader'   => true,
425
+				'capability' => 'ee_edit_registrations',
426
+				'args'       => array('cancel', true),
427
+			),
428
+			'wait_list_registration'              => array(
429
+				'func'       => 'wait_list_registration',
430
+				'noheader'   => true,
431
+				'capability' => 'ee_edit_registration',
432
+				'obj_id'     => $REG_ID,
433
+			),
434
+			'wait_list_and_notify_registration'   => array(
435
+				'func'       => 'wait_list_registration',
436
+				'noheader'   => true,
437
+				'args'       => array(true),
438
+				'capability' => 'ee_edit_registration',
439
+				'obj_id'     => $REG_ID,
440
+			),
441
+			'contact_list'                        => array(
442
+				'func'       => '_attendee_contact_list_table',
443
+				'capability' => 'ee_read_contacts',
444
+			),
445
+			'add_new_attendee'                    => array(
446
+				'func' => '_create_new_cpt_item',
447
+				'args' => array(
448
+					'new_attendee' => true,
449
+					'capability'   => 'ee_edit_contacts',
450
+				),
451
+			),
452
+			'edit_attendee'                       => array(
453
+				'func'       => '_edit_cpt_item',
454
+				'capability' => 'ee_edit_contacts',
455
+				'obj_id'     => $ATT_ID,
456
+			),
457
+			'duplicate_attendee'                  => array(
458
+				'func'       => '_duplicate_attendee',
459
+				'noheader'   => true,
460
+				'capability' => 'ee_edit_contacts',
461
+				'obj_id'     => $ATT_ID,
462
+			),
463
+			'insert_attendee'                     => array(
464
+				'func'       => '_insert_or_update_attendee',
465
+				'args'       => array(
466
+					'new_attendee' => true,
467
+				),
468
+				'noheader'   => true,
469
+				'capability' => 'ee_edit_contacts',
470
+			),
471
+			'update_attendee'                     => array(
472
+				'func'       => '_insert_or_update_attendee',
473
+				'args'       => array(
474
+					'new_attendee' => false,
475
+				),
476
+				'noheader'   => true,
477
+				'capability' => 'ee_edit_contacts',
478
+				'obj_id'     => $ATT_ID,
479
+			),
480
+			'trash_attendees'                     => array(
481
+				'func'       => '_trash_or_restore_attendees',
482
+				'args'       => array(
483
+					'trash' => 'true',
484
+				),
485
+				'noheader'   => true,
486
+				'capability' => 'ee_delete_contacts',
487
+			),
488
+			'trash_attendee'                      => array(
489
+				'func'       => '_trash_or_restore_attendees',
490
+				'args'       => array(
491
+					'trash' => true,
492
+				),
493
+				'noheader'   => true,
494
+				'capability' => 'ee_delete_contacts',
495
+				'obj_id'     => $ATT_ID,
496
+			),
497
+			'restore_attendees'                   => array(
498
+				'func'       => '_trash_or_restore_attendees',
499
+				'args'       => array(
500
+					'trash' => false,
501
+				),
502
+				'noheader'   => true,
503
+				'capability' => 'ee_delete_contacts',
504
+				'obj_id'     => $ATT_ID,
505
+			),
506
+			'resend_registration'                 => array(
507
+				'func'       => '_resend_registration',
508
+				'noheader'   => true,
509
+				'capability' => 'ee_send_message',
510
+			),
511
+			'registrations_report'                => array(
512
+				'func'       => '_registrations_report',
513
+				'noheader'   => true,
514
+				'capability' => 'ee_read_registrations',
515
+			),
516
+			'contact_list_export'                 => array(
517
+				'func'       => '_contact_list_export',
518
+				'noheader'   => true,
519
+				'capability' => 'export',
520
+			),
521
+			'contact_list_report'                 => array(
522
+				'func'       => '_contact_list_report',
523
+				'noheader'   => true,
524
+				'capability' => 'ee_read_contacts',
525
+			),
526
+		);
527
+	}
528
+
529
+
530
+	protected function _set_page_config()
531
+	{
532
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
533
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
534
+		$this->_page_config = array(
535
+			'default'           => array(
536
+				'nav'           => array(
537
+					'label' => esc_html__('Overview', 'event_espresso'),
538
+					'order' => 5,
539
+				),
540
+				'help_tabs'     => array(
541
+					'registrations_overview_help_tab'                       => array(
542
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
543
+						'filename' => 'registrations_overview',
544
+					),
545
+					'registrations_overview_table_column_headings_help_tab' => array(
546
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
547
+						'filename' => 'registrations_overview_table_column_headings',
548
+					),
549
+					'registrations_overview_filters_help_tab'               => array(
550
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
551
+						'filename' => 'registrations_overview_filters',
552
+					),
553
+					'registrations_overview_views_help_tab'                 => array(
554
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
555
+						'filename' => 'registrations_overview_views',
556
+					),
557
+					'registrations_regoverview_other_help_tab'              => array(
558
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
559
+						'filename' => 'registrations_overview_other',
560
+					),
561
+				),
562
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
563
+				// 'help_tour'     => array('Registration_Overview_Help_Tour'),
564
+				'qtips'         => array('Registration_List_Table_Tips'),
565
+				'list_table'    => 'EE_Registrations_List_Table',
566
+				'require_nonce' => false,
567
+			),
568
+			'view_registration' => array(
569
+				'nav'           => array(
570
+					'label'      => esc_html__('REG Details', 'event_espresso'),
571
+					'order'      => 15,
572
+					'url'        => $REG_ID
573
+						? add_query_arg(array('_REG_ID' => $REG_ID), $this->_current_page_view_url)
574
+						: $this->_admin_base_url,
575
+					'persistent' => false,
576
+				),
577
+				'help_tabs'     => array(
578
+					'registrations_details_help_tab'                    => array(
579
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
580
+						'filename' => 'registrations_details',
581
+					),
582
+					'registrations_details_table_help_tab'              => array(
583
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
584
+						'filename' => 'registrations_details_table',
585
+					),
586
+					'registrations_details_form_answers_help_tab'       => array(
587
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
588
+						'filename' => 'registrations_details_form_answers',
589
+					),
590
+					'registrations_details_registrant_details_help_tab' => array(
591
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
592
+						'filename' => 'registrations_details_registrant_details',
593
+					),
594
+				),
595
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
596
+				// 'help_tour'     => array('Registration_Details_Help_Tour'),
597
+				'metaboxes'     => array_merge(
598
+					$this->_default_espresso_metaboxes,
599
+					array('_registration_details_metaboxes')
600
+				),
601
+				'require_nonce' => false,
602
+			),
603
+			'new_registration'  => array(
604
+				'nav'           => array(
605
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
606
+					'url'        => '#',
607
+					'order'      => 15,
608
+					'persistent' => false,
609
+				),
610
+				'metaboxes'     => $this->_default_espresso_metaboxes,
611
+				'labels'        => array(
612
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
613
+				),
614
+				'require_nonce' => false,
615
+			),
616
+			'add_new_attendee'  => array(
617
+				'nav'           => array(
618
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
619
+					'order'      => 15,
620
+					'persistent' => false,
621
+				),
622
+				'metaboxes'     => array_merge(
623
+					$this->_default_espresso_metaboxes,
624
+					array('_publish_post_box', 'attendee_editor_metaboxes')
625
+				),
626
+				'require_nonce' => false,
627
+			),
628
+			'edit_attendee'     => array(
629
+				'nav'           => array(
630
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
631
+					'order'      => 15,
632
+					'persistent' => false,
633
+					'url'        => $ATT_ID
634
+						? add_query_arg(array('ATT_ID' => $ATT_ID), $this->_current_page_view_url)
635
+						: $this->_admin_base_url,
636
+				),
637
+				'metaboxes'     => array('attendee_editor_metaboxes'),
638
+				'require_nonce' => false,
639
+			),
640
+			'contact_list'      => array(
641
+				'nav'           => array(
642
+					'label' => esc_html__('Contact List', 'event_espresso'),
643
+					'order' => 20,
644
+				),
645
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
646
+				'help_tabs'     => array(
647
+					'registrations_contact_list_help_tab'                       => array(
648
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
649
+						'filename' => 'registrations_contact_list',
650
+					),
651
+					'registrations_contact-list_table_column_headings_help_tab' => array(
652
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
653
+						'filename' => 'registrations_contact_list_table_column_headings',
654
+					),
655
+					'registrations_contact_list_views_help_tab'                 => array(
656
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
657
+						'filename' => 'registrations_contact_list_views',
658
+					),
659
+					'registrations_contact_list_other_help_tab'                 => array(
660
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
661
+						'filename' => 'registrations_contact_list_other',
662
+					),
663
+				),
664
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
665
+				// 'help_tour'     => array('Contact_List_Help_Tour'),
666
+				'metaboxes'     => array(),
667
+				'require_nonce' => false,
668
+			),
669
+			// override default cpt routes
670
+			'create_new'        => '',
671
+			'edit'              => '',
672
+		);
673
+	}
674
+
675
+
676
+	/**
677
+	 * The below methods aren't used by this class currently
678
+	 */
679
+	protected function _add_screen_options()
680
+	{
681
+	}
682
+
683
+
684
+	protected function _add_feature_pointers()
685
+	{
686
+	}
687
+
688
+
689
+	public function admin_init()
690
+	{
691
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
692
+			'click "Update Registration Questions" to save your changes',
693
+			'event_espresso'
694
+		);
695
+	}
696
+
697
+
698
+	public function admin_notices()
699
+	{
700
+	}
701
+
702
+
703
+	public function admin_footer_scripts()
704
+	{
705
+	}
706
+
707
+
708
+	/**
709
+	 *        get list of registration statuses
710
+	 *
711
+	 * @access private
712
+	 * @return void
713
+	 * @throws EE_Error
714
+	 */
715
+	private function _get_registration_status_array()
716
+	{
717
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
718
+	}
719
+
720
+
721
+	/**
722
+	 * @throws InvalidArgumentException
723
+	 * @throws InvalidDataTypeException
724
+	 * @throws InvalidInterfaceException
725
+	 * @since 4.10.2.p
726
+	 */
727
+	protected function _add_screen_options_default()
728
+	{
729
+		$this->_per_page_screen_option();
730
+	}
731
+
732
+
733
+	/**
734
+	 * @throws InvalidArgumentException
735
+	 * @throws InvalidDataTypeException
736
+	 * @throws InvalidInterfaceException
737
+	 * @since 4.10.2.p
738
+	 */
739
+	protected function _add_screen_options_contact_list()
740
+	{
741
+		$page_title = $this->_admin_page_title;
742
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
743
+		$this->_per_page_screen_option();
744
+		$this->_admin_page_title = $page_title;
745
+	}
746
+
747
+
748
+	public function load_scripts_styles()
749
+	{
750
+		// style
751
+		wp_register_style(
752
+			'espresso_reg',
753
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
754
+			array('ee-admin-css'),
755
+			EVENT_ESPRESSO_VERSION
756
+		);
757
+		wp_enqueue_style('espresso_reg');
758
+		// script
759
+		wp_register_script(
760
+			'espresso_reg',
761
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
762
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
763
+			EVENT_ESPRESSO_VERSION,
764
+			true
765
+		);
766
+		wp_enqueue_script('espresso_reg');
767
+	}
768
+
769
+
770
+	/**
771
+	 * @throws EE_Error
772
+	 * @throws InvalidArgumentException
773
+	 * @throws InvalidDataTypeException
774
+	 * @throws InvalidInterfaceException
775
+	 * @throws ReflectionException
776
+	 * @since 4.10.2.p
777
+	 */
778
+	public function load_scripts_styles_edit_attendee()
779
+	{
780
+		// stuff to only show up on our attendee edit details page.
781
+		$attendee_details_translations = array(
782
+			'att_publish_text' => sprintf(
783
+				/* translators: The date and time */
784
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
785
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
786
+			),
787
+		);
788
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
789
+		wp_enqueue_script('jquery-validate');
790
+	}
791
+
792
+
793
+	/**
794
+	 * @throws EE_Error
795
+	 * @throws InvalidArgumentException
796
+	 * @throws InvalidDataTypeException
797
+	 * @throws InvalidInterfaceException
798
+	 * @throws ReflectionException
799
+	 * @since 4.10.2.p
800
+	 */
801
+	public function load_scripts_styles_view_registration()
802
+	{
803
+		// styles
804
+		wp_enqueue_style('espresso-ui-theme');
805
+		// scripts
806
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
807
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
808
+	}
809
+
810
+
811
+	public function load_scripts_styles_contact_list()
812
+	{
813
+		wp_dequeue_style('espresso_reg');
814
+		wp_register_style(
815
+			'espresso_att',
816
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
817
+			array('ee-admin-css'),
818
+			EVENT_ESPRESSO_VERSION
819
+		);
820
+		wp_enqueue_style('espresso_att');
821
+	}
822
+
823
+
824
+	public function load_scripts_styles_new_registration()
825
+	{
826
+		wp_register_script(
827
+			'ee-spco-for-admin',
828
+			REG_ASSETS_URL . 'spco_for_admin.js',
829
+			array('underscore', 'jquery'),
830
+			EVENT_ESPRESSO_VERSION,
831
+			true
832
+		);
833
+		wp_enqueue_script('ee-spco-for-admin');
834
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
835
+		EE_Form_Section_Proper::wp_enqueue_scripts();
836
+		EED_Ticket_Selector::load_tckt_slctr_assets();
837
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
838
+	}
839
+
840
+
841
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
842
+	{
843
+		add_filter('FHEE_load_EE_messages', '__return_true');
844
+	}
845
+
846
+
847
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
848
+	{
849
+		add_filter('FHEE_load_EE_messages', '__return_true');
850
+	}
851
+
852
+
853
+	/**
854
+	 * @throws EE_Error
855
+	 * @throws InvalidArgumentException
856
+	 * @throws InvalidDataTypeException
857
+	 * @throws InvalidInterfaceException
858
+	 * @throws ReflectionException
859
+	 * @since 4.10.2.p
860
+	 */
861
+	protected function _set_list_table_views_default()
862
+	{
863
+		// for notification related bulk actions we need to make sure only active messengers have an option.
864
+		EED_Messages::set_autoloaders();
865
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
866
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
867
+		$active_mts = $message_resource_manager->list_of_active_message_types();
868
+		// key= bulk_action_slug, value= message type.
869
+		$match_array = array(
870
+			'approve_registrations'    => 'registration',
871
+			'decline_registrations'    => 'declined_registration',
872
+			'pending_registrations'    => 'pending_approval',
873
+			'no_approve_registrations' => 'not_approved_registration',
874
+			'cancel_registrations'     => 'cancelled_registration',
875
+		);
876
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
877
+			'ee_send_message',
878
+			'batch_send_messages'
879
+		);
880
+		/** setup reg status bulk actions **/
881
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
882
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
883
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
884
+				'Approve and Notify Registrations',
885
+				'event_espresso'
886
+			);
887
+		}
888
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
889
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
890
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
891
+				'Decline and Notify Registrations',
892
+				'event_espresso'
893
+			);
894
+		}
895
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
896
+			'Set Registrations to Pending Payment',
897
+			'event_espresso'
898
+		);
899
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
900
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
901
+				'Set Registrations to Pending Payment and Notify',
902
+				'event_espresso'
903
+			);
904
+		}
905
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
906
+			'Set Registrations to Not Approved',
907
+			'event_espresso'
908
+		);
909
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
910
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
911
+				'Set Registrations to Not Approved and Notify',
912
+				'event_espresso'
913
+			);
914
+		}
915
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
916
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
917
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
918
+				'Cancel Registrations and Notify',
919
+				'event_espresso'
920
+			);
921
+		}
922
+		$def_reg_status_actions = apply_filters(
923
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
924
+			$def_reg_status_actions,
925
+			$active_mts,
926
+			$can_send
927
+		);
928
+
929
+		$this->_views = array(
930
+			'all'   => array(
931
+				'slug'        => 'all',
932
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
933
+				'count'       => 0,
934
+				'bulk_action' => array_merge(
935
+					$def_reg_status_actions,
936
+					array(
937
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
938
+					)
939
+				),
940
+			),
941
+			'month' => array(
942
+				'slug'        => 'month',
943
+				'label'       => esc_html__('This Month', 'event_espresso'),
944
+				'count'       => 0,
945
+				'bulk_action' => array_merge(
946
+					$def_reg_status_actions,
947
+					array(
948
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
949
+					)
950
+				),
951
+			),
952
+			'today' => array(
953
+				'slug'        => 'today',
954
+				'label'       => sprintf(
955
+					esc_html__('Today - %s', 'event_espresso'),
956
+					date('M d, Y', current_time('timestamp'))
957
+				),
958
+				'count'       => 0,
959
+				'bulk_action' => array_merge(
960
+					$def_reg_status_actions,
961
+					array(
962
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
963
+					)
964
+				),
965
+			),
966
+		);
967
+		if (
968
+			EE_Registry::instance()->CAP->current_user_can(
969
+				'ee_delete_registrations',
970
+				'espresso_registrations_delete_registration'
971
+			)
972
+		) {
973
+			$this->_views['incomplete'] = array(
974
+				'slug'        => 'incomplete',
975
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
976
+				'count'       => 0,
977
+				'bulk_action' => array(
978
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
979
+				),
980
+			);
981
+			$this->_views['trash'] = array(
982
+				'slug'        => 'trash',
983
+				'label'       => esc_html__('Trash', 'event_espresso'),
984
+				'count'       => 0,
985
+				'bulk_action' => array(
986
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
987
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
988
+				),
989
+			);
990
+		}
991
+	}
992
+
993
+
994
+	protected function _set_list_table_views_contact_list()
995
+	{
996
+		$this->_views = array(
997
+			'in_use' => array(
998
+				'slug'        => 'in_use',
999
+				'label'       => esc_html__('In Use', 'event_espresso'),
1000
+				'count'       => 0,
1001
+				'bulk_action' => array(
1002
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1003
+				),
1004
+			),
1005
+		);
1006
+		if (
1007
+			EE_Registry::instance()->CAP->current_user_can(
1008
+				'ee_delete_contacts',
1009
+				'espresso_registrations_trash_attendees'
1010
+			)
1011
+		) {
1012
+			$this->_views['trash'] = array(
1013
+				'slug'        => 'trash',
1014
+				'label'       => esc_html__('Trash', 'event_espresso'),
1015
+				'count'       => 0,
1016
+				'bulk_action' => array(
1017
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1018
+				),
1019
+			);
1020
+		}
1021
+	}
1022
+
1023
+
1024
+	protected function _registration_legend_items()
1025
+	{
1026
+		$fc_items = array(
1027
+			'star-icon'        => array(
1028
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1029
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1030
+			),
1031
+			'view_details'     => array(
1032
+				'class' => 'dashicons dashicons-clipboard',
1033
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1034
+			),
1035
+			'edit_attendee'    => array(
1036
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1037
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1038
+			),
1039
+			'view_transaction' => array(
1040
+				'class' => 'dashicons dashicons-cart',
1041
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1042
+			),
1043
+			'view_invoice'     => array(
1044
+				'class' => 'dashicons dashicons-media-spreadsheet',
1045
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1046
+			),
1047
+		);
1048
+		if (
1049
+			EE_Registry::instance()->CAP->current_user_can(
1050
+				'ee_send_message',
1051
+				'espresso_registrations_resend_registration'
1052
+			)
1053
+		) {
1054
+			$fc_items['resend_registration'] = array(
1055
+				'class' => 'dashicons dashicons-email-alt',
1056
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1057
+			);
1058
+		} else {
1059
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
1060
+		}
1061
+		if (
1062
+			EE_Registry::instance()->CAP->current_user_can(
1063
+				'ee_read_global_messages',
1064
+				'view_filtered_messages'
1065
+			)
1066
+		) {
1067
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1068
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1069
+				$fc_items['view_related_messages'] = array(
1070
+					'class' => $related_for_icon['css_class'],
1071
+					'desc'  => $related_for_icon['label'],
1072
+				);
1073
+			}
1074
+		}
1075
+		$sc_items = array(
1076
+			'approved_status'   => array(
1077
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1078
+				'desc'  => EEH_Template::pretty_status(
1079
+					EEM_Registration::status_id_approved,
1080
+					false,
1081
+					'sentence'
1082
+				),
1083
+			),
1084
+			'pending_status'    => array(
1085
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1086
+				'desc'  => EEH_Template::pretty_status(
1087
+					EEM_Registration::status_id_pending_payment,
1088
+					false,
1089
+					'sentence'
1090
+				),
1091
+			),
1092
+			'wait_list'         => array(
1093
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1094
+				'desc'  => EEH_Template::pretty_status(
1095
+					EEM_Registration::status_id_wait_list,
1096
+					false,
1097
+					'sentence'
1098
+				),
1099
+			),
1100
+			'incomplete_status' => array(
1101
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1102
+				'desc'  => EEH_Template::pretty_status(
1103
+					EEM_Registration::status_id_incomplete,
1104
+					false,
1105
+					'sentence'
1106
+				),
1107
+			),
1108
+			'not_approved'      => array(
1109
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1110
+				'desc'  => EEH_Template::pretty_status(
1111
+					EEM_Registration::status_id_not_approved,
1112
+					false,
1113
+					'sentence'
1114
+				),
1115
+			),
1116
+			'declined_status'   => array(
1117
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1118
+				'desc'  => EEH_Template::pretty_status(
1119
+					EEM_Registration::status_id_declined,
1120
+					false,
1121
+					'sentence'
1122
+				),
1123
+			),
1124
+			'cancelled_status'  => array(
1125
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1126
+				'desc'  => EEH_Template::pretty_status(
1127
+					EEM_Registration::status_id_cancelled,
1128
+					false,
1129
+					'sentence'
1130
+				),
1131
+			),
1132
+		);
1133
+		return array_merge($fc_items, $sc_items);
1134
+	}
1135
+
1136
+
1137
+
1138
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1139
+
1140
+
1141
+
1142
+	/**
1143
+	 * @throws DomainException
1144
+	 * @throws EE_Error
1145
+	 * @throws InvalidArgumentException
1146
+	 * @throws InvalidDataTypeException
1147
+	 * @throws InvalidInterfaceException
1148
+	 * @throws ReflectionException
1149
+	 */
1150
+	protected function _registrations_overview_list_table()
1151
+	{
1152
+		$this->appendAddNewRegistrationButtonToPageTitle();
1153
+		$header_text = '';
1154
+		$admin_page_header_decorators = [
1155
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1156
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1157
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1158
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1159
+		];
1160
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1161
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1162
+			$header_text = $filter_header_decorator->getHeaderText($header_text);
1163
+		}
1164
+		$this->_template_args['admin_page_header'] = $header_text;
1165
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1166
+		$this->display_admin_list_table_page_with_no_sidebar();
1167
+	}
1168
+
1169
+
1170
+	/**
1171
+	 * @throws EE_Error
1172
+	 * @throws InvalidArgumentException
1173
+	 * @throws InvalidDataTypeException
1174
+	 * @throws InvalidInterfaceException
1175
+	 */
1176
+	private function appendAddNewRegistrationButtonToPageTitle()
1177
+	{
1178
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1179
+		if (
1180
+			$EVT_ID
1181
+			&& EE_Registry::instance()->CAP->current_user_can(
1182
+				'ee_edit_registrations',
1183
+				'espresso_registrations_new_registration',
1184
+				$EVT_ID
1185
+			)
1186
+		) {
1187
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1188
+				'new_registration',
1189
+				'add-registrant',
1190
+				array('event_id' => $EVT_ID),
1191
+				'add-new-h2'
1192
+			);
1193
+		}
1194
+	}
1195
+
1196
+
1197
+	/**
1198
+	 * This sets the _registration property for the registration details screen
1199
+	 *
1200
+	 * @access private
1201
+	 * @return bool
1202
+	 * @throws EE_Error
1203
+	 * @throws InvalidArgumentException
1204
+	 * @throws InvalidDataTypeException
1205
+	 * @throws InvalidInterfaceException
1206
+	 */
1207
+	private function _set_registration_object()
1208
+	{
1209
+		// get out if we've already set the object
1210
+		if ($this->_registration instanceof EE_Registration) {
1211
+			return true;
1212
+		}
1213
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1214
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1215
+			return true;
1216
+		}
1217
+		$error_msg = sprintf(
1218
+			esc_html__(
1219
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1220
+				'event_espresso'
1221
+			),
1222
+			$REG_ID
1223
+		);
1224
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1225
+		$this->_registration = null;
1226
+		return false;
1227
+	}
1228
+
1229
+
1230
+	/**
1231
+	 * Used to retrieve registrations for the list table.
1232
+	 *
1233
+	 * @param int  $per_page
1234
+	 * @param bool $count
1235
+	 * @param bool $this_month
1236
+	 * @param bool $today
1237
+	 * @return EE_Registration[]|int
1238
+	 * @throws EE_Error
1239
+	 * @throws InvalidArgumentException
1240
+	 * @throws InvalidDataTypeException
1241
+	 * @throws InvalidInterfaceException
1242
+	 */
1243
+	public function get_registrations(
1244
+		$per_page = 10,
1245
+		$count = false,
1246
+		$this_month = false,
1247
+		$today = false
1248
+	) {
1249
+		if ($this_month) {
1250
+			$this->request->setRequestParam('status', 'month');
1251
+		}
1252
+		if ($today) {
1253
+			$this->request->setRequestParam('status', 'today');
1254
+		}
1255
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1256
+		/**
1257
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1258
+		 *
1259
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1260
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1261
+		 *                             or if you have the development copy of EE you can view this at the path:
1262
+		 *                             /docs/G--Model-System/model-query-params.md
1263
+		 */
1264
+		$query_params['group_by'] = '';
1265
+
1266
+		return $count
1267
+			? $this->getRegistrationModel()->count($query_params)
1268
+			/** @type EE_Registration[] */
1269
+			: $this->getRegistrationModel()->get_all($query_params);
1270
+	}
1271
+
1272
+
1273
+	/**
1274
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1275
+	 * Note: this listens to values on the request for some of the query parameters.
1276
+	 *
1277
+	 * @param array $request
1278
+	 * @param int   $per_page
1279
+	 * @param bool  $count
1280
+	 * @return array
1281
+	 * @throws EE_Error
1282
+	 * @throws InvalidArgumentException
1283
+	 * @throws InvalidDataTypeException
1284
+	 * @throws InvalidInterfaceException
1285
+	 */
1286
+	protected function _get_registration_query_parameters(
1287
+		$request = array(),
1288
+		$per_page = 10,
1289
+		$count = false
1290
+	) {
1291
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1292
+		$list_table_query_builder = $this->getLoader()->getNew(
1293
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1294
+			[ null, null, $request ]
1295
+		);
1296
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1297
+	}
1298
+
1299
+
1300
+	public function get_registration_status_array()
1301
+	{
1302
+		return self::$_reg_status;
1303
+	}
1304
+
1305
+
1306
+
1307
+
1308
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1309
+	/**
1310
+	 *        generates HTML for the View Registration Details Admin page
1311
+	 *
1312
+	 * @access protected
1313
+	 * @return void
1314
+	 * @throws DomainException
1315
+	 * @throws EE_Error
1316
+	 * @throws InvalidArgumentException
1317
+	 * @throws InvalidDataTypeException
1318
+	 * @throws InvalidInterfaceException
1319
+	 * @throws EntityNotFoundException
1320
+	 * @throws ReflectionException
1321
+	 */
1322
+	protected function _registration_details()
1323
+	{
1324
+		$this->_template_args = array();
1325
+		$this->_set_registration_object();
1326
+		if (is_object($this->_registration)) {
1327
+			$transaction = $this->_registration->transaction()
1328
+				? $this->_registration->transaction()
1329
+				: EE_Transaction::new_instance();
1330
+			$this->_session = $transaction->session_data();
1331
+			$event_id = $this->_registration->event_ID();
1332
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1333
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1334
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1335
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1336
+			$this->_template_args['grand_total'] = $transaction->total();
1337
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1338
+			// link back to overview
1339
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1340
+			$this->_template_args['registration'] = $this->_registration;
1341
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1342
+				array(
1343
+					'action'   => 'default',
1344
+					'event_id' => $event_id,
1345
+				),
1346
+				REG_ADMIN_URL
1347
+			);
1348
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1349
+				array(
1350
+					'action' => 'default',
1351
+					'EVT_ID' => $event_id,
1352
+					'page'   => 'espresso_transactions',
1353
+				),
1354
+				admin_url('admin.php')
1355
+			);
1356
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1357
+				array(
1358
+					'page'   => 'espresso_events',
1359
+					'action' => 'edit',
1360
+					'post'   => $event_id,
1361
+				),
1362
+				admin_url('admin.php')
1363
+			);
1364
+			// next and previous links
1365
+			$next_reg = $this->_registration->next(
1366
+				null,
1367
+				array(),
1368
+				'REG_ID'
1369
+			);
1370
+			$this->_template_args['next_registration'] = $next_reg
1371
+				? $this->_next_link(
1372
+					EE_Admin_Page::add_query_args_and_nonce(
1373
+						array(
1374
+							'action'  => 'view_registration',
1375
+							'_REG_ID' => $next_reg['REG_ID'],
1376
+						),
1377
+						REG_ADMIN_URL
1378
+					),
1379
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1380
+				)
1381
+				: '';
1382
+			$previous_reg = $this->_registration->previous(
1383
+				null,
1384
+				array(),
1385
+				'REG_ID'
1386
+			);
1387
+			$this->_template_args['previous_registration'] = $previous_reg
1388
+				? $this->_previous_link(
1389
+					EE_Admin_Page::add_query_args_and_nonce(
1390
+						array(
1391
+							'action'  => 'view_registration',
1392
+							'_REG_ID' => $previous_reg['REG_ID'],
1393
+						),
1394
+						REG_ADMIN_URL
1395
+					),
1396
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1397
+				)
1398
+				: '';
1399
+			// grab header
1400
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1401
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1402
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1403
+				$template_path,
1404
+				$this->_template_args,
1405
+				true
1406
+			);
1407
+		} else {
1408
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1409
+		}
1410
+		// the details template wrapper
1411
+		$this->display_admin_page_with_sidebar();
1412
+	}
1413
+
1414
+
1415
+	/**
1416
+	 * @throws EE_Error
1417
+	 * @throws InvalidArgumentException
1418
+	 * @throws InvalidDataTypeException
1419
+	 * @throws InvalidInterfaceException
1420
+	 * @throws ReflectionException
1421
+	 * @since 4.10.2.p
1422
+	 */
1423
+	protected function _registration_details_metaboxes()
1424
+	{
1425
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1426
+		$this->_set_registration_object();
1427
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1428
+		add_meta_box(
1429
+			'edit-reg-status-mbox',
1430
+			esc_html__('Registration Status', 'event_espresso'),
1431
+			array($this, 'set_reg_status_buttons_metabox'),
1432
+			$this->wp_page_slug,
1433
+			'normal',
1434
+			'high'
1435
+		);
1436
+		add_meta_box(
1437
+			'edit-reg-details-mbox',
1438
+			esc_html__('Registration Details', 'event_espresso'),
1439
+			array($this, '_reg_details_meta_box'),
1440
+			$this->wp_page_slug,
1441
+			'normal',
1442
+			'high'
1443
+		);
1444
+		if (
1445
+			$attendee instanceof EE_Attendee
1446
+			&& EE_Registry::instance()->CAP->current_user_can(
1447
+				'ee_read_registration',
1448
+				'edit-reg-questions-mbox',
1449
+				$this->_registration->ID()
1450
+			)
1451
+		) {
1452
+			add_meta_box(
1453
+				'edit-reg-questions-mbox',
1454
+				esc_html__('Registration Form Answers', 'event_espresso'),
1455
+				array($this, '_reg_questions_meta_box'),
1456
+				$this->wp_page_slug,
1457
+				'normal',
1458
+				'high'
1459
+			);
1460
+		}
1461
+		add_meta_box(
1462
+			'edit-reg-registrant-mbox',
1463
+			esc_html__('Contact Details', 'event_espresso'),
1464
+			array($this, '_reg_registrant_side_meta_box'),
1465
+			$this->wp_page_slug,
1466
+			'side',
1467
+			'high'
1468
+		);
1469
+		if ($this->_registration->group_size() > 1) {
1470
+			add_meta_box(
1471
+				'edit-reg-attendees-mbox',
1472
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1473
+				array($this, '_reg_attendees_meta_box'),
1474
+				$this->wp_page_slug,
1475
+				'normal',
1476
+				'high'
1477
+			);
1478
+		}
1479
+	}
1480
+
1481
+
1482
+	/**
1483
+	 * set_reg_status_buttons_metabox
1484
+	 *
1485
+	 * @access protected
1486
+	 * @return void
1487
+	 * @throws EE_Error
1488
+	 * @throws EntityNotFoundException
1489
+	 * @throws InvalidArgumentException
1490
+	 * @throws InvalidDataTypeException
1491
+	 * @throws InvalidInterfaceException
1492
+	 * @throws ReflectionException
1493
+	 */
1494
+	public function set_reg_status_buttons_metabox()
1495
+	{
1496
+		$this->_set_registration_object();
1497
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1498
+		$output = $change_reg_status_form->form_open(
1499
+			self::add_query_args_and_nonce(
1500
+				array(
1501
+					'action' => 'change_reg_status',
1502
+				),
1503
+				REG_ADMIN_URL
1504
+			)
1505
+		);
1506
+		$output .= $change_reg_status_form->get_html();
1507
+		$output .= $change_reg_status_form->form_close();
1508
+		echo $output; // already escaped
1509
+	}
1510
+
1511
+
1512
+	/**
1513
+	 * @return EE_Form_Section_Proper
1514
+	 * @throws EE_Error
1515
+	 * @throws InvalidArgumentException
1516
+	 * @throws InvalidDataTypeException
1517
+	 * @throws InvalidInterfaceException
1518
+	 * @throws EntityNotFoundException
1519
+	 * @throws ReflectionException
1520
+	 */
1521
+	protected function _generate_reg_status_change_form()
1522
+	{
1523
+		$reg_status_change_form_array = array(
1524
+			'name'            => 'reg_status_change_form',
1525
+			'html_id'         => 'reg-status-change-form',
1526
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1527
+			'subsections'     => array(
1528
+				'return'             => new EE_Hidden_Input(
1529
+					array(
1530
+						'name'    => 'return',
1531
+						'default' => 'view_registration',
1532
+					)
1533
+				),
1534
+				'REG_ID'             => new EE_Hidden_Input(
1535
+					array(
1536
+						'name'    => 'REG_ID',
1537
+						'default' => $this->_registration->ID(),
1538
+					)
1539
+				),
1540
+				'current_status'     => new EE_Form_Section_HTML(
1541
+					EEH_HTML::table(
1542
+						EEH_HTML::tr(
1543
+							EEH_HTML::th(
1544
+								EEH_HTML::label(
1545
+									EEH_HTML::strong(
1546
+										esc_html__('Current Registration Status', 'event_espresso')
1547
+									)
1548
+								)
1549
+							)
1550
+							. EEH_HTML::td(
1551
+								EEH_HTML::strong(
1552
+									$this->_registration->pretty_status(),
1553
+									'',
1554
+									'status-' . $this->_registration->status_ID(),
1555
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1556
+								)
1557
+							)
1558
+						)
1559
+					)
1560
+				)
1561
+			)
1562
+		);
1563
+		if (
1564
+			EE_Registry::instance()->CAP->current_user_can(
1565
+				'ee_edit_registration',
1566
+				'toggle_registration_status',
1567
+				$this->_registration->ID()
1568
+			)
1569
+		) {
1570
+			$reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1571
+				$this->_get_reg_statuses(),
1572
+				array(
1573
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1574
+					'default'         => $this->_registration->status_ID(),
1575
+				)
1576
+			);
1577
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1578
+				array(
1579
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1580
+					'default'         => false,
1581
+					'html_help_text'  => esc_html__(
1582
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1583
+						'event_espresso'
1584
+					)
1585
+				)
1586
+			);
1587
+			$reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1588
+				array(
1589
+					'html_class'      => 'button-primary',
1590
+					'html_label_text' => '&nbsp;',
1591
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1592
+				)
1593
+			);
1594
+		}
1595
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1596
+	}
1597
+
1598
+
1599
+	/**
1600
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1601
+	 *
1602
+	 * @return array
1603
+	 * @throws EE_Error
1604
+	 * @throws InvalidArgumentException
1605
+	 * @throws InvalidDataTypeException
1606
+	 * @throws InvalidInterfaceException
1607
+	 * @throws EntityNotFoundException
1608
+	 */
1609
+	protected function _get_reg_statuses()
1610
+	{
1611
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1612
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1613
+		// get current reg status
1614
+		$current_status = $this->_registration->status_ID();
1615
+		// is registration for free event? This will determine whether to display the pending payment option
1616
+		if (
1617
+			$current_status !== EEM_Registration::status_id_pending_payment
1618
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1619
+		) {
1620
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1621
+		}
1622
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1623
+	}
1624
+
1625
+
1626
+	/**
1627
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1628
+	 *
1629
+	 * @param bool $status REG status given for changing registrations to.
1630
+	 * @param bool $notify Whether to send messages notifications or not.
1631
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1632
+	 * @throws DomainException
1633
+	 * @throws EE_Error
1634
+	 * @throws EntityNotFoundException
1635
+	 * @throws InvalidArgumentException
1636
+	 * @throws InvalidDataTypeException
1637
+	 * @throws InvalidInterfaceException
1638
+	 * @throws ReflectionException
1639
+	 * @throws RuntimeException
1640
+	 */
1641
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1642
+	{
1643
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1644
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1645
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1646
+
1647
+		// sanitize $REG_IDs
1648
+		$REG_IDs = array_map('absint', $REG_IDs);
1649
+		// and remove empty entries
1650
+		$REG_IDs = array_filter($REG_IDs);
1651
+
1652
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1653
+
1654
+		/**
1655
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1656
+		 * Currently this value is used downstream by the _process_resend_registration method.
1657
+		 *
1658
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1659
+		 * @param bool                     $status           The status registrations were changed to.
1660
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1661
+		 * @param Registrations_Admin_Page $admin_page_object
1662
+		 */
1663
+		$REG_ID = apply_filters(
1664
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1665
+			$result['REG_ID'],
1666
+			$status,
1667
+			$result['success'],
1668
+			$this
1669
+		);
1670
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1671
+
1672
+		// notify?
1673
+		if (
1674
+			$notify
1675
+			&& $result['success']
1676
+			&& ! empty($REG_ID)
1677
+			&& EE_Registry::instance()->CAP->current_user_can(
1678
+				'ee_send_message',
1679
+				'espresso_registrations_resend_registration'
1680
+			)
1681
+		) {
1682
+			$this->_process_resend_registration();
1683
+		}
1684
+		return $result;
1685
+	}
1686
+
1687
+
1688
+	/**
1689
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1690
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1691
+	 *
1692
+	 * @param array  $REG_IDs
1693
+	 * @param string $status
1694
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1695
+	 *                        slug sent with setting the registration status.
1696
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1697
+	 * @throws EE_Error
1698
+	 * @throws InvalidArgumentException
1699
+	 * @throws InvalidDataTypeException
1700
+	 * @throws InvalidInterfaceException
1701
+	 * @throws ReflectionException
1702
+	 * @throws RuntimeException
1703
+	 * @throws EntityNotFoundException
1704
+	 * @throws DomainException
1705
+	 */
1706
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1707
+	{
1708
+		$success = false;
1709
+		// typecast $REG_IDs
1710
+		$REG_IDs = (array) $REG_IDs;
1711
+		if (! empty($REG_IDs)) {
1712
+			$success = true;
1713
+			// set default status if none is passed
1714
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1715
+			$status_context = $notify
1716
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1717
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1718
+			// loop through REG_ID's and change status
1719
+			foreach ($REG_IDs as $REG_ID) {
1720
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1721
+				if ($registration instanceof EE_Registration) {
1722
+					$registration->set_status(
1723
+						$status,
1724
+						false,
1725
+						new Context(
1726
+							$status_context,
1727
+							esc_html__(
1728
+								'Manually triggered status change on a Registration Admin Page route.',
1729
+								'event_espresso'
1730
+							)
1731
+						)
1732
+					);
1733
+					$result = $registration->save();
1734
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1735
+					$success = $result !== false ? $success : false;
1736
+				}
1737
+			}
1738
+		}
1739
+
1740
+		// return $success and processed registrations
1741
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * Common logic for setting up success message and redirecting to appropriate route
1747
+	 *
1748
+	 * @param string $STS_ID status id for the registration changed to
1749
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1750
+	 * @return void
1751
+	 * @throws DomainException
1752
+	 * @throws EE_Error
1753
+	 * @throws EntityNotFoundException
1754
+	 * @throws InvalidArgumentException
1755
+	 * @throws InvalidDataTypeException
1756
+	 * @throws InvalidInterfaceException
1757
+	 * @throws ReflectionException
1758
+	 * @throws RuntimeException
1759
+	 */
1760
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1761
+	{
1762
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1763
+			: array('success' => false);
1764
+		$success = isset($result['success']) && $result['success'];
1765
+		// setup success message
1766
+		if ($success) {
1767
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1768
+				$msg = sprintf(
1769
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1770
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1771
+				);
1772
+			} else {
1773
+				$msg = sprintf(
1774
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1775
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1776
+				);
1777
+			}
1778
+			EE_Error::add_success($msg);
1779
+		} else {
1780
+			EE_Error::add_error(
1781
+				esc_html__(
1782
+					'Something went wrong, and the status was not changed',
1783
+					'event_espresso'
1784
+				),
1785
+				__FILE__,
1786
+				__LINE__,
1787
+				__FUNCTION__
1788
+			);
1789
+		}
1790
+		$return = $this->request->getRequestParam('return');
1791
+		$route = $return === 'view_registration'
1792
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1793
+			: ['action' => 'default'];
1794
+		$route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1795
+		$this->_redirect_after_action($success, '', '', $route, true);
1796
+	}
1797
+
1798
+
1799
+	/**
1800
+	 * incoming reg status change from reg details page.
1801
+	 *
1802
+	 * @return void
1803
+	 * @throws EE_Error
1804
+	 * @throws EntityNotFoundException
1805
+	 * @throws InvalidArgumentException
1806
+	 * @throws InvalidDataTypeException
1807
+	 * @throws InvalidInterfaceException
1808
+	 * @throws ReflectionException
1809
+	 * @throws RuntimeException
1810
+	 * @throws DomainException
1811
+	 */
1812
+	protected function _change_reg_status()
1813
+	{
1814
+		$this->request->setRequestParam('return', 'view_registration');
1815
+		// set notify based on whether the send notifications toggle is set or not
1816
+		$notify = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1817
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1818
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1819
+		switch ($reg_status) {
1820
+			case EEM_Registration::status_id_approved:
1821
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1822
+				$this->approve_registration($notify);
1823
+				break;
1824
+			case EEM_Registration::status_id_pending_payment:
1825
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1826
+				$this->pending_registration($notify);
1827
+				break;
1828
+			case EEM_Registration::status_id_not_approved:
1829
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1830
+				$this->not_approve_registration($notify);
1831
+				break;
1832
+			case EEM_Registration::status_id_declined:
1833
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1834
+				$this->decline_registration($notify);
1835
+				break;
1836
+			case EEM_Registration::status_id_cancelled:
1837
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1838
+				$this->cancel_registration($notify);
1839
+				break;
1840
+			case EEM_Registration::status_id_wait_list:
1841
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1842
+				$this->wait_list_registration($notify);
1843
+				break;
1844
+			case EEM_Registration::status_id_incomplete:
1845
+			default:
1846
+				$this->request->unSetRequestParam('return');
1847
+				$this->_reg_status_change_return('');
1848
+				break;
1849
+		}
1850
+	}
1851
+
1852
+
1853
+	/**
1854
+	 * Callback for bulk action routes.
1855
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1856
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1857
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1858
+	 * when an action is happening on just a single registration).
1859
+	 *
1860
+	 * @param      $action
1861
+	 * @param bool $notify
1862
+	 */
1863
+	protected function bulk_action_on_registrations($action, $notify = false)
1864
+	{
1865
+		do_action(
1866
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1867
+			$this,
1868
+			$action,
1869
+			$notify
1870
+		);
1871
+		$method = $action . '_registration';
1872
+		if (method_exists($this, $method)) {
1873
+			$this->$method($notify);
1874
+		}
1875
+	}
1876
+
1877
+
1878
+	/**
1879
+	 * approve_registration
1880
+	 *
1881
+	 * @access protected
1882
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1883
+	 * @return void
1884
+	 * @throws EE_Error
1885
+	 * @throws EntityNotFoundException
1886
+	 * @throws InvalidArgumentException
1887
+	 * @throws InvalidDataTypeException
1888
+	 * @throws InvalidInterfaceException
1889
+	 * @throws ReflectionException
1890
+	 * @throws RuntimeException
1891
+	 * @throws DomainException
1892
+	 */
1893
+	protected function approve_registration($notify = false)
1894
+	{
1895
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 *        decline_registration
1901
+	 *
1902
+	 * @access protected
1903
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1904
+	 * @return void
1905
+	 * @throws EE_Error
1906
+	 * @throws EntityNotFoundException
1907
+	 * @throws InvalidArgumentException
1908
+	 * @throws InvalidDataTypeException
1909
+	 * @throws InvalidInterfaceException
1910
+	 * @throws ReflectionException
1911
+	 * @throws RuntimeException
1912
+	 * @throws DomainException
1913
+	 */
1914
+	protected function decline_registration($notify = false)
1915
+	{
1916
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
+	}
1918
+
1919
+
1920
+	/**
1921
+	 *        cancel_registration
1922
+	 *
1923
+	 * @access protected
1924
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1925
+	 * @return void
1926
+	 * @throws EE_Error
1927
+	 * @throws EntityNotFoundException
1928
+	 * @throws InvalidArgumentException
1929
+	 * @throws InvalidDataTypeException
1930
+	 * @throws InvalidInterfaceException
1931
+	 * @throws ReflectionException
1932
+	 * @throws RuntimeException
1933
+	 * @throws DomainException
1934
+	 */
1935
+	protected function cancel_registration($notify = false)
1936
+	{
1937
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1938
+	}
1939
+
1940
+
1941
+	/**
1942
+	 *        not_approve_registration
1943
+	 *
1944
+	 * @access protected
1945
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1946
+	 * @return void
1947
+	 * @throws EE_Error
1948
+	 * @throws EntityNotFoundException
1949
+	 * @throws InvalidArgumentException
1950
+	 * @throws InvalidDataTypeException
1951
+	 * @throws InvalidInterfaceException
1952
+	 * @throws ReflectionException
1953
+	 * @throws RuntimeException
1954
+	 * @throws DomainException
1955
+	 */
1956
+	protected function not_approve_registration($notify = false)
1957
+	{
1958
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1959
+	}
1960
+
1961
+
1962
+	/**
1963
+	 *        decline_registration
1964
+	 *
1965
+	 * @access protected
1966
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1967
+	 * @return void
1968
+	 * @throws EE_Error
1969
+	 * @throws EntityNotFoundException
1970
+	 * @throws InvalidArgumentException
1971
+	 * @throws InvalidDataTypeException
1972
+	 * @throws InvalidInterfaceException
1973
+	 * @throws ReflectionException
1974
+	 * @throws RuntimeException
1975
+	 * @throws DomainException
1976
+	 */
1977
+	protected function pending_registration($notify = false)
1978
+	{
1979
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1980
+	}
1981
+
1982
+
1983
+	/**
1984
+	 * waitlist_registration
1985
+	 *
1986
+	 * @access protected
1987
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1988
+	 * @return void
1989
+	 * @throws EE_Error
1990
+	 * @throws EntityNotFoundException
1991
+	 * @throws InvalidArgumentException
1992
+	 * @throws InvalidDataTypeException
1993
+	 * @throws InvalidInterfaceException
1994
+	 * @throws ReflectionException
1995
+	 * @throws RuntimeException
1996
+	 * @throws DomainException
1997
+	 */
1998
+	protected function wait_list_registration($notify = false)
1999
+	{
2000
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2001
+	}
2002
+
2003
+
2004
+	/**
2005
+	 *        generates HTML for the Registration main meta box
2006
+	 *
2007
+	 * @access public
2008
+	 * @return void
2009
+	 * @throws DomainException
2010
+	 * @throws EE_Error
2011
+	 * @throws InvalidArgumentException
2012
+	 * @throws InvalidDataTypeException
2013
+	 * @throws InvalidInterfaceException
2014
+	 * @throws ReflectionException
2015
+	 * @throws EntityNotFoundException
2016
+	 */
2017
+	public function _reg_details_meta_box()
2018
+	{
2019
+		EEH_Autoloader::register_line_item_display_autoloaders();
2020
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2021
+		EE_Registry::instance()->load_helper('Line_Item');
2022
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2023
+			: EE_Transaction::new_instance();
2024
+		$this->_session = $transaction->session_data();
2025
+		$filters = new EE_Line_Item_Filter_Collection();
2026
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2027
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2028
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2029
+			$filters,
2030
+			$transaction->total_line_item()
2031
+		);
2032
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2033
+		$line_item_display = new EE_Line_Item_Display(
2034
+			'reg_admin_table',
2035
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2036
+		);
2037
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2038
+			$filtered_line_item_tree,
2039
+			array('EE_Registration' => $this->_registration)
2040
+		);
2041
+		$attendee = $this->_registration->attendee();
2042
+		if (
2043
+			EE_Registry::instance()->CAP->current_user_can(
2044
+				'ee_read_transaction',
2045
+				'espresso_transactions_view_transaction'
2046
+			)
2047
+		) {
2048
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2049
+				EE_Admin_Page::add_query_args_and_nonce(
2050
+					array(
2051
+						'action' => 'view_transaction',
2052
+						'TXN_ID' => $transaction->ID(),
2053
+					),
2054
+					TXN_ADMIN_URL
2055
+				),
2056
+				esc_html__(' View Transaction', 'event_espresso'),
2057
+				'button secondary-button right',
2058
+				'dashicons dashicons-cart'
2059
+			);
2060
+		} else {
2061
+			$this->_template_args['view_transaction_button'] = '';
2062
+		}
2063
+		if (
2064
+			$attendee instanceof EE_Attendee
2065
+			&& EE_Registry::instance()->CAP->current_user_can(
2066
+				'ee_send_message',
2067
+				'espresso_registrations_resend_registration'
2068
+			)
2069
+		) {
2070
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2071
+				EE_Admin_Page::add_query_args_and_nonce(
2072
+					array(
2073
+						'action'      => 'resend_registration',
2074
+						'_REG_ID'     => $this->_registration->ID(),
2075
+						'redirect_to' => 'view_registration',
2076
+					),
2077
+					REG_ADMIN_URL
2078
+				),
2079
+				esc_html__(' Resend Registration', 'event_espresso'),
2080
+				'button secondary-button right',
2081
+				'dashicons dashicons-email-alt'
2082
+			);
2083
+		} else {
2084
+			$this->_template_args['resend_registration_button'] = '';
2085
+		}
2086
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2087
+		$payment = $transaction->get_first_related('Payment');
2088
+		$payment = ! $payment instanceof EE_Payment
2089
+			? EE_Payment::new_instance()
2090
+			: $payment;
2091
+		$payment_method = $payment->get_first_related('Payment_Method');
2092
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2093
+			? EE_Payment_Method::new_instance()
2094
+			: $payment_method;
2095
+		$reg_details = array(
2096
+			'payment_method'       => $payment_method->name(),
2097
+			'response_msg'         => $payment->gateway_response(),
2098
+			'registration_id'      => $this->_registration->get('REG_code'),
2099
+			'registration_session' => $this->_registration->session_ID(),
2100
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2101
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2102
+		);
2103
+		if (isset($reg_details['registration_id'])) {
2104
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2105
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2106
+				'Registration ID',
2107
+				'event_espresso'
2108
+			);
2109
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2110
+		}
2111
+		if (isset($reg_details['payment_method'])) {
2112
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2113
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2114
+				'Most Recent Payment Method',
2115
+				'event_espresso'
2116
+			);
2117
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2118
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2119
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2120
+				'Payment method response',
2121
+				'event_espresso'
2122
+			);
2123
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2124
+		}
2125
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2126
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2127
+			'Registration Session',
2128
+			'event_espresso'
2129
+		);
2130
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2131
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2132
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2133
+			'Registration placed from IP',
2134
+			'event_espresso'
2135
+		);
2136
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2137
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2138
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2139
+			'Registrant User Agent',
2140
+			'event_espresso'
2141
+		);
2142
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2143
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2144
+			array(
2145
+				'action'   => 'default',
2146
+				'event_id' => $this->_registration->event_ID(),
2147
+			),
2148
+			REG_ADMIN_URL
2149
+		);
2150
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2151
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2152
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2153
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2154
+	}
2155
+
2156
+
2157
+	/**
2158
+	 * generates HTML for the Registration Questions meta box.
2159
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2160
+	 * otherwise uses new forms system
2161
+	 *
2162
+	 * @access public
2163
+	 * @return void
2164
+	 * @throws DomainException
2165
+	 * @throws EE_Error
2166
+	 * @throws InvalidArgumentException
2167
+	 * @throws InvalidDataTypeException
2168
+	 * @throws InvalidInterfaceException
2169
+	 * @throws ReflectionException
2170
+	 */
2171
+	public function _reg_questions_meta_box()
2172
+	{
2173
+		// allow someone to override this method entirely
2174
+		if (
2175
+			apply_filters(
2176
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2177
+				true,
2178
+				$this,
2179
+				$this->_registration
2180
+			)
2181
+		) {
2182
+			$form = $this->_get_reg_custom_questions_form(
2183
+				$this->_registration->ID()
2184
+			);
2185
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2186
+				? $form->get_html_and_js()
2187
+				: '';
2188
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2189
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2190
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2191
+			EEH_Template::display_template($template_path, $this->_template_args);
2192
+		}
2193
+	}
2194
+
2195
+
2196
+	/**
2197
+	 * form_before_question_group
2198
+	 *
2199
+	 * @deprecated    as of 4.8.32.rc.000
2200
+	 * @access        public
2201
+	 * @param        string $output
2202
+	 * @return        string
2203
+	 */
2204
+	public function form_before_question_group($output)
2205
+	{
2206
+		EE_Error::doing_it_wrong(
2207
+			__CLASS__ . '::' . __FUNCTION__,
2208
+			esc_html__(
2209
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2210
+				'event_espresso'
2211
+			),
2212
+			'4.8.32.rc.000'
2213
+		);
2214
+		return '
2215 2215
 	<table class="form-table ee-width-100">
2216 2216
 		<tbody>
2217 2217
 			';
2218
-    }
2219
-
2220
-
2221
-    /**
2222
-     * form_after_question_group
2223
-     *
2224
-     * @deprecated    as of 4.8.32.rc.000
2225
-     * @access        public
2226
-     * @param        string $output
2227
-     * @return        string
2228
-     */
2229
-    public function form_after_question_group($output)
2230
-    {
2231
-        EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2233
-            esc_html__(
2234
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235
-                'event_espresso'
2236
-            ),
2237
-            '4.8.32.rc.000'
2238
-        );
2239
-        return '
2218
+	}
2219
+
2220
+
2221
+	/**
2222
+	 * form_after_question_group
2223
+	 *
2224
+	 * @deprecated    as of 4.8.32.rc.000
2225
+	 * @access        public
2226
+	 * @param        string $output
2227
+	 * @return        string
2228
+	 */
2229
+	public function form_after_question_group($output)
2230
+	{
2231
+		EE_Error::doing_it_wrong(
2232
+			__CLASS__ . '::' . __FUNCTION__,
2233
+			esc_html__(
2234
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235
+				'event_espresso'
2236
+			),
2237
+			'4.8.32.rc.000'
2238
+		);
2239
+		return '
2240 2240
 			<tr class="hide-if-no-js">
2241 2241
 				<th> </th>
2242 2242
 				<td class="reg-admin-edit-attendee-question-td">
2243 2243
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2244
-               . esc_attr__('click to edit question', 'event_espresso')
2245
-               . '">
2244
+			   . esc_attr__('click to edit question', 'event_espresso')
2245
+			   . '">
2246 2246
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2247
-               . esc_html__('edit the above question group', 'event_espresso')
2248
-               . '</span>
2247
+			   . esc_html__('edit the above question group', 'event_espresso')
2248
+			   . '</span>
2249 2249
 						<div class="dashicons dashicons-edit"></div>
2250 2250
 					</a>
2251 2251
 				</td>
@@ -2253,641 +2253,641 @@  discard block
 block discarded – undo
2253 2253
 		</tbody>
2254 2254
 	</table>
2255 2255
 ';
2256
-    }
2257
-
2258
-
2259
-    /**
2260
-     * form_form_field_label_wrap
2261
-     *
2262
-     * @deprecated    as of 4.8.32.rc.000
2263
-     * @access        public
2264
-     * @param        string $label
2265
-     * @return        string
2266
-     */
2267
-    public function form_form_field_label_wrap($label)
2268
-    {
2269
-        EE_Error::doing_it_wrong(
2270
-            __CLASS__ . '::' . __FUNCTION__,
2271
-            esc_html__(
2272
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2273
-                'event_espresso'
2274
-            ),
2275
-            '4.8.32.rc.000'
2276
-        );
2277
-        return '
2256
+	}
2257
+
2258
+
2259
+	/**
2260
+	 * form_form_field_label_wrap
2261
+	 *
2262
+	 * @deprecated    as of 4.8.32.rc.000
2263
+	 * @access        public
2264
+	 * @param        string $label
2265
+	 * @return        string
2266
+	 */
2267
+	public function form_form_field_label_wrap($label)
2268
+	{
2269
+		EE_Error::doing_it_wrong(
2270
+			__CLASS__ . '::' . __FUNCTION__,
2271
+			esc_html__(
2272
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2273
+				'event_espresso'
2274
+			),
2275
+			'4.8.32.rc.000'
2276
+		);
2277
+		return '
2278 2278
 			<tr>
2279 2279
 				<th>
2280 2280
 					' . $label . '
2281 2281
 				</th>';
2282
-    }
2283
-
2284
-
2285
-    /**
2286
-     * form_form_field_input__wrap
2287
-     *
2288
-     * @deprecated    as of 4.8.32.rc.000
2289
-     * @access        public
2290
-     * @param        string $input
2291
-     * @return        string
2292
-     */
2293
-    public function form_form_field_input__wrap($input)
2294
-    {
2295
-        EE_Error::doing_it_wrong(
2296
-            __CLASS__ . '::' . __FUNCTION__,
2297
-            esc_html__(
2298
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2299
-                'event_espresso'
2300
-            ),
2301
-            '4.8.32.rc.000'
2302
-        );
2303
-        return '
2282
+	}
2283
+
2284
+
2285
+	/**
2286
+	 * form_form_field_input__wrap
2287
+	 *
2288
+	 * @deprecated    as of 4.8.32.rc.000
2289
+	 * @access        public
2290
+	 * @param        string $input
2291
+	 * @return        string
2292
+	 */
2293
+	public function form_form_field_input__wrap($input)
2294
+	{
2295
+		EE_Error::doing_it_wrong(
2296
+			__CLASS__ . '::' . __FUNCTION__,
2297
+			esc_html__(
2298
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2299
+				'event_espresso'
2300
+			),
2301
+			'4.8.32.rc.000'
2302
+		);
2303
+		return '
2304 2304
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2305 2305
 					' . $input . '
2306 2306
 				</td>
2307 2307
 			</tr>';
2308
-    }
2309
-
2310
-
2311
-    /**
2312
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2313
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2314
-     * to display the page
2315
-     *
2316
-     * @access protected
2317
-     * @return void
2318
-     * @throws EE_Error
2319
-     * @throws InvalidArgumentException
2320
-     * @throws InvalidDataTypeException
2321
-     * @throws InvalidInterfaceException
2322
-     * @throws ReflectionException
2323
-     */
2324
-    protected function _update_attendee_registration_form()
2325
-    {
2326
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2327
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2328
-            $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
2329
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2330
-            if ($success) {
2331
-                $what = esc_html__('Registration Form', 'event_espresso');
2332
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2333
-                    : array('action' => 'default');
2334
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2335
-            }
2336
-        }
2337
-    }
2338
-
2339
-
2340
-    /**
2341
-     * Gets the form for saving registrations custom questions (if done
2342
-     * previously retrieves the cached form object, which may have validation errors in it)
2343
-     *
2344
-     * @param int $REG_ID
2345
-     * @return EE_Registration_Custom_Questions_Form
2346
-     * @throws EE_Error
2347
-     * @throws InvalidArgumentException
2348
-     * @throws InvalidDataTypeException
2349
-     * @throws InvalidInterfaceException
2350
-     */
2351
-    protected function _get_reg_custom_questions_form($REG_ID)
2352
-    {
2353
-        if (! $this->_reg_custom_questions_form) {
2354
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2355
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2356
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2357
-            );
2358
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2359
-        }
2360
-        return $this->_reg_custom_questions_form;
2361
-    }
2362
-
2363
-
2364
-    /**
2365
-     * Saves
2366
-     *
2367
-     * @access private
2368
-     * @param bool $REG_ID
2369
-     * @return bool
2370
-     * @throws EE_Error
2371
-     * @throws InvalidArgumentException
2372
-     * @throws InvalidDataTypeException
2373
-     * @throws InvalidInterfaceException
2374
-     * @throws ReflectionException
2375
-     */
2376
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2377
-    {
2378
-        if (! $REG_ID) {
2379
-            EE_Error::add_error(
2380
-                esc_html__(
2381
-                    'An error occurred. No registration ID was received.',
2382
-                    'event_espresso'
2383
-                ),
2384
-                __FILE__,
2385
-                __FUNCTION__,
2386
-                __LINE__
2387
-            );
2388
-        }
2389
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2390
-        $form->receive_form_submission($this->request->requestParams());
2391
-        $success = false;
2392
-        if ($form->is_valid()) {
2393
-            foreach ($form->subforms() as $question_group_form) {
2394
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2395
-                    $where_conditions = array(
2396
-                        'QST_ID' => $question_id,
2397
-                        'REG_ID' => $REG_ID,
2398
-                    );
2399
-                    $possibly_new_values = array(
2400
-                        'ANS_value' => $input->normalized_value(),
2401
-                    );
2402
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2403
-                    if ($answer instanceof EE_Answer) {
2404
-                        $success = $answer->save($possibly_new_values);
2405
-                    } else {
2406
-                        // insert it then
2407
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2408
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2409
-                        $success = $answer->save();
2410
-                    }
2411
-                }
2412
-            }
2413
-        } else {
2414
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2415
-        }
2416
-        return $success;
2417
-    }
2418
-
2419
-
2420
-    /**
2421
-     *        generates HTML for the Registration main meta box
2422
-     *
2423
-     * @access public
2424
-     * @return void
2425
-     * @throws DomainException
2426
-     * @throws EE_Error
2427
-     * @throws InvalidArgumentException
2428
-     * @throws InvalidDataTypeException
2429
-     * @throws InvalidInterfaceException
2430
-     * @throws ReflectionException
2431
-     */
2432
-    public function _reg_attendees_meta_box()
2433
-    {
2434
-        $REG = $this->getRegistrationModel();
2435
-        // get all other registrations on this transaction, and cache
2436
-        // the attendees for them so we don't have to run another query using force_join
2437
-        $registrations = $REG->get_all(
2438
-            array(
2439
-                array(
2440
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2441
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2442
-                ),
2443
-                'force_join' => array('Attendee'),
2444
-                'default_where_conditions' => 'other_models_only',
2445
-            )
2446
-        );
2447
-        $this->_template_args['attendees'] = array();
2448
-        $this->_template_args['attendee_notice'] = '';
2449
-        if (
2450
-            empty($registrations)
2451
-            || (is_array($registrations)
2452
-                && ! EEH_Array::get_one_item_from_array($registrations))
2453
-        ) {
2454
-            EE_Error::add_error(
2455
-                esc_html__(
2456
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2457
-                    'event_espresso'
2458
-                ),
2459
-                __FILE__,
2460
-                __FUNCTION__,
2461
-                __LINE__
2462
-            );
2463
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2464
-        } else {
2465
-            $att_nmbr = 1;
2466
-            foreach ($registrations as $registration) {
2467
-                /* @var $registration EE_Registration */
2468
-                $attendee = $registration->attendee()
2469
-                    ? $registration->attendee()
2470
-                    : $this->getAttendeeModel()->create_default_object();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2474
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2475
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2476
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2477
-                    ', ',
2478
-                    $attendee->full_address_as_array()
2479
-                );
2480
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2481
-                    array(
2482
-                        'action' => 'edit_attendee',
2483
-                        'post'   => $attendee->ID(),
2484
-                    ),
2485
-                    REG_ADMIN_URL
2486
-                );
2487
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2488
-                    ? $registration->event_obj()->name()
2489
-                    : '';
2490
-                $att_nmbr++;
2491
-            }
2492
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2493
-        }
2494
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2495
-        EEH_Template::display_template($template_path, $this->_template_args);
2496
-    }
2497
-
2498
-
2499
-    /**
2500
-     *        generates HTML for the Edit Registration side meta box
2501
-     *
2502
-     * @access public
2503
-     * @return void
2504
-     * @throws DomainException
2505
-     * @throws EE_Error
2506
-     * @throws InvalidArgumentException
2507
-     * @throws InvalidDataTypeException
2508
-     * @throws InvalidInterfaceException
2509
-     * @throws ReflectionException
2510
-     */
2511
-    public function _reg_registrant_side_meta_box()
2512
-    {
2513
-        /*@var $attendee EE_Attendee */
2514
-        $att_check = $this->_registration->attendee();
2515
-        $attendee = $att_check instanceof EE_Attendee
2516
-            ? $att_check
2517
-            : $this->getAttendeeModel()->create_default_object();
2518
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2519
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2520
-        // primary registration object (that way we know if we need to show create button or not)
2521
-        if (! $this->_registration->is_primary_registrant()) {
2522
-            $primary_registration = $this->_registration->get_primary_registration();
2523
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2524
-                : null;
2525
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2526
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2527
-                // custom attendee object so let's not worry about the primary reg.
2528
-                $primary_registration = null;
2529
-            }
2530
-        } else {
2531
-            $primary_registration = null;
2532
-        }
2533
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2534
-        $this->_template_args['fname'] = $attendee->fname();
2535
-        $this->_template_args['lname'] = $attendee->lname();
2536
-        $this->_template_args['email'] = $attendee->email();
2537
-        $this->_template_args['phone'] = $attendee->phone();
2538
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2539
-        // edit link
2540
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2541
-            array(
2542
-                'action' => 'edit_attendee',
2543
-                'post'   => $attendee->ID(),
2544
-            ),
2545
-            REG_ADMIN_URL
2546
-        );
2547
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2548
-        // create link
2549
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2550
-            ? EE_Admin_Page::add_query_args_and_nonce(
2551
-                array(
2552
-                    'action'  => 'duplicate_attendee',
2553
-                    '_REG_ID' => $this->_registration->ID(),
2554
-                ),
2555
-                REG_ADMIN_URL
2556
-            ) : '';
2557
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2558
-        $this->_template_args['att_check'] = $att_check;
2559
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2560
-        EEH_Template::display_template($template_path, $this->_template_args);
2561
-    }
2562
-
2563
-
2564
-    /**
2565
-     * trash or restore registrations
2566
-     *
2567
-     * @param  boolean $trash whether to archive or restore
2568
-     * @return void
2569
-     * @throws EE_Error
2570
-     * @throws InvalidArgumentException
2571
-     * @throws InvalidDataTypeException
2572
-     * @throws InvalidInterfaceException
2573
-     * @throws RuntimeException
2574
-     * @access protected
2575
-     */
2576
-    protected function _trash_or_restore_registrations($trash = true)
2577
-    {
2578
-        // if empty _REG_ID then get out because there's nothing to do
2579
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2580
-        if (empty($REG_IDs)) {
2581
-            EE_Error::add_error(
2582
-                sprintf(
2583
-                    esc_html__(
2584
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2585
-                        'event_espresso'
2586
-                    ),
2587
-                    $trash ? 'trash' : 'restore'
2588
-                ),
2589
-                __FILE__,
2590
-                __LINE__,
2591
-                __FUNCTION__
2592
-            );
2593
-            $this->_redirect_after_action(false, '', '', array(), true);
2594
-        }
2595
-        $success = 0;
2596
-        $overwrite_msgs = false;
2597
-        // Checkboxes
2598
-        $reg_count = count($REG_IDs);
2599
-        // cycle thru checkboxes
2600
-        foreach ($REG_IDs as $REG_ID) {
2601
-            /** @var EE_Registration $REG */
2602
-            $REG = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2603
-            $payments = $REG->registration_payments();
2604
-            if (! empty($payments)) {
2605
-                $name = $REG->attendee() instanceof EE_Attendee
2606
-                    ? $REG->attendee()->full_name()
2607
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2608
-                $overwrite_msgs = true;
2609
-                EE_Error::add_error(
2610
-                    sprintf(
2611
-                        esc_html__(
2612
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2613
-                            'event_espresso'
2614
-                        ),
2615
-                        $name
2616
-                    ),
2617
-                    __FILE__,
2618
-                    __FUNCTION__,
2619
-                    __LINE__
2620
-                );
2621
-                // can't trash this registration because it has payments.
2622
-                continue;
2623
-            }
2624
-            $updated = $trash ? $REG->delete() : $REG->restore();
2625
-            if ($updated) {
2626
-                $success++;
2627
-            }
2628
-        }
2629
-        $this->_redirect_after_action(
2630
-            $success === $reg_count, // were ALL registrations affected?
2631
-            $success > 1
2632
-                ? esc_html__('Registrations', 'event_espresso')
2633
-                : esc_html__('Registration', 'event_espresso'),
2634
-            $trash
2635
-                ? esc_html__('moved to the trash', 'event_espresso')
2636
-                : esc_html__('restored', 'event_espresso'),
2637
-            $this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2638
-            $overwrite_msgs
2639
-        );
2640
-    }
2641
-
2642
-
2643
-    /**
2644
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2645
-     * registration but also.
2646
-     * 1. Removing relations to EE_Attendee
2647
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2648
-     * ALSO trashed.
2649
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2650
-     * 4. Removing relationships between all tickets and the related registrations
2651
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2652
-     * 6. Deleting permanently any related Checkins.
2653
-     *
2654
-     * @return void
2655
-     * @throws EE_Error
2656
-     * @throws InvalidArgumentException
2657
-     * @throws InvalidDataTypeException
2658
-     * @throws InvalidInterfaceException
2659
-     * @throws ReflectionException
2660
-     */
2661
-    protected function _delete_registrations()
2662
-    {
2663
-        $REG_MDL = $this->getRegistrationModel();
2664
-        $success = 0;
2665
-        // Checkboxes
2666
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2667
-
2668
-        if (! empty($REG_IDs)) {
2669
-            // if array has more than one element than success message should be plural
2670
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2671
-            // cycle thru checkboxes
2672
-            foreach ($REG_IDs as $REG_ID) {
2673
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2674
-                if (! $REG instanceof EE_Registration) {
2675
-                    continue;
2676
-                }
2677
-                $deleted = $this->_delete_registration($REG);
2678
-                if (! $deleted) {
2679
-                    $success = 0;
2680
-                }
2681
-            }
2682
-        }
2683
-
2684
-        $what = $success > 1
2685
-            ? esc_html__('Registrations', 'event_espresso')
2686
-            : esc_html__('Registration', 'event_espresso');
2687
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2688
-        $this->_redirect_after_action(
2689
-            $success,
2690
-            $what,
2691
-            $action_desc,
2692
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2693
-            true
2694
-        );
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2700
-     * models get affected.
2701
-     *
2702
-     * @param EE_Registration $REG registration to be deleted permanently
2703
-     * @return bool true = successful deletion, false = fail.
2704
-     * @throws EE_Error
2705
-     * @throws InvalidArgumentException
2706
-     * @throws InvalidDataTypeException
2707
-     * @throws InvalidInterfaceException
2708
-     * @throws ReflectionException
2709
-     */
2710
-    protected function _delete_registration(EE_Registration $REG)
2711
-    {
2712
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713
-        // registrations on the transaction that are NOT trashed.
2714
-        $TXN = $REG->get_first_related('Transaction');
2715
-        if (! $TXN instanceof EE_Transaction) {
2716
-            EE_Error::add_error(
2717
-                sprintf(
2718
-                    esc_html__(
2719
-                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2720
-                        'event_espresso'
2721
-                    ),
2722
-                    $REG->id()
2723
-                ),
2724
-                __FILE__,
2725
-                __FUNCTION__,
2726
-                __LINE__
2727
-            );
2728
-            return false;
2729
-        }
2730
-        $REGS = $TXN->get_many_related('Registration');
2731
-        $all_trashed = true;
2732
-        foreach ($REGS as $registration) {
2733
-            if (! $registration->get('REG_deleted')) {
2734
-                $all_trashed = false;
2735
-            }
2736
-        }
2737
-        if (! $all_trashed) {
2738
-            EE_Error::add_error(
2739
-                esc_html__(
2740
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2741
-                    'event_espresso'
2742
-                ),
2743
-                __FILE__,
2744
-                __FUNCTION__,
2745
-                __LINE__
2746
-            );
2747
-            return false;
2748
-        }
2749
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2750
-        // separately from THIS one).
2751
-        foreach ($REGS as $registration) {
2752
-            // delete related answers
2753
-            $registration->delete_related_permanently('Answer');
2754
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2755
-            $attendee = $registration->get_first_related('Attendee');
2756
-            if ($attendee instanceof EE_Attendee) {
2757
-                $registration->_remove_relation_to($attendee, 'Attendee');
2758
-            }
2759
-            // now remove relationships to tickets on this registration.
2760
-            $registration->_remove_relations('Ticket');
2761
-            // now delete permanently the checkins related to this registration.
2762
-            $registration->delete_related_permanently('Checkin');
2763
-            if ($registration->ID() === $REG->ID()) {
2764
-                continue;
2765
-            } //we don't want to delete permanently the existing registration just yet.
2766
-            // remove relation to transaction for these registrations if NOT the existing registrations
2767
-            $registration->_remove_relations('Transaction');
2768
-            // delete permanently any related messages.
2769
-            $registration->delete_related_permanently('Message');
2770
-            // now delete this registration permanently
2771
-            $registration->delete_permanently();
2772
-        }
2773
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2774
-        // (the transaction and line items should be all that's left).
2775
-        // delete the line items related to the transaction for this registration.
2776
-        $TXN->delete_related_permanently('Line_Item');
2777
-        // we need to remove all the relationships on the transaction
2778
-        $TXN->delete_related_permanently('Payment');
2779
-        $TXN->delete_related_permanently('Extra_Meta');
2780
-        $TXN->delete_related_permanently('Message');
2781
-        // now we can delete this REG permanently (and the transaction of course)
2782
-        $REG->delete_related_permanently('Transaction');
2783
-        return $REG->delete_permanently();
2784
-    }
2785
-
2786
-
2787
-    /**
2788
-     *    generates HTML for the Register New Attendee Admin page
2789
-     *
2790
-     * @access private
2791
-     * @throws DomainException
2792
-     * @throws EE_Error
2793
-     * @throws InvalidArgumentException
2794
-     * @throws InvalidDataTypeException
2795
-     * @throws InvalidInterfaceException
2796
-     * @throws ReflectionException
2797
-     */
2798
-    public function new_registration()
2799
-    {
2800
-        if (! $this->_set_reg_event()) {
2801
-            throw new EE_Error(
2802
-                esc_html__(
2803
-                    'Unable to continue with registering because there is no Event ID in the request',
2804
-                    'event_espresso'
2805
-                )
2806
-            );
2807
-        }
2808
-        /** @var CurrentPage $current_page */
2809
-        $current_page = $this->loader->getShared(CurrentPage::class);
2810
-        $current_page->setEspressoPage(true);
2811
-        // gotta start with a clean slate if we're not coming here via ajax
2812
-        if (
2813
-            ! $this->request->isAjax()
2814
-            && (
2815
-                ! $this->request->requestParamIsSet('processing_registration')
2816
-                || $this->request->requestParamIsSet('step_error')
2817
-            )
2818
-        ) {
2819
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2820
-        }
2821
-        $this->_template_args['event_name'] = '';
2822
-        // event name
2823
-        if ($this->_reg_event) {
2824
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2825
-            $edit_event_url = self::add_query_args_and_nonce(
2826
-                array(
2827
-                    'action' => 'edit',
2828
-                    'post'   => $this->_reg_event->ID(),
2829
-                ),
2830
-                EVENTS_ADMIN_URL
2831
-            );
2832
-            $edit_event_lnk = '<a href="'
2833
-                              . $edit_event_url
2834
-                              . '" title="'
2835
-                              . esc_attr__('Edit ', 'event_espresso')
2836
-                              . $this->_reg_event->name()
2837
-                              . '">'
2838
-                              . esc_html__('Edit Event', 'event_espresso')
2839
-                              . '</a>';
2840
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2841
-                                                   . $edit_event_lnk
2842
-                                                   . '</span>';
2843
-        }
2844
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2845
-        if ($this->request->isAjax()) {
2846
-            $this->_return_json();
2847
-        }
2848
-        // grab header
2849
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2850
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2851
-            $template_path,
2852
-            $this->_template_args,
2853
-            true
2854
-        );
2855
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2856
-        // the details template wrapper
2857
-        $this->display_admin_page_with_sidebar();
2858
-    }
2859
-
2860
-
2861
-    /**
2862
-     * This returns the content for a registration step
2863
-     *
2864
-     * @access protected
2865
-     * @return string html
2866
-     * @throws DomainException
2867
-     * @throws EE_Error
2868
-     * @throws InvalidArgumentException
2869
-     * @throws InvalidDataTypeException
2870
-     * @throws InvalidInterfaceException
2871
-     * @throws ReflectionException
2872
-     */
2873
-    protected function _get_registration_step_content()
2874
-    {
2875
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2876
-            $warning_msg = sprintf(
2877
-                esc_html__(
2878
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2879
-                    'event_espresso'
2880
-                ),
2881
-                '<br />',
2882
-                '<h3 class="important-notice">',
2883
-                '</h3>',
2884
-                '<div class="float-right">',
2885
-                '<span id="redirect_timer" class="important-notice">30</span>',
2886
-                '</div>',
2887
-                '<b>',
2888
-                '</b>'
2889
-            );
2890
-            return '
2308
+	}
2309
+
2310
+
2311
+	/**
2312
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2313
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2314
+	 * to display the page
2315
+	 *
2316
+	 * @access protected
2317
+	 * @return void
2318
+	 * @throws EE_Error
2319
+	 * @throws InvalidArgumentException
2320
+	 * @throws InvalidDataTypeException
2321
+	 * @throws InvalidInterfaceException
2322
+	 * @throws ReflectionException
2323
+	 */
2324
+	protected function _update_attendee_registration_form()
2325
+	{
2326
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2327
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2328
+			$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
2329
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2330
+			if ($success) {
2331
+				$what = esc_html__('Registration Form', 'event_espresso');
2332
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2333
+					: array('action' => 'default');
2334
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2335
+			}
2336
+		}
2337
+	}
2338
+
2339
+
2340
+	/**
2341
+	 * Gets the form for saving registrations custom questions (if done
2342
+	 * previously retrieves the cached form object, which may have validation errors in it)
2343
+	 *
2344
+	 * @param int $REG_ID
2345
+	 * @return EE_Registration_Custom_Questions_Form
2346
+	 * @throws EE_Error
2347
+	 * @throws InvalidArgumentException
2348
+	 * @throws InvalidDataTypeException
2349
+	 * @throws InvalidInterfaceException
2350
+	 */
2351
+	protected function _get_reg_custom_questions_form($REG_ID)
2352
+	{
2353
+		if (! $this->_reg_custom_questions_form) {
2354
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2355
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2356
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2357
+			);
2358
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2359
+		}
2360
+		return $this->_reg_custom_questions_form;
2361
+	}
2362
+
2363
+
2364
+	/**
2365
+	 * Saves
2366
+	 *
2367
+	 * @access private
2368
+	 * @param bool $REG_ID
2369
+	 * @return bool
2370
+	 * @throws EE_Error
2371
+	 * @throws InvalidArgumentException
2372
+	 * @throws InvalidDataTypeException
2373
+	 * @throws InvalidInterfaceException
2374
+	 * @throws ReflectionException
2375
+	 */
2376
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2377
+	{
2378
+		if (! $REG_ID) {
2379
+			EE_Error::add_error(
2380
+				esc_html__(
2381
+					'An error occurred. No registration ID was received.',
2382
+					'event_espresso'
2383
+				),
2384
+				__FILE__,
2385
+				__FUNCTION__,
2386
+				__LINE__
2387
+			);
2388
+		}
2389
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2390
+		$form->receive_form_submission($this->request->requestParams());
2391
+		$success = false;
2392
+		if ($form->is_valid()) {
2393
+			foreach ($form->subforms() as $question_group_form) {
2394
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2395
+					$where_conditions = array(
2396
+						'QST_ID' => $question_id,
2397
+						'REG_ID' => $REG_ID,
2398
+					);
2399
+					$possibly_new_values = array(
2400
+						'ANS_value' => $input->normalized_value(),
2401
+					);
2402
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2403
+					if ($answer instanceof EE_Answer) {
2404
+						$success = $answer->save($possibly_new_values);
2405
+					} else {
2406
+						// insert it then
2407
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2408
+						$answer = EE_Answer::new_instance($cols_n_vals);
2409
+						$success = $answer->save();
2410
+					}
2411
+				}
2412
+			}
2413
+		} else {
2414
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2415
+		}
2416
+		return $success;
2417
+	}
2418
+
2419
+
2420
+	/**
2421
+	 *        generates HTML for the Registration main meta box
2422
+	 *
2423
+	 * @access public
2424
+	 * @return void
2425
+	 * @throws DomainException
2426
+	 * @throws EE_Error
2427
+	 * @throws InvalidArgumentException
2428
+	 * @throws InvalidDataTypeException
2429
+	 * @throws InvalidInterfaceException
2430
+	 * @throws ReflectionException
2431
+	 */
2432
+	public function _reg_attendees_meta_box()
2433
+	{
2434
+		$REG = $this->getRegistrationModel();
2435
+		// get all other registrations on this transaction, and cache
2436
+		// the attendees for them so we don't have to run another query using force_join
2437
+		$registrations = $REG->get_all(
2438
+			array(
2439
+				array(
2440
+					'TXN_ID' => $this->_registration->transaction_ID(),
2441
+					'REG_ID' => array('!=', $this->_registration->ID()),
2442
+				),
2443
+				'force_join' => array('Attendee'),
2444
+				'default_where_conditions' => 'other_models_only',
2445
+			)
2446
+		);
2447
+		$this->_template_args['attendees'] = array();
2448
+		$this->_template_args['attendee_notice'] = '';
2449
+		if (
2450
+			empty($registrations)
2451
+			|| (is_array($registrations)
2452
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2453
+		) {
2454
+			EE_Error::add_error(
2455
+				esc_html__(
2456
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2457
+					'event_espresso'
2458
+				),
2459
+				__FILE__,
2460
+				__FUNCTION__,
2461
+				__LINE__
2462
+			);
2463
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2464
+		} else {
2465
+			$att_nmbr = 1;
2466
+			foreach ($registrations as $registration) {
2467
+				/* @var $registration EE_Registration */
2468
+				$attendee = $registration->attendee()
2469
+					? $registration->attendee()
2470
+					: $this->getAttendeeModel()->create_default_object();
2471
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2472
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2473
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2474
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2475
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2476
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2477
+					', ',
2478
+					$attendee->full_address_as_array()
2479
+				);
2480
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2481
+					array(
2482
+						'action' => 'edit_attendee',
2483
+						'post'   => $attendee->ID(),
2484
+					),
2485
+					REG_ADMIN_URL
2486
+				);
2487
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2488
+					? $registration->event_obj()->name()
2489
+					: '';
2490
+				$att_nmbr++;
2491
+			}
2492
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2493
+		}
2494
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2495
+		EEH_Template::display_template($template_path, $this->_template_args);
2496
+	}
2497
+
2498
+
2499
+	/**
2500
+	 *        generates HTML for the Edit Registration side meta box
2501
+	 *
2502
+	 * @access public
2503
+	 * @return void
2504
+	 * @throws DomainException
2505
+	 * @throws EE_Error
2506
+	 * @throws InvalidArgumentException
2507
+	 * @throws InvalidDataTypeException
2508
+	 * @throws InvalidInterfaceException
2509
+	 * @throws ReflectionException
2510
+	 */
2511
+	public function _reg_registrant_side_meta_box()
2512
+	{
2513
+		/*@var $attendee EE_Attendee */
2514
+		$att_check = $this->_registration->attendee();
2515
+		$attendee = $att_check instanceof EE_Attendee
2516
+			? $att_check
2517
+			: $this->getAttendeeModel()->create_default_object();
2518
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2519
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2520
+		// primary registration object (that way we know if we need to show create button or not)
2521
+		if (! $this->_registration->is_primary_registrant()) {
2522
+			$primary_registration = $this->_registration->get_primary_registration();
2523
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2524
+				: null;
2525
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2526
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2527
+				// custom attendee object so let's not worry about the primary reg.
2528
+				$primary_registration = null;
2529
+			}
2530
+		} else {
2531
+			$primary_registration = null;
2532
+		}
2533
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2534
+		$this->_template_args['fname'] = $attendee->fname();
2535
+		$this->_template_args['lname'] = $attendee->lname();
2536
+		$this->_template_args['email'] = $attendee->email();
2537
+		$this->_template_args['phone'] = $attendee->phone();
2538
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2539
+		// edit link
2540
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2541
+			array(
2542
+				'action' => 'edit_attendee',
2543
+				'post'   => $attendee->ID(),
2544
+			),
2545
+			REG_ADMIN_URL
2546
+		);
2547
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2548
+		// create link
2549
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2550
+			? EE_Admin_Page::add_query_args_and_nonce(
2551
+				array(
2552
+					'action'  => 'duplicate_attendee',
2553
+					'_REG_ID' => $this->_registration->ID(),
2554
+				),
2555
+				REG_ADMIN_URL
2556
+			) : '';
2557
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2558
+		$this->_template_args['att_check'] = $att_check;
2559
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2560
+		EEH_Template::display_template($template_path, $this->_template_args);
2561
+	}
2562
+
2563
+
2564
+	/**
2565
+	 * trash or restore registrations
2566
+	 *
2567
+	 * @param  boolean $trash whether to archive or restore
2568
+	 * @return void
2569
+	 * @throws EE_Error
2570
+	 * @throws InvalidArgumentException
2571
+	 * @throws InvalidDataTypeException
2572
+	 * @throws InvalidInterfaceException
2573
+	 * @throws RuntimeException
2574
+	 * @access protected
2575
+	 */
2576
+	protected function _trash_or_restore_registrations($trash = true)
2577
+	{
2578
+		// if empty _REG_ID then get out because there's nothing to do
2579
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2580
+		if (empty($REG_IDs)) {
2581
+			EE_Error::add_error(
2582
+				sprintf(
2583
+					esc_html__(
2584
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2585
+						'event_espresso'
2586
+					),
2587
+					$trash ? 'trash' : 'restore'
2588
+				),
2589
+				__FILE__,
2590
+				__LINE__,
2591
+				__FUNCTION__
2592
+			);
2593
+			$this->_redirect_after_action(false, '', '', array(), true);
2594
+		}
2595
+		$success = 0;
2596
+		$overwrite_msgs = false;
2597
+		// Checkboxes
2598
+		$reg_count = count($REG_IDs);
2599
+		// cycle thru checkboxes
2600
+		foreach ($REG_IDs as $REG_ID) {
2601
+			/** @var EE_Registration $REG */
2602
+			$REG = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2603
+			$payments = $REG->registration_payments();
2604
+			if (! empty($payments)) {
2605
+				$name = $REG->attendee() instanceof EE_Attendee
2606
+					? $REG->attendee()->full_name()
2607
+					: esc_html__('Unknown Attendee', 'event_espresso');
2608
+				$overwrite_msgs = true;
2609
+				EE_Error::add_error(
2610
+					sprintf(
2611
+						esc_html__(
2612
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2613
+							'event_espresso'
2614
+						),
2615
+						$name
2616
+					),
2617
+					__FILE__,
2618
+					__FUNCTION__,
2619
+					__LINE__
2620
+				);
2621
+				// can't trash this registration because it has payments.
2622
+				continue;
2623
+			}
2624
+			$updated = $trash ? $REG->delete() : $REG->restore();
2625
+			if ($updated) {
2626
+				$success++;
2627
+			}
2628
+		}
2629
+		$this->_redirect_after_action(
2630
+			$success === $reg_count, // were ALL registrations affected?
2631
+			$success > 1
2632
+				? esc_html__('Registrations', 'event_espresso')
2633
+				: esc_html__('Registration', 'event_espresso'),
2634
+			$trash
2635
+				? esc_html__('moved to the trash', 'event_espresso')
2636
+				: esc_html__('restored', 'event_espresso'),
2637
+			$this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2638
+			$overwrite_msgs
2639
+		);
2640
+	}
2641
+
2642
+
2643
+	/**
2644
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2645
+	 * registration but also.
2646
+	 * 1. Removing relations to EE_Attendee
2647
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2648
+	 * ALSO trashed.
2649
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2650
+	 * 4. Removing relationships between all tickets and the related registrations
2651
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2652
+	 * 6. Deleting permanently any related Checkins.
2653
+	 *
2654
+	 * @return void
2655
+	 * @throws EE_Error
2656
+	 * @throws InvalidArgumentException
2657
+	 * @throws InvalidDataTypeException
2658
+	 * @throws InvalidInterfaceException
2659
+	 * @throws ReflectionException
2660
+	 */
2661
+	protected function _delete_registrations()
2662
+	{
2663
+		$REG_MDL = $this->getRegistrationModel();
2664
+		$success = 0;
2665
+		// Checkboxes
2666
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2667
+
2668
+		if (! empty($REG_IDs)) {
2669
+			// if array has more than one element than success message should be plural
2670
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2671
+			// cycle thru checkboxes
2672
+			foreach ($REG_IDs as $REG_ID) {
2673
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2674
+				if (! $REG instanceof EE_Registration) {
2675
+					continue;
2676
+				}
2677
+				$deleted = $this->_delete_registration($REG);
2678
+				if (! $deleted) {
2679
+					$success = 0;
2680
+				}
2681
+			}
2682
+		}
2683
+
2684
+		$what = $success > 1
2685
+			? esc_html__('Registrations', 'event_espresso')
2686
+			: esc_html__('Registration', 'event_espresso');
2687
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2688
+		$this->_redirect_after_action(
2689
+			$success,
2690
+			$what,
2691
+			$action_desc,
2692
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2693
+			true
2694
+		);
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2700
+	 * models get affected.
2701
+	 *
2702
+	 * @param EE_Registration $REG registration to be deleted permanently
2703
+	 * @return bool true = successful deletion, false = fail.
2704
+	 * @throws EE_Error
2705
+	 * @throws InvalidArgumentException
2706
+	 * @throws InvalidDataTypeException
2707
+	 * @throws InvalidInterfaceException
2708
+	 * @throws ReflectionException
2709
+	 */
2710
+	protected function _delete_registration(EE_Registration $REG)
2711
+	{
2712
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713
+		// registrations on the transaction that are NOT trashed.
2714
+		$TXN = $REG->get_first_related('Transaction');
2715
+		if (! $TXN instanceof EE_Transaction) {
2716
+			EE_Error::add_error(
2717
+				sprintf(
2718
+					esc_html__(
2719
+						'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2720
+						'event_espresso'
2721
+					),
2722
+					$REG->id()
2723
+				),
2724
+				__FILE__,
2725
+				__FUNCTION__,
2726
+				__LINE__
2727
+			);
2728
+			return false;
2729
+		}
2730
+		$REGS = $TXN->get_many_related('Registration');
2731
+		$all_trashed = true;
2732
+		foreach ($REGS as $registration) {
2733
+			if (! $registration->get('REG_deleted')) {
2734
+				$all_trashed = false;
2735
+			}
2736
+		}
2737
+		if (! $all_trashed) {
2738
+			EE_Error::add_error(
2739
+				esc_html__(
2740
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2741
+					'event_espresso'
2742
+				),
2743
+				__FILE__,
2744
+				__FUNCTION__,
2745
+				__LINE__
2746
+			);
2747
+			return false;
2748
+		}
2749
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2750
+		// separately from THIS one).
2751
+		foreach ($REGS as $registration) {
2752
+			// delete related answers
2753
+			$registration->delete_related_permanently('Answer');
2754
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2755
+			$attendee = $registration->get_first_related('Attendee');
2756
+			if ($attendee instanceof EE_Attendee) {
2757
+				$registration->_remove_relation_to($attendee, 'Attendee');
2758
+			}
2759
+			// now remove relationships to tickets on this registration.
2760
+			$registration->_remove_relations('Ticket');
2761
+			// now delete permanently the checkins related to this registration.
2762
+			$registration->delete_related_permanently('Checkin');
2763
+			if ($registration->ID() === $REG->ID()) {
2764
+				continue;
2765
+			} //we don't want to delete permanently the existing registration just yet.
2766
+			// remove relation to transaction for these registrations if NOT the existing registrations
2767
+			$registration->_remove_relations('Transaction');
2768
+			// delete permanently any related messages.
2769
+			$registration->delete_related_permanently('Message');
2770
+			// now delete this registration permanently
2771
+			$registration->delete_permanently();
2772
+		}
2773
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2774
+		// (the transaction and line items should be all that's left).
2775
+		// delete the line items related to the transaction for this registration.
2776
+		$TXN->delete_related_permanently('Line_Item');
2777
+		// we need to remove all the relationships on the transaction
2778
+		$TXN->delete_related_permanently('Payment');
2779
+		$TXN->delete_related_permanently('Extra_Meta');
2780
+		$TXN->delete_related_permanently('Message');
2781
+		// now we can delete this REG permanently (and the transaction of course)
2782
+		$REG->delete_related_permanently('Transaction');
2783
+		return $REG->delete_permanently();
2784
+	}
2785
+
2786
+
2787
+	/**
2788
+	 *    generates HTML for the Register New Attendee Admin page
2789
+	 *
2790
+	 * @access private
2791
+	 * @throws DomainException
2792
+	 * @throws EE_Error
2793
+	 * @throws InvalidArgumentException
2794
+	 * @throws InvalidDataTypeException
2795
+	 * @throws InvalidInterfaceException
2796
+	 * @throws ReflectionException
2797
+	 */
2798
+	public function new_registration()
2799
+	{
2800
+		if (! $this->_set_reg_event()) {
2801
+			throw new EE_Error(
2802
+				esc_html__(
2803
+					'Unable to continue with registering because there is no Event ID in the request',
2804
+					'event_espresso'
2805
+				)
2806
+			);
2807
+		}
2808
+		/** @var CurrentPage $current_page */
2809
+		$current_page = $this->loader->getShared(CurrentPage::class);
2810
+		$current_page->setEspressoPage(true);
2811
+		// gotta start with a clean slate if we're not coming here via ajax
2812
+		if (
2813
+			! $this->request->isAjax()
2814
+			&& (
2815
+				! $this->request->requestParamIsSet('processing_registration')
2816
+				|| $this->request->requestParamIsSet('step_error')
2817
+			)
2818
+		) {
2819
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2820
+		}
2821
+		$this->_template_args['event_name'] = '';
2822
+		// event name
2823
+		if ($this->_reg_event) {
2824
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2825
+			$edit_event_url = self::add_query_args_and_nonce(
2826
+				array(
2827
+					'action' => 'edit',
2828
+					'post'   => $this->_reg_event->ID(),
2829
+				),
2830
+				EVENTS_ADMIN_URL
2831
+			);
2832
+			$edit_event_lnk = '<a href="'
2833
+							  . $edit_event_url
2834
+							  . '" title="'
2835
+							  . esc_attr__('Edit ', 'event_espresso')
2836
+							  . $this->_reg_event->name()
2837
+							  . '">'
2838
+							  . esc_html__('Edit Event', 'event_espresso')
2839
+							  . '</a>';
2840
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2841
+												   . $edit_event_lnk
2842
+												   . '</span>';
2843
+		}
2844
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2845
+		if ($this->request->isAjax()) {
2846
+			$this->_return_json();
2847
+		}
2848
+		// grab header
2849
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2850
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2851
+			$template_path,
2852
+			$this->_template_args,
2853
+			true
2854
+		);
2855
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2856
+		// the details template wrapper
2857
+		$this->display_admin_page_with_sidebar();
2858
+	}
2859
+
2860
+
2861
+	/**
2862
+	 * This returns the content for a registration step
2863
+	 *
2864
+	 * @access protected
2865
+	 * @return string html
2866
+	 * @throws DomainException
2867
+	 * @throws EE_Error
2868
+	 * @throws InvalidArgumentException
2869
+	 * @throws InvalidDataTypeException
2870
+	 * @throws InvalidInterfaceException
2871
+	 * @throws ReflectionException
2872
+	 */
2873
+	protected function _get_registration_step_content()
2874
+	{
2875
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2876
+			$warning_msg = sprintf(
2877
+				esc_html__(
2878
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2879
+					'event_espresso'
2880
+				),
2881
+				'<br />',
2882
+				'<h3 class="important-notice">',
2883
+				'</h3>',
2884
+				'<div class="float-right">',
2885
+				'<span id="redirect_timer" class="important-notice">30</span>',
2886
+				'</div>',
2887
+				'<b>',
2888
+				'</b>'
2889
+			);
2890
+			return '
2891 2891
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2892 2892
 	<script >
2893 2893
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2900,856 +2900,856 @@  discard block
 block discarded – undo
2900 2900
 	        }
2901 2901
 	    }, 800 );
2902 2902
 	</script >';
2903
-        }
2904
-        $template_args = array(
2905
-            'title'                    => '',
2906
-            'content'                  => '',
2907
-            'step_button_text'         => '',
2908
-            'show_notification_toggle' => false,
2909
-        );
2910
-        // to indicate we're processing a new registration
2911
-        $hidden_fields = array(
2912
-            'processing_registration' => array(
2913
-                'type'  => 'hidden',
2914
-                'value' => 0,
2915
-            ),
2916
-            'event_id'                => array(
2917
-                'type'  => 'hidden',
2918
-                'value' => $this->_reg_event->ID(),
2919
-            ),
2920
-        );
2921
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2922
-        $cart = EE_Registry::instance()->SSN->cart();
2923
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2924
-        switch ($step) {
2925
-            case 'ticket':
2926
-                $hidden_fields['processing_registration']['value'] = 1;
2927
-                $template_args['title'] = esc_html__(
2928
-                    'Step One: Select the Ticket for this registration',
2929
-                    'event_espresso'
2930
-                );
2931
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2932
-                $template_args['content'] .= '</div>';
2933
-                $template_args['step_button_text'] = esc_html__(
2934
-                    'Add Tickets and Continue to Registrant Details',
2935
-                    'event_espresso'
2936
-                );
2937
-                $template_args['show_notification_toggle'] = false;
2938
-                break;
2939
-            case 'questions':
2940
-                $hidden_fields['processing_registration']['value'] = 2;
2941
-                $template_args['title'] = esc_html__(
2942
-                    'Step Two: Add Registrant Details for this Registration',
2943
-                    'event_espresso'
2944
-                );
2945
-                // in theory, we should be able to run EED_SPCO at this point
2946
-                // because the cart should have been set up properly by the first process_reg_step run.
2947
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2948
-                $template_args['step_button_text'] = esc_html__(
2949
-                    'Save Registration and Continue to Details',
2950
-                    'event_espresso'
2951
-                );
2952
-                $template_args['show_notification_toggle'] = true;
2953
-                break;
2954
-        }
2955
-        // we come back to the process_registration_step route.
2956
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2957
-        return EEH_Template::display_template(
2958
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2959
-            $template_args,
2960
-            true
2961
-        );
2962
-    }
2963
-
2964
-
2965
-    /**
2966
-     *        set_reg_event
2967
-     *
2968
-     * @access private
2969
-     * @return bool
2970
-     * @throws EE_Error
2971
-     * @throws InvalidArgumentException
2972
-     * @throws InvalidDataTypeException
2973
-     * @throws InvalidInterfaceException
2974
-     */
2975
-    private function _set_reg_event()
2976
-    {
2977
-        if (is_object($this->_reg_event)) {
2978
-            return true;
2979
-        }
2980
-
2981
-        $EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2982
-        if (! $EVT_ID) {
2983
-            return false;
2984
-        }
2985
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2986
-        return true;
2987
-    }
2988
-
2989
-
2990
-    /**
2991
-     * process_reg_step
2992
-     *
2993
-     * @return void
2994
-     * @throws DomainException
2995
-     * @throws EE_Error
2996
-     * @throws InvalidArgumentException
2997
-     * @throws InvalidDataTypeException
2998
-     * @throws InvalidInterfaceException
2999
-     * @throws ReflectionException
3000
-     * @throws RuntimeException
3001
-     */
3002
-    public function process_reg_step()
3003
-    {
3004
-        EE_System::do_not_cache();
3005
-        $this->_set_reg_event();
3006
-        /** @var CurrentPage $current_page */
3007
-        $current_page = $this->loader->getShared(CurrentPage::class);
3008
-        $current_page->setEspressoPage(true);
3009
-        $this->request->setRequestParam('uts', time());
3010
-        // what step are we on?
3011
-        $cart = EE_Registry::instance()->SSN->cart();
3012
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3013
-        // if doing ajax then we need to verify the nonce
3014
-        if ($this->request->isAjax()) {
3015
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3016
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3017
-        }
3018
-        switch ($step) {
3019
-            case 'ticket':
3020
-                // process ticket selection
3021
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3022
-                if ($success) {
3023
-                    EE_Error::add_success(
3024
-                        esc_html__(
3025
-                            'Tickets Selected. Now complete the registration.',
3026
-                            'event_espresso'
3027
-                        )
3028
-                    );
3029
-                } else {
3030
-                    $this->request->setRequestParam('step_error', true);
3031
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3032
-                }
3033
-                if ($this->request->isAjax()) {
3034
-                    $this->new_registration(); // display next step
3035
-                } else {
3036
-                    $query_args = array(
3037
-                        'action'                  => 'new_registration',
3038
-                        'processing_registration' => 1,
3039
-                        'event_id'                => $this->_reg_event->ID(),
3040
-                        'uts'                     => time(),
3041
-                    );
3042
-                    $this->_redirect_after_action(
3043
-                        false,
3044
-                        '',
3045
-                        '',
3046
-                        $query_args,
3047
-                        true
3048
-                    );
3049
-                }
3050
-                break;
3051
-            case 'questions':
3052
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3053
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3054
-                }
3055
-                // process registration
3056
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3057
-                if ($cart instanceof EE_Cart) {
3058
-                    $grand_total = $cart->get_cart_grand_total();
3059
-                    if ($grand_total instanceof EE_Line_Item) {
3060
-                        $grand_total->save_this_and_descendants_to_txn();
3061
-                    }
3062
-                }
3063
-                if (! $transaction instanceof EE_Transaction) {
3064
-                    $query_args = array(
3065
-                        'action'                  => 'new_registration',
3066
-                        'processing_registration' => 2,
3067
-                        'event_id'                => $this->_reg_event->ID(),
3068
-                        'uts'                     => time(),
3069
-                    );
3070
-                    if ($this->request->isAjax()) {
3071
-                        // display registration form again because there are errors (maybe validation?)
3072
-                        $this->new_registration();
3073
-                        return;
3074
-                    }
3075
-                    $this->_redirect_after_action(
3076
-                        false,
3077
-                        '',
3078
-                        '',
3079
-                        $query_args,
3080
-                        true
3081
-                    );
3082
-                    return;
3083
-                }
3084
-                // maybe update status, and make sure to save transaction if not done already
3085
-                if (! $transaction->update_status_based_on_total_paid()) {
3086
-                    $transaction->save();
3087
-                }
3088
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3089
-                $query_args = array(
3090
-                    'action'        => 'redirect_to_txn',
3091
-                    'TXN_ID'        => $transaction->ID(),
3092
-                    'EVT_ID'        => $this->_reg_event->ID(),
3093
-                    'event_name'    => urlencode($this->_reg_event->name()),
3094
-                    'redirect_from' => 'new_registration',
3095
-                );
3096
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3097
-                break;
3098
-        }
3099
-        // what are you looking here for?  Should be nothing to do at this point.
3100
-    }
3101
-
3102
-
3103
-    /**
3104
-     * redirect_to_txn
3105
-     *
3106
-     * @access public
3107
-     * @return void
3108
-     * @throws EE_Error
3109
-     * @throws InvalidArgumentException
3110
-     * @throws InvalidDataTypeException
3111
-     * @throws InvalidInterfaceException
3112
-     * @throws ReflectionException
3113
-     */
3114
-    public function redirect_to_txn()
3115
-    {
3116
-        EE_System::do_not_cache();
3117
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3118
-        $query_args = array(
3119
-            'action' => 'view_transaction',
3120
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3121
-            'page'   => 'espresso_transactions',
3122
-        );
3123
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3124
-            $query_args['EVT_ID'] = $this->request->getRequestParam('EVT_ID', 0, 'int');
3125
-            $query_args['event_name'] = urlencode($this->request->getRequestParam('event_name'));
3126
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3127
-        }
3128
-        EE_Error::add_success(
3129
-            esc_html__(
3130
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3131
-                'event_espresso'
3132
-            )
3133
-        );
3134
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3135
-    }
3136
-
3137
-
3138
-    /**
3139
-     *        generates HTML for the Attendee Contact List
3140
-     *
3141
-     * @access protected
3142
-     * @return void
3143
-     * @throws DomainException
3144
-     * @throws EE_Error
3145
-     */
3146
-    protected function _attendee_contact_list_table()
3147
-    {
3148
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3149
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3150
-        $this->display_admin_list_table_page_with_no_sidebar();
3151
-    }
3152
-
3153
-
3154
-    /**
3155
-     *        get_attendees
3156
-     *
3157
-     * @param      $per_page
3158
-     * @param bool $count whether to return count or data.
3159
-     * @param bool $trash
3160
-     * @return array
3161
-     * @throws EE_Error
3162
-     * @throws InvalidArgumentException
3163
-     * @throws InvalidDataTypeException
3164
-     * @throws InvalidInterfaceException
3165
-     * @access public
3166
-     */
3167
-    public function get_attendees($per_page, $count = false, $trash = false)
3168
-    {
3169
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3170
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3171
-        $orderby = $this->request->getRequestParam('orderby');
3172
-        switch ($orderby) {
3173
-            case 'ATT_ID':
3174
-            case 'ATT_fname':
3175
-            case 'ATT_email':
3176
-            case 'ATT_city':
3177
-            case 'STA_ID':
3178
-            case 'CNT_ID':
3179
-                break;
3180
-            case 'Registration_Count':
3181
-                $orderby = 'Registration_Count';
3182
-                break;
3183
-            default:
3184
-                $orderby = 'ATT_lname';
3185
-        }
3186
-        $sort = $this->request->getRequestParam('order', 'ASC');
3187
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3188
-        $per_page = absint($per_page) ? $per_page : 10;
3189
-        $per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
3190
-        $_where = array();
3191
-        $search_term = $this->request->getRequestParam('s');
3192
-        if ($search_term) {
3193
-            $search_term = '%' . $search_term . '%';
3194
-            $_where['OR'] = array(
3195
-                'Registration.Event.EVT_name'       => array('LIKE', $search_term),
3196
-                'Registration.Event.EVT_desc'       => array('LIKE', $search_term),
3197
-                'Registration.Event.EVT_short_desc' => array('LIKE', $search_term),
3198
-                'ATT_fname'                         => array('LIKE', $search_term),
3199
-                'ATT_lname'                         => array('LIKE', $search_term),
3200
-                'ATT_short_bio'                     => array('LIKE', $search_term),
3201
-                'ATT_email'                         => array('LIKE', $search_term),
3202
-                'ATT_address'                       => array('LIKE', $search_term),
3203
-                'ATT_address2'                      => array('LIKE', $search_term),
3204
-                'ATT_city'                          => array('LIKE', $search_term),
3205
-                'Country.CNT_name'                  => array('LIKE', $search_term),
3206
-                'State.STA_name'                    => array('LIKE', $search_term),
3207
-                'ATT_phone'                         => array('LIKE', $search_term),
3208
-                'Registration.REG_final_price'      => array('LIKE', $search_term),
3209
-                'Registration.REG_code'             => array('LIKE', $search_term),
3210
-                'Registration.REG_group_size'       => array('LIKE', $search_term),
3211
-            );
3212
-        }
3213
-        $offset = ($current_page - 1) * $per_page;
3214
-        $limit = $count ? null : array($offset, $per_page);
3215
-        $query_args = array(
3216
-            $_where,
3217
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3218
-            'limit'         => $limit,
3219
-        );
3220
-        if (! $count) {
3221
-            $query_args['order_by'] = array($orderby => $sort);
3222
-        }
3223
-        if ($trash) {
3224
-            $query_args[0]['status'] = array('!=', 'publish');
3225
-            $all_attendees = $count
3226
-                ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3227
-                : $this->getAttendeeModel()->get_all($query_args);
3228
-        } else {
3229
-            $query_args[0]['status'] = array('IN', array('publish'));
3230
-            $all_attendees = $count
3231
-                ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3232
-                : $this->getAttendeeModel()->get_all($query_args);
3233
-        }
3234
-        return $all_attendees;
3235
-    }
3236
-
3237
-
3238
-    /**
3239
-     * This is just taking care of resending the registration confirmation
3240
-     *
3241
-     * @access protected
3242
-     * @return void
3243
-     * @throws EE_Error
3244
-     * @throws InvalidArgumentException
3245
-     * @throws InvalidDataTypeException
3246
-     * @throws InvalidInterfaceException
3247
-     * @throws ReflectionException
3248
-     */
3249
-    protected function _resend_registration()
3250
-    {
3251
-        $this->_process_resend_registration();
3252
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3253
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3254
-        $query_args = $redirect_to
3255
-            ? array('action' => $redirect_to, '_REG_ID' => $REG_ID)
3256
-            : array('action' => 'default');
3257
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3258
-    }
3259
-
3260
-    /**
3261
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3262
-     * to use when selecting registrations
3263
-     *
3264
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3265
-     *                                                     the query parameters from the request
3266
-     * @return void ends the request with a redirect or download
3267
-     */
3268
-    public function _registrations_report_base($method_name_for_getting_query_params)
3269
-    {
3270
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3271
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3272
-            : null;
3273
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3274
-            $request_params = $this->request->requestParams();
3275
-            wp_redirect(
3276
-                EE_Admin_Page::add_query_args_and_nonce(
3277
-                    array(
3278
-                        'page'        => 'espresso_batch',
3279
-                        'batch'       => 'file',
3280
-                        'EVT_ID'      => $EVT_ID,
3281
-                        'filters'     => urlencode(
3282
-                            serialize(
3283
-                                $this->$method_name_for_getting_query_params(
3284
-                                    EEH_Array::is_set($request_params, 'filters', [])
3285
-                                )
3286
-                            )
3287
-                        ),
3288
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3289
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3290
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url')),
3291
-                    )
3292
-                )
3293
-            );
3294
-        } else {
3295
-            $new_request_args = array(
3296
-                'export' => 'report',
3297
-                'action' => 'registrations_report_for_event',
3298
-                'EVT_ID' => $EVT_ID,
3299
-            );
3300
-            $this->request->mergeRequestParams($new_request_args);
3301
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3302
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3303
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3304
-                $EE_Export->export();
3305
-            }
3306
-        }
3307
-    }
3308
-
3309
-
3310
-    /**
3311
-     * Creates a registration report using only query parameters in the request
3312
-     *
3313
-     * @return void
3314
-     */
3315
-    public function _registrations_report()
3316
-    {
3317
-        $this->_registrations_report_base('_get_registration_query_parameters');
3318
-    }
3319
-
3320
-
3321
-    public function _contact_list_export()
3322
-    {
3323
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3324
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3325
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3326
-            $EE_Export->export_attendees();
3327
-        }
3328
-    }
3329
-
3330
-
3331
-    public function _contact_list_report()
3332
-    {
3333
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3334
-            wp_redirect(
3335
-                EE_Admin_Page::add_query_args_and_nonce(
3336
-                    array(
3337
-                        'page'        => 'espresso_batch',
3338
-                        'batch'       => 'file',
3339
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3340
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url')),
3341
-                    )
3342
-                )
3343
-            );
3344
-        } else {
3345
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3346
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3347
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3348
-                $EE_Export->report_attendees();
3349
-            }
3350
-        }
3351
-    }
3352
-
3353
-
3354
-
3355
-
3356
-
3357
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3358
-    /**
3359
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3360
-     *
3361
-     * @return void
3362
-     * @throws EE_Error
3363
-     * @throws InvalidArgumentException
3364
-     * @throws InvalidDataTypeException
3365
-     * @throws InvalidInterfaceException
3366
-     * @throws ReflectionException
3367
-     */
3368
-    protected function _duplicate_attendee()
3369
-    {
3370
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3371
-        $action = $this->request->getRequestParam('return', 'default');
3372
-        // verify we have necessary info
3373
-        if (! $REG_ID) {
3374
-            EE_Error::add_error(
3375
-                esc_html__(
3376
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3377
-                    'event_espresso'
3378
-                ),
3379
-                __FILE__,
3380
-                __LINE__,
3381
-                __FUNCTION__
3382
-            );
3383
-            $query_args = array('action' => $action);
3384
-            $this->_redirect_after_action('', '', '', $query_args, true);
3385
-        }
3386
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3387
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3388
-        if (! $registration instanceof EE_Registration) {
3389
-            throw new RuntimeException(
3390
-                sprintf(
3391
-                    esc_html__(
3392
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3393
-                        'event_espresso'
3394
-                    ),
3395
-                    $REG_ID
3396
-                )
3397
-            );
3398
-        }
3399
-        $attendee = $registration->attendee();
3400
-        // remove relation of existing attendee on registration
3401
-        $registration->_remove_relation_to($attendee, 'Attendee');
3402
-        // new attendee
3403
-        $new_attendee = clone $attendee;
3404
-        $new_attendee->set('ATT_ID', 0);
3405
-        $new_attendee->save();
3406
-        // add new attendee to reg
3407
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3408
-        EE_Error::add_success(
3409
-            esc_html__(
3410
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3411
-                'event_espresso'
3412
-            )
3413
-        );
3414
-        // redirect to edit page for attendee
3415
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3416
-        $this->_redirect_after_action('', '', '', $query_args, true);
3417
-    }
3418
-
3419
-
3420
-    /**
3421
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3422
-     *
3423
-     * @param int     $post_id
3424
-     * @param WP_POST $post
3425
-     * @throws DomainException
3426
-     * @throws EE_Error
3427
-     * @throws InvalidArgumentException
3428
-     * @throws InvalidDataTypeException
3429
-     * @throws InvalidInterfaceException
3430
-     * @throws LogicException
3431
-     * @throws InvalidFormSubmissionException
3432
-     * @throws ReflectionException
3433
-     */
3434
-    protected function _insert_update_cpt_item($post_id, $post)
3435
-    {
3436
-        $success = true;
3437
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3438
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3439
-            : null;
3440
-        // for attendee updates
3441
-        if ($attendee instanceof EE_Attendee) {
3442
-            // note we should only be UPDATING attendees at this point.
3443
-            $fname = $this->request->getRequestParam('ATT_fname', '');
3444
-            $lname = $this->request->getRequestParam('ATT_lname', '');
3445
-            $updated_fields = array(
3446
-                'ATT_fname'     => $fname,
3447
-                'ATT_lname'     => $lname,
3448
-                'ATT_full_name' => "{$fname} {$lname}",
3449
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3450
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3451
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3452
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3453
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3454
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3455
-            );
3456
-            foreach ($updated_fields as $field => $value) {
3457
-                $attendee->set($field, $value);
3458
-            }
3459
-
3460
-            // process contact details metabox form handler (which will also save the attendee)
3461
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3462
-            $success = $contact_details_form->process($this->request->requestParams());
3463
-
3464
-            $attendee_update_callbacks = apply_filters(
3465
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3466
-                array()
3467
-            );
3468
-            foreach ($attendee_update_callbacks as $a_callback) {
3469
-                if (false === call_user_func_array($a_callback, array($attendee, $this->request->requestParams()))) {
3470
-                    throw new EE_Error(
3471
-                        sprintf(
3472
-                            esc_html__(
3473
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3474
-                                'event_espresso'
3475
-                            ),
3476
-                            $a_callback
3477
-                        )
3478
-                    );
3479
-                }
3480
-            }
3481
-        }
3482
-
3483
-        if ($success === false) {
3484
-            EE_Error::add_error(
3485
-                esc_html__(
3486
-                    'Something went wrong with updating the meta table data for the registration.',
3487
-                    'event_espresso'
3488
-                ),
3489
-                __FILE__,
3490
-                __FUNCTION__,
3491
-                __LINE__
3492
-            );
3493
-        }
3494
-    }
3495
-
3496
-
3497
-    public function trash_cpt_item($post_id)
3498
-    {
3499
-    }
3500
-
3501
-
3502
-    public function delete_cpt_item($post_id)
3503
-    {
3504
-    }
3505
-
3506
-
3507
-    public function restore_cpt_item($post_id)
3508
-    {
3509
-    }
3510
-
3511
-
3512
-    protected function _restore_cpt_item($post_id, $revision_id)
3513
-    {
3514
-    }
3515
-
3516
-
3517
-    /**
3518
-     * @throws EE_Error
3519
-     * @since 4.10.2.p
3520
-     */
3521
-    public function attendee_editor_metaboxes()
3522
-    {
3523
-        $this->verify_cpt_object();
3524
-        remove_meta_box(
3525
-            'postexcerpt',
3526
-            $this->_cpt_routes[ $this->_req_action ],
3527
-            'normal'
3528
-        );
3529
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3530
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3531
-            add_meta_box(
3532
-                'postexcerpt',
3533
-                esc_html__('Short Biography', 'event_espresso'),
3534
-                'post_excerpt_meta_box',
3535
-                $this->_cpt_routes[ $this->_req_action ],
3536
-                'normal'
3537
-            );
3538
-        }
3539
-        if (post_type_supports('espresso_attendees', 'comments')) {
3540
-            add_meta_box(
3541
-                'commentsdiv',
3542
-                esc_html__('Notes on the Contact', 'event_espresso'),
3543
-                'post_comment_meta_box',
3544
-                $this->_cpt_routes[ $this->_req_action ],
3545
-                'normal',
3546
-                'core'
3547
-            );
3548
-        }
3549
-        add_meta_box(
3550
-            'attendee_contact_info',
3551
-            esc_html__('Contact Info', 'event_espresso'),
3552
-            array($this, 'attendee_contact_info'),
3553
-            $this->_cpt_routes[ $this->_req_action ],
3554
-            'side',
3555
-            'core'
3556
-        );
3557
-        add_meta_box(
3558
-            'attendee_details_address',
3559
-            esc_html__('Address Details', 'event_espresso'),
3560
-            array($this, 'attendee_address_details'),
3561
-            $this->_cpt_routes[ $this->_req_action ],
3562
-            'normal',
3563
-            'core'
3564
-        );
3565
-        add_meta_box(
3566
-            'attendee_registrations',
3567
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3568
-            array($this, 'attendee_registrations_meta_box'),
3569
-            $this->_cpt_routes[ $this->_req_action ],
3570
-            'normal',
3571
-            'high'
3572
-        );
3573
-    }
3574
-
3575
-
3576
-    /**
3577
-     * Metabox for attendee contact info
3578
-     *
3579
-     * @param  WP_Post $post wp post object
3580
-     * @return void attendee contact info ( and form )
3581
-     * @throws EE_Error
3582
-     * @throws InvalidArgumentException
3583
-     * @throws InvalidDataTypeException
3584
-     * @throws InvalidInterfaceException
3585
-     * @throws LogicException
3586
-     * @throws DomainException
3587
-     */
3588
-    public function attendee_contact_info($post)
3589
-    {
3590
-        // get attendee object ( should already have it )
3591
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3592
-        $form->enqueueStylesAndScripts();
3593
-        echo $form->display(); // already escaped
3594
-    }
3595
-
3596
-
3597
-    /**
3598
-     * Return form handler for the contact details metabox
3599
-     *
3600
-     * @param EE_Attendee $attendee
3601
-     * @return AttendeeContactDetailsMetaboxFormHandler
3602
-     * @throws DomainException
3603
-     * @throws InvalidArgumentException
3604
-     * @throws InvalidDataTypeException
3605
-     * @throws InvalidInterfaceException
3606
-     */
3607
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3608
-    {
3609
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3610
-    }
3611
-
3612
-
3613
-    /**
3614
-     * Metabox for attendee details
3615
-     *
3616
-     * @param  WP_Post $post wp post object
3617
-     * @throws DomainException
3618
-     */
3619
-    public function attendee_address_details($post)
3620
-    {
3621
-        // get attendee object (should already have it)
3622
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3623
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3624
-            new EE_Question_Form_Input(
3625
-                EE_Question::new_instance(
3626
-                    array(
3627
-                        'QST_ID'           => 0,
3628
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3629
-                        'QST_system'       => 'admin-state',
3630
-                    )
3631
-                ),
3632
-                EE_Answer::new_instance(
3633
-                    array(
3634
-                        'ANS_ID'    => 0,
3635
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3636
-                    )
3637
-                ),
3638
-                array(
3639
-                    'input_id'       => 'STA_ID',
3640
-                    'input_name'     => 'STA_ID',
3641
-                    'input_prefix'   => '',
3642
-                    'append_qstn_id' => false,
3643
-                )
3644
-            )
3645
-        );
3646
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3647
-            new EE_Question_Form_Input(
3648
-                EE_Question::new_instance(
3649
-                    array(
3650
-                        'QST_ID'           => 0,
3651
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3652
-                        'QST_system'       => 'admin-country',
3653
-                    )
3654
-                ),
3655
-                EE_Answer::new_instance(
3656
-                    array(
3657
-                        'ANS_ID'    => 0,
3658
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3659
-                    )
3660
-                ),
3661
-                array(
3662
-                    'input_id'       => 'CNT_ISO',
3663
-                    'input_name'     => 'CNT_ISO',
3664
-                    'input_prefix'   => '',
3665
-                    'append_qstn_id' => false,
3666
-                )
3667
-            )
3668
-        );
3669
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3670
-        EEH_Template::display_template($template, $this->_template_args);
3671
-    }
3672
-
3673
-
3674
-    /**
3675
-     *        _attendee_details
3676
-     *
3677
-     * @access protected
3678
-     * @param $post
3679
-     * @return void
3680
-     * @throws DomainException
3681
-     * @throws EE_Error
3682
-     * @throws InvalidArgumentException
3683
-     * @throws InvalidDataTypeException
3684
-     * @throws InvalidInterfaceException
3685
-     * @throws ReflectionException
3686
-     */
3687
-    public function attendee_registrations_meta_box($post)
3688
-    {
3689
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3690
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3691
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3692
-        EEH_Template::display_template($template, $this->_template_args);
3693
-    }
3694
-
3695
-
3696
-    /**
3697
-     * add in the form fields for the attendee edit
3698
-     *
3699
-     * @param  WP_Post $post wp post object
3700
-     * @return void echos html for new form.
3701
-     * @throws DomainException
3702
-     */
3703
-    public function after_title_form_fields($post)
3704
-    {
3705
-        if ($post->post_type === 'espresso_attendees') {
3706
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3707
-            $template_args['attendee'] = $this->_cpt_model_obj;
3708
-            EEH_Template::display_template($template, $template_args);
3709
-        }
3710
-    }
3711
-
3712
-
3713
-    /**
3714
-     *        _trash_or_restore_attendee
3715
-     *
3716
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3717
-     * @return void
3718
-     * @throws EE_Error
3719
-     * @throws InvalidArgumentException
3720
-     * @throws InvalidDataTypeException
3721
-     * @throws InvalidInterfaceException
3722
-     * @throws ReflectionException
3723
-     * @access protected
3724
-     */
3725
-    protected function _trash_or_restore_attendees($trash = true)
3726
-    {
3727
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3728
-        $status = $trash ? 'trash' : 'publish';
3729
-        // Checkboxes
3730
-        if ($this->request->requestParamIsSet('checkbox')) {
3731
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3732
-            // if array has more than one element than success message should be plural
3733
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3734
-            // cycle thru checkboxes
3735
-            foreach ($ATT_IDs as $ATT_ID) {
3736
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3737
-                if (! $updated) {
3738
-                    $success = 0;
3739
-                }
3740
-            }
3741
-        } else {
3742
-            // grab single id and delete
3743
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3744
-            // update attendee
3745
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3746
-        }
3747
-        $what = $success > 1
3748
-            ? esc_html__('Contacts', 'event_espresso')
3749
-            : esc_html__('Contact', 'event_espresso');
3750
-        $action_desc = $trash
3751
-            ? esc_html__('moved to the trash', 'event_espresso')
3752
-            : esc_html__('restored', 'event_espresso');
3753
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3754
-    }
2903
+		}
2904
+		$template_args = array(
2905
+			'title'                    => '',
2906
+			'content'                  => '',
2907
+			'step_button_text'         => '',
2908
+			'show_notification_toggle' => false,
2909
+		);
2910
+		// to indicate we're processing a new registration
2911
+		$hidden_fields = array(
2912
+			'processing_registration' => array(
2913
+				'type'  => 'hidden',
2914
+				'value' => 0,
2915
+			),
2916
+			'event_id'                => array(
2917
+				'type'  => 'hidden',
2918
+				'value' => $this->_reg_event->ID(),
2919
+			),
2920
+		);
2921
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2922
+		$cart = EE_Registry::instance()->SSN->cart();
2923
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2924
+		switch ($step) {
2925
+			case 'ticket':
2926
+				$hidden_fields['processing_registration']['value'] = 1;
2927
+				$template_args['title'] = esc_html__(
2928
+					'Step One: Select the Ticket for this registration',
2929
+					'event_espresso'
2930
+				);
2931
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2932
+				$template_args['content'] .= '</div>';
2933
+				$template_args['step_button_text'] = esc_html__(
2934
+					'Add Tickets and Continue to Registrant Details',
2935
+					'event_espresso'
2936
+				);
2937
+				$template_args['show_notification_toggle'] = false;
2938
+				break;
2939
+			case 'questions':
2940
+				$hidden_fields['processing_registration']['value'] = 2;
2941
+				$template_args['title'] = esc_html__(
2942
+					'Step Two: Add Registrant Details for this Registration',
2943
+					'event_espresso'
2944
+				);
2945
+				// in theory, we should be able to run EED_SPCO at this point
2946
+				// because the cart should have been set up properly by the first process_reg_step run.
2947
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2948
+				$template_args['step_button_text'] = esc_html__(
2949
+					'Save Registration and Continue to Details',
2950
+					'event_espresso'
2951
+				);
2952
+				$template_args['show_notification_toggle'] = true;
2953
+				break;
2954
+		}
2955
+		// we come back to the process_registration_step route.
2956
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2957
+		return EEH_Template::display_template(
2958
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2959
+			$template_args,
2960
+			true
2961
+		);
2962
+	}
2963
+
2964
+
2965
+	/**
2966
+	 *        set_reg_event
2967
+	 *
2968
+	 * @access private
2969
+	 * @return bool
2970
+	 * @throws EE_Error
2971
+	 * @throws InvalidArgumentException
2972
+	 * @throws InvalidDataTypeException
2973
+	 * @throws InvalidInterfaceException
2974
+	 */
2975
+	private function _set_reg_event()
2976
+	{
2977
+		if (is_object($this->_reg_event)) {
2978
+			return true;
2979
+		}
2980
+
2981
+		$EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2982
+		if (! $EVT_ID) {
2983
+			return false;
2984
+		}
2985
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2986
+		return true;
2987
+	}
2988
+
2989
+
2990
+	/**
2991
+	 * process_reg_step
2992
+	 *
2993
+	 * @return void
2994
+	 * @throws DomainException
2995
+	 * @throws EE_Error
2996
+	 * @throws InvalidArgumentException
2997
+	 * @throws InvalidDataTypeException
2998
+	 * @throws InvalidInterfaceException
2999
+	 * @throws ReflectionException
3000
+	 * @throws RuntimeException
3001
+	 */
3002
+	public function process_reg_step()
3003
+	{
3004
+		EE_System::do_not_cache();
3005
+		$this->_set_reg_event();
3006
+		/** @var CurrentPage $current_page */
3007
+		$current_page = $this->loader->getShared(CurrentPage::class);
3008
+		$current_page->setEspressoPage(true);
3009
+		$this->request->setRequestParam('uts', time());
3010
+		// what step are we on?
3011
+		$cart = EE_Registry::instance()->SSN->cart();
3012
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3013
+		// if doing ajax then we need to verify the nonce
3014
+		if ($this->request->isAjax()) {
3015
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3016
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3017
+		}
3018
+		switch ($step) {
3019
+			case 'ticket':
3020
+				// process ticket selection
3021
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3022
+				if ($success) {
3023
+					EE_Error::add_success(
3024
+						esc_html__(
3025
+							'Tickets Selected. Now complete the registration.',
3026
+							'event_espresso'
3027
+						)
3028
+					);
3029
+				} else {
3030
+					$this->request->setRequestParam('step_error', true);
3031
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3032
+				}
3033
+				if ($this->request->isAjax()) {
3034
+					$this->new_registration(); // display next step
3035
+				} else {
3036
+					$query_args = array(
3037
+						'action'                  => 'new_registration',
3038
+						'processing_registration' => 1,
3039
+						'event_id'                => $this->_reg_event->ID(),
3040
+						'uts'                     => time(),
3041
+					);
3042
+					$this->_redirect_after_action(
3043
+						false,
3044
+						'',
3045
+						'',
3046
+						$query_args,
3047
+						true
3048
+					);
3049
+				}
3050
+				break;
3051
+			case 'questions':
3052
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3053
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3054
+				}
3055
+				// process registration
3056
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3057
+				if ($cart instanceof EE_Cart) {
3058
+					$grand_total = $cart->get_cart_grand_total();
3059
+					if ($grand_total instanceof EE_Line_Item) {
3060
+						$grand_total->save_this_and_descendants_to_txn();
3061
+					}
3062
+				}
3063
+				if (! $transaction instanceof EE_Transaction) {
3064
+					$query_args = array(
3065
+						'action'                  => 'new_registration',
3066
+						'processing_registration' => 2,
3067
+						'event_id'                => $this->_reg_event->ID(),
3068
+						'uts'                     => time(),
3069
+					);
3070
+					if ($this->request->isAjax()) {
3071
+						// display registration form again because there are errors (maybe validation?)
3072
+						$this->new_registration();
3073
+						return;
3074
+					}
3075
+					$this->_redirect_after_action(
3076
+						false,
3077
+						'',
3078
+						'',
3079
+						$query_args,
3080
+						true
3081
+					);
3082
+					return;
3083
+				}
3084
+				// maybe update status, and make sure to save transaction if not done already
3085
+				if (! $transaction->update_status_based_on_total_paid()) {
3086
+					$transaction->save();
3087
+				}
3088
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3089
+				$query_args = array(
3090
+					'action'        => 'redirect_to_txn',
3091
+					'TXN_ID'        => $transaction->ID(),
3092
+					'EVT_ID'        => $this->_reg_event->ID(),
3093
+					'event_name'    => urlencode($this->_reg_event->name()),
3094
+					'redirect_from' => 'new_registration',
3095
+				);
3096
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3097
+				break;
3098
+		}
3099
+		// what are you looking here for?  Should be nothing to do at this point.
3100
+	}
3101
+
3102
+
3103
+	/**
3104
+	 * redirect_to_txn
3105
+	 *
3106
+	 * @access public
3107
+	 * @return void
3108
+	 * @throws EE_Error
3109
+	 * @throws InvalidArgumentException
3110
+	 * @throws InvalidDataTypeException
3111
+	 * @throws InvalidInterfaceException
3112
+	 * @throws ReflectionException
3113
+	 */
3114
+	public function redirect_to_txn()
3115
+	{
3116
+		EE_System::do_not_cache();
3117
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3118
+		$query_args = array(
3119
+			'action' => 'view_transaction',
3120
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3121
+			'page'   => 'espresso_transactions',
3122
+		);
3123
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3124
+			$query_args['EVT_ID'] = $this->request->getRequestParam('EVT_ID', 0, 'int');
3125
+			$query_args['event_name'] = urlencode($this->request->getRequestParam('event_name'));
3126
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3127
+		}
3128
+		EE_Error::add_success(
3129
+			esc_html__(
3130
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3131
+				'event_espresso'
3132
+			)
3133
+		);
3134
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3135
+	}
3136
+
3137
+
3138
+	/**
3139
+	 *        generates HTML for the Attendee Contact List
3140
+	 *
3141
+	 * @access protected
3142
+	 * @return void
3143
+	 * @throws DomainException
3144
+	 * @throws EE_Error
3145
+	 */
3146
+	protected function _attendee_contact_list_table()
3147
+	{
3148
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3149
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3150
+		$this->display_admin_list_table_page_with_no_sidebar();
3151
+	}
3152
+
3153
+
3154
+	/**
3155
+	 *        get_attendees
3156
+	 *
3157
+	 * @param      $per_page
3158
+	 * @param bool $count whether to return count or data.
3159
+	 * @param bool $trash
3160
+	 * @return array
3161
+	 * @throws EE_Error
3162
+	 * @throws InvalidArgumentException
3163
+	 * @throws InvalidDataTypeException
3164
+	 * @throws InvalidInterfaceException
3165
+	 * @access public
3166
+	 */
3167
+	public function get_attendees($per_page, $count = false, $trash = false)
3168
+	{
3169
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3170
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3171
+		$orderby = $this->request->getRequestParam('orderby');
3172
+		switch ($orderby) {
3173
+			case 'ATT_ID':
3174
+			case 'ATT_fname':
3175
+			case 'ATT_email':
3176
+			case 'ATT_city':
3177
+			case 'STA_ID':
3178
+			case 'CNT_ID':
3179
+				break;
3180
+			case 'Registration_Count':
3181
+				$orderby = 'Registration_Count';
3182
+				break;
3183
+			default:
3184
+				$orderby = 'ATT_lname';
3185
+		}
3186
+		$sort = $this->request->getRequestParam('order', 'ASC');
3187
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3188
+		$per_page = absint($per_page) ? $per_page : 10;
3189
+		$per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
3190
+		$_where = array();
3191
+		$search_term = $this->request->getRequestParam('s');
3192
+		if ($search_term) {
3193
+			$search_term = '%' . $search_term . '%';
3194
+			$_where['OR'] = array(
3195
+				'Registration.Event.EVT_name'       => array('LIKE', $search_term),
3196
+				'Registration.Event.EVT_desc'       => array('LIKE', $search_term),
3197
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_term),
3198
+				'ATT_fname'                         => array('LIKE', $search_term),
3199
+				'ATT_lname'                         => array('LIKE', $search_term),
3200
+				'ATT_short_bio'                     => array('LIKE', $search_term),
3201
+				'ATT_email'                         => array('LIKE', $search_term),
3202
+				'ATT_address'                       => array('LIKE', $search_term),
3203
+				'ATT_address2'                      => array('LIKE', $search_term),
3204
+				'ATT_city'                          => array('LIKE', $search_term),
3205
+				'Country.CNT_name'                  => array('LIKE', $search_term),
3206
+				'State.STA_name'                    => array('LIKE', $search_term),
3207
+				'ATT_phone'                         => array('LIKE', $search_term),
3208
+				'Registration.REG_final_price'      => array('LIKE', $search_term),
3209
+				'Registration.REG_code'             => array('LIKE', $search_term),
3210
+				'Registration.REG_group_size'       => array('LIKE', $search_term),
3211
+			);
3212
+		}
3213
+		$offset = ($current_page - 1) * $per_page;
3214
+		$limit = $count ? null : array($offset, $per_page);
3215
+		$query_args = array(
3216
+			$_where,
3217
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3218
+			'limit'         => $limit,
3219
+		);
3220
+		if (! $count) {
3221
+			$query_args['order_by'] = array($orderby => $sort);
3222
+		}
3223
+		if ($trash) {
3224
+			$query_args[0]['status'] = array('!=', 'publish');
3225
+			$all_attendees = $count
3226
+				? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3227
+				: $this->getAttendeeModel()->get_all($query_args);
3228
+		} else {
3229
+			$query_args[0]['status'] = array('IN', array('publish'));
3230
+			$all_attendees = $count
3231
+				? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3232
+				: $this->getAttendeeModel()->get_all($query_args);
3233
+		}
3234
+		return $all_attendees;
3235
+	}
3236
+
3237
+
3238
+	/**
3239
+	 * This is just taking care of resending the registration confirmation
3240
+	 *
3241
+	 * @access protected
3242
+	 * @return void
3243
+	 * @throws EE_Error
3244
+	 * @throws InvalidArgumentException
3245
+	 * @throws InvalidDataTypeException
3246
+	 * @throws InvalidInterfaceException
3247
+	 * @throws ReflectionException
3248
+	 */
3249
+	protected function _resend_registration()
3250
+	{
3251
+		$this->_process_resend_registration();
3252
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3253
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3254
+		$query_args = $redirect_to
3255
+			? array('action' => $redirect_to, '_REG_ID' => $REG_ID)
3256
+			: array('action' => 'default');
3257
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3258
+	}
3259
+
3260
+	/**
3261
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3262
+	 * to use when selecting registrations
3263
+	 *
3264
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3265
+	 *                                                     the query parameters from the request
3266
+	 * @return void ends the request with a redirect or download
3267
+	 */
3268
+	public function _registrations_report_base($method_name_for_getting_query_params)
3269
+	{
3270
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3271
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3272
+			: null;
3273
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3274
+			$request_params = $this->request->requestParams();
3275
+			wp_redirect(
3276
+				EE_Admin_Page::add_query_args_and_nonce(
3277
+					array(
3278
+						'page'        => 'espresso_batch',
3279
+						'batch'       => 'file',
3280
+						'EVT_ID'      => $EVT_ID,
3281
+						'filters'     => urlencode(
3282
+							serialize(
3283
+								$this->$method_name_for_getting_query_params(
3284
+									EEH_Array::is_set($request_params, 'filters', [])
3285
+								)
3286
+							)
3287
+						),
3288
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3289
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3290
+						'return_url'  => urlencode($this->request->getRequestParam('return_url')),
3291
+					)
3292
+				)
3293
+			);
3294
+		} else {
3295
+			$new_request_args = array(
3296
+				'export' => 'report',
3297
+				'action' => 'registrations_report_for_event',
3298
+				'EVT_ID' => $EVT_ID,
3299
+			);
3300
+			$this->request->mergeRequestParams($new_request_args);
3301
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3302
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3303
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3304
+				$EE_Export->export();
3305
+			}
3306
+		}
3307
+	}
3308
+
3309
+
3310
+	/**
3311
+	 * Creates a registration report using only query parameters in the request
3312
+	 *
3313
+	 * @return void
3314
+	 */
3315
+	public function _registrations_report()
3316
+	{
3317
+		$this->_registrations_report_base('_get_registration_query_parameters');
3318
+	}
3319
+
3320
+
3321
+	public function _contact_list_export()
3322
+	{
3323
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3324
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3325
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3326
+			$EE_Export->export_attendees();
3327
+		}
3328
+	}
3329
+
3330
+
3331
+	public function _contact_list_report()
3332
+	{
3333
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3334
+			wp_redirect(
3335
+				EE_Admin_Page::add_query_args_and_nonce(
3336
+					array(
3337
+						'page'        => 'espresso_batch',
3338
+						'batch'       => 'file',
3339
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3340
+						'return_url'  => urlencode($this->request->getRequestParam('return_url')),
3341
+					)
3342
+				)
3343
+			);
3344
+		} else {
3345
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3346
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3347
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3348
+				$EE_Export->report_attendees();
3349
+			}
3350
+		}
3351
+	}
3352
+
3353
+
3354
+
3355
+
3356
+
3357
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3358
+	/**
3359
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3360
+	 *
3361
+	 * @return void
3362
+	 * @throws EE_Error
3363
+	 * @throws InvalidArgumentException
3364
+	 * @throws InvalidDataTypeException
3365
+	 * @throws InvalidInterfaceException
3366
+	 * @throws ReflectionException
3367
+	 */
3368
+	protected function _duplicate_attendee()
3369
+	{
3370
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3371
+		$action = $this->request->getRequestParam('return', 'default');
3372
+		// verify we have necessary info
3373
+		if (! $REG_ID) {
3374
+			EE_Error::add_error(
3375
+				esc_html__(
3376
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3377
+					'event_espresso'
3378
+				),
3379
+				__FILE__,
3380
+				__LINE__,
3381
+				__FUNCTION__
3382
+			);
3383
+			$query_args = array('action' => $action);
3384
+			$this->_redirect_after_action('', '', '', $query_args, true);
3385
+		}
3386
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3387
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3388
+		if (! $registration instanceof EE_Registration) {
3389
+			throw new RuntimeException(
3390
+				sprintf(
3391
+					esc_html__(
3392
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3393
+						'event_espresso'
3394
+					),
3395
+					$REG_ID
3396
+				)
3397
+			);
3398
+		}
3399
+		$attendee = $registration->attendee();
3400
+		// remove relation of existing attendee on registration
3401
+		$registration->_remove_relation_to($attendee, 'Attendee');
3402
+		// new attendee
3403
+		$new_attendee = clone $attendee;
3404
+		$new_attendee->set('ATT_ID', 0);
3405
+		$new_attendee->save();
3406
+		// add new attendee to reg
3407
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3408
+		EE_Error::add_success(
3409
+			esc_html__(
3410
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3411
+				'event_espresso'
3412
+			)
3413
+		);
3414
+		// redirect to edit page for attendee
3415
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3416
+		$this->_redirect_after_action('', '', '', $query_args, true);
3417
+	}
3418
+
3419
+
3420
+	/**
3421
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3422
+	 *
3423
+	 * @param int     $post_id
3424
+	 * @param WP_POST $post
3425
+	 * @throws DomainException
3426
+	 * @throws EE_Error
3427
+	 * @throws InvalidArgumentException
3428
+	 * @throws InvalidDataTypeException
3429
+	 * @throws InvalidInterfaceException
3430
+	 * @throws LogicException
3431
+	 * @throws InvalidFormSubmissionException
3432
+	 * @throws ReflectionException
3433
+	 */
3434
+	protected function _insert_update_cpt_item($post_id, $post)
3435
+	{
3436
+		$success = true;
3437
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3438
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3439
+			: null;
3440
+		// for attendee updates
3441
+		if ($attendee instanceof EE_Attendee) {
3442
+			// note we should only be UPDATING attendees at this point.
3443
+			$fname = $this->request->getRequestParam('ATT_fname', '');
3444
+			$lname = $this->request->getRequestParam('ATT_lname', '');
3445
+			$updated_fields = array(
3446
+				'ATT_fname'     => $fname,
3447
+				'ATT_lname'     => $lname,
3448
+				'ATT_full_name' => "{$fname} {$lname}",
3449
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3450
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3451
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3452
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3453
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3454
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3455
+			);
3456
+			foreach ($updated_fields as $field => $value) {
3457
+				$attendee->set($field, $value);
3458
+			}
3459
+
3460
+			// process contact details metabox form handler (which will also save the attendee)
3461
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3462
+			$success = $contact_details_form->process($this->request->requestParams());
3463
+
3464
+			$attendee_update_callbacks = apply_filters(
3465
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3466
+				array()
3467
+			);
3468
+			foreach ($attendee_update_callbacks as $a_callback) {
3469
+				if (false === call_user_func_array($a_callback, array($attendee, $this->request->requestParams()))) {
3470
+					throw new EE_Error(
3471
+						sprintf(
3472
+							esc_html__(
3473
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3474
+								'event_espresso'
3475
+							),
3476
+							$a_callback
3477
+						)
3478
+					);
3479
+				}
3480
+			}
3481
+		}
3482
+
3483
+		if ($success === false) {
3484
+			EE_Error::add_error(
3485
+				esc_html__(
3486
+					'Something went wrong with updating the meta table data for the registration.',
3487
+					'event_espresso'
3488
+				),
3489
+				__FILE__,
3490
+				__FUNCTION__,
3491
+				__LINE__
3492
+			);
3493
+		}
3494
+	}
3495
+
3496
+
3497
+	public function trash_cpt_item($post_id)
3498
+	{
3499
+	}
3500
+
3501
+
3502
+	public function delete_cpt_item($post_id)
3503
+	{
3504
+	}
3505
+
3506
+
3507
+	public function restore_cpt_item($post_id)
3508
+	{
3509
+	}
3510
+
3511
+
3512
+	protected function _restore_cpt_item($post_id, $revision_id)
3513
+	{
3514
+	}
3515
+
3516
+
3517
+	/**
3518
+	 * @throws EE_Error
3519
+	 * @since 4.10.2.p
3520
+	 */
3521
+	public function attendee_editor_metaboxes()
3522
+	{
3523
+		$this->verify_cpt_object();
3524
+		remove_meta_box(
3525
+			'postexcerpt',
3526
+			$this->_cpt_routes[ $this->_req_action ],
3527
+			'normal'
3528
+		);
3529
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3530
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3531
+			add_meta_box(
3532
+				'postexcerpt',
3533
+				esc_html__('Short Biography', 'event_espresso'),
3534
+				'post_excerpt_meta_box',
3535
+				$this->_cpt_routes[ $this->_req_action ],
3536
+				'normal'
3537
+			);
3538
+		}
3539
+		if (post_type_supports('espresso_attendees', 'comments')) {
3540
+			add_meta_box(
3541
+				'commentsdiv',
3542
+				esc_html__('Notes on the Contact', 'event_espresso'),
3543
+				'post_comment_meta_box',
3544
+				$this->_cpt_routes[ $this->_req_action ],
3545
+				'normal',
3546
+				'core'
3547
+			);
3548
+		}
3549
+		add_meta_box(
3550
+			'attendee_contact_info',
3551
+			esc_html__('Contact Info', 'event_espresso'),
3552
+			array($this, 'attendee_contact_info'),
3553
+			$this->_cpt_routes[ $this->_req_action ],
3554
+			'side',
3555
+			'core'
3556
+		);
3557
+		add_meta_box(
3558
+			'attendee_details_address',
3559
+			esc_html__('Address Details', 'event_espresso'),
3560
+			array($this, 'attendee_address_details'),
3561
+			$this->_cpt_routes[ $this->_req_action ],
3562
+			'normal',
3563
+			'core'
3564
+		);
3565
+		add_meta_box(
3566
+			'attendee_registrations',
3567
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3568
+			array($this, 'attendee_registrations_meta_box'),
3569
+			$this->_cpt_routes[ $this->_req_action ],
3570
+			'normal',
3571
+			'high'
3572
+		);
3573
+	}
3574
+
3575
+
3576
+	/**
3577
+	 * Metabox for attendee contact info
3578
+	 *
3579
+	 * @param  WP_Post $post wp post object
3580
+	 * @return void attendee contact info ( and form )
3581
+	 * @throws EE_Error
3582
+	 * @throws InvalidArgumentException
3583
+	 * @throws InvalidDataTypeException
3584
+	 * @throws InvalidInterfaceException
3585
+	 * @throws LogicException
3586
+	 * @throws DomainException
3587
+	 */
3588
+	public function attendee_contact_info($post)
3589
+	{
3590
+		// get attendee object ( should already have it )
3591
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3592
+		$form->enqueueStylesAndScripts();
3593
+		echo $form->display(); // already escaped
3594
+	}
3595
+
3596
+
3597
+	/**
3598
+	 * Return form handler for the contact details metabox
3599
+	 *
3600
+	 * @param EE_Attendee $attendee
3601
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3602
+	 * @throws DomainException
3603
+	 * @throws InvalidArgumentException
3604
+	 * @throws InvalidDataTypeException
3605
+	 * @throws InvalidInterfaceException
3606
+	 */
3607
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3608
+	{
3609
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3610
+	}
3611
+
3612
+
3613
+	/**
3614
+	 * Metabox for attendee details
3615
+	 *
3616
+	 * @param  WP_Post $post wp post object
3617
+	 * @throws DomainException
3618
+	 */
3619
+	public function attendee_address_details($post)
3620
+	{
3621
+		// get attendee object (should already have it)
3622
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3623
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3624
+			new EE_Question_Form_Input(
3625
+				EE_Question::new_instance(
3626
+					array(
3627
+						'QST_ID'           => 0,
3628
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3629
+						'QST_system'       => 'admin-state',
3630
+					)
3631
+				),
3632
+				EE_Answer::new_instance(
3633
+					array(
3634
+						'ANS_ID'    => 0,
3635
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3636
+					)
3637
+				),
3638
+				array(
3639
+					'input_id'       => 'STA_ID',
3640
+					'input_name'     => 'STA_ID',
3641
+					'input_prefix'   => '',
3642
+					'append_qstn_id' => false,
3643
+				)
3644
+			)
3645
+		);
3646
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3647
+			new EE_Question_Form_Input(
3648
+				EE_Question::new_instance(
3649
+					array(
3650
+						'QST_ID'           => 0,
3651
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3652
+						'QST_system'       => 'admin-country',
3653
+					)
3654
+				),
3655
+				EE_Answer::new_instance(
3656
+					array(
3657
+						'ANS_ID'    => 0,
3658
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3659
+					)
3660
+				),
3661
+				array(
3662
+					'input_id'       => 'CNT_ISO',
3663
+					'input_name'     => 'CNT_ISO',
3664
+					'input_prefix'   => '',
3665
+					'append_qstn_id' => false,
3666
+				)
3667
+			)
3668
+		);
3669
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3670
+		EEH_Template::display_template($template, $this->_template_args);
3671
+	}
3672
+
3673
+
3674
+	/**
3675
+	 *        _attendee_details
3676
+	 *
3677
+	 * @access protected
3678
+	 * @param $post
3679
+	 * @return void
3680
+	 * @throws DomainException
3681
+	 * @throws EE_Error
3682
+	 * @throws InvalidArgumentException
3683
+	 * @throws InvalidDataTypeException
3684
+	 * @throws InvalidInterfaceException
3685
+	 * @throws ReflectionException
3686
+	 */
3687
+	public function attendee_registrations_meta_box($post)
3688
+	{
3689
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3690
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3691
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3692
+		EEH_Template::display_template($template, $this->_template_args);
3693
+	}
3694
+
3695
+
3696
+	/**
3697
+	 * add in the form fields for the attendee edit
3698
+	 *
3699
+	 * @param  WP_Post $post wp post object
3700
+	 * @return void echos html for new form.
3701
+	 * @throws DomainException
3702
+	 */
3703
+	public function after_title_form_fields($post)
3704
+	{
3705
+		if ($post->post_type === 'espresso_attendees') {
3706
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3707
+			$template_args['attendee'] = $this->_cpt_model_obj;
3708
+			EEH_Template::display_template($template, $template_args);
3709
+		}
3710
+	}
3711
+
3712
+
3713
+	/**
3714
+	 *        _trash_or_restore_attendee
3715
+	 *
3716
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3717
+	 * @return void
3718
+	 * @throws EE_Error
3719
+	 * @throws InvalidArgumentException
3720
+	 * @throws InvalidDataTypeException
3721
+	 * @throws InvalidInterfaceException
3722
+	 * @throws ReflectionException
3723
+	 * @access protected
3724
+	 */
3725
+	protected function _trash_or_restore_attendees($trash = true)
3726
+	{
3727
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3728
+		$status = $trash ? 'trash' : 'publish';
3729
+		// Checkboxes
3730
+		if ($this->request->requestParamIsSet('checkbox')) {
3731
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3732
+			// if array has more than one element than success message should be plural
3733
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3734
+			// cycle thru checkboxes
3735
+			foreach ($ATT_IDs as $ATT_ID) {
3736
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3737
+				if (! $updated) {
3738
+					$success = 0;
3739
+				}
3740
+			}
3741
+		} else {
3742
+			// grab single id and delete
3743
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3744
+			// update attendee
3745
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3746
+		}
3747
+		$what = $success > 1
3748
+			? esc_html__('Contacts', 'event_espresso')
3749
+			: esc_html__('Contact', 'event_espresso');
3750
+		$action_desc = $trash
3751
+			? esc_html__('moved to the trash', 'event_espresso')
3752
+			: esc_html__('restored', 'event_espresso');
3753
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3754
+	}
3755 3755
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function getRegistrationModel()
90 90
     {
91
-        if (! $this->registration_model instanceof EEM_Registration) {
91
+        if ( ! $this->registration_model instanceof EEM_Registration) {
92 92
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
93 93
         }
94 94
         return $this->registration_model;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     protected function getAttendeeModel()
105 105
     {
106
-        if (! $this->attendee_model instanceof EEM_Attendee) {
106
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
107 107
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
108 108
         }
109 109
         return $this->attendee_model;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function getEventModel()
121 121
     {
122
-        if (! $this->event_model instanceof EEM_Event) {
122
+        if ( ! $this->event_model instanceof EEM_Event) {
123 123
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
124 124
         }
125 125
         return $this->event_model;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     protected function getStatusModel()
136 136
     {
137
-        if (! $this->status_model instanceof EEM_Status) {
137
+        if ( ! $this->status_model instanceof EEM_Status) {
138 138
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
139 139
         }
140 140
         return $this->status_model;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
         // style
751 751
         wp_register_style(
752 752
             'espresso_reg',
753
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
753
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
754 754
             array('ee-admin-css'),
755 755
             EVENT_ESPRESSO_VERSION
756 756
         );
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         // script
759 759
         wp_register_script(
760 760
             'espresso_reg',
761
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
761
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
762 762
             array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
763 763
             EVENT_ESPRESSO_VERSION,
764 764
             true
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
             'att_publish_text' => sprintf(
783 783
                 /* translators: The date and time */
784 784
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
785
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
785
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
786 786
             ),
787 787
         );
788 788
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
         wp_dequeue_style('espresso_reg');
814 814
         wp_register_style(
815 815
             'espresso_att',
816
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
816
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
817 817
             array('ee-admin-css'),
818 818
             EVENT_ESPRESSO_VERSION
819 819
         );
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     {
826 826
         wp_register_script(
827 827
             'ee-spco-for-admin',
828
-            REG_ASSETS_URL . 'spco_for_admin.js',
828
+            REG_ASSETS_URL.'spco_for_admin.js',
829 829
             array('underscore', 'jquery'),
830 830
             EVENT_ESPRESSO_VERSION,
831 831
             true
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
         }
1075 1075
         $sc_items = array(
1076 1076
             'approved_status'   => array(
1077
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1077
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1078 1078
                 'desc'  => EEH_Template::pretty_status(
1079 1079
                     EEM_Registration::status_id_approved,
1080 1080
                     false,
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
                 ),
1083 1083
             ),
1084 1084
             'pending_status'    => array(
1085
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1085
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1086 1086
                 'desc'  => EEH_Template::pretty_status(
1087 1087
                     EEM_Registration::status_id_pending_payment,
1088 1088
                     false,
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
                 ),
1091 1091
             ),
1092 1092
             'wait_list'         => array(
1093
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1093
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1094 1094
                 'desc'  => EEH_Template::pretty_status(
1095 1095
                     EEM_Registration::status_id_wait_list,
1096 1096
                     false,
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
                 ),
1099 1099
             ),
1100 1100
             'incomplete_status' => array(
1101
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1101
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1102 1102
                 'desc'  => EEH_Template::pretty_status(
1103 1103
                     EEM_Registration::status_id_incomplete,
1104 1104
                     false,
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
                 ),
1107 1107
             ),
1108 1108
             'not_approved'      => array(
1109
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1109
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1110 1110
                 'desc'  => EEH_Template::pretty_status(
1111 1111
                     EEM_Registration::status_id_not_approved,
1112 1112
                     false,
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
                 ),
1115 1115
             ),
1116 1116
             'declined_status'   => array(
1117
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1117
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1118 1118
                 'desc'  => EEH_Template::pretty_status(
1119 1119
                     EEM_Registration::status_id_declined,
1120 1120
                     false,
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
                 ),
1123 1123
             ),
1124 1124
             'cancelled_status'  => array(
1125
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1125
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1126 1126
                 'desc'  => EEH_Template::pretty_status(
1127 1127
                     EEM_Registration::status_id_cancelled,
1128 1128
                     false,
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
                 $EVT_ID
1185 1185
             )
1186 1186
         ) {
1187
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1187
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1188 1188
                 'new_registration',
1189 1189
                 'add-registrant',
1190 1190
                 array('event_id' => $EVT_ID),
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
         /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1292 1292
         $list_table_query_builder = $this->getLoader()->getNew(
1293 1293
             'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1294
-            [ null, null, $request ]
1294
+            [null, null, $request]
1295 1295
         );
1296 1296
         return $list_table_query_builder->getQueryParams($per_page, $count);
1297 1297
     }
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
                 )
1398 1398
                 : '';
1399 1399
             // grab header
1400
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1400
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1401 1401
             $this->_template_args['REG_ID'] = $this->_registration->ID();
1402 1402
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1403 1403
                 $template_path,
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
                                 EEH_HTML::strong(
1552 1552
                                     $this->_registration->pretty_status(),
1553 1553
                                     '',
1554
-                                    'status-' . $this->_registration->status_ID(),
1554
+                                    'status-'.$this->_registration->status_ID(),
1555 1555
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1556 1556
                                 )
1557 1557
                             )
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
     protected function _get_reg_statuses()
1610 1610
     {
1611 1611
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1612
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1612
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1613 1613
         // get current reg status
1614 1614
         $current_status = $this->_registration->status_ID();
1615 1615
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
             $current_status !== EEM_Registration::status_id_pending_payment
1618 1618
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1619 1619
         ) {
1620
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1620
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1621 1621
         }
1622 1622
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1623 1623
     }
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
         $success = false;
1709 1709
         // typecast $REG_IDs
1710 1710
         $REG_IDs = (array) $REG_IDs;
1711
-        if (! empty($REG_IDs)) {
1711
+        if ( ! empty($REG_IDs)) {
1712 1712
             $success = true;
1713 1713
             // set default status if none is passed
1714 1714
             $status = $status ? $status : EEM_Registration::status_id_pending_payment;
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
             $action,
1869 1869
             $notify
1870 1870
         );
1871
-        $method = $action . '_registration';
1871
+        $method = $action.'_registration';
1872 1872
         if (method_exists($this, $method)) {
1873 1873
             $this->$method($notify);
1874 1874
         }
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
         );
2150 2150
         $this->_template_args['REG_ID'] = $this->_registration->ID();
2151 2151
         $this->_template_args['event_id'] = $this->_registration->event_ID();
2152
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2152
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2153 2153
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2154 2154
     }
2155 2155
 
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
                 : '';
2188 2188
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2189 2189
             $this->_template_args['REG_ID'] = $this->_registration->ID();
2190
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2190
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2191 2191
             EEH_Template::display_template($template_path, $this->_template_args);
2192 2192
         }
2193 2193
     }
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
     public function form_before_question_group($output)
2205 2205
     {
2206 2206
         EE_Error::doing_it_wrong(
2207
-            __CLASS__ . '::' . __FUNCTION__,
2207
+            __CLASS__.'::'.__FUNCTION__,
2208 2208
             esc_html__(
2209 2209
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2210 2210
                 'event_espresso'
@@ -2229,7 +2229,7 @@  discard block
 block discarded – undo
2229 2229
     public function form_after_question_group($output)
2230 2230
     {
2231 2231
         EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2232
+            __CLASS__.'::'.__FUNCTION__,
2233 2233
             esc_html__(
2234 2234
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235 2235
                 'event_espresso'
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
     public function form_form_field_label_wrap($label)
2268 2268
     {
2269 2269
         EE_Error::doing_it_wrong(
2270
-            __CLASS__ . '::' . __FUNCTION__,
2270
+            __CLASS__.'::'.__FUNCTION__,
2271 2271
             esc_html__(
2272 2272
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2273 2273
                 'event_espresso'
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
         return '
2278 2278
 			<tr>
2279 2279
 				<th>
2280
-					' . $label . '
2280
+					' . $label.'
2281 2281
 				</th>';
2282 2282
     }
2283 2283
 
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
     public function form_form_field_input__wrap($input)
2294 2294
     {
2295 2295
         EE_Error::doing_it_wrong(
2296
-            __CLASS__ . '::' . __FUNCTION__,
2296
+            __CLASS__.'::'.__FUNCTION__,
2297 2297
             esc_html__(
2298 2298
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2299 2299
                 'event_espresso'
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
         );
2303 2303
         return '
2304 2304
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2305
-					' . $input . '
2305
+					' . $input.'
2306 2306
 				</td>
2307 2307
 			</tr>';
2308 2308
     }
@@ -2350,8 +2350,8 @@  discard block
 block discarded – undo
2350 2350
      */
2351 2351
     protected function _get_reg_custom_questions_form($REG_ID)
2352 2352
     {
2353
-        if (! $this->_reg_custom_questions_form) {
2354
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2353
+        if ( ! $this->_reg_custom_questions_form) {
2354
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2355 2355
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2356 2356
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2357 2357
             );
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
      */
2376 2376
     private function _save_reg_custom_questions_form($REG_ID = 0)
2377 2377
     {
2378
-        if (! $REG_ID) {
2378
+        if ( ! $REG_ID) {
2379 2379
             EE_Error::add_error(
2380 2380
                 esc_html__(
2381 2381
                     'An error occurred. No registration ID was received.',
@@ -2468,30 +2468,30 @@  discard block
 block discarded – undo
2468 2468
                 $attendee = $registration->attendee()
2469 2469
                     ? $registration->attendee()
2470 2470
                     : $this->getAttendeeModel()->create_default_object();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2474
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2475
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2476
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2471
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
2472
+                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();
2473
+                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();
2474
+                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();
2475
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2476
+                $this->_template_args['attendees'][$att_nmbr]['address'] = implode(
2477 2477
                     ', ',
2478 2478
                     $attendee->full_address_as_array()
2479 2479
                 );
2480
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2480
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2481 2481
                     array(
2482 2482
                         'action' => 'edit_attendee',
2483 2483
                         'post'   => $attendee->ID(),
2484 2484
                     ),
2485 2485
                     REG_ADMIN_URL
2486 2486
                 );
2487
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2487
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj() instanceof EE_Event
2488 2488
                     ? $registration->event_obj()->name()
2489 2489
                     : '';
2490 2490
                 $att_nmbr++;
2491 2491
             }
2492 2492
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2493 2493
         }
2494
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2494
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2495 2495
         EEH_Template::display_template($template_path, $this->_template_args);
2496 2496
     }
2497 2497
 
@@ -2518,11 +2518,11 @@  discard block
 block discarded – undo
2518 2518
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2519 2519
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2520 2520
         // primary registration object (that way we know if we need to show create button or not)
2521
-        if (! $this->_registration->is_primary_registrant()) {
2521
+        if ( ! $this->_registration->is_primary_registrant()) {
2522 2522
             $primary_registration = $this->_registration->get_primary_registration();
2523 2523
             $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2524 2524
                 : null;
2525
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2525
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2526 2526
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2527 2527
                 // custom attendee object so let's not worry about the primary reg.
2528 2528
                 $primary_registration = null;
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
             ) : '';
2557 2557
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2558 2558
         $this->_template_args['att_check'] = $att_check;
2559
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2559
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2560 2560
         EEH_Template::display_template($template_path, $this->_template_args);
2561 2561
     }
2562 2562
 
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
             /** @var EE_Registration $REG */
2602 2602
             $REG = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2603 2603
             $payments = $REG->registration_payments();
2604
-            if (! empty($payments)) {
2604
+            if ( ! empty($payments)) {
2605 2605
                 $name = $REG->attendee() instanceof EE_Attendee
2606 2606
                     ? $REG->attendee()->full_name()
2607 2607
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2665,17 +2665,17 @@  discard block
 block discarded – undo
2665 2665
         // Checkboxes
2666 2666
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2667 2667
 
2668
-        if (! empty($REG_IDs)) {
2668
+        if ( ! empty($REG_IDs)) {
2669 2669
             // if array has more than one element than success message should be plural
2670 2670
             $success = count($REG_IDs) > 1 ? 2 : 1;
2671 2671
             // cycle thru checkboxes
2672 2672
             foreach ($REG_IDs as $REG_ID) {
2673 2673
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2674
-                if (! $REG instanceof EE_Registration) {
2674
+                if ( ! $REG instanceof EE_Registration) {
2675 2675
                     continue;
2676 2676
                 }
2677 2677
                 $deleted = $this->_delete_registration($REG);
2678
-                if (! $deleted) {
2678
+                if ( ! $deleted) {
2679 2679
                     $success = 0;
2680 2680
                 }
2681 2681
             }
@@ -2712,7 +2712,7 @@  discard block
 block discarded – undo
2712 2712
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713 2713
         // registrations on the transaction that are NOT trashed.
2714 2714
         $TXN = $REG->get_first_related('Transaction');
2715
-        if (! $TXN instanceof EE_Transaction) {
2715
+        if ( ! $TXN instanceof EE_Transaction) {
2716 2716
             EE_Error::add_error(
2717 2717
                 sprintf(
2718 2718
                     esc_html__(
@@ -2730,11 +2730,11 @@  discard block
 block discarded – undo
2730 2730
         $REGS = $TXN->get_many_related('Registration');
2731 2731
         $all_trashed = true;
2732 2732
         foreach ($REGS as $registration) {
2733
-            if (! $registration->get('REG_deleted')) {
2733
+            if ( ! $registration->get('REG_deleted')) {
2734 2734
                 $all_trashed = false;
2735 2735
             }
2736 2736
         }
2737
-        if (! $all_trashed) {
2737
+        if ( ! $all_trashed) {
2738 2738
             EE_Error::add_error(
2739 2739
                 esc_html__(
2740 2740
                     'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
      */
2798 2798
     public function new_registration()
2799 2799
     {
2800
-        if (! $this->_set_reg_event()) {
2800
+        if ( ! $this->_set_reg_event()) {
2801 2801
             throw new EE_Error(
2802 2802
                 esc_html__(
2803 2803
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
             $this->_return_json();
2847 2847
         }
2848 2848
         // grab header
2849
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2849
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2850 2850
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2851 2851
             $template_path,
2852 2852
             $this->_template_args,
@@ -2888,7 +2888,7 @@  discard block
 block discarded – undo
2888 2888
                 '</b>'
2889 2889
             );
2890 2890
             return '
2891
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2891
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2892 2892
 	<script >
2893 2893
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2894 2894
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2955,7 +2955,7 @@  discard block
 block discarded – undo
2955 2955
         // we come back to the process_registration_step route.
2956 2956
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2957 2957
         return EEH_Template::display_template(
2958
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2958
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2959 2959
             $template_args,
2960 2960
             true
2961 2961
         );
@@ -2979,7 +2979,7 @@  discard block
 block discarded – undo
2979 2979
         }
2980 2980
 
2981 2981
         $EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2982
-        if (! $EVT_ID) {
2982
+        if ( ! $EVT_ID) {
2983 2983
             return false;
2984 2984
         }
2985 2985
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
                 }
3050 3050
                 break;
3051 3051
             case 'questions':
3052
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3052
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3053 3053
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3054 3054
                 }
3055 3055
                 // process registration
@@ -3060,7 +3060,7 @@  discard block
 block discarded – undo
3060 3060
                         $grand_total->save_this_and_descendants_to_txn();
3061 3061
                     }
3062 3062
                 }
3063
-                if (! $transaction instanceof EE_Transaction) {
3063
+                if ( ! $transaction instanceof EE_Transaction) {
3064 3064
                     $query_args = array(
3065 3065
                         'action'                  => 'new_registration',
3066 3066
                         'processing_registration' => 2,
@@ -3082,7 +3082,7 @@  discard block
 block discarded – undo
3082 3082
                     return;
3083 3083
                 }
3084 3084
                 // maybe update status, and make sure to save transaction if not done already
3085
-                if (! $transaction->update_status_based_on_total_paid()) {
3085
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3086 3086
                     $transaction->save();
3087 3087
                 }
3088 3088
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3167,7 +3167,7 @@  discard block
 block discarded – undo
3167 3167
     public function get_attendees($per_page, $count = false, $trash = false)
3168 3168
     {
3169 3169
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3170
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3170
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3171 3171
         $orderby = $this->request->getRequestParam('orderby');
3172 3172
         switch ($orderby) {
3173 3173
             case 'ATT_ID':
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
         $_where = array();
3191 3191
         $search_term = $this->request->getRequestParam('s');
3192 3192
         if ($search_term) {
3193
-            $search_term = '%' . $search_term . '%';
3193
+            $search_term = '%'.$search_term.'%';
3194 3194
             $_where['OR'] = array(
3195 3195
                 'Registration.Event.EVT_name'       => array('LIKE', $search_term),
3196 3196
                 'Registration.Event.EVT_desc'       => array('LIKE', $search_term),
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
             'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3218 3218
             'limit'         => $limit,
3219 3219
         );
3220
-        if (! $count) {
3220
+        if ( ! $count) {
3221 3221
             $query_args['order_by'] = array($orderby => $sort);
3222 3222
         }
3223 3223
         if ($trash) {
@@ -3270,7 +3270,7 @@  discard block
 block discarded – undo
3270 3270
         $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3271 3271
             ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3272 3272
             : null;
3273
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3273
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3274 3274
             $request_params = $this->request->requestParams();
3275 3275
             wp_redirect(
3276 3276
                 EE_Admin_Page::add_query_args_and_nonce(
@@ -3298,8 +3298,8 @@  discard block
 block discarded – undo
3298 3298
                 'EVT_ID' => $EVT_ID,
3299 3299
             );
3300 3300
             $this->request->mergeRequestParams($new_request_args);
3301
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3302
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3301
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3302
+                require_once(EE_CLASSES.'EE_Export.class.php');
3303 3303
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3304 3304
                 $EE_Export->export();
3305 3305
             }
@@ -3320,8 +3320,8 @@  discard block
 block discarded – undo
3320 3320
 
3321 3321
     public function _contact_list_export()
3322 3322
     {
3323
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3324
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3323
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3324
+            require_once(EE_CLASSES.'EE_Export.class.php');
3325 3325
             $EE_Export = EE_Export::instance($this->request->requestParams());
3326 3326
             $EE_Export->export_attendees();
3327 3327
         }
@@ -3330,7 +3330,7 @@  discard block
 block discarded – undo
3330 3330
 
3331 3331
     public function _contact_list_report()
3332 3332
     {
3333
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3333
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3334 3334
             wp_redirect(
3335 3335
                 EE_Admin_Page::add_query_args_and_nonce(
3336 3336
                     array(
@@ -3342,8 +3342,8 @@  discard block
 block discarded – undo
3342 3342
                 )
3343 3343
             );
3344 3344
         } else {
3345
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3346
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3345
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3346
+                require_once(EE_CLASSES.'EE_Export.class.php');
3347 3347
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3348 3348
                 $EE_Export->report_attendees();
3349 3349
             }
@@ -3370,7 +3370,7 @@  discard block
 block discarded – undo
3370 3370
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3371 3371
         $action = $this->request->getRequestParam('return', 'default');
3372 3372
         // verify we have necessary info
3373
-        if (! $REG_ID) {
3373
+        if ( ! $REG_ID) {
3374 3374
             EE_Error::add_error(
3375 3375
                 esc_html__(
3376 3376
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3385,7 +3385,7 @@  discard block
 block discarded – undo
3385 3385
         }
3386 3386
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3387 3387
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3388
-        if (! $registration instanceof EE_Registration) {
3388
+        if ( ! $registration instanceof EE_Registration) {
3389 3389
             throw new RuntimeException(
3390 3390
                 sprintf(
3391 3391
                     esc_html__(
@@ -3523,16 +3523,16 @@  discard block
 block discarded – undo
3523 3523
         $this->verify_cpt_object();
3524 3524
         remove_meta_box(
3525 3525
             'postexcerpt',
3526
-            $this->_cpt_routes[ $this->_req_action ],
3526
+            $this->_cpt_routes[$this->_req_action],
3527 3527
             'normal'
3528 3528
         );
3529
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3529
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
3530 3530
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3531 3531
             add_meta_box(
3532 3532
                 'postexcerpt',
3533 3533
                 esc_html__('Short Biography', 'event_espresso'),
3534 3534
                 'post_excerpt_meta_box',
3535
-                $this->_cpt_routes[ $this->_req_action ],
3535
+                $this->_cpt_routes[$this->_req_action],
3536 3536
                 'normal'
3537 3537
             );
3538 3538
         }
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
                 'commentsdiv',
3542 3542
                 esc_html__('Notes on the Contact', 'event_espresso'),
3543 3543
                 'post_comment_meta_box',
3544
-                $this->_cpt_routes[ $this->_req_action ],
3544
+                $this->_cpt_routes[$this->_req_action],
3545 3545
                 'normal',
3546 3546
                 'core'
3547 3547
             );
@@ -3550,7 +3550,7 @@  discard block
 block discarded – undo
3550 3550
             'attendee_contact_info',
3551 3551
             esc_html__('Contact Info', 'event_espresso'),
3552 3552
             array($this, 'attendee_contact_info'),
3553
-            $this->_cpt_routes[ $this->_req_action ],
3553
+            $this->_cpt_routes[$this->_req_action],
3554 3554
             'side',
3555 3555
             'core'
3556 3556
         );
@@ -3558,7 +3558,7 @@  discard block
 block discarded – undo
3558 3558
             'attendee_details_address',
3559 3559
             esc_html__('Address Details', 'event_espresso'),
3560 3560
             array($this, 'attendee_address_details'),
3561
-            $this->_cpt_routes[ $this->_req_action ],
3561
+            $this->_cpt_routes[$this->_req_action],
3562 3562
             'normal',
3563 3563
             'core'
3564 3564
         );
@@ -3566,7 +3566,7 @@  discard block
 block discarded – undo
3566 3566
             'attendee_registrations',
3567 3567
             esc_html__('Registrations for this Contact', 'event_espresso'),
3568 3568
             array($this, 'attendee_registrations_meta_box'),
3569
-            $this->_cpt_routes[ $this->_req_action ],
3569
+            $this->_cpt_routes[$this->_req_action],
3570 3570
             'normal',
3571 3571
             'high'
3572 3572
         );
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
                 )
3667 3667
             )
3668 3668
         );
3669
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3669
+        $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3670 3670
         EEH_Template::display_template($template, $this->_template_args);
3671 3671
     }
3672 3672
 
@@ -3688,7 +3688,7 @@  discard block
 block discarded – undo
3688 3688
     {
3689 3689
         $this->_template_args['attendee'] = $this->_cpt_model_obj;
3690 3690
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3691
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3691
+        $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3692 3692
         EEH_Template::display_template($template, $this->_template_args);
3693 3693
     }
3694 3694
 
@@ -3703,7 +3703,7 @@  discard block
 block discarded – undo
3703 3703
     public function after_title_form_fields($post)
3704 3704
     {
3705 3705
         if ($post->post_type === 'espresso_attendees') {
3706
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3706
+            $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3707 3707
             $template_args['attendee'] = $this->_cpt_model_obj;
3708 3708
             EEH_Template::display_template($template, $template_args);
3709 3709
         }
@@ -3734,7 +3734,7 @@  discard block
 block discarded – undo
3734 3734
             // cycle thru checkboxes
3735 3735
             foreach ($ATT_IDs as $ATT_ID) {
3736 3736
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3737
-                if (! $updated) {
3737
+                if ( ! $updated) {
3738 3738
                     $success = 0;
3739 3739
                 }
3740 3740
             }
Please login to merge, or discard this patch.
core/services/encryption/openssl/OpenSSL.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -18,266 +18,266 @@
 block discarded – undo
18 18
 abstract class OpenSSL implements EncryptionMethodInterface
19 19
 {
20 20
 
21
-    /**
22
-     * the default OPENSSL digest method to use
23
-     */
24
-    const DEFAULT_DIGEST_METHOD = 'sha512';
25
-
26
-    /**
27
-     * separates the encrypted text from the initialization vector
28
-     */
29
-    const IV_DELIMITER = ':iv:';
30
-
31
-    /**
32
-     * @var Base64Encoder
33
-     */
34
-    protected $base64_encoder;
35
-
36
-    /**
37
-     * @var CipherMethod
38
-     */
39
-    protected $cipher_method;
40
-
41
-    /**
42
-     * @var array $digest_methods
43
-     */
44
-    private $digest_methods = [];
45
-
46
-    /**
47
-     * @var EncryptionKeyManagerInterface
48
-     */
49
-    protected $encryption_key_manager;
50
-
51
-    /**
52
-     * @var boolean
53
-     */
54
-    private $openssl_installed;
55
-
56
-    /**
57
-     * @var string
58
-     */
59
-    private $min_php_version;
60
-
61
-    /**
62
-     * @var string
63
-     */
64
-    private $hash_algorithm;
65
-
66
-
67
-    /**
68
-     * To use custom a cipher method and/or encryption keys:
69
-     *  - extend this class
70
-     *  - configure a new CipherMethod / EncryptionKeyManager in the constructor
71
-     *  - pass those to this constructor, like so:
72
-     *
73
-     *      public function __construct(Base64Encoder $base64_encoder) {
74
-     *          parent::__construct(
75
-     *              $base64_encoder,
76
-     *              new CipherMethod(CIPHER_METHOD, CIPHER_METHOD_OPTION_NAME)
77
-     *              new EncryptionKeyManager(CUSTOM_KEY_ID, CUSTOM_KEYS_OPTION_NAME)
78
-     *          );
79
-     *      }
80
-     *
81
-     * @param Base64Encoder                      $base64_encoder
82
-     * @param CipherMethod                       $cipher_method
83
-     * @param EncryptionKeyManagerInterface|null $encryption_key_manager
84
-     * @param string                             $min_php_version
85
-     */
86
-    protected function __construct(
87
-        Base64Encoder $base64_encoder,
88
-        CipherMethod $cipher_method,
89
-        EncryptionKeyManagerInterface $encryption_key_manager,
90
-        $min_php_version
91
-    ) {
92
-        $this->base64_encoder         = $base64_encoder;
93
-        $this->cipher_method          = $cipher_method;
94
-        $this->encryption_key_manager = $encryption_key_manager;
95
-        $this->min_php_version        = $min_php_version;
96
-        $this->openssl_installed      = extension_loaded('openssl');
97
-    }
98
-
99
-
100
-    /**
101
-     * @return bool
102
-     */
103
-    public function isCryptographicallySecure()
104
-    {
105
-        return true;
106
-    }
107
-
108
-
109
-    /**
110
-     * @return bool
111
-     */
112
-    public function canUse()
113
-    {
114
-        return $this->openssl_installed && version_compare(PHP_VERSION, $this->min_php_version, '>=');
115
-    }
116
-
117
-
118
-    /**
119
-     * @return string
120
-     */
121
-    public function canUseNotice()
122
-    {
123
-        if (! $this->openssl_installed) {
124
-            return esc_html__(
125
-                'The PHP openssl server extension is required to use Openssl encryption. Please contact your hosting provider regarding this issue.',
126
-                'event_espresso'
127
-            );
128
-        }
129
-        if (version_compare(PHP_VERSION, $this->min_php_version, '<')) {
130
-            return sprintf(
131
-                esc_html__(
132
-                    'PHP version %1$s or greater is required to use Openssl encryption. Please contact your hosting provider regarding this issue.',
133
-                    'event_espresso'
134
-                ),
135
-                $this->min_php_version
136
-            );
137
-        }
138
-        return sprintf(
139
-            esc_html__('OpenSSL v1 encryption using %1$s is available for use.', 'event_espresso'),
140
-            OpenSSLv1::CIPHER_METHOD
141
-        );
142
-    }
143
-
144
-
145
-    /**
146
-     * Computes the digest hash value using the specified digest method.
147
-     * If that digest method fails to produce a valid hash value,
148
-     * then we'll grab the next digest method and recursively try again until something works.
149
-     *
150
-     * @param string $encryption_key
151
-     * @param string $digest_method
152
-     * @param bool   $return_raw_data
153
-     * @return string
154
-     * @throws RuntimeException
155
-     */
156
-    protected function getDigestHashValue(
157
-        $encryption_key,
158
-        $digest_method = OpenSSL::DEFAULT_DIGEST_METHOD,
159
-        $return_raw_data = false
160
-    ) {
161
-        $digest_hash_value = openssl_digest($encryption_key, $digest_method, $return_raw_data);
162
-        if ($digest_hash_value === false) {
163
-            return $this->getDigestHashValue($this->getDigestMethod());
164
-        }
165
-        return $digest_hash_value;
166
-    }
167
-
168
-
169
-    /**
170
-     * Returns the NEXT element in the $digest_methods array.
171
-     * If the $digest_methods array is empty, then we populate it
172
-     * with the available values returned from openssl_get_md_methods().
173
-     *
174
-     * @return string
175
-     * @throws RuntimeException
176
-     */
177
-    private function getDigestMethod()
178
-    {
179
-        $digest_method = prev($this->digest_methods);
180
-        if (empty($this->digest_methods)) {
181
-            $this->digest_methods = openssl_get_md_methods();
182
-            $digest_method        = end($this->digest_methods);
183
-        }
184
-        if ($digest_method === false) {
185
-            throw new RuntimeException(
186
-                esc_html__(
187
-                    'OpenSSL support appears to be enabled on the server, but no digest methods are available. Please contact the server administrator.',
188
-                    'event_espresso'
189
-                )
190
-            );
191
-        }
192
-        return $digest_method;
193
-    }
194
-
195
-
196
-    /**
197
-     * @param string $encryption_key
198
-     * @return int
199
-     */
200
-    protected function calculateHashLength($encryption_key)
201
-    {
202
-        // get existing key length
203
-        $prev_key_length = $this->encryption_key_manager->keyLength();
204
-        // set it to something HUGE
205
-        $this->encryption_key_manager->setKeyLength(512);
206
-        // generate a new weak key, which should just be a really long random string
207
-        $test_text = $this->encryption_key_manager->generateEncryptionKey(false);
208
-        // generate a hash using our test string and our real $encryption_key
209
-        $hash = hash_hmac($this->getHashAlgorithm(), $test_text, $encryption_key, true);
210
-        // reset key length back to original value
211
-        $this->encryption_key_manager->setKeyLength($prev_key_length);
212
-        // return the length of the hash
213
-        return strlen($hash);
214
-    }
215
-
216
-
217
-    /**
218
-     * @return string
219
-     */
220
-    protected function getHashAlgorithm()
221
-    {
222
-        if (! $this->hash_algorithm) {
223
-            // get installed hashing algorithms
224
-            $hash_algorithms = hash_algos();
225
-            // filter array for "sha" algorithms
226
-            $hash_algorithms = preg_grep('/^sha\d{3}$/i', $hash_algorithms);
227
-            // if no sha algorithms are installed, then just use md5
228
-            if (empty($hash_algorithms)) {
229
-                $this->hash_algorithm = 'md5';
230
-                return $this->hash_algorithm;
231
-            }
232
-            // sort ascending using "natural ordering"
233
-            sort($hash_algorithms, SORT_NATURAL);
234
-            // return last item from array, which should be the strongest installed sha hash
235
-            $this->hash_algorithm = array_pop($hash_algorithms);
236
-        }
237
-        return $this->hash_algorithm;
238
-    }
239
-
240
-
241
-    /**
242
-     * @param string $encrypted_text
243
-     * @throws RuntimeException
244
-     */
245
-    protected function validateEncryption($encrypted_text)
246
-    {
247
-        if ($encrypted_text === false) {
248
-            throw new RuntimeException(
249
-                sprintf(
250
-                    esc_html__('The following error occurred during OpenSSL encryption: %1$s', 'event_espresso'),
251
-                    $this->getOpenSslError()
252
-                )
253
-            );
254
-        }
255
-    }
256
-
257
-
258
-    /**
259
-     * @return false|string
260
-     */
261
-    private function getOpenSslError()
262
-    {
263
-        $error = openssl_error_string();
264
-        return $error ?: esc_html__('Unknown Error', 'event_espresso');
265
-    }
266
-
267
-
268
-    /**
269
-     * @param string $encrypted_text
270
-     * @throws RuntimeException
271
-     */
272
-    protected function validateDecryption($encrypted_text)
273
-    {
274
-        if ($encrypted_text === false) {
275
-            throw new RuntimeException(
276
-                sprintf(
277
-                    esc_html__('OpenSSL decryption failed for the following reason: %1$s', 'event_espresso'),
278
-                    $this->getOpenSslError()
279
-                )
280
-            );
281
-        }
282
-    }
21
+	/**
22
+	 * the default OPENSSL digest method to use
23
+	 */
24
+	const DEFAULT_DIGEST_METHOD = 'sha512';
25
+
26
+	/**
27
+	 * separates the encrypted text from the initialization vector
28
+	 */
29
+	const IV_DELIMITER = ':iv:';
30
+
31
+	/**
32
+	 * @var Base64Encoder
33
+	 */
34
+	protected $base64_encoder;
35
+
36
+	/**
37
+	 * @var CipherMethod
38
+	 */
39
+	protected $cipher_method;
40
+
41
+	/**
42
+	 * @var array $digest_methods
43
+	 */
44
+	private $digest_methods = [];
45
+
46
+	/**
47
+	 * @var EncryptionKeyManagerInterface
48
+	 */
49
+	protected $encryption_key_manager;
50
+
51
+	/**
52
+	 * @var boolean
53
+	 */
54
+	private $openssl_installed;
55
+
56
+	/**
57
+	 * @var string
58
+	 */
59
+	private $min_php_version;
60
+
61
+	/**
62
+	 * @var string
63
+	 */
64
+	private $hash_algorithm;
65
+
66
+
67
+	/**
68
+	 * To use custom a cipher method and/or encryption keys:
69
+	 *  - extend this class
70
+	 *  - configure a new CipherMethod / EncryptionKeyManager in the constructor
71
+	 *  - pass those to this constructor, like so:
72
+	 *
73
+	 *      public function __construct(Base64Encoder $base64_encoder) {
74
+	 *          parent::__construct(
75
+	 *              $base64_encoder,
76
+	 *              new CipherMethod(CIPHER_METHOD, CIPHER_METHOD_OPTION_NAME)
77
+	 *              new EncryptionKeyManager(CUSTOM_KEY_ID, CUSTOM_KEYS_OPTION_NAME)
78
+	 *          );
79
+	 *      }
80
+	 *
81
+	 * @param Base64Encoder                      $base64_encoder
82
+	 * @param CipherMethod                       $cipher_method
83
+	 * @param EncryptionKeyManagerInterface|null $encryption_key_manager
84
+	 * @param string                             $min_php_version
85
+	 */
86
+	protected function __construct(
87
+		Base64Encoder $base64_encoder,
88
+		CipherMethod $cipher_method,
89
+		EncryptionKeyManagerInterface $encryption_key_manager,
90
+		$min_php_version
91
+	) {
92
+		$this->base64_encoder         = $base64_encoder;
93
+		$this->cipher_method          = $cipher_method;
94
+		$this->encryption_key_manager = $encryption_key_manager;
95
+		$this->min_php_version        = $min_php_version;
96
+		$this->openssl_installed      = extension_loaded('openssl');
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return bool
102
+	 */
103
+	public function isCryptographicallySecure()
104
+	{
105
+		return true;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return bool
111
+	 */
112
+	public function canUse()
113
+	{
114
+		return $this->openssl_installed && version_compare(PHP_VERSION, $this->min_php_version, '>=');
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return string
120
+	 */
121
+	public function canUseNotice()
122
+	{
123
+		if (! $this->openssl_installed) {
124
+			return esc_html__(
125
+				'The PHP openssl server extension is required to use Openssl encryption. Please contact your hosting provider regarding this issue.',
126
+				'event_espresso'
127
+			);
128
+		}
129
+		if (version_compare(PHP_VERSION, $this->min_php_version, '<')) {
130
+			return sprintf(
131
+				esc_html__(
132
+					'PHP version %1$s or greater is required to use Openssl encryption. Please contact your hosting provider regarding this issue.',
133
+					'event_espresso'
134
+				),
135
+				$this->min_php_version
136
+			);
137
+		}
138
+		return sprintf(
139
+			esc_html__('OpenSSL v1 encryption using %1$s is available for use.', 'event_espresso'),
140
+			OpenSSLv1::CIPHER_METHOD
141
+		);
142
+	}
143
+
144
+
145
+	/**
146
+	 * Computes the digest hash value using the specified digest method.
147
+	 * If that digest method fails to produce a valid hash value,
148
+	 * then we'll grab the next digest method and recursively try again until something works.
149
+	 *
150
+	 * @param string $encryption_key
151
+	 * @param string $digest_method
152
+	 * @param bool   $return_raw_data
153
+	 * @return string
154
+	 * @throws RuntimeException
155
+	 */
156
+	protected function getDigestHashValue(
157
+		$encryption_key,
158
+		$digest_method = OpenSSL::DEFAULT_DIGEST_METHOD,
159
+		$return_raw_data = false
160
+	) {
161
+		$digest_hash_value = openssl_digest($encryption_key, $digest_method, $return_raw_data);
162
+		if ($digest_hash_value === false) {
163
+			return $this->getDigestHashValue($this->getDigestMethod());
164
+		}
165
+		return $digest_hash_value;
166
+	}
167
+
168
+
169
+	/**
170
+	 * Returns the NEXT element in the $digest_methods array.
171
+	 * If the $digest_methods array is empty, then we populate it
172
+	 * with the available values returned from openssl_get_md_methods().
173
+	 *
174
+	 * @return string
175
+	 * @throws RuntimeException
176
+	 */
177
+	private function getDigestMethod()
178
+	{
179
+		$digest_method = prev($this->digest_methods);
180
+		if (empty($this->digest_methods)) {
181
+			$this->digest_methods = openssl_get_md_methods();
182
+			$digest_method        = end($this->digest_methods);
183
+		}
184
+		if ($digest_method === false) {
185
+			throw new RuntimeException(
186
+				esc_html__(
187
+					'OpenSSL support appears to be enabled on the server, but no digest methods are available. Please contact the server administrator.',
188
+					'event_espresso'
189
+				)
190
+			);
191
+		}
192
+		return $digest_method;
193
+	}
194
+
195
+
196
+	/**
197
+	 * @param string $encryption_key
198
+	 * @return int
199
+	 */
200
+	protected function calculateHashLength($encryption_key)
201
+	{
202
+		// get existing key length
203
+		$prev_key_length = $this->encryption_key_manager->keyLength();
204
+		// set it to something HUGE
205
+		$this->encryption_key_manager->setKeyLength(512);
206
+		// generate a new weak key, which should just be a really long random string
207
+		$test_text = $this->encryption_key_manager->generateEncryptionKey(false);
208
+		// generate a hash using our test string and our real $encryption_key
209
+		$hash = hash_hmac($this->getHashAlgorithm(), $test_text, $encryption_key, true);
210
+		// reset key length back to original value
211
+		$this->encryption_key_manager->setKeyLength($prev_key_length);
212
+		// return the length of the hash
213
+		return strlen($hash);
214
+	}
215
+
216
+
217
+	/**
218
+	 * @return string
219
+	 */
220
+	protected function getHashAlgorithm()
221
+	{
222
+		if (! $this->hash_algorithm) {
223
+			// get installed hashing algorithms
224
+			$hash_algorithms = hash_algos();
225
+			// filter array for "sha" algorithms
226
+			$hash_algorithms = preg_grep('/^sha\d{3}$/i', $hash_algorithms);
227
+			// if no sha algorithms are installed, then just use md5
228
+			if (empty($hash_algorithms)) {
229
+				$this->hash_algorithm = 'md5';
230
+				return $this->hash_algorithm;
231
+			}
232
+			// sort ascending using "natural ordering"
233
+			sort($hash_algorithms, SORT_NATURAL);
234
+			// return last item from array, which should be the strongest installed sha hash
235
+			$this->hash_algorithm = array_pop($hash_algorithms);
236
+		}
237
+		return $this->hash_algorithm;
238
+	}
239
+
240
+
241
+	/**
242
+	 * @param string $encrypted_text
243
+	 * @throws RuntimeException
244
+	 */
245
+	protected function validateEncryption($encrypted_text)
246
+	{
247
+		if ($encrypted_text === false) {
248
+			throw new RuntimeException(
249
+				sprintf(
250
+					esc_html__('The following error occurred during OpenSSL encryption: %1$s', 'event_espresso'),
251
+					$this->getOpenSslError()
252
+				)
253
+			);
254
+		}
255
+	}
256
+
257
+
258
+	/**
259
+	 * @return false|string
260
+	 */
261
+	private function getOpenSslError()
262
+	{
263
+		$error = openssl_error_string();
264
+		return $error ?: esc_html__('Unknown Error', 'event_espresso');
265
+	}
266
+
267
+
268
+	/**
269
+	 * @param string $encrypted_text
270
+	 * @throws RuntimeException
271
+	 */
272
+	protected function validateDecryption($encrypted_text)
273
+	{
274
+		if ($encrypted_text === false) {
275
+			throw new RuntimeException(
276
+				sprintf(
277
+					esc_html__('OpenSSL decryption failed for the following reason: %1$s', 'event_espresso'),
278
+					$this->getOpenSslError()
279
+				)
280
+			);
281
+		}
282
+	}
283 283
 }
Please login to merge, or discard this patch.
core/services/request/RequestParams.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -14,327 +14,327 @@
 block discarded – undo
14 14
 class RequestParams
15 15
 {
16 16
 
17
-    /**
18
-     * $_GET parameters
19
-     *
20
-     * @var array
21
-     */
22
-    protected $get;
23
-
24
-    /**
25
-     * $_POST parameters
26
-     *
27
-     * @var array
28
-     */
29
-    protected $post;
30
-
31
-    /**
32
-     * $_REQUEST parameters
33
-     *
34
-     * @var array
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RequestSanitizer
40
-     */
41
-    protected $sanitizer;
42
-
43
-
44
-    /**
45
-     * RequestParams constructor.
46
-     *
47
-     * @param RequestSanitizer $sanitizer
48
-     * @param array            $get
49
-     * @param array            $post
50
-     */
51
-    public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
-    {
53
-        $this->sanitizer = $sanitizer;
54
-        $this->get       = ! empty($get) ? $get : $_GET;
55
-        $this->post      = ! empty($post) ? $post : $_POST;
56
-        $this->request   = array_merge($this->get, $this->post);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return array
62
-     */
63
-    public function getParams()
64
-    {
65
-        return $this->get;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function postParams()
73
-    {
74
-        return $this->post;
75
-    }
76
-
77
-
78
-    /**
79
-     * returns contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams()
84
-    {
85
-        return $this->request;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string     $key
91
-     * @param mixed|null $value
92
-     * @param bool       $override_ee
93
-     * @return    void
94
-     */
95
-    public function setRequestParam($key, $value, $override_ee = false)
96
-    {
97
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
98
-        if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
-            $this->request[ $key ] = $value;
100
-        }
101
-    }
102
-
103
-
104
-    /**
105
-     * merges the incoming array of parameters into the existing request parameters
106
-     *
107
-     * @param array $request_params
108
-     * @return void
109
-     * @since   $VID:$
110
-     */
111
-    public function mergeRequestParams(array $request_params)
112
-    {
113
-        $this->request = array_merge_recursive($this->request, $request_params);
114
-    }
115
-
116
-
117
-    /**
118
-     * returns   the value for a request param if the given key exists
119
-     *
120
-     * @param string     $key
121
-     * @param mixed|null $default
122
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
-     * @param string     $delimiter for CSV type strings that should be returned as an array
125
-     * @return array|bool|float|int|string
126
-     */
127
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
-    {
129
-        return $this->sanitizer->clean(
130
-            $this->parameterDrillDown($key, $default, 'get'),
131
-            $type,
132
-            $is_array,
133
-            $delimiter
134
-        );
135
-    }
136
-
137
-
138
-    /**
139
-     * check if param exists
140
-     *
141
-     * @param string $key
142
-     * @return bool
143
-     */
144
-    public function requestParamIsSet($key)
145
-    {
146
-        return (bool) $this->parameterDrillDown($key);
147
-    }
148
-
149
-
150
-    /**
151
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
-     * and return the value for the first match found
153
-     * wildcards can be either of the following:
154
-     *      ? to represent a single character of any type
155
-     *      * to represent one or more characters of any type
156
-     *
157
-     * @param string     $pattern
158
-     * @param mixed|null $default
159
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
-     * @param string     $delimiter for CSV type strings that should be returned as an array
162
-     * @return array|bool|float|int|string
163
-     */
164
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
-    {
166
-        return $this->sanitizer->clean(
167
-            $this->parameterDrillDown($pattern, $default, 'match'),
168
-            $type,
169
-            $is_array,
170
-            $delimiter
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
177
-     * wildcards can be either of the following:
178
-     *      ? to represent a single character of any type
179
-     *      * to represent one or more characters of any type
180
-     * returns true if a match is found or false if not
181
-     *
182
-     * @param string $pattern
183
-     * @return bool
184
-     */
185
-    public function matches($pattern)
186
-    {
187
-        return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
-    }
189
-
190
-
191
-    /**
192
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
-     *                                      and used to search through the current request's parameter keys
195
-     * @param array  $request_params        The array of request parameters to search through
196
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
197
-     *                                      Default is null
198
-     * @param string $return                [optional] Controls what kind of value is returned.
199
-     *                                      Options are:
200
-     *                                      'bool' will return true or false if match is found or not
201
-     *                                      'key' will return the first key found that matches the supplied pattern
202
-     *                                      'value' will return the value for the first request parameter
203
-     *                                      whose key matches the supplied pattern
204
-     *                                      Default is 'value'
205
-     * @return boolean|string
206
-     */
207
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
208
-    {
209
-        $return = in_array($return, ['bool', 'key', 'value'], true)
210
-            ? $return
211
-            : 'is_set';
212
-        // replace wildcard chars with regex chars
213
-        $pattern = str_replace(
214
-            ['\*', '\?'],
215
-            ['.*', '.'],
216
-            preg_quote($pattern, '/')
217
-        );
218
-        foreach ($request_params as $key => $request_param) {
219
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
220
-                // return value for request param
221
-                if ($return === 'value') {
222
-                    return $request_param;
223
-                }
224
-                // or actual key or true just to indicate it was found
225
-                return $return === 'key' ? $key : true;
226
-            }
227
-        }
228
-        // match not found so return default value or false
229
-        return $return === 'value' ? $default : false;
230
-    }
231
-
232
-
233
-    /**
234
-     * the supplied key can be a simple string to represent a "top-level" request parameter
235
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
-     * by using square brackets to surround keys for deeper array elements.
237
-     * For example :
238
-     * if the supplied $key was: "first[second][third]"
239
-     * then this will attempt to drill down into the request parameter array to find a value.
240
-     * Given the following request parameters:
241
-     *  array(
242
-     *      'first' => array(
243
-     *          'second' => array(
244
-     *              'third' => 'has a value'
245
-     *          )
246
-     *      )
247
-     *  )
248
-     * would return true if default parameters were set
249
-     *
250
-     * @param string $callback
251
-     * @param        $key
252
-     * @param null   $default
253
-     * @param string $return
254
-     * @param mixed  $request_params
255
-     * @return bool|mixed|null
256
-     */
257
-    private function parameterDrillDown(
258
-        $key,
259
-        $default = null,
260
-        $callback = 'is_set',
261
-        $return = 'value',
262
-        $request_params = []
263
-    ) {
264
-        $callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
-            ? $callback
266
-            : 'is_set';
267
-        $request_params = ! empty($request_params)
268
-            ? $request_params
269
-            : $this->request;
270
-        // does incoming key represent an array like 'first[second][third]'  ?
271
-        if (strpos($key, '[') !== false) {
272
-            // turn it into an actual array
273
-            $key  = str_replace(']', '', $key);
274
-            $keys = explode('[', $key);
275
-            $key  = array_shift($keys);
276
-            if ($callback === 'match') {
277
-                $real_key = $this->match($key, $request_params, $default, 'key');
278
-                $key      = $real_key ?: $key;
279
-            }
280
-            // check if top level key exists
281
-            if (isset($request_params[ $key ])) {
282
-                // build a new key to pass along like: 'second[third]'
283
-                // or just 'second' depending on depth of keys
284
-                $key_string = array_shift($keys);
285
-                if (! empty($keys)) {
286
-                    $key_string .= '[' . implode('][', $keys) . ']';
287
-                }
288
-                return $this->parameterDrillDown(
289
-                    $key_string,
290
-                    $default,
291
-                    $callback,
292
-                    $return,
293
-                    $request_params[ $key ]
294
-                );
295
-            }
296
-        }
297
-        if ($callback === 'is_set') {
298
-            return isset($request_params[ $key ]);
299
-        }
300
-        if ($callback === 'match') {
301
-            return $this->match($key, $request_params, $default, $return);
302
-        }
303
-        return isset($request_params[ $key ])
304
-            ? $request_params[ $key ]
305
-            : $default;
306
-    }
307
-
308
-
309
-    /**
310
-     * remove param
311
-     *
312
-     * @param      $key
313
-     * @param bool $unset_from_global_too
314
-     */
315
-    public function unSetRequestParam($key, $unset_from_global_too = false)
316
-    {
317
-        // because unset may not actually remove var
318
-        $this->get[ $key ]     = null;
319
-        $this->post[ $key ]    = null;
320
-        $this->request[ $key ] = null;
321
-        unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
-        if ($unset_from_global_too) {
323
-            unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * remove params
330
-     *
331
-     * @param array $keys
332
-     * @param bool  $unset_from_global_too
333
-     */
334
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
-    {
336
-        foreach ($keys as $key) {
337
-            $this->unSetRequestParam($key, $unset_from_global_too);
338
-        }
339
-    }
17
+	/**
18
+	 * $_GET parameters
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $get;
23
+
24
+	/**
25
+	 * $_POST parameters
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $post;
30
+
31
+	/**
32
+	 * $_REQUEST parameters
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RequestSanitizer
40
+	 */
41
+	protected $sanitizer;
42
+
43
+
44
+	/**
45
+	 * RequestParams constructor.
46
+	 *
47
+	 * @param RequestSanitizer $sanitizer
48
+	 * @param array            $get
49
+	 * @param array            $post
50
+	 */
51
+	public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
+	{
53
+		$this->sanitizer = $sanitizer;
54
+		$this->get       = ! empty($get) ? $get : $_GET;
55
+		$this->post      = ! empty($post) ? $post : $_POST;
56
+		$this->request   = array_merge($this->get, $this->post);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return array
62
+	 */
63
+	public function getParams()
64
+	{
65
+		return $this->get;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function postParams()
73
+	{
74
+		return $this->post;
75
+	}
76
+
77
+
78
+	/**
79
+	 * returns contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams()
84
+	{
85
+		return $this->request;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string     $key
91
+	 * @param mixed|null $value
92
+	 * @param bool       $override_ee
93
+	 * @return    void
94
+	 */
95
+	public function setRequestParam($key, $value, $override_ee = false)
96
+	{
97
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
98
+		if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
+			$this->request[ $key ] = $value;
100
+		}
101
+	}
102
+
103
+
104
+	/**
105
+	 * merges the incoming array of parameters into the existing request parameters
106
+	 *
107
+	 * @param array $request_params
108
+	 * @return void
109
+	 * @since   $VID:$
110
+	 */
111
+	public function mergeRequestParams(array $request_params)
112
+	{
113
+		$this->request = array_merge_recursive($this->request, $request_params);
114
+	}
115
+
116
+
117
+	/**
118
+	 * returns   the value for a request param if the given key exists
119
+	 *
120
+	 * @param string     $key
121
+	 * @param mixed|null $default
122
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
125
+	 * @return array|bool|float|int|string
126
+	 */
127
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
+	{
129
+		return $this->sanitizer->clean(
130
+			$this->parameterDrillDown($key, $default, 'get'),
131
+			$type,
132
+			$is_array,
133
+			$delimiter
134
+		);
135
+	}
136
+
137
+
138
+	/**
139
+	 * check if param exists
140
+	 *
141
+	 * @param string $key
142
+	 * @return bool
143
+	 */
144
+	public function requestParamIsSet($key)
145
+	{
146
+		return (bool) $this->parameterDrillDown($key);
147
+	}
148
+
149
+
150
+	/**
151
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
+	 * and return the value for the first match found
153
+	 * wildcards can be either of the following:
154
+	 *      ? to represent a single character of any type
155
+	 *      * to represent one or more characters of any type
156
+	 *
157
+	 * @param string     $pattern
158
+	 * @param mixed|null $default
159
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
162
+	 * @return array|bool|float|int|string
163
+	 */
164
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
+	{
166
+		return $this->sanitizer->clean(
167
+			$this->parameterDrillDown($pattern, $default, 'match'),
168
+			$type,
169
+			$is_array,
170
+			$delimiter
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
177
+	 * wildcards can be either of the following:
178
+	 *      ? to represent a single character of any type
179
+	 *      * to represent one or more characters of any type
180
+	 * returns true if a match is found or false if not
181
+	 *
182
+	 * @param string $pattern
183
+	 * @return bool
184
+	 */
185
+	public function matches($pattern)
186
+	{
187
+		return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
+	}
189
+
190
+
191
+	/**
192
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
+	 *                                      and used to search through the current request's parameter keys
195
+	 * @param array  $request_params        The array of request parameters to search through
196
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
197
+	 *                                      Default is null
198
+	 * @param string $return                [optional] Controls what kind of value is returned.
199
+	 *                                      Options are:
200
+	 *                                      'bool' will return true or false if match is found or not
201
+	 *                                      'key' will return the first key found that matches the supplied pattern
202
+	 *                                      'value' will return the value for the first request parameter
203
+	 *                                      whose key matches the supplied pattern
204
+	 *                                      Default is 'value'
205
+	 * @return boolean|string
206
+	 */
207
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
208
+	{
209
+		$return = in_array($return, ['bool', 'key', 'value'], true)
210
+			? $return
211
+			: 'is_set';
212
+		// replace wildcard chars with regex chars
213
+		$pattern = str_replace(
214
+			['\*', '\?'],
215
+			['.*', '.'],
216
+			preg_quote($pattern, '/')
217
+		);
218
+		foreach ($request_params as $key => $request_param) {
219
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
220
+				// return value for request param
221
+				if ($return === 'value') {
222
+					return $request_param;
223
+				}
224
+				// or actual key or true just to indicate it was found
225
+				return $return === 'key' ? $key : true;
226
+			}
227
+		}
228
+		// match not found so return default value or false
229
+		return $return === 'value' ? $default : false;
230
+	}
231
+
232
+
233
+	/**
234
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
235
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
+	 * by using square brackets to surround keys for deeper array elements.
237
+	 * For example :
238
+	 * if the supplied $key was: "first[second][third]"
239
+	 * then this will attempt to drill down into the request parameter array to find a value.
240
+	 * Given the following request parameters:
241
+	 *  array(
242
+	 *      'first' => array(
243
+	 *          'second' => array(
244
+	 *              'third' => 'has a value'
245
+	 *          )
246
+	 *      )
247
+	 *  )
248
+	 * would return true if default parameters were set
249
+	 *
250
+	 * @param string $callback
251
+	 * @param        $key
252
+	 * @param null   $default
253
+	 * @param string $return
254
+	 * @param mixed  $request_params
255
+	 * @return bool|mixed|null
256
+	 */
257
+	private function parameterDrillDown(
258
+		$key,
259
+		$default = null,
260
+		$callback = 'is_set',
261
+		$return = 'value',
262
+		$request_params = []
263
+	) {
264
+		$callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
+			? $callback
266
+			: 'is_set';
267
+		$request_params = ! empty($request_params)
268
+			? $request_params
269
+			: $this->request;
270
+		// does incoming key represent an array like 'first[second][third]'  ?
271
+		if (strpos($key, '[') !== false) {
272
+			// turn it into an actual array
273
+			$key  = str_replace(']', '', $key);
274
+			$keys = explode('[', $key);
275
+			$key  = array_shift($keys);
276
+			if ($callback === 'match') {
277
+				$real_key = $this->match($key, $request_params, $default, 'key');
278
+				$key      = $real_key ?: $key;
279
+			}
280
+			// check if top level key exists
281
+			if (isset($request_params[ $key ])) {
282
+				// build a new key to pass along like: 'second[third]'
283
+				// or just 'second' depending on depth of keys
284
+				$key_string = array_shift($keys);
285
+				if (! empty($keys)) {
286
+					$key_string .= '[' . implode('][', $keys) . ']';
287
+				}
288
+				return $this->parameterDrillDown(
289
+					$key_string,
290
+					$default,
291
+					$callback,
292
+					$return,
293
+					$request_params[ $key ]
294
+				);
295
+			}
296
+		}
297
+		if ($callback === 'is_set') {
298
+			return isset($request_params[ $key ]);
299
+		}
300
+		if ($callback === 'match') {
301
+			return $this->match($key, $request_params, $default, $return);
302
+		}
303
+		return isset($request_params[ $key ])
304
+			? $request_params[ $key ]
305
+			: $default;
306
+	}
307
+
308
+
309
+	/**
310
+	 * remove param
311
+	 *
312
+	 * @param      $key
313
+	 * @param bool $unset_from_global_too
314
+	 */
315
+	public function unSetRequestParam($key, $unset_from_global_too = false)
316
+	{
317
+		// because unset may not actually remove var
318
+		$this->get[ $key ]     = null;
319
+		$this->post[ $key ]    = null;
320
+		$this->request[ $key ] = null;
321
+		unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
+		if ($unset_from_global_too) {
323
+			unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * remove params
330
+	 *
331
+	 * @param array $keys
332
+	 * @param bool  $unset_from_global_too
333
+	 */
334
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
+	{
336
+		foreach ($keys as $key) {
337
+			$this->unSetRequestParam($key, $unset_from_global_too);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -17,495 +17,495 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_COOKIE parameters
22
-     *
23
-     * @var array
24
-     */
25
-    protected $cookies;
26
-
27
-    /**
28
-     * $_FILES parameters
29
-     *
30
-     * @var array
31
-     */
32
-    protected $files;
33
-
34
-    /**
35
-     * true if current user appears to be some kind of bot
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $is_bot;
40
-
41
-    /**
42
-     * @var RequestParams
43
-     */
44
-    protected $request_params;
45
-
46
-    /**
47
-     * @var RequestTypeContextCheckerInterface
48
-     */
49
-    protected $request_type;
50
-
51
-    /**
52
-     * @var ServerParams
53
-     */
54
-    protected $server_params;
55
-
56
-
57
-    public function __construct(
58
-        RequestParams $request_params,
59
-        ServerParams $server_params,
60
-        array $cookies = [],
61
-        array $files = []
62
-    ) {
63
-        $this->cookies = ! empty($cookies)
64
-            ? $cookies
65
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
-        $this->files          = ! empty($files) ? $files : $_FILES;
67
-        $this->request_params = $request_params;
68
-        $this->server_params  = $server_params;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestTypeContextCheckerInterface $type
74
-     */
75
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
-    {
77
-        $this->request_type = $type;
78
-    }
79
-
80
-
81
-    /**
82
-     * @return array
83
-     */
84
-    public function getParams()
85
-    {
86
-        return $this->request_params->getParams();
87
-    }
88
-
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    public function postParams()
94
-    {
95
-        return $this->request_params->postParams();
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    public function cookieParams()
103
-    {
104
-        return $this->cookies;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function serverParams()
112
-    {
113
-        return $this->server_params->getAllServerParams();
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $key
119
-     * @param mixed|null $default
120
-     * @return array|int|float|string
121
-     */
122
-    public function getServerParam($key, $default = null)
123
-    {
124
-        return $this->server_params->getServerParam($key, $default);
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                 $key
130
-     * @param array|int|float|string $value
131
-     * @return void
132
-     */
133
-    public function setServerParam($key, $value)
134
-    {
135
-        $this->server_params->setServerParam($key, $value);
136
-    }
137
-
138
-
139
-    /**
140
-     * @param string $key
141
-     * @return bool
142
-     */
143
-    public function serverParamIsSet($key)
144
-    {
145
-        return $this->server_params->serverParamIsSet($key);
146
-    }
147
-
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function filesParams()
153
-    {
154
-        return $this->files;
155
-    }
156
-
157
-
158
-    /**
159
-     * returns sanitized contents of $_REQUEST
160
-     *
161
-     * @return array
162
-     */
163
-    public function requestParams()
164
-    {
165
-        return $this->request_params->requestParams();
166
-    }
167
-
168
-
169
-    /**
170
-     * @param string     $key
171
-     * @param mixed|null $value
172
-     * @param bool       $override_ee
173
-     * @return void
174
-     */
175
-    public function setRequestParam($key, $value, $override_ee = false)
176
-    {
177
-        $this->request_params->setRequestParam($key, $value, $override_ee);
178
-    }
179
-
180
-
181
-    /**
182
-     * merges the incoming array of parameters into the existing request parameters
183
-     *
184
-     * @param array $request_params
185
-     * @return void
186
-     * @since   $VID:$
187
-     */
188
-    public function mergeRequestParams(array $request_params)
189
-    {
190
-        $this->request_params->mergeRequestParams($request_params);
191
-    }
192
-
193
-
194
-    /**
195
-     * returns sanitized value for a request param if the given key exists
196
-     *
197
-     * @param string     $key
198
-     * @param mixed|null $default
199
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
-     * @param string     $delimiter for CSV type strings that should be returned as an array
202
-     * @return array|bool|float|int|string
203
-     */
204
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
-    {
206
-        return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
-    }
208
-
209
-
210
-    /**
211
-     * check if param exists
212
-     *
213
-     * @param string $key
214
-     * @return bool
215
-     */
216
-    public function requestParamIsSet($key)
217
-    {
218
-        return $this->request_params->requestParamIsSet($key);
219
-    }
220
-
221
-
222
-    /**
223
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
-     * and return the sanitized value for the first match found
225
-     * wildcards can be either of the following:
226
-     *      ? to represent a single character of any type
227
-     *      * to represent one or more characters of any type
228
-     *
229
-     * @param string     $pattern
230
-     * @param mixed|null $default
231
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
-     * @param string     $delimiter for CSV type strings that should be returned as an array
234
-     * @return array|bool|float|int|string
235
-     */
236
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
-    {
238
-        return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
-    }
240
-
241
-
242
-    /**
243
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
244
-     * wildcards can be either of the following:
245
-     *      ? to represent a single character of any type
246
-     *      * to represent one or more characters of any type
247
-     * returns true if a match is found or false if not
248
-     *
249
-     * @param string $pattern
250
-     * @return bool
251
-     */
252
-    public function matches($pattern)
253
-    {
254
-        return $this->request_params->matches($pattern);
255
-    }
256
-
257
-
258
-    /**
259
-     * remove param
260
-     *
261
-     * @param      $key
262
-     * @param bool $unset_from_global_too
263
-     */
264
-    public function unSetRequestParam($key, $unset_from_global_too = false)
265
-    {
266
-        $this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
-    }
268
-
269
-
270
-    /**
271
-     * remove params
272
-     *
273
-     * @param array $keys
274
-     * @param bool  $unset_from_global_too
275
-     */
276
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
-    {
278
-        $this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
-    }
280
-
281
-
282
-    /**
283
-     * @return string
284
-     */
285
-    public function ipAddress()
286
-    {
287
-        return $this->server_params->ipAddress();
288
-    }
289
-
290
-
291
-    /**
292
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
-     *
294
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
-     * @return string
298
-     */
299
-    public function requestUri($relativeToWpRoot = false)
300
-    {
301
-        return $this->server_params->requestUri();
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function userAgent()
309
-    {
310
-        return $this->server_params->userAgent();
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $user_agent
316
-     */
317
-    public function setUserAgent($user_agent = '')
318
-    {
319
-        $this->server_params->setUserAgent($user_agent);
320
-    }
321
-
322
-
323
-    /**
324
-     * @return bool
325
-     */
326
-    public function isBot()
327
-    {
328
-        return $this->is_bot;
329
-    }
330
-
331
-
332
-    /**
333
-     * @param bool $is_bot
334
-     */
335
-    public function setIsBot($is_bot)
336
-    {
337
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
-    }
339
-
340
-
341
-    /**
342
-     * @return bool
343
-     */
344
-    public function isActivation()
345
-    {
346
-        return $this->request_type->isActivation();
347
-    }
348
-
349
-
350
-    /**
351
-     * @param $is_activation
352
-     * @return bool
353
-     */
354
-    public function setIsActivation($is_activation)
355
-    {
356
-        return $this->request_type->setIsActivation($is_activation);
357
-    }
358
-
359
-
360
-    /**
361
-     * @return bool
362
-     */
363
-    public function isAdmin()
364
-    {
365
-        return $this->request_type->isAdmin();
366
-    }
367
-
368
-
369
-    /**
370
-     * @return bool
371
-     */
372
-    public function isAdminAjax()
373
-    {
374
-        return $this->request_type->isAdminAjax();
375
-    }
376
-
377
-
378
-    /**
379
-     * @return bool
380
-     */
381
-    public function isAjax()
382
-    {
383
-        return $this->request_type->isAjax();
384
-    }
385
-
386
-
387
-    /**
388
-     * @return bool
389
-     */
390
-    public function isEeAjax()
391
-    {
392
-        return $this->request_type->isEeAjax();
393
-    }
394
-
395
-
396
-    /**
397
-     * @return bool
398
-     */
399
-    public function isOtherAjax()
400
-    {
401
-        return $this->request_type->isOtherAjax();
402
-    }
403
-
404
-
405
-    /**
406
-     * @return bool
407
-     */
408
-    public function isApi()
409
-    {
410
-        return $this->request_type->isApi();
411
-    }
412
-
413
-
414
-    /**
415
-     * @return bool
416
-     */
417
-    public function isCli()
418
-    {
419
-        return $this->request_type->isCli();
420
-    }
421
-
422
-
423
-    /**
424
-     * @return bool
425
-     */
426
-    public function isCron()
427
-    {
428
-        return $this->request_type->isCron();
429
-    }
430
-
431
-
432
-    /**
433
-     * @return bool
434
-     */
435
-    public function isFeed()
436
-    {
437
-        return $this->request_type->isFeed();
438
-    }
439
-
440
-
441
-    /**
442
-     * @return bool
443
-     */
444
-    public function isFrontend()
445
-    {
446
-        return $this->request_type->isFrontend();
447
-    }
448
-
449
-
450
-    /**
451
-     * @return bool
452
-     */
453
-    public function isFrontAjax()
454
-    {
455
-        return $this->request_type->isFrontAjax();
456
-    }
457
-
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isIframe()
463
-    {
464
-        return $this->request_type->isIframe();
465
-    }
466
-
467
-
468
-    /**
469
-     * @return bool
470
-     */
471
-    public function isWordPressApi()
472
-    {
473
-        return $this->request_type->isWordPressApi();
474
-    }
475
-
476
-
477
-    /**
478
-     * @return bool
479
-     */
480
-    public function isWordPressHeartbeat()
481
-    {
482
-        return $this->request_type->isWordPressHeartbeat();
483
-    }
484
-
485
-
486
-    /**
487
-     * @return bool
488
-     */
489
-    public function isWordPressScrape()
490
-    {
491
-        return $this->request_type->isWordPressScrape();
492
-    }
493
-
494
-
495
-    /**
496
-     * @return string
497
-     */
498
-    public function slug()
499
-    {
500
-        return $this->request_type->slug();
501
-    }
502
-
503
-
504
-    /**
505
-     * @return RequestTypeContextCheckerInterface
506
-     */
507
-    public function getRequestType()
508
-    {
509
-        return $this->request_type;
510
-    }
20
+	/**
21
+	 * $_COOKIE parameters
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $cookies;
26
+
27
+	/**
28
+	 * $_FILES parameters
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $files;
33
+
34
+	/**
35
+	 * true if current user appears to be some kind of bot
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $is_bot;
40
+
41
+	/**
42
+	 * @var RequestParams
43
+	 */
44
+	protected $request_params;
45
+
46
+	/**
47
+	 * @var RequestTypeContextCheckerInterface
48
+	 */
49
+	protected $request_type;
50
+
51
+	/**
52
+	 * @var ServerParams
53
+	 */
54
+	protected $server_params;
55
+
56
+
57
+	public function __construct(
58
+		RequestParams $request_params,
59
+		ServerParams $server_params,
60
+		array $cookies = [],
61
+		array $files = []
62
+	) {
63
+		$this->cookies = ! empty($cookies)
64
+			? $cookies
65
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
+		$this->files          = ! empty($files) ? $files : $_FILES;
67
+		$this->request_params = $request_params;
68
+		$this->server_params  = $server_params;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestTypeContextCheckerInterface $type
74
+	 */
75
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
+	{
77
+		$this->request_type = $type;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return array
83
+	 */
84
+	public function getParams()
85
+	{
86
+		return $this->request_params->getParams();
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	public function postParams()
94
+	{
95
+		return $this->request_params->postParams();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function cookieParams()
103
+	{
104
+		return $this->cookies;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function serverParams()
112
+	{
113
+		return $this->server_params->getAllServerParams();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $key
119
+	 * @param mixed|null $default
120
+	 * @return array|int|float|string
121
+	 */
122
+	public function getServerParam($key, $default = null)
123
+	{
124
+		return $this->server_params->getServerParam($key, $default);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                 $key
130
+	 * @param array|int|float|string $value
131
+	 * @return void
132
+	 */
133
+	public function setServerParam($key, $value)
134
+	{
135
+		$this->server_params->setServerParam($key, $value);
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param string $key
141
+	 * @return bool
142
+	 */
143
+	public function serverParamIsSet($key)
144
+	{
145
+		return $this->server_params->serverParamIsSet($key);
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function filesParams()
153
+	{
154
+		return $this->files;
155
+	}
156
+
157
+
158
+	/**
159
+	 * returns sanitized contents of $_REQUEST
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function requestParams()
164
+	{
165
+		return $this->request_params->requestParams();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param string     $key
171
+	 * @param mixed|null $value
172
+	 * @param bool       $override_ee
173
+	 * @return void
174
+	 */
175
+	public function setRequestParam($key, $value, $override_ee = false)
176
+	{
177
+		$this->request_params->setRequestParam($key, $value, $override_ee);
178
+	}
179
+
180
+
181
+	/**
182
+	 * merges the incoming array of parameters into the existing request parameters
183
+	 *
184
+	 * @param array $request_params
185
+	 * @return void
186
+	 * @since   $VID:$
187
+	 */
188
+	public function mergeRequestParams(array $request_params)
189
+	{
190
+		$this->request_params->mergeRequestParams($request_params);
191
+	}
192
+
193
+
194
+	/**
195
+	 * returns sanitized value for a request param if the given key exists
196
+	 *
197
+	 * @param string     $key
198
+	 * @param mixed|null $default
199
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
202
+	 * @return array|bool|float|int|string
203
+	 */
204
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
+	{
206
+		return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
+	}
208
+
209
+
210
+	/**
211
+	 * check if param exists
212
+	 *
213
+	 * @param string $key
214
+	 * @return bool
215
+	 */
216
+	public function requestParamIsSet($key)
217
+	{
218
+		return $this->request_params->requestParamIsSet($key);
219
+	}
220
+
221
+
222
+	/**
223
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
+	 * and return the sanitized value for the first match found
225
+	 * wildcards can be either of the following:
226
+	 *      ? to represent a single character of any type
227
+	 *      * to represent one or more characters of any type
228
+	 *
229
+	 * @param string     $pattern
230
+	 * @param mixed|null $default
231
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
234
+	 * @return array|bool|float|int|string
235
+	 */
236
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
+	{
238
+		return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
+	}
240
+
241
+
242
+	/**
243
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
244
+	 * wildcards can be either of the following:
245
+	 *      ? to represent a single character of any type
246
+	 *      * to represent one or more characters of any type
247
+	 * returns true if a match is found or false if not
248
+	 *
249
+	 * @param string $pattern
250
+	 * @return bool
251
+	 */
252
+	public function matches($pattern)
253
+	{
254
+		return $this->request_params->matches($pattern);
255
+	}
256
+
257
+
258
+	/**
259
+	 * remove param
260
+	 *
261
+	 * @param      $key
262
+	 * @param bool $unset_from_global_too
263
+	 */
264
+	public function unSetRequestParam($key, $unset_from_global_too = false)
265
+	{
266
+		$this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
+	}
268
+
269
+
270
+	/**
271
+	 * remove params
272
+	 *
273
+	 * @param array $keys
274
+	 * @param bool  $unset_from_global_too
275
+	 */
276
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
+	{
278
+		$this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return string
284
+	 */
285
+	public function ipAddress()
286
+	{
287
+		return $this->server_params->ipAddress();
288
+	}
289
+
290
+
291
+	/**
292
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
+	 *
294
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
+	 * @return string
298
+	 */
299
+	public function requestUri($relativeToWpRoot = false)
300
+	{
301
+		return $this->server_params->requestUri();
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function userAgent()
309
+	{
310
+		return $this->server_params->userAgent();
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $user_agent
316
+	 */
317
+	public function setUserAgent($user_agent = '')
318
+	{
319
+		$this->server_params->setUserAgent($user_agent);
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return bool
325
+	 */
326
+	public function isBot()
327
+	{
328
+		return $this->is_bot;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @param bool $is_bot
334
+	 */
335
+	public function setIsBot($is_bot)
336
+	{
337
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
+	}
339
+
340
+
341
+	/**
342
+	 * @return bool
343
+	 */
344
+	public function isActivation()
345
+	{
346
+		return $this->request_type->isActivation();
347
+	}
348
+
349
+
350
+	/**
351
+	 * @param $is_activation
352
+	 * @return bool
353
+	 */
354
+	public function setIsActivation($is_activation)
355
+	{
356
+		return $this->request_type->setIsActivation($is_activation);
357
+	}
358
+
359
+
360
+	/**
361
+	 * @return bool
362
+	 */
363
+	public function isAdmin()
364
+	{
365
+		return $this->request_type->isAdmin();
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return bool
371
+	 */
372
+	public function isAdminAjax()
373
+	{
374
+		return $this->request_type->isAdminAjax();
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return bool
380
+	 */
381
+	public function isAjax()
382
+	{
383
+		return $this->request_type->isAjax();
384
+	}
385
+
386
+
387
+	/**
388
+	 * @return bool
389
+	 */
390
+	public function isEeAjax()
391
+	{
392
+		return $this->request_type->isEeAjax();
393
+	}
394
+
395
+
396
+	/**
397
+	 * @return bool
398
+	 */
399
+	public function isOtherAjax()
400
+	{
401
+		return $this->request_type->isOtherAjax();
402
+	}
403
+
404
+
405
+	/**
406
+	 * @return bool
407
+	 */
408
+	public function isApi()
409
+	{
410
+		return $this->request_type->isApi();
411
+	}
412
+
413
+
414
+	/**
415
+	 * @return bool
416
+	 */
417
+	public function isCli()
418
+	{
419
+		return $this->request_type->isCli();
420
+	}
421
+
422
+
423
+	/**
424
+	 * @return bool
425
+	 */
426
+	public function isCron()
427
+	{
428
+		return $this->request_type->isCron();
429
+	}
430
+
431
+
432
+	/**
433
+	 * @return bool
434
+	 */
435
+	public function isFeed()
436
+	{
437
+		return $this->request_type->isFeed();
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return bool
443
+	 */
444
+	public function isFrontend()
445
+	{
446
+		return $this->request_type->isFrontend();
447
+	}
448
+
449
+
450
+	/**
451
+	 * @return bool
452
+	 */
453
+	public function isFrontAjax()
454
+	{
455
+		return $this->request_type->isFrontAjax();
456
+	}
457
+
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isIframe()
463
+	{
464
+		return $this->request_type->isIframe();
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return bool
470
+	 */
471
+	public function isWordPressApi()
472
+	{
473
+		return $this->request_type->isWordPressApi();
474
+	}
475
+
476
+
477
+	/**
478
+	 * @return bool
479
+	 */
480
+	public function isWordPressHeartbeat()
481
+	{
482
+		return $this->request_type->isWordPressHeartbeat();
483
+	}
484
+
485
+
486
+	/**
487
+	 * @return bool
488
+	 */
489
+	public function isWordPressScrape()
490
+	{
491
+		return $this->request_type->isWordPressScrape();
492
+	}
493
+
494
+
495
+	/**
496
+	 * @return string
497
+	 */
498
+	public function slug()
499
+	{
500
+		return $this->request_type->slug();
501
+	}
502
+
503
+
504
+	/**
505
+	 * @return RequestTypeContextCheckerInterface
506
+	 */
507
+	public function getRequestType()
508
+	{
509
+		return $this->request_type;
510
+	}
511 511
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -16,195 +16,195 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23 23
 
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function getParams();
29
-
30
-
31
-    /**
32
-     * @return array
33
-     */
34
-    public function postParams();
35
-
36
-
37
-    /**
38
-     * @return array
39
-     */
40
-    public function cookieParams();
41
-
42
-
43
-    /**
44
-     * @return array
45
-     */
46
-    public function serverParams();
47
-
48
-
49
-    /**
50
-     * @param string $key
51
-     * @param mixed|null $default
52
-     * @return array|int|float|string
53
-     */
54
-    public function getServerParam($key, $default = null);
55
-
56
-
57
-    /**
58
-     * @param string                 $key
59
-     * @param array|int|float|string $value
60
-     * @return void
61
-     */
62
-    public function setServerParam($key, $value);
63
-
64
-
65
-    /**
66
-     * @param string $key
67
-     * @return bool
68
-     */
69
-    public function serverParamIsSet($key);
70
-
71
-
72
-    /**
73
-     * @return array
74
-     */
75
-    public function filesParams();
76
-
77
-
78
-    /**
79
-     * returns sanitized contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams();
84
-
85
-
86
-    /**
87
-     * @param string $key
88
-     * @param string $value
89
-     * @param bool   $override_ee
90
-     * @return void
91
-     */
92
-    public function setRequestParam($key, $value, $override_ee = false);
93
-
94
-
95
-    /**
96
-     * returns   the value for a request param if the given key exists
97
-     *
98
-     * @param string     $key
99
-     * @param mixed|null $default
100
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
-     * @param string     $delimiter for CSV type strings that should be returned as an array
103
-     * @return array|bool|float|int|string
104
-     */
105
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
-
107
-
108
-    /**
109
-     * check if param exists
110
-     *
111
-     * @param string $key
112
-     * @return bool
113
-     */
114
-    public function requestParamIsSet($key);
115
-
116
-
117
-    /**
118
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
-     * and return the value for the first match found
120
-     * wildcards can be either of the following:
121
-     *      ? to represent a single character of any type
122
-     *      * to represent one or more characters of any type
123
-     *
124
-     * @param string     $pattern
125
-     * @param mixed|null $default
126
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
-     * @param string     $delimiter for CSV type strings that should be returned as an array
129
-     * @return array|bool|float|int|string
130
-     */
131
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
-
133
-
134
-    /**
135
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
136
-     * wildcards can be either of the following:
137
-     *      ? to represent a single character of any type
138
-     *      * to represent one or more characters of any type
139
-     * returns true if a match is found or false if not
140
-     *
141
-     * @param string $pattern
142
-     * @return false|int
143
-     */
144
-    public function matches($pattern);
145
-
146
-
147
-    /**
148
-     * remove param
149
-     *
150
-     * @param string $key
151
-     * @param bool   $unset_from_global_too
152
-     */
153
-    public function unSetRequestParam($key, $unset_from_global_too = false);
154
-
155
-
156
-    /**
157
-     * remove params
158
-     *
159
-     * @param array $keys
160
-     * @param bool  $unset_from_global_too
161
-     */
162
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public function ipAddress();
169
-
170
-
171
-    /**
172
-     * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
-     * @return string
174
-     */
175
-    public function requestUri($relativeToWpRoot = false);
176
-
177
-
178
-    /**
179
-     * @return string
180
-     */
181
-    public function userAgent();
182
-
183
-
184
-    /**
185
-     * @param string $user_agent
186
-     */
187
-    public function setUserAgent($user_agent = '');
188
-
189
-
190
-    /**
191
-     * @return bool
192
-     */
193
-    public function isBot();
194
-
195
-
196
-    /**
197
-     * @param bool $is_bot
198
-     */
199
-    public function setIsBot($is_bot);
200
-
201
-
202
-    /**
203
-     * merges the incoming array of parameters into the existing request parameters
204
-     *
205
-     * @param array $request_params
206
-     * @return mixed
207
-     * @since   $VID:$
208
-     */
209
-    public function mergeRequestParams(array $request_params);
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function getParams();
29
+
30
+
31
+	/**
32
+	 * @return array
33
+	 */
34
+	public function postParams();
35
+
36
+
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function cookieParams();
41
+
42
+
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function serverParams();
47
+
48
+
49
+	/**
50
+	 * @param string $key
51
+	 * @param mixed|null $default
52
+	 * @return array|int|float|string
53
+	 */
54
+	public function getServerParam($key, $default = null);
55
+
56
+
57
+	/**
58
+	 * @param string                 $key
59
+	 * @param array|int|float|string $value
60
+	 * @return void
61
+	 */
62
+	public function setServerParam($key, $value);
63
+
64
+
65
+	/**
66
+	 * @param string $key
67
+	 * @return bool
68
+	 */
69
+	public function serverParamIsSet($key);
70
+
71
+
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function filesParams();
76
+
77
+
78
+	/**
79
+	 * returns sanitized contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams();
84
+
85
+
86
+	/**
87
+	 * @param string $key
88
+	 * @param string $value
89
+	 * @param bool   $override_ee
90
+	 * @return void
91
+	 */
92
+	public function setRequestParam($key, $value, $override_ee = false);
93
+
94
+
95
+	/**
96
+	 * returns   the value for a request param if the given key exists
97
+	 *
98
+	 * @param string     $key
99
+	 * @param mixed|null $default
100
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
103
+	 * @return array|bool|float|int|string
104
+	 */
105
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
+
107
+
108
+	/**
109
+	 * check if param exists
110
+	 *
111
+	 * @param string $key
112
+	 * @return bool
113
+	 */
114
+	public function requestParamIsSet($key);
115
+
116
+
117
+	/**
118
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
+	 * and return the value for the first match found
120
+	 * wildcards can be either of the following:
121
+	 *      ? to represent a single character of any type
122
+	 *      * to represent one or more characters of any type
123
+	 *
124
+	 * @param string     $pattern
125
+	 * @param mixed|null $default
126
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
129
+	 * @return array|bool|float|int|string
130
+	 */
131
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
+
133
+
134
+	/**
135
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
136
+	 * wildcards can be either of the following:
137
+	 *      ? to represent a single character of any type
138
+	 *      * to represent one or more characters of any type
139
+	 * returns true if a match is found or false if not
140
+	 *
141
+	 * @param string $pattern
142
+	 * @return false|int
143
+	 */
144
+	public function matches($pattern);
145
+
146
+
147
+	/**
148
+	 * remove param
149
+	 *
150
+	 * @param string $key
151
+	 * @param bool   $unset_from_global_too
152
+	 */
153
+	public function unSetRequestParam($key, $unset_from_global_too = false);
154
+
155
+
156
+	/**
157
+	 * remove params
158
+	 *
159
+	 * @param array $keys
160
+	 * @param bool  $unset_from_global_too
161
+	 */
162
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public function ipAddress();
169
+
170
+
171
+	/**
172
+	 * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
+	 * @return string
174
+	 */
175
+	public function requestUri($relativeToWpRoot = false);
176
+
177
+
178
+	/**
179
+	 * @return string
180
+	 */
181
+	public function userAgent();
182
+
183
+
184
+	/**
185
+	 * @param string $user_agent
186
+	 */
187
+	public function setUserAgent($user_agent = '');
188
+
189
+
190
+	/**
191
+	 * @return bool
192
+	 */
193
+	public function isBot();
194
+
195
+
196
+	/**
197
+	 * @param bool $is_bot
198
+	 */
199
+	public function setIsBot($is_bot);
200
+
201
+
202
+	/**
203
+	 * merges the incoming array of parameters into the existing request parameters
204
+	 *
205
+	 * @param array $request_params
206
+	 * @return mixed
207
+	 * @since   $VID:$
208
+	 */
209
+	public function mergeRequestParams(array $request_params);
210 210
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.24.rc.003');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.24.rc.003');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.