Completed
Branch dev (f99e72)
by
unknown
12:52 queued 05:01
created
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3650 added lines, -3650 removed lines patch added patch discarded remove patch
@@ -19,2202 +19,2202 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
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
-    /**
38
-     * @var array
39
-     */
40
-    private static $_reg_status;
41
-
42
-    /**
43
-     * Form for displaying the custom questions for this registration.
44
-     * This gets used a few times throughout the request so its best to cache it
45
-     *
46
-     * @var EE_Registration_Custom_Questions_Form
47
-     */
48
-    protected $_reg_custom_questions_form;
49
-
50
-    /**
51
-     * @var EEM_Registration $registration_model
52
-     */
53
-    private $registration_model;
54
-
55
-    /**
56
-     * @var EEM_Attendee $attendee_model
57
-     */
58
-    private $attendee_model;
59
-
60
-    /**
61
-     * @var EEM_Event $event_model
62
-     */
63
-    private $event_model;
64
-
65
-    /**
66
-     * @var EEM_Status $status_model
67
-     */
68
-    private $status_model;
69
-
70
-
71
-    /**
72
-     * @param bool $routing
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws ReflectionException
78
-     */
79
-    public function __construct($routing = true)
80
-    {
81
-        parent::__construct($routing);
82
-        add_action('wp_loaded', [$this, 'wp_loaded']);
83
-    }
84
-
85
-
86
-    /**
87
-     * @return EEM_Registration
88
-     * @throws InvalidArgumentException
89
-     * @throws InvalidDataTypeException
90
-     * @throws InvalidInterfaceException
91
-     * @since 4.10.2.p
92
-     */
93
-    protected function getRegistrationModel()
94
-    {
95
-        if (! $this->registration_model instanceof EEM_Registration) {
96
-            $this->registration_model = $this->loader->getShared('EEM_Registration');
97
-        }
98
-        return $this->registration_model;
99
-    }
100
-
101
-
102
-    /**
103
-     * @return EEM_Attendee
104
-     * @throws InvalidArgumentException
105
-     * @throws InvalidDataTypeException
106
-     * @throws InvalidInterfaceException
107
-     * @since 4.10.2.p
108
-     */
109
-    protected function getAttendeeModel()
110
-    {
111
-        if (! $this->attendee_model instanceof EEM_Attendee) {
112
-            $this->attendee_model = $this->loader->getShared('EEM_Attendee');
113
-        }
114
-        return $this->attendee_model;
115
-    }
116
-
117
-
118
-    /**
119
-     * @return EEM_Event
120
-     * @throws InvalidArgumentException
121
-     * @throws InvalidDataTypeException
122
-     * @throws InvalidInterfaceException
123
-     * @since 4.10.2.p
124
-     */
125
-    protected function getEventModel()
126
-    {
127
-        if (! $this->event_model instanceof EEM_Event) {
128
-            $this->event_model = $this->loader->getShared('EEM_Event');
129
-        }
130
-        return $this->event_model;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return EEM_Status
136
-     * @throws InvalidArgumentException
137
-     * @throws InvalidDataTypeException
138
-     * @throws InvalidInterfaceException
139
-     * @since 4.10.2.p
140
-     */
141
-    protected function getStatusModel()
142
-    {
143
-        if (! $this->status_model instanceof EEM_Status) {
144
-            $this->status_model = $this->loader->getShared('EEM_Status');
145
-        }
146
-        return $this->status_model;
147
-    }
148
-
149
-
150
-    public function wp_loaded()
151
-    {
152
-        // when adding a new registration...
153
-        $action = $this->request->getRequestParam('action');
154
-        if ($action === 'new_registration') {
155
-            EE_System::do_not_cache();
156
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
157
-                // and it's NOT the attendee information reg step
158
-                // force cookie expiration by setting time to last week
159
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
160
-                // and update the global
161
-                $_COOKIE['ee_registration_added'] = 0;
162
-            }
163
-        }
164
-    }
165
-
166
-
167
-    protected function _init_page_props()
168
-    {
169
-        $this->page_slug        = REG_PG_SLUG;
170
-        $this->_admin_base_url  = REG_ADMIN_URL;
171
-        $this->_admin_base_path = REG_ADMIN;
172
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
173
-        $this->_cpt_routes      = [
174
-            'add_new_attendee' => 'espresso_attendees',
175
-            'edit_attendee'    => 'espresso_attendees',
176
-            'insert_attendee'  => 'espresso_attendees',
177
-            'update_attendee'  => 'espresso_attendees',
178
-        ];
179
-        $this->_cpt_model_names = [
180
-            'add_new_attendee' => 'EEM_Attendee',
181
-            'edit_attendee'    => 'EEM_Attendee',
182
-        ];
183
-        $this->_cpt_edit_routes = [
184
-            'espresso_attendees' => 'edit_attendee',
185
-        ];
186
-        $this->_pagenow_map     = [
187
-            'add_new_attendee' => 'post-new.php',
188
-            'edit_attendee'    => 'post.php',
189
-            'trash'            => 'post.php',
190
-        ];
191
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
192
-        // add filters so that the comment urls don't take users to a confusing 404 page
193
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
199
-     * @param WP_Comment $comment The current comment object.
200
-     * @return string
201
-     */
202
-    public function clear_comment_link($link, WP_Comment $comment)
203
-    {
204
-        // gotta make sure this only happens on this route
205
-        $post_type = get_post_type($comment->comment_post_ID);
206
-        if ($post_type === 'espresso_attendees') {
207
-            return '#commentsdiv';
208
-        }
209
-        return $link;
210
-    }
211
-
212
-
213
-    protected function _ajax_hooks()
214
-    {
215
-        // todo: all hooks for registrations ajax goes in here
216
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
217
-    }
218
-
219
-
220
-    protected function _define_page_props()
221
-    {
222
-        $this->_admin_page_title = $this->page_label;
223
-        $this->_labels           = [
224
-            'buttons'                      => [
225
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
226
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
227
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
228
-                'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
229
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
230
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
231
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
-            ],
234
-            'publishbox'                   => [
235
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
-            ],
238
-            'hide_add_button_on_cpt_route' => [
239
-                'edit_attendee' => true,
240
-            ],
241
-        ];
242
-    }
243
-
244
-
245
-    /**
246
-     * grab url requests and route them
247
-     *
248
-     * @return void
249
-     * @throws EE_Error
250
-     */
251
-    public function _set_page_routes()
252
-    {
253
-        $this->_get_registration_status_array();
254
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
-        $this->_page_routes = [
259
-            'default'                             => [
260
-                'func'       => '_registrations_overview_list_table',
261
-                'capability' => 'ee_read_registrations',
262
-            ],
263
-            'view_registration'                   => [
264
-                'func'       => '_registration_details',
265
-                'capability' => 'ee_read_registration',
266
-                'obj_id'     => $REG_ID,
267
-            ],
268
-            'edit_registration'                   => [
269
-                'func'               => '_update_attendee_registration_form',
270
-                'noheader'           => true,
271
-                'headers_sent_route' => 'view_registration',
272
-                'capability'         => 'ee_edit_registration',
273
-                'obj_id'             => $REG_ID,
274
-                '_REG_ID'            => $REG_ID,
275
-            ],
276
-            'trash_registrations'                 => [
277
-                'func'       => '_trash_or_restore_registrations',
278
-                'args'       => ['trash' => true],
279
-                'noheader'   => true,
280
-                'capability' => 'ee_delete_registrations',
281
-            ],
282
-            'restore_registrations'               => [
283
-                'func'       => '_trash_or_restore_registrations',
284
-                'args'       => ['trash' => false],
285
-                'noheader'   => true,
286
-                'capability' => 'ee_delete_registrations',
287
-            ],
288
-            'delete_registrations'                => [
289
-                'func'       => '_delete_registrations',
290
-                'noheader'   => true,
291
-                'capability' => 'ee_delete_registrations',
292
-            ],
293
-            'new_registration'                    => [
294
-                'func'       => 'new_registration',
295
-                'capability' => 'ee_edit_registrations',
296
-            ],
297
-            'process_reg_step'                    => [
298
-                'func'       => 'process_reg_step',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-            ],
302
-            'redirect_to_txn'                     => [
303
-                'func'       => 'redirect_to_txn',
304
-                'noheader'   => true,
305
-                'capability' => 'ee_edit_registrations',
306
-            ],
307
-            'change_reg_status'                   => [
308
-                'func'       => '_change_reg_status',
309
-                'noheader'   => true,
310
-                'capability' => 'ee_edit_registration',
311
-                'obj_id'     => $REG_ID,
312
-            ],
313
-            'approve_registration'                => [
314
-                'func'       => 'approve_registration',
315
-                'noheader'   => true,
316
-                'capability' => 'ee_edit_registration',
317
-                'obj_id'     => $REG_ID,
318
-            ],
319
-            'approve_and_notify_registration'     => [
320
-                'func'       => 'approve_registration',
321
-                'noheader'   => true,
322
-                'args'       => [true],
323
-                'capability' => 'ee_edit_registration',
324
-                'obj_id'     => $REG_ID,
325
-            ],
326
-            'approve_registrations'               => [
327
-                'func'       => 'bulk_action_on_registrations',
328
-                'noheader'   => true,
329
-                'capability' => 'ee_edit_registrations',
330
-                'args'       => ['approve'],
331
-            ],
332
-            'approve_and_notify_registrations'    => [
333
-                'func'       => 'bulk_action_on_registrations',
334
-                'noheader'   => true,
335
-                'capability' => 'ee_edit_registrations',
336
-                'args'       => ['approve', true],
337
-            ],
338
-            'decline_registration'                => [
339
-                'func'       => 'decline_registration',
340
-                'noheader'   => true,
341
-                'capability' => 'ee_edit_registration',
342
-                'obj_id'     => $REG_ID,
343
-            ],
344
-            'decline_and_notify_registration'     => [
345
-                'func'       => 'decline_registration',
346
-                'noheader'   => true,
347
-                'args'       => [true],
348
-                'capability' => 'ee_edit_registration',
349
-                'obj_id'     => $REG_ID,
350
-            ],
351
-            'decline_registrations'               => [
352
-                'func'       => 'bulk_action_on_registrations',
353
-                'noheader'   => true,
354
-                'capability' => 'ee_edit_registrations',
355
-                'args'       => ['decline'],
356
-            ],
357
-            'decline_and_notify_registrations'    => [
358
-                'func'       => 'bulk_action_on_registrations',
359
-                'noheader'   => true,
360
-                'capability' => 'ee_edit_registrations',
361
-                'args'       => ['decline', true],
362
-            ],
363
-            'pending_registration'                => [
364
-                'func'       => 'pending_registration',
365
-                'noheader'   => true,
366
-                'capability' => 'ee_edit_registration',
367
-                'obj_id'     => $REG_ID,
368
-            ],
369
-            'pending_and_notify_registration'     => [
370
-                'func'       => 'pending_registration',
371
-                'noheader'   => true,
372
-                'args'       => [true],
373
-                'capability' => 'ee_edit_registration',
374
-                'obj_id'     => $REG_ID,
375
-            ],
376
-            'pending_registrations'               => [
377
-                'func'       => 'bulk_action_on_registrations',
378
-                'noheader'   => true,
379
-                'capability' => 'ee_edit_registrations',
380
-                'args'       => ['pending'],
381
-            ],
382
-            'pending_and_notify_registrations'    => [
383
-                'func'       => 'bulk_action_on_registrations',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_registrations',
386
-                'args'       => ['pending', true],
387
-            ],
388
-            'no_approve_registration'             => [
389
-                'func'       => 'not_approve_registration',
390
-                'noheader'   => true,
391
-                'capability' => 'ee_edit_registration',
392
-                'obj_id'     => $REG_ID,
393
-            ],
394
-            'no_approve_and_notify_registration'  => [
395
-                'func'       => 'not_approve_registration',
396
-                'noheader'   => true,
397
-                'args'       => [true],
398
-                'capability' => 'ee_edit_registration',
399
-                'obj_id'     => $REG_ID,
400
-            ],
401
-            'no_approve_registrations'            => [
402
-                'func'       => 'bulk_action_on_registrations',
403
-                'noheader'   => true,
404
-                'capability' => 'ee_edit_registrations',
405
-                'args'       => ['not_approve'],
406
-            ],
407
-            'no_approve_and_notify_registrations' => [
408
-                'func'       => 'bulk_action_on_registrations',
409
-                'noheader'   => true,
410
-                'capability' => 'ee_edit_registrations',
411
-                'args'       => ['not_approve', true],
412
-            ],
413
-            'cancel_registration'                 => [
414
-                'func'       => 'cancel_registration',
415
-                'noheader'   => true,
416
-                'capability' => 'ee_edit_registration',
417
-                'obj_id'     => $REG_ID,
418
-            ],
419
-            'cancel_and_notify_registration'      => [
420
-                'func'       => 'cancel_registration',
421
-                'noheader'   => true,
422
-                'args'       => [true],
423
-                'capability' => 'ee_edit_registration',
424
-                'obj_id'     => $REG_ID,
425
-            ],
426
-            'cancel_registrations'                => [
427
-                'func'       => 'bulk_action_on_registrations',
428
-                'noheader'   => true,
429
-                'capability' => 'ee_edit_registrations',
430
-                'args'       => ['cancel'],
431
-            ],
432
-            'cancel_and_notify_registrations'     => [
433
-                'func'       => 'bulk_action_on_registrations',
434
-                'noheader'   => true,
435
-                'capability' => 'ee_edit_registrations',
436
-                'args'       => ['cancel', true],
437
-            ],
438
-            'wait_list_registration'              => [
439
-                'func'       => 'wait_list_registration',
440
-                'noheader'   => true,
441
-                'capability' => 'ee_edit_registration',
442
-                'obj_id'     => $REG_ID,
443
-            ],
444
-            'wait_list_and_notify_registration'   => [
445
-                'func'       => 'wait_list_registration',
446
-                'noheader'   => true,
447
-                'args'       => [true],
448
-                'capability' => 'ee_edit_registration',
449
-                'obj_id'     => $REG_ID,
450
-            ],
451
-            'contact_list'                        => [
452
-                'func'       => '_attendee_contact_list_table',
453
-                'capability' => 'ee_read_contacts',
454
-            ],
455
-            'add_new_attendee'                    => [
456
-                'func' => '_create_new_cpt_item',
457
-                'args' => [
458
-                    'new_attendee' => true,
459
-                    'capability'   => 'ee_edit_contacts',
460
-                ],
461
-            ],
462
-            'edit_attendee'                       => [
463
-                'func'       => '_edit_cpt_item',
464
-                'capability' => 'ee_edit_contacts',
465
-                'obj_id'     => $ATT_ID,
466
-            ],
467
-            'duplicate_attendee'                  => [
468
-                'func'       => '_duplicate_attendee',
469
-                'noheader'   => true,
470
-                'capability' => 'ee_edit_contacts',
471
-                'obj_id'     => $ATT_ID,
472
-            ],
473
-            'insert_attendee'                     => [
474
-                'func'       => '_insert_or_update_attendee',
475
-                'args'       => [
476
-                    'new_attendee' => true,
477
-                ],
478
-                'noheader'   => true,
479
-                'capability' => 'ee_edit_contacts',
480
-            ],
481
-            'update_attendee'                     => [
482
-                'func'       => '_insert_or_update_attendee',
483
-                'args'       => [
484
-                    'new_attendee' => false,
485
-                ],
486
-                'noheader'   => true,
487
-                'capability' => 'ee_edit_contacts',
488
-                'obj_id'     => $ATT_ID,
489
-            ],
490
-            'trash_attendees'                     => [
491
-                'func'       => '_trash_or_restore_attendees',
492
-                'args'       => [
493
-                    'trash' => 'true',
494
-                ],
495
-                'noheader'   => true,
496
-                'capability' => 'ee_delete_contacts',
497
-            ],
498
-            'trash_attendee'                      => [
499
-                'func'       => '_trash_or_restore_attendees',
500
-                'args'       => [
501
-                    'trash' => true,
502
-                ],
503
-                'noheader'   => true,
504
-                'capability' => 'ee_delete_contacts',
505
-                'obj_id'     => $ATT_ID,
506
-            ],
507
-            'restore_attendees'                   => [
508
-                'func'       => '_trash_or_restore_attendees',
509
-                'args'       => [
510
-                    'trash' => false,
511
-                ],
512
-                'noheader'   => true,
513
-                'capability' => 'ee_delete_contacts',
514
-                'obj_id'     => $ATT_ID,
515
-            ],
516
-            'resend_registration'                 => [
517
-                'func'       => '_resend_registration',
518
-                'noheader'   => true,
519
-                'capability' => 'ee_send_message',
520
-            ],
521
-            'registrations_report'                => [
522
-                'func'       => '_registrations_report',
523
-                'noheader'   => true,
524
-                'capability' => 'ee_read_registrations',
525
-            ],
526
-            'contact_list_export'                 => [
527
-                'func'       => '_contact_list_export',
528
-                'noheader'   => true,
529
-                'capability' => 'export',
530
-            ],
531
-            'contact_list_report'                 => [
532
-                'func'       => '_contact_list_report',
533
-                'noheader'   => true,
534
-                'capability' => 'ee_read_contacts',
535
-            ],
536
-        ];
537
-    }
538
-
539
-
540
-    protected function _set_page_config()
541
-    {
542
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
-        $this->_page_config = [
545
-            'default'           => [
546
-                'nav'           => [
547
-                    'label' => esc_html__('Overview', 'event_espresso'),
548
-                    'order' => 5,
549
-                ],
550
-                'help_tabs'     => [
551
-                    'registrations_overview_help_tab'                       => [
552
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
-                        'filename' => 'registrations_overview',
554
-                    ],
555
-                    'registrations_overview_table_column_headings_help_tab' => [
556
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
-                        'filename' => 'registrations_overview_table_column_headings',
558
-                    ],
559
-                    'registrations_overview_filters_help_tab'               => [
560
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
-                        'filename' => 'registrations_overview_filters',
562
-                    ],
563
-                    'registrations_overview_views_help_tab'                 => [
564
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
565
-                        'filename' => 'registrations_overview_views',
566
-                    ],
567
-                    'registrations_regoverview_other_help_tab'              => [
568
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
-                        'filename' => 'registrations_overview_other',
570
-                    ],
571
-                ],
572
-                'list_table'    => 'EE_Registrations_List_Table',
573
-                'require_nonce' => false,
574
-            ],
575
-            'view_registration' => [
576
-                'nav'           => [
577
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
578
-                    'order'      => 15,
579
-                    'url'        => $REG_ID
580
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
581
-                        : $this->_admin_base_url,
582
-                    'persistent' => false,
583
-                ],
584
-                'help_tabs'     => [
585
-                    'registrations_details_help_tab'                    => [
586
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
587
-                        'filename' => 'registrations_details',
588
-                    ],
589
-                    'registrations_details_table_help_tab'              => [
590
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
591
-                        'filename' => 'registrations_details_table',
592
-                    ],
593
-                    'registrations_details_form_answers_help_tab'       => [
594
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
595
-                        'filename' => 'registrations_details_form_answers',
596
-                    ],
597
-                    'registrations_details_registrant_details_help_tab' => [
598
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
599
-                        'filename' => 'registrations_details_registrant_details',
600
-                    ],
601
-                ],
602
-                'metaboxes'     => array_merge(
603
-                    $this->_default_espresso_metaboxes,
604
-                    ['_registration_details_metaboxes']
605
-                ),
606
-                'require_nonce' => false,
607
-            ],
608
-            'new_registration'  => [
609
-                'nav'           => [
610
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
611
-                    'url'        => '#',
612
-                    'order'      => 15,
613
-                    'persistent' => false,
614
-                ],
615
-                'metaboxes'     => $this->_default_espresso_metaboxes,
616
-                'labels'        => [
617
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
618
-                ],
619
-                'require_nonce' => false,
620
-            ],
621
-            'add_new_attendee'  => [
622
-                'nav'           => [
623
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
624
-                    'order'      => 15,
625
-                    'persistent' => false,
626
-                ],
627
-                'metaboxes'     => array_merge(
628
-                    $this->_default_espresso_metaboxes,
629
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
630
-                ),
631
-                'require_nonce' => false,
632
-            ],
633
-            'edit_attendee'     => [
634
-                'nav'           => [
635
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
636
-                    'order'      => 15,
637
-                    'persistent' => false,
638
-                    'url'        => $ATT_ID
639
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
640
-                        : $this->_admin_base_url,
641
-                ],
642
-                'metaboxes'     => array_merge(
643
-                    $this->_default_espresso_metaboxes,
644
-                    ['attendee_editor_metaboxes']
645
-                ),
646
-                'require_nonce' => false,
647
-            ],
648
-            'contact_list'      => [
649
-                'nav'           => [
650
-                    'label' => esc_html__('Contact List', 'event_espresso'),
651
-                    'order' => 20,
652
-                ],
653
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
654
-                'help_tabs'     => [
655
-                    'registrations_contact_list_help_tab'                       => [
656
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
657
-                        'filename' => 'registrations_contact_list',
658
-                    ],
659
-                    'registrations_contact-list_table_column_headings_help_tab' => [
660
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
661
-                        'filename' => 'registrations_contact_list_table_column_headings',
662
-                    ],
663
-                    'registrations_contact_list_views_help_tab'                 => [
664
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
665
-                        'filename' => 'registrations_contact_list_views',
666
-                    ],
667
-                    'registrations_contact_list_other_help_tab'                 => [
668
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
669
-                        'filename' => 'registrations_contact_list_other',
670
-                    ],
671
-                ],
672
-                'metaboxes'     => [],
673
-                'require_nonce' => false,
674
-            ],
675
-            // override default cpt routes
676
-            'create_new'        => '',
677
-            'edit'              => '',
678
-        ];
679
-    }
680
-
681
-
682
-    /**
683
-     * The below methods aren't used by this class currently
684
-     */
685
-    protected function _add_screen_options()
686
-    {
687
-    }
688
-
689
-
690
-    protected function _add_feature_pointers()
691
-    {
692
-    }
693
-
694
-
695
-    public function admin_init()
696
-    {
697
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
698
-            'click "Update Registration Questions" to save your changes',
699
-            'event_espresso'
700
-        );
701
-    }
702
-
703
-
704
-    public function admin_notices()
705
-    {
706
-    }
707
-
708
-
709
-    public function admin_footer_scripts()
710
-    {
711
-    }
712
-
713
-
714
-    /**
715
-     * get list of registration statuses
716
-     *
717
-     * @return void
718
-     * @throws EE_Error
719
-     */
720
-    private function _get_registration_status_array()
721
-    {
722
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
723
-    }
724
-
725
-
726
-    /**
727
-     * @throws InvalidArgumentException
728
-     * @throws InvalidDataTypeException
729
-     * @throws InvalidInterfaceException
730
-     * @since 4.10.2.p
731
-     */
732
-    protected function _add_screen_options_default()
733
-    {
734
-        $this->_per_page_screen_option();
735
-    }
736
-
737
-
738
-    /**
739
-     * @throws InvalidArgumentException
740
-     * @throws InvalidDataTypeException
741
-     * @throws InvalidInterfaceException
742
-     * @since 4.10.2.p
743
-     */
744
-    protected function _add_screen_options_contact_list()
745
-    {
746
-        $page_title              = $this->_admin_page_title;
747
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
748
-        $this->_per_page_screen_option();
749
-        $this->_admin_page_title = $page_title;
750
-    }
751
-
752
-
753
-    public function load_scripts_styles()
754
-    {
755
-        // style
756
-        wp_register_style(
757
-            'espresso_reg',
758
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
759
-            ['ee-admin-css'],
760
-            EVENT_ESPRESSO_VERSION
761
-        );
762
-        wp_enqueue_style('espresso_reg');
763
-        // script
764
-        wp_register_script(
765
-            'espresso_reg',
766
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
767
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
768
-            EVENT_ESPRESSO_VERSION,
769
-            true
770
-        );
771
-        wp_enqueue_script('espresso_reg');
772
-    }
773
-
774
-
775
-    /**
776
-     * @throws EE_Error
777
-     * @throws InvalidArgumentException
778
-     * @throws InvalidDataTypeException
779
-     * @throws InvalidInterfaceException
780
-     * @throws ReflectionException
781
-     * @since 4.10.2.p
782
-     */
783
-    public function load_scripts_styles_edit_attendee()
784
-    {
785
-        // stuff to only show up on our attendee edit details page.
786
-        $attendee_details_translations = [
787
-            'att_publish_text' => sprintf(
788
-            /* translators: The date and time */
789
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
790
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
791
-            ),
792
-        ];
793
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
794
-        wp_enqueue_script('jquery-validate');
795
-    }
796
-
797
-
798
-    /**
799
-     * @throws EE_Error
800
-     * @throws InvalidArgumentException
801
-     * @throws InvalidDataTypeException
802
-     * @throws InvalidInterfaceException
803
-     * @throws ReflectionException
804
-     * @since 4.10.2.p
805
-     */
806
-    public function load_scripts_styles_view_registration()
807
-    {
808
-        // styles
809
-        wp_enqueue_style('espresso-ui-theme');
810
-        // scripts
811
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
812
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
813
-    }
814
-
815
-
816
-    public function load_scripts_styles_contact_list()
817
-    {
818
-        wp_dequeue_style('espresso_reg');
819
-        wp_register_style(
820
-            'espresso_att',
821
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
822
-            ['ee-admin-css'],
823
-            EVENT_ESPRESSO_VERSION
824
-        );
825
-        wp_enqueue_style('espresso_att');
826
-    }
827
-
828
-
829
-    public function load_scripts_styles_new_registration()
830
-    {
831
-        wp_register_script(
832
-            'ee-spco-for-admin',
833
-            REG_ASSETS_URL . 'spco_for_admin.js',
834
-            ['underscore', 'jquery'],
835
-            EVENT_ESPRESSO_VERSION,
836
-            true
837
-        );
838
-        wp_enqueue_script('ee-spco-for-admin');
839
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
840
-        EE_Form_Section_Proper::wp_enqueue_scripts();
841
-        EED_Ticket_Selector::load_tckt_slctr_assets();
842
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
843
-    }
844
-
845
-
846
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
847
-    {
848
-        add_filter('FHEE_load_EE_messages', '__return_true');
849
-    }
850
-
851
-
852
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
853
-    {
854
-        add_filter('FHEE_load_EE_messages', '__return_true');
855
-    }
856
-
857
-
858
-    /**
859
-     * @throws EE_Error
860
-     * @throws InvalidArgumentException
861
-     * @throws InvalidDataTypeException
862
-     * @throws InvalidInterfaceException
863
-     * @throws ReflectionException
864
-     * @since 4.10.2.p
865
-     */
866
-    protected function _set_list_table_views_default()
867
-    {
868
-        // for notification related bulk actions we need to make sure only active messengers have an option.
869
-        EED_Messages::set_autoloaders();
870
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
871
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
872
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
873
-        // key= bulk_action_slug, value= message type.
874
-        $match_array = [
875
-            'approve_registrations'    => 'registration',
876
-            'decline_registrations'    => 'declined_registration',
877
-            'pending_registrations'    => 'pending_approval',
878
-            'no_approve_registrations' => 'not_approved_registration',
879
-            'cancel_registrations'     => 'cancelled_registration',
880
-        ];
881
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
882
-            'ee_send_message',
883
-            'batch_send_messages'
884
-        );
885
-        /** setup reg status bulk actions **/
886
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
887
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
888
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
889
-                'Approve and Notify Registrations',
890
-                'event_espresso'
891
-            );
892
-        }
893
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
894
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
895
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
896
-                'Decline and Notify Registrations',
897
-                'event_espresso'
898
-            );
899
-        }
900
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
901
-            'Set Registrations to Pending Payment',
902
-            'event_espresso'
903
-        );
904
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
905
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
906
-                'Set Registrations to Pending Payment and Notify',
907
-                'event_espresso'
908
-            );
909
-        }
910
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
911
-            'Set Registrations to Not Approved',
912
-            'event_espresso'
913
-        );
914
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
915
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
916
-                'Set Registrations to Not Approved and Notify',
917
-                'event_espresso'
918
-            );
919
-        }
920
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
921
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
922
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
923
-                'Cancel Registrations and Notify',
924
-                'event_espresso'
925
-            );
926
-        }
927
-        $def_reg_status_actions = apply_filters(
928
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
929
-            $def_reg_status_actions,
930
-            $active_mts,
931
-            $can_send
932
-        );
933
-
934
-        $this->_views = [
935
-            'all'   => [
936
-                'slug'        => 'all',
937
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
938
-                'count'       => 0,
939
-                'bulk_action' => array_merge(
940
-                    $def_reg_status_actions,
941
-                    [
942
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
943
-                    ]
944
-                ),
945
-            ],
946
-            'month' => [
947
-                'slug'        => 'month',
948
-                'label'       => esc_html__('This Month', 'event_espresso'),
949
-                'count'       => 0,
950
-                'bulk_action' => array_merge(
951
-                    $def_reg_status_actions,
952
-                    [
953
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
954
-                    ]
955
-                ),
956
-            ],
957
-            'today' => [
958
-                'slug'        => 'today',
959
-                'label'       => sprintf(
960
-                    esc_html__('Today - %s', 'event_espresso'),
961
-                    date('M d, Y', current_time('timestamp'))
962
-                ),
963
-                'count'       => 0,
964
-                'bulk_action' => array_merge(
965
-                    $def_reg_status_actions,
966
-                    [
967
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
968
-                    ]
969
-                ),
970
-            ],
971
-        ];
972
-        if (
973
-            EE_Registry::instance()->CAP->current_user_can(
974
-                'ee_delete_registrations',
975
-                'espresso_registrations_delete_registration'
976
-            )
977
-        ) {
978
-            $this->_views['incomplete'] = [
979
-                'slug'        => 'incomplete',
980
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
981
-                'count'       => 0,
982
-                'bulk_action' => [
983
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
984
-                ],
985
-            ];
986
-            $this->_views['trash']      = [
987
-                'slug'        => 'trash',
988
-                'label'       => esc_html__('Trash', 'event_espresso'),
989
-                'count'       => 0,
990
-                'bulk_action' => [
991
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
992
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
993
-                ],
994
-            ];
995
-        }
996
-    }
997
-
998
-
999
-    protected function _set_list_table_views_contact_list()
1000
-    {
1001
-        $this->_views = [
1002
-            'in_use' => [
1003
-                'slug'        => 'in_use',
1004
-                'label'       => esc_html__('In Use', 'event_espresso'),
1005
-                'count'       => 0,
1006
-                'bulk_action' => [
1007
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1008
-                ],
1009
-            ],
1010
-        ];
1011
-        if (
1012
-            EE_Registry::instance()->CAP->current_user_can(
1013
-                'ee_delete_contacts',
1014
-                'espresso_registrations_trash_attendees'
1015
-            )
1016
-        ) {
1017
-            $this->_views['trash'] = [
1018
-                'slug'        => 'trash',
1019
-                'label'       => esc_html__('Trash', 'event_espresso'),
1020
-                'count'       => 0,
1021
-                'bulk_action' => [
1022
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1023
-                ],
1024
-            ];
1025
-        }
1026
-    }
1027
-
1028
-
1029
-    /**
1030
-     * @return array
1031
-     * @throws EE_Error
1032
-     */
1033
-    protected function _registration_legend_items()
1034
-    {
1035
-        $fc_items = [
1036
-            'star-icon'        => [
1037
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1038
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1039
-            ],
1040
-            'view_details'     => [
1041
-                'class' => 'dashicons dashicons-clipboard',
1042
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1043
-            ],
1044
-            'edit_attendee'    => [
1045
-                'class' => 'dashicons dashicons-admin-users',
1046
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1047
-            ],
1048
-            'view_transaction' => [
1049
-                'class' => 'dashicons dashicons-cart',
1050
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1051
-            ],
1052
-            'view_invoice'     => [
1053
-                'class' => 'dashicons dashicons-media-spreadsheet',
1054
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1055
-            ],
1056
-        ];
1057
-        if (
1058
-            EE_Registry::instance()->CAP->current_user_can(
1059
-                'ee_send_message',
1060
-                'espresso_registrations_resend_registration'
1061
-            )
1062
-        ) {
1063
-            $fc_items['resend_registration'] = [
1064
-                'class' => 'dashicons dashicons-email-alt',
1065
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1066
-            ];
1067
-        } else {
1068
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1069
-        }
1070
-        if (
1071
-            EE_Registry::instance()->CAP->current_user_can(
1072
-                'ee_read_global_messages',
1073
-                'view_filtered_messages'
1074
-            )
1075
-        ) {
1076
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1077
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1078
-                $fc_items['view_related_messages'] = [
1079
-                    'class' => $related_for_icon['css_class'],
1080
-                    'desc'  => $related_for_icon['label'],
1081
-                ];
1082
-            }
1083
-        }
1084
-        $sc_items = [
1085
-            'approved_status'   => [
1086
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1087
-                'desc'  => EEH_Template::pretty_status(
1088
-                    EEM_Registration::status_id_approved,
1089
-                    false,
1090
-                    'sentence'
1091
-                ),
1092
-            ],
1093
-            'pending_status'    => [
1094
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1095
-                'desc'  => EEH_Template::pretty_status(
1096
-                    EEM_Registration::status_id_pending_payment,
1097
-                    false,
1098
-                    'sentence'
1099
-                ),
1100
-            ],
1101
-            'wait_list'         => [
1102
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1103
-                'desc'  => EEH_Template::pretty_status(
1104
-                    EEM_Registration::status_id_wait_list,
1105
-                    false,
1106
-                    'sentence'
1107
-                ),
1108
-            ],
1109
-            'incomplete_status' => [
1110
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1111
-                'desc'  => EEH_Template::pretty_status(
1112
-                    EEM_Registration::status_id_incomplete,
1113
-                    false,
1114
-                    'sentence'
1115
-                ),
1116
-            ],
1117
-            'not_approved'      => [
1118
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1119
-                'desc'  => EEH_Template::pretty_status(
1120
-                    EEM_Registration::status_id_not_approved,
1121
-                    false,
1122
-                    'sentence'
1123
-                ),
1124
-            ],
1125
-            'declined_status'   => [
1126
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1127
-                'desc'  => EEH_Template::pretty_status(
1128
-                    EEM_Registration::status_id_declined,
1129
-                    false,
1130
-                    'sentence'
1131
-                ),
1132
-            ],
1133
-            'cancelled_status'  => [
1134
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1135
-                'desc'  => EEH_Template::pretty_status(
1136
-                    EEM_Registration::status_id_cancelled,
1137
-                    false,
1138
-                    'sentence'
1139
-                ),
1140
-            ],
1141
-        ];
1142
-        return array_merge($fc_items, $sc_items);
1143
-    }
1144
-
1145
-
1146
-
1147
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1148
-
1149
-
1150
-    /**
1151
-     * @throws DomainException
1152
-     * @throws EE_Error
1153
-     * @throws InvalidArgumentException
1154
-     * @throws InvalidDataTypeException
1155
-     * @throws InvalidInterfaceException
1156
-     */
1157
-    protected function _registrations_overview_list_table()
1158
-    {
1159
-        $this->appendAddNewRegistrationButtonToPageTitle();
1160
-        $header_text                  = '';
1161
-        $admin_page_header_decorators = [
1162
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1163
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1164
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1165
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1166
-        ];
1167
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1168
-            $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1169
-            $header_text = $filter_header_decorator->getHeaderText($header_text);
1170
-        }
1171
-        $this->_template_args['admin_page_header'] = $header_text;
1172
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1173
-        $this->display_admin_list_table_page_with_no_sidebar();
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     * @throws EE_Error
1179
-     * @throws InvalidArgumentException
1180
-     * @throws InvalidDataTypeException
1181
-     * @throws InvalidInterfaceException
1182
-     */
1183
-    private function appendAddNewRegistrationButtonToPageTitle()
1184
-    {
1185
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1186
-        if (
1187
-            $EVT_ID
1188
-            && EE_Registry::instance()->CAP->current_user_can(
1189
-                'ee_edit_registrations',
1190
-                'espresso_registrations_new_registration',
1191
-                $EVT_ID
1192
-            )
1193
-        ) {
1194
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1195
-                'new_registration',
1196
-                'add-registrant',
1197
-                ['event_id' => $EVT_ID],
1198
-                'add-new-h2'
1199
-            );
1200
-        }
1201
-    }
1202
-
1203
-
1204
-    /**
1205
-     * This sets the _registration property for the registration details screen
1206
-     *
1207
-     * @return void
1208
-     * @throws EE_Error
1209
-     * @throws InvalidArgumentException
1210
-     * @throws InvalidDataTypeException
1211
-     * @throws InvalidInterfaceException
1212
-     */
1213
-    private function _set_registration_object()
1214
-    {
1215
-        // get out if we've already set the object
1216
-        if ($this->_registration instanceof EE_Registration) {
1217
-            return;
1218
-        }
1219
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1220
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1221
-            return;
1222
-        }
1223
-        $error_msg = sprintf(
1224
-            esc_html__(
1225
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1226
-                'event_espresso'
1227
-            ),
1228
-            $REG_ID
1229
-        );
1230
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1231
-        $this->_registration = null;
1232
-    }
1233
-
1234
-
1235
-    /**
1236
-     * Used to retrieve registrations for the list table.
1237
-     *
1238
-     * @param int  $per_page
1239
-     * @param bool $count
1240
-     * @param bool $this_month
1241
-     * @param bool $today
1242
-     * @return EE_Registration[]|int
1243
-     * @throws EE_Error
1244
-     * @throws InvalidArgumentException
1245
-     * @throws InvalidDataTypeException
1246
-     * @throws InvalidInterfaceException
1247
-     */
1248
-    public function get_registrations(
1249
-        $per_page = 10,
1250
-        $count = false,
1251
-        $this_month = false,
1252
-        $today = false
1253
-    ) {
1254
-        if ($this_month) {
1255
-            $this->request->setRequestParam('status', 'month');
1256
-        }
1257
-        if ($today) {
1258
-            $this->request->setRequestParam('status', 'today');
1259
-        }
1260
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1261
-        /**
1262
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1263
-         *
1264
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1265
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1266
-         *                      or if you have the development copy of EE you can view this at the path:
1267
-         *                      /docs/G--Model-System/model-query-params.md
1268
-         */
1269
-        $query_params['group_by'] = '';
1270
-
1271
-        return $count
1272
-            ? $this->getRegistrationModel()->count($query_params)
1273
-            /** @type EE_Registration[] */
1274
-            : $this->getRegistrationModel()->get_all($query_params);
1275
-    }
1276
-
1277
-
1278
-    /**
1279
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1280
-     * Note: this listens to values on the request for some of the query parameters.
1281
-     *
1282
-     * @param array $request
1283
-     * @param int   $per_page
1284
-     * @param bool  $count
1285
-     * @return array
1286
-     * @throws EE_Error
1287
-     * @throws InvalidArgumentException
1288
-     * @throws InvalidDataTypeException
1289
-     * @throws InvalidInterfaceException
1290
-     */
1291
-    protected function _get_registration_query_parameters(
1292
-        $request = [],
1293
-        $per_page = 10,
1294
-        $count = false
1295
-    ) {
1296
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1297
-        $list_table_query_builder = $this->loader->getNew(
1298
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1299
-            [null, null, $request]
1300
-        );
1301
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1302
-    }
1303
-
1304
-
1305
-    public function get_registration_status_array()
1306
-    {
1307
-        return self::$_reg_status;
1308
-    }
1309
-
1310
-
1311
-
1312
-
1313
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1314
-    /**
1315
-     * generates HTML for the View Registration Details Admin page
1316
-     *
1317
-     * @return void
1318
-     * @throws DomainException
1319
-     * @throws EE_Error
1320
-     * @throws InvalidArgumentException
1321
-     * @throws InvalidDataTypeException
1322
-     * @throws InvalidInterfaceException
1323
-     * @throws EntityNotFoundException
1324
-     * @throws ReflectionException
1325
-     */
1326
-    protected function _registration_details()
1327
-    {
1328
-        $this->_template_args = [];
1329
-        $this->_set_registration_object();
1330
-        if (is_object($this->_registration)) {
1331
-            $transaction                                   = $this->_registration->transaction()
1332
-                ? $this->_registration->transaction()
1333
-                : EE_Transaction::new_instance();
1334
-            $this->_session                                = $transaction->session_data();
1335
-            $event_id                                      = $this->_registration->event_ID();
1336
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1337
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1338
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1339
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1340
-            $this->_template_args['grand_total']           = $transaction->total();
1341
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1342
-            // link back to overview
1343
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1344
-            $this->_template_args['registration']                = $this->_registration;
1345
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1346
-                [
1347
-                    'action'   => 'default',
1348
-                    'event_id' => $event_id,
1349
-                ],
1350
-                REG_ADMIN_URL
1351
-            );
1352
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1353
-                [
1354
-                    'action' => 'default',
1355
-                    'EVT_ID' => $event_id,
1356
-                    'page'   => 'espresso_transactions',
1357
-                ],
1358
-                admin_url('admin.php')
1359
-            );
1360
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1361
-                [
1362
-                    'page'   => 'espresso_events',
1363
-                    'action' => 'edit',
1364
-                    'post'   => $event_id,
1365
-                ],
1366
-                admin_url('admin.php')
1367
-            );
1368
-            // next and previous links
1369
-            $next_reg                                      = $this->_registration->next(
1370
-                null,
1371
-                [],
1372
-                'REG_ID'
1373
-            );
1374
-            $this->_template_args['next_registration']     = $next_reg
1375
-                ? $this->_next_link(
1376
-                    EE_Admin_Page::add_query_args_and_nonce(
1377
-                        [
1378
-                            'action'  => 'view_registration',
1379
-                            '_REG_ID' => $next_reg['REG_ID'],
1380
-                        ],
1381
-                        REG_ADMIN_URL
1382
-                    ),
1383
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1384
-                )
1385
-                : '';
1386
-            $previous_reg                                  = $this->_registration->previous(
1387
-                null,
1388
-                [],
1389
-                'REG_ID'
1390
-            );
1391
-            $this->_template_args['previous_registration'] = $previous_reg
1392
-                ? $this->_previous_link(
1393
-                    EE_Admin_Page::add_query_args_and_nonce(
1394
-                        [
1395
-                            'action'  => 'view_registration',
1396
-                            '_REG_ID' => $previous_reg['REG_ID'],
1397
-                        ],
1398
-                        REG_ADMIN_URL
1399
-                    ),
1400
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1401
-                )
1402
-                : '';
1403
-            // grab header
1404
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1405
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1406
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1407
-                $template_path,
1408
-                $this->_template_args,
1409
-                true
1410
-            );
1411
-        } else {
1412
-            $this->_template_args['admin_page_header'] = '';
1413
-            $this->_display_espresso_notices();
1414
-        }
1415
-        // the details template wrapper
1416
-        $this->display_admin_page_with_sidebar();
1417
-    }
1418
-
1419
-
1420
-    /**
1421
-     * @throws EE_Error
1422
-     * @throws InvalidArgumentException
1423
-     * @throws InvalidDataTypeException
1424
-     * @throws InvalidInterfaceException
1425
-     * @throws ReflectionException
1426
-     * @since 4.10.2.p
1427
-     */
1428
-    protected function _registration_details_metaboxes()
1429
-    {
1430
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1431
-        $this->_set_registration_object();
1432
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1433
-        $this->addMetaBox(
1434
-            'edit-reg-status-mbox',
1435
-            esc_html__('Registration Status', 'event_espresso'),
1436
-            [$this, 'set_reg_status_buttons_metabox'],
1437
-            $this->_wp_page_slug
1438
-        );
1439
-        $this->addMetaBox(
1440
-            'edit-reg-details-mbox',
1441
-            '<span>' . esc_html__('Registration Details', 'event_espresso')
1442
-            . '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1443
-            [$this, '_reg_details_meta_box'],
1444
-            $this->_wp_page_slug
1445
-        );
1446
-        if (
1447
-            $attendee instanceof EE_Attendee
1448
-            && EE_Registry::instance()->CAP->current_user_can(
1449
-                'ee_read_registration',
1450
-                'edit-reg-questions-mbox',
1451
-                $this->_registration->ID()
1452
-            )
1453
-        ) {
1454
-            $this->addMetaBox(
1455
-                'edit-reg-questions-mbox',
1456
-                esc_html__('Registration Form Answers', 'event_espresso'),
1457
-                [$this, '_reg_questions_meta_box'],
1458
-                $this->_wp_page_slug
1459
-            );
1460
-        }
1461
-        $this->addMetaBox(
1462
-            'edit-reg-registrant-mbox',
1463
-            esc_html__('Contact Details', 'event_espresso'),
1464
-            [$this, '_reg_registrant_side_meta_box'],
1465
-            $this->_wp_page_slug,
1466
-            'side'
1467
-        );
1468
-        if ($this->_registration->group_size() > 1) {
1469
-            $this->addMetaBox(
1470
-                'edit-reg-attendees-mbox',
1471
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1472
-                [$this, '_reg_attendees_meta_box'],
1473
-                $this->_wp_page_slug
1474
-            );
1475
-        }
1476
-    }
1477
-
1478
-
1479
-    /**
1480
-     * set_reg_status_buttons_metabox
1481
-     *
1482
-     * @return void
1483
-     * @throws EE_Error
1484
-     * @throws EntityNotFoundException
1485
-     * @throws InvalidArgumentException
1486
-     * @throws InvalidDataTypeException
1487
-     * @throws InvalidInterfaceException
1488
-     * @throws ReflectionException
1489
-     */
1490
-    public function set_reg_status_buttons_metabox()
1491
-    {
1492
-        $this->_set_registration_object();
1493
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1494
-        $output                 = $change_reg_status_form->form_open(
1495
-            self::add_query_args_and_nonce(
1496
-                [
1497
-                    'action' => 'change_reg_status',
1498
-                ],
1499
-                REG_ADMIN_URL
1500
-            )
1501
-        );
1502
-        $output                 .= $change_reg_status_form->get_html();
1503
-        $output                 .= $change_reg_status_form->form_close();
1504
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1505
-    }
1506
-
1507
-
1508
-    /**
1509
-     * @return EE_Form_Section_Proper
1510
-     * @throws EE_Error
1511
-     * @throws InvalidArgumentException
1512
-     * @throws InvalidDataTypeException
1513
-     * @throws InvalidInterfaceException
1514
-     * @throws EntityNotFoundException
1515
-     * @throws ReflectionException
1516
-     */
1517
-    protected function _generate_reg_status_change_form()
1518
-    {
1519
-        $reg_status_change_form_array = [
1520
-            'name'            => 'reg_status_change_form',
1521
-            'html_id'         => 'reg-status-change-form',
1522
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1523
-            'subsections'     => [
1524
-                'return'         => new EE_Hidden_Input(
1525
-                    [
1526
-                        'name'    => 'return',
1527
-                        'default' => 'view_registration',
1528
-                    ]
1529
-                ),
1530
-                'REG_ID'         => new EE_Hidden_Input(
1531
-                    [
1532
-                        'name'    => 'REG_ID',
1533
-                        'default' => $this->_registration->ID(),
1534
-                    ]
1535
-                ),
1536
-            ],
1537
-        ];
1538
-        if (
1539
-            EE_Registry::instance()->CAP->current_user_can(
1540
-                'ee_edit_registration',
1541
-                'toggle_registration_status',
1542
-                $this->_registration->ID()
1543
-            )
1544
-        ) {
1545
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1546
-                $this->_get_reg_statuses(),
1547
-                [
1548
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1549
-                    'default'         => $this->_registration->status_ID(),
1550
-                ]
1551
-            );
1552
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1553
-                [
1554
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1555
-                    'default'         => false,
1556
-                    'html_help_text'  => esc_html__(
1557
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1558
-                        'event_espresso'
1559
-                    ),
1560
-                ]
1561
-            );
1562
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1563
-                [
1564
-                    'html_class'      => 'button--primary',
1565
-                    'html_label_text' => '&nbsp;',
1566
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1567
-                ]
1568
-            );
1569
-        }
1570
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1571
-    }
1572
-
1573
-
1574
-    /**
1575
-     * Returns an array of all the buttons for the various statuses and switch status actions
1576
-     *
1577
-     * @return array
1578
-     * @throws EE_Error
1579
-     * @throws InvalidArgumentException
1580
-     * @throws InvalidDataTypeException
1581
-     * @throws InvalidInterfaceException
1582
-     * @throws EntityNotFoundException
1583
-     */
1584
-    protected function _get_reg_statuses()
1585
-    {
1586
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1587
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1588
-        // get current reg status
1589
-        $current_status = $this->_registration->status_ID();
1590
-        // is registration for free event? This will determine whether to display the pending payment option
1591
-        if (
1592
-            $current_status !== EEM_Registration::status_id_pending_payment
1593
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1594
-        ) {
1595
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1596
-        }
1597
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1598
-    }
1599
-
1600
-
1601
-    /**
1602
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1603
-     *
1604
-     * @param bool $status REG status given for changing registrations to.
1605
-     * @param bool $notify Whether to send messages notifications or not.
1606
-     * @return array (array with reg_id(s) updated and whether update was successful.
1607
-     * @throws DomainException
1608
-     * @throws EE_Error
1609
-     * @throws EntityNotFoundException
1610
-     * @throws InvalidArgumentException
1611
-     * @throws InvalidDataTypeException
1612
-     * @throws InvalidInterfaceException
1613
-     * @throws ReflectionException
1614
-     * @throws RuntimeException
1615
-     */
1616
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1617
-    {
1618
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1619
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1620
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1621
-
1622
-        // sanitize $REG_IDs
1623
-        $REG_IDs = array_map('absint', $REG_IDs);
1624
-        // and remove empty entries
1625
-        $REG_IDs = array_filter($REG_IDs);
1626
-
1627
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1628
-
1629
-        /**
1630
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1631
-         * Currently this value is used downstream by the _process_resend_registration method.
1632
-         *
1633
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1634
-         * @param bool                     $status           The status registrations were changed to.
1635
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1636
-         * @param Registrations_Admin_Page $admin_page_object
1637
-         */
1638
-        $REG_ID = apply_filters(
1639
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1640
-            $result['REG_ID'],
1641
-            $status,
1642
-            $result['success'],
1643
-            $this
1644
-        );
1645
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1646
-
1647
-        // notify?
1648
-        if (
1649
-            $notify
1650
-            && $result['success']
1651
-            && ! empty($REG_ID)
1652
-            && EE_Registry::instance()->CAP->current_user_can(
1653
-                'ee_send_message',
1654
-                'espresso_registrations_resend_registration'
1655
-            )
1656
-        ) {
1657
-            $this->_process_resend_registration();
1658
-        }
1659
-        return $result;
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1665
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1666
-     *
1667
-     * @param array  $REG_IDs
1668
-     * @param string $status
1669
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1670
-     *                       slug sent with setting the registration status.
1671
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1672
-     * @throws EE_Error
1673
-     * @throws InvalidArgumentException
1674
-     * @throws InvalidDataTypeException
1675
-     * @throws InvalidInterfaceException
1676
-     * @throws ReflectionException
1677
-     * @throws RuntimeException
1678
-     * @throws EntityNotFoundException
1679
-     * @throws DomainException
1680
-     */
1681
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1682
-    {
1683
-        $success = false;
1684
-        // typecast $REG_IDs
1685
-        $REG_IDs = (array) $REG_IDs;
1686
-        if (! empty($REG_IDs)) {
1687
-            $success = true;
1688
-            // set default status if none is passed
1689
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1690
-            $status_context = $notify
1691
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1692
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1693
-            // loop through REG_ID's and change status
1694
-            foreach ($REG_IDs as $REG_ID) {
1695
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1696
-                if ($registration instanceof EE_Registration) {
1697
-                    $registration->set_status(
1698
-                        $status,
1699
-                        false,
1700
-                        new Context(
1701
-                            $status_context,
1702
-                            esc_html__(
1703
-                                'Manually triggered status change on a Registration Admin Page route.',
1704
-                                'event_espresso'
1705
-                            )
1706
-                        )
1707
-                    );
1708
-                    $result = $registration->save();
1709
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1710
-                    $success = $result !== false ? $success : false;
1711
-                }
1712
-            }
1713
-        }
1714
-
1715
-        // return $success and processed registrations
1716
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1717
-    }
1718
-
1719
-
1720
-    /**
1721
-     * Common logic for setting up success message and redirecting to appropriate route
1722
-     *
1723
-     * @param string $STS_ID status id for the registration changed to
1724
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1725
-     * @return void
1726
-     * @throws DomainException
1727
-     * @throws EE_Error
1728
-     * @throws EntityNotFoundException
1729
-     * @throws InvalidArgumentException
1730
-     * @throws InvalidDataTypeException
1731
-     * @throws InvalidInterfaceException
1732
-     * @throws ReflectionException
1733
-     * @throws RuntimeException
1734
-     */
1735
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1736
-    {
1737
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1738
-            : ['success' => false];
1739
-        $success = isset($result['success']) && $result['success'];
1740
-        // setup success message
1741
-        if ($success) {
1742
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1743
-                $msg = sprintf(
1744
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1745
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1746
-                );
1747
-            } else {
1748
-                $msg = sprintf(
1749
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1750
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1751
-                );
1752
-            }
1753
-            EE_Error::add_success($msg);
1754
-        } else {
1755
-            EE_Error::add_error(
1756
-                esc_html__(
1757
-                    'Something went wrong, and the status was not changed',
1758
-                    'event_espresso'
1759
-                ),
1760
-                __FILE__,
1761
-                __LINE__,
1762
-                __FUNCTION__
1763
-            );
1764
-        }
1765
-        $return = $this->request->getRequestParam('return');
1766
-        $route  = $return === 'view_registration'
1767
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1768
-            : ['action' => 'default'];
1769
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1770
-        $this->_redirect_after_action($success, '', '', $route, true);
1771
-    }
1772
-
1773
-
1774
-    /**
1775
-     * incoming reg status change from reg details page.
1776
-     *
1777
-     * @return void
1778
-     * @throws EE_Error
1779
-     * @throws EntityNotFoundException
1780
-     * @throws InvalidArgumentException
1781
-     * @throws InvalidDataTypeException
1782
-     * @throws InvalidInterfaceException
1783
-     * @throws ReflectionException
1784
-     * @throws RuntimeException
1785
-     * @throws DomainException
1786
-     */
1787
-    protected function _change_reg_status()
1788
-    {
1789
-        $this->request->setRequestParam('return', 'view_registration');
1790
-        // set notify based on whether the send notifications toggle is set or not
1791
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1792
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1793
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1794
-        switch ($reg_status) {
1795
-            case EEM_Registration::status_id_approved:
1796
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1797
-                $this->approve_registration($notify);
1798
-                break;
1799
-            case EEM_Registration::status_id_pending_payment:
1800
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1801
-                $this->pending_registration($notify);
1802
-                break;
1803
-            case EEM_Registration::status_id_not_approved:
1804
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1805
-                $this->not_approve_registration($notify);
1806
-                break;
1807
-            case EEM_Registration::status_id_declined:
1808
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1809
-                $this->decline_registration($notify);
1810
-                break;
1811
-            case EEM_Registration::status_id_cancelled:
1812
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1813
-                $this->cancel_registration($notify);
1814
-                break;
1815
-            case EEM_Registration::status_id_wait_list:
1816
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1817
-                $this->wait_list_registration($notify);
1818
-                break;
1819
-            case EEM_Registration::status_id_incomplete:
1820
-            default:
1821
-                $this->request->unSetRequestParam('return');
1822
-                $this->_reg_status_change_return('');
1823
-                break;
1824
-        }
1825
-    }
1826
-
1827
-
1828
-    /**
1829
-     * Callback for bulk action routes.
1830
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1831
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1832
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1833
-     * when an action is happening on just a single registration).
1834
-     *
1835
-     * @param      $action
1836
-     * @param bool $notify
1837
-     */
1838
-    protected function bulk_action_on_registrations($action, $notify = false)
1839
-    {
1840
-        do_action(
1841
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1842
-            $this,
1843
-            $action,
1844
-            $notify
1845
-        );
1846
-        $method = $action . '_registration';
1847
-        if (method_exists($this, $method)) {
1848
-            $this->$method($notify);
1849
-        }
1850
-    }
1851
-
1852
-
1853
-    /**
1854
-     * approve_registration
1855
-     *
1856
-     * @param bool $notify whether or not to notify the registrant about their approval.
1857
-     * @return void
1858
-     * @throws EE_Error
1859
-     * @throws EntityNotFoundException
1860
-     * @throws InvalidArgumentException
1861
-     * @throws InvalidDataTypeException
1862
-     * @throws InvalidInterfaceException
1863
-     * @throws ReflectionException
1864
-     * @throws RuntimeException
1865
-     * @throws DomainException
1866
-     */
1867
-    protected function approve_registration($notify = false)
1868
-    {
1869
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1870
-    }
1871
-
1872
-
1873
-    /**
1874
-     * decline_registration
1875
-     *
1876
-     * @param bool $notify whether or not to notify the registrant about their status change.
1877
-     * @return void
1878
-     * @throws EE_Error
1879
-     * @throws EntityNotFoundException
1880
-     * @throws InvalidArgumentException
1881
-     * @throws InvalidDataTypeException
1882
-     * @throws InvalidInterfaceException
1883
-     * @throws ReflectionException
1884
-     * @throws RuntimeException
1885
-     * @throws DomainException
1886
-     */
1887
-    protected function decline_registration($notify = false)
1888
-    {
1889
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1890
-    }
1891
-
1892
-
1893
-    /**
1894
-     * cancel_registration
1895
-     *
1896
-     * @param bool $notify whether or not to notify the registrant about their status change.
1897
-     * @return void
1898
-     * @throws EE_Error
1899
-     * @throws EntityNotFoundException
1900
-     * @throws InvalidArgumentException
1901
-     * @throws InvalidDataTypeException
1902
-     * @throws InvalidInterfaceException
1903
-     * @throws ReflectionException
1904
-     * @throws RuntimeException
1905
-     * @throws DomainException
1906
-     */
1907
-    protected function cancel_registration($notify = false)
1908
-    {
1909
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1910
-    }
1911
-
1912
-
1913
-    /**
1914
-     * not_approve_registration
1915
-     *
1916
-     * @param bool $notify whether or not to notify the registrant about their status change.
1917
-     * @return void
1918
-     * @throws EE_Error
1919
-     * @throws EntityNotFoundException
1920
-     * @throws InvalidArgumentException
1921
-     * @throws InvalidDataTypeException
1922
-     * @throws InvalidInterfaceException
1923
-     * @throws ReflectionException
1924
-     * @throws RuntimeException
1925
-     * @throws DomainException
1926
-     */
1927
-    protected function not_approve_registration($notify = false)
1928
-    {
1929
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1930
-    }
1931
-
1932
-
1933
-    /**
1934
-     * decline_registration
1935
-     *
1936
-     * @param bool $notify whether or not to notify the registrant about their status change.
1937
-     * @return void
1938
-     * @throws EE_Error
1939
-     * @throws EntityNotFoundException
1940
-     * @throws InvalidArgumentException
1941
-     * @throws InvalidDataTypeException
1942
-     * @throws InvalidInterfaceException
1943
-     * @throws ReflectionException
1944
-     * @throws RuntimeException
1945
-     * @throws DomainException
1946
-     */
1947
-    protected function pending_registration($notify = false)
1948
-    {
1949
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1950
-    }
1951
-
1952
-
1953
-    /**
1954
-     * waitlist_registration
1955
-     *
1956
-     * @param bool $notify whether or not to notify the registrant about their status change.
1957
-     * @return void
1958
-     * @throws EE_Error
1959
-     * @throws EntityNotFoundException
1960
-     * @throws InvalidArgumentException
1961
-     * @throws InvalidDataTypeException
1962
-     * @throws InvalidInterfaceException
1963
-     * @throws ReflectionException
1964
-     * @throws RuntimeException
1965
-     * @throws DomainException
1966
-     */
1967
-    protected function wait_list_registration($notify = false)
1968
-    {
1969
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1970
-    }
1971
-
1972
-
1973
-    /**
1974
-     * generates HTML for the Registration main meta box
1975
-     *
1976
-     * @return void
1977
-     * @throws DomainException
1978
-     * @throws EE_Error
1979
-     * @throws InvalidArgumentException
1980
-     * @throws InvalidDataTypeException
1981
-     * @throws InvalidInterfaceException
1982
-     * @throws ReflectionException
1983
-     * @throws EntityNotFoundException
1984
-     */
1985
-    public function _reg_details_meta_box()
1986
-    {
1987
-        EEH_Autoloader::register_line_item_display_autoloaders();
1988
-        EEH_Autoloader::register_line_item_filter_autoloaders();
1989
-        EE_Registry::instance()->load_helper('Line_Item');
1990
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1991
-            : EE_Transaction::new_instance();
1992
-        $this->_session = $transaction->session_data();
1993
-        $filters        = new EE_Line_Item_Filter_Collection();
1994
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1995
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
1996
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
1997
-            $filters,
1998
-            $transaction->total_line_item()
1999
-        );
2000
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2001
-        $line_item_display                       = new EE_Line_Item_Display(
2002
-            'reg_admin_table',
2003
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2004
-        );
2005
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2006
-            $filtered_line_item_tree,
2007
-            ['EE_Registration' => $this->_registration]
2008
-        );
2009
-        $attendee                                = $this->_registration->attendee();
2010
-        if (
2011
-            EE_Registry::instance()->CAP->current_user_can(
2012
-                'ee_read_transaction',
2013
-                'espresso_transactions_view_transaction'
2014
-            )
2015
-        ) {
2016
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2017
-                EE_Admin_Page::add_query_args_and_nonce(
2018
-                    [
2019
-                        'action' => 'view_transaction',
2020
-                        'TXN_ID' => $transaction->ID(),
2021
-                    ],
2022
-                    TXN_ADMIN_URL
2023
-                ),
2024
-                esc_html__(' View Transaction', 'event_espresso'),
2025
-                'button button--secondary right',
2026
-                'dashicons dashicons-cart'
2027
-            );
2028
-        } else {
2029
-            $this->_template_args['view_transaction_button'] = '';
2030
-        }
2031
-        if (
2032
-            $attendee instanceof EE_Attendee
2033
-            && EE_Registry::instance()->CAP->current_user_can(
2034
-                'ee_send_message',
2035
-                'espresso_registrations_resend_registration'
2036
-            )
2037
-        ) {
2038
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2039
-                EE_Admin_Page::add_query_args_and_nonce(
2040
-                    [
2041
-                        'action'      => 'resend_registration',
2042
-                        '_REG_ID'     => $this->_registration->ID(),
2043
-                        'redirect_to' => 'view_registration',
2044
-                    ],
2045
-                    REG_ADMIN_URL
2046
-                ),
2047
-                esc_html__(' Resend Registration', 'event_espresso'),
2048
-                'button button--secondary right',
2049
-                'dashicons dashicons-email-alt'
2050
-            );
2051
-        } else {
2052
-            $this->_template_args['resend_registration_button'] = '';
2053
-        }
2054
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2055
-        $payment                               = $transaction->get_first_related('Payment');
2056
-        $payment                               = ! $payment instanceof EE_Payment
2057
-            ? EE_Payment::new_instance()
2058
-            : $payment;
2059
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2060
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2061
-            ? EE_Payment_Method::new_instance()
2062
-            : $payment_method;
2063
-        $reg_details                           = [
2064
-            'payment_method'       => $payment_method->name(),
2065
-            'response_msg'         => $payment->gateway_response(),
2066
-            'registration_id'      => $this->_registration->get('REG_code'),
2067
-            'registration_session' => $this->_registration->session_ID(),
2068
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2069
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2070
-        ];
2071
-        if (isset($reg_details['registration_id'])) {
2072
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2073
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2074
-                'Registration ID',
2075
-                'event_espresso'
2076
-            );
2077
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2078
-        }
2079
-        if (isset($reg_details['payment_method'])) {
2080
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2081
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2082
-                'Most Recent Payment Method',
2083
-                'event_espresso'
2084
-            );
2085
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2086
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2087
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2088
-                'Payment method response',
2089
-                'event_espresso'
2090
-            );
2091
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2092
-        }
2093
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2094
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2095
-            'Registration Session',
2096
-            'event_espresso'
2097
-        );
2098
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2099
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2100
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2101
-            'Registration placed from IP',
2102
-            'event_espresso'
2103
-        );
2104
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2105
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2106
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2107
-            'Registrant User Agent',
2108
-            'event_espresso'
2109
-        );
2110
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2111
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2112
-            [
2113
-                'action'   => 'default',
2114
-                'event_id' => $this->_registration->event_ID(),
2115
-            ],
2116
-            REG_ADMIN_URL
2117
-        );
2118
-
2119
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2120
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2121
-
2122
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2123
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2124
-    }
2125
-
2126
-
2127
-    /**
2128
-     * generates HTML for the Registration Questions meta box.
2129
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2130
-     * otherwise uses new forms system
2131
-     *
2132
-     * @return void
2133
-     * @throws DomainException
2134
-     * @throws EE_Error
2135
-     * @throws InvalidArgumentException
2136
-     * @throws InvalidDataTypeException
2137
-     * @throws InvalidInterfaceException
2138
-     * @throws ReflectionException
2139
-     */
2140
-    public function _reg_questions_meta_box()
2141
-    {
2142
-        // allow someone to override this method entirely
2143
-        if (
2144
-            apply_filters(
2145
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2146
-                true,
2147
-                $this,
2148
-                $this->_registration
2149
-            )
2150
-        ) {
2151
-            $form = $this->_get_reg_custom_questions_form(
2152
-                $this->_registration->ID()
2153
-            );
2154
-
2155
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2156
-                ? $form->get_html_and_js()
2157
-                : '';
2158
-
2159
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2160
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2161
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2162
-            EEH_Template::display_template($template_path, $this->_template_args);
2163
-        }
2164
-    }
2165
-
2166
-
2167
-    /**
2168
-     * form_before_question_group
2169
-     *
2170
-     * @param string $output
2171
-     * @return        string
2172
-     * @deprecated    as of 4.8.32.rc.000
2173
-     */
2174
-    public function form_before_question_group($output)
2175
-    {
2176
-        EE_Error::doing_it_wrong(
2177
-            __CLASS__ . '::' . __FUNCTION__,
2178
-            esc_html__(
2179
-                '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.',
2180
-                'event_espresso'
2181
-            ),
2182
-            '4.8.32.rc.000'
2183
-        );
2184
-        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
+	/**
38
+	 * @var array
39
+	 */
40
+	private static $_reg_status;
41
+
42
+	/**
43
+	 * Form for displaying the custom questions for this registration.
44
+	 * This gets used a few times throughout the request so its best to cache it
45
+	 *
46
+	 * @var EE_Registration_Custom_Questions_Form
47
+	 */
48
+	protected $_reg_custom_questions_form;
49
+
50
+	/**
51
+	 * @var EEM_Registration $registration_model
52
+	 */
53
+	private $registration_model;
54
+
55
+	/**
56
+	 * @var EEM_Attendee $attendee_model
57
+	 */
58
+	private $attendee_model;
59
+
60
+	/**
61
+	 * @var EEM_Event $event_model
62
+	 */
63
+	private $event_model;
64
+
65
+	/**
66
+	 * @var EEM_Status $status_model
67
+	 */
68
+	private $status_model;
69
+
70
+
71
+	/**
72
+	 * @param bool $routing
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function __construct($routing = true)
80
+	{
81
+		parent::__construct($routing);
82
+		add_action('wp_loaded', [$this, 'wp_loaded']);
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return EEM_Registration
88
+	 * @throws InvalidArgumentException
89
+	 * @throws InvalidDataTypeException
90
+	 * @throws InvalidInterfaceException
91
+	 * @since 4.10.2.p
92
+	 */
93
+	protected function getRegistrationModel()
94
+	{
95
+		if (! $this->registration_model instanceof EEM_Registration) {
96
+			$this->registration_model = $this->loader->getShared('EEM_Registration');
97
+		}
98
+		return $this->registration_model;
99
+	}
100
+
101
+
102
+	/**
103
+	 * @return EEM_Attendee
104
+	 * @throws InvalidArgumentException
105
+	 * @throws InvalidDataTypeException
106
+	 * @throws InvalidInterfaceException
107
+	 * @since 4.10.2.p
108
+	 */
109
+	protected function getAttendeeModel()
110
+	{
111
+		if (! $this->attendee_model instanceof EEM_Attendee) {
112
+			$this->attendee_model = $this->loader->getShared('EEM_Attendee');
113
+		}
114
+		return $this->attendee_model;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return EEM_Event
120
+	 * @throws InvalidArgumentException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws InvalidInterfaceException
123
+	 * @since 4.10.2.p
124
+	 */
125
+	protected function getEventModel()
126
+	{
127
+		if (! $this->event_model instanceof EEM_Event) {
128
+			$this->event_model = $this->loader->getShared('EEM_Event');
129
+		}
130
+		return $this->event_model;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return EEM_Status
136
+	 * @throws InvalidArgumentException
137
+	 * @throws InvalidDataTypeException
138
+	 * @throws InvalidInterfaceException
139
+	 * @since 4.10.2.p
140
+	 */
141
+	protected function getStatusModel()
142
+	{
143
+		if (! $this->status_model instanceof EEM_Status) {
144
+			$this->status_model = $this->loader->getShared('EEM_Status');
145
+		}
146
+		return $this->status_model;
147
+	}
148
+
149
+
150
+	public function wp_loaded()
151
+	{
152
+		// when adding a new registration...
153
+		$action = $this->request->getRequestParam('action');
154
+		if ($action === 'new_registration') {
155
+			EE_System::do_not_cache();
156
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
157
+				// and it's NOT the attendee information reg step
158
+				// force cookie expiration by setting time to last week
159
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
160
+				// and update the global
161
+				$_COOKIE['ee_registration_added'] = 0;
162
+			}
163
+		}
164
+	}
165
+
166
+
167
+	protected function _init_page_props()
168
+	{
169
+		$this->page_slug        = REG_PG_SLUG;
170
+		$this->_admin_base_url  = REG_ADMIN_URL;
171
+		$this->_admin_base_path = REG_ADMIN;
172
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
173
+		$this->_cpt_routes      = [
174
+			'add_new_attendee' => 'espresso_attendees',
175
+			'edit_attendee'    => 'espresso_attendees',
176
+			'insert_attendee'  => 'espresso_attendees',
177
+			'update_attendee'  => 'espresso_attendees',
178
+		];
179
+		$this->_cpt_model_names = [
180
+			'add_new_attendee' => 'EEM_Attendee',
181
+			'edit_attendee'    => 'EEM_Attendee',
182
+		];
183
+		$this->_cpt_edit_routes = [
184
+			'espresso_attendees' => 'edit_attendee',
185
+		];
186
+		$this->_pagenow_map     = [
187
+			'add_new_attendee' => 'post-new.php',
188
+			'edit_attendee'    => 'post.php',
189
+			'trash'            => 'post.php',
190
+		];
191
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
192
+		// add filters so that the comment urls don't take users to a confusing 404 page
193
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
199
+	 * @param WP_Comment $comment The current comment object.
200
+	 * @return string
201
+	 */
202
+	public function clear_comment_link($link, WP_Comment $comment)
203
+	{
204
+		// gotta make sure this only happens on this route
205
+		$post_type = get_post_type($comment->comment_post_ID);
206
+		if ($post_type === 'espresso_attendees') {
207
+			return '#commentsdiv';
208
+		}
209
+		return $link;
210
+	}
211
+
212
+
213
+	protected function _ajax_hooks()
214
+	{
215
+		// todo: all hooks for registrations ajax goes in here
216
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
217
+	}
218
+
219
+
220
+	protected function _define_page_props()
221
+	{
222
+		$this->_admin_page_title = $this->page_label;
223
+		$this->_labels           = [
224
+			'buttons'                      => [
225
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
226
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
227
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
228
+				'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
229
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
230
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
231
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
+			],
234
+			'publishbox'                   => [
235
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
+			],
238
+			'hide_add_button_on_cpt_route' => [
239
+				'edit_attendee' => true,
240
+			],
241
+		];
242
+	}
243
+
244
+
245
+	/**
246
+	 * grab url requests and route them
247
+	 *
248
+	 * @return void
249
+	 * @throws EE_Error
250
+	 */
251
+	public function _set_page_routes()
252
+	{
253
+		$this->_get_registration_status_array();
254
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
+		$this->_page_routes = [
259
+			'default'                             => [
260
+				'func'       => '_registrations_overview_list_table',
261
+				'capability' => 'ee_read_registrations',
262
+			],
263
+			'view_registration'                   => [
264
+				'func'       => '_registration_details',
265
+				'capability' => 'ee_read_registration',
266
+				'obj_id'     => $REG_ID,
267
+			],
268
+			'edit_registration'                   => [
269
+				'func'               => '_update_attendee_registration_form',
270
+				'noheader'           => true,
271
+				'headers_sent_route' => 'view_registration',
272
+				'capability'         => 'ee_edit_registration',
273
+				'obj_id'             => $REG_ID,
274
+				'_REG_ID'            => $REG_ID,
275
+			],
276
+			'trash_registrations'                 => [
277
+				'func'       => '_trash_or_restore_registrations',
278
+				'args'       => ['trash' => true],
279
+				'noheader'   => true,
280
+				'capability' => 'ee_delete_registrations',
281
+			],
282
+			'restore_registrations'               => [
283
+				'func'       => '_trash_or_restore_registrations',
284
+				'args'       => ['trash' => false],
285
+				'noheader'   => true,
286
+				'capability' => 'ee_delete_registrations',
287
+			],
288
+			'delete_registrations'                => [
289
+				'func'       => '_delete_registrations',
290
+				'noheader'   => true,
291
+				'capability' => 'ee_delete_registrations',
292
+			],
293
+			'new_registration'                    => [
294
+				'func'       => 'new_registration',
295
+				'capability' => 'ee_edit_registrations',
296
+			],
297
+			'process_reg_step'                    => [
298
+				'func'       => 'process_reg_step',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+			],
302
+			'redirect_to_txn'                     => [
303
+				'func'       => 'redirect_to_txn',
304
+				'noheader'   => true,
305
+				'capability' => 'ee_edit_registrations',
306
+			],
307
+			'change_reg_status'                   => [
308
+				'func'       => '_change_reg_status',
309
+				'noheader'   => true,
310
+				'capability' => 'ee_edit_registration',
311
+				'obj_id'     => $REG_ID,
312
+			],
313
+			'approve_registration'                => [
314
+				'func'       => 'approve_registration',
315
+				'noheader'   => true,
316
+				'capability' => 'ee_edit_registration',
317
+				'obj_id'     => $REG_ID,
318
+			],
319
+			'approve_and_notify_registration'     => [
320
+				'func'       => 'approve_registration',
321
+				'noheader'   => true,
322
+				'args'       => [true],
323
+				'capability' => 'ee_edit_registration',
324
+				'obj_id'     => $REG_ID,
325
+			],
326
+			'approve_registrations'               => [
327
+				'func'       => 'bulk_action_on_registrations',
328
+				'noheader'   => true,
329
+				'capability' => 'ee_edit_registrations',
330
+				'args'       => ['approve'],
331
+			],
332
+			'approve_and_notify_registrations'    => [
333
+				'func'       => 'bulk_action_on_registrations',
334
+				'noheader'   => true,
335
+				'capability' => 'ee_edit_registrations',
336
+				'args'       => ['approve', true],
337
+			],
338
+			'decline_registration'                => [
339
+				'func'       => 'decline_registration',
340
+				'noheader'   => true,
341
+				'capability' => 'ee_edit_registration',
342
+				'obj_id'     => $REG_ID,
343
+			],
344
+			'decline_and_notify_registration'     => [
345
+				'func'       => 'decline_registration',
346
+				'noheader'   => true,
347
+				'args'       => [true],
348
+				'capability' => 'ee_edit_registration',
349
+				'obj_id'     => $REG_ID,
350
+			],
351
+			'decline_registrations'               => [
352
+				'func'       => 'bulk_action_on_registrations',
353
+				'noheader'   => true,
354
+				'capability' => 'ee_edit_registrations',
355
+				'args'       => ['decline'],
356
+			],
357
+			'decline_and_notify_registrations'    => [
358
+				'func'       => 'bulk_action_on_registrations',
359
+				'noheader'   => true,
360
+				'capability' => 'ee_edit_registrations',
361
+				'args'       => ['decline', true],
362
+			],
363
+			'pending_registration'                => [
364
+				'func'       => 'pending_registration',
365
+				'noheader'   => true,
366
+				'capability' => 'ee_edit_registration',
367
+				'obj_id'     => $REG_ID,
368
+			],
369
+			'pending_and_notify_registration'     => [
370
+				'func'       => 'pending_registration',
371
+				'noheader'   => true,
372
+				'args'       => [true],
373
+				'capability' => 'ee_edit_registration',
374
+				'obj_id'     => $REG_ID,
375
+			],
376
+			'pending_registrations'               => [
377
+				'func'       => 'bulk_action_on_registrations',
378
+				'noheader'   => true,
379
+				'capability' => 'ee_edit_registrations',
380
+				'args'       => ['pending'],
381
+			],
382
+			'pending_and_notify_registrations'    => [
383
+				'func'       => 'bulk_action_on_registrations',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_registrations',
386
+				'args'       => ['pending', true],
387
+			],
388
+			'no_approve_registration'             => [
389
+				'func'       => 'not_approve_registration',
390
+				'noheader'   => true,
391
+				'capability' => 'ee_edit_registration',
392
+				'obj_id'     => $REG_ID,
393
+			],
394
+			'no_approve_and_notify_registration'  => [
395
+				'func'       => 'not_approve_registration',
396
+				'noheader'   => true,
397
+				'args'       => [true],
398
+				'capability' => 'ee_edit_registration',
399
+				'obj_id'     => $REG_ID,
400
+			],
401
+			'no_approve_registrations'            => [
402
+				'func'       => 'bulk_action_on_registrations',
403
+				'noheader'   => true,
404
+				'capability' => 'ee_edit_registrations',
405
+				'args'       => ['not_approve'],
406
+			],
407
+			'no_approve_and_notify_registrations' => [
408
+				'func'       => 'bulk_action_on_registrations',
409
+				'noheader'   => true,
410
+				'capability' => 'ee_edit_registrations',
411
+				'args'       => ['not_approve', true],
412
+			],
413
+			'cancel_registration'                 => [
414
+				'func'       => 'cancel_registration',
415
+				'noheader'   => true,
416
+				'capability' => 'ee_edit_registration',
417
+				'obj_id'     => $REG_ID,
418
+			],
419
+			'cancel_and_notify_registration'      => [
420
+				'func'       => 'cancel_registration',
421
+				'noheader'   => true,
422
+				'args'       => [true],
423
+				'capability' => 'ee_edit_registration',
424
+				'obj_id'     => $REG_ID,
425
+			],
426
+			'cancel_registrations'                => [
427
+				'func'       => 'bulk_action_on_registrations',
428
+				'noheader'   => true,
429
+				'capability' => 'ee_edit_registrations',
430
+				'args'       => ['cancel'],
431
+			],
432
+			'cancel_and_notify_registrations'     => [
433
+				'func'       => 'bulk_action_on_registrations',
434
+				'noheader'   => true,
435
+				'capability' => 'ee_edit_registrations',
436
+				'args'       => ['cancel', true],
437
+			],
438
+			'wait_list_registration'              => [
439
+				'func'       => 'wait_list_registration',
440
+				'noheader'   => true,
441
+				'capability' => 'ee_edit_registration',
442
+				'obj_id'     => $REG_ID,
443
+			],
444
+			'wait_list_and_notify_registration'   => [
445
+				'func'       => 'wait_list_registration',
446
+				'noheader'   => true,
447
+				'args'       => [true],
448
+				'capability' => 'ee_edit_registration',
449
+				'obj_id'     => $REG_ID,
450
+			],
451
+			'contact_list'                        => [
452
+				'func'       => '_attendee_contact_list_table',
453
+				'capability' => 'ee_read_contacts',
454
+			],
455
+			'add_new_attendee'                    => [
456
+				'func' => '_create_new_cpt_item',
457
+				'args' => [
458
+					'new_attendee' => true,
459
+					'capability'   => 'ee_edit_contacts',
460
+				],
461
+			],
462
+			'edit_attendee'                       => [
463
+				'func'       => '_edit_cpt_item',
464
+				'capability' => 'ee_edit_contacts',
465
+				'obj_id'     => $ATT_ID,
466
+			],
467
+			'duplicate_attendee'                  => [
468
+				'func'       => '_duplicate_attendee',
469
+				'noheader'   => true,
470
+				'capability' => 'ee_edit_contacts',
471
+				'obj_id'     => $ATT_ID,
472
+			],
473
+			'insert_attendee'                     => [
474
+				'func'       => '_insert_or_update_attendee',
475
+				'args'       => [
476
+					'new_attendee' => true,
477
+				],
478
+				'noheader'   => true,
479
+				'capability' => 'ee_edit_contacts',
480
+			],
481
+			'update_attendee'                     => [
482
+				'func'       => '_insert_or_update_attendee',
483
+				'args'       => [
484
+					'new_attendee' => false,
485
+				],
486
+				'noheader'   => true,
487
+				'capability' => 'ee_edit_contacts',
488
+				'obj_id'     => $ATT_ID,
489
+			],
490
+			'trash_attendees'                     => [
491
+				'func'       => '_trash_or_restore_attendees',
492
+				'args'       => [
493
+					'trash' => 'true',
494
+				],
495
+				'noheader'   => true,
496
+				'capability' => 'ee_delete_contacts',
497
+			],
498
+			'trash_attendee'                      => [
499
+				'func'       => '_trash_or_restore_attendees',
500
+				'args'       => [
501
+					'trash' => true,
502
+				],
503
+				'noheader'   => true,
504
+				'capability' => 'ee_delete_contacts',
505
+				'obj_id'     => $ATT_ID,
506
+			],
507
+			'restore_attendees'                   => [
508
+				'func'       => '_trash_or_restore_attendees',
509
+				'args'       => [
510
+					'trash' => false,
511
+				],
512
+				'noheader'   => true,
513
+				'capability' => 'ee_delete_contacts',
514
+				'obj_id'     => $ATT_ID,
515
+			],
516
+			'resend_registration'                 => [
517
+				'func'       => '_resend_registration',
518
+				'noheader'   => true,
519
+				'capability' => 'ee_send_message',
520
+			],
521
+			'registrations_report'                => [
522
+				'func'       => '_registrations_report',
523
+				'noheader'   => true,
524
+				'capability' => 'ee_read_registrations',
525
+			],
526
+			'contact_list_export'                 => [
527
+				'func'       => '_contact_list_export',
528
+				'noheader'   => true,
529
+				'capability' => 'export',
530
+			],
531
+			'contact_list_report'                 => [
532
+				'func'       => '_contact_list_report',
533
+				'noheader'   => true,
534
+				'capability' => 'ee_read_contacts',
535
+			],
536
+		];
537
+	}
538
+
539
+
540
+	protected function _set_page_config()
541
+	{
542
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
+		$this->_page_config = [
545
+			'default'           => [
546
+				'nav'           => [
547
+					'label' => esc_html__('Overview', 'event_espresso'),
548
+					'order' => 5,
549
+				],
550
+				'help_tabs'     => [
551
+					'registrations_overview_help_tab'                       => [
552
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
+						'filename' => 'registrations_overview',
554
+					],
555
+					'registrations_overview_table_column_headings_help_tab' => [
556
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
+						'filename' => 'registrations_overview_table_column_headings',
558
+					],
559
+					'registrations_overview_filters_help_tab'               => [
560
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
+						'filename' => 'registrations_overview_filters',
562
+					],
563
+					'registrations_overview_views_help_tab'                 => [
564
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
565
+						'filename' => 'registrations_overview_views',
566
+					],
567
+					'registrations_regoverview_other_help_tab'              => [
568
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
+						'filename' => 'registrations_overview_other',
570
+					],
571
+				],
572
+				'list_table'    => 'EE_Registrations_List_Table',
573
+				'require_nonce' => false,
574
+			],
575
+			'view_registration' => [
576
+				'nav'           => [
577
+					'label'      => esc_html__('REG Details', 'event_espresso'),
578
+					'order'      => 15,
579
+					'url'        => $REG_ID
580
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
581
+						: $this->_admin_base_url,
582
+					'persistent' => false,
583
+				],
584
+				'help_tabs'     => [
585
+					'registrations_details_help_tab'                    => [
586
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
587
+						'filename' => 'registrations_details',
588
+					],
589
+					'registrations_details_table_help_tab'              => [
590
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
591
+						'filename' => 'registrations_details_table',
592
+					],
593
+					'registrations_details_form_answers_help_tab'       => [
594
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
595
+						'filename' => 'registrations_details_form_answers',
596
+					],
597
+					'registrations_details_registrant_details_help_tab' => [
598
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
599
+						'filename' => 'registrations_details_registrant_details',
600
+					],
601
+				],
602
+				'metaboxes'     => array_merge(
603
+					$this->_default_espresso_metaboxes,
604
+					['_registration_details_metaboxes']
605
+				),
606
+				'require_nonce' => false,
607
+			],
608
+			'new_registration'  => [
609
+				'nav'           => [
610
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
611
+					'url'        => '#',
612
+					'order'      => 15,
613
+					'persistent' => false,
614
+				],
615
+				'metaboxes'     => $this->_default_espresso_metaboxes,
616
+				'labels'        => [
617
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
618
+				],
619
+				'require_nonce' => false,
620
+			],
621
+			'add_new_attendee'  => [
622
+				'nav'           => [
623
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
624
+					'order'      => 15,
625
+					'persistent' => false,
626
+				],
627
+				'metaboxes'     => array_merge(
628
+					$this->_default_espresso_metaboxes,
629
+					['_publish_post_box', 'attendee_editor_metaboxes']
630
+				),
631
+				'require_nonce' => false,
632
+			],
633
+			'edit_attendee'     => [
634
+				'nav'           => [
635
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
636
+					'order'      => 15,
637
+					'persistent' => false,
638
+					'url'        => $ATT_ID
639
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
640
+						: $this->_admin_base_url,
641
+				],
642
+				'metaboxes'     => array_merge(
643
+					$this->_default_espresso_metaboxes,
644
+					['attendee_editor_metaboxes']
645
+				),
646
+				'require_nonce' => false,
647
+			],
648
+			'contact_list'      => [
649
+				'nav'           => [
650
+					'label' => esc_html__('Contact List', 'event_espresso'),
651
+					'order' => 20,
652
+				],
653
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
654
+				'help_tabs'     => [
655
+					'registrations_contact_list_help_tab'                       => [
656
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
657
+						'filename' => 'registrations_contact_list',
658
+					],
659
+					'registrations_contact-list_table_column_headings_help_tab' => [
660
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
661
+						'filename' => 'registrations_contact_list_table_column_headings',
662
+					],
663
+					'registrations_contact_list_views_help_tab'                 => [
664
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
665
+						'filename' => 'registrations_contact_list_views',
666
+					],
667
+					'registrations_contact_list_other_help_tab'                 => [
668
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
669
+						'filename' => 'registrations_contact_list_other',
670
+					],
671
+				],
672
+				'metaboxes'     => [],
673
+				'require_nonce' => false,
674
+			],
675
+			// override default cpt routes
676
+			'create_new'        => '',
677
+			'edit'              => '',
678
+		];
679
+	}
680
+
681
+
682
+	/**
683
+	 * The below methods aren't used by this class currently
684
+	 */
685
+	protected function _add_screen_options()
686
+	{
687
+	}
688
+
689
+
690
+	protected function _add_feature_pointers()
691
+	{
692
+	}
693
+
694
+
695
+	public function admin_init()
696
+	{
697
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
698
+			'click "Update Registration Questions" to save your changes',
699
+			'event_espresso'
700
+		);
701
+	}
702
+
703
+
704
+	public function admin_notices()
705
+	{
706
+	}
707
+
708
+
709
+	public function admin_footer_scripts()
710
+	{
711
+	}
712
+
713
+
714
+	/**
715
+	 * get list of registration statuses
716
+	 *
717
+	 * @return void
718
+	 * @throws EE_Error
719
+	 */
720
+	private function _get_registration_status_array()
721
+	{
722
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
723
+	}
724
+
725
+
726
+	/**
727
+	 * @throws InvalidArgumentException
728
+	 * @throws InvalidDataTypeException
729
+	 * @throws InvalidInterfaceException
730
+	 * @since 4.10.2.p
731
+	 */
732
+	protected function _add_screen_options_default()
733
+	{
734
+		$this->_per_page_screen_option();
735
+	}
736
+
737
+
738
+	/**
739
+	 * @throws InvalidArgumentException
740
+	 * @throws InvalidDataTypeException
741
+	 * @throws InvalidInterfaceException
742
+	 * @since 4.10.2.p
743
+	 */
744
+	protected function _add_screen_options_contact_list()
745
+	{
746
+		$page_title              = $this->_admin_page_title;
747
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
748
+		$this->_per_page_screen_option();
749
+		$this->_admin_page_title = $page_title;
750
+	}
751
+
752
+
753
+	public function load_scripts_styles()
754
+	{
755
+		// style
756
+		wp_register_style(
757
+			'espresso_reg',
758
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
759
+			['ee-admin-css'],
760
+			EVENT_ESPRESSO_VERSION
761
+		);
762
+		wp_enqueue_style('espresso_reg');
763
+		// script
764
+		wp_register_script(
765
+			'espresso_reg',
766
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
767
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
768
+			EVENT_ESPRESSO_VERSION,
769
+			true
770
+		);
771
+		wp_enqueue_script('espresso_reg');
772
+	}
773
+
774
+
775
+	/**
776
+	 * @throws EE_Error
777
+	 * @throws InvalidArgumentException
778
+	 * @throws InvalidDataTypeException
779
+	 * @throws InvalidInterfaceException
780
+	 * @throws ReflectionException
781
+	 * @since 4.10.2.p
782
+	 */
783
+	public function load_scripts_styles_edit_attendee()
784
+	{
785
+		// stuff to only show up on our attendee edit details page.
786
+		$attendee_details_translations = [
787
+			'att_publish_text' => sprintf(
788
+			/* translators: The date and time */
789
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
790
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
791
+			),
792
+		];
793
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
794
+		wp_enqueue_script('jquery-validate');
795
+	}
796
+
797
+
798
+	/**
799
+	 * @throws EE_Error
800
+	 * @throws InvalidArgumentException
801
+	 * @throws InvalidDataTypeException
802
+	 * @throws InvalidInterfaceException
803
+	 * @throws ReflectionException
804
+	 * @since 4.10.2.p
805
+	 */
806
+	public function load_scripts_styles_view_registration()
807
+	{
808
+		// styles
809
+		wp_enqueue_style('espresso-ui-theme');
810
+		// scripts
811
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
812
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
813
+	}
814
+
815
+
816
+	public function load_scripts_styles_contact_list()
817
+	{
818
+		wp_dequeue_style('espresso_reg');
819
+		wp_register_style(
820
+			'espresso_att',
821
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
822
+			['ee-admin-css'],
823
+			EVENT_ESPRESSO_VERSION
824
+		);
825
+		wp_enqueue_style('espresso_att');
826
+	}
827
+
828
+
829
+	public function load_scripts_styles_new_registration()
830
+	{
831
+		wp_register_script(
832
+			'ee-spco-for-admin',
833
+			REG_ASSETS_URL . 'spco_for_admin.js',
834
+			['underscore', 'jquery'],
835
+			EVENT_ESPRESSO_VERSION,
836
+			true
837
+		);
838
+		wp_enqueue_script('ee-spco-for-admin');
839
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
840
+		EE_Form_Section_Proper::wp_enqueue_scripts();
841
+		EED_Ticket_Selector::load_tckt_slctr_assets();
842
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
843
+	}
844
+
845
+
846
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
847
+	{
848
+		add_filter('FHEE_load_EE_messages', '__return_true');
849
+	}
850
+
851
+
852
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
853
+	{
854
+		add_filter('FHEE_load_EE_messages', '__return_true');
855
+	}
856
+
857
+
858
+	/**
859
+	 * @throws EE_Error
860
+	 * @throws InvalidArgumentException
861
+	 * @throws InvalidDataTypeException
862
+	 * @throws InvalidInterfaceException
863
+	 * @throws ReflectionException
864
+	 * @since 4.10.2.p
865
+	 */
866
+	protected function _set_list_table_views_default()
867
+	{
868
+		// for notification related bulk actions we need to make sure only active messengers have an option.
869
+		EED_Messages::set_autoloaders();
870
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
871
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
872
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
873
+		// key= bulk_action_slug, value= message type.
874
+		$match_array = [
875
+			'approve_registrations'    => 'registration',
876
+			'decline_registrations'    => 'declined_registration',
877
+			'pending_registrations'    => 'pending_approval',
878
+			'no_approve_registrations' => 'not_approved_registration',
879
+			'cancel_registrations'     => 'cancelled_registration',
880
+		];
881
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
882
+			'ee_send_message',
883
+			'batch_send_messages'
884
+		);
885
+		/** setup reg status bulk actions **/
886
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
887
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
888
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
889
+				'Approve and Notify Registrations',
890
+				'event_espresso'
891
+			);
892
+		}
893
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
894
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
895
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
896
+				'Decline and Notify Registrations',
897
+				'event_espresso'
898
+			);
899
+		}
900
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
901
+			'Set Registrations to Pending Payment',
902
+			'event_espresso'
903
+		);
904
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
905
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
906
+				'Set Registrations to Pending Payment and Notify',
907
+				'event_espresso'
908
+			);
909
+		}
910
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
911
+			'Set Registrations to Not Approved',
912
+			'event_espresso'
913
+		);
914
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
915
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
916
+				'Set Registrations to Not Approved and Notify',
917
+				'event_espresso'
918
+			);
919
+		}
920
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
921
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
922
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
923
+				'Cancel Registrations and Notify',
924
+				'event_espresso'
925
+			);
926
+		}
927
+		$def_reg_status_actions = apply_filters(
928
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
929
+			$def_reg_status_actions,
930
+			$active_mts,
931
+			$can_send
932
+		);
933
+
934
+		$this->_views = [
935
+			'all'   => [
936
+				'slug'        => 'all',
937
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
938
+				'count'       => 0,
939
+				'bulk_action' => array_merge(
940
+					$def_reg_status_actions,
941
+					[
942
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
943
+					]
944
+				),
945
+			],
946
+			'month' => [
947
+				'slug'        => 'month',
948
+				'label'       => esc_html__('This Month', 'event_espresso'),
949
+				'count'       => 0,
950
+				'bulk_action' => array_merge(
951
+					$def_reg_status_actions,
952
+					[
953
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
954
+					]
955
+				),
956
+			],
957
+			'today' => [
958
+				'slug'        => 'today',
959
+				'label'       => sprintf(
960
+					esc_html__('Today - %s', 'event_espresso'),
961
+					date('M d, Y', current_time('timestamp'))
962
+				),
963
+				'count'       => 0,
964
+				'bulk_action' => array_merge(
965
+					$def_reg_status_actions,
966
+					[
967
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
968
+					]
969
+				),
970
+			],
971
+		];
972
+		if (
973
+			EE_Registry::instance()->CAP->current_user_can(
974
+				'ee_delete_registrations',
975
+				'espresso_registrations_delete_registration'
976
+			)
977
+		) {
978
+			$this->_views['incomplete'] = [
979
+				'slug'        => 'incomplete',
980
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
981
+				'count'       => 0,
982
+				'bulk_action' => [
983
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
984
+				],
985
+			];
986
+			$this->_views['trash']      = [
987
+				'slug'        => 'trash',
988
+				'label'       => esc_html__('Trash', 'event_espresso'),
989
+				'count'       => 0,
990
+				'bulk_action' => [
991
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
992
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
993
+				],
994
+			];
995
+		}
996
+	}
997
+
998
+
999
+	protected function _set_list_table_views_contact_list()
1000
+	{
1001
+		$this->_views = [
1002
+			'in_use' => [
1003
+				'slug'        => 'in_use',
1004
+				'label'       => esc_html__('In Use', 'event_espresso'),
1005
+				'count'       => 0,
1006
+				'bulk_action' => [
1007
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1008
+				],
1009
+			],
1010
+		];
1011
+		if (
1012
+			EE_Registry::instance()->CAP->current_user_can(
1013
+				'ee_delete_contacts',
1014
+				'espresso_registrations_trash_attendees'
1015
+			)
1016
+		) {
1017
+			$this->_views['trash'] = [
1018
+				'slug'        => 'trash',
1019
+				'label'       => esc_html__('Trash', 'event_espresso'),
1020
+				'count'       => 0,
1021
+				'bulk_action' => [
1022
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1023
+				],
1024
+			];
1025
+		}
1026
+	}
1027
+
1028
+
1029
+	/**
1030
+	 * @return array
1031
+	 * @throws EE_Error
1032
+	 */
1033
+	protected function _registration_legend_items()
1034
+	{
1035
+		$fc_items = [
1036
+			'star-icon'        => [
1037
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1038
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1039
+			],
1040
+			'view_details'     => [
1041
+				'class' => 'dashicons dashicons-clipboard',
1042
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1043
+			],
1044
+			'edit_attendee'    => [
1045
+				'class' => 'dashicons dashicons-admin-users',
1046
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1047
+			],
1048
+			'view_transaction' => [
1049
+				'class' => 'dashicons dashicons-cart',
1050
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1051
+			],
1052
+			'view_invoice'     => [
1053
+				'class' => 'dashicons dashicons-media-spreadsheet',
1054
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1055
+			],
1056
+		];
1057
+		if (
1058
+			EE_Registry::instance()->CAP->current_user_can(
1059
+				'ee_send_message',
1060
+				'espresso_registrations_resend_registration'
1061
+			)
1062
+		) {
1063
+			$fc_items['resend_registration'] = [
1064
+				'class' => 'dashicons dashicons-email-alt',
1065
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1066
+			];
1067
+		} else {
1068
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1069
+		}
1070
+		if (
1071
+			EE_Registry::instance()->CAP->current_user_can(
1072
+				'ee_read_global_messages',
1073
+				'view_filtered_messages'
1074
+			)
1075
+		) {
1076
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1077
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1078
+				$fc_items['view_related_messages'] = [
1079
+					'class' => $related_for_icon['css_class'],
1080
+					'desc'  => $related_for_icon['label'],
1081
+				];
1082
+			}
1083
+		}
1084
+		$sc_items = [
1085
+			'approved_status'   => [
1086
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1087
+				'desc'  => EEH_Template::pretty_status(
1088
+					EEM_Registration::status_id_approved,
1089
+					false,
1090
+					'sentence'
1091
+				),
1092
+			],
1093
+			'pending_status'    => [
1094
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1095
+				'desc'  => EEH_Template::pretty_status(
1096
+					EEM_Registration::status_id_pending_payment,
1097
+					false,
1098
+					'sentence'
1099
+				),
1100
+			],
1101
+			'wait_list'         => [
1102
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1103
+				'desc'  => EEH_Template::pretty_status(
1104
+					EEM_Registration::status_id_wait_list,
1105
+					false,
1106
+					'sentence'
1107
+				),
1108
+			],
1109
+			'incomplete_status' => [
1110
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1111
+				'desc'  => EEH_Template::pretty_status(
1112
+					EEM_Registration::status_id_incomplete,
1113
+					false,
1114
+					'sentence'
1115
+				),
1116
+			],
1117
+			'not_approved'      => [
1118
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1119
+				'desc'  => EEH_Template::pretty_status(
1120
+					EEM_Registration::status_id_not_approved,
1121
+					false,
1122
+					'sentence'
1123
+				),
1124
+			],
1125
+			'declined_status'   => [
1126
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1127
+				'desc'  => EEH_Template::pretty_status(
1128
+					EEM_Registration::status_id_declined,
1129
+					false,
1130
+					'sentence'
1131
+				),
1132
+			],
1133
+			'cancelled_status'  => [
1134
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1135
+				'desc'  => EEH_Template::pretty_status(
1136
+					EEM_Registration::status_id_cancelled,
1137
+					false,
1138
+					'sentence'
1139
+				),
1140
+			],
1141
+		];
1142
+		return array_merge($fc_items, $sc_items);
1143
+	}
1144
+
1145
+
1146
+
1147
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1148
+
1149
+
1150
+	/**
1151
+	 * @throws DomainException
1152
+	 * @throws EE_Error
1153
+	 * @throws InvalidArgumentException
1154
+	 * @throws InvalidDataTypeException
1155
+	 * @throws InvalidInterfaceException
1156
+	 */
1157
+	protected function _registrations_overview_list_table()
1158
+	{
1159
+		$this->appendAddNewRegistrationButtonToPageTitle();
1160
+		$header_text                  = '';
1161
+		$admin_page_header_decorators = [
1162
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1163
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1164
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1165
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1166
+		];
1167
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1168
+			$filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1169
+			$header_text = $filter_header_decorator->getHeaderText($header_text);
1170
+		}
1171
+		$this->_template_args['admin_page_header'] = $header_text;
1172
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1173
+		$this->display_admin_list_table_page_with_no_sidebar();
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 * @throws EE_Error
1179
+	 * @throws InvalidArgumentException
1180
+	 * @throws InvalidDataTypeException
1181
+	 * @throws InvalidInterfaceException
1182
+	 */
1183
+	private function appendAddNewRegistrationButtonToPageTitle()
1184
+	{
1185
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1186
+		if (
1187
+			$EVT_ID
1188
+			&& EE_Registry::instance()->CAP->current_user_can(
1189
+				'ee_edit_registrations',
1190
+				'espresso_registrations_new_registration',
1191
+				$EVT_ID
1192
+			)
1193
+		) {
1194
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1195
+				'new_registration',
1196
+				'add-registrant',
1197
+				['event_id' => $EVT_ID],
1198
+				'add-new-h2'
1199
+			);
1200
+		}
1201
+	}
1202
+
1203
+
1204
+	/**
1205
+	 * This sets the _registration property for the registration details screen
1206
+	 *
1207
+	 * @return void
1208
+	 * @throws EE_Error
1209
+	 * @throws InvalidArgumentException
1210
+	 * @throws InvalidDataTypeException
1211
+	 * @throws InvalidInterfaceException
1212
+	 */
1213
+	private function _set_registration_object()
1214
+	{
1215
+		// get out if we've already set the object
1216
+		if ($this->_registration instanceof EE_Registration) {
1217
+			return;
1218
+		}
1219
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1220
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1221
+			return;
1222
+		}
1223
+		$error_msg = sprintf(
1224
+			esc_html__(
1225
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1226
+				'event_espresso'
1227
+			),
1228
+			$REG_ID
1229
+		);
1230
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1231
+		$this->_registration = null;
1232
+	}
1233
+
1234
+
1235
+	/**
1236
+	 * Used to retrieve registrations for the list table.
1237
+	 *
1238
+	 * @param int  $per_page
1239
+	 * @param bool $count
1240
+	 * @param bool $this_month
1241
+	 * @param bool $today
1242
+	 * @return EE_Registration[]|int
1243
+	 * @throws EE_Error
1244
+	 * @throws InvalidArgumentException
1245
+	 * @throws InvalidDataTypeException
1246
+	 * @throws InvalidInterfaceException
1247
+	 */
1248
+	public function get_registrations(
1249
+		$per_page = 10,
1250
+		$count = false,
1251
+		$this_month = false,
1252
+		$today = false
1253
+	) {
1254
+		if ($this_month) {
1255
+			$this->request->setRequestParam('status', 'month');
1256
+		}
1257
+		if ($today) {
1258
+			$this->request->setRequestParam('status', 'today');
1259
+		}
1260
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1261
+		/**
1262
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1263
+		 *
1264
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1265
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1266
+		 *                      or if you have the development copy of EE you can view this at the path:
1267
+		 *                      /docs/G--Model-System/model-query-params.md
1268
+		 */
1269
+		$query_params['group_by'] = '';
1270
+
1271
+		return $count
1272
+			? $this->getRegistrationModel()->count($query_params)
1273
+			/** @type EE_Registration[] */
1274
+			: $this->getRegistrationModel()->get_all($query_params);
1275
+	}
1276
+
1277
+
1278
+	/**
1279
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1280
+	 * Note: this listens to values on the request for some of the query parameters.
1281
+	 *
1282
+	 * @param array $request
1283
+	 * @param int   $per_page
1284
+	 * @param bool  $count
1285
+	 * @return array
1286
+	 * @throws EE_Error
1287
+	 * @throws InvalidArgumentException
1288
+	 * @throws InvalidDataTypeException
1289
+	 * @throws InvalidInterfaceException
1290
+	 */
1291
+	protected function _get_registration_query_parameters(
1292
+		$request = [],
1293
+		$per_page = 10,
1294
+		$count = false
1295
+	) {
1296
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1297
+		$list_table_query_builder = $this->loader->getNew(
1298
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1299
+			[null, null, $request]
1300
+		);
1301
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1302
+	}
1303
+
1304
+
1305
+	public function get_registration_status_array()
1306
+	{
1307
+		return self::$_reg_status;
1308
+	}
1309
+
1310
+
1311
+
1312
+
1313
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1314
+	/**
1315
+	 * generates HTML for the View Registration Details Admin page
1316
+	 *
1317
+	 * @return void
1318
+	 * @throws DomainException
1319
+	 * @throws EE_Error
1320
+	 * @throws InvalidArgumentException
1321
+	 * @throws InvalidDataTypeException
1322
+	 * @throws InvalidInterfaceException
1323
+	 * @throws EntityNotFoundException
1324
+	 * @throws ReflectionException
1325
+	 */
1326
+	protected function _registration_details()
1327
+	{
1328
+		$this->_template_args = [];
1329
+		$this->_set_registration_object();
1330
+		if (is_object($this->_registration)) {
1331
+			$transaction                                   = $this->_registration->transaction()
1332
+				? $this->_registration->transaction()
1333
+				: EE_Transaction::new_instance();
1334
+			$this->_session                                = $transaction->session_data();
1335
+			$event_id                                      = $this->_registration->event_ID();
1336
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1337
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1338
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1339
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1340
+			$this->_template_args['grand_total']           = $transaction->total();
1341
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1342
+			// link back to overview
1343
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1344
+			$this->_template_args['registration']                = $this->_registration;
1345
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1346
+				[
1347
+					'action'   => 'default',
1348
+					'event_id' => $event_id,
1349
+				],
1350
+				REG_ADMIN_URL
1351
+			);
1352
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1353
+				[
1354
+					'action' => 'default',
1355
+					'EVT_ID' => $event_id,
1356
+					'page'   => 'espresso_transactions',
1357
+				],
1358
+				admin_url('admin.php')
1359
+			);
1360
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1361
+				[
1362
+					'page'   => 'espresso_events',
1363
+					'action' => 'edit',
1364
+					'post'   => $event_id,
1365
+				],
1366
+				admin_url('admin.php')
1367
+			);
1368
+			// next and previous links
1369
+			$next_reg                                      = $this->_registration->next(
1370
+				null,
1371
+				[],
1372
+				'REG_ID'
1373
+			);
1374
+			$this->_template_args['next_registration']     = $next_reg
1375
+				? $this->_next_link(
1376
+					EE_Admin_Page::add_query_args_and_nonce(
1377
+						[
1378
+							'action'  => 'view_registration',
1379
+							'_REG_ID' => $next_reg['REG_ID'],
1380
+						],
1381
+						REG_ADMIN_URL
1382
+					),
1383
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1384
+				)
1385
+				: '';
1386
+			$previous_reg                                  = $this->_registration->previous(
1387
+				null,
1388
+				[],
1389
+				'REG_ID'
1390
+			);
1391
+			$this->_template_args['previous_registration'] = $previous_reg
1392
+				? $this->_previous_link(
1393
+					EE_Admin_Page::add_query_args_and_nonce(
1394
+						[
1395
+							'action'  => 'view_registration',
1396
+							'_REG_ID' => $previous_reg['REG_ID'],
1397
+						],
1398
+						REG_ADMIN_URL
1399
+					),
1400
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1401
+				)
1402
+				: '';
1403
+			// grab header
1404
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1405
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1406
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1407
+				$template_path,
1408
+				$this->_template_args,
1409
+				true
1410
+			);
1411
+		} else {
1412
+			$this->_template_args['admin_page_header'] = '';
1413
+			$this->_display_espresso_notices();
1414
+		}
1415
+		// the details template wrapper
1416
+		$this->display_admin_page_with_sidebar();
1417
+	}
1418
+
1419
+
1420
+	/**
1421
+	 * @throws EE_Error
1422
+	 * @throws InvalidArgumentException
1423
+	 * @throws InvalidDataTypeException
1424
+	 * @throws InvalidInterfaceException
1425
+	 * @throws ReflectionException
1426
+	 * @since 4.10.2.p
1427
+	 */
1428
+	protected function _registration_details_metaboxes()
1429
+	{
1430
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1431
+		$this->_set_registration_object();
1432
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1433
+		$this->addMetaBox(
1434
+			'edit-reg-status-mbox',
1435
+			esc_html__('Registration Status', 'event_espresso'),
1436
+			[$this, 'set_reg_status_buttons_metabox'],
1437
+			$this->_wp_page_slug
1438
+		);
1439
+		$this->addMetaBox(
1440
+			'edit-reg-details-mbox',
1441
+			'<span>' . esc_html__('Registration Details', 'event_espresso')
1442
+			. '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1443
+			[$this, '_reg_details_meta_box'],
1444
+			$this->_wp_page_slug
1445
+		);
1446
+		if (
1447
+			$attendee instanceof EE_Attendee
1448
+			&& EE_Registry::instance()->CAP->current_user_can(
1449
+				'ee_read_registration',
1450
+				'edit-reg-questions-mbox',
1451
+				$this->_registration->ID()
1452
+			)
1453
+		) {
1454
+			$this->addMetaBox(
1455
+				'edit-reg-questions-mbox',
1456
+				esc_html__('Registration Form Answers', 'event_espresso'),
1457
+				[$this, '_reg_questions_meta_box'],
1458
+				$this->_wp_page_slug
1459
+			);
1460
+		}
1461
+		$this->addMetaBox(
1462
+			'edit-reg-registrant-mbox',
1463
+			esc_html__('Contact Details', 'event_espresso'),
1464
+			[$this, '_reg_registrant_side_meta_box'],
1465
+			$this->_wp_page_slug,
1466
+			'side'
1467
+		);
1468
+		if ($this->_registration->group_size() > 1) {
1469
+			$this->addMetaBox(
1470
+				'edit-reg-attendees-mbox',
1471
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1472
+				[$this, '_reg_attendees_meta_box'],
1473
+				$this->_wp_page_slug
1474
+			);
1475
+		}
1476
+	}
1477
+
1478
+
1479
+	/**
1480
+	 * set_reg_status_buttons_metabox
1481
+	 *
1482
+	 * @return void
1483
+	 * @throws EE_Error
1484
+	 * @throws EntityNotFoundException
1485
+	 * @throws InvalidArgumentException
1486
+	 * @throws InvalidDataTypeException
1487
+	 * @throws InvalidInterfaceException
1488
+	 * @throws ReflectionException
1489
+	 */
1490
+	public function set_reg_status_buttons_metabox()
1491
+	{
1492
+		$this->_set_registration_object();
1493
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1494
+		$output                 = $change_reg_status_form->form_open(
1495
+			self::add_query_args_and_nonce(
1496
+				[
1497
+					'action' => 'change_reg_status',
1498
+				],
1499
+				REG_ADMIN_URL
1500
+			)
1501
+		);
1502
+		$output                 .= $change_reg_status_form->get_html();
1503
+		$output                 .= $change_reg_status_form->form_close();
1504
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1505
+	}
1506
+
1507
+
1508
+	/**
1509
+	 * @return EE_Form_Section_Proper
1510
+	 * @throws EE_Error
1511
+	 * @throws InvalidArgumentException
1512
+	 * @throws InvalidDataTypeException
1513
+	 * @throws InvalidInterfaceException
1514
+	 * @throws EntityNotFoundException
1515
+	 * @throws ReflectionException
1516
+	 */
1517
+	protected function _generate_reg_status_change_form()
1518
+	{
1519
+		$reg_status_change_form_array = [
1520
+			'name'            => 'reg_status_change_form',
1521
+			'html_id'         => 'reg-status-change-form',
1522
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1523
+			'subsections'     => [
1524
+				'return'         => new EE_Hidden_Input(
1525
+					[
1526
+						'name'    => 'return',
1527
+						'default' => 'view_registration',
1528
+					]
1529
+				),
1530
+				'REG_ID'         => new EE_Hidden_Input(
1531
+					[
1532
+						'name'    => 'REG_ID',
1533
+						'default' => $this->_registration->ID(),
1534
+					]
1535
+				),
1536
+			],
1537
+		];
1538
+		if (
1539
+			EE_Registry::instance()->CAP->current_user_can(
1540
+				'ee_edit_registration',
1541
+				'toggle_registration_status',
1542
+				$this->_registration->ID()
1543
+			)
1544
+		) {
1545
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1546
+				$this->_get_reg_statuses(),
1547
+				[
1548
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1549
+					'default'         => $this->_registration->status_ID(),
1550
+				]
1551
+			);
1552
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1553
+				[
1554
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1555
+					'default'         => false,
1556
+					'html_help_text'  => esc_html__(
1557
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1558
+						'event_espresso'
1559
+					),
1560
+				]
1561
+			);
1562
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1563
+				[
1564
+					'html_class'      => 'button--primary',
1565
+					'html_label_text' => '&nbsp;',
1566
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1567
+				]
1568
+			);
1569
+		}
1570
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1571
+	}
1572
+
1573
+
1574
+	/**
1575
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1576
+	 *
1577
+	 * @return array
1578
+	 * @throws EE_Error
1579
+	 * @throws InvalidArgumentException
1580
+	 * @throws InvalidDataTypeException
1581
+	 * @throws InvalidInterfaceException
1582
+	 * @throws EntityNotFoundException
1583
+	 */
1584
+	protected function _get_reg_statuses()
1585
+	{
1586
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1587
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1588
+		// get current reg status
1589
+		$current_status = $this->_registration->status_ID();
1590
+		// is registration for free event? This will determine whether to display the pending payment option
1591
+		if (
1592
+			$current_status !== EEM_Registration::status_id_pending_payment
1593
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1594
+		) {
1595
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1596
+		}
1597
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1598
+	}
1599
+
1600
+
1601
+	/**
1602
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1603
+	 *
1604
+	 * @param bool $status REG status given for changing registrations to.
1605
+	 * @param bool $notify Whether to send messages notifications or not.
1606
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1607
+	 * @throws DomainException
1608
+	 * @throws EE_Error
1609
+	 * @throws EntityNotFoundException
1610
+	 * @throws InvalidArgumentException
1611
+	 * @throws InvalidDataTypeException
1612
+	 * @throws InvalidInterfaceException
1613
+	 * @throws ReflectionException
1614
+	 * @throws RuntimeException
1615
+	 */
1616
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1617
+	{
1618
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1619
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1620
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1621
+
1622
+		// sanitize $REG_IDs
1623
+		$REG_IDs = array_map('absint', $REG_IDs);
1624
+		// and remove empty entries
1625
+		$REG_IDs = array_filter($REG_IDs);
1626
+
1627
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1628
+
1629
+		/**
1630
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1631
+		 * Currently this value is used downstream by the _process_resend_registration method.
1632
+		 *
1633
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1634
+		 * @param bool                     $status           The status registrations were changed to.
1635
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1636
+		 * @param Registrations_Admin_Page $admin_page_object
1637
+		 */
1638
+		$REG_ID = apply_filters(
1639
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1640
+			$result['REG_ID'],
1641
+			$status,
1642
+			$result['success'],
1643
+			$this
1644
+		);
1645
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1646
+
1647
+		// notify?
1648
+		if (
1649
+			$notify
1650
+			&& $result['success']
1651
+			&& ! empty($REG_ID)
1652
+			&& EE_Registry::instance()->CAP->current_user_can(
1653
+				'ee_send_message',
1654
+				'espresso_registrations_resend_registration'
1655
+			)
1656
+		) {
1657
+			$this->_process_resend_registration();
1658
+		}
1659
+		return $result;
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1665
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1666
+	 *
1667
+	 * @param array  $REG_IDs
1668
+	 * @param string $status
1669
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1670
+	 *                       slug sent with setting the registration status.
1671
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1672
+	 * @throws EE_Error
1673
+	 * @throws InvalidArgumentException
1674
+	 * @throws InvalidDataTypeException
1675
+	 * @throws InvalidInterfaceException
1676
+	 * @throws ReflectionException
1677
+	 * @throws RuntimeException
1678
+	 * @throws EntityNotFoundException
1679
+	 * @throws DomainException
1680
+	 */
1681
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1682
+	{
1683
+		$success = false;
1684
+		// typecast $REG_IDs
1685
+		$REG_IDs = (array) $REG_IDs;
1686
+		if (! empty($REG_IDs)) {
1687
+			$success = true;
1688
+			// set default status if none is passed
1689
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1690
+			$status_context = $notify
1691
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1692
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1693
+			// loop through REG_ID's and change status
1694
+			foreach ($REG_IDs as $REG_ID) {
1695
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1696
+				if ($registration instanceof EE_Registration) {
1697
+					$registration->set_status(
1698
+						$status,
1699
+						false,
1700
+						new Context(
1701
+							$status_context,
1702
+							esc_html__(
1703
+								'Manually triggered status change on a Registration Admin Page route.',
1704
+								'event_espresso'
1705
+							)
1706
+						)
1707
+					);
1708
+					$result = $registration->save();
1709
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1710
+					$success = $result !== false ? $success : false;
1711
+				}
1712
+			}
1713
+		}
1714
+
1715
+		// return $success and processed registrations
1716
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1717
+	}
1718
+
1719
+
1720
+	/**
1721
+	 * Common logic for setting up success message and redirecting to appropriate route
1722
+	 *
1723
+	 * @param string $STS_ID status id for the registration changed to
1724
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1725
+	 * @return void
1726
+	 * @throws DomainException
1727
+	 * @throws EE_Error
1728
+	 * @throws EntityNotFoundException
1729
+	 * @throws InvalidArgumentException
1730
+	 * @throws InvalidDataTypeException
1731
+	 * @throws InvalidInterfaceException
1732
+	 * @throws ReflectionException
1733
+	 * @throws RuntimeException
1734
+	 */
1735
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1736
+	{
1737
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1738
+			: ['success' => false];
1739
+		$success = isset($result['success']) && $result['success'];
1740
+		// setup success message
1741
+		if ($success) {
1742
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1743
+				$msg = sprintf(
1744
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1745
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1746
+				);
1747
+			} else {
1748
+				$msg = sprintf(
1749
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1750
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1751
+				);
1752
+			}
1753
+			EE_Error::add_success($msg);
1754
+		} else {
1755
+			EE_Error::add_error(
1756
+				esc_html__(
1757
+					'Something went wrong, and the status was not changed',
1758
+					'event_espresso'
1759
+				),
1760
+				__FILE__,
1761
+				__LINE__,
1762
+				__FUNCTION__
1763
+			);
1764
+		}
1765
+		$return = $this->request->getRequestParam('return');
1766
+		$route  = $return === 'view_registration'
1767
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1768
+			: ['action' => 'default'];
1769
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1770
+		$this->_redirect_after_action($success, '', '', $route, true);
1771
+	}
1772
+
1773
+
1774
+	/**
1775
+	 * incoming reg status change from reg details page.
1776
+	 *
1777
+	 * @return void
1778
+	 * @throws EE_Error
1779
+	 * @throws EntityNotFoundException
1780
+	 * @throws InvalidArgumentException
1781
+	 * @throws InvalidDataTypeException
1782
+	 * @throws InvalidInterfaceException
1783
+	 * @throws ReflectionException
1784
+	 * @throws RuntimeException
1785
+	 * @throws DomainException
1786
+	 */
1787
+	protected function _change_reg_status()
1788
+	{
1789
+		$this->request->setRequestParam('return', 'view_registration');
1790
+		// set notify based on whether the send notifications toggle is set or not
1791
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1792
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1793
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1794
+		switch ($reg_status) {
1795
+			case EEM_Registration::status_id_approved:
1796
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1797
+				$this->approve_registration($notify);
1798
+				break;
1799
+			case EEM_Registration::status_id_pending_payment:
1800
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1801
+				$this->pending_registration($notify);
1802
+				break;
1803
+			case EEM_Registration::status_id_not_approved:
1804
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1805
+				$this->not_approve_registration($notify);
1806
+				break;
1807
+			case EEM_Registration::status_id_declined:
1808
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1809
+				$this->decline_registration($notify);
1810
+				break;
1811
+			case EEM_Registration::status_id_cancelled:
1812
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1813
+				$this->cancel_registration($notify);
1814
+				break;
1815
+			case EEM_Registration::status_id_wait_list:
1816
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1817
+				$this->wait_list_registration($notify);
1818
+				break;
1819
+			case EEM_Registration::status_id_incomplete:
1820
+			default:
1821
+				$this->request->unSetRequestParam('return');
1822
+				$this->_reg_status_change_return('');
1823
+				break;
1824
+		}
1825
+	}
1826
+
1827
+
1828
+	/**
1829
+	 * Callback for bulk action routes.
1830
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1831
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1832
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1833
+	 * when an action is happening on just a single registration).
1834
+	 *
1835
+	 * @param      $action
1836
+	 * @param bool $notify
1837
+	 */
1838
+	protected function bulk_action_on_registrations($action, $notify = false)
1839
+	{
1840
+		do_action(
1841
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1842
+			$this,
1843
+			$action,
1844
+			$notify
1845
+		);
1846
+		$method = $action . '_registration';
1847
+		if (method_exists($this, $method)) {
1848
+			$this->$method($notify);
1849
+		}
1850
+	}
1851
+
1852
+
1853
+	/**
1854
+	 * approve_registration
1855
+	 *
1856
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1857
+	 * @return void
1858
+	 * @throws EE_Error
1859
+	 * @throws EntityNotFoundException
1860
+	 * @throws InvalidArgumentException
1861
+	 * @throws InvalidDataTypeException
1862
+	 * @throws InvalidInterfaceException
1863
+	 * @throws ReflectionException
1864
+	 * @throws RuntimeException
1865
+	 * @throws DomainException
1866
+	 */
1867
+	protected function approve_registration($notify = false)
1868
+	{
1869
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1870
+	}
1871
+
1872
+
1873
+	/**
1874
+	 * decline_registration
1875
+	 *
1876
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1877
+	 * @return void
1878
+	 * @throws EE_Error
1879
+	 * @throws EntityNotFoundException
1880
+	 * @throws InvalidArgumentException
1881
+	 * @throws InvalidDataTypeException
1882
+	 * @throws InvalidInterfaceException
1883
+	 * @throws ReflectionException
1884
+	 * @throws RuntimeException
1885
+	 * @throws DomainException
1886
+	 */
1887
+	protected function decline_registration($notify = false)
1888
+	{
1889
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1890
+	}
1891
+
1892
+
1893
+	/**
1894
+	 * cancel_registration
1895
+	 *
1896
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1897
+	 * @return void
1898
+	 * @throws EE_Error
1899
+	 * @throws EntityNotFoundException
1900
+	 * @throws InvalidArgumentException
1901
+	 * @throws InvalidDataTypeException
1902
+	 * @throws InvalidInterfaceException
1903
+	 * @throws ReflectionException
1904
+	 * @throws RuntimeException
1905
+	 * @throws DomainException
1906
+	 */
1907
+	protected function cancel_registration($notify = false)
1908
+	{
1909
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1910
+	}
1911
+
1912
+
1913
+	/**
1914
+	 * not_approve_registration
1915
+	 *
1916
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1917
+	 * @return void
1918
+	 * @throws EE_Error
1919
+	 * @throws EntityNotFoundException
1920
+	 * @throws InvalidArgumentException
1921
+	 * @throws InvalidDataTypeException
1922
+	 * @throws InvalidInterfaceException
1923
+	 * @throws ReflectionException
1924
+	 * @throws RuntimeException
1925
+	 * @throws DomainException
1926
+	 */
1927
+	protected function not_approve_registration($notify = false)
1928
+	{
1929
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1930
+	}
1931
+
1932
+
1933
+	/**
1934
+	 * decline_registration
1935
+	 *
1936
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1937
+	 * @return void
1938
+	 * @throws EE_Error
1939
+	 * @throws EntityNotFoundException
1940
+	 * @throws InvalidArgumentException
1941
+	 * @throws InvalidDataTypeException
1942
+	 * @throws InvalidInterfaceException
1943
+	 * @throws ReflectionException
1944
+	 * @throws RuntimeException
1945
+	 * @throws DomainException
1946
+	 */
1947
+	protected function pending_registration($notify = false)
1948
+	{
1949
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1950
+	}
1951
+
1952
+
1953
+	/**
1954
+	 * waitlist_registration
1955
+	 *
1956
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1957
+	 * @return void
1958
+	 * @throws EE_Error
1959
+	 * @throws EntityNotFoundException
1960
+	 * @throws InvalidArgumentException
1961
+	 * @throws InvalidDataTypeException
1962
+	 * @throws InvalidInterfaceException
1963
+	 * @throws ReflectionException
1964
+	 * @throws RuntimeException
1965
+	 * @throws DomainException
1966
+	 */
1967
+	protected function wait_list_registration($notify = false)
1968
+	{
1969
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1970
+	}
1971
+
1972
+
1973
+	/**
1974
+	 * generates HTML for the Registration main meta box
1975
+	 *
1976
+	 * @return void
1977
+	 * @throws DomainException
1978
+	 * @throws EE_Error
1979
+	 * @throws InvalidArgumentException
1980
+	 * @throws InvalidDataTypeException
1981
+	 * @throws InvalidInterfaceException
1982
+	 * @throws ReflectionException
1983
+	 * @throws EntityNotFoundException
1984
+	 */
1985
+	public function _reg_details_meta_box()
1986
+	{
1987
+		EEH_Autoloader::register_line_item_display_autoloaders();
1988
+		EEH_Autoloader::register_line_item_filter_autoloaders();
1989
+		EE_Registry::instance()->load_helper('Line_Item');
1990
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1991
+			: EE_Transaction::new_instance();
1992
+		$this->_session = $transaction->session_data();
1993
+		$filters        = new EE_Line_Item_Filter_Collection();
1994
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1995
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
1996
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
1997
+			$filters,
1998
+			$transaction->total_line_item()
1999
+		);
2000
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2001
+		$line_item_display                       = new EE_Line_Item_Display(
2002
+			'reg_admin_table',
2003
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2004
+		);
2005
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2006
+			$filtered_line_item_tree,
2007
+			['EE_Registration' => $this->_registration]
2008
+		);
2009
+		$attendee                                = $this->_registration->attendee();
2010
+		if (
2011
+			EE_Registry::instance()->CAP->current_user_can(
2012
+				'ee_read_transaction',
2013
+				'espresso_transactions_view_transaction'
2014
+			)
2015
+		) {
2016
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2017
+				EE_Admin_Page::add_query_args_and_nonce(
2018
+					[
2019
+						'action' => 'view_transaction',
2020
+						'TXN_ID' => $transaction->ID(),
2021
+					],
2022
+					TXN_ADMIN_URL
2023
+				),
2024
+				esc_html__(' View Transaction', 'event_espresso'),
2025
+				'button button--secondary right',
2026
+				'dashicons dashicons-cart'
2027
+			);
2028
+		} else {
2029
+			$this->_template_args['view_transaction_button'] = '';
2030
+		}
2031
+		if (
2032
+			$attendee instanceof EE_Attendee
2033
+			&& EE_Registry::instance()->CAP->current_user_can(
2034
+				'ee_send_message',
2035
+				'espresso_registrations_resend_registration'
2036
+			)
2037
+		) {
2038
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2039
+				EE_Admin_Page::add_query_args_and_nonce(
2040
+					[
2041
+						'action'      => 'resend_registration',
2042
+						'_REG_ID'     => $this->_registration->ID(),
2043
+						'redirect_to' => 'view_registration',
2044
+					],
2045
+					REG_ADMIN_URL
2046
+				),
2047
+				esc_html__(' Resend Registration', 'event_espresso'),
2048
+				'button button--secondary right',
2049
+				'dashicons dashicons-email-alt'
2050
+			);
2051
+		} else {
2052
+			$this->_template_args['resend_registration_button'] = '';
2053
+		}
2054
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2055
+		$payment                               = $transaction->get_first_related('Payment');
2056
+		$payment                               = ! $payment instanceof EE_Payment
2057
+			? EE_Payment::new_instance()
2058
+			: $payment;
2059
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2060
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2061
+			? EE_Payment_Method::new_instance()
2062
+			: $payment_method;
2063
+		$reg_details                           = [
2064
+			'payment_method'       => $payment_method->name(),
2065
+			'response_msg'         => $payment->gateway_response(),
2066
+			'registration_id'      => $this->_registration->get('REG_code'),
2067
+			'registration_session' => $this->_registration->session_ID(),
2068
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2069
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2070
+		];
2071
+		if (isset($reg_details['registration_id'])) {
2072
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2073
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2074
+				'Registration ID',
2075
+				'event_espresso'
2076
+			);
2077
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2078
+		}
2079
+		if (isset($reg_details['payment_method'])) {
2080
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2081
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2082
+				'Most Recent Payment Method',
2083
+				'event_espresso'
2084
+			);
2085
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2086
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2087
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2088
+				'Payment method response',
2089
+				'event_espresso'
2090
+			);
2091
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2092
+		}
2093
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2094
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2095
+			'Registration Session',
2096
+			'event_espresso'
2097
+		);
2098
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2099
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2100
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2101
+			'Registration placed from IP',
2102
+			'event_espresso'
2103
+		);
2104
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2105
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2106
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2107
+			'Registrant User Agent',
2108
+			'event_espresso'
2109
+		);
2110
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2111
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2112
+			[
2113
+				'action'   => 'default',
2114
+				'event_id' => $this->_registration->event_ID(),
2115
+			],
2116
+			REG_ADMIN_URL
2117
+		);
2118
+
2119
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2120
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2121
+
2122
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2123
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2124
+	}
2125
+
2126
+
2127
+	/**
2128
+	 * generates HTML for the Registration Questions meta box.
2129
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2130
+	 * otherwise uses new forms system
2131
+	 *
2132
+	 * @return void
2133
+	 * @throws DomainException
2134
+	 * @throws EE_Error
2135
+	 * @throws InvalidArgumentException
2136
+	 * @throws InvalidDataTypeException
2137
+	 * @throws InvalidInterfaceException
2138
+	 * @throws ReflectionException
2139
+	 */
2140
+	public function _reg_questions_meta_box()
2141
+	{
2142
+		// allow someone to override this method entirely
2143
+		if (
2144
+			apply_filters(
2145
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2146
+				true,
2147
+				$this,
2148
+				$this->_registration
2149
+			)
2150
+		) {
2151
+			$form = $this->_get_reg_custom_questions_form(
2152
+				$this->_registration->ID()
2153
+			);
2154
+
2155
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2156
+				? $form->get_html_and_js()
2157
+				: '';
2158
+
2159
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2160
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2161
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2162
+			EEH_Template::display_template($template_path, $this->_template_args);
2163
+		}
2164
+	}
2165
+
2166
+
2167
+	/**
2168
+	 * form_before_question_group
2169
+	 *
2170
+	 * @param string $output
2171
+	 * @return        string
2172
+	 * @deprecated    as of 4.8.32.rc.000
2173
+	 */
2174
+	public function form_before_question_group($output)
2175
+	{
2176
+		EE_Error::doing_it_wrong(
2177
+			__CLASS__ . '::' . __FUNCTION__,
2178
+			esc_html__(
2179
+				'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.',
2180
+				'event_espresso'
2181
+			),
2182
+			'4.8.32.rc.000'
2183
+		);
2184
+		return '
2185 2185
 	<table class="form-table ee-width-100">
2186 2186
 		<tbody>
2187 2187
 			';
2188
-    }
2189
-
2190
-
2191
-    /**
2192
-     * form_after_question_group
2193
-     *
2194
-     * @param string $output
2195
-     * @return        string
2196
-     * @deprecated    as of 4.8.32.rc.000
2197
-     */
2198
-    public function form_after_question_group($output)
2199
-    {
2200
-        EE_Error::doing_it_wrong(
2201
-            __CLASS__ . '::' . __FUNCTION__,
2202
-            esc_html__(
2203
-                '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.',
2204
-                'event_espresso'
2205
-            ),
2206
-            '4.8.32.rc.000'
2207
-        );
2208
-        return '
2188
+	}
2189
+
2190
+
2191
+	/**
2192
+	 * form_after_question_group
2193
+	 *
2194
+	 * @param string $output
2195
+	 * @return        string
2196
+	 * @deprecated    as of 4.8.32.rc.000
2197
+	 */
2198
+	public function form_after_question_group($output)
2199
+	{
2200
+		EE_Error::doing_it_wrong(
2201
+			__CLASS__ . '::' . __FUNCTION__,
2202
+			esc_html__(
2203
+				'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.',
2204
+				'event_espresso'
2205
+			),
2206
+			'4.8.32.rc.000'
2207
+		);
2208
+		return '
2209 2209
 			<tr class="hide-if-no-js">
2210 2210
 				<th> </th>
2211 2211
 				<td class="reg-admin-edit-attendee-question-td">
2212 2212
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2213
-               . esc_attr__('click to edit question', 'event_espresso')
2214
-               . '">
2213
+			   . esc_attr__('click to edit question', 'event_espresso')
2214
+			   . '">
2215 2215
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2216
-               . esc_html__('edit the above question group', 'event_espresso')
2217
-               . '</span>
2216
+			   . esc_html__('edit the above question group', 'event_espresso')
2217
+			   . '</span>
2218 2218
 						<div class="dashicons dashicons-edit"></div>
2219 2219
 					</a>
2220 2220
 				</td>
@@ -2222,636 +2222,636 @@  discard block
 block discarded – undo
2222 2222
 		</tbody>
2223 2223
 	</table>
2224 2224
 ';
2225
-    }
2226
-
2227
-
2228
-    /**
2229
-     * form_form_field_label_wrap
2230
-     *
2231
-     * @param string $label
2232
-     * @return        string
2233
-     * @deprecated    as of 4.8.32.rc.000
2234
-     */
2235
-    public function form_form_field_label_wrap($label)
2236
-    {
2237
-        EE_Error::doing_it_wrong(
2238
-            __CLASS__ . '::' . __FUNCTION__,
2239
-            esc_html__(
2240
-                '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.',
2241
-                'event_espresso'
2242
-            ),
2243
-            '4.8.32.rc.000'
2244
-        );
2245
-        return '
2225
+	}
2226
+
2227
+
2228
+	/**
2229
+	 * form_form_field_label_wrap
2230
+	 *
2231
+	 * @param string $label
2232
+	 * @return        string
2233
+	 * @deprecated    as of 4.8.32.rc.000
2234
+	 */
2235
+	public function form_form_field_label_wrap($label)
2236
+	{
2237
+		EE_Error::doing_it_wrong(
2238
+			__CLASS__ . '::' . __FUNCTION__,
2239
+			esc_html__(
2240
+				'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.',
2241
+				'event_espresso'
2242
+			),
2243
+			'4.8.32.rc.000'
2244
+		);
2245
+		return '
2246 2246
 			<tr>
2247 2247
 				<th>
2248 2248
 					' . $label . '
2249 2249
 				</th>';
2250
-    }
2251
-
2252
-
2253
-    /**
2254
-     * form_form_field_input__wrap
2255
-     *
2256
-     * @param string $input
2257
-     * @return        string
2258
-     * @deprecated    as of 4.8.32.rc.000
2259
-     */
2260
-    public function form_form_field_input__wrap($input)
2261
-    {
2262
-        EE_Error::doing_it_wrong(
2263
-            __CLASS__ . '::' . __FUNCTION__,
2264
-            esc_html__(
2265
-                '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.',
2266
-                'event_espresso'
2267
-            ),
2268
-            '4.8.32.rc.000'
2269
-        );
2270
-        return '
2250
+	}
2251
+
2252
+
2253
+	/**
2254
+	 * form_form_field_input__wrap
2255
+	 *
2256
+	 * @param string $input
2257
+	 * @return        string
2258
+	 * @deprecated    as of 4.8.32.rc.000
2259
+	 */
2260
+	public function form_form_field_input__wrap($input)
2261
+	{
2262
+		EE_Error::doing_it_wrong(
2263
+			__CLASS__ . '::' . __FUNCTION__,
2264
+			esc_html__(
2265
+				'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.',
2266
+				'event_espresso'
2267
+			),
2268
+			'4.8.32.rc.000'
2269
+		);
2270
+		return '
2271 2271
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2272 2272
 					' . $input . '
2273 2273
 				</td>
2274 2274
 			</tr>';
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2280
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2281
-     * to display the page
2282
-     *
2283
-     * @return void
2284
-     * @throws EE_Error
2285
-     * @throws InvalidArgumentException
2286
-     * @throws InvalidDataTypeException
2287
-     * @throws InvalidInterfaceException
2288
-     * @throws ReflectionException
2289
-     */
2290
-    protected function _update_attendee_registration_form()
2291
-    {
2292
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2293
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2294
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2295
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2296
-            if ($success) {
2297
-                $what  = esc_html__('Registration Form', 'event_espresso');
2298
-                $route = $REG_ID
2299
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2300
-                    : ['action' => 'default'];
2301
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2302
-            }
2303
-        }
2304
-    }
2305
-
2306
-
2307
-    /**
2308
-     * Gets the form for saving registrations custom questions (if done
2309
-     * previously retrieves the cached form object, which may have validation errors in it)
2310
-     *
2311
-     * @param int $REG_ID
2312
-     * @return EE_Registration_Custom_Questions_Form
2313
-     * @throws EE_Error
2314
-     * @throws InvalidArgumentException
2315
-     * @throws InvalidDataTypeException
2316
-     * @throws InvalidInterfaceException
2317
-     * @throws ReflectionException
2318
-     */
2319
-    protected function _get_reg_custom_questions_form($REG_ID)
2320
-    {
2321
-        if (! $this->_reg_custom_questions_form) {
2322
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2323
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2324
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2325
-            );
2326
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2327
-        }
2328
-        return $this->_reg_custom_questions_form;
2329
-    }
2330
-
2331
-
2332
-    /**
2333
-     * Saves
2334
-     *
2335
-     * @param bool $REG_ID
2336
-     * @return bool
2337
-     * @throws EE_Error
2338
-     * @throws InvalidArgumentException
2339
-     * @throws InvalidDataTypeException
2340
-     * @throws InvalidInterfaceException
2341
-     * @throws ReflectionException
2342
-     */
2343
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2344
-    {
2345
-        if (! $REG_ID) {
2346
-            EE_Error::add_error(
2347
-                esc_html__(
2348
-                    'An error occurred. No registration ID was received.',
2349
-                    'event_espresso'
2350
-                ),
2351
-                __FILE__,
2352
-                __FUNCTION__,
2353
-                __LINE__
2354
-            );
2355
-        }
2356
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2357
-        $form->receive_form_submission($this->request->requestParams());
2358
-        $success = false;
2359
-        if ($form->is_valid()) {
2360
-            foreach ($form->subforms() as $question_group_form) {
2361
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2362
-                    $where_conditions    = [
2363
-                        'QST_ID' => $question_id,
2364
-                        'REG_ID' => $REG_ID,
2365
-                    ];
2366
-                    $possibly_new_values = [
2367
-                        'ANS_value' => $input->normalized_value(),
2368
-                    ];
2369
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2370
-                    if ($answer instanceof EE_Answer) {
2371
-                        $success = $answer->save($possibly_new_values);
2372
-                    } else {
2373
-                        // insert it then
2374
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2375
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2376
-                        $success     = $answer->save();
2377
-                    }
2378
-                }
2379
-            }
2380
-        } else {
2381
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2382
-        }
2383
-        return $success;
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * generates HTML for the Registration main meta box
2389
-     *
2390
-     * @return void
2391
-     * @throws DomainException
2392
-     * @throws EE_Error
2393
-     * @throws InvalidArgumentException
2394
-     * @throws InvalidDataTypeException
2395
-     * @throws InvalidInterfaceException
2396
-     * @throws ReflectionException
2397
-     */
2398
-    public function _reg_attendees_meta_box()
2399
-    {
2400
-        $REG = $this->getRegistrationModel();
2401
-        // get all other registrations on this transaction, and cache
2402
-        // the attendees for them so we don't have to run another query using force_join
2403
-        $registrations                           = $REG->get_all(
2404
-            [
2405
-                [
2406
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2407
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2408
-                ],
2409
-                'force_join'               => ['Attendee'],
2410
-                'default_where_conditions' => 'other_models_only',
2411
-            ]
2412
-        );
2413
-        $this->_template_args['attendees']       = [];
2414
-        $this->_template_args['attendee_notice'] = '';
2415
-        if (
2416
-            empty($registrations)
2417
-            || (is_array($registrations)
2418
-                && ! EEH_Array::get_one_item_from_array($registrations))
2419
-        ) {
2420
-            EE_Error::add_error(
2421
-                esc_html__(
2422
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2423
-                    'event_espresso'
2424
-                ),
2425
-                __FILE__,
2426
-                __FUNCTION__,
2427
-                __LINE__
2428
-            );
2429
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2430
-        } else {
2431
-            $att_nmbr = 1;
2432
-            foreach ($registrations as $registration) {
2433
-                /* @var $registration EE_Registration */
2434
-                $attendee                                                      = $registration->attendee()
2435
-                    ? $registration->attendee()
2436
-                    : $this->getAttendeeModel()->create_default_object();
2437
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2438
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2439
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2440
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2441
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2442
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2443
-                    ', ',
2444
-                    $attendee->full_address_as_array()
2445
-                );
2446
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2447
-                    [
2448
-                        'action' => 'edit_attendee',
2449
-                        'post'   => $attendee->ID(),
2450
-                    ],
2451
-                    REG_ADMIN_URL
2452
-                );
2453
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2454
-                    $registration->event_obj() instanceof EE_Event
2455
-                        ? $registration->event_obj()->name()
2456
-                        : '';
2457
-                $att_nmbr++;
2458
-            }
2459
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2460
-        }
2461
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2462
-        EEH_Template::display_template($template_path, $this->_template_args);
2463
-    }
2464
-
2465
-
2466
-    /**
2467
-     * generates HTML for the Edit Registration side meta box
2468
-     *
2469
-     * @return void
2470
-     * @throws DomainException
2471
-     * @throws EE_Error
2472
-     * @throws InvalidArgumentException
2473
-     * @throws InvalidDataTypeException
2474
-     * @throws InvalidInterfaceException
2475
-     * @throws ReflectionException
2476
-     */
2477
-    public function _reg_registrant_side_meta_box()
2478
-    {
2479
-        /*@var $attendee EE_Attendee */
2480
-        $att_check = $this->_registration->attendee();
2481
-        $attendee  = $att_check instanceof EE_Attendee
2482
-            ? $att_check
2483
-            : $this->getAttendeeModel()->create_default_object();
2484
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2485
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2486
-        // primary registration object (that way we know if we need to show create button or not)
2487
-        if (! $this->_registration->is_primary_registrant()) {
2488
-            $primary_registration = $this->_registration->get_primary_registration();
2489
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2490
-                : null;
2491
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2492
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2493
-                // custom attendee object so let's not worry about the primary reg.
2494
-                $primary_registration = null;
2495
-            }
2496
-        } else {
2497
-            $primary_registration = null;
2498
-        }
2499
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2500
-        $this->_template_args['fname']             = $attendee->fname();
2501
-        $this->_template_args['lname']             = $attendee->lname();
2502
-        $this->_template_args['email']             = $attendee->email();
2503
-        $this->_template_args['phone']             = $attendee->phone();
2504
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2505
-        // edit link
2506
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2507
-            [
2508
-                'action' => 'edit_attendee',
2509
-                'post'   => $attendee->ID(),
2510
-            ],
2511
-            REG_ADMIN_URL
2512
-        );
2513
-        $this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2514
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2515
-        // create link
2516
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2517
-            ? EE_Admin_Page::add_query_args_and_nonce(
2518
-                [
2519
-                    'action'  => 'duplicate_attendee',
2520
-                    '_REG_ID' => $this->_registration->ID(),
2521
-                ],
2522
-                REG_ADMIN_URL
2523
-            ) : '';
2524
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2525
-        $this->_template_args['att_check'] = $att_check;
2526
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2527
-        EEH_Template::display_template($template_path, $this->_template_args);
2528
-    }
2529
-
2530
-
2531
-    /**
2532
-     * trash or restore registrations
2533
-     *
2534
-     * @param boolean $trash whether to archive or restore
2535
-     * @return void
2536
-     * @throws EE_Error
2537
-     * @throws InvalidArgumentException
2538
-     * @throws InvalidDataTypeException
2539
-     * @throws InvalidInterfaceException
2540
-     * @throws RuntimeException
2541
-     */
2542
-    protected function _trash_or_restore_registrations($trash = true)
2543
-    {
2544
-        // if empty _REG_ID then get out because there's nothing to do
2545
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2546
-        if (empty($REG_IDs)) {
2547
-            EE_Error::add_error(
2548
-                sprintf(
2549
-                    esc_html__(
2550
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2551
-                        'event_espresso'
2552
-                    ),
2553
-                    $trash ? 'trash' : 'restore'
2554
-                ),
2555
-                __FILE__,
2556
-                __LINE__,
2557
-                __FUNCTION__
2558
-            );
2559
-            $this->_redirect_after_action(false, '', '', [], true);
2560
-        }
2561
-        $success        = 0;
2562
-        $overwrite_msgs = false;
2563
-        // Checkboxes
2564
-        $reg_count = count($REG_IDs);
2565
-        // cycle thru checkboxes
2566
-        foreach ($REG_IDs as $REG_ID) {
2567
-            /** @var EE_Registration $REG */
2568
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2569
-            $payments = $REG->registration_payments();
2570
-            if (! empty($payments)) {
2571
-                $name           = $REG->attendee() instanceof EE_Attendee
2572
-                    ? $REG->attendee()->full_name()
2573
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2574
-                $overwrite_msgs = true;
2575
-                EE_Error::add_error(
2576
-                    sprintf(
2577
-                        esc_html__(
2578
-                            '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.',
2579
-                            'event_espresso'
2580
-                        ),
2581
-                        $name
2582
-                    ),
2583
-                    __FILE__,
2584
-                    __FUNCTION__,
2585
-                    __LINE__
2586
-                );
2587
-                // can't trash this registration because it has payments.
2588
-                continue;
2589
-            }
2590
-            $updated = $trash ? $REG->delete() : $REG->restore();
2591
-            if ($updated) {
2592
-                $success++;
2593
-            }
2594
-        }
2595
-        $this->_redirect_after_action(
2596
-            $success === $reg_count, // were ALL registrations affected?
2597
-            $success > 1
2598
-                ? esc_html__('Registrations', 'event_espresso')
2599
-                : esc_html__('Registration', 'event_espresso'),
2600
-            $trash
2601
-                ? esc_html__('moved to the trash', 'event_espresso')
2602
-                : esc_html__('restored', 'event_espresso'),
2603
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2604
-            $overwrite_msgs
2605
-        );
2606
-    }
2607
-
2608
-
2609
-    /**
2610
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2611
-     * registration but also.
2612
-     * 1. Removing relations to EE_Attendee
2613
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2614
-     * ALSO trashed.
2615
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2616
-     * 4. Removing relationships between all tickets and the related registrations
2617
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2618
-     * 6. Deleting permanently any related Checkins.
2619
-     *
2620
-     * @return void
2621
-     * @throws EE_Error
2622
-     * @throws InvalidArgumentException
2623
-     * @throws InvalidDataTypeException
2624
-     * @throws InvalidInterfaceException
2625
-     * @throws ReflectionException
2626
-     */
2627
-    protected function _delete_registrations()
2628
-    {
2629
-        $REG_MDL = $this->getRegistrationModel();
2630
-        $success = 0;
2631
-        // Checkboxes
2632
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2633
-
2634
-        if (! empty($REG_IDs)) {
2635
-            // if array has more than one element than success message should be plural
2636
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2637
-            // cycle thru checkboxes
2638
-            foreach ($REG_IDs as $REG_ID) {
2639
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2640
-                if (! $REG instanceof EE_Registration) {
2641
-                    continue;
2642
-                }
2643
-                $deleted = $this->_delete_registration($REG);
2644
-                if (! $deleted) {
2645
-                    $success = 0;
2646
-                }
2647
-            }
2648
-        }
2649
-
2650
-        $what        = $success > 1
2651
-            ? esc_html__('Registrations', 'event_espresso')
2652
-            : esc_html__('Registration', 'event_espresso');
2653
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2654
-        $this->_redirect_after_action(
2655
-            $success,
2656
-            $what,
2657
-            $action_desc,
2658
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2659
-            true
2660
-        );
2661
-    }
2662
-
2663
-
2664
-    /**
2665
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2666
-     * models get affected.
2667
-     *
2668
-     * @param EE_Registration $REG registration to be deleted permanently
2669
-     * @return bool true = successful deletion, false = fail.
2670
-     * @throws EE_Error
2671
-     * @throws InvalidArgumentException
2672
-     * @throws InvalidDataTypeException
2673
-     * @throws InvalidInterfaceException
2674
-     * @throws ReflectionException
2675
-     */
2676
-    protected function _delete_registration(EE_Registration $REG)
2677
-    {
2678
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2679
-        // registrations on the transaction that are NOT trashed.
2680
-        $TXN = $REG->get_first_related('Transaction');
2681
-        if (! $TXN instanceof EE_Transaction) {
2682
-            EE_Error::add_error(
2683
-                sprintf(
2684
-                    esc_html__(
2685
-                        '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.',
2686
-                        'event_espresso'
2687
-                    ),
2688
-                    $REG->id()
2689
-                ),
2690
-                __FILE__,
2691
-                __FUNCTION__,
2692
-                __LINE__
2693
-            );
2694
-            return false;
2695
-        }
2696
-        $REGS        = $TXN->get_many_related('Registration');
2697
-        $all_trashed = true;
2698
-        foreach ($REGS as $registration) {
2699
-            if (! $registration->get('REG_deleted')) {
2700
-                $all_trashed = false;
2701
-            }
2702
-        }
2703
-        if (! $all_trashed) {
2704
-            EE_Error::add_error(
2705
-                esc_html__(
2706
-                    '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.',
2707
-                    'event_espresso'
2708
-                ),
2709
-                __FILE__,
2710
-                __FUNCTION__,
2711
-                __LINE__
2712
-            );
2713
-            return false;
2714
-        }
2715
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2716
-        // separately from THIS one).
2717
-        foreach ($REGS as $registration) {
2718
-            // delete related answers
2719
-            $registration->delete_related_permanently('Answer');
2720
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2721
-            $attendee = $registration->get_first_related('Attendee');
2722
-            if ($attendee instanceof EE_Attendee) {
2723
-                $registration->_remove_relation_to($attendee, 'Attendee');
2724
-            }
2725
-            // now remove relationships to tickets on this registration.
2726
-            $registration->_remove_relations('Ticket');
2727
-            // now delete permanently the checkins related to this registration.
2728
-            $registration->delete_related_permanently('Checkin');
2729
-            if ($registration->ID() === $REG->ID()) {
2730
-                continue;
2731
-            } //we don't want to delete permanently the existing registration just yet.
2732
-            // remove relation to transaction for these registrations if NOT the existing registrations
2733
-            $registration->_remove_relations('Transaction');
2734
-            // delete permanently any related messages.
2735
-            $registration->delete_related_permanently('Message');
2736
-            // now delete this registration permanently
2737
-            $registration->delete_permanently();
2738
-        }
2739
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2740
-        // (the transaction and line items should be all that's left).
2741
-        // delete the line items related to the transaction for this registration.
2742
-        $TXN->delete_related_permanently('Line_Item');
2743
-        // we need to remove all the relationships on the transaction
2744
-        $TXN->delete_related_permanently('Payment');
2745
-        $TXN->delete_related_permanently('Extra_Meta');
2746
-        $TXN->delete_related_permanently('Message');
2747
-        // now we can delete this REG permanently (and the transaction of course)
2748
-        $REG->delete_related_permanently('Transaction');
2749
-        return $REG->delete_permanently();
2750
-    }
2751
-
2752
-
2753
-    /**
2754
-     *    generates HTML for the Register New Attendee Admin page
2755
-     *
2756
-     * @throws DomainException
2757
-     * @throws EE_Error
2758
-     * @throws InvalidArgumentException
2759
-     * @throws InvalidDataTypeException
2760
-     * @throws InvalidInterfaceException
2761
-     * @throws ReflectionException
2762
-     */
2763
-    public function new_registration()
2764
-    {
2765
-        if (! $this->_set_reg_event()) {
2766
-            throw new EE_Error(
2767
-                esc_html__(
2768
-                    'Unable to continue with registering because there is no Event ID in the request',
2769
-                    'event_espresso'
2770
-                )
2771
-            );
2772
-        }
2773
-        /** @var CurrentPage $current_page */
2774
-        $current_page = $this->loader->getShared(CurrentPage::class);
2775
-        $current_page->setEspressoPage(true);
2776
-        // gotta start with a clean slate if we're not coming here via ajax
2777
-        if (
2778
-            ! $this->request->isAjax()
2779
-            && (
2780
-                ! $this->request->requestParamIsSet('processing_registration')
2781
-                || $this->request->requestParamIsSet('step_error')
2782
-            )
2783
-        ) {
2784
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2785
-        }
2786
-        $this->_template_args['event_name'] = '';
2787
-        // event name
2788
-        if ($this->_reg_event) {
2789
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2790
-            $edit_event_url                     = self::add_query_args_and_nonce(
2791
-                [
2792
-                    'action' => 'edit',
2793
-                    'post'   => $this->_reg_event->ID(),
2794
-                ],
2795
-                EVENTS_ADMIN_URL
2796
-            );
2797
-            $edit_event_lnk                     = '<a href="'
2798
-                                                  . $edit_event_url
2799
-                                                  . '" title="'
2800
-                                                  . esc_attr__('Edit ', 'event_espresso')
2801
-                                                  . $this->_reg_event->name()
2802
-                                                  . '">'
2803
-                                                  . esc_html__('Edit Event', 'event_espresso')
2804
-                                                  . '</a>';
2805
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2806
-                                                   . $edit_event_lnk
2807
-                                                   . '</span>';
2808
-        }
2809
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2810
-        if ($this->request->isAjax()) {
2811
-            $this->_return_json();
2812
-        }
2813
-        // grab header
2814
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2815
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2816
-            $template_path,
2817
-            $this->_template_args,
2818
-            true
2819
-        );
2820
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2821
-        // the details template wrapper
2822
-        $this->display_admin_page_with_sidebar();
2823
-    }
2824
-
2825
-
2826
-    /**
2827
-     * This returns the content for a registration step
2828
-     *
2829
-     * @return string html
2830
-     * @throws DomainException
2831
-     * @throws EE_Error
2832
-     * @throws InvalidArgumentException
2833
-     * @throws InvalidDataTypeException
2834
-     * @throws InvalidInterfaceException
2835
-     * @throws ReflectionException
2836
-     */
2837
-    protected function _get_registration_step_content()
2838
-    {
2839
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2840
-            $warning_msg = sprintf(
2841
-                esc_html__(
2842
-                    '%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',
2843
-                    'event_espresso'
2844
-                ),
2845
-                '<br />',
2846
-                '<h3 class="important-notice">',
2847
-                '</h3>',
2848
-                '<div class="float-right">',
2849
-                '<span id="redirect_timer" class="important-notice">30</span>',
2850
-                '</div>',
2851
-                '<b>',
2852
-                '</b>'
2853
-            );
2854
-            return '
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2280
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2281
+	 * to display the page
2282
+	 *
2283
+	 * @return void
2284
+	 * @throws EE_Error
2285
+	 * @throws InvalidArgumentException
2286
+	 * @throws InvalidDataTypeException
2287
+	 * @throws InvalidInterfaceException
2288
+	 * @throws ReflectionException
2289
+	 */
2290
+	protected function _update_attendee_registration_form()
2291
+	{
2292
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2293
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2294
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2295
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2296
+			if ($success) {
2297
+				$what  = esc_html__('Registration Form', 'event_espresso');
2298
+				$route = $REG_ID
2299
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2300
+					: ['action' => 'default'];
2301
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2302
+			}
2303
+		}
2304
+	}
2305
+
2306
+
2307
+	/**
2308
+	 * Gets the form for saving registrations custom questions (if done
2309
+	 * previously retrieves the cached form object, which may have validation errors in it)
2310
+	 *
2311
+	 * @param int $REG_ID
2312
+	 * @return EE_Registration_Custom_Questions_Form
2313
+	 * @throws EE_Error
2314
+	 * @throws InvalidArgumentException
2315
+	 * @throws InvalidDataTypeException
2316
+	 * @throws InvalidInterfaceException
2317
+	 * @throws ReflectionException
2318
+	 */
2319
+	protected function _get_reg_custom_questions_form($REG_ID)
2320
+	{
2321
+		if (! $this->_reg_custom_questions_form) {
2322
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2323
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2324
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2325
+			);
2326
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2327
+		}
2328
+		return $this->_reg_custom_questions_form;
2329
+	}
2330
+
2331
+
2332
+	/**
2333
+	 * Saves
2334
+	 *
2335
+	 * @param bool $REG_ID
2336
+	 * @return bool
2337
+	 * @throws EE_Error
2338
+	 * @throws InvalidArgumentException
2339
+	 * @throws InvalidDataTypeException
2340
+	 * @throws InvalidInterfaceException
2341
+	 * @throws ReflectionException
2342
+	 */
2343
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2344
+	{
2345
+		if (! $REG_ID) {
2346
+			EE_Error::add_error(
2347
+				esc_html__(
2348
+					'An error occurred. No registration ID was received.',
2349
+					'event_espresso'
2350
+				),
2351
+				__FILE__,
2352
+				__FUNCTION__,
2353
+				__LINE__
2354
+			);
2355
+		}
2356
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2357
+		$form->receive_form_submission($this->request->requestParams());
2358
+		$success = false;
2359
+		if ($form->is_valid()) {
2360
+			foreach ($form->subforms() as $question_group_form) {
2361
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2362
+					$where_conditions    = [
2363
+						'QST_ID' => $question_id,
2364
+						'REG_ID' => $REG_ID,
2365
+					];
2366
+					$possibly_new_values = [
2367
+						'ANS_value' => $input->normalized_value(),
2368
+					];
2369
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2370
+					if ($answer instanceof EE_Answer) {
2371
+						$success = $answer->save($possibly_new_values);
2372
+					} else {
2373
+						// insert it then
2374
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2375
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2376
+						$success     = $answer->save();
2377
+					}
2378
+				}
2379
+			}
2380
+		} else {
2381
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2382
+		}
2383
+		return $success;
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * generates HTML for the Registration main meta box
2389
+	 *
2390
+	 * @return void
2391
+	 * @throws DomainException
2392
+	 * @throws EE_Error
2393
+	 * @throws InvalidArgumentException
2394
+	 * @throws InvalidDataTypeException
2395
+	 * @throws InvalidInterfaceException
2396
+	 * @throws ReflectionException
2397
+	 */
2398
+	public function _reg_attendees_meta_box()
2399
+	{
2400
+		$REG = $this->getRegistrationModel();
2401
+		// get all other registrations on this transaction, and cache
2402
+		// the attendees for them so we don't have to run another query using force_join
2403
+		$registrations                           = $REG->get_all(
2404
+			[
2405
+				[
2406
+					'TXN_ID' => $this->_registration->transaction_ID(),
2407
+					'REG_ID' => ['!=', $this->_registration->ID()],
2408
+				],
2409
+				'force_join'               => ['Attendee'],
2410
+				'default_where_conditions' => 'other_models_only',
2411
+			]
2412
+		);
2413
+		$this->_template_args['attendees']       = [];
2414
+		$this->_template_args['attendee_notice'] = '';
2415
+		if (
2416
+			empty($registrations)
2417
+			|| (is_array($registrations)
2418
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2419
+		) {
2420
+			EE_Error::add_error(
2421
+				esc_html__(
2422
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2423
+					'event_espresso'
2424
+				),
2425
+				__FILE__,
2426
+				__FUNCTION__,
2427
+				__LINE__
2428
+			);
2429
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2430
+		} else {
2431
+			$att_nmbr = 1;
2432
+			foreach ($registrations as $registration) {
2433
+				/* @var $registration EE_Registration */
2434
+				$attendee                                                      = $registration->attendee()
2435
+					? $registration->attendee()
2436
+					: $this->getAttendeeModel()->create_default_object();
2437
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2438
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2439
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2440
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2441
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2442
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2443
+					', ',
2444
+					$attendee->full_address_as_array()
2445
+				);
2446
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2447
+					[
2448
+						'action' => 'edit_attendee',
2449
+						'post'   => $attendee->ID(),
2450
+					],
2451
+					REG_ADMIN_URL
2452
+				);
2453
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2454
+					$registration->event_obj() instanceof EE_Event
2455
+						? $registration->event_obj()->name()
2456
+						: '';
2457
+				$att_nmbr++;
2458
+			}
2459
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2460
+		}
2461
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2462
+		EEH_Template::display_template($template_path, $this->_template_args);
2463
+	}
2464
+
2465
+
2466
+	/**
2467
+	 * generates HTML for the Edit Registration side meta box
2468
+	 *
2469
+	 * @return void
2470
+	 * @throws DomainException
2471
+	 * @throws EE_Error
2472
+	 * @throws InvalidArgumentException
2473
+	 * @throws InvalidDataTypeException
2474
+	 * @throws InvalidInterfaceException
2475
+	 * @throws ReflectionException
2476
+	 */
2477
+	public function _reg_registrant_side_meta_box()
2478
+	{
2479
+		/*@var $attendee EE_Attendee */
2480
+		$att_check = $this->_registration->attendee();
2481
+		$attendee  = $att_check instanceof EE_Attendee
2482
+			? $att_check
2483
+			: $this->getAttendeeModel()->create_default_object();
2484
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2485
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2486
+		// primary registration object (that way we know if we need to show create button or not)
2487
+		if (! $this->_registration->is_primary_registrant()) {
2488
+			$primary_registration = $this->_registration->get_primary_registration();
2489
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2490
+				: null;
2491
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2492
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2493
+				// custom attendee object so let's not worry about the primary reg.
2494
+				$primary_registration = null;
2495
+			}
2496
+		} else {
2497
+			$primary_registration = null;
2498
+		}
2499
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2500
+		$this->_template_args['fname']             = $attendee->fname();
2501
+		$this->_template_args['lname']             = $attendee->lname();
2502
+		$this->_template_args['email']             = $attendee->email();
2503
+		$this->_template_args['phone']             = $attendee->phone();
2504
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2505
+		// edit link
2506
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2507
+			[
2508
+				'action' => 'edit_attendee',
2509
+				'post'   => $attendee->ID(),
2510
+			],
2511
+			REG_ADMIN_URL
2512
+		);
2513
+		$this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2514
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2515
+		// create link
2516
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2517
+			? EE_Admin_Page::add_query_args_and_nonce(
2518
+				[
2519
+					'action'  => 'duplicate_attendee',
2520
+					'_REG_ID' => $this->_registration->ID(),
2521
+				],
2522
+				REG_ADMIN_URL
2523
+			) : '';
2524
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2525
+		$this->_template_args['att_check'] = $att_check;
2526
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2527
+		EEH_Template::display_template($template_path, $this->_template_args);
2528
+	}
2529
+
2530
+
2531
+	/**
2532
+	 * trash or restore registrations
2533
+	 *
2534
+	 * @param boolean $trash whether to archive or restore
2535
+	 * @return void
2536
+	 * @throws EE_Error
2537
+	 * @throws InvalidArgumentException
2538
+	 * @throws InvalidDataTypeException
2539
+	 * @throws InvalidInterfaceException
2540
+	 * @throws RuntimeException
2541
+	 */
2542
+	protected function _trash_or_restore_registrations($trash = true)
2543
+	{
2544
+		// if empty _REG_ID then get out because there's nothing to do
2545
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2546
+		if (empty($REG_IDs)) {
2547
+			EE_Error::add_error(
2548
+				sprintf(
2549
+					esc_html__(
2550
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2551
+						'event_espresso'
2552
+					),
2553
+					$trash ? 'trash' : 'restore'
2554
+				),
2555
+				__FILE__,
2556
+				__LINE__,
2557
+				__FUNCTION__
2558
+			);
2559
+			$this->_redirect_after_action(false, '', '', [], true);
2560
+		}
2561
+		$success        = 0;
2562
+		$overwrite_msgs = false;
2563
+		// Checkboxes
2564
+		$reg_count = count($REG_IDs);
2565
+		// cycle thru checkboxes
2566
+		foreach ($REG_IDs as $REG_ID) {
2567
+			/** @var EE_Registration $REG */
2568
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2569
+			$payments = $REG->registration_payments();
2570
+			if (! empty($payments)) {
2571
+				$name           = $REG->attendee() instanceof EE_Attendee
2572
+					? $REG->attendee()->full_name()
2573
+					: esc_html__('Unknown Attendee', 'event_espresso');
2574
+				$overwrite_msgs = true;
2575
+				EE_Error::add_error(
2576
+					sprintf(
2577
+						esc_html__(
2578
+							'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.',
2579
+							'event_espresso'
2580
+						),
2581
+						$name
2582
+					),
2583
+					__FILE__,
2584
+					__FUNCTION__,
2585
+					__LINE__
2586
+				);
2587
+				// can't trash this registration because it has payments.
2588
+				continue;
2589
+			}
2590
+			$updated = $trash ? $REG->delete() : $REG->restore();
2591
+			if ($updated) {
2592
+				$success++;
2593
+			}
2594
+		}
2595
+		$this->_redirect_after_action(
2596
+			$success === $reg_count, // were ALL registrations affected?
2597
+			$success > 1
2598
+				? esc_html__('Registrations', 'event_espresso')
2599
+				: esc_html__('Registration', 'event_espresso'),
2600
+			$trash
2601
+				? esc_html__('moved to the trash', 'event_espresso')
2602
+				: esc_html__('restored', 'event_espresso'),
2603
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2604
+			$overwrite_msgs
2605
+		);
2606
+	}
2607
+
2608
+
2609
+	/**
2610
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2611
+	 * registration but also.
2612
+	 * 1. Removing relations to EE_Attendee
2613
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2614
+	 * ALSO trashed.
2615
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2616
+	 * 4. Removing relationships between all tickets and the related registrations
2617
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2618
+	 * 6. Deleting permanently any related Checkins.
2619
+	 *
2620
+	 * @return void
2621
+	 * @throws EE_Error
2622
+	 * @throws InvalidArgumentException
2623
+	 * @throws InvalidDataTypeException
2624
+	 * @throws InvalidInterfaceException
2625
+	 * @throws ReflectionException
2626
+	 */
2627
+	protected function _delete_registrations()
2628
+	{
2629
+		$REG_MDL = $this->getRegistrationModel();
2630
+		$success = 0;
2631
+		// Checkboxes
2632
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2633
+
2634
+		if (! empty($REG_IDs)) {
2635
+			// if array has more than one element than success message should be plural
2636
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2637
+			// cycle thru checkboxes
2638
+			foreach ($REG_IDs as $REG_ID) {
2639
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2640
+				if (! $REG instanceof EE_Registration) {
2641
+					continue;
2642
+				}
2643
+				$deleted = $this->_delete_registration($REG);
2644
+				if (! $deleted) {
2645
+					$success = 0;
2646
+				}
2647
+			}
2648
+		}
2649
+
2650
+		$what        = $success > 1
2651
+			? esc_html__('Registrations', 'event_espresso')
2652
+			: esc_html__('Registration', 'event_espresso');
2653
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2654
+		$this->_redirect_after_action(
2655
+			$success,
2656
+			$what,
2657
+			$action_desc,
2658
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2659
+			true
2660
+		);
2661
+	}
2662
+
2663
+
2664
+	/**
2665
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2666
+	 * models get affected.
2667
+	 *
2668
+	 * @param EE_Registration $REG registration to be deleted permanently
2669
+	 * @return bool true = successful deletion, false = fail.
2670
+	 * @throws EE_Error
2671
+	 * @throws InvalidArgumentException
2672
+	 * @throws InvalidDataTypeException
2673
+	 * @throws InvalidInterfaceException
2674
+	 * @throws ReflectionException
2675
+	 */
2676
+	protected function _delete_registration(EE_Registration $REG)
2677
+	{
2678
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2679
+		// registrations on the transaction that are NOT trashed.
2680
+		$TXN = $REG->get_first_related('Transaction');
2681
+		if (! $TXN instanceof EE_Transaction) {
2682
+			EE_Error::add_error(
2683
+				sprintf(
2684
+					esc_html__(
2685
+						'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.',
2686
+						'event_espresso'
2687
+					),
2688
+					$REG->id()
2689
+				),
2690
+				__FILE__,
2691
+				__FUNCTION__,
2692
+				__LINE__
2693
+			);
2694
+			return false;
2695
+		}
2696
+		$REGS        = $TXN->get_many_related('Registration');
2697
+		$all_trashed = true;
2698
+		foreach ($REGS as $registration) {
2699
+			if (! $registration->get('REG_deleted')) {
2700
+				$all_trashed = false;
2701
+			}
2702
+		}
2703
+		if (! $all_trashed) {
2704
+			EE_Error::add_error(
2705
+				esc_html__(
2706
+					'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.',
2707
+					'event_espresso'
2708
+				),
2709
+				__FILE__,
2710
+				__FUNCTION__,
2711
+				__LINE__
2712
+			);
2713
+			return false;
2714
+		}
2715
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2716
+		// separately from THIS one).
2717
+		foreach ($REGS as $registration) {
2718
+			// delete related answers
2719
+			$registration->delete_related_permanently('Answer');
2720
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2721
+			$attendee = $registration->get_first_related('Attendee');
2722
+			if ($attendee instanceof EE_Attendee) {
2723
+				$registration->_remove_relation_to($attendee, 'Attendee');
2724
+			}
2725
+			// now remove relationships to tickets on this registration.
2726
+			$registration->_remove_relations('Ticket');
2727
+			// now delete permanently the checkins related to this registration.
2728
+			$registration->delete_related_permanently('Checkin');
2729
+			if ($registration->ID() === $REG->ID()) {
2730
+				continue;
2731
+			} //we don't want to delete permanently the existing registration just yet.
2732
+			// remove relation to transaction for these registrations if NOT the existing registrations
2733
+			$registration->_remove_relations('Transaction');
2734
+			// delete permanently any related messages.
2735
+			$registration->delete_related_permanently('Message');
2736
+			// now delete this registration permanently
2737
+			$registration->delete_permanently();
2738
+		}
2739
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2740
+		// (the transaction and line items should be all that's left).
2741
+		// delete the line items related to the transaction for this registration.
2742
+		$TXN->delete_related_permanently('Line_Item');
2743
+		// we need to remove all the relationships on the transaction
2744
+		$TXN->delete_related_permanently('Payment');
2745
+		$TXN->delete_related_permanently('Extra_Meta');
2746
+		$TXN->delete_related_permanently('Message');
2747
+		// now we can delete this REG permanently (and the transaction of course)
2748
+		$REG->delete_related_permanently('Transaction');
2749
+		return $REG->delete_permanently();
2750
+	}
2751
+
2752
+
2753
+	/**
2754
+	 *    generates HTML for the Register New Attendee Admin page
2755
+	 *
2756
+	 * @throws DomainException
2757
+	 * @throws EE_Error
2758
+	 * @throws InvalidArgumentException
2759
+	 * @throws InvalidDataTypeException
2760
+	 * @throws InvalidInterfaceException
2761
+	 * @throws ReflectionException
2762
+	 */
2763
+	public function new_registration()
2764
+	{
2765
+		if (! $this->_set_reg_event()) {
2766
+			throw new EE_Error(
2767
+				esc_html__(
2768
+					'Unable to continue with registering because there is no Event ID in the request',
2769
+					'event_espresso'
2770
+				)
2771
+			);
2772
+		}
2773
+		/** @var CurrentPage $current_page */
2774
+		$current_page = $this->loader->getShared(CurrentPage::class);
2775
+		$current_page->setEspressoPage(true);
2776
+		// gotta start with a clean slate if we're not coming here via ajax
2777
+		if (
2778
+			! $this->request->isAjax()
2779
+			&& (
2780
+				! $this->request->requestParamIsSet('processing_registration')
2781
+				|| $this->request->requestParamIsSet('step_error')
2782
+			)
2783
+		) {
2784
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2785
+		}
2786
+		$this->_template_args['event_name'] = '';
2787
+		// event name
2788
+		if ($this->_reg_event) {
2789
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2790
+			$edit_event_url                     = self::add_query_args_and_nonce(
2791
+				[
2792
+					'action' => 'edit',
2793
+					'post'   => $this->_reg_event->ID(),
2794
+				],
2795
+				EVENTS_ADMIN_URL
2796
+			);
2797
+			$edit_event_lnk                     = '<a href="'
2798
+												  . $edit_event_url
2799
+												  . '" title="'
2800
+												  . esc_attr__('Edit ', 'event_espresso')
2801
+												  . $this->_reg_event->name()
2802
+												  . '">'
2803
+												  . esc_html__('Edit Event', 'event_espresso')
2804
+												  . '</a>';
2805
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2806
+												   . $edit_event_lnk
2807
+												   . '</span>';
2808
+		}
2809
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2810
+		if ($this->request->isAjax()) {
2811
+			$this->_return_json();
2812
+		}
2813
+		// grab header
2814
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2815
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2816
+			$template_path,
2817
+			$this->_template_args,
2818
+			true
2819
+		);
2820
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2821
+		// the details template wrapper
2822
+		$this->display_admin_page_with_sidebar();
2823
+	}
2824
+
2825
+
2826
+	/**
2827
+	 * This returns the content for a registration step
2828
+	 *
2829
+	 * @return string html
2830
+	 * @throws DomainException
2831
+	 * @throws EE_Error
2832
+	 * @throws InvalidArgumentException
2833
+	 * @throws InvalidDataTypeException
2834
+	 * @throws InvalidInterfaceException
2835
+	 * @throws ReflectionException
2836
+	 */
2837
+	protected function _get_registration_step_content()
2838
+	{
2839
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2840
+			$warning_msg = sprintf(
2841
+				esc_html__(
2842
+					'%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',
2843
+					'event_espresso'
2844
+				),
2845
+				'<br />',
2846
+				'<h3 class="important-notice">',
2847
+				'</h3>',
2848
+				'<div class="float-right">',
2849
+				'<span id="redirect_timer" class="important-notice">30</span>',
2850
+				'</div>',
2851
+				'<b>',
2852
+				'</b>'
2853
+			);
2854
+			return '
2855 2855
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2856 2856
 	<script >
2857 2857
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2864,844 +2864,844 @@  discard block
 block discarded – undo
2864 2864
 	        }
2865 2865
 	    }, 800 );
2866 2866
 	</script >';
2867
-        }
2868
-        $template_args = [
2869
-            'title'                    => '',
2870
-            'content'                  => '',
2871
-            'step_button_text'         => '',
2872
-            'show_notification_toggle' => false,
2873
-        ];
2874
-        // to indicate we're processing a new registration
2875
-        $hidden_fields = [
2876
-            'processing_registration' => [
2877
-                'type'  => 'hidden',
2878
-                'value' => 0,
2879
-            ],
2880
-            'event_id'                => [
2881
-                'type'  => 'hidden',
2882
-                'value' => $this->_reg_event->ID(),
2883
-            ],
2884
-        ];
2885
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2886
-        $cart = EE_Registry::instance()->SSN->cart();
2887
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2888
-        switch ($step) {
2889
-            case 'ticket':
2890
-                $hidden_fields['processing_registration']['value'] = 1;
2891
-                $template_args['title']                            = esc_html__(
2892
-                    'Step One: Select the Ticket for this registration',
2893
-                    'event_espresso'
2894
-                );
2895
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2896
-                $template_args['content'] .= '</div>';
2897
-                $template_args['step_button_text'] = esc_html__(
2898
-                    'Add Tickets and Continue to Registrant Details',
2899
-                    'event_espresso'
2900
-                );
2901
-                $template_args['show_notification_toggle']         = false;
2902
-                break;
2903
-            case 'questions':
2904
-                $hidden_fields['processing_registration']['value'] = 2;
2905
-                $template_args['title']                            = esc_html__(
2906
-                    'Step Two: Add Registrant Details for this Registration',
2907
-                    'event_espresso'
2908
-                );
2909
-                // in theory, we should be able to run EED_SPCO at this point
2910
-                // because the cart should have been set up properly by the first process_reg_step run.
2911
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2912
-                $template_args['step_button_text'] = esc_html__(
2913
-                    'Save Registration and Continue to Details',
2914
-                    'event_espresso'
2915
-                );
2916
-                $template_args['show_notification_toggle'] = true;
2917
-                break;
2918
-        }
2919
-        // we come back to the process_registration_step route.
2920
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2921
-        return EEH_Template::display_template(
2922
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2923
-            $template_args,
2924
-            true
2925
-        );
2926
-    }
2927
-
2928
-
2929
-    /**
2930
-     * set_reg_event
2931
-     *
2932
-     * @return bool
2933
-     * @throws EE_Error
2934
-     * @throws InvalidArgumentException
2935
-     * @throws InvalidDataTypeException
2936
-     * @throws InvalidInterfaceException
2937
-     */
2938
-    private function _set_reg_event()
2939
-    {
2940
-        if (is_object($this->_reg_event)) {
2941
-            return true;
2942
-        }
2943
-
2944
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2945
-        if (! $EVT_ID) {
2946
-            return false;
2947
-        }
2948
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2949
-        return true;
2950
-    }
2951
-
2952
-
2953
-    /**
2954
-     * process_reg_step
2955
-     *
2956
-     * @return void
2957
-     * @throws DomainException
2958
-     * @throws EE_Error
2959
-     * @throws InvalidArgumentException
2960
-     * @throws InvalidDataTypeException
2961
-     * @throws InvalidInterfaceException
2962
-     * @throws ReflectionException
2963
-     * @throws RuntimeException
2964
-     */
2965
-    public function process_reg_step()
2966
-    {
2967
-        EE_System::do_not_cache();
2968
-        $this->_set_reg_event();
2969
-        /** @var CurrentPage $current_page */
2970
-        $current_page = $this->loader->getShared(CurrentPage::class);
2971
-        $current_page->setEspressoPage(true);
2972
-        $this->request->setRequestParam('uts', time());
2973
-        // what step are we on?
2974
-        $cart = EE_Registry::instance()->SSN->cart();
2975
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2976
-        // if doing ajax then we need to verify the nonce
2977
-        if ($this->request->isAjax()) {
2978
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
2979
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2980
-        }
2981
-        switch ($step) {
2982
-            case 'ticket':
2983
-                // process ticket selection
2984
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
2985
-                if ($success) {
2986
-                    EE_Error::add_success(
2987
-                        esc_html__(
2988
-                            'Tickets Selected. Now complete the registration.',
2989
-                            'event_espresso'
2990
-                        )
2991
-                    );
2992
-                } else {
2993
-                    $this->request->setRequestParam('step_error', true);
2994
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
2995
-                }
2996
-                if ($this->request->isAjax()) {
2997
-                    $this->new_registration(); // display next step
2998
-                } else {
2999
-                    $query_args = [
3000
-                        'action'                  => 'new_registration',
3001
-                        'processing_registration' => 1,
3002
-                        'event_id'                => $this->_reg_event->ID(),
3003
-                        'uts'                     => time(),
3004
-                    ];
3005
-                    $this->_redirect_after_action(
3006
-                        false,
3007
-                        '',
3008
-                        '',
3009
-                        $query_args,
3010
-                        true
3011
-                    );
3012
-                }
3013
-                break;
3014
-            case 'questions':
3015
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3016
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3017
-                }
3018
-                // process registration
3019
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3020
-                if ($cart instanceof EE_Cart) {
3021
-                    $grand_total = $cart->get_grand_total();
3022
-                    if ($grand_total instanceof EE_Line_Item) {
3023
-                        $grand_total->save_this_and_descendants_to_txn();
3024
-                    }
3025
-                }
3026
-                if (! $transaction instanceof EE_Transaction) {
3027
-                    $query_args = [
3028
-                        'action'                  => 'new_registration',
3029
-                        'processing_registration' => 2,
3030
-                        'event_id'                => $this->_reg_event->ID(),
3031
-                        'uts'                     => time(),
3032
-                    ];
3033
-                    if ($this->request->isAjax()) {
3034
-                        // display registration form again because there are errors (maybe validation?)
3035
-                        $this->new_registration();
3036
-                        return;
3037
-                    }
3038
-                    $this->_redirect_after_action(
3039
-                        false,
3040
-                        '',
3041
-                        '',
3042
-                        $query_args,
3043
-                        true
3044
-                    );
3045
-                    return;
3046
-                }
3047
-                // maybe update status, and make sure to save transaction if not done already
3048
-                if (! $transaction->update_status_based_on_total_paid()) {
3049
-                    $transaction->save();
3050
-                }
3051
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3052
-                $query_args = [
3053
-                    'action'        => 'redirect_to_txn',
3054
-                    'TXN_ID'        => $transaction->ID(),
3055
-                    'EVT_ID'        => $this->_reg_event->ID(),
3056
-                    'event_name'    => urlencode($this->_reg_event->name()),
3057
-                    'redirect_from' => 'new_registration',
3058
-                ];
3059
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3060
-                break;
3061
-        }
3062
-        // what are you looking here for?  Should be nothing to do at this point.
3063
-    }
3064
-
3065
-
3066
-    /**
3067
-     * redirect_to_txn
3068
-     *
3069
-     * @return void
3070
-     * @throws EE_Error
3071
-     * @throws InvalidArgumentException
3072
-     * @throws InvalidDataTypeException
3073
-     * @throws InvalidInterfaceException
3074
-     * @throws ReflectionException
3075
-     */
3076
-    public function redirect_to_txn()
3077
-    {
3078
-        EE_System::do_not_cache();
3079
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3080
-        $query_args = [
3081
-            'action' => 'view_transaction',
3082
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3083
-            'page'   => 'espresso_transactions',
3084
-        ];
3085
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3086
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3087
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3088
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3089
-        }
3090
-        EE_Error::add_success(
3091
-            esc_html__(
3092
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3093
-                'event_espresso'
3094
-            )
3095
-        );
3096
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * generates HTML for the Attendee Contact List
3102
-     *
3103
-     * @return void
3104
-     * @throws DomainException
3105
-     * @throws EE_Error
3106
-     */
3107
-    protected function _attendee_contact_list_table()
3108
-    {
3109
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3110
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3111
-        $this->display_admin_list_table_page_with_no_sidebar();
3112
-    }
3113
-
3114
-
3115
-    /**
3116
-     * get_attendees
3117
-     *
3118
-     * @param      $per_page
3119
-     * @param bool $count whether to return count or data.
3120
-     * @param bool $trash
3121
-     * @return array|int
3122
-     * @throws EE_Error
3123
-     * @throws InvalidArgumentException
3124
-     * @throws InvalidDataTypeException
3125
-     * @throws InvalidInterfaceException
3126
-     */
3127
-    public function get_attendees($per_page, $count = false, $trash = false)
3128
-    {
3129
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3130
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3131
-        $orderby = $this->request->getRequestParam('orderby');
3132
-        switch ($orderby) {
3133
-            case 'ATT_ID':
3134
-            case 'ATT_fname':
3135
-            case 'ATT_email':
3136
-            case 'ATT_city':
3137
-            case 'STA_ID':
3138
-            case 'CNT_ID':
3139
-                break;
3140
-            case 'Registration_Count':
3141
-                $orderby = 'Registration_Count';
3142
-                break;
3143
-            default:
3144
-                $orderby = 'ATT_lname';
3145
-        }
3146
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3147
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3148
-        $per_page     = absint($per_page) ? $per_page : 10;
3149
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3150
-        $_where       = [];
3151
-        $search_term  = $this->request->getRequestParam('s');
3152
-        if ($search_term) {
3153
-            $search_term  = '%' . $search_term . '%';
3154
-            $_where['OR'] = [
3155
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3156
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3157
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3158
-                'ATT_fname'                         => ['LIKE', $search_term],
3159
-                'ATT_lname'                         => ['LIKE', $search_term],
3160
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3161
-                'ATT_email'                         => ['LIKE', $search_term],
3162
-                'ATT_address'                       => ['LIKE', $search_term],
3163
-                'ATT_address2'                      => ['LIKE', $search_term],
3164
-                'ATT_city'                          => ['LIKE', $search_term],
3165
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3166
-                'State.STA_name'                    => ['LIKE', $search_term],
3167
-                'ATT_phone'                         => ['LIKE', $search_term],
3168
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3169
-                'Registration.REG_code'             => ['LIKE', $search_term],
3170
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3171
-            ];
3172
-        }
3173
-        $offset     = ($current_page - 1) * $per_page;
3174
-        $limit      = $count ? null : [$offset, $per_page];
3175
-        $query_args = [
3176
-            $_where,
3177
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3178
-            'limit'         => $limit,
3179
-        ];
3180
-        if (! $count) {
3181
-            $query_args['order_by'] = [$orderby => $sort];
3182
-        }
3183
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3184
-        return $count
3185
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3186
-            : $this->getAttendeeModel()->get_all($query_args);
3187
-    }
3188
-
3189
-
3190
-    /**
3191
-     * This is just taking care of resending the registration confirmation
3192
-     *
3193
-     * @return void
3194
-     * @throws EE_Error
3195
-     * @throws InvalidArgumentException
3196
-     * @throws InvalidDataTypeException
3197
-     * @throws InvalidInterfaceException
3198
-     * @throws ReflectionException
3199
-     */
3200
-    protected function _resend_registration()
3201
-    {
3202
-        $this->_process_resend_registration();
3203
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3204
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3205
-        $query_args  = $redirect_to
3206
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3207
-            : ['action' => 'default'];
3208
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3209
-    }
3210
-
3211
-
3212
-    /**
3213
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3214
-     * to use when selecting registrations
3215
-     *
3216
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3217
-     *                                                     the query parameters from the request
3218
-     * @return void ends the request with a redirect or download
3219
-     */
3220
-    public function _registrations_report_base($method_name_for_getting_query_params)
3221
-    {
3222
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3223
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3224
-            : null;
3225
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3226
-            $request_params = $this->request->requestParams();
3227
-            wp_redirect(
3228
-                EE_Admin_Page::add_query_args_and_nonce(
3229
-                    [
3230
-                        'page'        => 'espresso_batch',
3231
-                        'batch'       => 'file',
3232
-                        'EVT_ID'      => $EVT_ID,
3233
-                        'filters'     => urlencode(
3234
-                            serialize(
3235
-                                $this->$method_name_for_getting_query_params(
3236
-                                    EEH_Array::is_set($request_params, 'filters', [])
3237
-                                )
3238
-                            )
3239
-                        ),
3240
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3241
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3242
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3243
-                    ]
3244
-                )
3245
-            );
3246
-        } else {
3247
-            // Pull the current request params
3248
-            $request_args = $this->request->requestParams();
3249
-            // Set the required request_args to be passed to the export
3250
-            $required_request_args = [
3251
-                'export' => 'report',
3252
-                'action' => 'registrations_report_for_event',
3253
-                'EVT_ID' => $EVT_ID,
3254
-            ];
3255
-            // Merge required request args, overriding any currently set
3256
-            $request_args = array_merge($request_args, $required_request_args);
3257
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3258
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3259
-                $EE_Export = EE_Export::instance($request_args);
3260
-                $EE_Export->export();
3261
-            }
3262
-        }
3263
-    }
3264
-
3265
-
3266
-    /**
3267
-     * Creates a registration report using only query parameters in the request
3268
-     *
3269
-     * @return void
3270
-     */
3271
-    public function _registrations_report()
3272
-    {
3273
-        $this->_registrations_report_base('_get_registration_query_parameters');
3274
-    }
3275
-
3276
-
3277
-    public function _contact_list_export()
3278
-    {
3279
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3280
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3281
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3282
-            $EE_Export->export_attendees();
3283
-        }
3284
-    }
3285
-
3286
-
3287
-    public function _contact_list_report()
3288
-    {
3289
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3290
-            wp_redirect(
3291
-                EE_Admin_Page::add_query_args_and_nonce(
3292
-                    [
3293
-                        'page'        => 'espresso_batch',
3294
-                        'batch'       => 'file',
3295
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3296
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3297
-                    ]
3298
-                )
3299
-            );
3300
-        } else {
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->report_attendees();
3305
-            }
3306
-        }
3307
-    }
3308
-
3309
-
3310
-
3311
-
3312
-
3313
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3314
-    /**
3315
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3316
-     *
3317
-     * @return void
3318
-     * @throws EE_Error
3319
-     * @throws InvalidArgumentException
3320
-     * @throws InvalidDataTypeException
3321
-     * @throws InvalidInterfaceException
3322
-     * @throws ReflectionException
3323
-     */
3324
-    protected function _duplicate_attendee()
3325
-    {
3326
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3327
-        $action = $this->request->getRequestParam('return', 'default');
3328
-        // verify we have necessary info
3329
-        if (! $REG_ID) {
3330
-            EE_Error::add_error(
3331
-                esc_html__(
3332
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3333
-                    'event_espresso'
3334
-                ),
3335
-                __FILE__,
3336
-                __LINE__,
3337
-                __FUNCTION__
3338
-            );
3339
-            $query_args = ['action' => $action];
3340
-            $this->_redirect_after_action('', '', '', $query_args, true);
3341
-        }
3342
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3343
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3344
-        if (! $registration instanceof EE_Registration) {
3345
-            throw new RuntimeException(
3346
-                sprintf(
3347
-                    esc_html__(
3348
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3349
-                        'event_espresso'
3350
-                    ),
3351
-                    $REG_ID
3352
-                )
3353
-            );
3354
-        }
3355
-        $attendee = $registration->attendee();
3356
-        // remove relation of existing attendee on registration
3357
-        $registration->_remove_relation_to($attendee, 'Attendee');
3358
-        // new attendee
3359
-        $new_attendee = clone $attendee;
3360
-        $new_attendee->set('ATT_ID', 0);
3361
-        $new_attendee->save();
3362
-        // add new attendee to reg
3363
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3364
-        EE_Error::add_success(
3365
-            esc_html__(
3366
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3367
-                'event_espresso'
3368
-            )
3369
-        );
3370
-        // redirect to edit page for attendee
3371
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3372
-        $this->_redirect_after_action('', '', '', $query_args, true);
3373
-    }
3374
-
3375
-
3376
-    /**
3377
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3378
-     *
3379
-     * @param int     $post_id
3380
-     * @param WP_Post $post
3381
-     * @throws DomainException
3382
-     * @throws EE_Error
3383
-     * @throws InvalidArgumentException
3384
-     * @throws InvalidDataTypeException
3385
-     * @throws InvalidInterfaceException
3386
-     * @throws LogicException
3387
-     * @throws InvalidFormSubmissionException
3388
-     * @throws ReflectionException
3389
-     */
3390
-    protected function _insert_update_cpt_item($post_id, $post)
3391
-    {
3392
-        $success  = true;
3393
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3394
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3395
-            : null;
3396
-        // for attendee updates
3397
-        if ($attendee instanceof EE_Attendee) {
3398
-            // note we should only be UPDATING attendees at this point.
3399
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3400
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3401
-            $updated_fields = [
3402
-                'ATT_fname'     => $fname,
3403
-                'ATT_lname'     => $lname,
3404
-                'ATT_full_name' => "{$fname} {$lname}",
3405
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3406
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3407
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3408
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3409
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3410
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3411
-            ];
3412
-            foreach ($updated_fields as $field => $value) {
3413
-                $attendee->set($field, $value);
3414
-            }
3415
-
3416
-            // process contact details metabox form handler (which will also save the attendee)
3417
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3418
-            $success              = $contact_details_form->process($this->request->requestParams());
3419
-
3420
-            $attendee_update_callbacks = apply_filters(
3421
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3422
-                []
3423
-            );
3424
-            foreach ($attendee_update_callbacks as $a_callback) {
3425
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3426
-                    throw new EE_Error(
3427
-                        sprintf(
3428
-                            esc_html__(
3429
-                                '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.',
3430
-                                'event_espresso'
3431
-                            ),
3432
-                            $a_callback
3433
-                        )
3434
-                    );
3435
-                }
3436
-            }
3437
-        }
3438
-
3439
-        if ($success === false) {
3440
-            EE_Error::add_error(
3441
-                esc_html__(
3442
-                    'Something went wrong with updating the meta table data for the registration.',
3443
-                    'event_espresso'
3444
-                ),
3445
-                __FILE__,
3446
-                __FUNCTION__,
3447
-                __LINE__
3448
-            );
3449
-        }
3450
-    }
3451
-
3452
-
3453
-    public function trash_cpt_item($post_id)
3454
-    {
3455
-    }
3456
-
3457
-
3458
-    public function delete_cpt_item($post_id)
3459
-    {
3460
-    }
3461
-
3462
-
3463
-    public function restore_cpt_item($post_id)
3464
-    {
3465
-    }
3466
-
3467
-
3468
-    protected function _restore_cpt_item($post_id, $revision_id)
3469
-    {
3470
-    }
3471
-
3472
-
3473
-    /**
3474
-     * @throws EE_Error
3475
-     * @throws ReflectionException
3476
-     * @since 4.10.2.p
3477
-     */
3478
-    public function attendee_editor_metaboxes()
3479
-    {
3480
-        $this->verify_cpt_object();
3481
-        remove_meta_box(
3482
-            'postexcerpt',
3483
-            $this->_cpt_routes[ $this->_req_action ],
3484
-            'normal'
3485
-        );
3486
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3487
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3488
-            $this->addMetaBox(
3489
-                'postexcerpt',
3490
-                esc_html__('Short Biography', 'event_espresso'),
3491
-                'post_excerpt_meta_box',
3492
-                $this->_cpt_routes[ $this->_req_action ]
3493
-            );
3494
-        }
3495
-        if (post_type_supports('espresso_attendees', 'comments')) {
3496
-            $this->addMetaBox(
3497
-                'commentsdiv',
3498
-                esc_html__('Notes on the Contact', 'event_espresso'),
3499
-                'post_comment_meta_box',
3500
-                $this->_cpt_routes[ $this->_req_action ],
3501
-                'normal',
3502
-                'core'
3503
-            );
3504
-        }
3505
-        $this->addMetaBox(
3506
-            'attendee_contact_info',
3507
-            esc_html__('Contact Info', 'event_espresso'),
3508
-            [$this, 'attendee_contact_info'],
3509
-            $this->_cpt_routes[ $this->_req_action ],
3510
-            'side',
3511
-            'core'
3512
-        );
3513
-        $this->addMetaBox(
3514
-            'attendee_details_address',
3515
-            esc_html__('Address Details', 'event_espresso'),
3516
-            [$this, 'attendee_address_details'],
3517
-            $this->_cpt_routes[ $this->_req_action ],
3518
-            'normal',
3519
-            'core'
3520
-        );
3521
-        $this->addMetaBox(
3522
-            'attendee_registrations',
3523
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3524
-            [$this, 'attendee_registrations_meta_box'],
3525
-            $this->_cpt_routes[ $this->_req_action ]
3526
-        );
3527
-    }
3528
-
3529
-
3530
-    /**
3531
-     * Metabox for attendee contact info
3532
-     *
3533
-     * @param WP_Post $post wp post object
3534
-     * @return void attendee contact info ( and form )
3535
-     * @throws EE_Error
3536
-     * @throws InvalidArgumentException
3537
-     * @throws InvalidDataTypeException
3538
-     * @throws InvalidInterfaceException
3539
-     * @throws LogicException
3540
-     * @throws DomainException
3541
-     */
3542
-    public function attendee_contact_info($post)
3543
-    {
3544
-        // get attendee object ( should already have it )
3545
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3546
-        $form->enqueueStylesAndScripts();
3547
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3548
-    }
3549
-
3550
-
3551
-    /**
3552
-     * Return form handler for the contact details metabox
3553
-     *
3554
-     * @param EE_Attendee $attendee
3555
-     * @return AttendeeContactDetailsMetaboxFormHandler
3556
-     * @throws DomainException
3557
-     * @throws InvalidArgumentException
3558
-     * @throws InvalidDataTypeException
3559
-     * @throws InvalidInterfaceException
3560
-     */
3561
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3562
-    {
3563
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3564
-    }
3565
-
3566
-
3567
-    /**
3568
-     * Metabox for attendee details
3569
-     *
3570
-     * @param WP_Post $post wp post object
3571
-     * @throws EE_Error
3572
-     * @throws ReflectionException
3573
-     */
3574
-    public function attendee_address_details($post)
3575
-    {
3576
-        // get attendee object (should already have it)
3577
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3578
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3579
-            new EE_Question_Form_Input(
3580
-                EE_Question::new_instance(
3581
-                    [
3582
-                        'QST_ID'           => 0,
3583
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3584
-                        'QST_system'       => 'admin-state',
3585
-                    ]
3586
-                ),
3587
-                EE_Answer::new_instance(
3588
-                    [
3589
-                        'ANS_ID'    => 0,
3590
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3591
-                    ]
3592
-                ),
3593
-                [
3594
-                    'input_id'       => 'STA_ID',
3595
-                    'input_name'     => 'STA_ID',
3596
-                    'input_prefix'   => '',
3597
-                    'append_qstn_id' => false,
3598
-                ]
3599
-            )
3600
-        );
3601
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3602
-            new EE_Question_Form_Input(
3603
-                EE_Question::new_instance(
3604
-                    [
3605
-                        'QST_ID'           => 0,
3606
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3607
-                        'QST_system'       => 'admin-country',
3608
-                    ]
3609
-                ),
3610
-                EE_Answer::new_instance(
3611
-                    [
3612
-                        'ANS_ID'    => 0,
3613
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3614
-                    ]
3615
-                ),
3616
-                [
3617
-                    'input_id'       => 'CNT_ISO',
3618
-                    'input_name'     => 'CNT_ISO',
3619
-                    'input_prefix'   => '',
3620
-                    'append_qstn_id' => false,
3621
-                ]
3622
-            )
3623
-        );
3624
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3625
-        EEH_Template::display_template($template, $this->_template_args);
3626
-    }
3627
-
3628
-
3629
-    /**
3630
-     * _attendee_details
3631
-     *
3632
-     * @param $post
3633
-     * @return void
3634
-     * @throws DomainException
3635
-     * @throws EE_Error
3636
-     * @throws InvalidArgumentException
3637
-     * @throws InvalidDataTypeException
3638
-     * @throws InvalidInterfaceException
3639
-     * @throws ReflectionException
3640
-     */
3641
-    public function attendee_registrations_meta_box($post)
3642
-    {
3643
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3644
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3645
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3646
-        EEH_Template::display_template($template, $this->_template_args);
3647
-    }
3648
-
3649
-
3650
-    /**
3651
-     * add in the form fields for the attendee edit
3652
-     *
3653
-     * @param WP_Post $post wp post object
3654
-     * @return void echos html for new form.
3655
-     * @throws DomainException
3656
-     */
3657
-    public function after_title_form_fields($post)
3658
-    {
3659
-        if ($post->post_type === 'espresso_attendees') {
3660
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3661
-            $template_args['attendee'] = $this->_cpt_model_obj;
3662
-            EEH_Template::display_template($template, $template_args);
3663
-        }
3664
-    }
3665
-
3666
-
3667
-    /**
3668
-     * _trash_or_restore_attendee
3669
-     *
3670
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3671
-     * @return void
3672
-     * @throws EE_Error
3673
-     * @throws InvalidArgumentException
3674
-     * @throws InvalidDataTypeException
3675
-     * @throws InvalidInterfaceException
3676
-     */
3677
-    protected function _trash_or_restore_attendees($trash = true)
3678
-    {
3679
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3680
-        $status = $trash ? 'trash' : 'publish';
3681
-        // Checkboxes
3682
-        if ($this->request->requestParamIsSet('checkbox')) {
3683
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3684
-            // if array has more than one element than success message should be plural
3685
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3686
-            // cycle thru checkboxes
3687
-            foreach ($ATT_IDs as $ATT_ID) {
3688
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3689
-                if (! $updated) {
3690
-                    $success = 0;
3691
-                }
3692
-            }
3693
-        } else {
3694
-            // grab single id and delete
3695
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3696
-            // update attendee
3697
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3698
-        }
3699
-        $what        = $success > 1
3700
-            ? esc_html__('Contacts', 'event_espresso')
3701
-            : esc_html__('Contact', 'event_espresso');
3702
-        $action_desc = $trash
3703
-            ? esc_html__('moved to the trash', 'event_espresso')
3704
-            : esc_html__('restored', 'event_espresso');
3705
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3706
-    }
2867
+		}
2868
+		$template_args = [
2869
+			'title'                    => '',
2870
+			'content'                  => '',
2871
+			'step_button_text'         => '',
2872
+			'show_notification_toggle' => false,
2873
+		];
2874
+		// to indicate we're processing a new registration
2875
+		$hidden_fields = [
2876
+			'processing_registration' => [
2877
+				'type'  => 'hidden',
2878
+				'value' => 0,
2879
+			],
2880
+			'event_id'                => [
2881
+				'type'  => 'hidden',
2882
+				'value' => $this->_reg_event->ID(),
2883
+			],
2884
+		];
2885
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2886
+		$cart = EE_Registry::instance()->SSN->cart();
2887
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2888
+		switch ($step) {
2889
+			case 'ticket':
2890
+				$hidden_fields['processing_registration']['value'] = 1;
2891
+				$template_args['title']                            = esc_html__(
2892
+					'Step One: Select the Ticket for this registration',
2893
+					'event_espresso'
2894
+				);
2895
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2896
+				$template_args['content'] .= '</div>';
2897
+				$template_args['step_button_text'] = esc_html__(
2898
+					'Add Tickets and Continue to Registrant Details',
2899
+					'event_espresso'
2900
+				);
2901
+				$template_args['show_notification_toggle']         = false;
2902
+				break;
2903
+			case 'questions':
2904
+				$hidden_fields['processing_registration']['value'] = 2;
2905
+				$template_args['title']                            = esc_html__(
2906
+					'Step Two: Add Registrant Details for this Registration',
2907
+					'event_espresso'
2908
+				);
2909
+				// in theory, we should be able to run EED_SPCO at this point
2910
+				// because the cart should have been set up properly by the first process_reg_step run.
2911
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2912
+				$template_args['step_button_text'] = esc_html__(
2913
+					'Save Registration and Continue to Details',
2914
+					'event_espresso'
2915
+				);
2916
+				$template_args['show_notification_toggle'] = true;
2917
+				break;
2918
+		}
2919
+		// we come back to the process_registration_step route.
2920
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2921
+		return EEH_Template::display_template(
2922
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2923
+			$template_args,
2924
+			true
2925
+		);
2926
+	}
2927
+
2928
+
2929
+	/**
2930
+	 * set_reg_event
2931
+	 *
2932
+	 * @return bool
2933
+	 * @throws EE_Error
2934
+	 * @throws InvalidArgumentException
2935
+	 * @throws InvalidDataTypeException
2936
+	 * @throws InvalidInterfaceException
2937
+	 */
2938
+	private function _set_reg_event()
2939
+	{
2940
+		if (is_object($this->_reg_event)) {
2941
+			return true;
2942
+		}
2943
+
2944
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2945
+		if (! $EVT_ID) {
2946
+			return false;
2947
+		}
2948
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2949
+		return true;
2950
+	}
2951
+
2952
+
2953
+	/**
2954
+	 * process_reg_step
2955
+	 *
2956
+	 * @return void
2957
+	 * @throws DomainException
2958
+	 * @throws EE_Error
2959
+	 * @throws InvalidArgumentException
2960
+	 * @throws InvalidDataTypeException
2961
+	 * @throws InvalidInterfaceException
2962
+	 * @throws ReflectionException
2963
+	 * @throws RuntimeException
2964
+	 */
2965
+	public function process_reg_step()
2966
+	{
2967
+		EE_System::do_not_cache();
2968
+		$this->_set_reg_event();
2969
+		/** @var CurrentPage $current_page */
2970
+		$current_page = $this->loader->getShared(CurrentPage::class);
2971
+		$current_page->setEspressoPage(true);
2972
+		$this->request->setRequestParam('uts', time());
2973
+		// what step are we on?
2974
+		$cart = EE_Registry::instance()->SSN->cart();
2975
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2976
+		// if doing ajax then we need to verify the nonce
2977
+		if ($this->request->isAjax()) {
2978
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
2979
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2980
+		}
2981
+		switch ($step) {
2982
+			case 'ticket':
2983
+				// process ticket selection
2984
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2985
+				if ($success) {
2986
+					EE_Error::add_success(
2987
+						esc_html__(
2988
+							'Tickets Selected. Now complete the registration.',
2989
+							'event_espresso'
2990
+						)
2991
+					);
2992
+				} else {
2993
+					$this->request->setRequestParam('step_error', true);
2994
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
2995
+				}
2996
+				if ($this->request->isAjax()) {
2997
+					$this->new_registration(); // display next step
2998
+				} else {
2999
+					$query_args = [
3000
+						'action'                  => 'new_registration',
3001
+						'processing_registration' => 1,
3002
+						'event_id'                => $this->_reg_event->ID(),
3003
+						'uts'                     => time(),
3004
+					];
3005
+					$this->_redirect_after_action(
3006
+						false,
3007
+						'',
3008
+						'',
3009
+						$query_args,
3010
+						true
3011
+					);
3012
+				}
3013
+				break;
3014
+			case 'questions':
3015
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3016
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3017
+				}
3018
+				// process registration
3019
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3020
+				if ($cart instanceof EE_Cart) {
3021
+					$grand_total = $cart->get_grand_total();
3022
+					if ($grand_total instanceof EE_Line_Item) {
3023
+						$grand_total->save_this_and_descendants_to_txn();
3024
+					}
3025
+				}
3026
+				if (! $transaction instanceof EE_Transaction) {
3027
+					$query_args = [
3028
+						'action'                  => 'new_registration',
3029
+						'processing_registration' => 2,
3030
+						'event_id'                => $this->_reg_event->ID(),
3031
+						'uts'                     => time(),
3032
+					];
3033
+					if ($this->request->isAjax()) {
3034
+						// display registration form again because there are errors (maybe validation?)
3035
+						$this->new_registration();
3036
+						return;
3037
+					}
3038
+					$this->_redirect_after_action(
3039
+						false,
3040
+						'',
3041
+						'',
3042
+						$query_args,
3043
+						true
3044
+					);
3045
+					return;
3046
+				}
3047
+				// maybe update status, and make sure to save transaction if not done already
3048
+				if (! $transaction->update_status_based_on_total_paid()) {
3049
+					$transaction->save();
3050
+				}
3051
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3052
+				$query_args = [
3053
+					'action'        => 'redirect_to_txn',
3054
+					'TXN_ID'        => $transaction->ID(),
3055
+					'EVT_ID'        => $this->_reg_event->ID(),
3056
+					'event_name'    => urlencode($this->_reg_event->name()),
3057
+					'redirect_from' => 'new_registration',
3058
+				];
3059
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3060
+				break;
3061
+		}
3062
+		// what are you looking here for?  Should be nothing to do at this point.
3063
+	}
3064
+
3065
+
3066
+	/**
3067
+	 * redirect_to_txn
3068
+	 *
3069
+	 * @return void
3070
+	 * @throws EE_Error
3071
+	 * @throws InvalidArgumentException
3072
+	 * @throws InvalidDataTypeException
3073
+	 * @throws InvalidInterfaceException
3074
+	 * @throws ReflectionException
3075
+	 */
3076
+	public function redirect_to_txn()
3077
+	{
3078
+		EE_System::do_not_cache();
3079
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3080
+		$query_args = [
3081
+			'action' => 'view_transaction',
3082
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3083
+			'page'   => 'espresso_transactions',
3084
+		];
3085
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3086
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3087
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3088
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3089
+		}
3090
+		EE_Error::add_success(
3091
+			esc_html__(
3092
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3093
+				'event_espresso'
3094
+			)
3095
+		);
3096
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * generates HTML for the Attendee Contact List
3102
+	 *
3103
+	 * @return void
3104
+	 * @throws DomainException
3105
+	 * @throws EE_Error
3106
+	 */
3107
+	protected function _attendee_contact_list_table()
3108
+	{
3109
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3110
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3111
+		$this->display_admin_list_table_page_with_no_sidebar();
3112
+	}
3113
+
3114
+
3115
+	/**
3116
+	 * get_attendees
3117
+	 *
3118
+	 * @param      $per_page
3119
+	 * @param bool $count whether to return count or data.
3120
+	 * @param bool $trash
3121
+	 * @return array|int
3122
+	 * @throws EE_Error
3123
+	 * @throws InvalidArgumentException
3124
+	 * @throws InvalidDataTypeException
3125
+	 * @throws InvalidInterfaceException
3126
+	 */
3127
+	public function get_attendees($per_page, $count = false, $trash = false)
3128
+	{
3129
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3130
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3131
+		$orderby = $this->request->getRequestParam('orderby');
3132
+		switch ($orderby) {
3133
+			case 'ATT_ID':
3134
+			case 'ATT_fname':
3135
+			case 'ATT_email':
3136
+			case 'ATT_city':
3137
+			case 'STA_ID':
3138
+			case 'CNT_ID':
3139
+				break;
3140
+			case 'Registration_Count':
3141
+				$orderby = 'Registration_Count';
3142
+				break;
3143
+			default:
3144
+				$orderby = 'ATT_lname';
3145
+		}
3146
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3147
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3148
+		$per_page     = absint($per_page) ? $per_page : 10;
3149
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3150
+		$_where       = [];
3151
+		$search_term  = $this->request->getRequestParam('s');
3152
+		if ($search_term) {
3153
+			$search_term  = '%' . $search_term . '%';
3154
+			$_where['OR'] = [
3155
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3156
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3157
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3158
+				'ATT_fname'                         => ['LIKE', $search_term],
3159
+				'ATT_lname'                         => ['LIKE', $search_term],
3160
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3161
+				'ATT_email'                         => ['LIKE', $search_term],
3162
+				'ATT_address'                       => ['LIKE', $search_term],
3163
+				'ATT_address2'                      => ['LIKE', $search_term],
3164
+				'ATT_city'                          => ['LIKE', $search_term],
3165
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3166
+				'State.STA_name'                    => ['LIKE', $search_term],
3167
+				'ATT_phone'                         => ['LIKE', $search_term],
3168
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3169
+				'Registration.REG_code'             => ['LIKE', $search_term],
3170
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3171
+			];
3172
+		}
3173
+		$offset     = ($current_page - 1) * $per_page;
3174
+		$limit      = $count ? null : [$offset, $per_page];
3175
+		$query_args = [
3176
+			$_where,
3177
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3178
+			'limit'         => $limit,
3179
+		];
3180
+		if (! $count) {
3181
+			$query_args['order_by'] = [$orderby => $sort];
3182
+		}
3183
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3184
+		return $count
3185
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3186
+			: $this->getAttendeeModel()->get_all($query_args);
3187
+	}
3188
+
3189
+
3190
+	/**
3191
+	 * This is just taking care of resending the registration confirmation
3192
+	 *
3193
+	 * @return void
3194
+	 * @throws EE_Error
3195
+	 * @throws InvalidArgumentException
3196
+	 * @throws InvalidDataTypeException
3197
+	 * @throws InvalidInterfaceException
3198
+	 * @throws ReflectionException
3199
+	 */
3200
+	protected function _resend_registration()
3201
+	{
3202
+		$this->_process_resend_registration();
3203
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3204
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3205
+		$query_args  = $redirect_to
3206
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3207
+			: ['action' => 'default'];
3208
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3209
+	}
3210
+
3211
+
3212
+	/**
3213
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3214
+	 * to use when selecting registrations
3215
+	 *
3216
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3217
+	 *                                                     the query parameters from the request
3218
+	 * @return void ends the request with a redirect or download
3219
+	 */
3220
+	public function _registrations_report_base($method_name_for_getting_query_params)
3221
+	{
3222
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3223
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3224
+			: null;
3225
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3226
+			$request_params = $this->request->requestParams();
3227
+			wp_redirect(
3228
+				EE_Admin_Page::add_query_args_and_nonce(
3229
+					[
3230
+						'page'        => 'espresso_batch',
3231
+						'batch'       => 'file',
3232
+						'EVT_ID'      => $EVT_ID,
3233
+						'filters'     => urlencode(
3234
+							serialize(
3235
+								$this->$method_name_for_getting_query_params(
3236
+									EEH_Array::is_set($request_params, 'filters', [])
3237
+								)
3238
+							)
3239
+						),
3240
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3241
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3242
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3243
+					]
3244
+				)
3245
+			);
3246
+		} else {
3247
+			// Pull the current request params
3248
+			$request_args = $this->request->requestParams();
3249
+			// Set the required request_args to be passed to the export
3250
+			$required_request_args = [
3251
+				'export' => 'report',
3252
+				'action' => 'registrations_report_for_event',
3253
+				'EVT_ID' => $EVT_ID,
3254
+			];
3255
+			// Merge required request args, overriding any currently set
3256
+			$request_args = array_merge($request_args, $required_request_args);
3257
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3258
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3259
+				$EE_Export = EE_Export::instance($request_args);
3260
+				$EE_Export->export();
3261
+			}
3262
+		}
3263
+	}
3264
+
3265
+
3266
+	/**
3267
+	 * Creates a registration report using only query parameters in the request
3268
+	 *
3269
+	 * @return void
3270
+	 */
3271
+	public function _registrations_report()
3272
+	{
3273
+		$this->_registrations_report_base('_get_registration_query_parameters');
3274
+	}
3275
+
3276
+
3277
+	public function _contact_list_export()
3278
+	{
3279
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3280
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3281
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3282
+			$EE_Export->export_attendees();
3283
+		}
3284
+	}
3285
+
3286
+
3287
+	public function _contact_list_report()
3288
+	{
3289
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3290
+			wp_redirect(
3291
+				EE_Admin_Page::add_query_args_and_nonce(
3292
+					[
3293
+						'page'        => 'espresso_batch',
3294
+						'batch'       => 'file',
3295
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3296
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3297
+					]
3298
+				)
3299
+			);
3300
+		} else {
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->report_attendees();
3305
+			}
3306
+		}
3307
+	}
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3314
+	/**
3315
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3316
+	 *
3317
+	 * @return void
3318
+	 * @throws EE_Error
3319
+	 * @throws InvalidArgumentException
3320
+	 * @throws InvalidDataTypeException
3321
+	 * @throws InvalidInterfaceException
3322
+	 * @throws ReflectionException
3323
+	 */
3324
+	protected function _duplicate_attendee()
3325
+	{
3326
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3327
+		$action = $this->request->getRequestParam('return', 'default');
3328
+		// verify we have necessary info
3329
+		if (! $REG_ID) {
3330
+			EE_Error::add_error(
3331
+				esc_html__(
3332
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3333
+					'event_espresso'
3334
+				),
3335
+				__FILE__,
3336
+				__LINE__,
3337
+				__FUNCTION__
3338
+			);
3339
+			$query_args = ['action' => $action];
3340
+			$this->_redirect_after_action('', '', '', $query_args, true);
3341
+		}
3342
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3343
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3344
+		if (! $registration instanceof EE_Registration) {
3345
+			throw new RuntimeException(
3346
+				sprintf(
3347
+					esc_html__(
3348
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3349
+						'event_espresso'
3350
+					),
3351
+					$REG_ID
3352
+				)
3353
+			);
3354
+		}
3355
+		$attendee = $registration->attendee();
3356
+		// remove relation of existing attendee on registration
3357
+		$registration->_remove_relation_to($attendee, 'Attendee');
3358
+		// new attendee
3359
+		$new_attendee = clone $attendee;
3360
+		$new_attendee->set('ATT_ID', 0);
3361
+		$new_attendee->save();
3362
+		// add new attendee to reg
3363
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3364
+		EE_Error::add_success(
3365
+			esc_html__(
3366
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3367
+				'event_espresso'
3368
+			)
3369
+		);
3370
+		// redirect to edit page for attendee
3371
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3372
+		$this->_redirect_after_action('', '', '', $query_args, true);
3373
+	}
3374
+
3375
+
3376
+	/**
3377
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3378
+	 *
3379
+	 * @param int     $post_id
3380
+	 * @param WP_Post $post
3381
+	 * @throws DomainException
3382
+	 * @throws EE_Error
3383
+	 * @throws InvalidArgumentException
3384
+	 * @throws InvalidDataTypeException
3385
+	 * @throws InvalidInterfaceException
3386
+	 * @throws LogicException
3387
+	 * @throws InvalidFormSubmissionException
3388
+	 * @throws ReflectionException
3389
+	 */
3390
+	protected function _insert_update_cpt_item($post_id, $post)
3391
+	{
3392
+		$success  = true;
3393
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3394
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3395
+			: null;
3396
+		// for attendee updates
3397
+		if ($attendee instanceof EE_Attendee) {
3398
+			// note we should only be UPDATING attendees at this point.
3399
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3400
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3401
+			$updated_fields = [
3402
+				'ATT_fname'     => $fname,
3403
+				'ATT_lname'     => $lname,
3404
+				'ATT_full_name' => "{$fname} {$lname}",
3405
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3406
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3407
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3408
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3409
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3410
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3411
+			];
3412
+			foreach ($updated_fields as $field => $value) {
3413
+				$attendee->set($field, $value);
3414
+			}
3415
+
3416
+			// process contact details metabox form handler (which will also save the attendee)
3417
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3418
+			$success              = $contact_details_form->process($this->request->requestParams());
3419
+
3420
+			$attendee_update_callbacks = apply_filters(
3421
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3422
+				[]
3423
+			);
3424
+			foreach ($attendee_update_callbacks as $a_callback) {
3425
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3426
+					throw new EE_Error(
3427
+						sprintf(
3428
+							esc_html__(
3429
+								'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.',
3430
+								'event_espresso'
3431
+							),
3432
+							$a_callback
3433
+						)
3434
+					);
3435
+				}
3436
+			}
3437
+		}
3438
+
3439
+		if ($success === false) {
3440
+			EE_Error::add_error(
3441
+				esc_html__(
3442
+					'Something went wrong with updating the meta table data for the registration.',
3443
+					'event_espresso'
3444
+				),
3445
+				__FILE__,
3446
+				__FUNCTION__,
3447
+				__LINE__
3448
+			);
3449
+		}
3450
+	}
3451
+
3452
+
3453
+	public function trash_cpt_item($post_id)
3454
+	{
3455
+	}
3456
+
3457
+
3458
+	public function delete_cpt_item($post_id)
3459
+	{
3460
+	}
3461
+
3462
+
3463
+	public function restore_cpt_item($post_id)
3464
+	{
3465
+	}
3466
+
3467
+
3468
+	protected function _restore_cpt_item($post_id, $revision_id)
3469
+	{
3470
+	}
3471
+
3472
+
3473
+	/**
3474
+	 * @throws EE_Error
3475
+	 * @throws ReflectionException
3476
+	 * @since 4.10.2.p
3477
+	 */
3478
+	public function attendee_editor_metaboxes()
3479
+	{
3480
+		$this->verify_cpt_object();
3481
+		remove_meta_box(
3482
+			'postexcerpt',
3483
+			$this->_cpt_routes[ $this->_req_action ],
3484
+			'normal'
3485
+		);
3486
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3487
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3488
+			$this->addMetaBox(
3489
+				'postexcerpt',
3490
+				esc_html__('Short Biography', 'event_espresso'),
3491
+				'post_excerpt_meta_box',
3492
+				$this->_cpt_routes[ $this->_req_action ]
3493
+			);
3494
+		}
3495
+		if (post_type_supports('espresso_attendees', 'comments')) {
3496
+			$this->addMetaBox(
3497
+				'commentsdiv',
3498
+				esc_html__('Notes on the Contact', 'event_espresso'),
3499
+				'post_comment_meta_box',
3500
+				$this->_cpt_routes[ $this->_req_action ],
3501
+				'normal',
3502
+				'core'
3503
+			);
3504
+		}
3505
+		$this->addMetaBox(
3506
+			'attendee_contact_info',
3507
+			esc_html__('Contact Info', 'event_espresso'),
3508
+			[$this, 'attendee_contact_info'],
3509
+			$this->_cpt_routes[ $this->_req_action ],
3510
+			'side',
3511
+			'core'
3512
+		);
3513
+		$this->addMetaBox(
3514
+			'attendee_details_address',
3515
+			esc_html__('Address Details', 'event_espresso'),
3516
+			[$this, 'attendee_address_details'],
3517
+			$this->_cpt_routes[ $this->_req_action ],
3518
+			'normal',
3519
+			'core'
3520
+		);
3521
+		$this->addMetaBox(
3522
+			'attendee_registrations',
3523
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3524
+			[$this, 'attendee_registrations_meta_box'],
3525
+			$this->_cpt_routes[ $this->_req_action ]
3526
+		);
3527
+	}
3528
+
3529
+
3530
+	/**
3531
+	 * Metabox for attendee contact info
3532
+	 *
3533
+	 * @param WP_Post $post wp post object
3534
+	 * @return void attendee contact info ( and form )
3535
+	 * @throws EE_Error
3536
+	 * @throws InvalidArgumentException
3537
+	 * @throws InvalidDataTypeException
3538
+	 * @throws InvalidInterfaceException
3539
+	 * @throws LogicException
3540
+	 * @throws DomainException
3541
+	 */
3542
+	public function attendee_contact_info($post)
3543
+	{
3544
+		// get attendee object ( should already have it )
3545
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3546
+		$form->enqueueStylesAndScripts();
3547
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3548
+	}
3549
+
3550
+
3551
+	/**
3552
+	 * Return form handler for the contact details metabox
3553
+	 *
3554
+	 * @param EE_Attendee $attendee
3555
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3556
+	 * @throws DomainException
3557
+	 * @throws InvalidArgumentException
3558
+	 * @throws InvalidDataTypeException
3559
+	 * @throws InvalidInterfaceException
3560
+	 */
3561
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3562
+	{
3563
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3564
+	}
3565
+
3566
+
3567
+	/**
3568
+	 * Metabox for attendee details
3569
+	 *
3570
+	 * @param WP_Post $post wp post object
3571
+	 * @throws EE_Error
3572
+	 * @throws ReflectionException
3573
+	 */
3574
+	public function attendee_address_details($post)
3575
+	{
3576
+		// get attendee object (should already have it)
3577
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3578
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3579
+			new EE_Question_Form_Input(
3580
+				EE_Question::new_instance(
3581
+					[
3582
+						'QST_ID'           => 0,
3583
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3584
+						'QST_system'       => 'admin-state',
3585
+					]
3586
+				),
3587
+				EE_Answer::new_instance(
3588
+					[
3589
+						'ANS_ID'    => 0,
3590
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3591
+					]
3592
+				),
3593
+				[
3594
+					'input_id'       => 'STA_ID',
3595
+					'input_name'     => 'STA_ID',
3596
+					'input_prefix'   => '',
3597
+					'append_qstn_id' => false,
3598
+				]
3599
+			)
3600
+		);
3601
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3602
+			new EE_Question_Form_Input(
3603
+				EE_Question::new_instance(
3604
+					[
3605
+						'QST_ID'           => 0,
3606
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3607
+						'QST_system'       => 'admin-country',
3608
+					]
3609
+				),
3610
+				EE_Answer::new_instance(
3611
+					[
3612
+						'ANS_ID'    => 0,
3613
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3614
+					]
3615
+				),
3616
+				[
3617
+					'input_id'       => 'CNT_ISO',
3618
+					'input_name'     => 'CNT_ISO',
3619
+					'input_prefix'   => '',
3620
+					'append_qstn_id' => false,
3621
+				]
3622
+			)
3623
+		);
3624
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3625
+		EEH_Template::display_template($template, $this->_template_args);
3626
+	}
3627
+
3628
+
3629
+	/**
3630
+	 * _attendee_details
3631
+	 *
3632
+	 * @param $post
3633
+	 * @return void
3634
+	 * @throws DomainException
3635
+	 * @throws EE_Error
3636
+	 * @throws InvalidArgumentException
3637
+	 * @throws InvalidDataTypeException
3638
+	 * @throws InvalidInterfaceException
3639
+	 * @throws ReflectionException
3640
+	 */
3641
+	public function attendee_registrations_meta_box($post)
3642
+	{
3643
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3644
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3645
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3646
+		EEH_Template::display_template($template, $this->_template_args);
3647
+	}
3648
+
3649
+
3650
+	/**
3651
+	 * add in the form fields for the attendee edit
3652
+	 *
3653
+	 * @param WP_Post $post wp post object
3654
+	 * @return void echos html for new form.
3655
+	 * @throws DomainException
3656
+	 */
3657
+	public function after_title_form_fields($post)
3658
+	{
3659
+		if ($post->post_type === 'espresso_attendees') {
3660
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3661
+			$template_args['attendee'] = $this->_cpt_model_obj;
3662
+			EEH_Template::display_template($template, $template_args);
3663
+		}
3664
+	}
3665
+
3666
+
3667
+	/**
3668
+	 * _trash_or_restore_attendee
3669
+	 *
3670
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3671
+	 * @return void
3672
+	 * @throws EE_Error
3673
+	 * @throws InvalidArgumentException
3674
+	 * @throws InvalidDataTypeException
3675
+	 * @throws InvalidInterfaceException
3676
+	 */
3677
+	protected function _trash_or_restore_attendees($trash = true)
3678
+	{
3679
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3680
+		$status = $trash ? 'trash' : 'publish';
3681
+		// Checkboxes
3682
+		if ($this->request->requestParamIsSet('checkbox')) {
3683
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3684
+			// if array has more than one element than success message should be plural
3685
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3686
+			// cycle thru checkboxes
3687
+			foreach ($ATT_IDs as $ATT_ID) {
3688
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3689
+				if (! $updated) {
3690
+					$success = 0;
3691
+				}
3692
+			}
3693
+		} else {
3694
+			// grab single id and delete
3695
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3696
+			// update attendee
3697
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3698
+		}
3699
+		$what        = $success > 1
3700
+			? esc_html__('Contacts', 'event_espresso')
3701
+			: esc_html__('Contact', 'event_espresso');
3702
+		$action_desc = $trash
3703
+			? esc_html__('moved to the trash', 'event_espresso')
3704
+			: esc_html__('restored', 'event_espresso');
3705
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3706
+	}
3707 3707
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1026 added lines, -1026 removed lines patch added patch discarded remove patch
@@ -14,595 +14,595 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_Registrations_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var Registrations_Admin_Page
19
-     */
20
-    protected $_admin_page;
21
-
22
-    /**
23
-     * @var RegistrationsListTableUserCapabilities
24
-     */
25
-    protected $caps_handler;
26
-
27
-    /**
28
-     * @var array
29
-     */
30
-    private $_status;
31
-
32
-    /**
33
-     * An array of transaction details for the related transaction to the registration being processed.
34
-     * This is set via the _set_related_details method.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $_transaction_details = [];
39
-
40
-    /**
41
-     * An array of event details for the related event to the registration being processed.
42
-     * This is set via the _set_related_details method.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $_event_details = [];
47
-
48
-
49
-    /**
50
-     * @param Registrations_Admin_Page $admin_page
51
-     */
52
-    public function __construct(Registrations_Admin_Page $admin_page)
53
-    {
54
-        $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
-        $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
57
-            $extra_query_args = [];
58
-            foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
-            }
61
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
-        }
63
-        parent::__construct($admin_page);
64
-        $this->_status = $this->_admin_page->get_registration_status_array();
65
-    }
66
-
67
-
68
-    /**
69
-     * @return void
70
-     * @throws EE_Error
71
-     */
72
-    protected function _setup_data()
73
-    {
74
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
-    }
77
-
78
-
79
-    /**
80
-     * @return void
81
-     */
82
-    protected function _set_properties()
83
-    {
84
-        $return_url          = $this->getReturnUrl();
85
-        $this->_wp_list_args = [
86
-            'singular' => esc_html__('registration', 'event_espresso'),
87
-            'plural'   => esc_html__('registrations', 'event_espresso'),
88
-            'ajax'     => true,
89
-            'screen'   => $this->_admin_page->get_current_screen()->id,
90
-        ];
91
-        $req_data            = $this->_admin_page->get_request_data();
92
-        if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
94
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
-                'id'               => esc_html__('ID', 'event_espresso'),
96
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
-                'actions'          => $this->actionsColumnHeader(),
104
-            ];
105
-            $this->_bottom_buttons = [
106
-                'report' => [
107
-                    'route'         => 'registrations_report',
108
-                    'extra_request' => [
109
-                        'EVT_ID'     => $this->_req_data['event_id'] ?? null,
110
-                        'return_url' => $return_url,
111
-                    ],
112
-                ],
113
-            ];
114
-        } else {
115
-            $this->_columns        = [
116
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117
-                'id'               => esc_html__('ID', 'event_espresso'),
118
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
119
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
120
-                'event_name'       => esc_html__('Event', 'event_espresso'),
121
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
122
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
123
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
124
-                'actions'          => $this->actionsColumnHeader(),
125
-            ];
126
-            $this->_bottom_buttons = [
127
-                'report_all' => [
128
-                    'route'         => 'registrations_report',
129
-                    'extra_request' => [
130
-                        'return_url' => $return_url,
131
-                    ],
132
-                ],
133
-            ];
134
-        }
135
-        $this->_bottom_buttons['report_filtered'] = [
136
-            'route'         => 'registrations_report',
137
-            'extra_request' => [
138
-                'use_filters' => true,
139
-                'return_url'  => $return_url,
140
-            ],
141
-        ];
142
-        $filters                                  = array_diff_key(
143
-            $this->_req_data,
144
-            array_flip(
145
-                [
146
-                    'page',
147
-                    'action',
148
-                    'default_nonce',
149
-                ]
150
-            )
151
-        );
152
-        if (! empty($filters)) {
153
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154
-        }
155
-        $this->_primary_column   = 'id';
156
-        $this->_sortable_columns = [
157
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
158
-            /**
159
-             * Allows users to change the default sort if they wish.
160
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
161
-             * name.
162
-             */
163
-            'ATT_fname'     => [
164
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
165
-                true,
166
-                $this,
167
-            ]
168
-                ? ['ATT_lname' => false]
169
-                : ['ATT_fname' => false],
170
-            'event_name'    => ['event_name' => false],
171
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
172
-            'id'            => ['REG_ID' => false],
173
-        ];
174
-        $this->_hidden_columns   = [];
175
-    }
176
-
177
-
178
-    /**
179
-     * This simply sets up the row class for the table rows.
180
-     * Allows for easier overriding of child methods for setting up sorting.
181
-     *
182
-     * @param EE_Registration $item the current item
183
-     * @return string
184
-     */
185
-    protected function _get_row_class($item): string
186
-    {
187
-        $class = parent::_get_row_class($item);
188
-        if ($this->_has_checkbox_column) {
189
-            $class .= ' has-checkbox-column';
190
-        }
191
-        return $class;
192
-    }
193
-
194
-
195
-    /**
196
-     * Set the $_transaction_details property if not set yet.
197
-     *
198
-     * @param EE_Registration $registration
199
-     * @throws EE_Error
200
-     * @throws InvalidArgumentException
201
-     * @throws ReflectionException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     */
205
-    protected function _set_related_details(EE_Registration $registration)
206
-    {
207
-        $transaction                = $registration->get_first_related('Transaction');
208
-        $status                     = $transaction instanceof EE_Transaction
209
-            ? $transaction->status_ID()
210
-            : EEM_Transaction::failed_status_code;
211
-        $this->_transaction_details = [
212
-            'transaction' => $transaction,
213
-            'status'      => $status,
214
-            'id'          => $transaction instanceof EE_Transaction
215
-                ? $transaction->ID()
216
-                : 0,
217
-            'title_attr'  => sprintf(
218
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
219
-                EEH_Template::pretty_status($status, false, 'sentence')
220
-            ),
221
-        ];
222
-        try {
223
-            $event = $registration->event();
224
-        } catch (EntityNotFoundException $e) {
225
-            $event = null;
226
-        }
227
-        $status               = $event instanceof EE_Event
228
-            ? $event->get_active_status()
229
-            : EE_Datetime::inactive;
230
-        $this->_event_details = [
231
-            'event'      => $event,
232
-            'status'     => $status,
233
-            'id'         => $event instanceof EE_Event
234
-                ? $event->ID()
235
-                : 0,
236
-            'title_attr' => sprintf(
237
-                esc_html__('Edit Event (%s)', 'event_espresso'),
238
-                EEH_Template::pretty_status($status, false, 'sentence')
239
-            ),
240
-        ];
241
-    }
242
-
243
-
244
-    /**
245
-     * @return array
246
-     * @throws EE_Error
247
-     * @throws ReflectionException
248
-     */
249
-    protected function _get_table_filters(): array
250
-    {
251
-        $filters = [];
252
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
253
-        // methods.
254
-        $cur_date     = $this->_req_data['month_range'] ?? '';
255
-        $cur_category = $this->_req_data['EVT_CAT'] ?? -1;
256
-        $reg_status   = $this->_req_data['_reg_status'] ?? '';
257
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
258
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
259
-        $status       = [];
260
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
261
-        foreach ($this->_status as $key => $value) {
262
-            $status[] = ['id' => $key, 'text' => $value];
263
-        }
264
-        if ($this->_view !== 'incomplete') {
265
-            $filters[] = EEH_Form_Fields::select_input(
266
-                '_reg_status',
267
-                $status,
268
-                isset($this->_req_data['_reg_status'])
269
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
270
-                    : ''
271
-            );
272
-        }
273
-        if (isset($this->_req_data['event_id'])) {
274
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
275
-        }
276
-        return $filters;
277
-    }
278
-
279
-
280
-    /**
281
-     * @return void
282
-     * @throws EE_Error
283
-     * @throws InvalidArgumentException
284
-     * @throws InvalidDataTypeException
285
-     * @throws InvalidInterfaceException
286
-     * @throws ReflectionException
287
-     */
288
-    protected function _add_view_counts()
289
-    {
290
-        $this->_views['all']['count']   = $this->_total_registrations();
291
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
292
-        $this->_views['today']['count'] = $this->_total_registrations_today();
293
-        if ($this->caps_handler->userCanTrashRegistrations()) {
294
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
295
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
296
-        }
297
-    }
298
-
299
-
300
-    /**
301
-     * @param string $view
302
-     * @return int
303
-     * @throws EE_Error
304
-     * @throws ReflectionException
305
-     */
306
-    protected function _total_registrations(string $view = ''): int
307
-    {
308
-        $_where = [];
309
-        $EVT_ID = isset($this->_req_data['event_id'])
310
-            ? absint($this->_req_data['event_id'])
311
-            : false;
312
-        if ($EVT_ID) {
313
-            $_where['EVT_ID'] = $EVT_ID;
314
-        }
315
-        switch ($view) {
316
-            case 'trash':
317
-                return EEM_Registration::instance()->count_deleted([$_where]);
318
-            case 'incomplete':
319
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
320
-                break;
321
-            default:
322
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
323
-        }
324
-        return EEM_Registration::instance()->count([$_where]);
325
-    }
326
-
327
-
328
-    /**
329
-     * @return int
330
-     * @throws EE_Error
331
-     * @throws ReflectionException
332
-     */
333
-    protected function _total_registrations_this_month(): int
334
-    {
335
-        $EVT_ID          = isset($this->_req_data['event_id'])
336
-            ? absint($this->_req_data['event_id'])
337
-            : false;
338
-        $_where          = $EVT_ID
339
-            ? ['EVT_ID' => $EVT_ID]
340
-            : [];
341
-        $this_year_r     = date('Y', current_time('timestamp'));
342
-        $time_start      = ' 00:00:00';
343
-        $time_end        = ' 23:59:59';
344
-        $this_month_r    = date('m', current_time('timestamp'));
345
-        $days_this_month = date('t', current_time('timestamp'));
346
-        // setup date query.
347
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
348
-            'REG_date',
349
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
350
-            'Y-m-d H:i:s'
351
-        );
352
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
353
-            'REG_date',
354
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
355
-            'Y-m-d H:i:s'
356
-        );
357
-        $_where['REG_date'] = [
358
-            'BETWEEN',
359
-            [
360
-                $beginning_string,
361
-                $end_string,
362
-            ],
363
-        ];
364
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
365
-        return EEM_Registration::instance()->count([$_where]);
366
-    }
367
-
368
-
369
-    /**
370
-     * @return int
371
-     * @throws EE_Error
372
-     * @throws ReflectionException
373
-     */
374
-    protected function _total_registrations_today(): int
375
-    {
376
-        $EVT_ID             = isset($this->_req_data['event_id'])
377
-            ? absint($this->_req_data['event_id'])
378
-            : false;
379
-        $_where             = $EVT_ID
380
-            ? ['EVT_ID' => $EVT_ID]
381
-            : [];
382
-        $current_date       = date('Y-m-d', current_time('timestamp'));
383
-        $time_start         = ' 00:00:00';
384
-        $time_end           = ' 23:59:59';
385
-        $_where['REG_date'] = [
386
-            'BETWEEN',
387
-            [
388
-                EEM_Registration::instance()->convert_datetime_for_query(
389
-                    'REG_date',
390
-                    $current_date . $time_start,
391
-                    'Y-m-d H:i:s'
392
-                ),
393
-                EEM_Registration::instance()->convert_datetime_for_query(
394
-                    'REG_date',
395
-                    $current_date . $time_end,
396
-                    'Y-m-d H:i:s'
397
-                ),
398
-            ],
399
-        ];
400
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
401
-        return EEM_Registration::instance()->count([$_where]);
402
-    }
403
-
404
-
405
-    /**
406
-     * @param EE_Registration $item
407
-     * @return string
408
-     * @throws EE_Error
409
-     * @throws InvalidArgumentException
410
-     * @throws InvalidDataTypeException
411
-     * @throws InvalidInterfaceException
412
-     * @throws ReflectionException
413
-     */
414
-    public function column_cb($item): string
415
-    {
416
-        /** checkbox/lock **/
417
-        $REG_ID        = $item->ID();
418
-        $transaction   = $item->get_first_related('Transaction');
419
-        $payment_count = $transaction instanceof EE_Transaction
420
-            ? $transaction->count_related('Payment')
421
-            : 0;
422
-
423
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
424
-        $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425
-            ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box" 
17
+	/**
18
+	 * @var Registrations_Admin_Page
19
+	 */
20
+	protected $_admin_page;
21
+
22
+	/**
23
+	 * @var RegistrationsListTableUserCapabilities
24
+	 */
25
+	protected $caps_handler;
26
+
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $_status;
31
+
32
+	/**
33
+	 * An array of transaction details for the related transaction to the registration being processed.
34
+	 * This is set via the _set_related_details method.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected $_transaction_details = [];
39
+
40
+	/**
41
+	 * An array of event details for the related event to the registration being processed.
42
+	 * This is set via the _set_related_details method.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $_event_details = [];
47
+
48
+
49
+	/**
50
+	 * @param Registrations_Admin_Page $admin_page
51
+	 */
52
+	public function __construct(Registrations_Admin_Page $admin_page)
53
+	{
54
+		$this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
+		$req_data = $admin_page->get_request_data();
56
+		if (! empty($req_data['event_id'])) {
57
+			$extra_query_args = [];
58
+			foreach ($admin_page->get_views() as $view_details) {
59
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
+			}
61
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
+		}
63
+		parent::__construct($admin_page);
64
+		$this->_status = $this->_admin_page->get_registration_status_array();
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return void
70
+	 * @throws EE_Error
71
+	 */
72
+	protected function _setup_data()
73
+	{
74
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return void
81
+	 */
82
+	protected function _set_properties()
83
+	{
84
+		$return_url          = $this->getReturnUrl();
85
+		$this->_wp_list_args = [
86
+			'singular' => esc_html__('registration', 'event_espresso'),
87
+			'plural'   => esc_html__('registrations', 'event_espresso'),
88
+			'ajax'     => true,
89
+			'screen'   => $this->_admin_page->get_current_screen()->id,
90
+		];
91
+		$req_data            = $this->_admin_page->get_request_data();
92
+		if (isset($req_data['event_id'])) {
93
+			$this->_columns        = [
94
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
+				'id'               => esc_html__('ID', 'event_espresso'),
96
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
+				'actions'          => $this->actionsColumnHeader(),
104
+			];
105
+			$this->_bottom_buttons = [
106
+				'report' => [
107
+					'route'         => 'registrations_report',
108
+					'extra_request' => [
109
+						'EVT_ID'     => $this->_req_data['event_id'] ?? null,
110
+						'return_url' => $return_url,
111
+					],
112
+				],
113
+			];
114
+		} else {
115
+			$this->_columns        = [
116
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117
+				'id'               => esc_html__('ID', 'event_espresso'),
118
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
119
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
120
+				'event_name'       => esc_html__('Event', 'event_espresso'),
121
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
122
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
123
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
124
+				'actions'          => $this->actionsColumnHeader(),
125
+			];
126
+			$this->_bottom_buttons = [
127
+				'report_all' => [
128
+					'route'         => 'registrations_report',
129
+					'extra_request' => [
130
+						'return_url' => $return_url,
131
+					],
132
+				],
133
+			];
134
+		}
135
+		$this->_bottom_buttons['report_filtered'] = [
136
+			'route'         => 'registrations_report',
137
+			'extra_request' => [
138
+				'use_filters' => true,
139
+				'return_url'  => $return_url,
140
+			],
141
+		];
142
+		$filters                                  = array_diff_key(
143
+			$this->_req_data,
144
+			array_flip(
145
+				[
146
+					'page',
147
+					'action',
148
+					'default_nonce',
149
+				]
150
+			)
151
+		);
152
+		if (! empty($filters)) {
153
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154
+		}
155
+		$this->_primary_column   = 'id';
156
+		$this->_sortable_columns = [
157
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
158
+			/**
159
+			 * Allows users to change the default sort if they wish.
160
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
161
+			 * name.
162
+			 */
163
+			'ATT_fname'     => [
164
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
165
+				true,
166
+				$this,
167
+			]
168
+				? ['ATT_lname' => false]
169
+				: ['ATT_fname' => false],
170
+			'event_name'    => ['event_name' => false],
171
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
172
+			'id'            => ['REG_ID' => false],
173
+		];
174
+		$this->_hidden_columns   = [];
175
+	}
176
+
177
+
178
+	/**
179
+	 * This simply sets up the row class for the table rows.
180
+	 * Allows for easier overriding of child methods for setting up sorting.
181
+	 *
182
+	 * @param EE_Registration $item the current item
183
+	 * @return string
184
+	 */
185
+	protected function _get_row_class($item): string
186
+	{
187
+		$class = parent::_get_row_class($item);
188
+		if ($this->_has_checkbox_column) {
189
+			$class .= ' has-checkbox-column';
190
+		}
191
+		return $class;
192
+	}
193
+
194
+
195
+	/**
196
+	 * Set the $_transaction_details property if not set yet.
197
+	 *
198
+	 * @param EE_Registration $registration
199
+	 * @throws EE_Error
200
+	 * @throws InvalidArgumentException
201
+	 * @throws ReflectionException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 */
205
+	protected function _set_related_details(EE_Registration $registration)
206
+	{
207
+		$transaction                = $registration->get_first_related('Transaction');
208
+		$status                     = $transaction instanceof EE_Transaction
209
+			? $transaction->status_ID()
210
+			: EEM_Transaction::failed_status_code;
211
+		$this->_transaction_details = [
212
+			'transaction' => $transaction,
213
+			'status'      => $status,
214
+			'id'          => $transaction instanceof EE_Transaction
215
+				? $transaction->ID()
216
+				: 0,
217
+			'title_attr'  => sprintf(
218
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
219
+				EEH_Template::pretty_status($status, false, 'sentence')
220
+			),
221
+		];
222
+		try {
223
+			$event = $registration->event();
224
+		} catch (EntityNotFoundException $e) {
225
+			$event = null;
226
+		}
227
+		$status               = $event instanceof EE_Event
228
+			? $event->get_active_status()
229
+			: EE_Datetime::inactive;
230
+		$this->_event_details = [
231
+			'event'      => $event,
232
+			'status'     => $status,
233
+			'id'         => $event instanceof EE_Event
234
+				? $event->ID()
235
+				: 0,
236
+			'title_attr' => sprintf(
237
+				esc_html__('Edit Event (%s)', 'event_espresso'),
238
+				EEH_Template::pretty_status($status, false, 'sentence')
239
+			),
240
+		];
241
+	}
242
+
243
+
244
+	/**
245
+	 * @return array
246
+	 * @throws EE_Error
247
+	 * @throws ReflectionException
248
+	 */
249
+	protected function _get_table_filters(): array
250
+	{
251
+		$filters = [];
252
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
253
+		// methods.
254
+		$cur_date     = $this->_req_data['month_range'] ?? '';
255
+		$cur_category = $this->_req_data['EVT_CAT'] ?? -1;
256
+		$reg_status   = $this->_req_data['_reg_status'] ?? '';
257
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
258
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
259
+		$status       = [];
260
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
261
+		foreach ($this->_status as $key => $value) {
262
+			$status[] = ['id' => $key, 'text' => $value];
263
+		}
264
+		if ($this->_view !== 'incomplete') {
265
+			$filters[] = EEH_Form_Fields::select_input(
266
+				'_reg_status',
267
+				$status,
268
+				isset($this->_req_data['_reg_status'])
269
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
270
+					: ''
271
+			);
272
+		}
273
+		if (isset($this->_req_data['event_id'])) {
274
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
275
+		}
276
+		return $filters;
277
+	}
278
+
279
+
280
+	/**
281
+	 * @return void
282
+	 * @throws EE_Error
283
+	 * @throws InvalidArgumentException
284
+	 * @throws InvalidDataTypeException
285
+	 * @throws InvalidInterfaceException
286
+	 * @throws ReflectionException
287
+	 */
288
+	protected function _add_view_counts()
289
+	{
290
+		$this->_views['all']['count']   = $this->_total_registrations();
291
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
292
+		$this->_views['today']['count'] = $this->_total_registrations_today();
293
+		if ($this->caps_handler->userCanTrashRegistrations()) {
294
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
295
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
296
+		}
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param string $view
302
+	 * @return int
303
+	 * @throws EE_Error
304
+	 * @throws ReflectionException
305
+	 */
306
+	protected function _total_registrations(string $view = ''): int
307
+	{
308
+		$_where = [];
309
+		$EVT_ID = isset($this->_req_data['event_id'])
310
+			? absint($this->_req_data['event_id'])
311
+			: false;
312
+		if ($EVT_ID) {
313
+			$_where['EVT_ID'] = $EVT_ID;
314
+		}
315
+		switch ($view) {
316
+			case 'trash':
317
+				return EEM_Registration::instance()->count_deleted([$_where]);
318
+			case 'incomplete':
319
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
320
+				break;
321
+			default:
322
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
323
+		}
324
+		return EEM_Registration::instance()->count([$_where]);
325
+	}
326
+
327
+
328
+	/**
329
+	 * @return int
330
+	 * @throws EE_Error
331
+	 * @throws ReflectionException
332
+	 */
333
+	protected function _total_registrations_this_month(): int
334
+	{
335
+		$EVT_ID          = isset($this->_req_data['event_id'])
336
+			? absint($this->_req_data['event_id'])
337
+			: false;
338
+		$_where          = $EVT_ID
339
+			? ['EVT_ID' => $EVT_ID]
340
+			: [];
341
+		$this_year_r     = date('Y', current_time('timestamp'));
342
+		$time_start      = ' 00:00:00';
343
+		$time_end        = ' 23:59:59';
344
+		$this_month_r    = date('m', current_time('timestamp'));
345
+		$days_this_month = date('t', current_time('timestamp'));
346
+		// setup date query.
347
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
348
+			'REG_date',
349
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
350
+			'Y-m-d H:i:s'
351
+		);
352
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
353
+			'REG_date',
354
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
355
+			'Y-m-d H:i:s'
356
+		);
357
+		$_where['REG_date'] = [
358
+			'BETWEEN',
359
+			[
360
+				$beginning_string,
361
+				$end_string,
362
+			],
363
+		];
364
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
365
+		return EEM_Registration::instance()->count([$_where]);
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return int
371
+	 * @throws EE_Error
372
+	 * @throws ReflectionException
373
+	 */
374
+	protected function _total_registrations_today(): int
375
+	{
376
+		$EVT_ID             = isset($this->_req_data['event_id'])
377
+			? absint($this->_req_data['event_id'])
378
+			: false;
379
+		$_where             = $EVT_ID
380
+			? ['EVT_ID' => $EVT_ID]
381
+			: [];
382
+		$current_date       = date('Y-m-d', current_time('timestamp'));
383
+		$time_start         = ' 00:00:00';
384
+		$time_end           = ' 23:59:59';
385
+		$_where['REG_date'] = [
386
+			'BETWEEN',
387
+			[
388
+				EEM_Registration::instance()->convert_datetime_for_query(
389
+					'REG_date',
390
+					$current_date . $time_start,
391
+					'Y-m-d H:i:s'
392
+				),
393
+				EEM_Registration::instance()->convert_datetime_for_query(
394
+					'REG_date',
395
+					$current_date . $time_end,
396
+					'Y-m-d H:i:s'
397
+				),
398
+			],
399
+		];
400
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
401
+		return EEM_Registration::instance()->count([$_where]);
402
+	}
403
+
404
+
405
+	/**
406
+	 * @param EE_Registration $item
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 * @throws InvalidArgumentException
410
+	 * @throws InvalidDataTypeException
411
+	 * @throws InvalidInterfaceException
412
+	 * @throws ReflectionException
413
+	 */
414
+	public function column_cb($item): string
415
+	{
416
+		/** checkbox/lock **/
417
+		$REG_ID        = $item->ID();
418
+		$transaction   = $item->get_first_related('Transaction');
419
+		$payment_count = $transaction instanceof EE_Transaction
420
+			? $transaction->count_related('Payment')
421
+			: 0;
422
+
423
+		$content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
424
+		$content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425
+			? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box" 
426 426
                     aria-label="' . $this->lockedRegMessage() . '"></span>'
427
-            : '';
428
-        return $this->columnContent('cb', $content, 'center');
429
-    }
430
-
431
-
432
-    private function lockedRegMessage(): string
433
-    {
434
-        return esc_html__(
435
-            'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
436
-            'event_espresso'
437
-        );
438
-    }
439
-
440
-
441
-    /**
442
-     * @param EE_Registration $registration
443
-     * @return string
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     * @throws ReflectionException
449
-     */
450
-    public function column_id(EE_Registration $registration): string
451
-    {
452
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
453
-        $content .= '<span class="show-on-mobile-view-only">';
454
-        $content .= $this->column_ATT_fname($registration, false);
455
-        $content .= '</span>';
456
-
457
-        return $this->columnContent('id', $content, 'end');
458
-    }
459
-
460
-
461
-    /**
462
-     * @param EE_Registration $registration
463
-     * @param bool            $prep_content
464
-     * @return string
465
-     * @throws EE_Error
466
-     * @throws ReflectionException
467
-     */
468
-    public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
469
-    {
470
-
471
-        $status         = esc_attr($registration->status_ID());
472
-        $pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
473
-        $prime_reg_star = $registration->count() === 1
474
-            ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
475
-            : '';
476
-
477
-        $group_count = '
427
+			: '';
428
+		return $this->columnContent('cb', $content, 'center');
429
+	}
430
+
431
+
432
+	private function lockedRegMessage(): string
433
+	{
434
+		return esc_html__(
435
+			'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
436
+			'event_espresso'
437
+		);
438
+	}
439
+
440
+
441
+	/**
442
+	 * @param EE_Registration $registration
443
+	 * @return string
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 * @throws ReflectionException
449
+	 */
450
+	public function column_id(EE_Registration $registration): string
451
+	{
452
+		$content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
453
+		$content .= '<span class="show-on-mobile-view-only">';
454
+		$content .= $this->column_ATT_fname($registration, false);
455
+		$content .= '</span>';
456
+
457
+		return $this->columnContent('id', $content, 'end');
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param EE_Registration $registration
463
+	 * @param bool            $prep_content
464
+	 * @return string
465
+	 * @throws EE_Error
466
+	 * @throws ReflectionException
467
+	 */
468
+	public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
469
+	{
470
+
471
+		$status         = esc_attr($registration->status_ID());
472
+		$pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
473
+		$prime_reg_star = $registration->count() === 1
474
+			? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
475
+			: '';
476
+
477
+		$group_count = '
478 478
             <span class="reg-count-group-size" >
479 479
                 ' . sprintf(
480
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
481
-            $registration->count(),
482
-            $registration->group_size()
483
-        ) . '
480
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
481
+			$registration->count(),
482
+			$registration->group_size()
483
+		) . '
484 484
             </span >';
485 485
 
486
-        $content = '
486
+		$content = '
487 487
         <div class="ee-layout-row">
488 488
             <span aria-label="' . $pretty_status . '" 
489 489
                   class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
490 490
             ></span>
491 491
             ' . $this->viewRegistrationLink($registration, $status)
492
-                   . $prime_reg_star
493
-                   . $group_count . '
492
+				   . $prime_reg_star
493
+				   . $group_count . '
494 494
             <span class="spacer"></span>
495 495
             <span>
496 496
                 ' . sprintf(
497
-                       esc_html__('Reg Code: %s', 'event_espresso'),
498
-                       $registration->get('REG_code')
499
-                   ) . '
497
+					   esc_html__('Reg Code: %s', 'event_espresso'),
498
+					   $registration->get('REG_code')
499
+				   ) . '
500 500
             </span>
501 501
         </div>';
502 502
 
503
-        $url_params = ['_REG_ID' => $registration->ID()];
504
-        if (isset($this->_req_data['event_id'])) {
505
-            $url_params['event_id'] = $registration->event_ID();
506
-        }
507
-        // trash/restore/delete actions
508
-        $actions = $this->trashRegistrationLink($registration, $url_params);
509
-        $actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
510
-        $actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
511
-
512
-        $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
513
-
514
-        return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
515
-    }
516
-
517
-
518
-    /**
519
-     * @param EE_Registration $registration
520
-     * @param bool            $prep_content
521
-     * @return string
522
-     * @throws EE_Error
523
-     * @throws ReflectionException
524
-     */
525
-    public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
526
-    {
527
-        $this->_set_related_details($registration);
528
-        // Build row actions
529
-        $content = $this->caps_handler->userCanViewTransaction()
530
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
531
-              . $this->viewTransactionUrl()
532
-              . '" aria-label="'
533
-              . esc_attr($this->_transaction_details['title_attr'])
534
-              . '">'
535
-              . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
536
-              . '</a>'
537
-            : $registration->get_i18n_datetime('REG_date');
538
-
539
-        return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
540
-    }
541
-
542
-
543
-    /**
544
-     * @param EE_Registration $registration
545
-     * @return string
546
-     * @throws EE_Error
547
-     * @throws InvalidArgumentException
548
-     * @throws InvalidDataTypeException
549
-     * @throws InvalidInterfaceException
550
-     * @throws ReflectionException
551
-     */
552
-    public function column_event_name(EE_Registration $registration): string
553
-    {
554
-        $this->_set_related_details($registration);
555
-        $EVT_ID     = $registration->event_ID();
556
-        $event_name = $registration->event_name();
557
-        $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
558
-        $event_name = wp_trim_words($event_name, 30, '...');
559
-        $edit_event = $this->editEventLink($EVT_ID, $event_name);
560
-        $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
561
-        $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
562
-
563
-        return $this->columnContent('event_name', $content);
564
-    }
565
-
566
-
567
-    /**
568
-     * @param EE_Registration $registration
569
-     * @return string
570
-     * @throws EE_Error
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     * @throws ReflectionException
575
-     */
576
-    public function column_DTT_EVT_start(EE_Registration $registration): string
577
-    {
578
-        $datetime_strings = [];
579
-        $ticket           = $registration->ticket();
580
-        if ($ticket instanceof EE_Ticket) {
581
-            $remove_defaults = ['default_where_conditions' => 'none'];
582
-            $datetimes       = $ticket->datetimes($remove_defaults);
583
-            foreach ($datetimes as $datetime) {
584
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
585
-            }
586
-            $content = $this->generateDisplayForDatetimes($datetime_strings);
587
-        } else {
588
-            $content = esc_html__('There is no ticket on this registration', 'event_espresso');
589
-        }
590
-        return $this->columnContent('DTT_EVT_start', $content);
591
-    }
592
-
593
-
594
-    /**
595
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
596
-     *
597
-     * @param array $datetime_strings
598
-     * @return string
599
-     */
600
-    public function generateDisplayForDatetimes(array $datetime_strings): string
601
-    {
602
-        // get first item for initial visibility
603
-        $content = array_shift($datetime_strings);
604
-        if (! empty($datetime_strings)) {
605
-            $content .= '
503
+		$url_params = ['_REG_ID' => $registration->ID()];
504
+		if (isset($this->_req_data['event_id'])) {
505
+			$url_params['event_id'] = $registration->event_ID();
506
+		}
507
+		// trash/restore/delete actions
508
+		$actions = $this->trashRegistrationLink($registration, $url_params);
509
+		$actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
510
+		$actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
511
+
512
+		$content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
513
+
514
+		return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param EE_Registration $registration
520
+	 * @param bool            $prep_content
521
+	 * @return string
522
+	 * @throws EE_Error
523
+	 * @throws ReflectionException
524
+	 */
525
+	public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
526
+	{
527
+		$this->_set_related_details($registration);
528
+		// Build row actions
529
+		$content = $this->caps_handler->userCanViewTransaction()
530
+			? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
531
+			  . $this->viewTransactionUrl()
532
+			  . '" aria-label="'
533
+			  . esc_attr($this->_transaction_details['title_attr'])
534
+			  . '">'
535
+			  . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
536
+			  . '</a>'
537
+			: $registration->get_i18n_datetime('REG_date');
538
+
539
+		return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
540
+	}
541
+
542
+
543
+	/**
544
+	 * @param EE_Registration $registration
545
+	 * @return string
546
+	 * @throws EE_Error
547
+	 * @throws InvalidArgumentException
548
+	 * @throws InvalidDataTypeException
549
+	 * @throws InvalidInterfaceException
550
+	 * @throws ReflectionException
551
+	 */
552
+	public function column_event_name(EE_Registration $registration): string
553
+	{
554
+		$this->_set_related_details($registration);
555
+		$EVT_ID     = $registration->event_ID();
556
+		$event_name = $registration->event_name();
557
+		$event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
558
+		$event_name = wp_trim_words($event_name, 30, '...');
559
+		$edit_event = $this->editEventLink($EVT_ID, $event_name);
560
+		$actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
561
+		$content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
562
+
563
+		return $this->columnContent('event_name', $content);
564
+	}
565
+
566
+
567
+	/**
568
+	 * @param EE_Registration $registration
569
+	 * @return string
570
+	 * @throws EE_Error
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 * @throws ReflectionException
575
+	 */
576
+	public function column_DTT_EVT_start(EE_Registration $registration): string
577
+	{
578
+		$datetime_strings = [];
579
+		$ticket           = $registration->ticket();
580
+		if ($ticket instanceof EE_Ticket) {
581
+			$remove_defaults = ['default_where_conditions' => 'none'];
582
+			$datetimes       = $ticket->datetimes($remove_defaults);
583
+			foreach ($datetimes as $datetime) {
584
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
585
+			}
586
+			$content = $this->generateDisplayForDatetimes($datetime_strings);
587
+		} else {
588
+			$content = esc_html__('There is no ticket on this registration', 'event_espresso');
589
+		}
590
+		return $this->columnContent('DTT_EVT_start', $content);
591
+	}
592
+
593
+
594
+	/**
595
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
596
+	 *
597
+	 * @param array $datetime_strings
598
+	 * @return string
599
+	 */
600
+	public function generateDisplayForDatetimes(array $datetime_strings): string
601
+	{
602
+		// get first item for initial visibility
603
+		$content = array_shift($datetime_strings);
604
+		if (! empty($datetime_strings)) {
605
+			$content .= '
606 606
                 <div class="ee-registration-event-datetimes-container-wrap">
607 607
                     <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '" 
608 608
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
@@ -613,539 +613,539 @@  discard block
 block discarded – undo
613 613
                         ' . implode("", $datetime_strings) . '
614 614
                     </div>
615 615
                 </div>';
616
-        }
617
-        return $content;
618
-    }
619
-
620
-
621
-    /**
622
-     * @param EE_Registration $registration
623
-     * @return string
624
-     * @throws EE_Error
625
-     * @throws InvalidArgumentException
626
-     * @throws InvalidDataTypeException
627
-     * @throws InvalidInterfaceException
628
-     * @throws ReflectionException
629
-     */
630
-    public function column_ATT_email(EE_Registration $registration): string
631
-    {
632
-        $attendee = $registration->get_first_related('Attendee');
633
-        $content  = ! $attendee instanceof EE_Attendee
634
-            ? esc_html__('No attached contact record.', 'event_espresso')
635
-            : $attendee->email();
636
-        return $this->columnContent('ATT_email', $content);
637
-    }
638
-
639
-
640
-    /**
641
-     * @param EE_Registration $registration
642
-     * @return string
643
-     */
644
-    public function column__REG_count(EE_Registration $registration): string
645
-    {
646
-        $content =
647
-            sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
648
-        return $this->columnContent('_REG_count', $content);
649
-    }
650
-
651
-
652
-    /**
653
-     * @param EE_Registration $registration
654
-     * @return string
655
-     * @throws EE_Error
656
-     * @throws ReflectionException
657
-     */
658
-    public function column_PRC_amount(EE_Registration $registration): string
659
-    {
660
-        $ticket   = $registration->ticket();
661
-        $req_data = $this->_admin_page->get_request_data();
662
-
663
-        $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
665
-            : '';
666
-
667
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
-        $content        .= $registration->final_price() > 0
669
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
616
+		}
617
+		return $content;
618
+	}
619
+
620
+
621
+	/**
622
+	 * @param EE_Registration $registration
623
+	 * @return string
624
+	 * @throws EE_Error
625
+	 * @throws InvalidArgumentException
626
+	 * @throws InvalidDataTypeException
627
+	 * @throws InvalidInterfaceException
628
+	 * @throws ReflectionException
629
+	 */
630
+	public function column_ATT_email(EE_Registration $registration): string
631
+	{
632
+		$attendee = $registration->get_first_related('Attendee');
633
+		$content  = ! $attendee instanceof EE_Attendee
634
+			? esc_html__('No attached contact record.', 'event_espresso')
635
+			: $attendee->email();
636
+		return $this->columnContent('ATT_email', $content);
637
+	}
638
+
639
+
640
+	/**
641
+	 * @param EE_Registration $registration
642
+	 * @return string
643
+	 */
644
+	public function column__REG_count(EE_Registration $registration): string
645
+	{
646
+		$content =
647
+			sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
648
+		return $this->columnContent('_REG_count', $content);
649
+	}
650
+
651
+
652
+	/**
653
+	 * @param EE_Registration $registration
654
+	 * @return string
655
+	 * @throws EE_Error
656
+	 * @throws ReflectionException
657
+	 */
658
+	public function column_PRC_amount(EE_Registration $registration): string
659
+	{
660
+		$ticket   = $registration->ticket();
661
+		$req_data = $this->_admin_page->get_request_data();
662
+
663
+		$content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
+			? '<div class="TKT_name">' . $ticket->name() . '</div>'
665
+			: '';
666
+
667
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
+		$content        .= $registration->final_price() > 0
669
+			? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
670 670
                 ' . $registration->pretty_final_price() . '
671 671
                </span>'
672
-            // free event
673
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
674
-
675
-        return $this->columnContent('PRC_amount', $content, 'end');
676
-    }
677
-
678
-
679
-    /**
680
-     * @param EE_Registration $registration
681
-     * @return string
682
-     * @throws EE_Error
683
-     * @throws ReflectionException
684
-     */
685
-    public function column__REG_final_price(EE_Registration $registration): string
686
-    {
687
-        $ticket   = $registration->ticket();
688
-        $req_data = $this->_admin_page->get_request_data();
689
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
690
-            ? ''
691
-            : '<span class="TKT_name ee-status-color--'
692
-              . $ticket->ticket_status()
693
-              . '">'
694
-              . $ticket->name()
695
-              . '</span> ';
696
-
697
-        $content .= '
672
+			// free event
673
+			: '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
674
+
675
+		return $this->columnContent('PRC_amount', $content, 'end');
676
+	}
677
+
678
+
679
+	/**
680
+	 * @param EE_Registration $registration
681
+	 * @return string
682
+	 * @throws EE_Error
683
+	 * @throws ReflectionException
684
+	 */
685
+	public function column__REG_final_price(EE_Registration $registration): string
686
+	{
687
+		$ticket   = $registration->ticket();
688
+		$req_data = $this->_admin_page->get_request_data();
689
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
690
+			? ''
691
+			: '<span class="TKT_name ee-status-color--'
692
+			  . $ticket->ticket_status()
693
+			  . '">'
694
+			  . $ticket->name()
695
+			  . '</span> ';
696
+
697
+		$content .= '
698 698
             <span class="reg-overview-paid-event-spn">
699 699
                 ' . $registration->pretty_final_price() . '
700 700
             </span>';
701
-        return $this->columnContent('_REG_final_price', $content, 'end');
702
-    }
703
-
704
-
705
-    /**
706
-     * @param EE_Registration $registration
707
-     * @return string
708
-     * @throws EE_Error
709
-     */
710
-    public function column__REG_paid(EE_Registration $registration): string
711
-    {
712
-        $payment_method      = $registration->payment_method();
713
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
714
-            ? $payment_method->admin_name()
715
-            : esc_html__('Unknown', 'event_espresso');
716
-
717
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718
-        $content        = '
701
+		return $this->columnContent('_REG_final_price', $content, 'end');
702
+	}
703
+
704
+
705
+	/**
706
+	 * @param EE_Registration $registration
707
+	 * @return string
708
+	 * @throws EE_Error
709
+	 */
710
+	public function column__REG_paid(EE_Registration $registration): string
711
+	{
712
+		$payment_method      = $registration->payment_method();
713
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
714
+			? $payment_method->admin_name()
715
+			: esc_html__('Unknown', 'event_espresso');
716
+
717
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718
+		$content        = '
719 719
             <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
720 720
                 ' . $registration->pretty_paid() . '
721 721
             </span>';
722
-        if ($registration->paid() > 0) {
723
-            $content .= '<span class="ee-status-text-small">'
724
-                        . sprintf(
725
-                            esc_html__('...via %s', 'event_espresso'),
726
-                            $payment_method_name
727
-                        )
728
-                        . '</span>';
729
-        }
730
-        return $this->columnContent('_REG_paid', $content, 'end');
731
-    }
732
-
733
-
734
-    /**
735
-     * @param EE_Registration $registration
736
-     * @return string
737
-     * @throws EE_Error
738
-     * @throws EntityNotFoundException
739
-     * @throws InvalidArgumentException
740
-     * @throws InvalidDataTypeException
741
-     * @throws InvalidInterfaceException
742
-     * @throws ReflectionException
743
-     */
744
-    public function column_TXN_total(EE_Registration $registration): string
745
-    {
746
-        if ($registration->transaction()) {
747
-            $content = $this->caps_handler->userCanViewTransaction()
748
-                ? '
722
+		if ($registration->paid() > 0) {
723
+			$content .= '<span class="ee-status-text-small">'
724
+						. sprintf(
725
+							esc_html__('...via %s', 'event_espresso'),
726
+							$payment_method_name
727
+						)
728
+						. '</span>';
729
+		}
730
+		return $this->columnContent('_REG_paid', $content, 'end');
731
+	}
732
+
733
+
734
+	/**
735
+	 * @param EE_Registration $registration
736
+	 * @return string
737
+	 * @throws EE_Error
738
+	 * @throws EntityNotFoundException
739
+	 * @throws InvalidArgumentException
740
+	 * @throws InvalidDataTypeException
741
+	 * @throws InvalidInterfaceException
742
+	 * @throws ReflectionException
743
+	 */
744
+	public function column_TXN_total(EE_Registration $registration): string
745
+	{
746
+		if ($registration->transaction()) {
747
+			$content = $this->caps_handler->userCanViewTransaction()
748
+				? '
749 749
                     <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '" 
750 750
                         href="' . $this->viewTransactionUrl() . '" 
751 751
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
752 752
                     >
753 753
                         ' . $registration->transaction()->pretty_total() . '
754 754
                     </a>'
755
-                : $registration->transaction()->pretty_total();
756
-        } else {
757
-            $content = esc_html__("None", "event_espresso");
758
-        }
759
-        return $this->columnContent('TXN_total', $content, 'end');
760
-    }
761
-
762
-
763
-    /**
764
-     * @param EE_Registration $registration
765
-     * @return string
766
-     * @throws EE_Error
767
-     * @throws EntityNotFoundException
768
-     * @throws InvalidArgumentException
769
-     * @throws InvalidDataTypeException
770
-     * @throws InvalidInterfaceException
771
-     * @throws ReflectionException
772
-     */
773
-    public function column_TXN_paid(EE_Registration $registration): string
774
-    {
775
-        $content = '&nbsp;';
776
-        $align   = 'end';
777
-        if ($registration->count() === 1) {
778
-            $transaction = $registration->transaction()
779
-                ? $registration->transaction()
780
-                : EE_Transaction::new_instance();
781
-            if ($transaction->paid() >= $transaction->total()) {
782
-                $align   = 'center';
783
-                $content = '<span class="dashicons dashicons-yes green-icon"></span>';
784
-            } else {
785
-                $content = $this->caps_handler->userCanViewTransaction()
786
-                    ? '
755
+				: $registration->transaction()->pretty_total();
756
+		} else {
757
+			$content = esc_html__("None", "event_espresso");
758
+		}
759
+		return $this->columnContent('TXN_total', $content, 'end');
760
+	}
761
+
762
+
763
+	/**
764
+	 * @param EE_Registration $registration
765
+	 * @return string
766
+	 * @throws EE_Error
767
+	 * @throws EntityNotFoundException
768
+	 * @throws InvalidArgumentException
769
+	 * @throws InvalidDataTypeException
770
+	 * @throws InvalidInterfaceException
771
+	 * @throws ReflectionException
772
+	 */
773
+	public function column_TXN_paid(EE_Registration $registration): string
774
+	{
775
+		$content = '&nbsp;';
776
+		$align   = 'end';
777
+		if ($registration->count() === 1) {
778
+			$transaction = $registration->transaction()
779
+				? $registration->transaction()
780
+				: EE_Transaction::new_instance();
781
+			if ($transaction->paid() >= $transaction->total()) {
782
+				$align   = 'center';
783
+				$content = '<span class="dashicons dashicons-yes green-icon"></span>';
784
+			} else {
785
+				$content = $this->caps_handler->userCanViewTransaction()
786
+					? '
787 787
                     <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '" 
788 788
                         href="' . $this->viewTransactionUrl() . '"  
789 789
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
790 790
                     >
791 791
                         ' . $registration->transaction()->pretty_paid() . '
792 792
                     </a>'
793
-                    : $registration->transaction()->pretty_paid();
794
-            }
795
-        }
796
-        return $this->columnContent('TXN_paid', $content, $align);
797
-    }
798
-
799
-
800
-    /**
801
-     * @param EE_Registration $registration
802
-     * @return string
803
-     * @throws EE_Error
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     * @throws ReflectionException
808
-     */
809
-    public function column_actions(EE_Registration $registration): string
810
-    {
811
-        $attendee = $registration->attendee();
812
-        $this->_set_related_details($registration);
813
-
814
-        // Build and filter row actions
815
-        $actions = apply_filters(
816
-            'FHEE__EE_Registrations_List_Table__column_actions__actions',
817
-            [
818
-                'view_lnk'               => $this->viewRegistrationAction($registration),
819
-                'edit_lnk'               => $this->editContactAction($registration, $attendee),
820
-                'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
821
-                'view_txn_lnk'           => $this->viewTransactionAction(),
822
-                'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
823
-                'filtered_messages_link' => $this->viewNotificationsAction($registration),
824
-            ],
825
-            $registration,
826
-            $this
827
-        );
828
-
829
-        $content = $this->_action_string(
830
-            implode('', $actions),
831
-            $registration,
832
-            'div',
833
-            'reg-overview-actions ee-list-table-actions'
834
-        );
835
-
836
-        return $this->columnContent('actions', $this->actionsModalMenu($content));
837
-    }
838
-
839
-
840
-    /**
841
-     * @throws EE_Error
842
-     * @throws ReflectionException
843
-     */
844
-    private function viewRegistrationUrl(EE_Registration $registration): string
845
-    {
846
-        return EE_Admin_Page::add_query_args_and_nonce(
847
-            [
848
-                'action'  => 'view_registration',
849
-                '_REG_ID' => $registration->ID(),
850
-            ],
851
-            REG_ADMIN_URL
852
-        );
853
-    }
854
-
855
-
856
-    /**
857
-     * @throws EE_Error
858
-     * @throws ReflectionException
859
-     */
860
-    private function viewRegistrationLink(
861
-        EE_Registration $registration,
862
-        string $status
863
-    ): string {
864
-        $attendee      = $registration->attendee();
865
-        $attendee_name = $attendee instanceof EE_Attendee
866
-            ? $attendee->full_name()
867
-            : '';
868
-        return $this->caps_handler->userCanReadRegistration($registration)
869
-            ? '
793
+					: $registration->transaction()->pretty_paid();
794
+			}
795
+		}
796
+		return $this->columnContent('TXN_paid', $content, $align);
797
+	}
798
+
799
+
800
+	/**
801
+	 * @param EE_Registration $registration
802
+	 * @return string
803
+	 * @throws EE_Error
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws ReflectionException
808
+	 */
809
+	public function column_actions(EE_Registration $registration): string
810
+	{
811
+		$attendee = $registration->attendee();
812
+		$this->_set_related_details($registration);
813
+
814
+		// Build and filter row actions
815
+		$actions = apply_filters(
816
+			'FHEE__EE_Registrations_List_Table__column_actions__actions',
817
+			[
818
+				'view_lnk'               => $this->viewRegistrationAction($registration),
819
+				'edit_lnk'               => $this->editContactAction($registration, $attendee),
820
+				'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
821
+				'view_txn_lnk'           => $this->viewTransactionAction(),
822
+				'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
823
+				'filtered_messages_link' => $this->viewNotificationsAction($registration),
824
+			],
825
+			$registration,
826
+			$this
827
+		);
828
+
829
+		$content = $this->_action_string(
830
+			implode('', $actions),
831
+			$registration,
832
+			'div',
833
+			'reg-overview-actions ee-list-table-actions'
834
+		);
835
+
836
+		return $this->columnContent('actions', $this->actionsModalMenu($content));
837
+	}
838
+
839
+
840
+	/**
841
+	 * @throws EE_Error
842
+	 * @throws ReflectionException
843
+	 */
844
+	private function viewRegistrationUrl(EE_Registration $registration): string
845
+	{
846
+		return EE_Admin_Page::add_query_args_and_nonce(
847
+			[
848
+				'action'  => 'view_registration',
849
+				'_REG_ID' => $registration->ID(),
850
+			],
851
+			REG_ADMIN_URL
852
+		);
853
+	}
854
+
855
+
856
+	/**
857
+	 * @throws EE_Error
858
+	 * @throws ReflectionException
859
+	 */
860
+	private function viewRegistrationLink(
861
+		EE_Registration $registration,
862
+		string $status
863
+	): string {
864
+		$attendee      = $registration->attendee();
865
+		$attendee_name = $attendee instanceof EE_Attendee
866
+			? $attendee->full_name()
867
+			: '';
868
+		return $this->caps_handler->userCanReadRegistration($registration)
869
+			? '
870 870
             <a  href="' . $this->viewRegistrationUrl($registration) . '"  
871 871
                 class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" 
872 872
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
873 873
             >
874 874
                 ' . $attendee_name . '
875 875
             </a>'
876
-            : $attendee_name;
877
-    }
878
-
879
-
880
-    /**
881
-     * @throws EE_Error
882
-     * @throws ReflectionException
883
-     */
884
-    private function viewRegistrationAction(EE_Registration $registration): string
885
-    {
886
-        return $this->caps_handler->userCanReadRegistration($registration)
887
-            ? '
876
+			: $attendee_name;
877
+	}
878
+
879
+
880
+	/**
881
+	 * @throws EE_Error
882
+	 * @throws ReflectionException
883
+	 */
884
+	private function viewRegistrationAction(EE_Registration $registration): string
885
+	{
886
+		return $this->caps_handler->userCanReadRegistration($registration)
887
+			? '
888 888
             <a  href="' . $this->viewRegistrationUrl($registration) . '"  
889 889
                 class="ee-aria-tooltip button button--icon-only"
890 890
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
891 891
             >
892 892
                 <span class="dashicons dashicons-clipboard"></span>
893 893
             </a>'
894
-            : '';
895
-    }
896
-
897
-
898
-    private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
899
-    {
900
-
901
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
902
-            $edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
903
-                [
904
-                    'action' => 'edit_attendee',
905
-                    'post'   => $registration->attendee_ID(),
906
-                ],
907
-                REG_ADMIN_URL
908
-            );
909
-            return '
894
+			: '';
895
+	}
896
+
897
+
898
+	private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
899
+	{
900
+
901
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
902
+			$edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
903
+				[
904
+					'action' => 'edit_attendee',
905
+					'post'   => $registration->attendee_ID(),
906
+				],
907
+				REG_ADMIN_URL
908
+			);
909
+			return '
910 910
                 <a href="' . $edit_link_url . '" 
911 911
                    aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" 
912 912
                    class="ee-aria-tooltip button button--secondary button--icon-only"
913 913
                 >
914 914
                     <span class="dashicons dashicons-admin-users"></span>
915 915
                 </a>';
916
-        }
917
-        return '';
918
-    }
919
-
920
-
921
-    /**
922
-     * @throws EE_Error
923
-     * @throws ReflectionException
924
-     */
925
-    private function resendRegistrationMessageAction(
926
-        EE_Registration $registration,
927
-        ?EE_Attendee $attendee = null
928
-    ): string {
929
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
930
-            $resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
931
-                [
932
-                    'action'  => 'resend_registration',
933
-                    '_REG_ID' => $registration->ID(),
934
-                ],
935
-                REG_ADMIN_URL,
936
-                true
937
-            );
938
-            return '
916
+		}
917
+		return '';
918
+	}
919
+
920
+
921
+	/**
922
+	 * @throws EE_Error
923
+	 * @throws ReflectionException
924
+	 */
925
+	private function resendRegistrationMessageAction(
926
+		EE_Registration $registration,
927
+		?EE_Attendee $attendee = null
928
+	): string {
929
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
930
+			$resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
931
+				[
932
+					'action'  => 'resend_registration',
933
+					'_REG_ID' => $registration->ID(),
934
+				],
935
+				REG_ADMIN_URL,
936
+				true
937
+			);
938
+			return '
939 939
 			    <a href="' . $resend_reg_link_url . '" aria-label="'
940
-                                         . esc_attr__('Resend Registration Details', 'event_espresso')
941
-                                         . '" class="ee-aria-tooltip button button--icon-only">
940
+										 . esc_attr__('Resend Registration Details', 'event_espresso')
941
+										 . '" class="ee-aria-tooltip button button--icon-only">
942 942
 			        <span class="dashicons dashicons-email-alt"></span>
943 943
 			    </a>';
944
-        }
945
-        return '';
946
-    }
947
-
948
-
949
-    private function viewTransactionUrl(): string
950
-    {
951
-        return EE_Admin_Page::add_query_args_and_nonce(
952
-            [
953
-                    'action' => 'view_transaction',
954
-                    'TXN_ID' => $this->_transaction_details['id'],
955
-                ],
956
-            TXN_ADMIN_URL
957
-        );
958
-    }
959
-
960
-
961
-    private function viewTransactionAction(): string
962
-    {
963
-        if ($this->caps_handler->userCanViewTransaction()) {
964
-            return '
944
+		}
945
+		return '';
946
+	}
947
+
948
+
949
+	private function viewTransactionUrl(): string
950
+	{
951
+		return EE_Admin_Page::add_query_args_and_nonce(
952
+			[
953
+					'action' => 'view_transaction',
954
+					'TXN_ID' => $this->_transaction_details['id'],
955
+				],
956
+			TXN_ADMIN_URL
957
+		);
958
+	}
959
+
960
+
961
+	private function viewTransactionAction(): string
962
+	{
963
+		if ($this->caps_handler->userCanViewTransaction()) {
964
+			return '
965 965
                 <a class="ee-aria-tooltip button button--icon-only" 
966 966
                    href="' . $this->viewTransactionUrl() . '"  
967 967
                    aria-label="' . $this->_transaction_details['title_attr'] . '"
968 968
                 >
969 969
                     <span class="dashicons dashicons-cart"></span>
970 970
                 </a>';
971
-        }
972
-        return '';
973
-    }
974
-
975
-
976
-    /**
977
-     * @throws EE_Error
978
-     * @throws ReflectionException
979
-     */
980
-    private function viewTransactionInvoiceAction(
981
-        EE_Registration $registration,
982
-        ?EE_Attendee $attendee = null
983
-    ): string {
984
-        // only show invoice link if message type is active.
985
-        if (
986
-            $attendee instanceof EE_Attendee
987
-            && $registration->is_primary_registrant()
988
-            && EEH_MSG_Template::is_mt_active('invoice')
989
-        ) {
990
-            return '
971
+		}
972
+		return '';
973
+	}
974
+
975
+
976
+	/**
977
+	 * @throws EE_Error
978
+	 * @throws ReflectionException
979
+	 */
980
+	private function viewTransactionInvoiceAction(
981
+		EE_Registration $registration,
982
+		?EE_Attendee $attendee = null
983
+	): string {
984
+		// only show invoice link if message type is active.
985
+		if (
986
+			$attendee instanceof EE_Attendee
987
+			&& $registration->is_primary_registrant()
988
+			&& EEH_MSG_Template::is_mt_active('invoice')
989
+		) {
990
+			return '
991 991
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
992
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
992
+										 . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
993 993
                     <span class="dashicons dashicons-media-spreadsheet"></span>
994 994
                 </a>';
995
-        }
996
-        return '';
997
-    }
998
-
999
-
1000
-    /**
1001
-     * @throws ReflectionException
1002
-     * @throws EE_Error
1003
-     */
1004
-    private function viewNotificationsAction(EE_Registration $registration): string
1005
-    {
1006
-        // message list table link (filtered by REG_ID
1007
-        return $this->caps_handler->userCanReadGlobalMessages()
1008
-            ? EEH_MSG_Template::get_message_action_link(
1009
-                'see_notifications_for',
1010
-                null,
1011
-                ['_REG_ID' => $registration->ID()]
1012
-            )
1013
-            : '';
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * @throws EE_Error
1019
-     * @throws ReflectionException
1020
-     */
1021
-    private function trashRegistrationLink(
1022
-        EE_Registration $registration,
1023
-        array $url_params
1024
-    ): array {
1025
-        $actions = [];
1026
-        // can't trash what's already trashed
1027
-        if ($this->_view === 'trash') {
1028
-            return $actions;
1029
-        }
1030
-
1031
-        // check caps
1032
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1033
-            return $actions;
1034
-        }
1035
-
1036
-        // don't delete registrations that have payments applied
1037
-        $transaction   = $registration->get_first_related('Transaction');
1038
-        $payment_count = $transaction instanceof EE_Transaction
1039
-            ? $transaction->count_related('Payment')
1040
-            : 0;
1041
-
1042
-        if ($payment_count > 0) {
1043
-            return $actions;
1044
-        }
1045
-
1046
-        $url_params['action'] = 'trash_registrations';
1047
-        $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048
-        $actions['trash']     = '
995
+		}
996
+		return '';
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * @throws ReflectionException
1002
+	 * @throws EE_Error
1003
+	 */
1004
+	private function viewNotificationsAction(EE_Registration $registration): string
1005
+	{
1006
+		// message list table link (filtered by REG_ID
1007
+		return $this->caps_handler->userCanReadGlobalMessages()
1008
+			? EEH_MSG_Template::get_message_action_link(
1009
+				'see_notifications_for',
1010
+				null,
1011
+				['_REG_ID' => $registration->ID()]
1012
+			)
1013
+			: '';
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * @throws EE_Error
1019
+	 * @throws ReflectionException
1020
+	 */
1021
+	private function trashRegistrationLink(
1022
+		EE_Registration $registration,
1023
+		array $url_params
1024
+	): array {
1025
+		$actions = [];
1026
+		// can't trash what's already trashed
1027
+		if ($this->_view === 'trash') {
1028
+			return $actions;
1029
+		}
1030
+
1031
+		// check caps
1032
+		if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1033
+			return $actions;
1034
+		}
1035
+
1036
+		// don't delete registrations that have payments applied
1037
+		$transaction   = $registration->get_first_related('Transaction');
1038
+		$payment_count = $transaction instanceof EE_Transaction
1039
+			? $transaction->count_related('Payment')
1040
+			: 0;
1041
+
1042
+		if ($payment_count > 0) {
1043
+			return $actions;
1044
+		}
1045
+
1046
+		$url_params['action'] = 'trash_registrations';
1047
+		$trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048
+		$actions['trash']     = '
1049 1049
             <a class="ee-aria-tooltip" 
1050 1050
                 href="' . $trash_link_url . '" 
1051 1051
                 aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1052 1052
             >
1053 1053
                 ' . esc_html__('Trash', 'event_espresso') . '
1054 1054
             </a>';
1055
-        return $actions;
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * @throws EE_Error
1061
-     * @throws ReflectionException
1062
-     */
1063
-    private function restoreRegistrationLink(
1064
-        EE_Registration $registration,
1065
-        array $url_params,
1066
-        array $actions
1067
-    ): array {
1068
-        // can't restore what's not trashed
1069
-        if ($this->_view !== 'trash') {
1070
-            return $actions;
1071
-        }
1072
-
1073
-        // restore registration link
1074
-        if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1075
-            $url_params['action'] = 'restore_registrations';
1076
-            $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077
-            $actions['restore']   = '
1055
+		return $actions;
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * @throws EE_Error
1061
+	 * @throws ReflectionException
1062
+	 */
1063
+	private function restoreRegistrationLink(
1064
+		EE_Registration $registration,
1065
+		array $url_params,
1066
+		array $actions
1067
+	): array {
1068
+		// can't restore what's not trashed
1069
+		if ($this->_view !== 'trash') {
1070
+			return $actions;
1071
+		}
1072
+
1073
+		// restore registration link
1074
+		if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1075
+			$url_params['action'] = 'restore_registrations';
1076
+			$restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077
+			$actions['restore']   = '
1078 1078
                 <a class="ee-aria-tooltip" 
1079 1079
                     href="' . $restore_link_url . '" 
1080 1080
                     aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1081 1081
                 >
1082 1082
                     ' . esc_html__('Restore', 'event_espresso') . '
1083 1083
                 </a>';
1084
-        }
1085
-
1086
-        return $actions;
1087
-    }
1088
-
1089
-
1090
-    /**
1091
-     * @throws EE_Error
1092
-     * @throws ReflectionException
1093
-     */
1094
-    private function deleteRegistrationLink(
1095
-        EE_Registration $registration,
1096
-        array $url_params,
1097
-        array $actions
1098
-    ): array {
1099
-        if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1100
-            $url_params['action'] = 'delete_registrations';
1101
-            $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102
-            $actions['delete']    = '
1084
+		}
1085
+
1086
+		return $actions;
1087
+	}
1088
+
1089
+
1090
+	/**
1091
+	 * @throws EE_Error
1092
+	 * @throws ReflectionException
1093
+	 */
1094
+	private function deleteRegistrationLink(
1095
+		EE_Registration $registration,
1096
+		array $url_params,
1097
+		array $actions
1098
+	): array {
1099
+		if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1100
+			$url_params['action'] = 'delete_registrations';
1101
+			$delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102
+			$actions['delete']    = '
1103 1103
                 <a class="ee-aria-tooltip" 
1104 1104
                     href="' . $delete_link_url . '" 
1105 1105
                     aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1106 1106
                 >
1107 1107
                     ' . esc_html__('Delete', 'event_espresso') . '
1108 1108
                 </a>';
1109
-        }
1110
-        return $actions;
1111
-    }
1112
-
1113
-
1114
-    private function editEventLink(int $EVT_ID, string $event_name): string
1115
-    {
1116
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117
-            return $event_name;
1118
-        }
1119
-        $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1120
-            ['action' => 'edit', 'post' => $EVT_ID],
1121
-            EVENTS_ADMIN_URL
1122
-        );
1123
-        return '
1109
+		}
1110
+		return $actions;
1111
+	}
1112
+
1113
+
1114
+	private function editEventLink(int $EVT_ID, string $event_name): string
1115
+	{
1116
+		if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117
+			return $event_name;
1118
+		}
1119
+		$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1120
+			['action' => 'edit', 'post' => $EVT_ID],
1121
+			EVENTS_ADMIN_URL
1122
+		);
1123
+		return '
1124 1124
             <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '" 
1125 1125
                 href="' . $edit_event_url . '" 
1126 1126
                 aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1127 1127
             >
1128 1128
                 ' . $event_name . '
1129 1129
             </a>';
1130
-    }
1130
+	}
1131 1131
 
1132 1132
 
1133
-    private function eventFilterLink(int $EVT_ID, string $event_name): string
1134
-    {
1135
-        if (!$EVT_ID) {
1136
-            return '';
1137
-        }
1138
-        $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139
-        return '
1133
+	private function eventFilterLink(int $EVT_ID, string $event_name): string
1134
+	{
1135
+		if (!$EVT_ID) {
1136
+			return '';
1137
+		}
1138
+		$event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139
+		return '
1140 1140
             <a  class="ee-aria-tooltip ee-event-filter-link" 
1141 1141
                 href="' . $event_filter_url . '" 
1142 1142
                 aria-label="' . sprintf(
1143
-                    esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144
-                    $event_name
1145
-                ) . '"
1143
+					esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144
+					$event_name
1145
+				) . '"
1146 1146
             >
1147 1147
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1148
-                . esc_html__('View Registrations', 'event_espresso') . '
1148
+				. esc_html__('View Registrations', 'event_espresso') . '
1149 1149
             </a>';
1150
-    }
1150
+	}
1151 1151
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55 55
         $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
56
+        if ( ! empty($req_data['event_id'])) {
57 57
             $extra_query_args = [];
58 58
             foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
59
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
60 60
             }
61 61
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62 62
         }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             'ajax'     => true,
89 89
             'screen'   => $this->_admin_page->get_current_screen()->id,
90 90
         ];
91
-        $req_data            = $this->_admin_page->get_request_data();
91
+        $req_data = $this->_admin_page->get_request_data();
92 92
         if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
93
+            $this->_columns = [
94 94
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95 95
                 'id'               => esc_html__('ID', 'event_espresso'),
96 96
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 ],
113 113
             ];
114 114
         } else {
115
-            $this->_columns        = [
115
+            $this->_columns = [
116 116
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117 117
                 'id'               => esc_html__('ID', 'event_espresso'),
118 118
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 'return_url'  => $return_url,
140 140
             ],
141 141
         ];
142
-        $filters                                  = array_diff_key(
142
+        $filters = array_diff_key(
143 143
             $this->_req_data,
144 144
             array_flip(
145 145
                 [
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
                 ]
150 150
             )
151 151
         );
152
-        if (! empty($filters)) {
152
+        if ( ! empty($filters)) {
153 153
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154 154
         }
155 155
         $this->_primary_column   = 'id';
156 156
         $this->_sortable_columns = [
157
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
157
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
158 158
             /**
159 159
              * Allows users to change the default sort if they wish.
160 160
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
172 172
             'id'            => ['REG_ID' => false],
173 173
         ];
174
-        $this->_hidden_columns   = [];
174
+        $this->_hidden_columns = [];
175 175
     }
176 176
 
177 177
 
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
         $this_month_r    = date('m', current_time('timestamp'));
345 345
         $days_this_month = date('t', current_time('timestamp'));
346 346
         // setup date query.
347
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
347
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
348 348
             'REG_date',
349
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
349
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
350 350
             'Y-m-d H:i:s'
351 351
         );
352
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
352
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
353 353
             'REG_date',
354
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
354
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
355 355
             'Y-m-d H:i:s'
356 356
         );
357 357
         $_where['REG_date'] = [
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
                 $end_string,
362 362
             ],
363 363
         ];
364
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
364
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
365 365
         return EEM_Registration::instance()->count([$_where]);
366 366
     }
367 367
 
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
             [
388 388
                 EEM_Registration::instance()->convert_datetime_for_query(
389 389
                     'REG_date',
390
-                    $current_date . $time_start,
390
+                    $current_date.$time_start,
391 391
                     'Y-m-d H:i:s'
392 392
                 ),
393 393
                 EEM_Registration::instance()->convert_datetime_for_query(
394 394
                     'REG_date',
395
-                    $current_date . $time_end,
395
+                    $current_date.$time_end,
396 396
                     'Y-m-d H:i:s'
397 397
                 ),
398 398
             ],
399 399
         ];
400
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
400
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
401 401
         return EEM_Registration::instance()->count([$_where]);
402 402
     }
403 403
 
@@ -420,10 +420,10 @@  discard block
 block discarded – undo
420 420
             ? $transaction->count_related('Payment')
421 421
             : 0;
422 422
 
423
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
423
+        $content = '<input type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" />';
424 424
         $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425 425
             ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box" 
426
-                    aria-label="' . $this->lockedRegMessage() . '"></span>'
426
+                    aria-label="' . $this->lockedRegMessage().'"></span>'
427 427
             : '';
428 428
         return $this->columnContent('cb', $content, 'center');
429 429
     }
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
      */
450 450
     public function column_id(EE_Registration $registration): string
451 451
     {
452
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
452
+        $content = '<span class="ee-entity-id">'.$registration->ID().'</span>';
453 453
         $content .= '<span class="show-on-mobile-view-only">';
454 454
         $content .= $this->column_ATT_fname($registration, false);
455 455
         $content .= '</span>';
@@ -480,23 +480,23 @@  discard block
 block discarded – undo
480 480
             esc_html__('(%1$s / %2$s)', 'event_espresso'),
481 481
             $registration->count(),
482 482
             $registration->group_size()
483
-        ) . '
483
+        ).'
484 484
             </span >';
485 485
 
486 486
         $content = '
487 487
         <div class="ee-layout-row">
488
-            <span aria-label="' . $pretty_status . '" 
489
-                  class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
488
+            <span aria-label="' . $pretty_status.'" 
489
+                  class="ee-status-dot ee-status-bg--' . $status.' ee-aria-tooltip"
490 490
             ></span>
491 491
             ' . $this->viewRegistrationLink($registration, $status)
492 492
                    . $prime_reg_star
493
-                   . $group_count . '
493
+                   . $group_count.'
494 494
             <span class="spacer"></span>
495 495
             <span>
496 496
                 ' . sprintf(
497 497
                        esc_html__('Reg Code: %s', 'event_espresso'),
498 498
                        $registration->get('REG_code')
499
-                   ) . '
499
+                   ).'
500 500
             </span>
501 501
         </div>';
502 502
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         $this->_set_related_details($registration);
528 528
         // Build row actions
529 529
         $content = $this->caps_handler->userCanViewTransaction()
530
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
530
+            ? '<a class="ee-aria-tooltip ee-status-color--'.$this->_transaction_details['status'].'" href="'
531 531
               . $this->viewTransactionUrl()
532 532
               . '" aria-label="'
533 533
               . esc_attr($this->_transaction_details['title_attr'])
@@ -601,16 +601,16 @@  discard block
 block discarded – undo
601 601
     {
602 602
         // get first item for initial visibility
603 603
         $content = array_shift($datetime_strings);
604
-        if (! empty($datetime_strings)) {
604
+        if ( ! empty($datetime_strings)) {
605 605
             $content .= '
606 606
                 <div class="ee-registration-event-datetimes-container-wrap">
607
-                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '" 
607
+                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso').'" 
608 608
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
609 609
                     >
610 610
                         <span class="dashicons dashicons-admin-collapse"></span>
611 611
                     </button>
612 612
                     <div class="ee-registration-event-datetimes-container more-items hidden">
613
-                        ' . implode("", $datetime_strings) . '
613
+                        ' . implode("", $datetime_strings).'
614 614
                     </div>
615 615
                 </div>';
616 616
         }
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
         $req_data = $this->_admin_page->get_request_data();
662 662
 
663 663
         $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
664
+            ? '<div class="TKT_name">'.$ticket->name().'</div>'
665 665
             : '';
666 666
 
667 667
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
-        $content        .= $registration->final_price() > 0
669
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
670
-                ' . $registration->pretty_final_price() . '
668
+        $content .= $registration->final_price() > 0
669
+            ? '<span class="reg-overview-paid-event-spn ee-status-color--'.$payment_status.'">
670
+                ' . $registration->pretty_final_price().'
671 671
                </span>'
672 672
             // free event
673
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
673
+            : '<span class="reg-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
674 674
 
675 675
         return $this->columnContent('PRC_amount', $content, 'end');
676 676
     }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 
697 697
         $content .= '
698 698
             <span class="reg-overview-paid-event-spn">
699
-                ' . $registration->pretty_final_price() . '
699
+                ' . $registration->pretty_final_price().'
700 700
             </span>';
701 701
         return $this->columnContent('_REG_final_price', $content, 'end');
702 702
     }
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 
717 717
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718 718
         $content        = '
719
-            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
720
-                ' . $registration->pretty_paid() . '
719
+            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status.'">
720
+                ' . $registration->pretty_paid().'
721 721
             </span>';
722 722
         if ($registration->paid() > 0) {
723 723
             $content .= '<span class="ee-status-text-small">'
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
         if ($registration->transaction()) {
747 747
             $content = $this->caps_handler->userCanViewTransaction()
748 748
                 ? '
749
-                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '" 
750
-                        href="' . $this->viewTransactionUrl() . '" 
751
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
749
+                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID().'" 
750
+                        href="' . $this->viewTransactionUrl().'" 
751
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
752 752
                     >
753
-                        ' . $registration->transaction()->pretty_total() . '
753
+                        ' . $registration->transaction()->pretty_total().'
754 754
                     </a>'
755 755
                 : $registration->transaction()->pretty_total();
756 756
         } else {
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
             } else {
785 785
                 $content = $this->caps_handler->userCanViewTransaction()
786 786
                     ? '
787
-                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '" 
788
-                        href="' . $this->viewTransactionUrl() . '"  
789
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
787
+                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID().'" 
788
+                        href="' . $this->viewTransactionUrl().'"  
789
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
790 790
                     >
791
-                        ' . $registration->transaction()->pretty_paid() . '
791
+                        ' . $registration->transaction()->pretty_paid().'
792 792
                     </a>'
793 793
                     : $registration->transaction()->pretty_paid();
794 794
             }
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
             : '';
868 868
         return $this->caps_handler->userCanReadRegistration($registration)
869 869
             ? '
870
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"  
871
-                class="row-title ee-status-color--' . $status . ' ee-aria-tooltip" 
872
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
870
+            <a  href="' . $this->viewRegistrationUrl($registration).'"  
871
+                class="row-title ee-status-color--' . $status.' ee-aria-tooltip" 
872
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
873 873
             >
874
-                ' . $attendee_name . '
874
+                ' . $attendee_name.'
875 875
             </a>'
876 876
             : $attendee_name;
877 877
     }
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
     {
886 886
         return $this->caps_handler->userCanReadRegistration($registration)
887 887
             ? '
888
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"  
888
+            <a  href="' . $this->viewRegistrationUrl($registration).'"  
889 889
                 class="ee-aria-tooltip button button--icon-only"
890
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
890
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
891 891
             >
892 892
                 <span class="dashicons dashicons-clipboard"></span>
893 893
             </a>'
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
                 REG_ADMIN_URL
908 908
             );
909 909
             return '
910
-                <a href="' . $edit_link_url . '" 
911
-                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" 
910
+                <a href="' . $edit_link_url.'" 
911
+                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso').'" 
912 912
                    class="ee-aria-tooltip button button--secondary button--icon-only"
913 913
                 >
914 914
                     <span class="dashicons dashicons-admin-users"></span>
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
                 true
937 937
             );
938 938
             return '
939
-			    <a href="' . $resend_reg_link_url . '" aria-label="'
939
+			    <a href="' . $resend_reg_link_url.'" aria-label="'
940 940
                                          . esc_attr__('Resend Registration Details', 'event_espresso')
941 941
                                          . '" class="ee-aria-tooltip button button--icon-only">
942 942
 			        <span class="dashicons dashicons-email-alt"></span>
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
         if ($this->caps_handler->userCanViewTransaction()) {
964 964
             return '
965 965
                 <a class="ee-aria-tooltip button button--icon-only" 
966
-                   href="' . $this->viewTransactionUrl() . '"  
967
-                   aria-label="' . $this->_transaction_details['title_attr'] . '"
966
+                   href="' . $this->viewTransactionUrl().'"  
967
+                   aria-label="' . $this->_transaction_details['title_attr'].'"
968 968
                 >
969 969
                     <span class="dashicons dashicons-cart"></span>
970 970
                 </a>';
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
         ) {
990 990
             return '
991 991
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
992
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
992
+                                         . '" target="_blank" href="'.$registration->invoice_url().'" class="ee-aria-tooltip button button--icon-only">
993 993
                     <span class="dashicons dashicons-media-spreadsheet"></span>
994 994
                 </a>';
995 995
         }
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
         }
1030 1030
 
1031 1031
         // check caps
1032
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1032
+        if ( ! $this->caps_handler->userCanTrashRegistration($registration)) {
1033 1033
             return $actions;
1034 1034
         }
1035 1035
 
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
         $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048 1048
         $actions['trash']     = '
1049 1049
             <a class="ee-aria-tooltip" 
1050
-                href="' . $trash_link_url . '" 
1051
-                aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1050
+                href="' . $trash_link_url.'" 
1051
+                aria-label="' . esc_attr__('Trash Registration', 'event_espresso').'"
1052 1052
             >
1053
-                ' . esc_html__('Trash', 'event_espresso') . '
1053
+                ' . esc_html__('Trash', 'event_espresso').'
1054 1054
             </a>';
1055 1055
         return $actions;
1056 1056
     }
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
             $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077 1077
             $actions['restore']   = '
1078 1078
                 <a class="ee-aria-tooltip" 
1079
-                    href="' . $restore_link_url . '" 
1080
-                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1079
+                    href="' . $restore_link_url.'" 
1080
+                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso').'"
1081 1081
                 >
1082
-                    ' . esc_html__('Restore', 'event_espresso') . '
1082
+                    ' . esc_html__('Restore', 'event_espresso').'
1083 1083
                 </a>';
1084 1084
         }
1085 1085
 
@@ -1101,10 +1101,10 @@  discard block
 block discarded – undo
1101 1101
             $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102 1102
             $actions['delete']    = '
1103 1103
                 <a class="ee-aria-tooltip" 
1104
-                    href="' . $delete_link_url . '" 
1105
-                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1104
+                    href="' . $delete_link_url.'" 
1105
+                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso').'"
1106 1106
                 >
1107
-                    ' . esc_html__('Delete', 'event_espresso') . '
1107
+                    ' . esc_html__('Delete', 'event_espresso').'
1108 1108
                 </a>';
1109 1109
         }
1110 1110
         return $actions;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
     private function editEventLink(int $EVT_ID, string $event_name): string
1115 1115
     {
1116
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1116
+        if ( ! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117 1117
             return $event_name;
1118 1118
         }
1119 1119
         $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
@@ -1121,31 +1121,31 @@  discard block
 block discarded – undo
1121 1121
             EVENTS_ADMIN_URL
1122 1122
         );
1123 1123
         return '
1124
-            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '" 
1125
-                href="' . $edit_event_url . '" 
1126
-                aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1124
+            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'].'" 
1125
+                href="' . $edit_event_url.'" 
1126
+                aria-label="' . esc_attr($this->_event_details['title_attr']).'"
1127 1127
             >
1128
-                ' . $event_name . '
1128
+                ' . $event_name.'
1129 1129
             </a>';
1130 1130
     }
1131 1131
 
1132 1132
 
1133 1133
     private function eventFilterLink(int $EVT_ID, string $event_name): string
1134 1134
     {
1135
-        if (!$EVT_ID) {
1135
+        if ( ! $EVT_ID) {
1136 1136
             return '';
1137 1137
         }
1138 1138
         $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139 1139
         return '
1140 1140
             <a  class="ee-aria-tooltip ee-event-filter-link" 
1141
-                href="' . $event_filter_url . '" 
1141
+                href="' . $event_filter_url.'" 
1142 1142
                 aria-label="' . sprintf(
1143 1143
                     esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144 1144
                     $event_name
1145
-                ) . '"
1145
+                ).'"
1146 1146
             >
1147 1147
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1148
-                . esc_html__('View Registrations', 'event_espresso') . '
1148
+                . esc_html__('View Registrations', 'event_espresso').'
1149 1149
             </a>';
1150 1150
     }
1151 1151
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1405 added lines, -1405 removed lines patch added patch discarded remove patch
@@ -20,1422 +20,1422 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Core_Config
25
-     */
26
-    public $core_config;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
-    }
61
-
62
-
63
-    /**
64
-     * Set page routes property.
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = [
69
-            'critical_pages'                => [
70
-                'func'       => '_espresso_page_settings',
71
-                'capability' => 'manage_options',
72
-            ],
73
-            'update_espresso_page_settings' => [
74
-                'func'       => '_update_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-                'noheader'   => true,
77
-            ],
78
-            'default'                       => [
79
-                'func'       => '_your_organization_settings',
80
-                'capability' => 'manage_options',
81
-            ],
82
-
83
-            'update_your_organization_settings' => [
84
-                'func'       => '_update_your_organization_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-
89
-            'admin_option_settings' => [
90
-                'func'       => '_admin_option_settings',
91
-                'capability' => 'manage_options',
92
-            ],
93
-
94
-            'update_admin_option_settings' => [
95
-                'func'       => '_update_admin_option_settings',
96
-                'capability' => 'manage_options',
97
-                'noheader'   => true,
98
-            ],
99
-
100
-            'country_settings' => [
101
-                'func'       => '_country_settings',
102
-                'capability' => 'manage_options',
103
-            ],
104
-
105
-            'update_country_settings' => [
106
-                'func'       => '_update_country_settings',
107
-                'capability' => 'manage_options',
108
-                'noheader'   => true,
109
-            ],
110
-
111
-            'display_country_settings' => [
112
-                'func'       => 'display_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ],
116
-
117
-            'add_new_state' => [
118
-                'func'       => 'add_new_state',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ],
122
-
123
-            'delete_state'            => [
124
-                'func'       => 'delete_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ],
128
-            'privacy_settings'        => [
129
-                'func'       => 'privacySettings',
130
-                'capability' => 'manage_options',
131
-            ],
132
-            'update_privacy_settings' => [
133
-                'func'               => 'updatePrivacySettings',
134
-                'capability'         => 'manage_options',
135
-                'noheader'           => true,
136
-                'headers_sent_route' => 'privacy_settings',
137
-            ],
138
-        ];
139
-    }
140
-
141
-
142
-    /**
143
-     * Set page configuration property
144
-     */
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = [
148
-            'critical_pages'        => [
149
-                'nav'           => [
150
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'order' => 20,
166
-                ],
167
-                'help_tabs'     => [
168
-                    'general_settings_your_organization_help_tab' => [
169
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
170
-                        'filename' => 'general_settings_your_organization',
171
-                    ],
172
-                ],
173
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
-                'require_nonce' => false,
175
-            ],
176
-            'admin_option_settings' => [
177
-                'nav'           => [
178
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
179
-                    'order' => 60,
180
-                ],
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
-                'help_tabs'     => [
183
-                    'general_settings_admin_options_help_tab' => [
184
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
185
-                        'filename' => 'general_settings_admin_options',
186
-                    ],
187
-                ],
188
-                'require_nonce' => false,
189
-            ],
190
-            'country_settings'      => [
191
-                'nav'           => [
192
-                    'label' => esc_html__('Countries', 'event_espresso'),
193
-                    'order' => 70,
194
-                ],
195
-                'help_tabs'     => [
196
-                    'general_settings_countries_help_tab' => [
197
-                        'title'    => esc_html__('Countries', 'event_espresso'),
198
-                        'filename' => 'general_settings_countries',
199
-                    ],
200
-                ],
201
-                'require_nonce' => false,
202
-            ],
203
-            'privacy_settings'      => [
204
-                'nav'           => [
205
-                    'label' => esc_html__('Privacy', 'event_espresso'),
206
-                    'order' => 80,
207
-                ],
208
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
-                'require_nonce' => false,
210
-            ],
211
-        ];
212
-    }
213
-
214
-
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-    protected function _add_feature_pointers()
221
-    {
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
-     */
228
-    public function load_scripts_styles()
229
-    {
230
-        // styles
231
-        wp_enqueue_style('espresso-ui-theme');
232
-        // scripts
233
-        wp_enqueue_script('ee_admin_js');
234
-    }
235
-
236
-
237
-    /**
238
-     * Execute logic running on `admin_init`
239
-     */
240
-    public function admin_init()
241
-    {
242
-        $this->core_config = EE_Registry::instance()->CFG->core;
243
-
244
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
-            esc_html__(
246
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
-                'event_espresso'
248
-            )
249
-        );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
-            esc_html__(
252
-                'An error occurred! Please refresh the page and try again.',
253
-                'event_espresso'
254
-            )
255
-        );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
-            esc_html__(
258
-                'Are you sure you want to delete this State / Province?',
259
-                'event_espresso'
260
-            )
261
-        );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
-            'admin-ajax.php?page=espresso_general_settings',
264
-            is_ssl() ? 'https://' : 'http://'
265
-        );
266
-    }
267
-
268
-
269
-    public function admin_notices()
270
-    {
271
-    }
272
-
273
-
274
-    public function admin_footer_scripts()
275
-    {
276
-    }
277
-
278
-
279
-    /**
280
-     * Enqueue scripts and styles for the default route.
281
-     */
282
-    public function load_scripts_styles_default()
283
-    {
284
-        // styles
285
-        wp_enqueue_style('thickbox');
286
-        // scripts
287
-        wp_enqueue_script('media-upload');
288
-        wp_enqueue_script('thickbox');
289
-        wp_register_script(
290
-            'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
-            ['jquery', 'media-upload', 'thickbox'],
293
-            EVENT_ESPRESSO_VERSION,
294
-            true
295
-        );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
-        wp_enqueue_script('organization_settings');
298
-        wp_enqueue_style('organization-css');
299
-        $confirm_image_delete = [
300
-            'text' => wp_strip_all_tags(
301
-                esc_html__(
302
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                    'event_espresso'
304
-                )
305
-            ),
306
-        ];
307
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
-    }
309
-
310
-
311
-    /**
312
-     * Enqueue scripts and styles for the country settings route.
313
-     */
314
-    public function load_scripts_styles_country_settings()
315
-    {
316
-        // scripts
317
-        wp_register_script(
318
-            'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
-            ['ee_admin_js'],
321
-            EVENT_ESPRESSO_VERSION,
322
-            true
323
-        );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
-        wp_enqueue_script('gen_settings_countries');
326
-        wp_enqueue_style('organization-css');
327
-    }
328
-
329
-
330
-    /*************        Espresso Pages        *************/
331
-    /**
332
-     * _espresso_page_settings
333
-     *
334
-     * @throws EE_Error
335
-     * @throws DomainException
336
-     * @throws DomainException
337
-     * @throws InvalidDataTypeException
338
-     * @throws InvalidArgumentException
339
-     */
340
-    protected function _espresso_page_settings()
341
-    {
342
-        // Check to make sure all of the main pages are set up properly,
343
-        // if not create the default pages and display an admin notice
344
-        EEH_Activation::verify_default_pages_exist();
345
-        $this->_transient_garbage_collection();
346
-
347
-        $this->_template_args['values']             = $this->_yes_no_values;
348
-
349
-        $this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
350
-        $this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
351
-            ? get_post($this->core_config->reg_page_id)
352
-            : false;
353
-
354
-        $this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
355
-        $this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
356
-            ? get_post($this->core_config->txn_page_id)
357
-            : false;
358
-
359
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
-            ? get_post($this->core_config->thank_you_page_id)
362
-            : false;
363
-
364
-        $this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
365
-        $this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
366
-            ? get_post($this->core_config->cancel_page_id)
367
-            : false;
368
-
369
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
370
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
371
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * Handler for updating espresso page settings.
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    protected function _update_espresso_page_settings()
386
-    {
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
521
-                $admin_options_settings_form->display(),
522
-                '',
523
-                'padding'
524
-            );
525
-        } catch (Exception $e) {
526
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
-        }
528
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
529
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
530
-        $this->display_admin_page_with_sidebar();
531
-    }
532
-
533
-
534
-    /**
535
-     * _update_admin_option_settings
536
-     *
537
-     * @throws EE_Error
538
-     * @throws InvalidDataTypeException
539
-     * @throws InvalidFormSubmissionException
540
-     * @throws InvalidArgumentException
541
-     * @throws LogicException
542
-     */
543
-    protected function _update_admin_option_settings()
544
-    {
545
-        try {
546
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
-            $admin_options_settings_form->process(
548
-                $this->request->getRequestParam(
549
-                    $admin_options_settings_form->slug(),
550
-                    [],
551
-                    DataType::STRING,
552
-                    true
553
-                )
554
-            );
555
-            EE_Registry::instance()->CFG->admin = apply_filters(
556
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
-                EE_Registry::instance()->CFG->admin
558
-            );
559
-        } catch (Exception $e) {
560
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
-        }
562
-        $this->_redirect_after_action(
563
-            apply_filters(
564
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
-                $this->_update_espresso_configuration(
566
-                    esc_html__('Admin Options', 'event_espresso'),
567
-                    EE_Registry::instance()->CFG->admin,
568
-                    __FILE__,
569
-                    __FUNCTION__,
570
-                    __LINE__
571
-                )
572
-            ),
573
-            esc_html__('Admin Options', 'event_espresso'),
574
-            'updated',
575
-            ['action' => 'admin_option_settings']
576
-        );
577
-    }
578
-
579
-
580
-    /*************        Countries        *************/
581
-
582
-
583
-    /**
584
-     * @param string|null $default
585
-     * @return string
586
-     */
587
-    protected function getCountryISO(?string $default = null): string
588
-    {
589
-        $default = $default ?? $this->getCountryIsoForSite();
590
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
591
-        return strtoupper($CNT_ISO);
592
-    }
593
-
594
-
595
-    /**
596
-     * @return string
597
-     */
598
-    protected function getCountryIsoForSite(): string
599
-    {
600
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
601
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
602
-            : 'US';
603
-    }
604
-
605
-
606
-    /**
607
-     * @param string          $CNT_ISO
608
-     * @param EE_Country|null $country
609
-     * @return EE_Base_Class|EE_Country
610
-     * @throws EE_Error
611
-     * @throws InvalidArgumentException
612
-     * @throws InvalidDataTypeException
613
-     * @throws InvalidInterfaceException
614
-     * @throws ReflectionException
615
-     */
616
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
617
-    {
618
-        /** @var EE_Country $country */
619
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
620
-            ? $country
621
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
622
-    }
623
-
624
-
625
-    /**
626
-     * Output Country Settings view.
627
-     *
628
-     * @throws DomainException
629
-     * @throws EE_Error
630
-     * @throws InvalidArgumentException
631
-     * @throws InvalidDataTypeException
632
-     * @throws InvalidInterfaceException
633
-     * @throws ReflectionException
634
-     */
635
-    protected function _country_settings()
636
-    {
637
-        $CNT_ISO = $this->getCountryISO();
638
-
639
-        $this->_template_args['values']    = $this->_yes_no_values;
640
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
641
-            EE_Question::new_instance(
642
-                [
643
-                  'QST_ID'           => 0,
644
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
645
-                  'QST_system'       => 'admin-country',
646
-                ]
647
-            ),
648
-            EE_Answer::new_instance(
649
-                [
650
-                    'ANS_ID'    => 0,
651
-                    'ANS_value' => $CNT_ISO,
652
-                ]
653
-            ),
654
-            [
655
-                'input_id'       => 'country',
656
-                'input_name'     => 'country',
657
-                'input_prefix'   => '',
658
-                'append_qstn_id' => false,
659
-            ]
660
-        );
661
-
662
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
663
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
664
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
665
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
666
-            $country->ID(),
667
-            $country
668
-        );
669
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
670
-            $country->ID(),
671
-            $country
672
-        );
673
-        $this->_template_args['CNT_name_for_site']        = $country->name();
674
-
675
-        $this->_set_add_edit_form_tags('update_country_settings');
676
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
677
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
678
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
679
-            $this->_template_args,
680
-            true
681
-        );
682
-        $this->display_admin_page_with_no_sidebar();
683
-    }
684
-
685
-
686
-    /**
687
-     * @param string          $CNT_ISO
688
-     * @param EE_Country|null $country
689
-     * @return string
690
-     * @throws DomainException
691
-     * @throws EE_Error
692
-     * @throws InvalidArgumentException
693
-     * @throws InvalidDataTypeException
694
-     * @throws InvalidInterfaceException
695
-     * @throws ReflectionException
696
-     */
697
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
698
-    {
699
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
700
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
701
-
702
-        if (! $CNT_ISO) {
703
-            return '';
704
-        }
705
-
706
-        // for ajax
707
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
708
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
709
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
710
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
711
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
712
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
713
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
714
-
715
-        $country_input_types            = [
716
-            'CNT_active'      => [
717
-                'type'             => 'RADIO_BTN',
718
-                'input_name'       => "cntry[$CNT_ISO]",
719
-                'class'            => '',
720
-                'options'          => $this->_yes_no_values,
721
-                'use_desc_4_label' => true,
722
-            ],
723
-            'CNT_ISO'         => [
724
-                'type'       => 'TEXT',
725
-                'input_name' => "cntry[$CNT_ISO]",
726
-                'class'      => 'ee-input-size--small',
727
-            ],
728
-            'CNT_ISO3'        => [
729
-                'type'       => 'TEXT',
730
-                'input_name' => "cntry[$CNT_ISO]",
731
-                'class'      => 'ee-input-size--small',
732
-            ],
733
-            // 'RGN_ID'          => [
734
-            //     'type'       => 'TEXT',
735
-            //     'input_name' => "cntry[$CNT_ISO]",
736
-            //     'class'      => 'ee-input-size--small',
737
-            // ],
738
-            'CNT_name'        => [
739
-                'type'       => 'TEXT',
740
-                'input_name' => "cntry[$CNT_ISO]",
741
-                'class'      => 'ee-input-size--big',
742
-            ],
743
-            'CNT_cur_code'    => [
744
-                'type'       => 'TEXT',
745
-                'input_name' => "cntry[$CNT_ISO]",
746
-                'class'      => 'ee-input-size--small',
747
-                'disabled'   => $CNT_cur_disabled,
748
-            ],
749
-            'CNT_cur_single'  => [
750
-                'type'       => 'TEXT',
751
-                'input_name' => "cntry[$CNT_ISO]",
752
-                'class'      => 'ee-input-size--reg',
753
-                'disabled'   => $CNT_cur_disabled,
754
-            ],
755
-            'CNT_cur_plural'  => [
756
-                'type'       => 'TEXT',
757
-                'input_name' => "cntry[$CNT_ISO]",
758
-                'class'      => 'ee-input-size--reg',
759
-                'disabled'   => $CNT_cur_disabled,
760
-            ],
761
-            'CNT_cur_sign'    => [
762
-                'type'         => 'TEXT',
763
-                'input_name'   => "cntry[$CNT_ISO]",
764
-                'class'        => 'ee-input-size--small',
765
-                'htmlentities' => false,
766
-                'disabled'     => $CNT_cur_disabled,
767
-            ],
768
-            'CNT_cur_sign_b4' => [
769
-                'type'             => 'RADIO_BTN',
770
-                'input_name'       => "cntry[$CNT_ISO]",
771
-                'class'            => '',
772
-                'options'          => $this->_yes_no_values,
773
-                'use_desc_4_label' => true,
774
-                'disabled'         => $CNT_cur_disabled,
775
-            ],
776
-            'CNT_cur_dec_plc' => [
777
-                'type'       => 'RADIO_BTN',
778
-                'input_name' => "cntry[$CNT_ISO]",
779
-                'class'      => '',
780
-                'options'    => [
781
-                    ['id' => 0, 'text' => ''],
782
-                    ['id' => 1, 'text' => ''],
783
-                    ['id' => 2, 'text' => ''],
784
-                    ['id' => 3, 'text' => ''],
785
-                ],
786
-                'disabled'   => $CNT_cur_disabled,
787
-            ],
788
-            'CNT_cur_dec_mrk' => [
789
-                'type'             => 'RADIO_BTN',
790
-                'input_name'       => "cntry[$CNT_ISO]",
791
-                'class'            => '',
792
-                'options'          => [
793
-                    [
794
-                        'id'   => ',',
795
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
796
-                    ],
797
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
798
-                ],
799
-                'use_desc_4_label' => true,
800
-                'disabled'         => $CNT_cur_disabled,
801
-            ],
802
-            'CNT_cur_thsnds'  => [
803
-                'type'             => 'RADIO_BTN',
804
-                'input_name'       => "cntry[$CNT_ISO]",
805
-                'class'            => '',
806
-                'options'          => [
807
-                    [
808
-                        'id'   => ',',
809
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
810
-                    ],
811
-                    [
812
-                        'id'   => '.',
813
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
814
-                    ],
815
-                    [
816
-                        'id'   => '&nbsp;',
817
-                        'text' => esc_html__('(space)', 'event_espresso'),
818
-                    ],
819
-                ],
820
-                'use_desc_4_label' => true,
821
-                'disabled'         => $CNT_cur_disabled,
822
-            ],
823
-            'CNT_tel_code'    => [
824
-                'type'       => 'TEXT',
825
-                'input_name' => "cntry[$CNT_ISO]",
826
-                'class'      => 'ee-input-size--small',
827
-            ],
828
-            'CNT_is_EU'       => [
829
-                'type'             => 'RADIO_BTN',
830
-                'input_name'       => "cntry[$CNT_ISO]",
831
-                'class'            => '',
832
-                'options'          => $this->_yes_no_values,
833
-                'use_desc_4_label' => true,
834
-            ],
835
-        ];
836
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
837
-            $country,
838
-            $country_input_types
839
-        );
840
-        $country_details_settings       = EEH_Template::display_template(
841
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
842
-            $this->_template_args,
843
-            true
844
-        );
845
-
846
-        if (defined('DOING_AJAX')) {
847
-            $notices = EE_Error::get_notices(false, false, false);
848
-            echo wp_json_encode(
849
-                [
850
-                    'return_data' => $country_details_settings,
851
-                    'success'     => $notices['success'],
852
-                    'errors'      => $notices['errors'],
853
-                ]
854
-            );
855
-            die();
856
-        }
857
-        return $country_details_settings;
858
-    }
859
-
860
-
861
-    /**
862
-     * @param string          $CNT_ISO
863
-     * @param EE_Country|null $country
864
-     * @return string
865
-     * @throws DomainException
866
-     * @throws EE_Error
867
-     * @throws InvalidArgumentException
868
-     * @throws InvalidDataTypeException
869
-     * @throws InvalidInterfaceException
870
-     * @throws ReflectionException
871
-     */
872
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
873
-    {
874
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
875
-        if (! $CNT_ISO) {
876
-            return '';
877
-        }
878
-        // for ajax
879
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
880
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
881
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
882
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
883
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
884
-        if (empty($states)) {
885
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
886
-            $countrySubRegionDao = $this->loader->getShared(
887
-                'EventEspresso\core\services\address\CountrySubRegionDao'
888
-            );
889
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
890
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
891
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
892
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
893
-                }
894
-            }
895
-        }
896
-        if (is_array($states)) {
897
-            foreach ($states as $STA_ID => $state) {
898
-                if ($state instanceof EE_State) {
899
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
900
-                        $state,
901
-                        [
902
-                            'STA_abbrev' => [
903
-                                'type'             => 'TEXT',
904
-                                'label'            => esc_html__('Code', 'event_espresso'),
905
-                                'input_name'       => "states[$STA_ID]",
906
-                                'class'            => 'ee-input-size--tiny',
907
-                                'add_mobile_label' => true,
908
-                            ],
909
-                            'STA_name'   => [
910
-                                'type'             => 'TEXT',
911
-                                'label'            => esc_html__('Name', 'event_espresso'),
912
-                                'input_name'       => "states[$STA_ID]",
913
-                                'class'            => 'ee-input-size--big',
914
-                                'add_mobile_label' => true,
915
-                            ],
916
-                            'STA_active' => [
917
-                                'type'             => 'RADIO_BTN',
918
-                                'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
919
-                                'input_name'       => "states[$STA_ID]",
920
-                                'options'          => $this->_yes_no_values,
921
-                                'use_desc_4_label' => true,
922
-                                'add_mobile_label' => true,
923
-                            ],
924
-                        ]
925
-                    );
926
-
927
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
928
-                        [
929
-                            'action'     => 'delete_state',
930
-                            'STA_ID'     => $STA_ID,
931
-                            'CNT_ISO'    => $CNT_ISO,
932
-                            'STA_abbrev' => $state->abbrev(),
933
-                        ],
934
-                        GEN_SET_ADMIN_URL
935
-                    );
936
-
937
-                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
938
-                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
939
-                }
940
-            }
941
-        } else {
942
-            $this->_template_args['states'] = false;
943
-        }
944
-
945
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
946
-            ['action' => 'add_new_state'],
947
-            GEN_SET_ADMIN_URL
948
-        );
949
-
950
-        $state_details_settings = EEH_Template::display_template(
951
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
952
-            $this->_template_args,
953
-            true
954
-        );
955
-
956
-        if (defined('DOING_AJAX')) {
957
-            $notices = EE_Error::get_notices(false, false, false);
958
-            echo wp_json_encode(
959
-                [
960
-                    'return_data' => $state_details_settings,
961
-                    'success'     => $notices['success'],
962
-                    'errors'      => $notices['errors'],
963
-                ]
964
-            );
965
-            die();
966
-        }
967
-        return $state_details_settings;
968
-    }
969
-
970
-
971
-    /**
972
-     * @return void
973
-     * @throws EE_Error
974
-     * @throws InvalidArgumentException
975
-     * @throws InvalidDataTypeException
976
-     * @throws InvalidInterfaceException
977
-     * @throws ReflectionException
978
-     */
979
-    public function add_new_state()
980
-    {
981
-        $success = true;
982
-        $CNT_ISO = $this->getCountryISO('');
983
-        if (! $CNT_ISO) {
984
-            EE_Error::add_error(
985
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
986
-                __FILE__,
987
-                __FUNCTION__,
988
-                __LINE__
989
-            );
990
-            $success = false;
991
-        }
992
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
993
-        if (! $STA_abbrev) {
994
-            EE_Error::add_error(
995
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
996
-                __FILE__,
997
-                __FUNCTION__,
998
-                __LINE__
999
-            );
1000
-            $success = false;
1001
-        }
1002
-        $STA_name = $this->request->getRequestParam('STA_name');
1003
-        if (! $STA_name) {
1004
-            EE_Error::add_error(
1005
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1006
-                __FILE__,
1007
-                __FUNCTION__,
1008
-                __LINE__
1009
-            );
1010
-            $success = false;
1011
-        }
1012
-
1013
-        if ($success) {
1014
-            $cols_n_values = [
1015
-                'CNT_ISO'    => $CNT_ISO,
1016
-                'STA_abbrev' => $STA_abbrev,
1017
-                'STA_name'   => $STA_name,
1018
-                'STA_active' => true,
1019
-            ];
1020
-            $success       = EEM_State::instance()->insert($cols_n_values);
1021
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1022
-        }
1023
-
1024
-        if (defined('DOING_AJAX')) {
1025
-            $notices = EE_Error::get_notices(false, false, false);
1026
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1027
-            die();
1028
-        }
1029
-        $this->_redirect_after_action(
1030
-            $success,
1031
-            esc_html__('State', 'event_espresso'),
1032
-            'added',
1033
-            ['action' => 'country_settings']
1034
-        );
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @return void
1040
-     * @throws EE_Error
1041
-     * @throws InvalidArgumentException
1042
-     * @throws InvalidDataTypeException
1043
-     * @throws InvalidInterfaceException
1044
-     * @throws ReflectionException
1045
-     */
1046
-    public function delete_state()
1047
-    {
1048
-        $CNT_ISO    = $this->getCountryISO();
1049
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1050
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
-
1052
-        if (! $STA_ID) {
1053
-            EE_Error::add_error(
1054
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
-                __FILE__,
1056
-                __FUNCTION__,
1057
-                __LINE__
1058
-            );
1059
-            return;
1060
-        }
1061
-
1062
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
-        if ($success !== false) {
1064
-            do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
-                      $CNT_ISO,
1066
-                      $STA_ID,
1067
-                      ['STA_abbrev' => $STA_abbrev]);
1068
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1069
-        }
1070
-        if (defined('DOING_AJAX')) {
1071
-            $notices                = EE_Error::get_notices(false);
1072
-            $notices['return_data'] = true;
1073
-            echo wp_json_encode($notices);
1074
-            die();
1075
-        }
1076
-        $this->_redirect_after_action(
1077
-            $success,
1078
-            esc_html__('State', 'event_espresso'),
1079
-            'deleted',
1080
-            ['action' => 'country_settings']
1081
-        );
1082
-    }
1083
-
1084
-
1085
-    /**
1086
-     * @return void
1087
-     * @throws EE_Error
1088
-     * @throws InvalidArgumentException
1089
-     * @throws InvalidDataTypeException
1090
-     * @throws InvalidInterfaceException
1091
-     * @throws ReflectionException
1092
-     */
1093
-    protected function _update_country_settings()
1094
-    {
1095
-        $CNT_ISO = $this->getCountryISO();
1096
-        if (! $CNT_ISO) {
1097
-            EE_Error::add_error(
1098
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1099
-                __FILE__,
1100
-                __FUNCTION__,
1101
-                __LINE__
1102
-            );
1103
-            return;
1104
-        }
1105
-
1106
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1107
-
1108
-        $cols_n_values                    = [];
1109
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1110
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1111
-        );
1112
-        $cols_n_values['CNT_name']        =
1113
-            $this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1114
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1115
-            $this->request->getRequestParam(
1116
-                "cntry[$CNT_ISO][CNT_cur_code]",
1117
-                $country->currency_code()
1118
-            )
1119
-        );
1120
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1121
-            "cntry[$CNT_ISO][CNT_cur_single]",
1122
-            $country->currency_name_single()
1123
-        );
1124
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1125
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1126
-            $country->currency_name_plural()
1127
-        );
1128
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1129
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1130
-            $country->currency_sign()
1131
-        );
1132
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1133
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1134
-            $country->currency_sign_before(),
1135
-            DataType::BOOL
1136
-        );
1137
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1138
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1139
-            $country->currency_decimal_places()
1140
-        );
1141
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1142
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1143
-            $country->currency_decimal_mark()
1144
-        );
1145
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1146
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1147
-            $country->currency_thousands_separator()
1148
-        );
1149
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1150
-            "cntry[$CNT_ISO][CNT_tel_code]",
1151
-            $country->telephoneCode()
1152
-        );
1153
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1154
-            "cntry[$CNT_ISO][CNT_active]",
1155
-            $country->isActive(),
1156
-            DataType::BOOL
1157
-        );
1158
-
1159
-        // allow filtering of country data
1160
-        $cols_n_values = apply_filters(
1161
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1162
-            $cols_n_values
1163
-        );
1164
-
1165
-        // where values
1166
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1167
-        // run the update
1168
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1169
-
1170
-        // allow filtering of states data
1171
-        $states = apply_filters(
1172
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1174
-        );
1175
-
1176
-        if (! empty($states) && $success !== false) {
1177
-            // loop thru state data ( looks like : states[75][STA_name] )
1178
-            foreach ($states as $STA_ID => $state) {
1179
-                $cols_n_values = [
1180
-                    'CNT_ISO'    => $CNT_ISO,
1181
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1182
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1183
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1184
-                ];
1185
-                // where values
1186
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1187
-                // run the update
1188
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1189
-                if ($success !== false) {
1190
-                    do_action(
1191
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1192
-                        $CNT_ISO,
1193
-                        $STA_ID,
1194
-                        $cols_n_values
1195
-                    );
1196
-                }
1197
-            }
1198
-        }
1199
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1200
-        if (
1201
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1202
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1203
-        ) {
1204
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1205
-            EE_Registry::instance()->CFG->update_espresso_config();
1206
-        }
1207
-
1208
-        if ($success !== false) {
1209
-            EE_Error::add_success(
1210
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1211
-            );
1212
-        }
1213
-        $this->_redirect_after_action(
1214
-            $success,
1215
-            '',
1216
-            '',
1217
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1218
-            true
1219
-        );
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * form_form_field_label_wrap
1225
-     *
1226
-     * @param string $label
1227
-     * @return string
1228
-     */
1229
-    public function country_form_field_label_wrap(string $label): string
1230
-    {
1231
-        return '
23
+	/**
24
+	 * @var EE_Core_Config
25
+	 */
26
+	public $core_config;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
+	}
61
+
62
+
63
+	/**
64
+	 * Set page routes property.
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = [
69
+			'critical_pages'                => [
70
+				'func'       => '_espresso_page_settings',
71
+				'capability' => 'manage_options',
72
+			],
73
+			'update_espresso_page_settings' => [
74
+				'func'       => '_update_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+				'noheader'   => true,
77
+			],
78
+			'default'                       => [
79
+				'func'       => '_your_organization_settings',
80
+				'capability' => 'manage_options',
81
+			],
82
+
83
+			'update_your_organization_settings' => [
84
+				'func'       => '_update_your_organization_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+
89
+			'admin_option_settings' => [
90
+				'func'       => '_admin_option_settings',
91
+				'capability' => 'manage_options',
92
+			],
93
+
94
+			'update_admin_option_settings' => [
95
+				'func'       => '_update_admin_option_settings',
96
+				'capability' => 'manage_options',
97
+				'noheader'   => true,
98
+			],
99
+
100
+			'country_settings' => [
101
+				'func'       => '_country_settings',
102
+				'capability' => 'manage_options',
103
+			],
104
+
105
+			'update_country_settings' => [
106
+				'func'       => '_update_country_settings',
107
+				'capability' => 'manage_options',
108
+				'noheader'   => true,
109
+			],
110
+
111
+			'display_country_settings' => [
112
+				'func'       => 'display_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			],
116
+
117
+			'add_new_state' => [
118
+				'func'       => 'add_new_state',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			],
122
+
123
+			'delete_state'            => [
124
+				'func'       => 'delete_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			],
128
+			'privacy_settings'        => [
129
+				'func'       => 'privacySettings',
130
+				'capability' => 'manage_options',
131
+			],
132
+			'update_privacy_settings' => [
133
+				'func'               => 'updatePrivacySettings',
134
+				'capability'         => 'manage_options',
135
+				'noheader'           => true,
136
+				'headers_sent_route' => 'privacy_settings',
137
+			],
138
+		];
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set page configuration property
144
+	 */
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = [
148
+			'critical_pages'        => [
149
+				'nav'           => [
150
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'order' => 20,
166
+				],
167
+				'help_tabs'     => [
168
+					'general_settings_your_organization_help_tab' => [
169
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
170
+						'filename' => 'general_settings_your_organization',
171
+					],
172
+				],
173
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
+				'require_nonce' => false,
175
+			],
176
+			'admin_option_settings' => [
177
+				'nav'           => [
178
+					'label' => esc_html__('Admin Options', 'event_espresso'),
179
+					'order' => 60,
180
+				],
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
+				'help_tabs'     => [
183
+					'general_settings_admin_options_help_tab' => [
184
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
185
+						'filename' => 'general_settings_admin_options',
186
+					],
187
+				],
188
+				'require_nonce' => false,
189
+			],
190
+			'country_settings'      => [
191
+				'nav'           => [
192
+					'label' => esc_html__('Countries', 'event_espresso'),
193
+					'order' => 70,
194
+				],
195
+				'help_tabs'     => [
196
+					'general_settings_countries_help_tab' => [
197
+						'title'    => esc_html__('Countries', 'event_espresso'),
198
+						'filename' => 'general_settings_countries',
199
+					],
200
+				],
201
+				'require_nonce' => false,
202
+			],
203
+			'privacy_settings'      => [
204
+				'nav'           => [
205
+					'label' => esc_html__('Privacy', 'event_espresso'),
206
+					'order' => 80,
207
+				],
208
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
+				'require_nonce' => false,
210
+			],
211
+		];
212
+	}
213
+
214
+
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+	protected function _add_feature_pointers()
221
+	{
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
+	 */
228
+	public function load_scripts_styles()
229
+	{
230
+		// styles
231
+		wp_enqueue_style('espresso-ui-theme');
232
+		// scripts
233
+		wp_enqueue_script('ee_admin_js');
234
+	}
235
+
236
+
237
+	/**
238
+	 * Execute logic running on `admin_init`
239
+	 */
240
+	public function admin_init()
241
+	{
242
+		$this->core_config = EE_Registry::instance()->CFG->core;
243
+
244
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
+			esc_html__(
246
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
+				'event_espresso'
248
+			)
249
+		);
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
+			esc_html__(
252
+				'An error occurred! Please refresh the page and try again.',
253
+				'event_espresso'
254
+			)
255
+		);
256
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
+			esc_html__(
258
+				'Are you sure you want to delete this State / Province?',
259
+				'event_espresso'
260
+			)
261
+		);
262
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
+			'admin-ajax.php?page=espresso_general_settings',
264
+			is_ssl() ? 'https://' : 'http://'
265
+		);
266
+	}
267
+
268
+
269
+	public function admin_notices()
270
+	{
271
+	}
272
+
273
+
274
+	public function admin_footer_scripts()
275
+	{
276
+	}
277
+
278
+
279
+	/**
280
+	 * Enqueue scripts and styles for the default route.
281
+	 */
282
+	public function load_scripts_styles_default()
283
+	{
284
+		// styles
285
+		wp_enqueue_style('thickbox');
286
+		// scripts
287
+		wp_enqueue_script('media-upload');
288
+		wp_enqueue_script('thickbox');
289
+		wp_register_script(
290
+			'organization_settings',
291
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+			['jquery', 'media-upload', 'thickbox'],
293
+			EVENT_ESPRESSO_VERSION,
294
+			true
295
+		);
296
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
+		wp_enqueue_script('organization_settings');
298
+		wp_enqueue_style('organization-css');
299
+		$confirm_image_delete = [
300
+			'text' => wp_strip_all_tags(
301
+				esc_html__(
302
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+					'event_espresso'
304
+				)
305
+			),
306
+		];
307
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
+	}
309
+
310
+
311
+	/**
312
+	 * Enqueue scripts and styles for the country settings route.
313
+	 */
314
+	public function load_scripts_styles_country_settings()
315
+	{
316
+		// scripts
317
+		wp_register_script(
318
+			'gen_settings_countries',
319
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+			['ee_admin_js'],
321
+			EVENT_ESPRESSO_VERSION,
322
+			true
323
+		);
324
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
+		wp_enqueue_script('gen_settings_countries');
326
+		wp_enqueue_style('organization-css');
327
+	}
328
+
329
+
330
+	/*************        Espresso Pages        *************/
331
+	/**
332
+	 * _espresso_page_settings
333
+	 *
334
+	 * @throws EE_Error
335
+	 * @throws DomainException
336
+	 * @throws DomainException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws InvalidArgumentException
339
+	 */
340
+	protected function _espresso_page_settings()
341
+	{
342
+		// Check to make sure all of the main pages are set up properly,
343
+		// if not create the default pages and display an admin notice
344
+		EEH_Activation::verify_default_pages_exist();
345
+		$this->_transient_garbage_collection();
346
+
347
+		$this->_template_args['values']             = $this->_yes_no_values;
348
+
349
+		$this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
350
+		$this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
351
+			? get_post($this->core_config->reg_page_id)
352
+			: false;
353
+
354
+		$this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
355
+		$this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
356
+			? get_post($this->core_config->txn_page_id)
357
+			: false;
358
+
359
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
+			? get_post($this->core_config->thank_you_page_id)
362
+			: false;
363
+
364
+		$this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
365
+		$this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
366
+			? get_post($this->core_config->cancel_page_id)
367
+			: false;
368
+
369
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
370
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
371
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * Handler for updating espresso page settings.
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	protected function _update_espresso_page_settings()
386
+	{
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
521
+				$admin_options_settings_form->display(),
522
+				'',
523
+				'padding'
524
+			);
525
+		} catch (Exception $e) {
526
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
+		}
528
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
529
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
530
+		$this->display_admin_page_with_sidebar();
531
+	}
532
+
533
+
534
+	/**
535
+	 * _update_admin_option_settings
536
+	 *
537
+	 * @throws EE_Error
538
+	 * @throws InvalidDataTypeException
539
+	 * @throws InvalidFormSubmissionException
540
+	 * @throws InvalidArgumentException
541
+	 * @throws LogicException
542
+	 */
543
+	protected function _update_admin_option_settings()
544
+	{
545
+		try {
546
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
+			$admin_options_settings_form->process(
548
+				$this->request->getRequestParam(
549
+					$admin_options_settings_form->slug(),
550
+					[],
551
+					DataType::STRING,
552
+					true
553
+				)
554
+			);
555
+			EE_Registry::instance()->CFG->admin = apply_filters(
556
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
+				EE_Registry::instance()->CFG->admin
558
+			);
559
+		} catch (Exception $e) {
560
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
+		}
562
+		$this->_redirect_after_action(
563
+			apply_filters(
564
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
+				$this->_update_espresso_configuration(
566
+					esc_html__('Admin Options', 'event_espresso'),
567
+					EE_Registry::instance()->CFG->admin,
568
+					__FILE__,
569
+					__FUNCTION__,
570
+					__LINE__
571
+				)
572
+			),
573
+			esc_html__('Admin Options', 'event_espresso'),
574
+			'updated',
575
+			['action' => 'admin_option_settings']
576
+		);
577
+	}
578
+
579
+
580
+	/*************        Countries        *************/
581
+
582
+
583
+	/**
584
+	 * @param string|null $default
585
+	 * @return string
586
+	 */
587
+	protected function getCountryISO(?string $default = null): string
588
+	{
589
+		$default = $default ?? $this->getCountryIsoForSite();
590
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
591
+		return strtoupper($CNT_ISO);
592
+	}
593
+
594
+
595
+	/**
596
+	 * @return string
597
+	 */
598
+	protected function getCountryIsoForSite(): string
599
+	{
600
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
601
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
602
+			: 'US';
603
+	}
604
+
605
+
606
+	/**
607
+	 * @param string          $CNT_ISO
608
+	 * @param EE_Country|null $country
609
+	 * @return EE_Base_Class|EE_Country
610
+	 * @throws EE_Error
611
+	 * @throws InvalidArgumentException
612
+	 * @throws InvalidDataTypeException
613
+	 * @throws InvalidInterfaceException
614
+	 * @throws ReflectionException
615
+	 */
616
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
617
+	{
618
+		/** @var EE_Country $country */
619
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
620
+			? $country
621
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
622
+	}
623
+
624
+
625
+	/**
626
+	 * Output Country Settings view.
627
+	 *
628
+	 * @throws DomainException
629
+	 * @throws EE_Error
630
+	 * @throws InvalidArgumentException
631
+	 * @throws InvalidDataTypeException
632
+	 * @throws InvalidInterfaceException
633
+	 * @throws ReflectionException
634
+	 */
635
+	protected function _country_settings()
636
+	{
637
+		$CNT_ISO = $this->getCountryISO();
638
+
639
+		$this->_template_args['values']    = $this->_yes_no_values;
640
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
641
+			EE_Question::new_instance(
642
+				[
643
+				  'QST_ID'           => 0,
644
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
645
+				  'QST_system'       => 'admin-country',
646
+				]
647
+			),
648
+			EE_Answer::new_instance(
649
+				[
650
+					'ANS_ID'    => 0,
651
+					'ANS_value' => $CNT_ISO,
652
+				]
653
+			),
654
+			[
655
+				'input_id'       => 'country',
656
+				'input_name'     => 'country',
657
+				'input_prefix'   => '',
658
+				'append_qstn_id' => false,
659
+			]
660
+		);
661
+
662
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
663
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
664
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
665
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
666
+			$country->ID(),
667
+			$country
668
+		);
669
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
670
+			$country->ID(),
671
+			$country
672
+		);
673
+		$this->_template_args['CNT_name_for_site']        = $country->name();
674
+
675
+		$this->_set_add_edit_form_tags('update_country_settings');
676
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
677
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
678
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
679
+			$this->_template_args,
680
+			true
681
+		);
682
+		$this->display_admin_page_with_no_sidebar();
683
+	}
684
+
685
+
686
+	/**
687
+	 * @param string          $CNT_ISO
688
+	 * @param EE_Country|null $country
689
+	 * @return string
690
+	 * @throws DomainException
691
+	 * @throws EE_Error
692
+	 * @throws InvalidArgumentException
693
+	 * @throws InvalidDataTypeException
694
+	 * @throws InvalidInterfaceException
695
+	 * @throws ReflectionException
696
+	 */
697
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
698
+	{
699
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
700
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
701
+
702
+		if (! $CNT_ISO) {
703
+			return '';
704
+		}
705
+
706
+		// for ajax
707
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
708
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
709
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
710
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
711
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
712
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
713
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
714
+
715
+		$country_input_types            = [
716
+			'CNT_active'      => [
717
+				'type'             => 'RADIO_BTN',
718
+				'input_name'       => "cntry[$CNT_ISO]",
719
+				'class'            => '',
720
+				'options'          => $this->_yes_no_values,
721
+				'use_desc_4_label' => true,
722
+			],
723
+			'CNT_ISO'         => [
724
+				'type'       => 'TEXT',
725
+				'input_name' => "cntry[$CNT_ISO]",
726
+				'class'      => 'ee-input-size--small',
727
+			],
728
+			'CNT_ISO3'        => [
729
+				'type'       => 'TEXT',
730
+				'input_name' => "cntry[$CNT_ISO]",
731
+				'class'      => 'ee-input-size--small',
732
+			],
733
+			// 'RGN_ID'          => [
734
+			//     'type'       => 'TEXT',
735
+			//     'input_name' => "cntry[$CNT_ISO]",
736
+			//     'class'      => 'ee-input-size--small',
737
+			// ],
738
+			'CNT_name'        => [
739
+				'type'       => 'TEXT',
740
+				'input_name' => "cntry[$CNT_ISO]",
741
+				'class'      => 'ee-input-size--big',
742
+			],
743
+			'CNT_cur_code'    => [
744
+				'type'       => 'TEXT',
745
+				'input_name' => "cntry[$CNT_ISO]",
746
+				'class'      => 'ee-input-size--small',
747
+				'disabled'   => $CNT_cur_disabled,
748
+			],
749
+			'CNT_cur_single'  => [
750
+				'type'       => 'TEXT',
751
+				'input_name' => "cntry[$CNT_ISO]",
752
+				'class'      => 'ee-input-size--reg',
753
+				'disabled'   => $CNT_cur_disabled,
754
+			],
755
+			'CNT_cur_plural'  => [
756
+				'type'       => 'TEXT',
757
+				'input_name' => "cntry[$CNT_ISO]",
758
+				'class'      => 'ee-input-size--reg',
759
+				'disabled'   => $CNT_cur_disabled,
760
+			],
761
+			'CNT_cur_sign'    => [
762
+				'type'         => 'TEXT',
763
+				'input_name'   => "cntry[$CNT_ISO]",
764
+				'class'        => 'ee-input-size--small',
765
+				'htmlentities' => false,
766
+				'disabled'     => $CNT_cur_disabled,
767
+			],
768
+			'CNT_cur_sign_b4' => [
769
+				'type'             => 'RADIO_BTN',
770
+				'input_name'       => "cntry[$CNT_ISO]",
771
+				'class'            => '',
772
+				'options'          => $this->_yes_no_values,
773
+				'use_desc_4_label' => true,
774
+				'disabled'         => $CNT_cur_disabled,
775
+			],
776
+			'CNT_cur_dec_plc' => [
777
+				'type'       => 'RADIO_BTN',
778
+				'input_name' => "cntry[$CNT_ISO]",
779
+				'class'      => '',
780
+				'options'    => [
781
+					['id' => 0, 'text' => ''],
782
+					['id' => 1, 'text' => ''],
783
+					['id' => 2, 'text' => ''],
784
+					['id' => 3, 'text' => ''],
785
+				],
786
+				'disabled'   => $CNT_cur_disabled,
787
+			],
788
+			'CNT_cur_dec_mrk' => [
789
+				'type'             => 'RADIO_BTN',
790
+				'input_name'       => "cntry[$CNT_ISO]",
791
+				'class'            => '',
792
+				'options'          => [
793
+					[
794
+						'id'   => ',',
795
+						'text' => esc_html__(', (comma)', 'event_espresso'),
796
+					],
797
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
798
+				],
799
+				'use_desc_4_label' => true,
800
+				'disabled'         => $CNT_cur_disabled,
801
+			],
802
+			'CNT_cur_thsnds'  => [
803
+				'type'             => 'RADIO_BTN',
804
+				'input_name'       => "cntry[$CNT_ISO]",
805
+				'class'            => '',
806
+				'options'          => [
807
+					[
808
+						'id'   => ',',
809
+						'text' => esc_html__(', (comma)', 'event_espresso'),
810
+					],
811
+					[
812
+						'id'   => '.',
813
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
814
+					],
815
+					[
816
+						'id'   => '&nbsp;',
817
+						'text' => esc_html__('(space)', 'event_espresso'),
818
+					],
819
+				],
820
+				'use_desc_4_label' => true,
821
+				'disabled'         => $CNT_cur_disabled,
822
+			],
823
+			'CNT_tel_code'    => [
824
+				'type'       => 'TEXT',
825
+				'input_name' => "cntry[$CNT_ISO]",
826
+				'class'      => 'ee-input-size--small',
827
+			],
828
+			'CNT_is_EU'       => [
829
+				'type'             => 'RADIO_BTN',
830
+				'input_name'       => "cntry[$CNT_ISO]",
831
+				'class'            => '',
832
+				'options'          => $this->_yes_no_values,
833
+				'use_desc_4_label' => true,
834
+			],
835
+		];
836
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
837
+			$country,
838
+			$country_input_types
839
+		);
840
+		$country_details_settings       = EEH_Template::display_template(
841
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
842
+			$this->_template_args,
843
+			true
844
+		);
845
+
846
+		if (defined('DOING_AJAX')) {
847
+			$notices = EE_Error::get_notices(false, false, false);
848
+			echo wp_json_encode(
849
+				[
850
+					'return_data' => $country_details_settings,
851
+					'success'     => $notices['success'],
852
+					'errors'      => $notices['errors'],
853
+				]
854
+			);
855
+			die();
856
+		}
857
+		return $country_details_settings;
858
+	}
859
+
860
+
861
+	/**
862
+	 * @param string          $CNT_ISO
863
+	 * @param EE_Country|null $country
864
+	 * @return string
865
+	 * @throws DomainException
866
+	 * @throws EE_Error
867
+	 * @throws InvalidArgumentException
868
+	 * @throws InvalidDataTypeException
869
+	 * @throws InvalidInterfaceException
870
+	 * @throws ReflectionException
871
+	 */
872
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
873
+	{
874
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
875
+		if (! $CNT_ISO) {
876
+			return '';
877
+		}
878
+		// for ajax
879
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
880
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
881
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
882
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
883
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
884
+		if (empty($states)) {
885
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
886
+			$countrySubRegionDao = $this->loader->getShared(
887
+				'EventEspresso\core\services\address\CountrySubRegionDao'
888
+			);
889
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
890
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
891
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
892
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
893
+				}
894
+			}
895
+		}
896
+		if (is_array($states)) {
897
+			foreach ($states as $STA_ID => $state) {
898
+				if ($state instanceof EE_State) {
899
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
900
+						$state,
901
+						[
902
+							'STA_abbrev' => [
903
+								'type'             => 'TEXT',
904
+								'label'            => esc_html__('Code', 'event_espresso'),
905
+								'input_name'       => "states[$STA_ID]",
906
+								'class'            => 'ee-input-size--tiny',
907
+								'add_mobile_label' => true,
908
+							],
909
+							'STA_name'   => [
910
+								'type'             => 'TEXT',
911
+								'label'            => esc_html__('Name', 'event_espresso'),
912
+								'input_name'       => "states[$STA_ID]",
913
+								'class'            => 'ee-input-size--big',
914
+								'add_mobile_label' => true,
915
+							],
916
+							'STA_active' => [
917
+								'type'             => 'RADIO_BTN',
918
+								'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
919
+								'input_name'       => "states[$STA_ID]",
920
+								'options'          => $this->_yes_no_values,
921
+								'use_desc_4_label' => true,
922
+								'add_mobile_label' => true,
923
+							],
924
+						]
925
+					);
926
+
927
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
928
+						[
929
+							'action'     => 'delete_state',
930
+							'STA_ID'     => $STA_ID,
931
+							'CNT_ISO'    => $CNT_ISO,
932
+							'STA_abbrev' => $state->abbrev(),
933
+						],
934
+						GEN_SET_ADMIN_URL
935
+					);
936
+
937
+					$this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
938
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
939
+				}
940
+			}
941
+		} else {
942
+			$this->_template_args['states'] = false;
943
+		}
944
+
945
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
946
+			['action' => 'add_new_state'],
947
+			GEN_SET_ADMIN_URL
948
+		);
949
+
950
+		$state_details_settings = EEH_Template::display_template(
951
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
952
+			$this->_template_args,
953
+			true
954
+		);
955
+
956
+		if (defined('DOING_AJAX')) {
957
+			$notices = EE_Error::get_notices(false, false, false);
958
+			echo wp_json_encode(
959
+				[
960
+					'return_data' => $state_details_settings,
961
+					'success'     => $notices['success'],
962
+					'errors'      => $notices['errors'],
963
+				]
964
+			);
965
+			die();
966
+		}
967
+		return $state_details_settings;
968
+	}
969
+
970
+
971
+	/**
972
+	 * @return void
973
+	 * @throws EE_Error
974
+	 * @throws InvalidArgumentException
975
+	 * @throws InvalidDataTypeException
976
+	 * @throws InvalidInterfaceException
977
+	 * @throws ReflectionException
978
+	 */
979
+	public function add_new_state()
980
+	{
981
+		$success = true;
982
+		$CNT_ISO = $this->getCountryISO('');
983
+		if (! $CNT_ISO) {
984
+			EE_Error::add_error(
985
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
986
+				__FILE__,
987
+				__FUNCTION__,
988
+				__LINE__
989
+			);
990
+			$success = false;
991
+		}
992
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
993
+		if (! $STA_abbrev) {
994
+			EE_Error::add_error(
995
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
996
+				__FILE__,
997
+				__FUNCTION__,
998
+				__LINE__
999
+			);
1000
+			$success = false;
1001
+		}
1002
+		$STA_name = $this->request->getRequestParam('STA_name');
1003
+		if (! $STA_name) {
1004
+			EE_Error::add_error(
1005
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1006
+				__FILE__,
1007
+				__FUNCTION__,
1008
+				__LINE__
1009
+			);
1010
+			$success = false;
1011
+		}
1012
+
1013
+		if ($success) {
1014
+			$cols_n_values = [
1015
+				'CNT_ISO'    => $CNT_ISO,
1016
+				'STA_abbrev' => $STA_abbrev,
1017
+				'STA_name'   => $STA_name,
1018
+				'STA_active' => true,
1019
+			];
1020
+			$success       = EEM_State::instance()->insert($cols_n_values);
1021
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1022
+		}
1023
+
1024
+		if (defined('DOING_AJAX')) {
1025
+			$notices = EE_Error::get_notices(false, false, false);
1026
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1027
+			die();
1028
+		}
1029
+		$this->_redirect_after_action(
1030
+			$success,
1031
+			esc_html__('State', 'event_espresso'),
1032
+			'added',
1033
+			['action' => 'country_settings']
1034
+		);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @return void
1040
+	 * @throws EE_Error
1041
+	 * @throws InvalidArgumentException
1042
+	 * @throws InvalidDataTypeException
1043
+	 * @throws InvalidInterfaceException
1044
+	 * @throws ReflectionException
1045
+	 */
1046
+	public function delete_state()
1047
+	{
1048
+		$CNT_ISO    = $this->getCountryISO();
1049
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1050
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
+
1052
+		if (! $STA_ID) {
1053
+			EE_Error::add_error(
1054
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
+				__FILE__,
1056
+				__FUNCTION__,
1057
+				__LINE__
1058
+			);
1059
+			return;
1060
+		}
1061
+
1062
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
+		if ($success !== false) {
1064
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
+					  $CNT_ISO,
1066
+					  $STA_ID,
1067
+					  ['STA_abbrev' => $STA_abbrev]);
1068
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1069
+		}
1070
+		if (defined('DOING_AJAX')) {
1071
+			$notices                = EE_Error::get_notices(false);
1072
+			$notices['return_data'] = true;
1073
+			echo wp_json_encode($notices);
1074
+			die();
1075
+		}
1076
+		$this->_redirect_after_action(
1077
+			$success,
1078
+			esc_html__('State', 'event_espresso'),
1079
+			'deleted',
1080
+			['action' => 'country_settings']
1081
+		);
1082
+	}
1083
+
1084
+
1085
+	/**
1086
+	 * @return void
1087
+	 * @throws EE_Error
1088
+	 * @throws InvalidArgumentException
1089
+	 * @throws InvalidDataTypeException
1090
+	 * @throws InvalidInterfaceException
1091
+	 * @throws ReflectionException
1092
+	 */
1093
+	protected function _update_country_settings()
1094
+	{
1095
+		$CNT_ISO = $this->getCountryISO();
1096
+		if (! $CNT_ISO) {
1097
+			EE_Error::add_error(
1098
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1099
+				__FILE__,
1100
+				__FUNCTION__,
1101
+				__LINE__
1102
+			);
1103
+			return;
1104
+		}
1105
+
1106
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1107
+
1108
+		$cols_n_values                    = [];
1109
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1110
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1111
+		);
1112
+		$cols_n_values['CNT_name']        =
1113
+			$this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1114
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1115
+			$this->request->getRequestParam(
1116
+				"cntry[$CNT_ISO][CNT_cur_code]",
1117
+				$country->currency_code()
1118
+			)
1119
+		);
1120
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1121
+			"cntry[$CNT_ISO][CNT_cur_single]",
1122
+			$country->currency_name_single()
1123
+		);
1124
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1125
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1126
+			$country->currency_name_plural()
1127
+		);
1128
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1129
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1130
+			$country->currency_sign()
1131
+		);
1132
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1133
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1134
+			$country->currency_sign_before(),
1135
+			DataType::BOOL
1136
+		);
1137
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1138
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1139
+			$country->currency_decimal_places()
1140
+		);
1141
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1142
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1143
+			$country->currency_decimal_mark()
1144
+		);
1145
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1146
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1147
+			$country->currency_thousands_separator()
1148
+		);
1149
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1150
+			"cntry[$CNT_ISO][CNT_tel_code]",
1151
+			$country->telephoneCode()
1152
+		);
1153
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1154
+			"cntry[$CNT_ISO][CNT_active]",
1155
+			$country->isActive(),
1156
+			DataType::BOOL
1157
+		);
1158
+
1159
+		// allow filtering of country data
1160
+		$cols_n_values = apply_filters(
1161
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1162
+			$cols_n_values
1163
+		);
1164
+
1165
+		// where values
1166
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1167
+		// run the update
1168
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1169
+
1170
+		// allow filtering of states data
1171
+		$states = apply_filters(
1172
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1174
+		);
1175
+
1176
+		if (! empty($states) && $success !== false) {
1177
+			// loop thru state data ( looks like : states[75][STA_name] )
1178
+			foreach ($states as $STA_ID => $state) {
1179
+				$cols_n_values = [
1180
+					'CNT_ISO'    => $CNT_ISO,
1181
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1182
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1183
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1184
+				];
1185
+				// where values
1186
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1187
+				// run the update
1188
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1189
+				if ($success !== false) {
1190
+					do_action(
1191
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1192
+						$CNT_ISO,
1193
+						$STA_ID,
1194
+						$cols_n_values
1195
+					);
1196
+				}
1197
+			}
1198
+		}
1199
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1200
+		if (
1201
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1202
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1203
+		) {
1204
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1205
+			EE_Registry::instance()->CFG->update_espresso_config();
1206
+		}
1207
+
1208
+		if ($success !== false) {
1209
+			EE_Error::add_success(
1210
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1211
+			);
1212
+		}
1213
+		$this->_redirect_after_action(
1214
+			$success,
1215
+			'',
1216
+			'',
1217
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1218
+			true
1219
+		);
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * form_form_field_label_wrap
1225
+	 *
1226
+	 * @param string $label
1227
+	 * @return string
1228
+	 */
1229
+	public function country_form_field_label_wrap(string $label): string
1230
+	{
1231
+		return '
1232 1232
 			<tr>
1233 1233
 				<th>
1234 1234
 					' . $label . '
1235 1235
 				</th>';
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * form_form_field_input__wrap
1241
-     *
1242
-     * @param string $input
1243
-     * @return string
1244
-     */
1245
-    public function country_form_field_input__wrap(string $input): string
1246
-    {
1247
-        return '
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * form_form_field_input__wrap
1241
+	 *
1242
+	 * @param string $input
1243
+	 * @return string
1244
+	 */
1245
+	public function country_form_field_input__wrap(string $input): string
1246
+	{
1247
+		return '
1248 1248
 				<td class="general-settings-country-input-td">
1249 1249
 					' . $input . '
1250 1250
 				</td>
1251 1251
 			</tr>';
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     * form_form_field_label_wrap
1257
-     *
1258
-     * @param string $label
1259
-     * @param string $required_text
1260
-     * @return string
1261
-     */
1262
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1263
-    {
1264
-        return $required_text;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * form_form_field_input__wrap
1270
-     *
1271
-     * @param string $input
1272
-     * @return string
1273
-     */
1274
-    public function state_form_field_input__wrap(string $input): string
1275
-    {
1276
-        return '
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 * form_form_field_label_wrap
1257
+	 *
1258
+	 * @param string $label
1259
+	 * @param string $required_text
1260
+	 * @return string
1261
+	 */
1262
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1263
+	{
1264
+		return $required_text;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * form_form_field_input__wrap
1270
+	 *
1271
+	 * @param string $input
1272
+	 * @return string
1273
+	 */
1274
+	public function state_form_field_input__wrap(string $input): string
1275
+	{
1276
+		return '
1277 1277
 				<td class="general-settings-country-state-input-td">
1278 1278
 					' . $input . '
1279 1279
 				</td>';
1280
-    }
1281
-
1282
-
1283
-    /***********/
1284
-
1285
-
1286
-    /**
1287
-     * displays edit and view links for critical EE pages
1288
-     *
1289
-     * @param int $ee_page_id
1290
-     * @return string
1291
-     */
1292
-    public static function edit_view_links(int $ee_page_id): string
1293
-    {
1294
-        $edit_url = add_query_arg(
1295
-            ['post' => $ee_page_id, 'action' => 'edit'],
1296
-            admin_url('post.php')
1297
-        );
1298
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1299
-        $links    .= ' &nbsp;|&nbsp; ';
1300
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1301
-
1302
-        return $links;
1303
-    }
1304
-
1305
-
1306
-    /**
1307
-     * displays page and shortcode status for critical EE pages
1308
-     *
1309
-     * @param WP_Post $ee_page
1310
-     * @param string  $shortcode
1311
-     * @return string
1312
-     */
1313
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1314
-    {
1315
-        // page status
1316
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1317
-            $pg_class  = 'ee-status-bg--success';
1318
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1319
-        } else {
1320
-            $pg_class  = 'ee-status-bg--error';
1321
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1322
-        }
1323
-
1324
-        // shortcode status
1325
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1326
-            $sc_class  = 'ee-status-bg--success';
1327
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1328
-        } else {
1329
-            $sc_class  = 'ee-status-bg--error';
1330
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1331
-        }
1332
-
1333
-        return '
1280
+	}
1281
+
1282
+
1283
+	/***********/
1284
+
1285
+
1286
+	/**
1287
+	 * displays edit and view links for critical EE pages
1288
+	 *
1289
+	 * @param int $ee_page_id
1290
+	 * @return string
1291
+	 */
1292
+	public static function edit_view_links(int $ee_page_id): string
1293
+	{
1294
+		$edit_url = add_query_arg(
1295
+			['post' => $ee_page_id, 'action' => 'edit'],
1296
+			admin_url('post.php')
1297
+		);
1298
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1299
+		$links    .= ' &nbsp;|&nbsp; ';
1300
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1301
+
1302
+		return $links;
1303
+	}
1304
+
1305
+
1306
+	/**
1307
+	 * displays page and shortcode status for critical EE pages
1308
+	 *
1309
+	 * @param WP_Post $ee_page
1310
+	 * @param string  $shortcode
1311
+	 * @return string
1312
+	 */
1313
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1314
+	{
1315
+		// page status
1316
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1317
+			$pg_class  = 'ee-status-bg--success';
1318
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1319
+		} else {
1320
+			$pg_class  = 'ee-status-bg--error';
1321
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1322
+		}
1323
+
1324
+		// shortcode status
1325
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1326
+			$sc_class  = 'ee-status-bg--success';
1327
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1328
+		} else {
1329
+			$sc_class  = 'ee-status-bg--error';
1330
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1331
+		}
1332
+
1333
+		return '
1334 1334
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1335 1335
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * generates a dropdown of all parent pages - copied from WP core
1341
-     *
1342
-     * @param int  $default
1343
-     * @param int  $parent
1344
-     * @param int  $level
1345
-     * @param bool $echo
1346
-     * @return string;
1347
-     */
1348
-    public static function page_settings_dropdown(
1349
-        int $default = 0,
1350
-        int $parent = 0,
1351
-        int $level = 0,
1352
-        bool $echo = true
1353
-    ): string {
1354
-        global $wpdb;
1355
-        $items  = $wpdb->get_results(
1356
-            $wpdb->prepare(
1357
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1358
-                $parent
1359
-            )
1360
-        );
1361
-        $output = '';
1362
-
1363
-        if ($items) {
1364
-            $level = absint($level);
1365
-            foreach ($items as $item) {
1366
-                $ID         = absint($item->ID);
1367
-                $post_title = wp_strip_all_tags($item->post_title);
1368
-                $pad        = str_repeat('&nbsp;', $level * 3);
1369
-                $option     = "\n\t";
1370
-                $option     .= '<option class="level-' . $level . '" ';
1371
-                $option     .= 'value="' . $ID . '" ';
1372
-                $option     .= $ID === absint($default) ? ' selected="selected"' : '';
1373
-                $option     .= '>';
1374
-                $option     .= "$pad $post_title";
1375
-                $option     .= '</option>';
1376
-                $output     .= $option;
1377
-                ob_start();
1378
-                parent_dropdown($default, $item->ID, $level + 1);
1379
-                $output .= ob_get_clean();
1380
-            }
1381
-        }
1382
-        if ($echo) {
1383
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1384
-            return '';
1385
-        }
1386
-        return $output;
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     * Loads the scripts for the privacy settings form
1392
-     */
1393
-    public function load_scripts_styles_privacy_settings()
1394
-    {
1395
-        $form_handler = $this->loader->getShared(
1396
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1397
-        );
1398
-        $form_handler->enqueueStylesAndScripts();
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * display the privacy settings form
1404
-     *
1405
-     * @throws EE_Error
1406
-     */
1407
-    public function privacySettings()
1408
-    {
1409
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1410
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1411
-        $form_handler                               = $this->loader->getShared(
1412
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1413
-        );
1414
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1415
-            $form_handler->display(),
1416
-            '',
1417
-            'padding'
1418
-        );
1419
-        $this->display_admin_page_with_sidebar();
1420
-    }
1421
-
1422
-
1423
-    /**
1424
-     * Update the privacy settings from form data
1425
-     *
1426
-     * @throws EE_Error
1427
-     */
1428
-    public function updatePrivacySettings()
1429
-    {
1430
-        $form_handler = $this->loader->getShared(
1431
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1432
-        );
1433
-        $success      = $form_handler->process($this->get_request_data());
1434
-        $this->_redirect_after_action(
1435
-            $success,
1436
-            esc_html__('Registration Form Options', 'event_espresso'),
1437
-            'updated',
1438
-            ['action' => 'privacy_settings']
1439
-        );
1440
-    }
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * generates a dropdown of all parent pages - copied from WP core
1341
+	 *
1342
+	 * @param int  $default
1343
+	 * @param int  $parent
1344
+	 * @param int  $level
1345
+	 * @param bool $echo
1346
+	 * @return string;
1347
+	 */
1348
+	public static function page_settings_dropdown(
1349
+		int $default = 0,
1350
+		int $parent = 0,
1351
+		int $level = 0,
1352
+		bool $echo = true
1353
+	): string {
1354
+		global $wpdb;
1355
+		$items  = $wpdb->get_results(
1356
+			$wpdb->prepare(
1357
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1358
+				$parent
1359
+			)
1360
+		);
1361
+		$output = '';
1362
+
1363
+		if ($items) {
1364
+			$level = absint($level);
1365
+			foreach ($items as $item) {
1366
+				$ID         = absint($item->ID);
1367
+				$post_title = wp_strip_all_tags($item->post_title);
1368
+				$pad        = str_repeat('&nbsp;', $level * 3);
1369
+				$option     = "\n\t";
1370
+				$option     .= '<option class="level-' . $level . '" ';
1371
+				$option     .= 'value="' . $ID . '" ';
1372
+				$option     .= $ID === absint($default) ? ' selected="selected"' : '';
1373
+				$option     .= '>';
1374
+				$option     .= "$pad $post_title";
1375
+				$option     .= '</option>';
1376
+				$output     .= $option;
1377
+				ob_start();
1378
+				parent_dropdown($default, $item->ID, $level + 1);
1379
+				$output .= ob_get_clean();
1380
+			}
1381
+		}
1382
+		if ($echo) {
1383
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1384
+			return '';
1385
+		}
1386
+		return $output;
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 * Loads the scripts for the privacy settings form
1392
+	 */
1393
+	public function load_scripts_styles_privacy_settings()
1394
+	{
1395
+		$form_handler = $this->loader->getShared(
1396
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1397
+		);
1398
+		$form_handler->enqueueStylesAndScripts();
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * display the privacy settings form
1404
+	 *
1405
+	 * @throws EE_Error
1406
+	 */
1407
+	public function privacySettings()
1408
+	{
1409
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1410
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1411
+		$form_handler                               = $this->loader->getShared(
1412
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1413
+		);
1414
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1415
+			$form_handler->display(),
1416
+			'',
1417
+			'padding'
1418
+		);
1419
+		$this->display_admin_page_with_sidebar();
1420
+	}
1421
+
1422
+
1423
+	/**
1424
+	 * Update the privacy settings from form data
1425
+	 *
1426
+	 * @throws EE_Error
1427
+	 */
1428
+	public function updatePrivacySettings()
1429
+	{
1430
+		$form_handler = $this->loader->getShared(
1431
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1432
+		);
1433
+		$success      = $form_handler->process($this->get_request_data());
1434
+		$this->_redirect_after_action(
1435
+			$success,
1436
+			esc_html__('Registration Form Options', 'event_espresso'),
1437
+			'updated',
1438
+			['action' => 'privacy_settings']
1439
+		);
1440
+	}
1441 1441
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +549 added lines, -549 removed lines patch added patch discarded remove patch
@@ -16,553 +16,553 @@
 block discarded – undo
16 16
  */
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19
-    /**
20
-     * $_COOKIE parameters
21
-     *
22
-     * @var array
23
-     */
24
-    protected $cookies;
25
-
26
-    /**
27
-     * $_FILES parameters
28
-     *
29
-     * @var array
30
-     */
31
-    protected $files;
32
-
33
-    /**
34
-     * true if current user appears to be some kind of bot
35
-     *
36
-     * @var bool
37
-     */
38
-    protected $is_bot;
39
-
40
-    /**
41
-     * @var RequestParams
42
-     */
43
-    protected $request_params;
44
-
45
-    /**
46
-     * @var RequestTypeContextCheckerInterface
47
-     */
48
-    protected $request_type;
49
-
50
-    /**
51
-     * @var ServerParams
52
-     */
53
-    protected $server_params;
54
-
55
-
56
-    public function __construct(
57
-        RequestParams $request_params,
58
-        ServerParams $server_params,
59
-        array $cookies = [],
60
-        array $files = []
61
-    ) {
62
-        $this->cookies        = ! empty($cookies)
63
-            ? $cookies
64
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
65
-        $this->files          = ! empty($files) ? $files : $_FILES;
66
-        $this->request_params = $request_params;
67
-        $this->server_params  = $server_params;
68
-    }
69
-
70
-
71
-    /**
72
-     * @param RequestTypeContextCheckerInterface $type
73
-     */
74
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
75
-    {
76
-        $this->request_type = $type;
77
-    }
78
-
79
-
80
-    /**
81
-     * @return array
82
-     */
83
-    public function getParams()
84
-    {
85
-        return $this->request_params->getParams();
86
-    }
87
-
88
-
89
-    /**
90
-     * @return array
91
-     */
92
-    public function postParams()
93
-    {
94
-        return $this->request_params->postParams();
95
-    }
96
-
97
-
98
-    /**
99
-     * @return array
100
-     */
101
-    public function cookieParams()
102
-    {
103
-        return $this->cookies;
104
-    }
105
-
106
-
107
-    /**
108
-     * @return array
109
-     */
110
-    public function serverParams()
111
-    {
112
-        return $this->server_params->getAllServerParams();
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string     $key
118
-     * @param mixed|null $default
119
-     * @return array|int|float|string
120
-     */
121
-    public function getServerParam($key, $default = null)
122
-    {
123
-        return $this->server_params->getServerParam($key, $default);
124
-    }
125
-
126
-
127
-    /**
128
-     * @param string                 $key
129
-     * @param array|int|float|string $value
130
-     * @param bool                   $set_global_too
131
-     * @return void
132
-     */
133
-    public function setServerParam(string $key, $value, bool $set_global_too = false)
134
-    {
135
-        $this->server_params->setServerParam($key, $value, $set_global_too);
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   4.10.24.p
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 = DataType::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 = DataType::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
-     * @param string $key
284
-     * @param bool   $unset_from_global_too
285
-     * @return void
286
-     */
287
-    public function unSetServerParam(string $key, bool $unset_from_global_too = false)
288
-    {
289
-        $this->server_params->unSetServerParam($key, $unset_from_global_too);
290
-    }
291
-
292
-
293
-    /**
294
-     * @return string
295
-     */
296
-    public function ipAddress()
297
-    {
298
-        return $this->server_params->ipAddress();
299
-    }
300
-
301
-
302
-    /**
303
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
304
-     *
305
-     * @param boolean $relativeToWpRoot    If home_url() is "http://mysite.com/wp/", and a request comes to
306
-     *                                     "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
307
-     *                                     "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
308
-     * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
309
-     * @return string
310
-     */
311
-    public function requestUri($relativeToWpRoot = false, $remove_query_params = false)
312
-    {
313
-        return $this->server_params->requestUri($relativeToWpRoot);
314
-    }
315
-
316
-
317
-    /**
318
-     * @return string
319
-     */
320
-    public function userAgent()
321
-    {
322
-        return $this->server_params->userAgent();
323
-    }
324
-
325
-
326
-    /**
327
-     * @param string $user_agent
328
-     */
329
-    public function setUserAgent($user_agent = '')
330
-    {
331
-        $this->server_params->setUserAgent($user_agent);
332
-    }
333
-
334
-
335
-    /**
336
-     * @return bool
337
-     */
338
-    public function isBot()
339
-    {
340
-        return $this->is_bot;
341
-    }
342
-
343
-
344
-    /**
345
-     * @param bool $is_bot
346
-     */
347
-    public function setIsBot($is_bot)
348
-    {
349
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
350
-    }
351
-
352
-
353
-    /**
354
-     * @return bool
355
-     */
356
-    public function isActivation()
357
-    {
358
-        return $this->request_type->isActivation();
359
-    }
360
-
361
-
362
-    /**
363
-     * @param $is_activation
364
-     * @return bool
365
-     */
366
-    public function setIsActivation($is_activation)
367
-    {
368
-        return $this->request_type->setIsActivation($is_activation);
369
-    }
370
-
371
-
372
-    /**
373
-     * @return bool
374
-     */
375
-    public function isAdmin()
376
-    {
377
-        return $this->request_type->isAdmin();
378
-    }
379
-
380
-
381
-    /**
382
-     * @return bool
383
-     */
384
-    public function isAdminAjax()
385
-    {
386
-        return $this->request_type->isAdminAjax();
387
-    }
388
-
389
-
390
-    /**
391
-     * @return bool
392
-     */
393
-    public function isAjax()
394
-    {
395
-        return $this->request_type->isAjax();
396
-    }
397
-
398
-
399
-    /**
400
-     * @return bool
401
-     */
402
-    public function isEeAjax()
403
-    {
404
-        return $this->request_type->isEeAjax();
405
-    }
406
-
407
-
408
-    /**
409
-     * @return bool
410
-     */
411
-    public function isOtherAjax()
412
-    {
413
-        return $this->request_type->isOtherAjax();
414
-    }
415
-
416
-
417
-    /**
418
-     * @return bool
419
-     */
420
-    public function isApi()
421
-    {
422
-        return $this->request_type->isApi();
423
-    }
424
-
425
-
426
-    /**
427
-     * @return bool
428
-     */
429
-    public function isCli()
430
-    {
431
-        return $this->request_type->isCli();
432
-    }
433
-
434
-
435
-    /**
436
-     * @return bool
437
-     */
438
-    public function isCron()
439
-    {
440
-        return $this->request_type->isCron();
441
-    }
442
-
443
-
444
-    /**
445
-     * @return bool
446
-     */
447
-    public function isFeed()
448
-    {
449
-        return $this->request_type->isFeed();
450
-    }
451
-
452
-
453
-    /**
454
-     * @return bool
455
-     */
456
-    public function isFrontend()
457
-    {
458
-        return $this->request_type->isFrontend();
459
-    }
460
-
461
-
462
-    /**
463
-     * @return bool
464
-     */
465
-    public function isFrontAjax()
466
-    {
467
-        return $this->request_type->isFrontAjax();
468
-    }
469
-
470
-
471
-    /**
472
-     * @return bool
473
-     */
474
-    public function isGQL()
475
-    {
476
-        return $this->request_type->isGQL();
477
-    }
478
-
479
-
480
-    /**
481
-     * @return bool
482
-     */
483
-    public function isIframe()
484
-    {
485
-        return $this->request_type->isIframe();
486
-    }
487
-
488
-
489
-    /**
490
-     * @return bool
491
-     */
492
-    public function isUnitTesting()
493
-    {
494
-        return $this->request_type->isUnitTesting();
495
-    }
496
-
497
-
498
-    /**
499
-     * @return bool
500
-     */
501
-    public function isWordPressApi()
502
-    {
503
-        return $this->request_type->isWordPressApi();
504
-    }
505
-
506
-
507
-    /**
508
-     * @return bool
509
-     */
510
-    public function isWordPressHeartbeat()
511
-    {
512
-        return $this->request_type->isWordPressHeartbeat();
513
-    }
514
-
515
-
516
-    /**
517
-     * @return bool
518
-     */
519
-    public function isWordPressScrape()
520
-    {
521
-        return $this->request_type->isWordPressScrape();
522
-    }
523
-
524
-
525
-    /**
526
-     * @return string
527
-     */
528
-    public function slug()
529
-    {
530
-        return $this->request_type->slug();
531
-    }
532
-
533
-
534
-    /**
535
-     * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
536
-     *
537
-     * @return string
538
-     * @since   $VID:$
539
-     */
540
-    public function requestPath()
541
-    {
542
-        return $this->requestUri(true, true);
543
-    }
544
-
545
-
546
-    /**
547
-     * returns true if the last segment of the current request path (without params) matches the provided string
548
-     *
549
-     * @param string $uri_segment
550
-     * @return bool
551
-     * @since   $VID:$
552
-     */
553
-    public function currentPageIs($uri_segment)
554
-    {
555
-        $request_path = $this->requestPath();
556
-        $current_page = explode('/', $request_path);
557
-        return end($current_page) === $uri_segment;
558
-    }
559
-
560
-
561
-    /**
562
-     * @return RequestTypeContextCheckerInterface
563
-     */
564
-    public function getRequestType(): RequestTypeContextCheckerInterface
565
-    {
566
-        return $this->request_type;
567
-    }
19
+	/**
20
+	 * $_COOKIE parameters
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $cookies;
25
+
26
+	/**
27
+	 * $_FILES parameters
28
+	 *
29
+	 * @var array
30
+	 */
31
+	protected $files;
32
+
33
+	/**
34
+	 * true if current user appears to be some kind of bot
35
+	 *
36
+	 * @var bool
37
+	 */
38
+	protected $is_bot;
39
+
40
+	/**
41
+	 * @var RequestParams
42
+	 */
43
+	protected $request_params;
44
+
45
+	/**
46
+	 * @var RequestTypeContextCheckerInterface
47
+	 */
48
+	protected $request_type;
49
+
50
+	/**
51
+	 * @var ServerParams
52
+	 */
53
+	protected $server_params;
54
+
55
+
56
+	public function __construct(
57
+		RequestParams $request_params,
58
+		ServerParams $server_params,
59
+		array $cookies = [],
60
+		array $files = []
61
+	) {
62
+		$this->cookies        = ! empty($cookies)
63
+			? $cookies
64
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
65
+		$this->files          = ! empty($files) ? $files : $_FILES;
66
+		$this->request_params = $request_params;
67
+		$this->server_params  = $server_params;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param RequestTypeContextCheckerInterface $type
73
+	 */
74
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
75
+	{
76
+		$this->request_type = $type;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @return array
82
+	 */
83
+	public function getParams()
84
+	{
85
+		return $this->request_params->getParams();
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return array
91
+	 */
92
+	public function postParams()
93
+	{
94
+		return $this->request_params->postParams();
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return array
100
+	 */
101
+	public function cookieParams()
102
+	{
103
+		return $this->cookies;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return array
109
+	 */
110
+	public function serverParams()
111
+	{
112
+		return $this->server_params->getAllServerParams();
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string     $key
118
+	 * @param mixed|null $default
119
+	 * @return array|int|float|string
120
+	 */
121
+	public function getServerParam($key, $default = null)
122
+	{
123
+		return $this->server_params->getServerParam($key, $default);
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param string                 $key
129
+	 * @param array|int|float|string $value
130
+	 * @param bool                   $set_global_too
131
+	 * @return void
132
+	 */
133
+	public function setServerParam(string $key, $value, bool $set_global_too = false)
134
+	{
135
+		$this->server_params->setServerParam($key, $value, $set_global_too);
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   4.10.24.p
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 = DataType::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 = DataType::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
+	 * @param string $key
284
+	 * @param bool   $unset_from_global_too
285
+	 * @return void
286
+	 */
287
+	public function unSetServerParam(string $key, bool $unset_from_global_too = false)
288
+	{
289
+		$this->server_params->unSetServerParam($key, $unset_from_global_too);
290
+	}
291
+
292
+
293
+	/**
294
+	 * @return string
295
+	 */
296
+	public function ipAddress()
297
+	{
298
+		return $this->server_params->ipAddress();
299
+	}
300
+
301
+
302
+	/**
303
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
304
+	 *
305
+	 * @param boolean $relativeToWpRoot    If home_url() is "http://mysite.com/wp/", and a request comes to
306
+	 *                                     "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
307
+	 *                                     "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
308
+	 * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
309
+	 * @return string
310
+	 */
311
+	public function requestUri($relativeToWpRoot = false, $remove_query_params = false)
312
+	{
313
+		return $this->server_params->requestUri($relativeToWpRoot);
314
+	}
315
+
316
+
317
+	/**
318
+	 * @return string
319
+	 */
320
+	public function userAgent()
321
+	{
322
+		return $this->server_params->userAgent();
323
+	}
324
+
325
+
326
+	/**
327
+	 * @param string $user_agent
328
+	 */
329
+	public function setUserAgent($user_agent = '')
330
+	{
331
+		$this->server_params->setUserAgent($user_agent);
332
+	}
333
+
334
+
335
+	/**
336
+	 * @return bool
337
+	 */
338
+	public function isBot()
339
+	{
340
+		return $this->is_bot;
341
+	}
342
+
343
+
344
+	/**
345
+	 * @param bool $is_bot
346
+	 */
347
+	public function setIsBot($is_bot)
348
+	{
349
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
350
+	}
351
+
352
+
353
+	/**
354
+	 * @return bool
355
+	 */
356
+	public function isActivation()
357
+	{
358
+		return $this->request_type->isActivation();
359
+	}
360
+
361
+
362
+	/**
363
+	 * @param $is_activation
364
+	 * @return bool
365
+	 */
366
+	public function setIsActivation($is_activation)
367
+	{
368
+		return $this->request_type->setIsActivation($is_activation);
369
+	}
370
+
371
+
372
+	/**
373
+	 * @return bool
374
+	 */
375
+	public function isAdmin()
376
+	{
377
+		return $this->request_type->isAdmin();
378
+	}
379
+
380
+
381
+	/**
382
+	 * @return bool
383
+	 */
384
+	public function isAdminAjax()
385
+	{
386
+		return $this->request_type->isAdminAjax();
387
+	}
388
+
389
+
390
+	/**
391
+	 * @return bool
392
+	 */
393
+	public function isAjax()
394
+	{
395
+		return $this->request_type->isAjax();
396
+	}
397
+
398
+
399
+	/**
400
+	 * @return bool
401
+	 */
402
+	public function isEeAjax()
403
+	{
404
+		return $this->request_type->isEeAjax();
405
+	}
406
+
407
+
408
+	/**
409
+	 * @return bool
410
+	 */
411
+	public function isOtherAjax()
412
+	{
413
+		return $this->request_type->isOtherAjax();
414
+	}
415
+
416
+
417
+	/**
418
+	 * @return bool
419
+	 */
420
+	public function isApi()
421
+	{
422
+		return $this->request_type->isApi();
423
+	}
424
+
425
+
426
+	/**
427
+	 * @return bool
428
+	 */
429
+	public function isCli()
430
+	{
431
+		return $this->request_type->isCli();
432
+	}
433
+
434
+
435
+	/**
436
+	 * @return bool
437
+	 */
438
+	public function isCron()
439
+	{
440
+		return $this->request_type->isCron();
441
+	}
442
+
443
+
444
+	/**
445
+	 * @return bool
446
+	 */
447
+	public function isFeed()
448
+	{
449
+		return $this->request_type->isFeed();
450
+	}
451
+
452
+
453
+	/**
454
+	 * @return bool
455
+	 */
456
+	public function isFrontend()
457
+	{
458
+		return $this->request_type->isFrontend();
459
+	}
460
+
461
+
462
+	/**
463
+	 * @return bool
464
+	 */
465
+	public function isFrontAjax()
466
+	{
467
+		return $this->request_type->isFrontAjax();
468
+	}
469
+
470
+
471
+	/**
472
+	 * @return bool
473
+	 */
474
+	public function isGQL()
475
+	{
476
+		return $this->request_type->isGQL();
477
+	}
478
+
479
+
480
+	/**
481
+	 * @return bool
482
+	 */
483
+	public function isIframe()
484
+	{
485
+		return $this->request_type->isIframe();
486
+	}
487
+
488
+
489
+	/**
490
+	 * @return bool
491
+	 */
492
+	public function isUnitTesting()
493
+	{
494
+		return $this->request_type->isUnitTesting();
495
+	}
496
+
497
+
498
+	/**
499
+	 * @return bool
500
+	 */
501
+	public function isWordPressApi()
502
+	{
503
+		return $this->request_type->isWordPressApi();
504
+	}
505
+
506
+
507
+	/**
508
+	 * @return bool
509
+	 */
510
+	public function isWordPressHeartbeat()
511
+	{
512
+		return $this->request_type->isWordPressHeartbeat();
513
+	}
514
+
515
+
516
+	/**
517
+	 * @return bool
518
+	 */
519
+	public function isWordPressScrape()
520
+	{
521
+		return $this->request_type->isWordPressScrape();
522
+	}
523
+
524
+
525
+	/**
526
+	 * @return string
527
+	 */
528
+	public function slug()
529
+	{
530
+		return $this->request_type->slug();
531
+	}
532
+
533
+
534
+	/**
535
+	 * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
536
+	 *
537
+	 * @return string
538
+	 * @since   $VID:$
539
+	 */
540
+	public function requestPath()
541
+	{
542
+		return $this->requestUri(true, true);
543
+	}
544
+
545
+
546
+	/**
547
+	 * returns true if the last segment of the current request path (without params) matches the provided string
548
+	 *
549
+	 * @param string $uri_segment
550
+	 * @return bool
551
+	 * @since   $VID:$
552
+	 */
553
+	public function currentPageIs($uri_segment)
554
+	{
555
+		$request_path = $this->requestPath();
556
+		$current_page = explode('/', $request_path);
557
+		return end($current_page) === $uri_segment;
558
+	}
559
+
560
+
561
+	/**
562
+	 * @return RequestTypeContextCheckerInterface
563
+	 */
564
+	public function getRequestType(): RequestTypeContextCheckerInterface
565
+	{
566
+		return $this->request_type;
567
+	}
568 568
 }
Please login to merge, or discard this patch.