Completed
Branch fix/events-archive-config-rese... (0ef832)
by
unknown
12:05 queued 09:36
created
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3689 added lines, -3689 removed lines patch added patch discarded remove patch
@@ -19,2233 +19,2233 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    /**
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 = null;
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->getLoader()->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->getLoader()->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->getLoader()->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->getLoader()->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
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
573
-                // 'help_tour'     => array('Registration_Overview_Help_Tour'),
574
-                'qtips'         => ['Registration_List_Table_Tips'],
575
-                'list_table'    => 'EE_Registrations_List_Table',
576
-                'require_nonce' => false,
577
-            ],
578
-            'view_registration' => [
579
-                'nav'           => [
580
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
581
-                    'order'      => 15,
582
-                    'url'        => $REG_ID
583
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
584
-                        : $this->_admin_base_url,
585
-                    'persistent' => false,
586
-                ],
587
-                'help_tabs'     => [
588
-                    'registrations_details_help_tab'                    => [
589
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
590
-                        'filename' => 'registrations_details',
591
-                    ],
592
-                    'registrations_details_table_help_tab'              => [
593
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
594
-                        'filename' => 'registrations_details_table',
595
-                    ],
596
-                    'registrations_details_form_answers_help_tab'       => [
597
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
598
-                        'filename' => 'registrations_details_form_answers',
599
-                    ],
600
-                    'registrations_details_registrant_details_help_tab' => [
601
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
602
-                        'filename' => 'registrations_details_registrant_details',
603
-                    ],
604
-                ],
605
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
606
-                // 'help_tour'     => array('Registration_Details_Help_Tour'),
607
-                'metaboxes'     => array_merge(
608
-                    $this->_default_espresso_metaboxes,
609
-                    ['_registration_details_metaboxes']
610
-                ),
611
-                'require_nonce' => false,
612
-            ],
613
-            'new_registration'  => [
614
-                'nav'           => [
615
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
616
-                    'url'        => '#',
617
-                    'order'      => 15,
618
-                    'persistent' => false,
619
-                ],
620
-                'metaboxes'     => $this->_default_espresso_metaboxes,
621
-                'labels'        => [
622
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
623
-                ],
624
-                'require_nonce' => false,
625
-            ],
626
-            'add_new_attendee'  => [
627
-                'nav'           => [
628
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
629
-                    'order'      => 15,
630
-                    'persistent' => false,
631
-                ],
632
-                'metaboxes'     => array_merge(
633
-                    $this->_default_espresso_metaboxes,
634
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
635
-                ),
636
-                'require_nonce' => false,
637
-            ],
638
-            'edit_attendee'     => [
639
-                'nav'           => [
640
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
641
-                    'order'      => 15,
642
-                    'persistent' => false,
643
-                    'url'        => $ATT_ID
644
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
645
-                        : $this->_admin_base_url,
646
-                ],
647
-                'metaboxes'     => ['attendee_editor_metaboxes'],
648
-                'require_nonce' => false,
649
-            ],
650
-            'contact_list'      => [
651
-                'nav'           => [
652
-                    'label' => esc_html__('Contact List', 'event_espresso'),
653
-                    'order' => 20,
654
-                ],
655
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
656
-                'help_tabs'     => [
657
-                    'registrations_contact_list_help_tab'                       => [
658
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
659
-                        'filename' => 'registrations_contact_list',
660
-                    ],
661
-                    'registrations_contact-list_table_column_headings_help_tab' => [
662
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
663
-                        'filename' => 'registrations_contact_list_table_column_headings',
664
-                    ],
665
-                    'registrations_contact_list_views_help_tab'                 => [
666
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
667
-                        'filename' => 'registrations_contact_list_views',
668
-                    ],
669
-                    'registrations_contact_list_other_help_tab'                 => [
670
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
671
-                        'filename' => 'registrations_contact_list_other',
672
-                    ],
673
-                ],
674
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
675
-                // 'help_tour'     => array('Contact_List_Help_Tour'),
676
-                'metaboxes'     => [],
677
-                'require_nonce' => false,
678
-            ],
679
-            // override default cpt routes
680
-            'create_new'        => '',
681
-            'edit'              => '',
682
-        ];
683
-    }
684
-
685
-
686
-    /**
687
-     * The below methods aren't used by this class currently
688
-     */
689
-    protected function _add_screen_options()
690
-    {
691
-    }
692
-
693
-
694
-    protected function _add_feature_pointers()
695
-    {
696
-    }
697
-
698
-
699
-    public function admin_init()
700
-    {
701
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
702
-            'click "Update Registration Questions" to save your changes',
703
-            'event_espresso'
704
-        );
705
-    }
706
-
707
-
708
-    public function admin_notices()
709
-    {
710
-    }
711
-
712
-
713
-    public function admin_footer_scripts()
714
-    {
715
-    }
716
-
717
-
718
-    /**
719
-     * get list of registration statuses
720
-     *
721
-     * @return void
722
-     * @throws EE_Error
723
-     */
724
-    private function _get_registration_status_array()
725
-    {
726
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
727
-    }
728
-
729
-
730
-    /**
731
-     * @throws InvalidArgumentException
732
-     * @throws InvalidDataTypeException
733
-     * @throws InvalidInterfaceException
734
-     * @since 4.10.2.p
735
-     */
736
-    protected function _add_screen_options_default()
737
-    {
738
-        $this->_per_page_screen_option();
739
-    }
740
-
741
-
742
-    /**
743
-     * @throws InvalidArgumentException
744
-     * @throws InvalidDataTypeException
745
-     * @throws InvalidInterfaceException
746
-     * @since 4.10.2.p
747
-     */
748
-    protected function _add_screen_options_contact_list()
749
-    {
750
-        $page_title              = $this->_admin_page_title;
751
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
752
-        $this->_per_page_screen_option();
753
-        $this->_admin_page_title = $page_title;
754
-    }
755
-
756
-
757
-    public function load_scripts_styles()
758
-    {
759
-        // style
760
-        wp_register_style(
761
-            'espresso_reg',
762
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
763
-            ['ee-admin-css'],
764
-            EVENT_ESPRESSO_VERSION
765
-        );
766
-        wp_enqueue_style('espresso_reg');
767
-        // script
768
-        wp_register_script(
769
-            'espresso_reg',
770
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
771
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772
-            EVENT_ESPRESSO_VERSION,
773
-            true
774
-        );
775
-        wp_enqueue_script('espresso_reg');
776
-    }
777
-
778
-
779
-    /**
780
-     * @throws EE_Error
781
-     * @throws InvalidArgumentException
782
-     * @throws InvalidDataTypeException
783
-     * @throws InvalidInterfaceException
784
-     * @throws ReflectionException
785
-     * @since 4.10.2.p
786
-     */
787
-    public function load_scripts_styles_edit_attendee()
788
-    {
789
-        // stuff to only show up on our attendee edit details page.
790
-        $attendee_details_translations = [
791
-            'att_publish_text' => sprintf(
792
-            /* translators: The date and time */
793
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
795
-            ),
796
-        ];
797
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
798
-        wp_enqueue_script('jquery-validate');
799
-    }
800
-
801
-
802
-    /**
803
-     * @throws EE_Error
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     * @throws ReflectionException
808
-     * @since 4.10.2.p
809
-     */
810
-    public function load_scripts_styles_view_registration()
811
-    {
812
-        // styles
813
-        wp_enqueue_style('espresso-ui-theme');
814
-        // scripts
815
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
816
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
817
-    }
818
-
819
-
820
-    public function load_scripts_styles_contact_list()
821
-    {
822
-        wp_dequeue_style('espresso_reg');
823
-        wp_register_style(
824
-            'espresso_att',
825
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
826
-            ['ee-admin-css'],
827
-            EVENT_ESPRESSO_VERSION
828
-        );
829
-        wp_enqueue_style('espresso_att');
830
-    }
831
-
832
-
833
-    public function load_scripts_styles_new_registration()
834
-    {
835
-        wp_register_script(
836
-            'ee-spco-for-admin',
837
-            REG_ASSETS_URL . 'spco_for_admin.js',
838
-            ['underscore', 'jquery'],
839
-            EVENT_ESPRESSO_VERSION,
840
-            true
841
-        );
842
-        wp_enqueue_script('ee-spco-for-admin');
843
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
844
-        EE_Form_Section_Proper::wp_enqueue_scripts();
845
-        EED_Ticket_Selector::load_tckt_slctr_assets();
846
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
847
-    }
848
-
849
-
850
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
851
-    {
852
-        add_filter('FHEE_load_EE_messages', '__return_true');
853
-    }
854
-
855
-
856
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
857
-    {
858
-        add_filter('FHEE_load_EE_messages', '__return_true');
859
-    }
860
-
861
-
862
-    /**
863
-     * @throws EE_Error
864
-     * @throws InvalidArgumentException
865
-     * @throws InvalidDataTypeException
866
-     * @throws InvalidInterfaceException
867
-     * @throws ReflectionException
868
-     * @since 4.10.2.p
869
-     */
870
-    protected function _set_list_table_views_default()
871
-    {
872
-        // for notification related bulk actions we need to make sure only active messengers have an option.
873
-        EED_Messages::set_autoloaders();
874
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
875
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
876
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
877
-        // key= bulk_action_slug, value= message type.
878
-        $match_array = [
879
-            'approve_registrations'    => 'registration',
880
-            'decline_registrations'    => 'declined_registration',
881
-            'pending_registrations'    => 'pending_approval',
882
-            'no_approve_registrations' => 'not_approved_registration',
883
-            'cancel_registrations'     => 'cancelled_registration',
884
-        ];
885
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
886
-            'ee_send_message',
887
-            'batch_send_messages'
888
-        );
889
-        /** setup reg status bulk actions **/
890
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
891
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
892
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
893
-                'Approve and Notify Registrations',
894
-                'event_espresso'
895
-            );
896
-        }
897
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
898
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
899
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
900
-                'Decline and Notify Registrations',
901
-                'event_espresso'
902
-            );
903
-        }
904
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
905
-            'Set Registrations to Pending Payment',
906
-            'event_espresso'
907
-        );
908
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
909
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
910
-                'Set Registrations to Pending Payment and Notify',
911
-                'event_espresso'
912
-            );
913
-        }
914
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
915
-            'Set Registrations to Not Approved',
916
-            'event_espresso'
917
-        );
918
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
919
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
920
-                'Set Registrations to Not Approved and Notify',
921
-                'event_espresso'
922
-            );
923
-        }
924
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
925
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
926
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
927
-                'Cancel Registrations and Notify',
928
-                'event_espresso'
929
-            );
930
-        }
931
-        $def_reg_status_actions = apply_filters(
932
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
933
-            $def_reg_status_actions,
934
-            $active_mts,
935
-            $can_send
936
-        );
937
-
938
-        $this->_views = [
939
-            'all'   => [
940
-                'slug'        => 'all',
941
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
942
-                'count'       => 0,
943
-                'bulk_action' => array_merge(
944
-                    $def_reg_status_actions,
945
-                    [
946
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
947
-                    ]
948
-                ),
949
-            ],
950
-            'month' => [
951
-                'slug'        => 'month',
952
-                'label'       => esc_html__('This Month', 'event_espresso'),
953
-                'count'       => 0,
954
-                'bulk_action' => array_merge(
955
-                    $def_reg_status_actions,
956
-                    [
957
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
958
-                    ]
959
-                ),
960
-            ],
961
-            'today' => [
962
-                'slug'        => 'today',
963
-                'label'       => sprintf(
964
-                    esc_html__('Today - %s', 'event_espresso'),
965
-                    date('M d, Y', current_time('timestamp'))
966
-                ),
967
-                'count'       => 0,
968
-                'bulk_action' => array_merge(
969
-                    $def_reg_status_actions,
970
-                    [
971
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
972
-                    ]
973
-                ),
974
-            ],
975
-        ];
976
-        if (
977
-            EE_Registry::instance()->CAP->current_user_can(
978
-                'ee_delete_registrations',
979
-                'espresso_registrations_delete_registration'
980
-            )
981
-        ) {
982
-            $this->_views['incomplete'] = [
983
-                'slug'        => 'incomplete',
984
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
985
-                'count'       => 0,
986
-                'bulk_action' => [
987
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988
-                ],
989
-            ];
990
-            $this->_views['trash']      = [
991
-                'slug'        => 'trash',
992
-                'label'       => esc_html__('Trash', 'event_espresso'),
993
-                'count'       => 0,
994
-                'bulk_action' => [
995
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
996
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
997
-                ],
998
-            ];
999
-        }
1000
-    }
1001
-
1002
-
1003
-    protected function _set_list_table_views_contact_list()
1004
-    {
1005
-        $this->_views = [
1006
-            'in_use' => [
1007
-                'slug'        => 'in_use',
1008
-                'label'       => esc_html__('In Use', 'event_espresso'),
1009
-                'count'       => 0,
1010
-                'bulk_action' => [
1011
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1012
-                ],
1013
-            ],
1014
-        ];
1015
-        if (
1016
-            EE_Registry::instance()->CAP->current_user_can(
1017
-                'ee_delete_contacts',
1018
-                'espresso_registrations_trash_attendees'
1019
-            )
1020
-        ) {
1021
-            $this->_views['trash'] = [
1022
-                'slug'        => 'trash',
1023
-                'label'       => esc_html__('Trash', 'event_espresso'),
1024
-                'count'       => 0,
1025
-                'bulk_action' => [
1026
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1027
-                ],
1028
-            ];
1029
-        }
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return array
1035
-     * @throws EE_Error
1036
-     */
1037
-    protected function _registration_legend_items()
1038
-    {
1039
-        $fc_items = [
1040
-            'star-icon'        => [
1041
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1042
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1043
-            ],
1044
-            'view_details'     => [
1045
-                'class' => 'dashicons dashicons-clipboard',
1046
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1047
-            ],
1048
-            'edit_attendee'    => [
1049
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1050
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1051
-            ],
1052
-            'view_transaction' => [
1053
-                'class' => 'dashicons dashicons-cart',
1054
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1055
-            ],
1056
-            'view_invoice'     => [
1057
-                'class' => 'dashicons dashicons-media-spreadsheet',
1058
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1059
-            ],
1060
-        ];
1061
-        if (
1062
-            EE_Registry::instance()->CAP->current_user_can(
1063
-                'ee_send_message',
1064
-                'espresso_registrations_resend_registration'
1065
-            )
1066
-        ) {
1067
-            $fc_items['resend_registration'] = [
1068
-                'class' => 'dashicons dashicons-email-alt',
1069
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1070
-            ];
1071
-        } else {
1072
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1073
-        }
1074
-        if (
1075
-            EE_Registry::instance()->CAP->current_user_can(
1076
-                'ee_read_global_messages',
1077
-                'view_filtered_messages'
1078
-            )
1079
-        ) {
1080
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1081
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1082
-                $fc_items['view_related_messages'] = [
1083
-                    'class' => $related_for_icon['css_class'],
1084
-                    'desc'  => $related_for_icon['label'],
1085
-                ];
1086
-            }
1087
-        }
1088
-        $sc_items = [
1089
-            'approved_status'   => [
1090
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1091
-                'desc'  => EEH_Template::pretty_status(
1092
-                    EEM_Registration::status_id_approved,
1093
-                    false,
1094
-                    'sentence'
1095
-                ),
1096
-            ],
1097
-            'pending_status'    => [
1098
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1099
-                'desc'  => EEH_Template::pretty_status(
1100
-                    EEM_Registration::status_id_pending_payment,
1101
-                    false,
1102
-                    'sentence'
1103
-                ),
1104
-            ],
1105
-            'wait_list'         => [
1106
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1107
-                'desc'  => EEH_Template::pretty_status(
1108
-                    EEM_Registration::status_id_wait_list,
1109
-                    false,
1110
-                    'sentence'
1111
-                ),
1112
-            ],
1113
-            'incomplete_status' => [
1114
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1115
-                'desc'  => EEH_Template::pretty_status(
1116
-                    EEM_Registration::status_id_incomplete,
1117
-                    false,
1118
-                    'sentence'
1119
-                ),
1120
-            ],
1121
-            'not_approved'      => [
1122
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1123
-                'desc'  => EEH_Template::pretty_status(
1124
-                    EEM_Registration::status_id_not_approved,
1125
-                    false,
1126
-                    'sentence'
1127
-                ),
1128
-            ],
1129
-            'declined_status'   => [
1130
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1131
-                'desc'  => EEH_Template::pretty_status(
1132
-                    EEM_Registration::status_id_declined,
1133
-                    false,
1134
-                    'sentence'
1135
-                ),
1136
-            ],
1137
-            'cancelled_status'  => [
1138
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1139
-                'desc'  => EEH_Template::pretty_status(
1140
-                    EEM_Registration::status_id_cancelled,
1141
-                    false,
1142
-                    'sentence'
1143
-                ),
1144
-            ],
1145
-        ];
1146
-        return array_merge($fc_items, $sc_items);
1147
-    }
1148
-
1149
-
1150
-
1151
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1152
-
1153
-
1154
-    /**
1155
-     * @throws DomainException
1156
-     * @throws EE_Error
1157
-     * @throws InvalidArgumentException
1158
-     * @throws InvalidDataTypeException
1159
-     * @throws InvalidInterfaceException
1160
-     */
1161
-    protected function _registrations_overview_list_table()
1162
-    {
1163
-        $this->appendAddNewRegistrationButtonToPageTitle();
1164
-        $header_text                  = '';
1165
-        $admin_page_header_decorators = [
1166
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1167
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1168
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1169
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1170
-        ];
1171
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1172
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1173
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1174
-        }
1175
-        $this->_template_args['admin_page_header'] = $header_text;
1176
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1177
-        $this->display_admin_list_table_page_with_no_sidebar();
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * @throws EE_Error
1183
-     * @throws InvalidArgumentException
1184
-     * @throws InvalidDataTypeException
1185
-     * @throws InvalidInterfaceException
1186
-     */
1187
-    private function appendAddNewRegistrationButtonToPageTitle()
1188
-    {
1189
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1190
-        if (
1191
-            $EVT_ID
1192
-            && EE_Registry::instance()->CAP->current_user_can(
1193
-                'ee_edit_registrations',
1194
-                'espresso_registrations_new_registration',
1195
-                $EVT_ID
1196
-            )
1197
-        ) {
1198
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1199
-                'new_registration',
1200
-                'add-registrant',
1201
-                ['event_id' => $EVT_ID],
1202
-                'add-new-h2'
1203
-            );
1204
-        }
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     * This sets the _registration property for the registration details screen
1210
-     *
1211
-     * @return void
1212
-     * @throws EE_Error
1213
-     * @throws InvalidArgumentException
1214
-     * @throws InvalidDataTypeException
1215
-     * @throws InvalidInterfaceException
1216
-     */
1217
-    private function _set_registration_object()
1218
-    {
1219
-        // get out if we've already set the object
1220
-        if ($this->_registration instanceof EE_Registration) {
1221
-            return;
1222
-        }
1223
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1224
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1225
-            return;
1226
-        }
1227
-        $error_msg = sprintf(
1228
-            esc_html__(
1229
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1230
-                'event_espresso'
1231
-            ),
1232
-            $REG_ID
1233
-        );
1234
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1235
-        $this->_registration = null;
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * Used to retrieve registrations for the list table.
1241
-     *
1242
-     * @param int  $per_page
1243
-     * @param bool $count
1244
-     * @param bool $this_month
1245
-     * @param bool $today
1246
-     * @return EE_Registration[]|int
1247
-     * @throws EE_Error
1248
-     * @throws InvalidArgumentException
1249
-     * @throws InvalidDataTypeException
1250
-     * @throws InvalidInterfaceException
1251
-     */
1252
-    public function get_registrations(
1253
-        $per_page = 10,
1254
-        $count = false,
1255
-        $this_month = false,
1256
-        $today = false
1257
-    ) {
1258
-        if ($this_month) {
1259
-            $this->request->setRequestParam('status', 'month');
1260
-        }
1261
-        if ($today) {
1262
-            $this->request->setRequestParam('status', 'today');
1263
-        }
1264
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1265
-        /**
1266
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1267
-         *
1268
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1269
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1270
-         *                      or if you have the development copy of EE you can view this at the path:
1271
-         *                      /docs/G--Model-System/model-query-params.md
1272
-         */
1273
-        $query_params['group_by'] = '';
1274
-
1275
-        return $count
1276
-            ? $this->getRegistrationModel()->count($query_params)
1277
-            /** @type EE_Registration[] */
1278
-            : $this->getRegistrationModel()->get_all($query_params);
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1284
-     * Note: this listens to values on the request for some of the query parameters.
1285
-     *
1286
-     * @param array $request
1287
-     * @param int   $per_page
1288
-     * @param bool  $count
1289
-     * @return array
1290
-     * @throws EE_Error
1291
-     * @throws InvalidArgumentException
1292
-     * @throws InvalidDataTypeException
1293
-     * @throws InvalidInterfaceException
1294
-     */
1295
-    protected function _get_registration_query_parameters(
1296
-        $request = [],
1297
-        $per_page = 10,
1298
-        $count = false
1299
-    ) {
1300
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1301
-        $list_table_query_builder = $this->getLoader()->getNew(
1302
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1303
-            [null, null, $request]
1304
-        );
1305
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1306
-    }
1307
-
1308
-
1309
-    public function get_registration_status_array()
1310
-    {
1311
-        return self::$_reg_status;
1312
-    }
1313
-
1314
-
1315
-
1316
-
1317
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1318
-    /**
1319
-     * generates HTML for the View Registration Details Admin page
1320
-     *
1321
-     * @return void
1322
-     * @throws DomainException
1323
-     * @throws EE_Error
1324
-     * @throws InvalidArgumentException
1325
-     * @throws InvalidDataTypeException
1326
-     * @throws InvalidInterfaceException
1327
-     * @throws EntityNotFoundException
1328
-     * @throws ReflectionException
1329
-     */
1330
-    protected function _registration_details()
1331
-    {
1332
-        $this->_template_args = [];
1333
-        $this->_set_registration_object();
1334
-        if (is_object($this->_registration)) {
1335
-            $transaction                                   = $this->_registration->transaction()
1336
-                ? $this->_registration->transaction()
1337
-                : EE_Transaction::new_instance();
1338
-            $this->_session                                = $transaction->session_data();
1339
-            $event_id                                      = $this->_registration->event_ID();
1340
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1341
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1342
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1343
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1344
-            $this->_template_args['grand_total']           = $transaction->total();
1345
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1346
-            // link back to overview
1347
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1348
-            $this->_template_args['registration']                = $this->_registration;
1349
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350
-                [
1351
-                    'action'   => 'default',
1352
-                    'event_id' => $event_id,
1353
-                ],
1354
-                REG_ADMIN_URL
1355
-            );
1356
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1357
-                [
1358
-                    'action' => 'default',
1359
-                    'EVT_ID' => $event_id,
1360
-                    'page'   => 'espresso_transactions',
1361
-                ],
1362
-                admin_url('admin.php')
1363
-            );
1364
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1365
-                [
1366
-                    'page'   => 'espresso_events',
1367
-                    'action' => 'edit',
1368
-                    'post'   => $event_id,
1369
-                ],
1370
-                admin_url('admin.php')
1371
-            );
1372
-            // next and previous links
1373
-            $next_reg                                      = $this->_registration->next(
1374
-                null,
1375
-                [],
1376
-                'REG_ID'
1377
-            );
1378
-            $this->_template_args['next_registration']     = $next_reg
1379
-                ? $this->_next_link(
1380
-                    EE_Admin_Page::add_query_args_and_nonce(
1381
-                        [
1382
-                            'action'  => 'view_registration',
1383
-                            '_REG_ID' => $next_reg['REG_ID'],
1384
-                        ],
1385
-                        REG_ADMIN_URL
1386
-                    ),
1387
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1388
-                )
1389
-                : '';
1390
-            $previous_reg                                  = $this->_registration->previous(
1391
-                null,
1392
-                [],
1393
-                'REG_ID'
1394
-            );
1395
-            $this->_template_args['previous_registration'] = $previous_reg
1396
-                ? $this->_previous_link(
1397
-                    EE_Admin_Page::add_query_args_and_nonce(
1398
-                        [
1399
-                            'action'  => 'view_registration',
1400
-                            '_REG_ID' => $previous_reg['REG_ID'],
1401
-                        ],
1402
-                        REG_ADMIN_URL
1403
-                    ),
1404
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1405
-                )
1406
-                : '';
1407
-            // grab header
1408
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1409
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1410
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411
-                $template_path,
1412
-                $this->_template_args,
1413
-                true
1414
-            );
1415
-        } else {
1416
-            $this->_template_args['admin_page_header'] = '';
1417
-            $this->_display_espresso_notices();
1418
-        }
1419
-        // the details template wrapper
1420
-        $this->display_admin_page_with_sidebar();
1421
-    }
1422
-
1423
-
1424
-    /**
1425
-     * @throws EE_Error
1426
-     * @throws InvalidArgumentException
1427
-     * @throws InvalidDataTypeException
1428
-     * @throws InvalidInterfaceException
1429
-     * @throws ReflectionException
1430
-     * @since 4.10.2.p
1431
-     */
1432
-    protected function _registration_details_metaboxes()
1433
-    {
1434
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1435
-        $this->_set_registration_object();
1436
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1437
-        add_meta_box(
1438
-            'edit-reg-status-mbox',
1439
-            esc_html__('Registration Status', 'event_espresso'),
1440
-            [$this, 'set_reg_status_buttons_metabox'],
1441
-            $this->_wp_page_slug,
1442
-            'normal',
1443
-            'high'
1444
-        );
1445
-        add_meta_box(
1446
-            'edit-reg-details-mbox',
1447
-            esc_html__('Registration Details', 'event_espresso'),
1448
-            [$this, '_reg_details_meta_box'],
1449
-            $this->_wp_page_slug,
1450
-            'normal',
1451
-            'high'
1452
-        );
1453
-        if (
1454
-            $attendee instanceof EE_Attendee
1455
-            && EE_Registry::instance()->CAP->current_user_can(
1456
-                'ee_read_registration',
1457
-                'edit-reg-questions-mbox',
1458
-                $this->_registration->ID()
1459
-            )
1460
-        ) {
1461
-            add_meta_box(
1462
-                'edit-reg-questions-mbox',
1463
-                esc_html__('Registration Form Answers', 'event_espresso'),
1464
-                [$this, '_reg_questions_meta_box'],
1465
-                $this->_wp_page_slug,
1466
-                'normal',
1467
-                'high'
1468
-            );
1469
-        }
1470
-        add_meta_box(
1471
-            'edit-reg-registrant-mbox',
1472
-            esc_html__('Contact Details', 'event_espresso'),
1473
-            [$this, '_reg_registrant_side_meta_box'],
1474
-            $this->_wp_page_slug,
1475
-            'side',
1476
-            'high'
1477
-        );
1478
-        if ($this->_registration->group_size() > 1) {
1479
-            add_meta_box(
1480
-                'edit-reg-attendees-mbox',
1481
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1482
-                [$this, '_reg_attendees_meta_box'],
1483
-                $this->_wp_page_slug,
1484
-                'normal',
1485
-                'high'
1486
-            );
1487
-        }
1488
-    }
1489
-
1490
-
1491
-    /**
1492
-     * set_reg_status_buttons_metabox
1493
-     *
1494
-     * @return void
1495
-     * @throws EE_Error
1496
-     * @throws EntityNotFoundException
1497
-     * @throws InvalidArgumentException
1498
-     * @throws InvalidDataTypeException
1499
-     * @throws InvalidInterfaceException
1500
-     * @throws ReflectionException
1501
-     */
1502
-    public function set_reg_status_buttons_metabox()
1503
-    {
1504
-        $this->_set_registration_object();
1505
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1506
-        $output                 = $change_reg_status_form->form_open(
1507
-            self::add_query_args_and_nonce(
1508
-                [
1509
-                    'action' => 'change_reg_status',
1510
-                ],
1511
-                REG_ADMIN_URL
1512
-            )
1513
-        );
1514
-        $output                 .= $change_reg_status_form->get_html();
1515
-        $output                 .= $change_reg_status_form->form_close();
1516
-        echo $output; // already escaped
1517
-    }
1518
-
1519
-
1520
-    /**
1521
-     * @return EE_Form_Section_Proper
1522
-     * @throws EE_Error
1523
-     * @throws InvalidArgumentException
1524
-     * @throws InvalidDataTypeException
1525
-     * @throws InvalidInterfaceException
1526
-     * @throws EntityNotFoundException
1527
-     * @throws ReflectionException
1528
-     */
1529
-    protected function _generate_reg_status_change_form()
1530
-    {
1531
-        $reg_status_change_form_array = [
1532
-            'name'            => 'reg_status_change_form',
1533
-            'html_id'         => 'reg-status-change-form',
1534
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1535
-            'subsections'     => [
1536
-                'return'         => new EE_Hidden_Input(
1537
-                    [
1538
-                        'name'    => 'return',
1539
-                        'default' => 'view_registration',
1540
-                    ]
1541
-                ),
1542
-                'REG_ID'         => new EE_Hidden_Input(
1543
-                    [
1544
-                        'name'    => 'REG_ID',
1545
-                        'default' => $this->_registration->ID(),
1546
-                    ]
1547
-                ),
1548
-                'current_status' => new EE_Form_Section_HTML(
1549
-                    EEH_HTML::table(
1550
-                        EEH_HTML::tr(
1551
-                            EEH_HTML::th(
1552
-                                EEH_HTML::label(
1553
-                                    EEH_HTML::strong(
1554
-                                        esc_html__('Current Registration Status', 'event_espresso')
1555
-                                    )
1556
-                                )
1557
-                            )
1558
-                            . EEH_HTML::td(
1559
-                                EEH_HTML::strong(
1560
-                                    $this->_registration->pretty_status(),
1561
-                                    '',
1562
-                                    'status-' . $this->_registration->status_ID(),
1563
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564
-                                )
1565
-                            )
1566
-                        )
1567
-                    )
1568
-                ),
1569
-            ],
1570
-        ];
1571
-        if (
1572
-            EE_Registry::instance()->CAP->current_user_can(
1573
-                'ee_edit_registration',
1574
-                'toggle_registration_status',
1575
-                $this->_registration->ID()
1576
-            )
1577
-        ) {
1578
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1579
-                $this->_get_reg_statuses(),
1580
-                [
1581
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1582
-                    'default'         => $this->_registration->status_ID(),
1583
-                ]
1584
-            );
1585
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1586
-                [
1587
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1588
-                    'default'         => false,
1589
-                    'html_help_text'  => esc_html__(
1590
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1591
-                        'event_espresso'
1592
-                    ),
1593
-                ]
1594
-            );
1595
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1596
-                [
1597
-                    'html_class'      => 'button-primary',
1598
-                    'html_label_text' => '&nbsp;',
1599
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1600
-                ]
1601
-            );
1602
-        }
1603
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1604
-    }
1605
-
1606
-
1607
-    /**
1608
-     * Returns an array of all the buttons for the various statuses and switch status actions
1609
-     *
1610
-     * @return array
1611
-     * @throws EE_Error
1612
-     * @throws InvalidArgumentException
1613
-     * @throws InvalidDataTypeException
1614
-     * @throws InvalidInterfaceException
1615
-     * @throws EntityNotFoundException
1616
-     */
1617
-    protected function _get_reg_statuses()
1618
-    {
1619
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1621
-        // get current reg status
1622
-        $current_status = $this->_registration->status_ID();
1623
-        // is registration for free event? This will determine whether to display the pending payment option
1624
-        if (
1625
-            $current_status !== EEM_Registration::status_id_pending_payment
1626
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627
-        ) {
1628
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1629
-        }
1630
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631
-    }
1632
-
1633
-
1634
-    /**
1635
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1636
-     *
1637
-     * @param bool $status REG status given for changing registrations to.
1638
-     * @param bool $notify Whether to send messages notifications or not.
1639
-     * @return array (array with reg_id(s) updated and whether update was successful.
1640
-     * @throws DomainException
1641
-     * @throws EE_Error
1642
-     * @throws EntityNotFoundException
1643
-     * @throws InvalidArgumentException
1644
-     * @throws InvalidDataTypeException
1645
-     * @throws InvalidInterfaceException
1646
-     * @throws ReflectionException
1647
-     * @throws RuntimeException
1648
-     */
1649
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1650
-    {
1651
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1652
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1653
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1654
-
1655
-        // sanitize $REG_IDs
1656
-        $REG_IDs = array_map('absint', $REG_IDs);
1657
-        // and remove empty entries
1658
-        $REG_IDs = array_filter($REG_IDs);
1659
-
1660
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1661
-
1662
-        /**
1663
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1664
-         * Currently this value is used downstream by the _process_resend_registration method.
1665
-         *
1666
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1667
-         * @param bool                     $status           The status registrations were changed to.
1668
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1669
-         * @param Registrations_Admin_Page $admin_page_object
1670
-         */
1671
-        $REG_ID = apply_filters(
1672
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1673
-            $result['REG_ID'],
1674
-            $status,
1675
-            $result['success'],
1676
-            $this
1677
-        );
1678
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1679
-
1680
-        // notify?
1681
-        if (
1682
-            $notify
1683
-            && $result['success']
1684
-            && ! empty($REG_ID)
1685
-            && EE_Registry::instance()->CAP->current_user_can(
1686
-                'ee_send_message',
1687
-                'espresso_registrations_resend_registration'
1688
-            )
1689
-        ) {
1690
-            $this->_process_resend_registration();
1691
-        }
1692
-        return $result;
1693
-    }
1694
-
1695
-
1696
-    /**
1697
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1698
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1699
-     *
1700
-     * @param array  $REG_IDs
1701
-     * @param string $status
1702
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1703
-     *                       slug sent with setting the registration status.
1704
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1705
-     * @throws EE_Error
1706
-     * @throws InvalidArgumentException
1707
-     * @throws InvalidDataTypeException
1708
-     * @throws InvalidInterfaceException
1709
-     * @throws ReflectionException
1710
-     * @throws RuntimeException
1711
-     * @throws EntityNotFoundException
1712
-     * @throws DomainException
1713
-     */
1714
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1715
-    {
1716
-        $success = false;
1717
-        // typecast $REG_IDs
1718
-        $REG_IDs = (array) $REG_IDs;
1719
-        if (! empty($REG_IDs)) {
1720
-            $success = true;
1721
-            // set default status if none is passed
1722
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1723
-            $status_context = $notify
1724
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1725
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1726
-            // loop through REG_ID's and change status
1727
-            foreach ($REG_IDs as $REG_ID) {
1728
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1729
-                if ($registration instanceof EE_Registration) {
1730
-                    $registration->set_status(
1731
-                        $status,
1732
-                        false,
1733
-                        new Context(
1734
-                            $status_context,
1735
-                            esc_html__(
1736
-                                'Manually triggered status change on a Registration Admin Page route.',
1737
-                                'event_espresso'
1738
-                            )
1739
-                        )
1740
-                    );
1741
-                    $result = $registration->save();
1742
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1743
-                    $success = $result !== false ? $success : false;
1744
-                }
1745
-            }
1746
-        }
1747
-
1748
-        // return $success and processed registrations
1749
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1750
-    }
1751
-
1752
-
1753
-    /**
1754
-     * Common logic for setting up success message and redirecting to appropriate route
1755
-     *
1756
-     * @param string $STS_ID status id for the registration changed to
1757
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1758
-     * @return void
1759
-     * @throws DomainException
1760
-     * @throws EE_Error
1761
-     * @throws EntityNotFoundException
1762
-     * @throws InvalidArgumentException
1763
-     * @throws InvalidDataTypeException
1764
-     * @throws InvalidInterfaceException
1765
-     * @throws ReflectionException
1766
-     * @throws RuntimeException
1767
-     */
1768
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1769
-    {
1770
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1771
-            : ['success' => false];
1772
-        $success = isset($result['success']) && $result['success'];
1773
-        // setup success message
1774
-        if ($success) {
1775
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1776
-                $msg = sprintf(
1777
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1778
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
-                );
1780
-            } else {
1781
-                $msg = sprintf(
1782
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1783
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1784
-                );
1785
-            }
1786
-            EE_Error::add_success($msg);
1787
-        } else {
1788
-            EE_Error::add_error(
1789
-                esc_html__(
1790
-                    'Something went wrong, and the status was not changed',
1791
-                    'event_espresso'
1792
-                ),
1793
-                __FILE__,
1794
-                __LINE__,
1795
-                __FUNCTION__
1796
-            );
1797
-        }
1798
-        $return = $this->request->getRequestParam('return');
1799
-        $route  = $return === 'view_registration'
1800
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1801
-            : ['action' => 'default'];
1802
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1803
-        $this->_redirect_after_action($success, '', '', $route, true);
1804
-    }
1805
-
1806
-
1807
-    /**
1808
-     * incoming reg status change from reg details page.
1809
-     *
1810
-     * @return void
1811
-     * @throws EE_Error
1812
-     * @throws EntityNotFoundException
1813
-     * @throws InvalidArgumentException
1814
-     * @throws InvalidDataTypeException
1815
-     * @throws InvalidInterfaceException
1816
-     * @throws ReflectionException
1817
-     * @throws RuntimeException
1818
-     * @throws DomainException
1819
-     */
1820
-    protected function _change_reg_status()
1821
-    {
1822
-        $this->request->setRequestParam('return', 'view_registration');
1823
-        // set notify based on whether the send notifications toggle is set or not
1824
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1825
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1826
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1827
-        switch ($reg_status) {
1828
-            case EEM_Registration::status_id_approved:
1829
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1830
-                $this->approve_registration($notify);
1831
-                break;
1832
-            case EEM_Registration::status_id_pending_payment:
1833
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1834
-                $this->pending_registration($notify);
1835
-                break;
1836
-            case EEM_Registration::status_id_not_approved:
1837
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1838
-                $this->not_approve_registration($notify);
1839
-                break;
1840
-            case EEM_Registration::status_id_declined:
1841
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1842
-                $this->decline_registration($notify);
1843
-                break;
1844
-            case EEM_Registration::status_id_cancelled:
1845
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1846
-                $this->cancel_registration($notify);
1847
-                break;
1848
-            case EEM_Registration::status_id_wait_list:
1849
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1850
-                $this->wait_list_registration($notify);
1851
-                break;
1852
-            case EEM_Registration::status_id_incomplete:
1853
-            default:
1854
-                $this->request->unSetRequestParam('return');
1855
-                $this->_reg_status_change_return('');
1856
-                break;
1857
-        }
1858
-    }
1859
-
1860
-
1861
-    /**
1862
-     * Callback for bulk action routes.
1863
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1864
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1865
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1866
-     * when an action is happening on just a single registration).
1867
-     *
1868
-     * @param      $action
1869
-     * @param bool $notify
1870
-     */
1871
-    protected function bulk_action_on_registrations($action, $notify = false)
1872
-    {
1873
-        do_action(
1874
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1875
-            $this,
1876
-            $action,
1877
-            $notify
1878
-        );
1879
-        $method = $action . '_registration';
1880
-        if (method_exists($this, $method)) {
1881
-            $this->$method($notify);
1882
-        }
1883
-    }
1884
-
1885
-
1886
-    /**
1887
-     * approve_registration
1888
-     *
1889
-     * @param bool $notify whether or not to notify the registrant about their approval.
1890
-     * @return void
1891
-     * @throws EE_Error
1892
-     * @throws EntityNotFoundException
1893
-     * @throws InvalidArgumentException
1894
-     * @throws InvalidDataTypeException
1895
-     * @throws InvalidInterfaceException
1896
-     * @throws ReflectionException
1897
-     * @throws RuntimeException
1898
-     * @throws DomainException
1899
-     */
1900
-    protected function approve_registration($notify = false)
1901
-    {
1902
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1903
-    }
1904
-
1905
-
1906
-    /**
1907
-     * decline_registration
1908
-     *
1909
-     * @param bool $notify whether or not to notify the registrant about their status change.
1910
-     * @return void
1911
-     * @throws EE_Error
1912
-     * @throws EntityNotFoundException
1913
-     * @throws InvalidArgumentException
1914
-     * @throws InvalidDataTypeException
1915
-     * @throws InvalidInterfaceException
1916
-     * @throws ReflectionException
1917
-     * @throws RuntimeException
1918
-     * @throws DomainException
1919
-     */
1920
-    protected function decline_registration($notify = false)
1921
-    {
1922
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1923
-    }
1924
-
1925
-
1926
-    /**
1927
-     * cancel_registration
1928
-     *
1929
-     * @param bool $notify whether or not to notify the registrant about their status change.
1930
-     * @return void
1931
-     * @throws EE_Error
1932
-     * @throws EntityNotFoundException
1933
-     * @throws InvalidArgumentException
1934
-     * @throws InvalidDataTypeException
1935
-     * @throws InvalidInterfaceException
1936
-     * @throws ReflectionException
1937
-     * @throws RuntimeException
1938
-     * @throws DomainException
1939
-     */
1940
-    protected function cancel_registration($notify = false)
1941
-    {
1942
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1943
-    }
1944
-
1945
-
1946
-    /**
1947
-     * not_approve_registration
1948
-     *
1949
-     * @param bool $notify whether or not to notify the registrant about their status change.
1950
-     * @return void
1951
-     * @throws EE_Error
1952
-     * @throws EntityNotFoundException
1953
-     * @throws InvalidArgumentException
1954
-     * @throws InvalidDataTypeException
1955
-     * @throws InvalidInterfaceException
1956
-     * @throws ReflectionException
1957
-     * @throws RuntimeException
1958
-     * @throws DomainException
1959
-     */
1960
-    protected function not_approve_registration($notify = false)
1961
-    {
1962
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1963
-    }
1964
-
1965
-
1966
-    /**
1967
-     * decline_registration
1968
-     *
1969
-     * @param bool $notify whether or not to notify the registrant about their status change.
1970
-     * @return void
1971
-     * @throws EE_Error
1972
-     * @throws EntityNotFoundException
1973
-     * @throws InvalidArgumentException
1974
-     * @throws InvalidDataTypeException
1975
-     * @throws InvalidInterfaceException
1976
-     * @throws ReflectionException
1977
-     * @throws RuntimeException
1978
-     * @throws DomainException
1979
-     */
1980
-    protected function pending_registration($notify = false)
1981
-    {
1982
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1983
-    }
1984
-
1985
-
1986
-    /**
1987
-     * waitlist_registration
1988
-     *
1989
-     * @param bool $notify whether or not to notify the registrant about their status change.
1990
-     * @return void
1991
-     * @throws EE_Error
1992
-     * @throws EntityNotFoundException
1993
-     * @throws InvalidArgumentException
1994
-     * @throws InvalidDataTypeException
1995
-     * @throws InvalidInterfaceException
1996
-     * @throws ReflectionException
1997
-     * @throws RuntimeException
1998
-     * @throws DomainException
1999
-     */
2000
-    protected function wait_list_registration($notify = false)
2001
-    {
2002
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2003
-    }
2004
-
2005
-
2006
-    /**
2007
-     * generates HTML for the Registration main meta box
2008
-     *
2009
-     * @return void
2010
-     * @throws DomainException
2011
-     * @throws EE_Error
2012
-     * @throws InvalidArgumentException
2013
-     * @throws InvalidDataTypeException
2014
-     * @throws InvalidInterfaceException
2015
-     * @throws ReflectionException
2016
-     * @throws EntityNotFoundException
2017
-     */
2018
-    public function _reg_details_meta_box()
2019
-    {
2020
-        EEH_Autoloader::register_line_item_display_autoloaders();
2021
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2022
-        EE_Registry::instance()->load_helper('Line_Item');
2023
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2024
-            : EE_Transaction::new_instance();
2025
-        $this->_session = $transaction->session_data();
2026
-        $filters        = new EE_Line_Item_Filter_Collection();
2027
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2030
-            $filters,
2031
-            $transaction->total_line_item()
2032
-        );
2033
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2034
-        $line_item_display                       = new EE_Line_Item_Display(
2035
-            'reg_admin_table',
2036
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2037
-        );
2038
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2039
-            $filtered_line_item_tree,
2040
-            ['EE_Registration' => $this->_registration]
2041
-        );
2042
-        $attendee                                = $this->_registration->attendee();
2043
-        if (
2044
-            EE_Registry::instance()->CAP->current_user_can(
2045
-                'ee_read_transaction',
2046
-                'espresso_transactions_view_transaction'
2047
-            )
2048
-        ) {
2049
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2050
-                EE_Admin_Page::add_query_args_and_nonce(
2051
-                    [
2052
-                        'action' => 'view_transaction',
2053
-                        'TXN_ID' => $transaction->ID(),
2054
-                    ],
2055
-                    TXN_ADMIN_URL
2056
-                ),
2057
-                esc_html__(' View Transaction', 'event_espresso'),
2058
-                'button secondary-button right',
2059
-                'dashicons dashicons-cart'
2060
-            );
2061
-        } else {
2062
-            $this->_template_args['view_transaction_button'] = '';
2063
-        }
2064
-        if (
2065
-            $attendee instanceof EE_Attendee
2066
-            && EE_Registry::instance()->CAP->current_user_can(
2067
-                'ee_send_message',
2068
-                'espresso_registrations_resend_registration'
2069
-            )
2070
-        ) {
2071
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2072
-                EE_Admin_Page::add_query_args_and_nonce(
2073
-                    [
2074
-                        'action'      => 'resend_registration',
2075
-                        '_REG_ID'     => $this->_registration->ID(),
2076
-                        'redirect_to' => 'view_registration',
2077
-                    ],
2078
-                    REG_ADMIN_URL
2079
-                ),
2080
-                esc_html__(' Resend Registration', 'event_espresso'),
2081
-                'button secondary-button right',
2082
-                'dashicons dashicons-email-alt'
2083
-            );
2084
-        } else {
2085
-            $this->_template_args['resend_registration_button'] = '';
2086
-        }
2087
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2088
-        $payment                               = $transaction->get_first_related('Payment');
2089
-        $payment                               = ! $payment instanceof EE_Payment
2090
-            ? EE_Payment::new_instance()
2091
-            : $payment;
2092
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2093
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2094
-            ? EE_Payment_Method::new_instance()
2095
-            : $payment_method;
2096
-        $reg_details                           = [
2097
-            'payment_method'       => $payment_method->name(),
2098
-            'response_msg'         => $payment->gateway_response(),
2099
-            'registration_id'      => $this->_registration->get('REG_code'),
2100
-            'registration_session' => $this->_registration->session_ID(),
2101
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2102
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2103
-        ];
2104
-        if (isset($reg_details['registration_id'])) {
2105
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2106
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2107
-                'Registration ID',
2108
-                'event_espresso'
2109
-            );
2110
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2111
-        }
2112
-        if (isset($reg_details['payment_method'])) {
2113
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2114
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2115
-                'Most Recent Payment Method',
2116
-                'event_espresso'
2117
-            );
2118
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2119
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2120
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2121
-                'Payment method response',
2122
-                'event_espresso'
2123
-            );
2124
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2125
-        }
2126
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2128
-            'Registration Session',
2129
-            'event_espresso'
2130
-        );
2131
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2132
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2133
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2134
-            'Registration placed from IP',
2135
-            'event_espresso'
2136
-        );
2137
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2138
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2139
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2140
-            'Registrant User Agent',
2141
-            'event_espresso'
2142
-        );
2143
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2144
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2145
-            [
2146
-                'action'   => 'default',
2147
-                'event_id' => $this->_registration->event_ID(),
2148
-            ],
2149
-            REG_ADMIN_URL
2150
-        );
2151
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153
-        $template_path                                                        =
2154
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2155
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156
-    }
2157
-
2158
-
2159
-    /**
2160
-     * generates HTML for the Registration Questions meta box.
2161
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2162
-     * otherwise uses new forms system
2163
-     *
2164
-     * @return void
2165
-     * @throws DomainException
2166
-     * @throws EE_Error
2167
-     * @throws InvalidArgumentException
2168
-     * @throws InvalidDataTypeException
2169
-     * @throws InvalidInterfaceException
2170
-     * @throws ReflectionException
2171
-     */
2172
-    public function _reg_questions_meta_box()
2173
-    {
2174
-        // allow someone to override this method entirely
2175
-        if (
2176
-            apply_filters(
2177
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2178
-                true,
2179
-                $this,
2180
-                $this->_registration
2181
-            )
2182
-        ) {
2183
-            $form                                              = $this->_get_reg_custom_questions_form(
2184
-                $this->_registration->ID()
2185
-            );
2186
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2187
-                ? $form->get_html_and_js()
2188
-                : '';
2189
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2191
-            $template_path                                     =
2192
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2193
-            EEH_Template::display_template($template_path, $this->_template_args);
2194
-        }
2195
-    }
2196
-
2197
-
2198
-    /**
2199
-     * form_before_question_group
2200
-     *
2201
-     * @param string $output
2202
-     * @return        string
2203
-     * @deprecated    as of 4.8.32.rc.000
2204
-     */
2205
-    public function form_before_question_group($output)
2206
-    {
2207
-        EE_Error::doing_it_wrong(
2208
-            __CLASS__ . '::' . __FUNCTION__,
2209
-            esc_html__(
2210
-                '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.',
2211
-                'event_espresso'
2212
-            ),
2213
-            '4.8.32.rc.000'
2214
-        );
2215
-        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 = null;
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->getLoader()->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->getLoader()->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->getLoader()->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->getLoader()->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
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
573
+				// 'help_tour'     => array('Registration_Overview_Help_Tour'),
574
+				'qtips'         => ['Registration_List_Table_Tips'],
575
+				'list_table'    => 'EE_Registrations_List_Table',
576
+				'require_nonce' => false,
577
+			],
578
+			'view_registration' => [
579
+				'nav'           => [
580
+					'label'      => esc_html__('REG Details', 'event_espresso'),
581
+					'order'      => 15,
582
+					'url'        => $REG_ID
583
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
584
+						: $this->_admin_base_url,
585
+					'persistent' => false,
586
+				],
587
+				'help_tabs'     => [
588
+					'registrations_details_help_tab'                    => [
589
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
590
+						'filename' => 'registrations_details',
591
+					],
592
+					'registrations_details_table_help_tab'              => [
593
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
594
+						'filename' => 'registrations_details_table',
595
+					],
596
+					'registrations_details_form_answers_help_tab'       => [
597
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
598
+						'filename' => 'registrations_details_form_answers',
599
+					],
600
+					'registrations_details_registrant_details_help_tab' => [
601
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
602
+						'filename' => 'registrations_details_registrant_details',
603
+					],
604
+				],
605
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
606
+				// 'help_tour'     => array('Registration_Details_Help_Tour'),
607
+				'metaboxes'     => array_merge(
608
+					$this->_default_espresso_metaboxes,
609
+					['_registration_details_metaboxes']
610
+				),
611
+				'require_nonce' => false,
612
+			],
613
+			'new_registration'  => [
614
+				'nav'           => [
615
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
616
+					'url'        => '#',
617
+					'order'      => 15,
618
+					'persistent' => false,
619
+				],
620
+				'metaboxes'     => $this->_default_espresso_metaboxes,
621
+				'labels'        => [
622
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
623
+				],
624
+				'require_nonce' => false,
625
+			],
626
+			'add_new_attendee'  => [
627
+				'nav'           => [
628
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
629
+					'order'      => 15,
630
+					'persistent' => false,
631
+				],
632
+				'metaboxes'     => array_merge(
633
+					$this->_default_espresso_metaboxes,
634
+					['_publish_post_box', 'attendee_editor_metaboxes']
635
+				),
636
+				'require_nonce' => false,
637
+			],
638
+			'edit_attendee'     => [
639
+				'nav'           => [
640
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
641
+					'order'      => 15,
642
+					'persistent' => false,
643
+					'url'        => $ATT_ID
644
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
645
+						: $this->_admin_base_url,
646
+				],
647
+				'metaboxes'     => ['attendee_editor_metaboxes'],
648
+				'require_nonce' => false,
649
+			],
650
+			'contact_list'      => [
651
+				'nav'           => [
652
+					'label' => esc_html__('Contact List', 'event_espresso'),
653
+					'order' => 20,
654
+				],
655
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
656
+				'help_tabs'     => [
657
+					'registrations_contact_list_help_tab'                       => [
658
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
659
+						'filename' => 'registrations_contact_list',
660
+					],
661
+					'registrations_contact-list_table_column_headings_help_tab' => [
662
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
663
+						'filename' => 'registrations_contact_list_table_column_headings',
664
+					],
665
+					'registrations_contact_list_views_help_tab'                 => [
666
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
667
+						'filename' => 'registrations_contact_list_views',
668
+					],
669
+					'registrations_contact_list_other_help_tab'                 => [
670
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
671
+						'filename' => 'registrations_contact_list_other',
672
+					],
673
+				],
674
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
675
+				// 'help_tour'     => array('Contact_List_Help_Tour'),
676
+				'metaboxes'     => [],
677
+				'require_nonce' => false,
678
+			],
679
+			// override default cpt routes
680
+			'create_new'        => '',
681
+			'edit'              => '',
682
+		];
683
+	}
684
+
685
+
686
+	/**
687
+	 * The below methods aren't used by this class currently
688
+	 */
689
+	protected function _add_screen_options()
690
+	{
691
+	}
692
+
693
+
694
+	protected function _add_feature_pointers()
695
+	{
696
+	}
697
+
698
+
699
+	public function admin_init()
700
+	{
701
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
702
+			'click "Update Registration Questions" to save your changes',
703
+			'event_espresso'
704
+		);
705
+	}
706
+
707
+
708
+	public function admin_notices()
709
+	{
710
+	}
711
+
712
+
713
+	public function admin_footer_scripts()
714
+	{
715
+	}
716
+
717
+
718
+	/**
719
+	 * get list of registration statuses
720
+	 *
721
+	 * @return void
722
+	 * @throws EE_Error
723
+	 */
724
+	private function _get_registration_status_array()
725
+	{
726
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
727
+	}
728
+
729
+
730
+	/**
731
+	 * @throws InvalidArgumentException
732
+	 * @throws InvalidDataTypeException
733
+	 * @throws InvalidInterfaceException
734
+	 * @since 4.10.2.p
735
+	 */
736
+	protected function _add_screen_options_default()
737
+	{
738
+		$this->_per_page_screen_option();
739
+	}
740
+
741
+
742
+	/**
743
+	 * @throws InvalidArgumentException
744
+	 * @throws InvalidDataTypeException
745
+	 * @throws InvalidInterfaceException
746
+	 * @since 4.10.2.p
747
+	 */
748
+	protected function _add_screen_options_contact_list()
749
+	{
750
+		$page_title              = $this->_admin_page_title;
751
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
752
+		$this->_per_page_screen_option();
753
+		$this->_admin_page_title = $page_title;
754
+	}
755
+
756
+
757
+	public function load_scripts_styles()
758
+	{
759
+		// style
760
+		wp_register_style(
761
+			'espresso_reg',
762
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
763
+			['ee-admin-css'],
764
+			EVENT_ESPRESSO_VERSION
765
+		);
766
+		wp_enqueue_style('espresso_reg');
767
+		// script
768
+		wp_register_script(
769
+			'espresso_reg',
770
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
771
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772
+			EVENT_ESPRESSO_VERSION,
773
+			true
774
+		);
775
+		wp_enqueue_script('espresso_reg');
776
+	}
777
+
778
+
779
+	/**
780
+	 * @throws EE_Error
781
+	 * @throws InvalidArgumentException
782
+	 * @throws InvalidDataTypeException
783
+	 * @throws InvalidInterfaceException
784
+	 * @throws ReflectionException
785
+	 * @since 4.10.2.p
786
+	 */
787
+	public function load_scripts_styles_edit_attendee()
788
+	{
789
+		// stuff to only show up on our attendee edit details page.
790
+		$attendee_details_translations = [
791
+			'att_publish_text' => sprintf(
792
+			/* translators: The date and time */
793
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
795
+			),
796
+		];
797
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
798
+		wp_enqueue_script('jquery-validate');
799
+	}
800
+
801
+
802
+	/**
803
+	 * @throws EE_Error
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws ReflectionException
808
+	 * @since 4.10.2.p
809
+	 */
810
+	public function load_scripts_styles_view_registration()
811
+	{
812
+		// styles
813
+		wp_enqueue_style('espresso-ui-theme');
814
+		// scripts
815
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
816
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
817
+	}
818
+
819
+
820
+	public function load_scripts_styles_contact_list()
821
+	{
822
+		wp_dequeue_style('espresso_reg');
823
+		wp_register_style(
824
+			'espresso_att',
825
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
826
+			['ee-admin-css'],
827
+			EVENT_ESPRESSO_VERSION
828
+		);
829
+		wp_enqueue_style('espresso_att');
830
+	}
831
+
832
+
833
+	public function load_scripts_styles_new_registration()
834
+	{
835
+		wp_register_script(
836
+			'ee-spco-for-admin',
837
+			REG_ASSETS_URL . 'spco_for_admin.js',
838
+			['underscore', 'jquery'],
839
+			EVENT_ESPRESSO_VERSION,
840
+			true
841
+		);
842
+		wp_enqueue_script('ee-spco-for-admin');
843
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
844
+		EE_Form_Section_Proper::wp_enqueue_scripts();
845
+		EED_Ticket_Selector::load_tckt_slctr_assets();
846
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
847
+	}
848
+
849
+
850
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
851
+	{
852
+		add_filter('FHEE_load_EE_messages', '__return_true');
853
+	}
854
+
855
+
856
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
857
+	{
858
+		add_filter('FHEE_load_EE_messages', '__return_true');
859
+	}
860
+
861
+
862
+	/**
863
+	 * @throws EE_Error
864
+	 * @throws InvalidArgumentException
865
+	 * @throws InvalidDataTypeException
866
+	 * @throws InvalidInterfaceException
867
+	 * @throws ReflectionException
868
+	 * @since 4.10.2.p
869
+	 */
870
+	protected function _set_list_table_views_default()
871
+	{
872
+		// for notification related bulk actions we need to make sure only active messengers have an option.
873
+		EED_Messages::set_autoloaders();
874
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
875
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
876
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
877
+		// key= bulk_action_slug, value= message type.
878
+		$match_array = [
879
+			'approve_registrations'    => 'registration',
880
+			'decline_registrations'    => 'declined_registration',
881
+			'pending_registrations'    => 'pending_approval',
882
+			'no_approve_registrations' => 'not_approved_registration',
883
+			'cancel_registrations'     => 'cancelled_registration',
884
+		];
885
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
886
+			'ee_send_message',
887
+			'batch_send_messages'
888
+		);
889
+		/** setup reg status bulk actions **/
890
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
891
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
892
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
893
+				'Approve and Notify Registrations',
894
+				'event_espresso'
895
+			);
896
+		}
897
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
898
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
899
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
900
+				'Decline and Notify Registrations',
901
+				'event_espresso'
902
+			);
903
+		}
904
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
905
+			'Set Registrations to Pending Payment',
906
+			'event_espresso'
907
+		);
908
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
909
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
910
+				'Set Registrations to Pending Payment and Notify',
911
+				'event_espresso'
912
+			);
913
+		}
914
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
915
+			'Set Registrations to Not Approved',
916
+			'event_espresso'
917
+		);
918
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
919
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
920
+				'Set Registrations to Not Approved and Notify',
921
+				'event_espresso'
922
+			);
923
+		}
924
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
925
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
926
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
927
+				'Cancel Registrations and Notify',
928
+				'event_espresso'
929
+			);
930
+		}
931
+		$def_reg_status_actions = apply_filters(
932
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
933
+			$def_reg_status_actions,
934
+			$active_mts,
935
+			$can_send
936
+		);
937
+
938
+		$this->_views = [
939
+			'all'   => [
940
+				'slug'        => 'all',
941
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
942
+				'count'       => 0,
943
+				'bulk_action' => array_merge(
944
+					$def_reg_status_actions,
945
+					[
946
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
947
+					]
948
+				),
949
+			],
950
+			'month' => [
951
+				'slug'        => 'month',
952
+				'label'       => esc_html__('This Month', 'event_espresso'),
953
+				'count'       => 0,
954
+				'bulk_action' => array_merge(
955
+					$def_reg_status_actions,
956
+					[
957
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
958
+					]
959
+				),
960
+			],
961
+			'today' => [
962
+				'slug'        => 'today',
963
+				'label'       => sprintf(
964
+					esc_html__('Today - %s', 'event_espresso'),
965
+					date('M d, Y', current_time('timestamp'))
966
+				),
967
+				'count'       => 0,
968
+				'bulk_action' => array_merge(
969
+					$def_reg_status_actions,
970
+					[
971
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
972
+					]
973
+				),
974
+			],
975
+		];
976
+		if (
977
+			EE_Registry::instance()->CAP->current_user_can(
978
+				'ee_delete_registrations',
979
+				'espresso_registrations_delete_registration'
980
+			)
981
+		) {
982
+			$this->_views['incomplete'] = [
983
+				'slug'        => 'incomplete',
984
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
985
+				'count'       => 0,
986
+				'bulk_action' => [
987
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988
+				],
989
+			];
990
+			$this->_views['trash']      = [
991
+				'slug'        => 'trash',
992
+				'label'       => esc_html__('Trash', 'event_espresso'),
993
+				'count'       => 0,
994
+				'bulk_action' => [
995
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
996
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
997
+				],
998
+			];
999
+		}
1000
+	}
1001
+
1002
+
1003
+	protected function _set_list_table_views_contact_list()
1004
+	{
1005
+		$this->_views = [
1006
+			'in_use' => [
1007
+				'slug'        => 'in_use',
1008
+				'label'       => esc_html__('In Use', 'event_espresso'),
1009
+				'count'       => 0,
1010
+				'bulk_action' => [
1011
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1012
+				],
1013
+			],
1014
+		];
1015
+		if (
1016
+			EE_Registry::instance()->CAP->current_user_can(
1017
+				'ee_delete_contacts',
1018
+				'espresso_registrations_trash_attendees'
1019
+			)
1020
+		) {
1021
+			$this->_views['trash'] = [
1022
+				'slug'        => 'trash',
1023
+				'label'       => esc_html__('Trash', 'event_espresso'),
1024
+				'count'       => 0,
1025
+				'bulk_action' => [
1026
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1027
+				],
1028
+			];
1029
+		}
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return array
1035
+	 * @throws EE_Error
1036
+	 */
1037
+	protected function _registration_legend_items()
1038
+	{
1039
+		$fc_items = [
1040
+			'star-icon'        => [
1041
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1042
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1043
+			],
1044
+			'view_details'     => [
1045
+				'class' => 'dashicons dashicons-clipboard',
1046
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1047
+			],
1048
+			'edit_attendee'    => [
1049
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1050
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1051
+			],
1052
+			'view_transaction' => [
1053
+				'class' => 'dashicons dashicons-cart',
1054
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1055
+			],
1056
+			'view_invoice'     => [
1057
+				'class' => 'dashicons dashicons-media-spreadsheet',
1058
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1059
+			],
1060
+		];
1061
+		if (
1062
+			EE_Registry::instance()->CAP->current_user_can(
1063
+				'ee_send_message',
1064
+				'espresso_registrations_resend_registration'
1065
+			)
1066
+		) {
1067
+			$fc_items['resend_registration'] = [
1068
+				'class' => 'dashicons dashicons-email-alt',
1069
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1070
+			];
1071
+		} else {
1072
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1073
+		}
1074
+		if (
1075
+			EE_Registry::instance()->CAP->current_user_can(
1076
+				'ee_read_global_messages',
1077
+				'view_filtered_messages'
1078
+			)
1079
+		) {
1080
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1081
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1082
+				$fc_items['view_related_messages'] = [
1083
+					'class' => $related_for_icon['css_class'],
1084
+					'desc'  => $related_for_icon['label'],
1085
+				];
1086
+			}
1087
+		}
1088
+		$sc_items = [
1089
+			'approved_status'   => [
1090
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1091
+				'desc'  => EEH_Template::pretty_status(
1092
+					EEM_Registration::status_id_approved,
1093
+					false,
1094
+					'sentence'
1095
+				),
1096
+			],
1097
+			'pending_status'    => [
1098
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1099
+				'desc'  => EEH_Template::pretty_status(
1100
+					EEM_Registration::status_id_pending_payment,
1101
+					false,
1102
+					'sentence'
1103
+				),
1104
+			],
1105
+			'wait_list'         => [
1106
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1107
+				'desc'  => EEH_Template::pretty_status(
1108
+					EEM_Registration::status_id_wait_list,
1109
+					false,
1110
+					'sentence'
1111
+				),
1112
+			],
1113
+			'incomplete_status' => [
1114
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1115
+				'desc'  => EEH_Template::pretty_status(
1116
+					EEM_Registration::status_id_incomplete,
1117
+					false,
1118
+					'sentence'
1119
+				),
1120
+			],
1121
+			'not_approved'      => [
1122
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1123
+				'desc'  => EEH_Template::pretty_status(
1124
+					EEM_Registration::status_id_not_approved,
1125
+					false,
1126
+					'sentence'
1127
+				),
1128
+			],
1129
+			'declined_status'   => [
1130
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1131
+				'desc'  => EEH_Template::pretty_status(
1132
+					EEM_Registration::status_id_declined,
1133
+					false,
1134
+					'sentence'
1135
+				),
1136
+			],
1137
+			'cancelled_status'  => [
1138
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1139
+				'desc'  => EEH_Template::pretty_status(
1140
+					EEM_Registration::status_id_cancelled,
1141
+					false,
1142
+					'sentence'
1143
+				),
1144
+			],
1145
+		];
1146
+		return array_merge($fc_items, $sc_items);
1147
+	}
1148
+
1149
+
1150
+
1151
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1152
+
1153
+
1154
+	/**
1155
+	 * @throws DomainException
1156
+	 * @throws EE_Error
1157
+	 * @throws InvalidArgumentException
1158
+	 * @throws InvalidDataTypeException
1159
+	 * @throws InvalidInterfaceException
1160
+	 */
1161
+	protected function _registrations_overview_list_table()
1162
+	{
1163
+		$this->appendAddNewRegistrationButtonToPageTitle();
1164
+		$header_text                  = '';
1165
+		$admin_page_header_decorators = [
1166
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1167
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1168
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1169
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1170
+		];
1171
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1172
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1173
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1174
+		}
1175
+		$this->_template_args['admin_page_header'] = $header_text;
1176
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1177
+		$this->display_admin_list_table_page_with_no_sidebar();
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * @throws EE_Error
1183
+	 * @throws InvalidArgumentException
1184
+	 * @throws InvalidDataTypeException
1185
+	 * @throws InvalidInterfaceException
1186
+	 */
1187
+	private function appendAddNewRegistrationButtonToPageTitle()
1188
+	{
1189
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1190
+		if (
1191
+			$EVT_ID
1192
+			&& EE_Registry::instance()->CAP->current_user_can(
1193
+				'ee_edit_registrations',
1194
+				'espresso_registrations_new_registration',
1195
+				$EVT_ID
1196
+			)
1197
+		) {
1198
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1199
+				'new_registration',
1200
+				'add-registrant',
1201
+				['event_id' => $EVT_ID],
1202
+				'add-new-h2'
1203
+			);
1204
+		}
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 * This sets the _registration property for the registration details screen
1210
+	 *
1211
+	 * @return void
1212
+	 * @throws EE_Error
1213
+	 * @throws InvalidArgumentException
1214
+	 * @throws InvalidDataTypeException
1215
+	 * @throws InvalidInterfaceException
1216
+	 */
1217
+	private function _set_registration_object()
1218
+	{
1219
+		// get out if we've already set the object
1220
+		if ($this->_registration instanceof EE_Registration) {
1221
+			return;
1222
+		}
1223
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1224
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1225
+			return;
1226
+		}
1227
+		$error_msg = sprintf(
1228
+			esc_html__(
1229
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1230
+				'event_espresso'
1231
+			),
1232
+			$REG_ID
1233
+		);
1234
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1235
+		$this->_registration = null;
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * Used to retrieve registrations for the list table.
1241
+	 *
1242
+	 * @param int  $per_page
1243
+	 * @param bool $count
1244
+	 * @param bool $this_month
1245
+	 * @param bool $today
1246
+	 * @return EE_Registration[]|int
1247
+	 * @throws EE_Error
1248
+	 * @throws InvalidArgumentException
1249
+	 * @throws InvalidDataTypeException
1250
+	 * @throws InvalidInterfaceException
1251
+	 */
1252
+	public function get_registrations(
1253
+		$per_page = 10,
1254
+		$count = false,
1255
+		$this_month = false,
1256
+		$today = false
1257
+	) {
1258
+		if ($this_month) {
1259
+			$this->request->setRequestParam('status', 'month');
1260
+		}
1261
+		if ($today) {
1262
+			$this->request->setRequestParam('status', 'today');
1263
+		}
1264
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1265
+		/**
1266
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1267
+		 *
1268
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1269
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1270
+		 *                      or if you have the development copy of EE you can view this at the path:
1271
+		 *                      /docs/G--Model-System/model-query-params.md
1272
+		 */
1273
+		$query_params['group_by'] = '';
1274
+
1275
+		return $count
1276
+			? $this->getRegistrationModel()->count($query_params)
1277
+			/** @type EE_Registration[] */
1278
+			: $this->getRegistrationModel()->get_all($query_params);
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1284
+	 * Note: this listens to values on the request for some of the query parameters.
1285
+	 *
1286
+	 * @param array $request
1287
+	 * @param int   $per_page
1288
+	 * @param bool  $count
1289
+	 * @return array
1290
+	 * @throws EE_Error
1291
+	 * @throws InvalidArgumentException
1292
+	 * @throws InvalidDataTypeException
1293
+	 * @throws InvalidInterfaceException
1294
+	 */
1295
+	protected function _get_registration_query_parameters(
1296
+		$request = [],
1297
+		$per_page = 10,
1298
+		$count = false
1299
+	) {
1300
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1301
+		$list_table_query_builder = $this->getLoader()->getNew(
1302
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1303
+			[null, null, $request]
1304
+		);
1305
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1306
+	}
1307
+
1308
+
1309
+	public function get_registration_status_array()
1310
+	{
1311
+		return self::$_reg_status;
1312
+	}
1313
+
1314
+
1315
+
1316
+
1317
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1318
+	/**
1319
+	 * generates HTML for the View Registration Details Admin page
1320
+	 *
1321
+	 * @return void
1322
+	 * @throws DomainException
1323
+	 * @throws EE_Error
1324
+	 * @throws InvalidArgumentException
1325
+	 * @throws InvalidDataTypeException
1326
+	 * @throws InvalidInterfaceException
1327
+	 * @throws EntityNotFoundException
1328
+	 * @throws ReflectionException
1329
+	 */
1330
+	protected function _registration_details()
1331
+	{
1332
+		$this->_template_args = [];
1333
+		$this->_set_registration_object();
1334
+		if (is_object($this->_registration)) {
1335
+			$transaction                                   = $this->_registration->transaction()
1336
+				? $this->_registration->transaction()
1337
+				: EE_Transaction::new_instance();
1338
+			$this->_session                                = $transaction->session_data();
1339
+			$event_id                                      = $this->_registration->event_ID();
1340
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1341
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1342
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1343
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1344
+			$this->_template_args['grand_total']           = $transaction->total();
1345
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1346
+			// link back to overview
1347
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1348
+			$this->_template_args['registration']                = $this->_registration;
1349
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350
+				[
1351
+					'action'   => 'default',
1352
+					'event_id' => $event_id,
1353
+				],
1354
+				REG_ADMIN_URL
1355
+			);
1356
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1357
+				[
1358
+					'action' => 'default',
1359
+					'EVT_ID' => $event_id,
1360
+					'page'   => 'espresso_transactions',
1361
+				],
1362
+				admin_url('admin.php')
1363
+			);
1364
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1365
+				[
1366
+					'page'   => 'espresso_events',
1367
+					'action' => 'edit',
1368
+					'post'   => $event_id,
1369
+				],
1370
+				admin_url('admin.php')
1371
+			);
1372
+			// next and previous links
1373
+			$next_reg                                      = $this->_registration->next(
1374
+				null,
1375
+				[],
1376
+				'REG_ID'
1377
+			);
1378
+			$this->_template_args['next_registration']     = $next_reg
1379
+				? $this->_next_link(
1380
+					EE_Admin_Page::add_query_args_and_nonce(
1381
+						[
1382
+							'action'  => 'view_registration',
1383
+							'_REG_ID' => $next_reg['REG_ID'],
1384
+						],
1385
+						REG_ADMIN_URL
1386
+					),
1387
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1388
+				)
1389
+				: '';
1390
+			$previous_reg                                  = $this->_registration->previous(
1391
+				null,
1392
+				[],
1393
+				'REG_ID'
1394
+			);
1395
+			$this->_template_args['previous_registration'] = $previous_reg
1396
+				? $this->_previous_link(
1397
+					EE_Admin_Page::add_query_args_and_nonce(
1398
+						[
1399
+							'action'  => 'view_registration',
1400
+							'_REG_ID' => $previous_reg['REG_ID'],
1401
+						],
1402
+						REG_ADMIN_URL
1403
+					),
1404
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1405
+				)
1406
+				: '';
1407
+			// grab header
1408
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1409
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1410
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411
+				$template_path,
1412
+				$this->_template_args,
1413
+				true
1414
+			);
1415
+		} else {
1416
+			$this->_template_args['admin_page_header'] = '';
1417
+			$this->_display_espresso_notices();
1418
+		}
1419
+		// the details template wrapper
1420
+		$this->display_admin_page_with_sidebar();
1421
+	}
1422
+
1423
+
1424
+	/**
1425
+	 * @throws EE_Error
1426
+	 * @throws InvalidArgumentException
1427
+	 * @throws InvalidDataTypeException
1428
+	 * @throws InvalidInterfaceException
1429
+	 * @throws ReflectionException
1430
+	 * @since 4.10.2.p
1431
+	 */
1432
+	protected function _registration_details_metaboxes()
1433
+	{
1434
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1435
+		$this->_set_registration_object();
1436
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1437
+		add_meta_box(
1438
+			'edit-reg-status-mbox',
1439
+			esc_html__('Registration Status', 'event_espresso'),
1440
+			[$this, 'set_reg_status_buttons_metabox'],
1441
+			$this->_wp_page_slug,
1442
+			'normal',
1443
+			'high'
1444
+		);
1445
+		add_meta_box(
1446
+			'edit-reg-details-mbox',
1447
+			esc_html__('Registration Details', 'event_espresso'),
1448
+			[$this, '_reg_details_meta_box'],
1449
+			$this->_wp_page_slug,
1450
+			'normal',
1451
+			'high'
1452
+		);
1453
+		if (
1454
+			$attendee instanceof EE_Attendee
1455
+			&& EE_Registry::instance()->CAP->current_user_can(
1456
+				'ee_read_registration',
1457
+				'edit-reg-questions-mbox',
1458
+				$this->_registration->ID()
1459
+			)
1460
+		) {
1461
+			add_meta_box(
1462
+				'edit-reg-questions-mbox',
1463
+				esc_html__('Registration Form Answers', 'event_espresso'),
1464
+				[$this, '_reg_questions_meta_box'],
1465
+				$this->_wp_page_slug,
1466
+				'normal',
1467
+				'high'
1468
+			);
1469
+		}
1470
+		add_meta_box(
1471
+			'edit-reg-registrant-mbox',
1472
+			esc_html__('Contact Details', 'event_espresso'),
1473
+			[$this, '_reg_registrant_side_meta_box'],
1474
+			$this->_wp_page_slug,
1475
+			'side',
1476
+			'high'
1477
+		);
1478
+		if ($this->_registration->group_size() > 1) {
1479
+			add_meta_box(
1480
+				'edit-reg-attendees-mbox',
1481
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1482
+				[$this, '_reg_attendees_meta_box'],
1483
+				$this->_wp_page_slug,
1484
+				'normal',
1485
+				'high'
1486
+			);
1487
+		}
1488
+	}
1489
+
1490
+
1491
+	/**
1492
+	 * set_reg_status_buttons_metabox
1493
+	 *
1494
+	 * @return void
1495
+	 * @throws EE_Error
1496
+	 * @throws EntityNotFoundException
1497
+	 * @throws InvalidArgumentException
1498
+	 * @throws InvalidDataTypeException
1499
+	 * @throws InvalidInterfaceException
1500
+	 * @throws ReflectionException
1501
+	 */
1502
+	public function set_reg_status_buttons_metabox()
1503
+	{
1504
+		$this->_set_registration_object();
1505
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1506
+		$output                 = $change_reg_status_form->form_open(
1507
+			self::add_query_args_and_nonce(
1508
+				[
1509
+					'action' => 'change_reg_status',
1510
+				],
1511
+				REG_ADMIN_URL
1512
+			)
1513
+		);
1514
+		$output                 .= $change_reg_status_form->get_html();
1515
+		$output                 .= $change_reg_status_form->form_close();
1516
+		echo $output; // already escaped
1517
+	}
1518
+
1519
+
1520
+	/**
1521
+	 * @return EE_Form_Section_Proper
1522
+	 * @throws EE_Error
1523
+	 * @throws InvalidArgumentException
1524
+	 * @throws InvalidDataTypeException
1525
+	 * @throws InvalidInterfaceException
1526
+	 * @throws EntityNotFoundException
1527
+	 * @throws ReflectionException
1528
+	 */
1529
+	protected function _generate_reg_status_change_form()
1530
+	{
1531
+		$reg_status_change_form_array = [
1532
+			'name'            => 'reg_status_change_form',
1533
+			'html_id'         => 'reg-status-change-form',
1534
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1535
+			'subsections'     => [
1536
+				'return'         => new EE_Hidden_Input(
1537
+					[
1538
+						'name'    => 'return',
1539
+						'default' => 'view_registration',
1540
+					]
1541
+				),
1542
+				'REG_ID'         => new EE_Hidden_Input(
1543
+					[
1544
+						'name'    => 'REG_ID',
1545
+						'default' => $this->_registration->ID(),
1546
+					]
1547
+				),
1548
+				'current_status' => new EE_Form_Section_HTML(
1549
+					EEH_HTML::table(
1550
+						EEH_HTML::tr(
1551
+							EEH_HTML::th(
1552
+								EEH_HTML::label(
1553
+									EEH_HTML::strong(
1554
+										esc_html__('Current Registration Status', 'event_espresso')
1555
+									)
1556
+								)
1557
+							)
1558
+							. EEH_HTML::td(
1559
+								EEH_HTML::strong(
1560
+									$this->_registration->pretty_status(),
1561
+									'',
1562
+									'status-' . $this->_registration->status_ID(),
1563
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564
+								)
1565
+							)
1566
+						)
1567
+					)
1568
+				),
1569
+			],
1570
+		];
1571
+		if (
1572
+			EE_Registry::instance()->CAP->current_user_can(
1573
+				'ee_edit_registration',
1574
+				'toggle_registration_status',
1575
+				$this->_registration->ID()
1576
+			)
1577
+		) {
1578
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1579
+				$this->_get_reg_statuses(),
1580
+				[
1581
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1582
+					'default'         => $this->_registration->status_ID(),
1583
+				]
1584
+			);
1585
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1586
+				[
1587
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1588
+					'default'         => false,
1589
+					'html_help_text'  => esc_html__(
1590
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1591
+						'event_espresso'
1592
+					),
1593
+				]
1594
+			);
1595
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1596
+				[
1597
+					'html_class'      => 'button-primary',
1598
+					'html_label_text' => '&nbsp;',
1599
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1600
+				]
1601
+			);
1602
+		}
1603
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1604
+	}
1605
+
1606
+
1607
+	/**
1608
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1609
+	 *
1610
+	 * @return array
1611
+	 * @throws EE_Error
1612
+	 * @throws InvalidArgumentException
1613
+	 * @throws InvalidDataTypeException
1614
+	 * @throws InvalidInterfaceException
1615
+	 * @throws EntityNotFoundException
1616
+	 */
1617
+	protected function _get_reg_statuses()
1618
+	{
1619
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1621
+		// get current reg status
1622
+		$current_status = $this->_registration->status_ID();
1623
+		// is registration for free event? This will determine whether to display the pending payment option
1624
+		if (
1625
+			$current_status !== EEM_Registration::status_id_pending_payment
1626
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627
+		) {
1628
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1629
+		}
1630
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631
+	}
1632
+
1633
+
1634
+	/**
1635
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1636
+	 *
1637
+	 * @param bool $status REG status given for changing registrations to.
1638
+	 * @param bool $notify Whether to send messages notifications or not.
1639
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1640
+	 * @throws DomainException
1641
+	 * @throws EE_Error
1642
+	 * @throws EntityNotFoundException
1643
+	 * @throws InvalidArgumentException
1644
+	 * @throws InvalidDataTypeException
1645
+	 * @throws InvalidInterfaceException
1646
+	 * @throws ReflectionException
1647
+	 * @throws RuntimeException
1648
+	 */
1649
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1650
+	{
1651
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1652
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1653
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1654
+
1655
+		// sanitize $REG_IDs
1656
+		$REG_IDs = array_map('absint', $REG_IDs);
1657
+		// and remove empty entries
1658
+		$REG_IDs = array_filter($REG_IDs);
1659
+
1660
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1661
+
1662
+		/**
1663
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1664
+		 * Currently this value is used downstream by the _process_resend_registration method.
1665
+		 *
1666
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1667
+		 * @param bool                     $status           The status registrations were changed to.
1668
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1669
+		 * @param Registrations_Admin_Page $admin_page_object
1670
+		 */
1671
+		$REG_ID = apply_filters(
1672
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1673
+			$result['REG_ID'],
1674
+			$status,
1675
+			$result['success'],
1676
+			$this
1677
+		);
1678
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1679
+
1680
+		// notify?
1681
+		if (
1682
+			$notify
1683
+			&& $result['success']
1684
+			&& ! empty($REG_ID)
1685
+			&& EE_Registry::instance()->CAP->current_user_can(
1686
+				'ee_send_message',
1687
+				'espresso_registrations_resend_registration'
1688
+			)
1689
+		) {
1690
+			$this->_process_resend_registration();
1691
+		}
1692
+		return $result;
1693
+	}
1694
+
1695
+
1696
+	/**
1697
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1698
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1699
+	 *
1700
+	 * @param array  $REG_IDs
1701
+	 * @param string $status
1702
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1703
+	 *                       slug sent with setting the registration status.
1704
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1705
+	 * @throws EE_Error
1706
+	 * @throws InvalidArgumentException
1707
+	 * @throws InvalidDataTypeException
1708
+	 * @throws InvalidInterfaceException
1709
+	 * @throws ReflectionException
1710
+	 * @throws RuntimeException
1711
+	 * @throws EntityNotFoundException
1712
+	 * @throws DomainException
1713
+	 */
1714
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1715
+	{
1716
+		$success = false;
1717
+		// typecast $REG_IDs
1718
+		$REG_IDs = (array) $REG_IDs;
1719
+		if (! empty($REG_IDs)) {
1720
+			$success = true;
1721
+			// set default status if none is passed
1722
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1723
+			$status_context = $notify
1724
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1725
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1726
+			// loop through REG_ID's and change status
1727
+			foreach ($REG_IDs as $REG_ID) {
1728
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1729
+				if ($registration instanceof EE_Registration) {
1730
+					$registration->set_status(
1731
+						$status,
1732
+						false,
1733
+						new Context(
1734
+							$status_context,
1735
+							esc_html__(
1736
+								'Manually triggered status change on a Registration Admin Page route.',
1737
+								'event_espresso'
1738
+							)
1739
+						)
1740
+					);
1741
+					$result = $registration->save();
1742
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1743
+					$success = $result !== false ? $success : false;
1744
+				}
1745
+			}
1746
+		}
1747
+
1748
+		// return $success and processed registrations
1749
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1750
+	}
1751
+
1752
+
1753
+	/**
1754
+	 * Common logic for setting up success message and redirecting to appropriate route
1755
+	 *
1756
+	 * @param string $STS_ID status id for the registration changed to
1757
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1758
+	 * @return void
1759
+	 * @throws DomainException
1760
+	 * @throws EE_Error
1761
+	 * @throws EntityNotFoundException
1762
+	 * @throws InvalidArgumentException
1763
+	 * @throws InvalidDataTypeException
1764
+	 * @throws InvalidInterfaceException
1765
+	 * @throws ReflectionException
1766
+	 * @throws RuntimeException
1767
+	 */
1768
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1769
+	{
1770
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1771
+			: ['success' => false];
1772
+		$success = isset($result['success']) && $result['success'];
1773
+		// setup success message
1774
+		if ($success) {
1775
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1776
+				$msg = sprintf(
1777
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1778
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
+				);
1780
+			} else {
1781
+				$msg = sprintf(
1782
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1783
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1784
+				);
1785
+			}
1786
+			EE_Error::add_success($msg);
1787
+		} else {
1788
+			EE_Error::add_error(
1789
+				esc_html__(
1790
+					'Something went wrong, and the status was not changed',
1791
+					'event_espresso'
1792
+				),
1793
+				__FILE__,
1794
+				__LINE__,
1795
+				__FUNCTION__
1796
+			);
1797
+		}
1798
+		$return = $this->request->getRequestParam('return');
1799
+		$route  = $return === 'view_registration'
1800
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1801
+			: ['action' => 'default'];
1802
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1803
+		$this->_redirect_after_action($success, '', '', $route, true);
1804
+	}
1805
+
1806
+
1807
+	/**
1808
+	 * incoming reg status change from reg details page.
1809
+	 *
1810
+	 * @return void
1811
+	 * @throws EE_Error
1812
+	 * @throws EntityNotFoundException
1813
+	 * @throws InvalidArgumentException
1814
+	 * @throws InvalidDataTypeException
1815
+	 * @throws InvalidInterfaceException
1816
+	 * @throws ReflectionException
1817
+	 * @throws RuntimeException
1818
+	 * @throws DomainException
1819
+	 */
1820
+	protected function _change_reg_status()
1821
+	{
1822
+		$this->request->setRequestParam('return', 'view_registration');
1823
+		// set notify based on whether the send notifications toggle is set or not
1824
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1825
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1826
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1827
+		switch ($reg_status) {
1828
+			case EEM_Registration::status_id_approved:
1829
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1830
+				$this->approve_registration($notify);
1831
+				break;
1832
+			case EEM_Registration::status_id_pending_payment:
1833
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1834
+				$this->pending_registration($notify);
1835
+				break;
1836
+			case EEM_Registration::status_id_not_approved:
1837
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1838
+				$this->not_approve_registration($notify);
1839
+				break;
1840
+			case EEM_Registration::status_id_declined:
1841
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1842
+				$this->decline_registration($notify);
1843
+				break;
1844
+			case EEM_Registration::status_id_cancelled:
1845
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1846
+				$this->cancel_registration($notify);
1847
+				break;
1848
+			case EEM_Registration::status_id_wait_list:
1849
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1850
+				$this->wait_list_registration($notify);
1851
+				break;
1852
+			case EEM_Registration::status_id_incomplete:
1853
+			default:
1854
+				$this->request->unSetRequestParam('return');
1855
+				$this->_reg_status_change_return('');
1856
+				break;
1857
+		}
1858
+	}
1859
+
1860
+
1861
+	/**
1862
+	 * Callback for bulk action routes.
1863
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1864
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1865
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1866
+	 * when an action is happening on just a single registration).
1867
+	 *
1868
+	 * @param      $action
1869
+	 * @param bool $notify
1870
+	 */
1871
+	protected function bulk_action_on_registrations($action, $notify = false)
1872
+	{
1873
+		do_action(
1874
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1875
+			$this,
1876
+			$action,
1877
+			$notify
1878
+		);
1879
+		$method = $action . '_registration';
1880
+		if (method_exists($this, $method)) {
1881
+			$this->$method($notify);
1882
+		}
1883
+	}
1884
+
1885
+
1886
+	/**
1887
+	 * approve_registration
1888
+	 *
1889
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1890
+	 * @return void
1891
+	 * @throws EE_Error
1892
+	 * @throws EntityNotFoundException
1893
+	 * @throws InvalidArgumentException
1894
+	 * @throws InvalidDataTypeException
1895
+	 * @throws InvalidInterfaceException
1896
+	 * @throws ReflectionException
1897
+	 * @throws RuntimeException
1898
+	 * @throws DomainException
1899
+	 */
1900
+	protected function approve_registration($notify = false)
1901
+	{
1902
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1903
+	}
1904
+
1905
+
1906
+	/**
1907
+	 * decline_registration
1908
+	 *
1909
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1910
+	 * @return void
1911
+	 * @throws EE_Error
1912
+	 * @throws EntityNotFoundException
1913
+	 * @throws InvalidArgumentException
1914
+	 * @throws InvalidDataTypeException
1915
+	 * @throws InvalidInterfaceException
1916
+	 * @throws ReflectionException
1917
+	 * @throws RuntimeException
1918
+	 * @throws DomainException
1919
+	 */
1920
+	protected function decline_registration($notify = false)
1921
+	{
1922
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1923
+	}
1924
+
1925
+
1926
+	/**
1927
+	 * cancel_registration
1928
+	 *
1929
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1930
+	 * @return void
1931
+	 * @throws EE_Error
1932
+	 * @throws EntityNotFoundException
1933
+	 * @throws InvalidArgumentException
1934
+	 * @throws InvalidDataTypeException
1935
+	 * @throws InvalidInterfaceException
1936
+	 * @throws ReflectionException
1937
+	 * @throws RuntimeException
1938
+	 * @throws DomainException
1939
+	 */
1940
+	protected function cancel_registration($notify = false)
1941
+	{
1942
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1943
+	}
1944
+
1945
+
1946
+	/**
1947
+	 * not_approve_registration
1948
+	 *
1949
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1950
+	 * @return void
1951
+	 * @throws EE_Error
1952
+	 * @throws EntityNotFoundException
1953
+	 * @throws InvalidArgumentException
1954
+	 * @throws InvalidDataTypeException
1955
+	 * @throws InvalidInterfaceException
1956
+	 * @throws ReflectionException
1957
+	 * @throws RuntimeException
1958
+	 * @throws DomainException
1959
+	 */
1960
+	protected function not_approve_registration($notify = false)
1961
+	{
1962
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1963
+	}
1964
+
1965
+
1966
+	/**
1967
+	 * decline_registration
1968
+	 *
1969
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1970
+	 * @return void
1971
+	 * @throws EE_Error
1972
+	 * @throws EntityNotFoundException
1973
+	 * @throws InvalidArgumentException
1974
+	 * @throws InvalidDataTypeException
1975
+	 * @throws InvalidInterfaceException
1976
+	 * @throws ReflectionException
1977
+	 * @throws RuntimeException
1978
+	 * @throws DomainException
1979
+	 */
1980
+	protected function pending_registration($notify = false)
1981
+	{
1982
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1983
+	}
1984
+
1985
+
1986
+	/**
1987
+	 * waitlist_registration
1988
+	 *
1989
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1990
+	 * @return void
1991
+	 * @throws EE_Error
1992
+	 * @throws EntityNotFoundException
1993
+	 * @throws InvalidArgumentException
1994
+	 * @throws InvalidDataTypeException
1995
+	 * @throws InvalidInterfaceException
1996
+	 * @throws ReflectionException
1997
+	 * @throws RuntimeException
1998
+	 * @throws DomainException
1999
+	 */
2000
+	protected function wait_list_registration($notify = false)
2001
+	{
2002
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2003
+	}
2004
+
2005
+
2006
+	/**
2007
+	 * generates HTML for the Registration main meta box
2008
+	 *
2009
+	 * @return void
2010
+	 * @throws DomainException
2011
+	 * @throws EE_Error
2012
+	 * @throws InvalidArgumentException
2013
+	 * @throws InvalidDataTypeException
2014
+	 * @throws InvalidInterfaceException
2015
+	 * @throws ReflectionException
2016
+	 * @throws EntityNotFoundException
2017
+	 */
2018
+	public function _reg_details_meta_box()
2019
+	{
2020
+		EEH_Autoloader::register_line_item_display_autoloaders();
2021
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2022
+		EE_Registry::instance()->load_helper('Line_Item');
2023
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2024
+			: EE_Transaction::new_instance();
2025
+		$this->_session = $transaction->session_data();
2026
+		$filters        = new EE_Line_Item_Filter_Collection();
2027
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2030
+			$filters,
2031
+			$transaction->total_line_item()
2032
+		);
2033
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2034
+		$line_item_display                       = new EE_Line_Item_Display(
2035
+			'reg_admin_table',
2036
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2037
+		);
2038
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2039
+			$filtered_line_item_tree,
2040
+			['EE_Registration' => $this->_registration]
2041
+		);
2042
+		$attendee                                = $this->_registration->attendee();
2043
+		if (
2044
+			EE_Registry::instance()->CAP->current_user_can(
2045
+				'ee_read_transaction',
2046
+				'espresso_transactions_view_transaction'
2047
+			)
2048
+		) {
2049
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2050
+				EE_Admin_Page::add_query_args_and_nonce(
2051
+					[
2052
+						'action' => 'view_transaction',
2053
+						'TXN_ID' => $transaction->ID(),
2054
+					],
2055
+					TXN_ADMIN_URL
2056
+				),
2057
+				esc_html__(' View Transaction', 'event_espresso'),
2058
+				'button secondary-button right',
2059
+				'dashicons dashicons-cart'
2060
+			);
2061
+		} else {
2062
+			$this->_template_args['view_transaction_button'] = '';
2063
+		}
2064
+		if (
2065
+			$attendee instanceof EE_Attendee
2066
+			&& EE_Registry::instance()->CAP->current_user_can(
2067
+				'ee_send_message',
2068
+				'espresso_registrations_resend_registration'
2069
+			)
2070
+		) {
2071
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2072
+				EE_Admin_Page::add_query_args_and_nonce(
2073
+					[
2074
+						'action'      => 'resend_registration',
2075
+						'_REG_ID'     => $this->_registration->ID(),
2076
+						'redirect_to' => 'view_registration',
2077
+					],
2078
+					REG_ADMIN_URL
2079
+				),
2080
+				esc_html__(' Resend Registration', 'event_espresso'),
2081
+				'button secondary-button right',
2082
+				'dashicons dashicons-email-alt'
2083
+			);
2084
+		} else {
2085
+			$this->_template_args['resend_registration_button'] = '';
2086
+		}
2087
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2088
+		$payment                               = $transaction->get_first_related('Payment');
2089
+		$payment                               = ! $payment instanceof EE_Payment
2090
+			? EE_Payment::new_instance()
2091
+			: $payment;
2092
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2093
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2094
+			? EE_Payment_Method::new_instance()
2095
+			: $payment_method;
2096
+		$reg_details                           = [
2097
+			'payment_method'       => $payment_method->name(),
2098
+			'response_msg'         => $payment->gateway_response(),
2099
+			'registration_id'      => $this->_registration->get('REG_code'),
2100
+			'registration_session' => $this->_registration->session_ID(),
2101
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2102
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2103
+		];
2104
+		if (isset($reg_details['registration_id'])) {
2105
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2106
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2107
+				'Registration ID',
2108
+				'event_espresso'
2109
+			);
2110
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2111
+		}
2112
+		if (isset($reg_details['payment_method'])) {
2113
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2114
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2115
+				'Most Recent Payment Method',
2116
+				'event_espresso'
2117
+			);
2118
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2119
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2120
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2121
+				'Payment method response',
2122
+				'event_espresso'
2123
+			);
2124
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2125
+		}
2126
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2128
+			'Registration Session',
2129
+			'event_espresso'
2130
+		);
2131
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2132
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2133
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2134
+			'Registration placed from IP',
2135
+			'event_espresso'
2136
+		);
2137
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2138
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2139
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2140
+			'Registrant User Agent',
2141
+			'event_espresso'
2142
+		);
2143
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2144
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2145
+			[
2146
+				'action'   => 'default',
2147
+				'event_id' => $this->_registration->event_ID(),
2148
+			],
2149
+			REG_ADMIN_URL
2150
+		);
2151
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153
+		$template_path                                                        =
2154
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2155
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156
+	}
2157
+
2158
+
2159
+	/**
2160
+	 * generates HTML for the Registration Questions meta box.
2161
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2162
+	 * otherwise uses new forms system
2163
+	 *
2164
+	 * @return void
2165
+	 * @throws DomainException
2166
+	 * @throws EE_Error
2167
+	 * @throws InvalidArgumentException
2168
+	 * @throws InvalidDataTypeException
2169
+	 * @throws InvalidInterfaceException
2170
+	 * @throws ReflectionException
2171
+	 */
2172
+	public function _reg_questions_meta_box()
2173
+	{
2174
+		// allow someone to override this method entirely
2175
+		if (
2176
+			apply_filters(
2177
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2178
+				true,
2179
+				$this,
2180
+				$this->_registration
2181
+			)
2182
+		) {
2183
+			$form                                              = $this->_get_reg_custom_questions_form(
2184
+				$this->_registration->ID()
2185
+			);
2186
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2187
+				? $form->get_html_and_js()
2188
+				: '';
2189
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2191
+			$template_path                                     =
2192
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2193
+			EEH_Template::display_template($template_path, $this->_template_args);
2194
+		}
2195
+	}
2196
+
2197
+
2198
+	/**
2199
+	 * form_before_question_group
2200
+	 *
2201
+	 * @param string $output
2202
+	 * @return        string
2203
+	 * @deprecated    as of 4.8.32.rc.000
2204
+	 */
2205
+	public function form_before_question_group($output)
2206
+	{
2207
+		EE_Error::doing_it_wrong(
2208
+			__CLASS__ . '::' . __FUNCTION__,
2209
+			esc_html__(
2210
+				'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.',
2211
+				'event_espresso'
2212
+			),
2213
+			'4.8.32.rc.000'
2214
+		);
2215
+		return '
2216 2216
 	<table class="form-table ee-width-100">
2217 2217
 		<tbody>
2218 2218
 			';
2219
-    }
2220
-
2221
-
2222
-    /**
2223
-     * form_after_question_group
2224
-     *
2225
-     * @param string $output
2226
-     * @return        string
2227
-     * @deprecated    as of 4.8.32.rc.000
2228
-     */
2229
-    public function form_after_question_group($output)
2230
-    {
2231
-        EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2233
-            esc_html__(
2234
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235
-                'event_espresso'
2236
-            ),
2237
-            '4.8.32.rc.000'
2238
-        );
2239
-        return '
2219
+	}
2220
+
2221
+
2222
+	/**
2223
+	 * form_after_question_group
2224
+	 *
2225
+	 * @param string $output
2226
+	 * @return        string
2227
+	 * @deprecated    as of 4.8.32.rc.000
2228
+	 */
2229
+	public function form_after_question_group($output)
2230
+	{
2231
+		EE_Error::doing_it_wrong(
2232
+			__CLASS__ . '::' . __FUNCTION__,
2233
+			esc_html__(
2234
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235
+				'event_espresso'
2236
+			),
2237
+			'4.8.32.rc.000'
2238
+		);
2239
+		return '
2240 2240
 			<tr class="hide-if-no-js">
2241 2241
 				<th> </th>
2242 2242
 				<td class="reg-admin-edit-attendee-question-td">
2243 2243
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2244
-               . esc_attr__('click to edit question', 'event_espresso')
2245
-               . '">
2244
+			   . esc_attr__('click to edit question', 'event_espresso')
2245
+			   . '">
2246 2246
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2247
-               . esc_html__('edit the above question group', 'event_espresso')
2248
-               . '</span>
2247
+			   . esc_html__('edit the above question group', 'event_espresso')
2248
+			   . '</span>
2249 2249
 						<div class="dashicons dashicons-edit"></div>
2250 2250
 					</a>
2251 2251
 				</td>
@@ -2253,637 +2253,637 @@  discard block
 block discarded – undo
2253 2253
 		</tbody>
2254 2254
 	</table>
2255 2255
 ';
2256
-    }
2257
-
2258
-
2259
-    /**
2260
-     * form_form_field_label_wrap
2261
-     *
2262
-     * @param string $label
2263
-     * @return        string
2264
-     * @deprecated    as of 4.8.32.rc.000
2265
-     */
2266
-    public function form_form_field_label_wrap($label)
2267
-    {
2268
-        EE_Error::doing_it_wrong(
2269
-            __CLASS__ . '::' . __FUNCTION__,
2270
-            esc_html__(
2271
-                '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.',
2272
-                'event_espresso'
2273
-            ),
2274
-            '4.8.32.rc.000'
2275
-        );
2276
-        return '
2256
+	}
2257
+
2258
+
2259
+	/**
2260
+	 * form_form_field_label_wrap
2261
+	 *
2262
+	 * @param string $label
2263
+	 * @return        string
2264
+	 * @deprecated    as of 4.8.32.rc.000
2265
+	 */
2266
+	public function form_form_field_label_wrap($label)
2267
+	{
2268
+		EE_Error::doing_it_wrong(
2269
+			__CLASS__ . '::' . __FUNCTION__,
2270
+			esc_html__(
2271
+				'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.',
2272
+				'event_espresso'
2273
+			),
2274
+			'4.8.32.rc.000'
2275
+		);
2276
+		return '
2277 2277
 			<tr>
2278 2278
 				<th>
2279 2279
 					' . $label . '
2280 2280
 				</th>';
2281
-    }
2282
-
2283
-
2284
-    /**
2285
-     * form_form_field_input__wrap
2286
-     *
2287
-     * @param string $input
2288
-     * @return        string
2289
-     * @deprecated    as of 4.8.32.rc.000
2290
-     */
2291
-    public function form_form_field_input__wrap($input)
2292
-    {
2293
-        EE_Error::doing_it_wrong(
2294
-            __CLASS__ . '::' . __FUNCTION__,
2295
-            esc_html__(
2296
-                '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.',
2297
-                'event_espresso'
2298
-            ),
2299
-            '4.8.32.rc.000'
2300
-        );
2301
-        return '
2281
+	}
2282
+
2283
+
2284
+	/**
2285
+	 * form_form_field_input__wrap
2286
+	 *
2287
+	 * @param string $input
2288
+	 * @return        string
2289
+	 * @deprecated    as of 4.8.32.rc.000
2290
+	 */
2291
+	public function form_form_field_input__wrap($input)
2292
+	{
2293
+		EE_Error::doing_it_wrong(
2294
+			__CLASS__ . '::' . __FUNCTION__,
2295
+			esc_html__(
2296
+				'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.',
2297
+				'event_espresso'
2298
+			),
2299
+			'4.8.32.rc.000'
2300
+		);
2301
+		return '
2302 2302
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2303 2303
 					' . $input . '
2304 2304
 				</td>
2305 2305
 			</tr>';
2306
-    }
2307
-
2308
-
2309
-    /**
2310
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2311
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2312
-     * to display the page
2313
-     *
2314
-     * @return void
2315
-     * @throws EE_Error
2316
-     * @throws InvalidArgumentException
2317
-     * @throws InvalidDataTypeException
2318
-     * @throws InvalidInterfaceException
2319
-     * @throws ReflectionException
2320
-     */
2321
-    protected function _update_attendee_registration_form()
2322
-    {
2323
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2324
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2325
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2326
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2327
-            if ($success) {
2328
-                $what  = esc_html__('Registration Form', 'event_espresso');
2329
-                $route = $REG_ID
2330
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2331
-                    : ['action' => 'default'];
2332
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2333
-            }
2334
-        }
2335
-    }
2336
-
2337
-
2338
-    /**
2339
-     * Gets the form for saving registrations custom questions (if done
2340
-     * previously retrieves the cached form object, which may have validation errors in it)
2341
-     *
2342
-     * @param int $REG_ID
2343
-     * @return EE_Registration_Custom_Questions_Form
2344
-     * @throws EE_Error
2345
-     * @throws InvalidArgumentException
2346
-     * @throws InvalidDataTypeException
2347
-     * @throws InvalidInterfaceException
2348
-     * @throws ReflectionException
2349
-     */
2350
-    protected function _get_reg_custom_questions_form($REG_ID)
2351
-    {
2352
-        if (! $this->_reg_custom_questions_form) {
2353
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356
-            );
2357
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2358
-        }
2359
-        return $this->_reg_custom_questions_form;
2360
-    }
2361
-
2362
-
2363
-    /**
2364
-     * Saves
2365
-     *
2366
-     * @param bool $REG_ID
2367
-     * @return bool
2368
-     * @throws EE_Error
2369
-     * @throws InvalidArgumentException
2370
-     * @throws InvalidDataTypeException
2371
-     * @throws InvalidInterfaceException
2372
-     * @throws ReflectionException
2373
-     */
2374
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2375
-    {
2376
-        if (! $REG_ID) {
2377
-            EE_Error::add_error(
2378
-                esc_html__(
2379
-                    'An error occurred. No registration ID was received.',
2380
-                    'event_espresso'
2381
-                ),
2382
-                __FILE__,
2383
-                __FUNCTION__,
2384
-                __LINE__
2385
-            );
2386
-        }
2387
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2388
-        $form->receive_form_submission($this->request->requestParams());
2389
-        $success = false;
2390
-        if ($form->is_valid()) {
2391
-            foreach ($form->subforms() as $question_group_form) {
2392
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2393
-                    $where_conditions    = [
2394
-                        'QST_ID' => $question_id,
2395
-                        'REG_ID' => $REG_ID,
2396
-                    ];
2397
-                    $possibly_new_values = [
2398
-                        'ANS_value' => $input->normalized_value(),
2399
-                    ];
2400
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2401
-                    if ($answer instanceof EE_Answer) {
2402
-                        $success = $answer->save($possibly_new_values);
2403
-                    } else {
2404
-                        // insert it then
2405
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2406
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2407
-                        $success     = $answer->save();
2408
-                    }
2409
-                }
2410
-            }
2411
-        } else {
2412
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2413
-        }
2414
-        return $success;
2415
-    }
2416
-
2417
-
2418
-    /**
2419
-     * generates HTML for the Registration main meta box
2420
-     *
2421
-     * @return void
2422
-     * @throws DomainException
2423
-     * @throws EE_Error
2424
-     * @throws InvalidArgumentException
2425
-     * @throws InvalidDataTypeException
2426
-     * @throws InvalidInterfaceException
2427
-     * @throws ReflectionException
2428
-     */
2429
-    public function _reg_attendees_meta_box()
2430
-    {
2431
-        $REG = $this->getRegistrationModel();
2432
-        // get all other registrations on this transaction, and cache
2433
-        // the attendees for them so we don't have to run another query using force_join
2434
-        $registrations                           = $REG->get_all(
2435
-            [
2436
-                [
2437
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2438
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2439
-                ],
2440
-                'force_join'               => ['Attendee'],
2441
-                'default_where_conditions' => 'other_models_only',
2442
-            ]
2443
-        );
2444
-        $this->_template_args['attendees']       = [];
2445
-        $this->_template_args['attendee_notice'] = '';
2446
-        if (
2447
-            empty($registrations)
2448
-            || (is_array($registrations)
2449
-                && ! EEH_Array::get_one_item_from_array($registrations))
2450
-        ) {
2451
-            EE_Error::add_error(
2452
-                esc_html__(
2453
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2454
-                    'event_espresso'
2455
-                ),
2456
-                __FILE__,
2457
-                __FUNCTION__,
2458
-                __LINE__
2459
-            );
2460
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2461
-        } else {
2462
-            $att_nmbr = 1;
2463
-            foreach ($registrations as $registration) {
2464
-                /* @var $registration EE_Registration */
2465
-                $attendee                                                      = $registration->attendee()
2466
-                    ? $registration->attendee()
2467
-                    : $this->getAttendeeModel()->create_default_object();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2474
-                    ', ',
2475
-                    $attendee->full_address_as_array()
2476
-                );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2478
-                    [
2479
-                        'action' => 'edit_attendee',
2480
-                        'post'   => $attendee->ID(),
2481
-                    ],
2482
-                    REG_ADMIN_URL
2483
-                );
2484
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2485
-                    $registration->event_obj() instanceof EE_Event
2486
-                        ? $registration->event_obj()->name()
2487
-                        : '';
2488
-                $att_nmbr++;
2489
-            }
2490
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491
-        }
2492
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2493
-        EEH_Template::display_template($template_path, $this->_template_args);
2494
-    }
2495
-
2496
-
2497
-    /**
2498
-     * generates HTML for the Edit Registration side meta box
2499
-     *
2500
-     * @return void
2501
-     * @throws DomainException
2502
-     * @throws EE_Error
2503
-     * @throws InvalidArgumentException
2504
-     * @throws InvalidDataTypeException
2505
-     * @throws InvalidInterfaceException
2506
-     * @throws ReflectionException
2507
-     */
2508
-    public function _reg_registrant_side_meta_box()
2509
-    {
2510
-        /*@var $attendee EE_Attendee */
2511
-        $att_check = $this->_registration->attendee();
2512
-        $attendee  = $att_check instanceof EE_Attendee
2513
-            ? $att_check
2514
-            : $this->getAttendeeModel()->create_default_object();
2515
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2516
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517
-        // primary registration object (that way we know if we need to show create button or not)
2518
-        if (! $this->_registration->is_primary_registrant()) {
2519
-            $primary_registration = $this->_registration->get_primary_registration();
2520
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521
-                : null;
2522
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524
-                // custom attendee object so let's not worry about the primary reg.
2525
-                $primary_registration = null;
2526
-            }
2527
-        } else {
2528
-            $primary_registration = null;
2529
-        }
2530
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2531
-        $this->_template_args['fname']             = $attendee->fname();
2532
-        $this->_template_args['lname']             = $attendee->lname();
2533
-        $this->_template_args['email']             = $attendee->email();
2534
-        $this->_template_args['phone']             = $attendee->phone();
2535
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536
-        // edit link
2537
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2538
-            [
2539
-                'action' => 'edit_attendee',
2540
-                'post'   => $attendee->ID(),
2541
-            ],
2542
-            REG_ADMIN_URL
2543
-        );
2544
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545
-        // create link
2546
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2547
-            ? EE_Admin_Page::add_query_args_and_nonce(
2548
-                [
2549
-                    'action'  => 'duplicate_attendee',
2550
-                    '_REG_ID' => $this->_registration->ID(),
2551
-                ],
2552
-                REG_ADMIN_URL
2553
-            ) : '';
2554
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555
-        $this->_template_args['att_check']    = $att_check;
2556
-        $template_path                        =
2557
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2558
-        EEH_Template::display_template($template_path, $this->_template_args);
2559
-    }
2560
-
2561
-
2562
-    /**
2563
-     * trash or restore registrations
2564
-     *
2565
-     * @param boolean $trash whether to archive or restore
2566
-     * @return void
2567
-     * @throws EE_Error
2568
-     * @throws InvalidArgumentException
2569
-     * @throws InvalidDataTypeException
2570
-     * @throws InvalidInterfaceException
2571
-     * @throws RuntimeException
2572
-     */
2573
-    protected function _trash_or_restore_registrations($trash = true)
2574
-    {
2575
-        // if empty _REG_ID then get out because there's nothing to do
2576
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2577
-        if (empty($REG_IDs)) {
2578
-            EE_Error::add_error(
2579
-                sprintf(
2580
-                    esc_html__(
2581
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2582
-                        'event_espresso'
2583
-                    ),
2584
-                    $trash ? 'trash' : 'restore'
2585
-                ),
2586
-                __FILE__,
2587
-                __LINE__,
2588
-                __FUNCTION__
2589
-            );
2590
-            $this->_redirect_after_action(false, '', '', [], true);
2591
-        }
2592
-        $success        = 0;
2593
-        $overwrite_msgs = false;
2594
-        // Checkboxes
2595
-        $reg_count = count($REG_IDs);
2596
-        // cycle thru checkboxes
2597
-        foreach ($REG_IDs as $REG_ID) {
2598
-            /** @var EE_Registration $REG */
2599
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600
-            $payments = $REG->registration_payments();
2601
-            if (! empty($payments)) {
2602
-                $name           = $REG->attendee() instanceof EE_Attendee
2603
-                    ? $REG->attendee()->full_name()
2604
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2605
-                $overwrite_msgs = true;
2606
-                EE_Error::add_error(
2607
-                    sprintf(
2608
-                        esc_html__(
2609
-                            '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.',
2610
-                            'event_espresso'
2611
-                        ),
2612
-                        $name
2613
-                    ),
2614
-                    __FILE__,
2615
-                    __FUNCTION__,
2616
-                    __LINE__
2617
-                );
2618
-                // can't trash this registration because it has payments.
2619
-                continue;
2620
-            }
2621
-            $updated = $trash ? $REG->delete() : $REG->restore();
2622
-            if ($updated) {
2623
-                $success++;
2624
-            }
2625
-        }
2626
-        $this->_redirect_after_action(
2627
-            $success === $reg_count, // were ALL registrations affected?
2628
-            $success > 1
2629
-                ? esc_html__('Registrations', 'event_espresso')
2630
-                : esc_html__('Registration', 'event_espresso'),
2631
-            $trash
2632
-                ? esc_html__('moved to the trash', 'event_espresso')
2633
-                : esc_html__('restored', 'event_espresso'),
2634
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2635
-            $overwrite_msgs
2636
-        );
2637
-    }
2638
-
2639
-
2640
-    /**
2641
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2642
-     * registration but also.
2643
-     * 1. Removing relations to EE_Attendee
2644
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2645
-     * ALSO trashed.
2646
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2647
-     * 4. Removing relationships between all tickets and the related registrations
2648
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2649
-     * 6. Deleting permanently any related Checkins.
2650
-     *
2651
-     * @return void
2652
-     * @throws EE_Error
2653
-     * @throws InvalidArgumentException
2654
-     * @throws InvalidDataTypeException
2655
-     * @throws InvalidInterfaceException
2656
-     * @throws ReflectionException
2657
-     */
2658
-    protected function _delete_registrations()
2659
-    {
2660
-        $REG_MDL = $this->getRegistrationModel();
2661
-        $success = 0;
2662
-        // Checkboxes
2663
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664
-
2665
-        if (! empty($REG_IDs)) {
2666
-            // if array has more than one element than success message should be plural
2667
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2668
-            // cycle thru checkboxes
2669
-            foreach ($REG_IDs as $REG_ID) {
2670
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
-                if (! $REG instanceof EE_Registration) {
2672
-                    continue;
2673
-                }
2674
-                $deleted = $this->_delete_registration($REG);
2675
-                if (! $deleted) {
2676
-                    $success = 0;
2677
-                }
2678
-            }
2679
-        }
2680
-
2681
-        $what        = $success > 1
2682
-            ? esc_html__('Registrations', 'event_espresso')
2683
-            : esc_html__('Registration', 'event_espresso');
2684
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2685
-        $this->_redirect_after_action(
2686
-            $success,
2687
-            $what,
2688
-            $action_desc,
2689
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2690
-            true
2691
-        );
2692
-    }
2693
-
2694
-
2695
-    /**
2696
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2697
-     * models get affected.
2698
-     *
2699
-     * @param EE_Registration $REG registration to be deleted permanently
2700
-     * @return bool true = successful deletion, false = fail.
2701
-     * @throws EE_Error
2702
-     * @throws InvalidArgumentException
2703
-     * @throws InvalidDataTypeException
2704
-     * @throws InvalidInterfaceException
2705
-     * @throws ReflectionException
2706
-     */
2707
-    protected function _delete_registration(EE_Registration $REG)
2708
-    {
2709
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710
-        // registrations on the transaction that are NOT trashed.
2711
-        $TXN = $REG->get_first_related('Transaction');
2712
-        if (! $TXN instanceof EE_Transaction) {
2713
-            EE_Error::add_error(
2714
-                sprintf(
2715
-                    esc_html__(
2716
-                        '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.',
2717
-                        'event_espresso'
2718
-                    ),
2719
-                    $REG->id()
2720
-                ),
2721
-                __FILE__,
2722
-                __FUNCTION__,
2723
-                __LINE__
2724
-            );
2725
-            return false;
2726
-        }
2727
-        $REGS        = $TXN->get_many_related('Registration');
2728
-        $all_trashed = true;
2729
-        foreach ($REGS as $registration) {
2730
-            if (! $registration->get('REG_deleted')) {
2731
-                $all_trashed = false;
2732
-            }
2733
-        }
2734
-        if (! $all_trashed) {
2735
-            EE_Error::add_error(
2736
-                esc_html__(
2737
-                    '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.',
2738
-                    'event_espresso'
2739
-                ),
2740
-                __FILE__,
2741
-                __FUNCTION__,
2742
-                __LINE__
2743
-            );
2744
-            return false;
2745
-        }
2746
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2747
-        // separately from THIS one).
2748
-        foreach ($REGS as $registration) {
2749
-            // delete related answers
2750
-            $registration->delete_related_permanently('Answer');
2751
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2752
-            $attendee = $registration->get_first_related('Attendee');
2753
-            if ($attendee instanceof EE_Attendee) {
2754
-                $registration->_remove_relation_to($attendee, 'Attendee');
2755
-            }
2756
-            // now remove relationships to tickets on this registration.
2757
-            $registration->_remove_relations('Ticket');
2758
-            // now delete permanently the checkins related to this registration.
2759
-            $registration->delete_related_permanently('Checkin');
2760
-            if ($registration->ID() === $REG->ID()) {
2761
-                continue;
2762
-            } //we don't want to delete permanently the existing registration just yet.
2763
-            // remove relation to transaction for these registrations if NOT the existing registrations
2764
-            $registration->_remove_relations('Transaction');
2765
-            // delete permanently any related messages.
2766
-            $registration->delete_related_permanently('Message');
2767
-            // now delete this registration permanently
2768
-            $registration->delete_permanently();
2769
-        }
2770
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2771
-        // (the transaction and line items should be all that's left).
2772
-        // delete the line items related to the transaction for this registration.
2773
-        $TXN->delete_related_permanently('Line_Item');
2774
-        // we need to remove all the relationships on the transaction
2775
-        $TXN->delete_related_permanently('Payment');
2776
-        $TXN->delete_related_permanently('Extra_Meta');
2777
-        $TXN->delete_related_permanently('Message');
2778
-        // now we can delete this REG permanently (and the transaction of course)
2779
-        $REG->delete_related_permanently('Transaction');
2780
-        return $REG->delete_permanently();
2781
-    }
2782
-
2783
-
2784
-    /**
2785
-     *    generates HTML for the Register New Attendee Admin page
2786
-     *
2787
-     * @throws DomainException
2788
-     * @throws EE_Error
2789
-     * @throws InvalidArgumentException
2790
-     * @throws InvalidDataTypeException
2791
-     * @throws InvalidInterfaceException
2792
-     * @throws ReflectionException
2793
-     */
2794
-    public function new_registration()
2795
-    {
2796
-        if (! $this->_set_reg_event()) {
2797
-            throw new EE_Error(
2798
-                esc_html__(
2799
-                    'Unable to continue with registering because there is no Event ID in the request',
2800
-                    'event_espresso'
2801
-                )
2802
-            );
2803
-        }
2804
-        /** @var CurrentPage $current_page */
2805
-        $current_page = $this->loader->getShared(CurrentPage::class);
2806
-        $current_page->setEspressoPage(true);
2807
-        // gotta start with a clean slate if we're not coming here via ajax
2808
-        if (
2809
-            ! $this->request->isAjax()
2810
-            && (
2811
-                ! $this->request->requestParamIsSet('processing_registration')
2812
-                || $this->request->requestParamIsSet('step_error')
2813
-            )
2814
-        ) {
2815
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2816
-        }
2817
-        $this->_template_args['event_name'] = '';
2818
-        // event name
2819
-        if ($this->_reg_event) {
2820
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2821
-            $edit_event_url                     = self::add_query_args_and_nonce(
2822
-                [
2823
-                    'action' => 'edit',
2824
-                    'post'   => $this->_reg_event->ID(),
2825
-                ],
2826
-                EVENTS_ADMIN_URL
2827
-            );
2828
-            $edit_event_lnk                     = '<a href="'
2829
-                                                  . $edit_event_url
2830
-                                                  . '" title="'
2831
-                                                  . esc_attr__('Edit ', 'event_espresso')
2832
-                                                  . $this->_reg_event->name()
2833
-                                                  . '">'
2834
-                                                  . esc_html__('Edit Event', 'event_espresso')
2835
-                                                  . '</a>';
2836
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2837
-                                                   . $edit_event_lnk
2838
-                                                   . '</span>';
2839
-        }
2840
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2841
-        if ($this->request->isAjax()) {
2842
-            $this->_return_json();
2843
-        }
2844
-        // grab header
2845
-        $template_path                              =
2846
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2847
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848
-            $template_path,
2849
-            $this->_template_args,
2850
-            true
2851
-        );
2852
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2853
-        // the details template wrapper
2854
-        $this->display_admin_page_with_sidebar();
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     * This returns the content for a registration step
2860
-     *
2861
-     * @return string html
2862
-     * @throws DomainException
2863
-     * @throws EE_Error
2864
-     * @throws InvalidArgumentException
2865
-     * @throws InvalidDataTypeException
2866
-     * @throws InvalidInterfaceException
2867
-     * @throws ReflectionException
2868
-     */
2869
-    protected function _get_registration_step_content()
2870
-    {
2871
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2872
-            $warning_msg = sprintf(
2873
-                esc_html__(
2874
-                    '%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',
2875
-                    'event_espresso'
2876
-                ),
2877
-                '<br />',
2878
-                '<h3 class="important-notice">',
2879
-                '</h3>',
2880
-                '<div class="float-right">',
2881
-                '<span id="redirect_timer" class="important-notice">30</span>',
2882
-                '</div>',
2883
-                '<b>',
2884
-                '</b>'
2885
-            );
2886
-            return '
2306
+	}
2307
+
2308
+
2309
+	/**
2310
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2311
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2312
+	 * to display the page
2313
+	 *
2314
+	 * @return void
2315
+	 * @throws EE_Error
2316
+	 * @throws InvalidArgumentException
2317
+	 * @throws InvalidDataTypeException
2318
+	 * @throws InvalidInterfaceException
2319
+	 * @throws ReflectionException
2320
+	 */
2321
+	protected function _update_attendee_registration_form()
2322
+	{
2323
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2324
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2325
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2326
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2327
+			if ($success) {
2328
+				$what  = esc_html__('Registration Form', 'event_espresso');
2329
+				$route = $REG_ID
2330
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2331
+					: ['action' => 'default'];
2332
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2333
+			}
2334
+		}
2335
+	}
2336
+
2337
+
2338
+	/**
2339
+	 * Gets the form for saving registrations custom questions (if done
2340
+	 * previously retrieves the cached form object, which may have validation errors in it)
2341
+	 *
2342
+	 * @param int $REG_ID
2343
+	 * @return EE_Registration_Custom_Questions_Form
2344
+	 * @throws EE_Error
2345
+	 * @throws InvalidArgumentException
2346
+	 * @throws InvalidDataTypeException
2347
+	 * @throws InvalidInterfaceException
2348
+	 * @throws ReflectionException
2349
+	 */
2350
+	protected function _get_reg_custom_questions_form($REG_ID)
2351
+	{
2352
+		if (! $this->_reg_custom_questions_form) {
2353
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356
+			);
2357
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2358
+		}
2359
+		return $this->_reg_custom_questions_form;
2360
+	}
2361
+
2362
+
2363
+	/**
2364
+	 * Saves
2365
+	 *
2366
+	 * @param bool $REG_ID
2367
+	 * @return bool
2368
+	 * @throws EE_Error
2369
+	 * @throws InvalidArgumentException
2370
+	 * @throws InvalidDataTypeException
2371
+	 * @throws InvalidInterfaceException
2372
+	 * @throws ReflectionException
2373
+	 */
2374
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2375
+	{
2376
+		if (! $REG_ID) {
2377
+			EE_Error::add_error(
2378
+				esc_html__(
2379
+					'An error occurred. No registration ID was received.',
2380
+					'event_espresso'
2381
+				),
2382
+				__FILE__,
2383
+				__FUNCTION__,
2384
+				__LINE__
2385
+			);
2386
+		}
2387
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2388
+		$form->receive_form_submission($this->request->requestParams());
2389
+		$success = false;
2390
+		if ($form->is_valid()) {
2391
+			foreach ($form->subforms() as $question_group_form) {
2392
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2393
+					$where_conditions    = [
2394
+						'QST_ID' => $question_id,
2395
+						'REG_ID' => $REG_ID,
2396
+					];
2397
+					$possibly_new_values = [
2398
+						'ANS_value' => $input->normalized_value(),
2399
+					];
2400
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2401
+					if ($answer instanceof EE_Answer) {
2402
+						$success = $answer->save($possibly_new_values);
2403
+					} else {
2404
+						// insert it then
2405
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2406
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2407
+						$success     = $answer->save();
2408
+					}
2409
+				}
2410
+			}
2411
+		} else {
2412
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2413
+		}
2414
+		return $success;
2415
+	}
2416
+
2417
+
2418
+	/**
2419
+	 * generates HTML for the Registration main meta box
2420
+	 *
2421
+	 * @return void
2422
+	 * @throws DomainException
2423
+	 * @throws EE_Error
2424
+	 * @throws InvalidArgumentException
2425
+	 * @throws InvalidDataTypeException
2426
+	 * @throws InvalidInterfaceException
2427
+	 * @throws ReflectionException
2428
+	 */
2429
+	public function _reg_attendees_meta_box()
2430
+	{
2431
+		$REG = $this->getRegistrationModel();
2432
+		// get all other registrations on this transaction, and cache
2433
+		// the attendees for them so we don't have to run another query using force_join
2434
+		$registrations                           = $REG->get_all(
2435
+			[
2436
+				[
2437
+					'TXN_ID' => $this->_registration->transaction_ID(),
2438
+					'REG_ID' => ['!=', $this->_registration->ID()],
2439
+				],
2440
+				'force_join'               => ['Attendee'],
2441
+				'default_where_conditions' => 'other_models_only',
2442
+			]
2443
+		);
2444
+		$this->_template_args['attendees']       = [];
2445
+		$this->_template_args['attendee_notice'] = '';
2446
+		if (
2447
+			empty($registrations)
2448
+			|| (is_array($registrations)
2449
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2450
+		) {
2451
+			EE_Error::add_error(
2452
+				esc_html__(
2453
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2454
+					'event_espresso'
2455
+				),
2456
+				__FILE__,
2457
+				__FUNCTION__,
2458
+				__LINE__
2459
+			);
2460
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2461
+		} else {
2462
+			$att_nmbr = 1;
2463
+			foreach ($registrations as $registration) {
2464
+				/* @var $registration EE_Registration */
2465
+				$attendee                                                      = $registration->attendee()
2466
+					? $registration->attendee()
2467
+					: $this->getAttendeeModel()->create_default_object();
2468
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2474
+					', ',
2475
+					$attendee->full_address_as_array()
2476
+				);
2477
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2478
+					[
2479
+						'action' => 'edit_attendee',
2480
+						'post'   => $attendee->ID(),
2481
+					],
2482
+					REG_ADMIN_URL
2483
+				);
2484
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2485
+					$registration->event_obj() instanceof EE_Event
2486
+						? $registration->event_obj()->name()
2487
+						: '';
2488
+				$att_nmbr++;
2489
+			}
2490
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491
+		}
2492
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2493
+		EEH_Template::display_template($template_path, $this->_template_args);
2494
+	}
2495
+
2496
+
2497
+	/**
2498
+	 * generates HTML for the Edit Registration side meta box
2499
+	 *
2500
+	 * @return void
2501
+	 * @throws DomainException
2502
+	 * @throws EE_Error
2503
+	 * @throws InvalidArgumentException
2504
+	 * @throws InvalidDataTypeException
2505
+	 * @throws InvalidInterfaceException
2506
+	 * @throws ReflectionException
2507
+	 */
2508
+	public function _reg_registrant_side_meta_box()
2509
+	{
2510
+		/*@var $attendee EE_Attendee */
2511
+		$att_check = $this->_registration->attendee();
2512
+		$attendee  = $att_check instanceof EE_Attendee
2513
+			? $att_check
2514
+			: $this->getAttendeeModel()->create_default_object();
2515
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2516
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517
+		// primary registration object (that way we know if we need to show create button or not)
2518
+		if (! $this->_registration->is_primary_registrant()) {
2519
+			$primary_registration = $this->_registration->get_primary_registration();
2520
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521
+				: null;
2522
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524
+				// custom attendee object so let's not worry about the primary reg.
2525
+				$primary_registration = null;
2526
+			}
2527
+		} else {
2528
+			$primary_registration = null;
2529
+		}
2530
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2531
+		$this->_template_args['fname']             = $attendee->fname();
2532
+		$this->_template_args['lname']             = $attendee->lname();
2533
+		$this->_template_args['email']             = $attendee->email();
2534
+		$this->_template_args['phone']             = $attendee->phone();
2535
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536
+		// edit link
2537
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2538
+			[
2539
+				'action' => 'edit_attendee',
2540
+				'post'   => $attendee->ID(),
2541
+			],
2542
+			REG_ADMIN_URL
2543
+		);
2544
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545
+		// create link
2546
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2547
+			? EE_Admin_Page::add_query_args_and_nonce(
2548
+				[
2549
+					'action'  => 'duplicate_attendee',
2550
+					'_REG_ID' => $this->_registration->ID(),
2551
+				],
2552
+				REG_ADMIN_URL
2553
+			) : '';
2554
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555
+		$this->_template_args['att_check']    = $att_check;
2556
+		$template_path                        =
2557
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2558
+		EEH_Template::display_template($template_path, $this->_template_args);
2559
+	}
2560
+
2561
+
2562
+	/**
2563
+	 * trash or restore registrations
2564
+	 *
2565
+	 * @param boolean $trash whether to archive or restore
2566
+	 * @return void
2567
+	 * @throws EE_Error
2568
+	 * @throws InvalidArgumentException
2569
+	 * @throws InvalidDataTypeException
2570
+	 * @throws InvalidInterfaceException
2571
+	 * @throws RuntimeException
2572
+	 */
2573
+	protected function _trash_or_restore_registrations($trash = true)
2574
+	{
2575
+		// if empty _REG_ID then get out because there's nothing to do
2576
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2577
+		if (empty($REG_IDs)) {
2578
+			EE_Error::add_error(
2579
+				sprintf(
2580
+					esc_html__(
2581
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2582
+						'event_espresso'
2583
+					),
2584
+					$trash ? 'trash' : 'restore'
2585
+				),
2586
+				__FILE__,
2587
+				__LINE__,
2588
+				__FUNCTION__
2589
+			);
2590
+			$this->_redirect_after_action(false, '', '', [], true);
2591
+		}
2592
+		$success        = 0;
2593
+		$overwrite_msgs = false;
2594
+		// Checkboxes
2595
+		$reg_count = count($REG_IDs);
2596
+		// cycle thru checkboxes
2597
+		foreach ($REG_IDs as $REG_ID) {
2598
+			/** @var EE_Registration $REG */
2599
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600
+			$payments = $REG->registration_payments();
2601
+			if (! empty($payments)) {
2602
+				$name           = $REG->attendee() instanceof EE_Attendee
2603
+					? $REG->attendee()->full_name()
2604
+					: esc_html__('Unknown Attendee', 'event_espresso');
2605
+				$overwrite_msgs = true;
2606
+				EE_Error::add_error(
2607
+					sprintf(
2608
+						esc_html__(
2609
+							'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.',
2610
+							'event_espresso'
2611
+						),
2612
+						$name
2613
+					),
2614
+					__FILE__,
2615
+					__FUNCTION__,
2616
+					__LINE__
2617
+				);
2618
+				// can't trash this registration because it has payments.
2619
+				continue;
2620
+			}
2621
+			$updated = $trash ? $REG->delete() : $REG->restore();
2622
+			if ($updated) {
2623
+				$success++;
2624
+			}
2625
+		}
2626
+		$this->_redirect_after_action(
2627
+			$success === $reg_count, // were ALL registrations affected?
2628
+			$success > 1
2629
+				? esc_html__('Registrations', 'event_espresso')
2630
+				: esc_html__('Registration', 'event_espresso'),
2631
+			$trash
2632
+				? esc_html__('moved to the trash', 'event_espresso')
2633
+				: esc_html__('restored', 'event_espresso'),
2634
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2635
+			$overwrite_msgs
2636
+		);
2637
+	}
2638
+
2639
+
2640
+	/**
2641
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2642
+	 * registration but also.
2643
+	 * 1. Removing relations to EE_Attendee
2644
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2645
+	 * ALSO trashed.
2646
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2647
+	 * 4. Removing relationships between all tickets and the related registrations
2648
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2649
+	 * 6. Deleting permanently any related Checkins.
2650
+	 *
2651
+	 * @return void
2652
+	 * @throws EE_Error
2653
+	 * @throws InvalidArgumentException
2654
+	 * @throws InvalidDataTypeException
2655
+	 * @throws InvalidInterfaceException
2656
+	 * @throws ReflectionException
2657
+	 */
2658
+	protected function _delete_registrations()
2659
+	{
2660
+		$REG_MDL = $this->getRegistrationModel();
2661
+		$success = 0;
2662
+		// Checkboxes
2663
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664
+
2665
+		if (! empty($REG_IDs)) {
2666
+			// if array has more than one element than success message should be plural
2667
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2668
+			// cycle thru checkboxes
2669
+			foreach ($REG_IDs as $REG_ID) {
2670
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
+				if (! $REG instanceof EE_Registration) {
2672
+					continue;
2673
+				}
2674
+				$deleted = $this->_delete_registration($REG);
2675
+				if (! $deleted) {
2676
+					$success = 0;
2677
+				}
2678
+			}
2679
+		}
2680
+
2681
+		$what        = $success > 1
2682
+			? esc_html__('Registrations', 'event_espresso')
2683
+			: esc_html__('Registration', 'event_espresso');
2684
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2685
+		$this->_redirect_after_action(
2686
+			$success,
2687
+			$what,
2688
+			$action_desc,
2689
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2690
+			true
2691
+		);
2692
+	}
2693
+
2694
+
2695
+	/**
2696
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2697
+	 * models get affected.
2698
+	 *
2699
+	 * @param EE_Registration $REG registration to be deleted permanently
2700
+	 * @return bool true = successful deletion, false = fail.
2701
+	 * @throws EE_Error
2702
+	 * @throws InvalidArgumentException
2703
+	 * @throws InvalidDataTypeException
2704
+	 * @throws InvalidInterfaceException
2705
+	 * @throws ReflectionException
2706
+	 */
2707
+	protected function _delete_registration(EE_Registration $REG)
2708
+	{
2709
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710
+		// registrations on the transaction that are NOT trashed.
2711
+		$TXN = $REG->get_first_related('Transaction');
2712
+		if (! $TXN instanceof EE_Transaction) {
2713
+			EE_Error::add_error(
2714
+				sprintf(
2715
+					esc_html__(
2716
+						'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.',
2717
+						'event_espresso'
2718
+					),
2719
+					$REG->id()
2720
+				),
2721
+				__FILE__,
2722
+				__FUNCTION__,
2723
+				__LINE__
2724
+			);
2725
+			return false;
2726
+		}
2727
+		$REGS        = $TXN->get_many_related('Registration');
2728
+		$all_trashed = true;
2729
+		foreach ($REGS as $registration) {
2730
+			if (! $registration->get('REG_deleted')) {
2731
+				$all_trashed = false;
2732
+			}
2733
+		}
2734
+		if (! $all_trashed) {
2735
+			EE_Error::add_error(
2736
+				esc_html__(
2737
+					'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.',
2738
+					'event_espresso'
2739
+				),
2740
+				__FILE__,
2741
+				__FUNCTION__,
2742
+				__LINE__
2743
+			);
2744
+			return false;
2745
+		}
2746
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2747
+		// separately from THIS one).
2748
+		foreach ($REGS as $registration) {
2749
+			// delete related answers
2750
+			$registration->delete_related_permanently('Answer');
2751
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2752
+			$attendee = $registration->get_first_related('Attendee');
2753
+			if ($attendee instanceof EE_Attendee) {
2754
+				$registration->_remove_relation_to($attendee, 'Attendee');
2755
+			}
2756
+			// now remove relationships to tickets on this registration.
2757
+			$registration->_remove_relations('Ticket');
2758
+			// now delete permanently the checkins related to this registration.
2759
+			$registration->delete_related_permanently('Checkin');
2760
+			if ($registration->ID() === $REG->ID()) {
2761
+				continue;
2762
+			} //we don't want to delete permanently the existing registration just yet.
2763
+			// remove relation to transaction for these registrations if NOT the existing registrations
2764
+			$registration->_remove_relations('Transaction');
2765
+			// delete permanently any related messages.
2766
+			$registration->delete_related_permanently('Message');
2767
+			// now delete this registration permanently
2768
+			$registration->delete_permanently();
2769
+		}
2770
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2771
+		// (the transaction and line items should be all that's left).
2772
+		// delete the line items related to the transaction for this registration.
2773
+		$TXN->delete_related_permanently('Line_Item');
2774
+		// we need to remove all the relationships on the transaction
2775
+		$TXN->delete_related_permanently('Payment');
2776
+		$TXN->delete_related_permanently('Extra_Meta');
2777
+		$TXN->delete_related_permanently('Message');
2778
+		// now we can delete this REG permanently (and the transaction of course)
2779
+		$REG->delete_related_permanently('Transaction');
2780
+		return $REG->delete_permanently();
2781
+	}
2782
+
2783
+
2784
+	/**
2785
+	 *    generates HTML for the Register New Attendee Admin page
2786
+	 *
2787
+	 * @throws DomainException
2788
+	 * @throws EE_Error
2789
+	 * @throws InvalidArgumentException
2790
+	 * @throws InvalidDataTypeException
2791
+	 * @throws InvalidInterfaceException
2792
+	 * @throws ReflectionException
2793
+	 */
2794
+	public function new_registration()
2795
+	{
2796
+		if (! $this->_set_reg_event()) {
2797
+			throw new EE_Error(
2798
+				esc_html__(
2799
+					'Unable to continue with registering because there is no Event ID in the request',
2800
+					'event_espresso'
2801
+				)
2802
+			);
2803
+		}
2804
+		/** @var CurrentPage $current_page */
2805
+		$current_page = $this->loader->getShared(CurrentPage::class);
2806
+		$current_page->setEspressoPage(true);
2807
+		// gotta start with a clean slate if we're not coming here via ajax
2808
+		if (
2809
+			! $this->request->isAjax()
2810
+			&& (
2811
+				! $this->request->requestParamIsSet('processing_registration')
2812
+				|| $this->request->requestParamIsSet('step_error')
2813
+			)
2814
+		) {
2815
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2816
+		}
2817
+		$this->_template_args['event_name'] = '';
2818
+		// event name
2819
+		if ($this->_reg_event) {
2820
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2821
+			$edit_event_url                     = self::add_query_args_and_nonce(
2822
+				[
2823
+					'action' => 'edit',
2824
+					'post'   => $this->_reg_event->ID(),
2825
+				],
2826
+				EVENTS_ADMIN_URL
2827
+			);
2828
+			$edit_event_lnk                     = '<a href="'
2829
+												  . $edit_event_url
2830
+												  . '" title="'
2831
+												  . esc_attr__('Edit ', 'event_espresso')
2832
+												  . $this->_reg_event->name()
2833
+												  . '">'
2834
+												  . esc_html__('Edit Event', 'event_espresso')
2835
+												  . '</a>';
2836
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2837
+												   . $edit_event_lnk
2838
+												   . '</span>';
2839
+		}
2840
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2841
+		if ($this->request->isAjax()) {
2842
+			$this->_return_json();
2843
+		}
2844
+		// grab header
2845
+		$template_path                              =
2846
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2847
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848
+			$template_path,
2849
+			$this->_template_args,
2850
+			true
2851
+		);
2852
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2853
+		// the details template wrapper
2854
+		$this->display_admin_page_with_sidebar();
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 * This returns the content for a registration step
2860
+	 *
2861
+	 * @return string html
2862
+	 * @throws DomainException
2863
+	 * @throws EE_Error
2864
+	 * @throws InvalidArgumentException
2865
+	 * @throws InvalidDataTypeException
2866
+	 * @throws InvalidInterfaceException
2867
+	 * @throws ReflectionException
2868
+	 */
2869
+	protected function _get_registration_step_content()
2870
+	{
2871
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2872
+			$warning_msg = sprintf(
2873
+				esc_html__(
2874
+					'%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',
2875
+					'event_espresso'
2876
+				),
2877
+				'<br />',
2878
+				'<h3 class="important-notice">',
2879
+				'</h3>',
2880
+				'<div class="float-right">',
2881
+				'<span id="redirect_timer" class="important-notice">30</span>',
2882
+				'</div>',
2883
+				'<b>',
2884
+				'</b>'
2885
+			);
2886
+			return '
2887 2887
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2888 2888
 	<script >
2889 2889
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2896,851 +2896,851 @@  discard block
 block discarded – undo
2896 2896
 	        }
2897 2897
 	    }, 800 );
2898 2898
 	</script >';
2899
-        }
2900
-        $template_args = [
2901
-            'title'                    => '',
2902
-            'content'                  => '',
2903
-            'step_button_text'         => '',
2904
-            'show_notification_toggle' => false,
2905
-        ];
2906
-        // to indicate we're processing a new registration
2907
-        $hidden_fields = [
2908
-            'processing_registration' => [
2909
-                'type'  => 'hidden',
2910
-                'value' => 0,
2911
-            ],
2912
-            'event_id'                => [
2913
-                'type'  => 'hidden',
2914
-                'value' => $this->_reg_event->ID(),
2915
-            ],
2916
-        ];
2917
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2918
-        $cart = EE_Registry::instance()->SSN->cart();
2919
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2920
-        switch ($step) {
2921
-            case 'ticket':
2922
-                $hidden_fields['processing_registration']['value'] = 1;
2923
-                $template_args['title']                            = esc_html__(
2924
-                    'Step One: Select the Ticket for this registration',
2925
-                    'event_espresso'
2926
-                );
2927
-                $template_args['content']                          =
2928
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
-                $template_args['content']                          .= '</div>';
2930
-                $template_args['step_button_text']                 = esc_html__(
2931
-                    'Add Tickets and Continue to Registrant Details',
2932
-                    'event_espresso'
2933
-                );
2934
-                $template_args['show_notification_toggle']         = false;
2935
-                break;
2936
-            case 'questions':
2937
-                $hidden_fields['processing_registration']['value'] = 2;
2938
-                $template_args['title']                            = esc_html__(
2939
-                    'Step Two: Add Registrant Details for this Registration',
2940
-                    'event_espresso'
2941
-                );
2942
-                // in theory, we should be able to run EED_SPCO at this point
2943
-                // because the cart should have been set up properly by the first process_reg_step run.
2944
-                $template_args['content']                  =
2945
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2946
-                $template_args['step_button_text']         = esc_html__(
2947
-                    'Save Registration and Continue to Details',
2948
-                    'event_espresso'
2949
-                );
2950
-                $template_args['show_notification_toggle'] = true;
2951
-                break;
2952
-        }
2953
-        // we come back to the process_registration_step route.
2954
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955
-        return EEH_Template::display_template(
2956
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2957
-            $template_args,
2958
-            true
2959
-        );
2960
-    }
2961
-
2962
-
2963
-    /**
2964
-     * set_reg_event
2965
-     *
2966
-     * @return bool
2967
-     * @throws EE_Error
2968
-     * @throws InvalidArgumentException
2969
-     * @throws InvalidDataTypeException
2970
-     * @throws InvalidInterfaceException
2971
-     */
2972
-    private function _set_reg_event()
2973
-    {
2974
-        if (is_object($this->_reg_event)) {
2975
-            return true;
2976
-        }
2977
-
2978
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2979
-        if (! $EVT_ID) {
2980
-            return false;
2981
-        }
2982
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2983
-        return true;
2984
-    }
2985
-
2986
-
2987
-    /**
2988
-     * process_reg_step
2989
-     *
2990
-     * @return void
2991
-     * @throws DomainException
2992
-     * @throws EE_Error
2993
-     * @throws InvalidArgumentException
2994
-     * @throws InvalidDataTypeException
2995
-     * @throws InvalidInterfaceException
2996
-     * @throws ReflectionException
2997
-     * @throws RuntimeException
2998
-     */
2999
-    public function process_reg_step()
3000
-    {
3001
-        EE_System::do_not_cache();
3002
-        $this->_set_reg_event();
3003
-        /** @var CurrentPage $current_page */
3004
-        $current_page = $this->loader->getShared(CurrentPage::class);
3005
-        $current_page->setEspressoPage(true);
3006
-        $this->request->setRequestParam('uts', time());
3007
-        // what step are we on?
3008
-        $cart = EE_Registry::instance()->SSN->cart();
3009
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3010
-        // if doing ajax then we need to verify the nonce
3011
-        if ($this->request->isAjax()) {
3012
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3013
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3014
-        }
3015
-        switch ($step) {
3016
-            case 'ticket':
3017
-                // process ticket selection
3018
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3019
-                if ($success) {
3020
-                    EE_Error::add_success(
3021
-                        esc_html__(
3022
-                            'Tickets Selected. Now complete the registration.',
3023
-                            'event_espresso'
3024
-                        )
3025
-                    );
3026
-                } else {
3027
-                    $this->request->setRequestParam('step_error', true);
3028
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3029
-                }
3030
-                if ($this->request->isAjax()) {
3031
-                    $this->new_registration(); // display next step
3032
-                } else {
3033
-                    $query_args = [
3034
-                        'action'                  => 'new_registration',
3035
-                        'processing_registration' => 1,
3036
-                        'event_id'                => $this->_reg_event->ID(),
3037
-                        'uts'                     => time(),
3038
-                    ];
3039
-                    $this->_redirect_after_action(
3040
-                        false,
3041
-                        '',
3042
-                        '',
3043
-                        $query_args,
3044
-                        true
3045
-                    );
3046
-                }
3047
-                break;
3048
-            case 'questions':
3049
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051
-                }
3052
-                // process registration
3053
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3054
-                if ($cart instanceof EE_Cart) {
3055
-                    $grand_total = $cart->get_grand_total();
3056
-                    if ($grand_total instanceof EE_Line_Item) {
3057
-                        $grand_total->save_this_and_descendants_to_txn();
3058
-                    }
3059
-                }
3060
-                if (! $transaction instanceof EE_Transaction) {
3061
-                    $query_args = [
3062
-                        'action'                  => 'new_registration',
3063
-                        'processing_registration' => 2,
3064
-                        'event_id'                => $this->_reg_event->ID(),
3065
-                        'uts'                     => time(),
3066
-                    ];
3067
-                    if ($this->request->isAjax()) {
3068
-                        // display registration form again because there are errors (maybe validation?)
3069
-                        $this->new_registration();
3070
-                        return;
3071
-                    }
3072
-                    $this->_redirect_after_action(
3073
-                        false,
3074
-                        '',
3075
-                        '',
3076
-                        $query_args,
3077
-                        true
3078
-                    );
3079
-                    return;
3080
-                }
3081
-                // maybe update status, and make sure to save transaction if not done already
3082
-                if (! $transaction->update_status_based_on_total_paid()) {
3083
-                    $transaction->save();
3084
-                }
3085
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3086
-                $query_args = [
3087
-                    'action'        => 'redirect_to_txn',
3088
-                    'TXN_ID'        => $transaction->ID(),
3089
-                    'EVT_ID'        => $this->_reg_event->ID(),
3090
-                    'event_name'    => urlencode($this->_reg_event->name()),
3091
-                    'redirect_from' => 'new_registration',
3092
-                ];
3093
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3094
-                break;
3095
-        }
3096
-        // what are you looking here for?  Should be nothing to do at this point.
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * redirect_to_txn
3102
-     *
3103
-     * @return void
3104
-     * @throws EE_Error
3105
-     * @throws InvalidArgumentException
3106
-     * @throws InvalidDataTypeException
3107
-     * @throws InvalidInterfaceException
3108
-     * @throws ReflectionException
3109
-     */
3110
-    public function redirect_to_txn()
3111
-    {
3112
-        EE_System::do_not_cache();
3113
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3114
-        $query_args = [
3115
-            'action' => 'view_transaction',
3116
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3117
-            'page'   => 'espresso_transactions',
3118
-        ];
3119
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3120
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3121
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3122
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3123
-        }
3124
-        EE_Error::add_success(
3125
-            esc_html__(
3126
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3127
-                'event_espresso'
3128
-            )
3129
-        );
3130
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3131
-    }
3132
-
3133
-
3134
-    /**
3135
-     * generates HTML for the Attendee Contact List
3136
-     *
3137
-     * @return void
3138
-     * @throws DomainException
3139
-     * @throws EE_Error
3140
-     */
3141
-    protected function _attendee_contact_list_table()
3142
-    {
3143
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3144
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3145
-        $this->display_admin_list_table_page_with_no_sidebar();
3146
-    }
3147
-
3148
-
3149
-    /**
3150
-     * get_attendees
3151
-     *
3152
-     * @param      $per_page
3153
-     * @param bool $count whether to return count or data.
3154
-     * @param bool $trash
3155
-     * @return array|int
3156
-     * @throws EE_Error
3157
-     * @throws InvalidArgumentException
3158
-     * @throws InvalidDataTypeException
3159
-     * @throws InvalidInterfaceException
3160
-     */
3161
-    public function get_attendees($per_page, $count = false, $trash = false)
3162
-    {
3163
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3165
-        $orderby = $this->request->getRequestParam('orderby');
3166
-        switch ($orderby) {
3167
-            case 'ATT_ID':
3168
-            case 'ATT_fname':
3169
-            case 'ATT_email':
3170
-            case 'ATT_city':
3171
-            case 'STA_ID':
3172
-            case 'CNT_ID':
3173
-                break;
3174
-            case 'Registration_Count':
3175
-                $orderby = 'Registration_Count';
3176
-                break;
3177
-            default:
3178
-                $orderby = 'ATT_lname';
3179
-        }
3180
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3181
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3182
-        $per_page     = absint($per_page) ? $per_page : 10;
3183
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3184
-        $_where       = [];
3185
-        $search_term  = $this->request->getRequestParam('s');
3186
-        if ($search_term) {
3187
-            $search_term  = '%' . $search_term . '%';
3188
-            $_where['OR'] = [
3189
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3191
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3192
-                'ATT_fname'                         => ['LIKE', $search_term],
3193
-                'ATT_lname'                         => ['LIKE', $search_term],
3194
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3195
-                'ATT_email'                         => ['LIKE', $search_term],
3196
-                'ATT_address'                       => ['LIKE', $search_term],
3197
-                'ATT_address2'                      => ['LIKE', $search_term],
3198
-                'ATT_city'                          => ['LIKE', $search_term],
3199
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3200
-                'State.STA_name'                    => ['LIKE', $search_term],
3201
-                'ATT_phone'                         => ['LIKE', $search_term],
3202
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3203
-                'Registration.REG_code'             => ['LIKE', $search_term],
3204
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3205
-            ];
3206
-        }
3207
-        $offset     = ($current_page - 1) * $per_page;
3208
-        $limit      = $count ? null : [$offset, $per_page];
3209
-        $query_args = [
3210
-            $_where,
3211
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212
-            'limit'         => $limit,
3213
-        ];
3214
-        if (! $count) {
3215
-            $query_args['order_by'] = [$orderby => $sort];
3216
-        }
3217
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3218
-        return $count
3219
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3220
-            : $this->getAttendeeModel()->get_all($query_args);
3221
-    }
3222
-
3223
-
3224
-    /**
3225
-     * This is just taking care of resending the registration confirmation
3226
-     *
3227
-     * @return void
3228
-     * @throws EE_Error
3229
-     * @throws InvalidArgumentException
3230
-     * @throws InvalidDataTypeException
3231
-     * @throws InvalidInterfaceException
3232
-     * @throws ReflectionException
3233
-     */
3234
-    protected function _resend_registration()
3235
-    {
3236
-        $this->_process_resend_registration();
3237
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3238
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3239
-        $query_args  = $redirect_to
3240
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3241
-            : ['action' => 'default'];
3242
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3243
-    }
3244
-
3245
-
3246
-    /**
3247
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3248
-     * to use when selecting registrations
3249
-     *
3250
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3251
-     *                                                     the query parameters from the request
3252
-     * @return void ends the request with a redirect or download
3253
-     */
3254
-    public function _registrations_report_base($method_name_for_getting_query_params)
3255
-    {
3256
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258
-            : null;
3259
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260
-            $request_params = $this->request->requestParams();
3261
-            wp_redirect(
3262
-                EE_Admin_Page::add_query_args_and_nonce(
3263
-                    [
3264
-                        'page'        => 'espresso_batch',
3265
-                        'batch'       => 'file',
3266
-                        'EVT_ID'      => $EVT_ID,
3267
-                        'filters'     => urlencode(
3268
-                            serialize(
3269
-                                $this->$method_name_for_getting_query_params(
3270
-                                    EEH_Array::is_set($request_params, 'filters', [])
3271
-                                )
3272
-                            )
3273
-                        ),
3274
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3275
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3276
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3277
-                    ]
3278
-                )
3279
-            );
3280
-        } else {
3281
-            // Pull the current request params
3282
-            $request_args = $this->request->requestParams();
3283
-            // Set the required request_args to be passed to the export
3284
-            $required_request_args = [
3285
-                'export' => 'report',
3286
-                'action' => 'registrations_report_for_event',
3287
-                'EVT_ID' => $EVT_ID,
3288
-            ];
3289
-            // Merge required request args, overriding any currently set
3290
-            $request_args = array_merge($request_args, $required_request_args);
3291
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3292
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3293
-                $EE_Export = EE_Export::instance($request_args);
3294
-                $EE_Export->export();
3295
-            }
3296
-        }
3297
-    }
3298
-
3299
-
3300
-    /**
3301
-     * Creates a registration report using only query parameters in the request
3302
-     *
3303
-     * @return void
3304
-     */
3305
-    public function _registrations_report()
3306
-    {
3307
-        $this->_registrations_report_base('_get_registration_query_parameters');
3308
-    }
3309
-
3310
-
3311
-    public function _contact_list_export()
3312
-    {
3313
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3314
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3315
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3316
-            $EE_Export->export_attendees();
3317
-        }
3318
-    }
3319
-
3320
-
3321
-    public function _contact_list_report()
3322
-    {
3323
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3324
-            wp_redirect(
3325
-                EE_Admin_Page::add_query_args_and_nonce(
3326
-                    [
3327
-                        'page'        => 'espresso_batch',
3328
-                        'batch'       => 'file',
3329
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3330
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3331
-                    ]
3332
-                )
3333
-            );
3334
-        } else {
3335
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3336
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3337
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3338
-                $EE_Export->report_attendees();
3339
-            }
3340
-        }
3341
-    }
3342
-
3343
-
3344
-
3345
-
3346
-
3347
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3348
-    /**
3349
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3350
-     *
3351
-     * @return void
3352
-     * @throws EE_Error
3353
-     * @throws InvalidArgumentException
3354
-     * @throws InvalidDataTypeException
3355
-     * @throws InvalidInterfaceException
3356
-     * @throws ReflectionException
3357
-     */
3358
-    protected function _duplicate_attendee()
3359
-    {
3360
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3361
-        $action = $this->request->getRequestParam('return', 'default');
3362
-        // verify we have necessary info
3363
-        if (! $REG_ID) {
3364
-            EE_Error::add_error(
3365
-                esc_html__(
3366
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3367
-                    'event_espresso'
3368
-                ),
3369
-                __FILE__,
3370
-                __LINE__,
3371
-                __FUNCTION__
3372
-            );
3373
-            $query_args = ['action' => $action];
3374
-            $this->_redirect_after_action('', '', '', $query_args, true);
3375
-        }
3376
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3377
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3378
-        if (! $registration instanceof EE_Registration) {
3379
-            throw new RuntimeException(
3380
-                sprintf(
3381
-                    esc_html__(
3382
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3383
-                        'event_espresso'
3384
-                    ),
3385
-                    $REG_ID
3386
-                )
3387
-            );
3388
-        }
3389
-        $attendee = $registration->attendee();
3390
-        // remove relation of existing attendee on registration
3391
-        $registration->_remove_relation_to($attendee, 'Attendee');
3392
-        // new attendee
3393
-        $new_attendee = clone $attendee;
3394
-        $new_attendee->set('ATT_ID', 0);
3395
-        $new_attendee->save();
3396
-        // add new attendee to reg
3397
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3398
-        EE_Error::add_success(
3399
-            esc_html__(
3400
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3401
-                'event_espresso'
3402
-            )
3403
-        );
3404
-        // redirect to edit page for attendee
3405
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3406
-        $this->_redirect_after_action('', '', '', $query_args, true);
3407
-    }
3408
-
3409
-
3410
-    /**
3411
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3412
-     *
3413
-     * @param int     $post_id
3414
-     * @param WP_POST $post
3415
-     * @throws DomainException
3416
-     * @throws EE_Error
3417
-     * @throws InvalidArgumentException
3418
-     * @throws InvalidDataTypeException
3419
-     * @throws InvalidInterfaceException
3420
-     * @throws LogicException
3421
-     * @throws InvalidFormSubmissionException
3422
-     * @throws ReflectionException
3423
-     */
3424
-    protected function _insert_update_cpt_item($post_id, $post)
3425
-    {
3426
-        $success  = true;
3427
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3428
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3429
-            : null;
3430
-        // for attendee updates
3431
-        if ($attendee instanceof EE_Attendee) {
3432
-            // note we should only be UPDATING attendees at this point.
3433
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3434
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3435
-            $updated_fields = [
3436
-                'ATT_fname'     => $fname,
3437
-                'ATT_lname'     => $lname,
3438
-                'ATT_full_name' => "{$fname} {$lname}",
3439
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3440
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3441
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3442
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3443
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3444
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3445
-            ];
3446
-            foreach ($updated_fields as $field => $value) {
3447
-                $attendee->set($field, $value);
3448
-            }
3449
-
3450
-            // process contact details metabox form handler (which will also save the attendee)
3451
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3452
-            $success              = $contact_details_form->process($this->request->requestParams());
3453
-
3454
-            $attendee_update_callbacks = apply_filters(
3455
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3456
-                []
3457
-            );
3458
-            foreach ($attendee_update_callbacks as $a_callback) {
3459
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3460
-                    throw new EE_Error(
3461
-                        sprintf(
3462
-                            esc_html__(
3463
-                                '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.',
3464
-                                'event_espresso'
3465
-                            ),
3466
-                            $a_callback
3467
-                        )
3468
-                    );
3469
-                }
3470
-            }
3471
-        }
3472
-
3473
-        if ($success === false) {
3474
-            EE_Error::add_error(
3475
-                esc_html__(
3476
-                    'Something went wrong with updating the meta table data for the registration.',
3477
-                    'event_espresso'
3478
-                ),
3479
-                __FILE__,
3480
-                __FUNCTION__,
3481
-                __LINE__
3482
-            );
3483
-        }
3484
-    }
3485
-
3486
-
3487
-    public function trash_cpt_item($post_id)
3488
-    {
3489
-    }
3490
-
3491
-
3492
-    public function delete_cpt_item($post_id)
3493
-    {
3494
-    }
3495
-
3496
-
3497
-    public function restore_cpt_item($post_id)
3498
-    {
3499
-    }
3500
-
3501
-
3502
-    protected function _restore_cpt_item($post_id, $revision_id)
3503
-    {
3504
-    }
3505
-
3506
-
3507
-    /**
3508
-     * @throws EE_Error
3509
-     * @throws ReflectionException
3510
-     * @since 4.10.2.p
3511
-     */
3512
-    public function attendee_editor_metaboxes()
3513
-    {
3514
-        $this->verify_cpt_object();
3515
-        remove_meta_box(
3516
-            'postexcerpt',
3517
-            $this->_cpt_routes[ $this->_req_action ],
3518
-            'normal'
3519
-        );
3520
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3521
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3522
-            add_meta_box(
3523
-                'postexcerpt',
3524
-                esc_html__('Short Biography', 'event_espresso'),
3525
-                'post_excerpt_meta_box',
3526
-                $this->_cpt_routes[ $this->_req_action ],
3527
-                'normal'
3528
-            );
3529
-        }
3530
-        if (post_type_supports('espresso_attendees', 'comments')) {
3531
-            add_meta_box(
3532
-                'commentsdiv',
3533
-                esc_html__('Notes on the Contact', 'event_espresso'),
3534
-                'post_comment_meta_box',
3535
-                $this->_cpt_routes[ $this->_req_action ],
3536
-                'normal',
3537
-                'core'
3538
-            );
3539
-        }
3540
-        add_meta_box(
3541
-            'attendee_contact_info',
3542
-            esc_html__('Contact Info', 'event_espresso'),
3543
-            [$this, 'attendee_contact_info'],
3544
-            $this->_cpt_routes[ $this->_req_action ],
3545
-            'side',
3546
-            'core'
3547
-        );
3548
-        add_meta_box(
3549
-            'attendee_details_address',
3550
-            esc_html__('Address Details', 'event_espresso'),
3551
-            [$this, 'attendee_address_details'],
3552
-            $this->_cpt_routes[ $this->_req_action ],
3553
-            'normal',
3554
-            'core'
3555
-        );
3556
-        add_meta_box(
3557
-            'attendee_registrations',
3558
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3559
-            [$this, 'attendee_registrations_meta_box'],
3560
-            $this->_cpt_routes[ $this->_req_action ],
3561
-            'normal',
3562
-            'high'
3563
-        );
3564
-    }
3565
-
3566
-
3567
-    /**
3568
-     * Metabox for attendee contact info
3569
-     *
3570
-     * @param WP_Post $post wp post object
3571
-     * @return void attendee contact info ( and form )
3572
-     * @throws EE_Error
3573
-     * @throws InvalidArgumentException
3574
-     * @throws InvalidDataTypeException
3575
-     * @throws InvalidInterfaceException
3576
-     * @throws LogicException
3577
-     * @throws DomainException
3578
-     */
3579
-    public function attendee_contact_info($post)
3580
-    {
3581
-        // get attendee object ( should already have it )
3582
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3583
-        $form->enqueueStylesAndScripts();
3584
-        echo $form->display(); // already escaped
3585
-    }
3586
-
3587
-
3588
-    /**
3589
-     * Return form handler for the contact details metabox
3590
-     *
3591
-     * @param EE_Attendee $attendee
3592
-     * @return AttendeeContactDetailsMetaboxFormHandler
3593
-     * @throws DomainException
3594
-     * @throws InvalidArgumentException
3595
-     * @throws InvalidDataTypeException
3596
-     * @throws InvalidInterfaceException
3597
-     */
3598
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3599
-    {
3600
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3601
-    }
3602
-
3603
-
3604
-    /**
3605
-     * Metabox for attendee details
3606
-     *
3607
-     * @param WP_Post $post wp post object
3608
-     * @throws EE_Error
3609
-     * @throws ReflectionException
3610
-     */
3611
-    public function attendee_address_details($post)
3612
-    {
3613
-        // get attendee object (should already have it)
3614
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3615
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3616
-            new EE_Question_Form_Input(
3617
-                EE_Question::new_instance(
3618
-                    [
3619
-                        'QST_ID'           => 0,
3620
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3621
-                        'QST_system'       => 'admin-state',
3622
-                    ]
3623
-                ),
3624
-                EE_Answer::new_instance(
3625
-                    [
3626
-                        'ANS_ID'    => 0,
3627
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3628
-                    ]
3629
-                ),
3630
-                [
3631
-                    'input_id'       => 'STA_ID',
3632
-                    'input_name'     => 'STA_ID',
3633
-                    'input_prefix'   => '',
3634
-                    'append_qstn_id' => false,
3635
-                ]
3636
-            )
3637
-        );
3638
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3639
-            new EE_Question_Form_Input(
3640
-                EE_Question::new_instance(
3641
-                    [
3642
-                        'QST_ID'           => 0,
3643
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3644
-                        'QST_system'       => 'admin-country',
3645
-                    ]
3646
-                ),
3647
-                EE_Answer::new_instance(
3648
-                    [
3649
-                        'ANS_ID'    => 0,
3650
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3651
-                    ]
3652
-                ),
3653
-                [
3654
-                    'input_id'       => 'CNT_ISO',
3655
-                    'input_name'     => 'CNT_ISO',
3656
-                    'input_prefix'   => '',
3657
-                    'append_qstn_id' => false,
3658
-                ]
3659
-            )
3660
-        );
3661
-        $template                             =
3662
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3663
-        EEH_Template::display_template($template, $this->_template_args);
3664
-    }
3665
-
3666
-
3667
-    /**
3668
-     * _attendee_details
3669
-     *
3670
-     * @param $post
3671
-     * @return void
3672
-     * @throws DomainException
3673
-     * @throws EE_Error
3674
-     * @throws InvalidArgumentException
3675
-     * @throws InvalidDataTypeException
3676
-     * @throws InvalidInterfaceException
3677
-     * @throws ReflectionException
3678
-     */
3679
-    public function attendee_registrations_meta_box($post)
3680
-    {
3681
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3682
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3683
-        $template                              =
3684
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3685
-        EEH_Template::display_template($template, $this->_template_args);
3686
-    }
3687
-
3688
-
3689
-    /**
3690
-     * add in the form fields for the attendee edit
3691
-     *
3692
-     * @param WP_Post $post wp post object
3693
-     * @return void echos html for new form.
3694
-     * @throws DomainException
3695
-     */
3696
-    public function after_title_form_fields($post)
3697
-    {
3698
-        if ($post->post_type === 'espresso_attendees') {
3699
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3700
-            $template_args['attendee'] = $this->_cpt_model_obj;
3701
-            EEH_Template::display_template($template, $template_args);
3702
-        }
3703
-    }
3704
-
3705
-
3706
-    /**
3707
-     * _trash_or_restore_attendee
3708
-     *
3709
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3710
-     * @return void
3711
-     * @throws EE_Error
3712
-     * @throws InvalidArgumentException
3713
-     * @throws InvalidDataTypeException
3714
-     * @throws InvalidInterfaceException
3715
-     */
3716
-    protected function _trash_or_restore_attendees($trash = true)
3717
-    {
3718
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3719
-        $status = $trash ? 'trash' : 'publish';
3720
-        // Checkboxes
3721
-        if ($this->request->requestParamIsSet('checkbox')) {
3722
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3723
-            // if array has more than one element than success message should be plural
3724
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3725
-            // cycle thru checkboxes
3726
-            foreach ($ATT_IDs as $ATT_ID) {
3727
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3728
-                if (! $updated) {
3729
-                    $success = 0;
3730
-                }
3731
-            }
3732
-        } else {
3733
-            // grab single id and delete
3734
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3735
-            // update attendee
3736
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3737
-        }
3738
-        $what        = $success > 1
3739
-            ? esc_html__('Contacts', 'event_espresso')
3740
-            : esc_html__('Contact', 'event_espresso');
3741
-        $action_desc = $trash
3742
-            ? esc_html__('moved to the trash', 'event_espresso')
3743
-            : esc_html__('restored', 'event_espresso');
3744
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3745
-    }
2899
+		}
2900
+		$template_args = [
2901
+			'title'                    => '',
2902
+			'content'                  => '',
2903
+			'step_button_text'         => '',
2904
+			'show_notification_toggle' => false,
2905
+		];
2906
+		// to indicate we're processing a new registration
2907
+		$hidden_fields = [
2908
+			'processing_registration' => [
2909
+				'type'  => 'hidden',
2910
+				'value' => 0,
2911
+			],
2912
+			'event_id'                => [
2913
+				'type'  => 'hidden',
2914
+				'value' => $this->_reg_event->ID(),
2915
+			],
2916
+		];
2917
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2918
+		$cart = EE_Registry::instance()->SSN->cart();
2919
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2920
+		switch ($step) {
2921
+			case 'ticket':
2922
+				$hidden_fields['processing_registration']['value'] = 1;
2923
+				$template_args['title']                            = esc_html__(
2924
+					'Step One: Select the Ticket for this registration',
2925
+					'event_espresso'
2926
+				);
2927
+				$template_args['content']                          =
2928
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
+				$template_args['content']                          .= '</div>';
2930
+				$template_args['step_button_text']                 = esc_html__(
2931
+					'Add Tickets and Continue to Registrant Details',
2932
+					'event_espresso'
2933
+				);
2934
+				$template_args['show_notification_toggle']         = false;
2935
+				break;
2936
+			case 'questions':
2937
+				$hidden_fields['processing_registration']['value'] = 2;
2938
+				$template_args['title']                            = esc_html__(
2939
+					'Step Two: Add Registrant Details for this Registration',
2940
+					'event_espresso'
2941
+				);
2942
+				// in theory, we should be able to run EED_SPCO at this point
2943
+				// because the cart should have been set up properly by the first process_reg_step run.
2944
+				$template_args['content']                  =
2945
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2946
+				$template_args['step_button_text']         = esc_html__(
2947
+					'Save Registration and Continue to Details',
2948
+					'event_espresso'
2949
+				);
2950
+				$template_args['show_notification_toggle'] = true;
2951
+				break;
2952
+		}
2953
+		// we come back to the process_registration_step route.
2954
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955
+		return EEH_Template::display_template(
2956
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2957
+			$template_args,
2958
+			true
2959
+		);
2960
+	}
2961
+
2962
+
2963
+	/**
2964
+	 * set_reg_event
2965
+	 *
2966
+	 * @return bool
2967
+	 * @throws EE_Error
2968
+	 * @throws InvalidArgumentException
2969
+	 * @throws InvalidDataTypeException
2970
+	 * @throws InvalidInterfaceException
2971
+	 */
2972
+	private function _set_reg_event()
2973
+	{
2974
+		if (is_object($this->_reg_event)) {
2975
+			return true;
2976
+		}
2977
+
2978
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2979
+		if (! $EVT_ID) {
2980
+			return false;
2981
+		}
2982
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2983
+		return true;
2984
+	}
2985
+
2986
+
2987
+	/**
2988
+	 * process_reg_step
2989
+	 *
2990
+	 * @return void
2991
+	 * @throws DomainException
2992
+	 * @throws EE_Error
2993
+	 * @throws InvalidArgumentException
2994
+	 * @throws InvalidDataTypeException
2995
+	 * @throws InvalidInterfaceException
2996
+	 * @throws ReflectionException
2997
+	 * @throws RuntimeException
2998
+	 */
2999
+	public function process_reg_step()
3000
+	{
3001
+		EE_System::do_not_cache();
3002
+		$this->_set_reg_event();
3003
+		/** @var CurrentPage $current_page */
3004
+		$current_page = $this->loader->getShared(CurrentPage::class);
3005
+		$current_page->setEspressoPage(true);
3006
+		$this->request->setRequestParam('uts', time());
3007
+		// what step are we on?
3008
+		$cart = EE_Registry::instance()->SSN->cart();
3009
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3010
+		// if doing ajax then we need to verify the nonce
3011
+		if ($this->request->isAjax()) {
3012
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3013
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3014
+		}
3015
+		switch ($step) {
3016
+			case 'ticket':
3017
+				// process ticket selection
3018
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3019
+				if ($success) {
3020
+					EE_Error::add_success(
3021
+						esc_html__(
3022
+							'Tickets Selected. Now complete the registration.',
3023
+							'event_espresso'
3024
+						)
3025
+					);
3026
+				} else {
3027
+					$this->request->setRequestParam('step_error', true);
3028
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3029
+				}
3030
+				if ($this->request->isAjax()) {
3031
+					$this->new_registration(); // display next step
3032
+				} else {
3033
+					$query_args = [
3034
+						'action'                  => 'new_registration',
3035
+						'processing_registration' => 1,
3036
+						'event_id'                => $this->_reg_event->ID(),
3037
+						'uts'                     => time(),
3038
+					];
3039
+					$this->_redirect_after_action(
3040
+						false,
3041
+						'',
3042
+						'',
3043
+						$query_args,
3044
+						true
3045
+					);
3046
+				}
3047
+				break;
3048
+			case 'questions':
3049
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051
+				}
3052
+				// process registration
3053
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3054
+				if ($cart instanceof EE_Cart) {
3055
+					$grand_total = $cart->get_grand_total();
3056
+					if ($grand_total instanceof EE_Line_Item) {
3057
+						$grand_total->save_this_and_descendants_to_txn();
3058
+					}
3059
+				}
3060
+				if (! $transaction instanceof EE_Transaction) {
3061
+					$query_args = [
3062
+						'action'                  => 'new_registration',
3063
+						'processing_registration' => 2,
3064
+						'event_id'                => $this->_reg_event->ID(),
3065
+						'uts'                     => time(),
3066
+					];
3067
+					if ($this->request->isAjax()) {
3068
+						// display registration form again because there are errors (maybe validation?)
3069
+						$this->new_registration();
3070
+						return;
3071
+					}
3072
+					$this->_redirect_after_action(
3073
+						false,
3074
+						'',
3075
+						'',
3076
+						$query_args,
3077
+						true
3078
+					);
3079
+					return;
3080
+				}
3081
+				// maybe update status, and make sure to save transaction if not done already
3082
+				if (! $transaction->update_status_based_on_total_paid()) {
3083
+					$transaction->save();
3084
+				}
3085
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3086
+				$query_args = [
3087
+					'action'        => 'redirect_to_txn',
3088
+					'TXN_ID'        => $transaction->ID(),
3089
+					'EVT_ID'        => $this->_reg_event->ID(),
3090
+					'event_name'    => urlencode($this->_reg_event->name()),
3091
+					'redirect_from' => 'new_registration',
3092
+				];
3093
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3094
+				break;
3095
+		}
3096
+		// what are you looking here for?  Should be nothing to do at this point.
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * redirect_to_txn
3102
+	 *
3103
+	 * @return void
3104
+	 * @throws EE_Error
3105
+	 * @throws InvalidArgumentException
3106
+	 * @throws InvalidDataTypeException
3107
+	 * @throws InvalidInterfaceException
3108
+	 * @throws ReflectionException
3109
+	 */
3110
+	public function redirect_to_txn()
3111
+	{
3112
+		EE_System::do_not_cache();
3113
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3114
+		$query_args = [
3115
+			'action' => 'view_transaction',
3116
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3117
+			'page'   => 'espresso_transactions',
3118
+		];
3119
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3120
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3121
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3122
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3123
+		}
3124
+		EE_Error::add_success(
3125
+			esc_html__(
3126
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3127
+				'event_espresso'
3128
+			)
3129
+		);
3130
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3131
+	}
3132
+
3133
+
3134
+	/**
3135
+	 * generates HTML for the Attendee Contact List
3136
+	 *
3137
+	 * @return void
3138
+	 * @throws DomainException
3139
+	 * @throws EE_Error
3140
+	 */
3141
+	protected function _attendee_contact_list_table()
3142
+	{
3143
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3144
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3145
+		$this->display_admin_list_table_page_with_no_sidebar();
3146
+	}
3147
+
3148
+
3149
+	/**
3150
+	 * get_attendees
3151
+	 *
3152
+	 * @param      $per_page
3153
+	 * @param bool $count whether to return count or data.
3154
+	 * @param bool $trash
3155
+	 * @return array|int
3156
+	 * @throws EE_Error
3157
+	 * @throws InvalidArgumentException
3158
+	 * @throws InvalidDataTypeException
3159
+	 * @throws InvalidInterfaceException
3160
+	 */
3161
+	public function get_attendees($per_page, $count = false, $trash = false)
3162
+	{
3163
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3165
+		$orderby = $this->request->getRequestParam('orderby');
3166
+		switch ($orderby) {
3167
+			case 'ATT_ID':
3168
+			case 'ATT_fname':
3169
+			case 'ATT_email':
3170
+			case 'ATT_city':
3171
+			case 'STA_ID':
3172
+			case 'CNT_ID':
3173
+				break;
3174
+			case 'Registration_Count':
3175
+				$orderby = 'Registration_Count';
3176
+				break;
3177
+			default:
3178
+				$orderby = 'ATT_lname';
3179
+		}
3180
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3181
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3182
+		$per_page     = absint($per_page) ? $per_page : 10;
3183
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3184
+		$_where       = [];
3185
+		$search_term  = $this->request->getRequestParam('s');
3186
+		if ($search_term) {
3187
+			$search_term  = '%' . $search_term . '%';
3188
+			$_where['OR'] = [
3189
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3191
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3192
+				'ATT_fname'                         => ['LIKE', $search_term],
3193
+				'ATT_lname'                         => ['LIKE', $search_term],
3194
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3195
+				'ATT_email'                         => ['LIKE', $search_term],
3196
+				'ATT_address'                       => ['LIKE', $search_term],
3197
+				'ATT_address2'                      => ['LIKE', $search_term],
3198
+				'ATT_city'                          => ['LIKE', $search_term],
3199
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3200
+				'State.STA_name'                    => ['LIKE', $search_term],
3201
+				'ATT_phone'                         => ['LIKE', $search_term],
3202
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3203
+				'Registration.REG_code'             => ['LIKE', $search_term],
3204
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3205
+			];
3206
+		}
3207
+		$offset     = ($current_page - 1) * $per_page;
3208
+		$limit      = $count ? null : [$offset, $per_page];
3209
+		$query_args = [
3210
+			$_where,
3211
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212
+			'limit'         => $limit,
3213
+		];
3214
+		if (! $count) {
3215
+			$query_args['order_by'] = [$orderby => $sort];
3216
+		}
3217
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3218
+		return $count
3219
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3220
+			: $this->getAttendeeModel()->get_all($query_args);
3221
+	}
3222
+
3223
+
3224
+	/**
3225
+	 * This is just taking care of resending the registration confirmation
3226
+	 *
3227
+	 * @return void
3228
+	 * @throws EE_Error
3229
+	 * @throws InvalidArgumentException
3230
+	 * @throws InvalidDataTypeException
3231
+	 * @throws InvalidInterfaceException
3232
+	 * @throws ReflectionException
3233
+	 */
3234
+	protected function _resend_registration()
3235
+	{
3236
+		$this->_process_resend_registration();
3237
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3238
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3239
+		$query_args  = $redirect_to
3240
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3241
+			: ['action' => 'default'];
3242
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3243
+	}
3244
+
3245
+
3246
+	/**
3247
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3248
+	 * to use when selecting registrations
3249
+	 *
3250
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3251
+	 *                                                     the query parameters from the request
3252
+	 * @return void ends the request with a redirect or download
3253
+	 */
3254
+	public function _registrations_report_base($method_name_for_getting_query_params)
3255
+	{
3256
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258
+			: null;
3259
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260
+			$request_params = $this->request->requestParams();
3261
+			wp_redirect(
3262
+				EE_Admin_Page::add_query_args_and_nonce(
3263
+					[
3264
+						'page'        => 'espresso_batch',
3265
+						'batch'       => 'file',
3266
+						'EVT_ID'      => $EVT_ID,
3267
+						'filters'     => urlencode(
3268
+							serialize(
3269
+								$this->$method_name_for_getting_query_params(
3270
+									EEH_Array::is_set($request_params, 'filters', [])
3271
+								)
3272
+							)
3273
+						),
3274
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3275
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3276
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3277
+					]
3278
+				)
3279
+			);
3280
+		} else {
3281
+			// Pull the current request params
3282
+			$request_args = $this->request->requestParams();
3283
+			// Set the required request_args to be passed to the export
3284
+			$required_request_args = [
3285
+				'export' => 'report',
3286
+				'action' => 'registrations_report_for_event',
3287
+				'EVT_ID' => $EVT_ID,
3288
+			];
3289
+			// Merge required request args, overriding any currently set
3290
+			$request_args = array_merge($request_args, $required_request_args);
3291
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3292
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3293
+				$EE_Export = EE_Export::instance($request_args);
3294
+				$EE_Export->export();
3295
+			}
3296
+		}
3297
+	}
3298
+
3299
+
3300
+	/**
3301
+	 * Creates a registration report using only query parameters in the request
3302
+	 *
3303
+	 * @return void
3304
+	 */
3305
+	public function _registrations_report()
3306
+	{
3307
+		$this->_registrations_report_base('_get_registration_query_parameters');
3308
+	}
3309
+
3310
+
3311
+	public function _contact_list_export()
3312
+	{
3313
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3314
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3315
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3316
+			$EE_Export->export_attendees();
3317
+		}
3318
+	}
3319
+
3320
+
3321
+	public function _contact_list_report()
3322
+	{
3323
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3324
+			wp_redirect(
3325
+				EE_Admin_Page::add_query_args_and_nonce(
3326
+					[
3327
+						'page'        => 'espresso_batch',
3328
+						'batch'       => 'file',
3329
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3330
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3331
+					]
3332
+				)
3333
+			);
3334
+		} else {
3335
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3336
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3337
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3338
+				$EE_Export->report_attendees();
3339
+			}
3340
+		}
3341
+	}
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3348
+	/**
3349
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3350
+	 *
3351
+	 * @return void
3352
+	 * @throws EE_Error
3353
+	 * @throws InvalidArgumentException
3354
+	 * @throws InvalidDataTypeException
3355
+	 * @throws InvalidInterfaceException
3356
+	 * @throws ReflectionException
3357
+	 */
3358
+	protected function _duplicate_attendee()
3359
+	{
3360
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3361
+		$action = $this->request->getRequestParam('return', 'default');
3362
+		// verify we have necessary info
3363
+		if (! $REG_ID) {
3364
+			EE_Error::add_error(
3365
+				esc_html__(
3366
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3367
+					'event_espresso'
3368
+				),
3369
+				__FILE__,
3370
+				__LINE__,
3371
+				__FUNCTION__
3372
+			);
3373
+			$query_args = ['action' => $action];
3374
+			$this->_redirect_after_action('', '', '', $query_args, true);
3375
+		}
3376
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3377
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3378
+		if (! $registration instanceof EE_Registration) {
3379
+			throw new RuntimeException(
3380
+				sprintf(
3381
+					esc_html__(
3382
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3383
+						'event_espresso'
3384
+					),
3385
+					$REG_ID
3386
+				)
3387
+			);
3388
+		}
3389
+		$attendee = $registration->attendee();
3390
+		// remove relation of existing attendee on registration
3391
+		$registration->_remove_relation_to($attendee, 'Attendee');
3392
+		// new attendee
3393
+		$new_attendee = clone $attendee;
3394
+		$new_attendee->set('ATT_ID', 0);
3395
+		$new_attendee->save();
3396
+		// add new attendee to reg
3397
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3398
+		EE_Error::add_success(
3399
+			esc_html__(
3400
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3401
+				'event_espresso'
3402
+			)
3403
+		);
3404
+		// redirect to edit page for attendee
3405
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3406
+		$this->_redirect_after_action('', '', '', $query_args, true);
3407
+	}
3408
+
3409
+
3410
+	/**
3411
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3412
+	 *
3413
+	 * @param int     $post_id
3414
+	 * @param WP_POST $post
3415
+	 * @throws DomainException
3416
+	 * @throws EE_Error
3417
+	 * @throws InvalidArgumentException
3418
+	 * @throws InvalidDataTypeException
3419
+	 * @throws InvalidInterfaceException
3420
+	 * @throws LogicException
3421
+	 * @throws InvalidFormSubmissionException
3422
+	 * @throws ReflectionException
3423
+	 */
3424
+	protected function _insert_update_cpt_item($post_id, $post)
3425
+	{
3426
+		$success  = true;
3427
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3428
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3429
+			: null;
3430
+		// for attendee updates
3431
+		if ($attendee instanceof EE_Attendee) {
3432
+			// note we should only be UPDATING attendees at this point.
3433
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3434
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3435
+			$updated_fields = [
3436
+				'ATT_fname'     => $fname,
3437
+				'ATT_lname'     => $lname,
3438
+				'ATT_full_name' => "{$fname} {$lname}",
3439
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3440
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3441
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3442
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3443
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3444
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3445
+			];
3446
+			foreach ($updated_fields as $field => $value) {
3447
+				$attendee->set($field, $value);
3448
+			}
3449
+
3450
+			// process contact details metabox form handler (which will also save the attendee)
3451
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3452
+			$success              = $contact_details_form->process($this->request->requestParams());
3453
+
3454
+			$attendee_update_callbacks = apply_filters(
3455
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3456
+				[]
3457
+			);
3458
+			foreach ($attendee_update_callbacks as $a_callback) {
3459
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3460
+					throw new EE_Error(
3461
+						sprintf(
3462
+							esc_html__(
3463
+								'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.',
3464
+								'event_espresso'
3465
+							),
3466
+							$a_callback
3467
+						)
3468
+					);
3469
+				}
3470
+			}
3471
+		}
3472
+
3473
+		if ($success === false) {
3474
+			EE_Error::add_error(
3475
+				esc_html__(
3476
+					'Something went wrong with updating the meta table data for the registration.',
3477
+					'event_espresso'
3478
+				),
3479
+				__FILE__,
3480
+				__FUNCTION__,
3481
+				__LINE__
3482
+			);
3483
+		}
3484
+	}
3485
+
3486
+
3487
+	public function trash_cpt_item($post_id)
3488
+	{
3489
+	}
3490
+
3491
+
3492
+	public function delete_cpt_item($post_id)
3493
+	{
3494
+	}
3495
+
3496
+
3497
+	public function restore_cpt_item($post_id)
3498
+	{
3499
+	}
3500
+
3501
+
3502
+	protected function _restore_cpt_item($post_id, $revision_id)
3503
+	{
3504
+	}
3505
+
3506
+
3507
+	/**
3508
+	 * @throws EE_Error
3509
+	 * @throws ReflectionException
3510
+	 * @since 4.10.2.p
3511
+	 */
3512
+	public function attendee_editor_metaboxes()
3513
+	{
3514
+		$this->verify_cpt_object();
3515
+		remove_meta_box(
3516
+			'postexcerpt',
3517
+			$this->_cpt_routes[ $this->_req_action ],
3518
+			'normal'
3519
+		);
3520
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3521
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3522
+			add_meta_box(
3523
+				'postexcerpt',
3524
+				esc_html__('Short Biography', 'event_espresso'),
3525
+				'post_excerpt_meta_box',
3526
+				$this->_cpt_routes[ $this->_req_action ],
3527
+				'normal'
3528
+			);
3529
+		}
3530
+		if (post_type_supports('espresso_attendees', 'comments')) {
3531
+			add_meta_box(
3532
+				'commentsdiv',
3533
+				esc_html__('Notes on the Contact', 'event_espresso'),
3534
+				'post_comment_meta_box',
3535
+				$this->_cpt_routes[ $this->_req_action ],
3536
+				'normal',
3537
+				'core'
3538
+			);
3539
+		}
3540
+		add_meta_box(
3541
+			'attendee_contact_info',
3542
+			esc_html__('Contact Info', 'event_espresso'),
3543
+			[$this, 'attendee_contact_info'],
3544
+			$this->_cpt_routes[ $this->_req_action ],
3545
+			'side',
3546
+			'core'
3547
+		);
3548
+		add_meta_box(
3549
+			'attendee_details_address',
3550
+			esc_html__('Address Details', 'event_espresso'),
3551
+			[$this, 'attendee_address_details'],
3552
+			$this->_cpt_routes[ $this->_req_action ],
3553
+			'normal',
3554
+			'core'
3555
+		);
3556
+		add_meta_box(
3557
+			'attendee_registrations',
3558
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3559
+			[$this, 'attendee_registrations_meta_box'],
3560
+			$this->_cpt_routes[ $this->_req_action ],
3561
+			'normal',
3562
+			'high'
3563
+		);
3564
+	}
3565
+
3566
+
3567
+	/**
3568
+	 * Metabox for attendee contact info
3569
+	 *
3570
+	 * @param WP_Post $post wp post object
3571
+	 * @return void attendee contact info ( and form )
3572
+	 * @throws EE_Error
3573
+	 * @throws InvalidArgumentException
3574
+	 * @throws InvalidDataTypeException
3575
+	 * @throws InvalidInterfaceException
3576
+	 * @throws LogicException
3577
+	 * @throws DomainException
3578
+	 */
3579
+	public function attendee_contact_info($post)
3580
+	{
3581
+		// get attendee object ( should already have it )
3582
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3583
+		$form->enqueueStylesAndScripts();
3584
+		echo $form->display(); // already escaped
3585
+	}
3586
+
3587
+
3588
+	/**
3589
+	 * Return form handler for the contact details metabox
3590
+	 *
3591
+	 * @param EE_Attendee $attendee
3592
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3593
+	 * @throws DomainException
3594
+	 * @throws InvalidArgumentException
3595
+	 * @throws InvalidDataTypeException
3596
+	 * @throws InvalidInterfaceException
3597
+	 */
3598
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3599
+	{
3600
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3601
+	}
3602
+
3603
+
3604
+	/**
3605
+	 * Metabox for attendee details
3606
+	 *
3607
+	 * @param WP_Post $post wp post object
3608
+	 * @throws EE_Error
3609
+	 * @throws ReflectionException
3610
+	 */
3611
+	public function attendee_address_details($post)
3612
+	{
3613
+		// get attendee object (should already have it)
3614
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3615
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3616
+			new EE_Question_Form_Input(
3617
+				EE_Question::new_instance(
3618
+					[
3619
+						'QST_ID'           => 0,
3620
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3621
+						'QST_system'       => 'admin-state',
3622
+					]
3623
+				),
3624
+				EE_Answer::new_instance(
3625
+					[
3626
+						'ANS_ID'    => 0,
3627
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3628
+					]
3629
+				),
3630
+				[
3631
+					'input_id'       => 'STA_ID',
3632
+					'input_name'     => 'STA_ID',
3633
+					'input_prefix'   => '',
3634
+					'append_qstn_id' => false,
3635
+				]
3636
+			)
3637
+		);
3638
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3639
+			new EE_Question_Form_Input(
3640
+				EE_Question::new_instance(
3641
+					[
3642
+						'QST_ID'           => 0,
3643
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3644
+						'QST_system'       => 'admin-country',
3645
+					]
3646
+				),
3647
+				EE_Answer::new_instance(
3648
+					[
3649
+						'ANS_ID'    => 0,
3650
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3651
+					]
3652
+				),
3653
+				[
3654
+					'input_id'       => 'CNT_ISO',
3655
+					'input_name'     => 'CNT_ISO',
3656
+					'input_prefix'   => '',
3657
+					'append_qstn_id' => false,
3658
+				]
3659
+			)
3660
+		);
3661
+		$template                             =
3662
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3663
+		EEH_Template::display_template($template, $this->_template_args);
3664
+	}
3665
+
3666
+
3667
+	/**
3668
+	 * _attendee_details
3669
+	 *
3670
+	 * @param $post
3671
+	 * @return void
3672
+	 * @throws DomainException
3673
+	 * @throws EE_Error
3674
+	 * @throws InvalidArgumentException
3675
+	 * @throws InvalidDataTypeException
3676
+	 * @throws InvalidInterfaceException
3677
+	 * @throws ReflectionException
3678
+	 */
3679
+	public function attendee_registrations_meta_box($post)
3680
+	{
3681
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3682
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3683
+		$template                              =
3684
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3685
+		EEH_Template::display_template($template, $this->_template_args);
3686
+	}
3687
+
3688
+
3689
+	/**
3690
+	 * add in the form fields for the attendee edit
3691
+	 *
3692
+	 * @param WP_Post $post wp post object
3693
+	 * @return void echos html for new form.
3694
+	 * @throws DomainException
3695
+	 */
3696
+	public function after_title_form_fields($post)
3697
+	{
3698
+		if ($post->post_type === 'espresso_attendees') {
3699
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3700
+			$template_args['attendee'] = $this->_cpt_model_obj;
3701
+			EEH_Template::display_template($template, $template_args);
3702
+		}
3703
+	}
3704
+
3705
+
3706
+	/**
3707
+	 * _trash_or_restore_attendee
3708
+	 *
3709
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3710
+	 * @return void
3711
+	 * @throws EE_Error
3712
+	 * @throws InvalidArgumentException
3713
+	 * @throws InvalidDataTypeException
3714
+	 * @throws InvalidInterfaceException
3715
+	 */
3716
+	protected function _trash_or_restore_attendees($trash = true)
3717
+	{
3718
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3719
+		$status = $trash ? 'trash' : 'publish';
3720
+		// Checkboxes
3721
+		if ($this->request->requestParamIsSet('checkbox')) {
3722
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3723
+			// if array has more than one element than success message should be plural
3724
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3725
+			// cycle thru checkboxes
3726
+			foreach ($ATT_IDs as $ATT_ID) {
3727
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3728
+				if (! $updated) {
3729
+					$success = 0;
3730
+				}
3731
+			}
3732
+		} else {
3733
+			// grab single id and delete
3734
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3735
+			// update attendee
3736
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3737
+		}
3738
+		$what        = $success > 1
3739
+			? esc_html__('Contacts', 'event_espresso')
3740
+			: esc_html__('Contact', 'event_espresso');
3741
+		$action_desc = $trash
3742
+			? esc_html__('moved to the trash', 'event_espresso')
3743
+			: esc_html__('restored', 'event_espresso');
3744
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3745
+	}
3746 3746
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function getRegistrationModel()
94 94
     {
95
-        if (! $this->registration_model instanceof EEM_Registration) {
95
+        if ( ! $this->registration_model instanceof EEM_Registration) {
96 96
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
97 97
         }
98 98
         return $this->registration_model;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     protected function getAttendeeModel()
110 110
     {
111
-        if (! $this->attendee_model instanceof EEM_Attendee) {
111
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
112 112
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
113 113
         }
114 114
         return $this->attendee_model;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     protected function getEventModel()
126 126
     {
127
-        if (! $this->event_model instanceof EEM_Event) {
127
+        if ( ! $this->event_model instanceof EEM_Event) {
128 128
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
129 129
         }
130 130
         return $this->event_model;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function getStatusModel()
142 142
     {
143
-        if (! $this->status_model instanceof EEM_Status) {
143
+        if ( ! $this->status_model instanceof EEM_Status) {
144 144
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
145 145
         }
146 146
         return $this->status_model;
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
         // style
760 760
         wp_register_style(
761 761
             'espresso_reg',
762
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
762
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
763 763
             ['ee-admin-css'],
764 764
             EVENT_ESPRESSO_VERSION
765 765
         );
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         // script
768 768
         wp_register_script(
769 769
             'espresso_reg',
770
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
770
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
771 771
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772 772
             EVENT_ESPRESSO_VERSION,
773 773
             true
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
             'att_publish_text' => sprintf(
792 792
             /* translators: The date and time */
793 793
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
794
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
795 795
             ),
796 796
         ];
797 797
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
         wp_dequeue_style('espresso_reg');
823 823
         wp_register_style(
824 824
             'espresso_att',
825
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
825
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
826 826
             ['ee-admin-css'],
827 827
             EVENT_ESPRESSO_VERSION
828 828
         );
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
     {
835 835
         wp_register_script(
836 836
             'ee-spco-for-admin',
837
-            REG_ASSETS_URL . 'spco_for_admin.js',
837
+            REG_ASSETS_URL.'spco_for_admin.js',
838 838
             ['underscore', 'jquery'],
839 839
             EVENT_ESPRESSO_VERSION,
840 840
             true
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
             'no_approve_registrations' => 'not_approved_registration',
883 883
             'cancel_registrations'     => 'cancelled_registration',
884 884
         ];
885
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
885
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
886 886
             'ee_send_message',
887 887
             'batch_send_messages'
888 888
         );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988 988
                 ],
989 989
             ];
990
-            $this->_views['trash']      = [
990
+            $this->_views['trash'] = [
991 991
                 'slug'        => 'trash',
992 992
                 'label'       => esc_html__('Trash', 'event_espresso'),
993 993
                 'count'       => 0,
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         }
1088 1088
         $sc_items = [
1089 1089
             'approved_status'   => [
1090
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1090
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1091 1091
                 'desc'  => EEH_Template::pretty_status(
1092 1092
                     EEM_Registration::status_id_approved,
1093 1093
                     false,
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
                 ),
1096 1096
             ],
1097 1097
             'pending_status'    => [
1098
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1098
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1099 1099
                 'desc'  => EEH_Template::pretty_status(
1100 1100
                     EEM_Registration::status_id_pending_payment,
1101 1101
                     false,
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
                 ),
1104 1104
             ],
1105 1105
             'wait_list'         => [
1106
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1106
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1107 1107
                 'desc'  => EEH_Template::pretty_status(
1108 1108
                     EEM_Registration::status_id_wait_list,
1109 1109
                     false,
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
                 ),
1112 1112
             ],
1113 1113
             'incomplete_status' => [
1114
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1114
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1115 1115
                 'desc'  => EEH_Template::pretty_status(
1116 1116
                     EEM_Registration::status_id_incomplete,
1117 1117
                     false,
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
                 ),
1120 1120
             ],
1121 1121
             'not_approved'      => [
1122
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1122
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1123 1123
                 'desc'  => EEH_Template::pretty_status(
1124 1124
                     EEM_Registration::status_id_not_approved,
1125 1125
                     false,
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
                 ),
1128 1128
             ],
1129 1129
             'declined_status'   => [
1130
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1130
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1131 1131
                 'desc'  => EEH_Template::pretty_status(
1132 1132
                     EEM_Registration::status_id_declined,
1133 1133
                     false,
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
                 ),
1136 1136
             ],
1137 1137
             'cancelled_status'  => [
1138
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1138
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1139 1139
                 'desc'  => EEH_Template::pretty_status(
1140 1140
                     EEM_Registration::status_id_cancelled,
1141 1141
                     false,
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
                 $EVT_ID
1196 1196
             )
1197 1197
         ) {
1198
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1198
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1199 1199
                 'new_registration',
1200 1200
                 'add-registrant',
1201 1201
                 ['event_id' => $EVT_ID],
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
                 ],
1354 1354
                 REG_ADMIN_URL
1355 1355
             );
1356
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1356
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1357 1357
                 [
1358 1358
                     'action' => 'default',
1359 1359
                     'EVT_ID' => $event_id,
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
                 ],
1362 1362
                 admin_url('admin.php')
1363 1363
             );
1364
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1364
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1365 1365
                 [
1366 1366
                     'page'   => 'espresso_events',
1367 1367
                     'action' => 'edit',
@@ -1370,12 +1370,12 @@  discard block
 block discarded – undo
1370 1370
                 admin_url('admin.php')
1371 1371
             );
1372 1372
             // next and previous links
1373
-            $next_reg                                      = $this->_registration->next(
1373
+            $next_reg = $this->_registration->next(
1374 1374
                 null,
1375 1375
                 [],
1376 1376
                 'REG_ID'
1377 1377
             );
1378
-            $this->_template_args['next_registration']     = $next_reg
1378
+            $this->_template_args['next_registration'] = $next_reg
1379 1379
                 ? $this->_next_link(
1380 1380
                     EE_Admin_Page::add_query_args_and_nonce(
1381 1381
                         [
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1388 1388
                 )
1389 1389
                 : '';
1390
-            $previous_reg                                  = $this->_registration->previous(
1390
+            $previous_reg = $this->_registration->previous(
1391 1391
                 null,
1392 1392
                 [],
1393 1393
                 'REG_ID'
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                 )
1406 1406
                 : '';
1407 1407
             // grab header
1408
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1408
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1409 1409
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1410 1410
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411 1411
                 $template_path,
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
                                 EEH_HTML::strong(
1560 1560
                                     $this->_registration->pretty_status(),
1561 1561
                                     '',
1562
-                                    'status-' . $this->_registration->status_ID(),
1562
+                                    'status-'.$this->_registration->status_ID(),
1563 1563
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564 1564
                                 )
1565 1565
                             )
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
                 $this->_registration->ID()
1576 1576
             )
1577 1577
         ) {
1578
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1578
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1579 1579
                 $this->_get_reg_statuses(),
1580 1580
                 [
1581 1581
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
                     ),
1593 1593
                 ]
1594 1594
             );
1595
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1595
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1596 1596
                 [
1597 1597
                     'html_class'      => 'button-primary',
1598 1598
                     'html_label_text' => '&nbsp;',
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
     protected function _get_reg_statuses()
1618 1618
     {
1619 1619
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1620
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1621 1621
         // get current reg status
1622 1622
         $current_status = $this->_registration->status_ID();
1623 1623
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
             $current_status !== EEM_Registration::status_id_pending_payment
1626 1626
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627 1627
         ) {
1628
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1628
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1629 1629
         }
1630 1630
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631 1631
     }
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
         $success = false;
1717 1717
         // typecast $REG_IDs
1718 1718
         $REG_IDs = (array) $REG_IDs;
1719
-        if (! empty($REG_IDs)) {
1719
+        if ( ! empty($REG_IDs)) {
1720 1720
             $success = true;
1721 1721
             // set default status if none is passed
1722 1722
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1876,7 +1876,7 @@  discard block
 block discarded – undo
1876 1876
             $action,
1877 1877
             $notify
1878 1878
         );
1879
-        $method = $action . '_registration';
1879
+        $method = $action.'_registration';
1880 1880
         if (method_exists($this, $method)) {
1881 1881
             $this->$method($notify);
1882 1882
         }
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
         $filters        = new EE_Line_Item_Filter_Collection();
2027 2027
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028 2028
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2029
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2030 2030
             $filters,
2031 2031
             $transaction->total_line_item()
2032 2032
         );
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
             $filtered_line_item_tree,
2040 2040
             ['EE_Registration' => $this->_registration]
2041 2041
         );
2042
-        $attendee                                = $this->_registration->attendee();
2042
+        $attendee = $this->_registration->attendee();
2043 2043
         if (
2044 2044
             EE_Registry::instance()->CAP->current_user_can(
2045 2045
                 'ee_read_transaction',
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
                 'Payment method response',
2122 2122
                 'event_espresso'
2123 2123
             );
2124
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2124
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2125 2125
         }
2126 2126
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127 2127
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2151,7 +2151,7 @@  discard block
 block discarded – undo
2151 2151
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152 2152
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153 2153
         $template_path                                                        =
2154
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2154
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2155 2155
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156 2156
     }
2157 2157
 
@@ -2189,7 +2189,7 @@  discard block
 block discarded – undo
2189 2189
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190 2190
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2191 2191
             $template_path                                     =
2192
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2192
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2193 2193
             EEH_Template::display_template($template_path, $this->_template_args);
2194 2194
         }
2195 2195
     }
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
     public function form_before_question_group($output)
2206 2206
     {
2207 2207
         EE_Error::doing_it_wrong(
2208
-            __CLASS__ . '::' . __FUNCTION__,
2208
+            __CLASS__.'::'.__FUNCTION__,
2209 2209
             esc_html__(
2210 2210
                 '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.',
2211 2211
                 'event_espresso'
@@ -2229,7 +2229,7 @@  discard block
 block discarded – undo
2229 2229
     public function form_after_question_group($output)
2230 2230
     {
2231 2231
         EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2232
+            __CLASS__.'::'.__FUNCTION__,
2233 2233
             esc_html__(
2234 2234
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2235 2235
                 'event_espresso'
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
     public function form_form_field_label_wrap($label)
2267 2267
     {
2268 2268
         EE_Error::doing_it_wrong(
2269
-            __CLASS__ . '::' . __FUNCTION__,
2269
+            __CLASS__.'::'.__FUNCTION__,
2270 2270
             esc_html__(
2271 2271
                 '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.',
2272 2272
                 'event_espresso'
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
         return '
2277 2277
 			<tr>
2278 2278
 				<th>
2279
-					' . $label . '
2279
+					' . $label.'
2280 2280
 				</th>';
2281 2281
     }
2282 2282
 
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
     public function form_form_field_input__wrap($input)
2292 2292
     {
2293 2293
         EE_Error::doing_it_wrong(
2294
-            __CLASS__ . '::' . __FUNCTION__,
2294
+            __CLASS__.'::'.__FUNCTION__,
2295 2295
             esc_html__(
2296 2296
                 '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.',
2297 2297
                 'event_espresso'
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
         );
2301 2301
         return '
2302 2302
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2303
-					' . $input . '
2303
+					' . $input.'
2304 2304
 				</td>
2305 2305
 			</tr>';
2306 2306
     }
@@ -2349,8 +2349,8 @@  discard block
 block discarded – undo
2349 2349
      */
2350 2350
     protected function _get_reg_custom_questions_form($REG_ID)
2351 2351
     {
2352
-        if (! $this->_reg_custom_questions_form) {
2353
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2352
+        if ( ! $this->_reg_custom_questions_form) {
2353
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354 2354
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355 2355
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356 2356
             );
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
      */
2374 2374
     private function _save_reg_custom_questions_form($REG_ID = 0)
2375 2375
     {
2376
-        if (! $REG_ID) {
2376
+        if ( ! $REG_ID) {
2377 2377
             EE_Error::add_error(
2378 2378
                 esc_html__(
2379 2379
                     'An error occurred. No registration ID was received.',
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
         if ($form->is_valid()) {
2391 2391
             foreach ($form->subforms() as $question_group_form) {
2392 2392
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2393
-                    $where_conditions    = [
2393
+                    $where_conditions = [
2394 2394
                         'QST_ID' => $question_id,
2395 2395
                         'REG_ID' => $REG_ID,
2396 2396
                     ];
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
         $REG = $this->getRegistrationModel();
2432 2432
         // get all other registrations on this transaction, and cache
2433 2433
         // the attendees for them so we don't have to run another query using force_join
2434
-        $registrations                           = $REG->get_all(
2434
+        $registrations = $REG->get_all(
2435 2435
             [
2436 2436
                 [
2437 2437
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2465,23 +2465,23 @@  discard block
 block discarded – undo
2465 2465
                 $attendee                                                      = $registration->attendee()
2466 2466
                     ? $registration->attendee()
2467 2467
                     : $this->getAttendeeModel()->create_default_object();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2469
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2470
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2471
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2472
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2473
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2474 2474
                     ', ',
2475 2475
                     $attendee->full_address_as_array()
2476 2476
                 );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2477
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2478 2478
                     [
2479 2479
                         'action' => 'edit_attendee',
2480 2480
                         'post'   => $attendee->ID(),
2481 2481
                     ],
2482 2482
                     REG_ADMIN_URL
2483 2483
                 );
2484
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2484
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2485 2485
                     $registration->event_obj() instanceof EE_Event
2486 2486
                         ? $registration->event_obj()->name()
2487 2487
                         : '';
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
             }
2490 2490
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491 2491
         }
2492
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2492
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2493 2493
         EEH_Template::display_template($template_path, $this->_template_args);
2494 2494
     }
2495 2495
 
@@ -2515,11 +2515,11 @@  discard block
 block discarded – undo
2515 2515
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2516 2516
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517 2517
         // primary registration object (that way we know if we need to show create button or not)
2518
-        if (! $this->_registration->is_primary_registrant()) {
2518
+        if ( ! $this->_registration->is_primary_registrant()) {
2519 2519
             $primary_registration = $this->_registration->get_primary_registration();
2520 2520
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521 2521
                 : null;
2522
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2522
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523 2523
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524 2524
                 // custom attendee object so let's not worry about the primary reg.
2525 2525
                 $primary_registration = null;
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
         $this->_template_args['phone']             = $attendee->phone();
2535 2535
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536 2536
         // edit link
2537
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2537
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2538 2538
             [
2539 2539
                 'action' => 'edit_attendee',
2540 2540
                 'post'   => $attendee->ID(),
@@ -2543,7 +2543,7 @@  discard block
 block discarded – undo
2543 2543
         );
2544 2544
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545 2545
         // create link
2546
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2546
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2547 2547
             ? EE_Admin_Page::add_query_args_and_nonce(
2548 2548
                 [
2549 2549
                     'action'  => 'duplicate_attendee',
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555 2555
         $this->_template_args['att_check']    = $att_check;
2556 2556
         $template_path                        =
2557
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2557
+            REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2558 2558
         EEH_Template::display_template($template_path, $this->_template_args);
2559 2559
     }
2560 2560
 
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
             /** @var EE_Registration $REG */
2599 2599
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600 2600
             $payments = $REG->registration_payments();
2601
-            if (! empty($payments)) {
2601
+            if ( ! empty($payments)) {
2602 2602
                 $name           = $REG->attendee() instanceof EE_Attendee
2603 2603
                     ? $REG->attendee()->full_name()
2604 2604
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2662,17 +2662,17 @@  discard block
 block discarded – undo
2662 2662
         // Checkboxes
2663 2663
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664 2664
 
2665
-        if (! empty($REG_IDs)) {
2665
+        if ( ! empty($REG_IDs)) {
2666 2666
             // if array has more than one element than success message should be plural
2667 2667
             $success = count($REG_IDs) > 1 ? 2 : 1;
2668 2668
             // cycle thru checkboxes
2669 2669
             foreach ($REG_IDs as $REG_ID) {
2670 2670
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
-                if (! $REG instanceof EE_Registration) {
2671
+                if ( ! $REG instanceof EE_Registration) {
2672 2672
                     continue;
2673 2673
                 }
2674 2674
                 $deleted = $this->_delete_registration($REG);
2675
-                if (! $deleted) {
2675
+                if ( ! $deleted) {
2676 2676
                     $success = 0;
2677 2677
                 }
2678 2678
             }
@@ -2709,7 +2709,7 @@  discard block
 block discarded – undo
2709 2709
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710 2710
         // registrations on the transaction that are NOT trashed.
2711 2711
         $TXN = $REG->get_first_related('Transaction');
2712
-        if (! $TXN instanceof EE_Transaction) {
2712
+        if ( ! $TXN instanceof EE_Transaction) {
2713 2713
             EE_Error::add_error(
2714 2714
                 sprintf(
2715 2715
                     esc_html__(
@@ -2727,11 +2727,11 @@  discard block
 block discarded – undo
2727 2727
         $REGS        = $TXN->get_many_related('Registration');
2728 2728
         $all_trashed = true;
2729 2729
         foreach ($REGS as $registration) {
2730
-            if (! $registration->get('REG_deleted')) {
2730
+            if ( ! $registration->get('REG_deleted')) {
2731 2731
                 $all_trashed = false;
2732 2732
             }
2733 2733
         }
2734
-        if (! $all_trashed) {
2734
+        if ( ! $all_trashed) {
2735 2735
             EE_Error::add_error(
2736 2736
                 esc_html__(
2737 2737
                     '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.',
@@ -2793,7 +2793,7 @@  discard block
 block discarded – undo
2793 2793
      */
2794 2794
     public function new_registration()
2795 2795
     {
2796
-        if (! $this->_set_reg_event()) {
2796
+        if ( ! $this->_set_reg_event()) {
2797 2797
             throw new EE_Error(
2798 2798
                 esc_html__(
2799 2799
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2825,7 +2825,7 @@  discard block
 block discarded – undo
2825 2825
                 ],
2826 2826
                 EVENTS_ADMIN_URL
2827 2827
             );
2828
-            $edit_event_lnk                     = '<a href="'
2828
+            $edit_event_lnk = '<a href="'
2829 2829
                                                   . $edit_event_url
2830 2830
                                                   . '" title="'
2831 2831
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
         }
2844 2844
         // grab header
2845 2845
         $template_path                              =
2846
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2846
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2847 2847
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848 2848
             $template_path,
2849 2849
             $this->_template_args,
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
                 '</b>'
2885 2885
             );
2886 2886
             return '
2887
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2887
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2888 2888
 	<script >
2889 2889
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2890 2890
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
                 );
2927 2927
                 $template_args['content']                          =
2928 2928
                     EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
-                $template_args['content']                          .= '</div>';
2929
+                $template_args['content'] .= '</div>';
2930 2930
                 $template_args['step_button_text']                 = esc_html__(
2931 2931
                     'Add Tickets and Continue to Registrant Details',
2932 2932
                     'event_espresso'
@@ -2953,7 +2953,7 @@  discard block
 block discarded – undo
2953 2953
         // we come back to the process_registration_step route.
2954 2954
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955 2955
         return EEH_Template::display_template(
2956
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2956
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2957 2957
             $template_args,
2958 2958
             true
2959 2959
         );
@@ -2976,7 +2976,7 @@  discard block
 block discarded – undo
2976 2976
         }
2977 2977
 
2978 2978
         $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2979
-        if (! $EVT_ID) {
2979
+        if ( ! $EVT_ID) {
2980 2980
             return false;
2981 2981
         }
2982 2982
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
                 }
3047 3047
                 break;
3048 3048
             case 'questions':
3049
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3049
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050 3050
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051 3051
                 }
3052 3052
                 // process registration
@@ -3057,7 +3057,7 @@  discard block
 block discarded – undo
3057 3057
                         $grand_total->save_this_and_descendants_to_txn();
3058 3058
                     }
3059 3059
                 }
3060
-                if (! $transaction instanceof EE_Transaction) {
3060
+                if ( ! $transaction instanceof EE_Transaction) {
3061 3061
                     $query_args = [
3062 3062
                         'action'                  => 'new_registration',
3063 3063
                         'processing_registration' => 2,
@@ -3079,7 +3079,7 @@  discard block
 block discarded – undo
3079 3079
                     return;
3080 3080
                 }
3081 3081
                 // maybe update status, and make sure to save transaction if not done already
3082
-                if (! $transaction->update_status_based_on_total_paid()) {
3082
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3083 3083
                     $transaction->save();
3084 3084
                 }
3085 3085
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3161,7 +3161,7 @@  discard block
 block discarded – undo
3161 3161
     public function get_attendees($per_page, $count = false, $trash = false)
3162 3162
     {
3163 3163
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3164
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3165 3165
         $orderby = $this->request->getRequestParam('orderby');
3166 3166
         switch ($orderby) {
3167 3167
             case 'ATT_ID':
@@ -3184,7 +3184,7 @@  discard block
 block discarded – undo
3184 3184
         $_where       = [];
3185 3185
         $search_term  = $this->request->getRequestParam('s');
3186 3186
         if ($search_term) {
3187
-            $search_term  = '%' . $search_term . '%';
3187
+            $search_term  = '%'.$search_term.'%';
3188 3188
             $_where['OR'] = [
3189 3189
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190 3190
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3211,7 +3211,7 @@  discard block
 block discarded – undo
3211 3211
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212 3212
             'limit'         => $limit,
3213 3213
         ];
3214
-        if (! $count) {
3214
+        if ( ! $count) {
3215 3215
             $query_args['order_by'] = [$orderby => $sort];
3216 3216
         }
3217 3217
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3256,7 +3256,7 @@  discard block
 block discarded – undo
3256 3256
         $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257 3257
             ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258 3258
             : null;
3259
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3259
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260 3260
             $request_params = $this->request->requestParams();
3261 3261
             wp_redirect(
3262 3262
                 EE_Admin_Page::add_query_args_and_nonce(
@@ -3288,8 +3288,8 @@  discard block
 block discarded – undo
3288 3288
             ];
3289 3289
             // Merge required request args, overriding any currently set
3290 3290
             $request_args = array_merge($request_args, $required_request_args);
3291
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3292
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3291
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3292
+                require_once(EE_CLASSES.'EE_Export.class.php');
3293 3293
                 $EE_Export = EE_Export::instance($request_args);
3294 3294
                 $EE_Export->export();
3295 3295
             }
@@ -3310,8 +3310,8 @@  discard block
 block discarded – undo
3310 3310
 
3311 3311
     public function _contact_list_export()
3312 3312
     {
3313
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3314
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3313
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3314
+            require_once(EE_CLASSES.'EE_Export.class.php');
3315 3315
             $EE_Export = EE_Export::instance($this->request->requestParams());
3316 3316
             $EE_Export->export_attendees();
3317 3317
         }
@@ -3320,7 +3320,7 @@  discard block
 block discarded – undo
3320 3320
 
3321 3321
     public function _contact_list_report()
3322 3322
     {
3323
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3323
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3324 3324
             wp_redirect(
3325 3325
                 EE_Admin_Page::add_query_args_and_nonce(
3326 3326
                     [
@@ -3332,8 +3332,8 @@  discard block
 block discarded – undo
3332 3332
                 )
3333 3333
             );
3334 3334
         } else {
3335
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3336
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3335
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3336
+                require_once(EE_CLASSES.'EE_Export.class.php');
3337 3337
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3338 3338
                 $EE_Export->report_attendees();
3339 3339
             }
@@ -3360,7 +3360,7 @@  discard block
 block discarded – undo
3360 3360
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3361 3361
         $action = $this->request->getRequestParam('return', 'default');
3362 3362
         // verify we have necessary info
3363
-        if (! $REG_ID) {
3363
+        if ( ! $REG_ID) {
3364 3364
             EE_Error::add_error(
3365 3365
                 esc_html__(
3366 3366
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3375,7 +3375,7 @@  discard block
 block discarded – undo
3375 3375
         }
3376 3376
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3377 3377
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3378
-        if (! $registration instanceof EE_Registration) {
3378
+        if ( ! $registration instanceof EE_Registration) {
3379 3379
             throw new RuntimeException(
3380 3380
                 sprintf(
3381 3381
                     esc_html__(
@@ -3514,16 +3514,16 @@  discard block
 block discarded – undo
3514 3514
         $this->verify_cpt_object();
3515 3515
         remove_meta_box(
3516 3516
             'postexcerpt',
3517
-            $this->_cpt_routes[ $this->_req_action ],
3517
+            $this->_cpt_routes[$this->_req_action],
3518 3518
             'normal'
3519 3519
         );
3520
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3520
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3521 3521
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3522 3522
             add_meta_box(
3523 3523
                 'postexcerpt',
3524 3524
                 esc_html__('Short Biography', 'event_espresso'),
3525 3525
                 'post_excerpt_meta_box',
3526
-                $this->_cpt_routes[ $this->_req_action ],
3526
+                $this->_cpt_routes[$this->_req_action],
3527 3527
                 'normal'
3528 3528
             );
3529 3529
         }
@@ -3532,7 +3532,7 @@  discard block
 block discarded – undo
3532 3532
                 'commentsdiv',
3533 3533
                 esc_html__('Notes on the Contact', 'event_espresso'),
3534 3534
                 'post_comment_meta_box',
3535
-                $this->_cpt_routes[ $this->_req_action ],
3535
+                $this->_cpt_routes[$this->_req_action],
3536 3536
                 'normal',
3537 3537
                 'core'
3538 3538
             );
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
             'attendee_contact_info',
3542 3542
             esc_html__('Contact Info', 'event_espresso'),
3543 3543
             [$this, 'attendee_contact_info'],
3544
-            $this->_cpt_routes[ $this->_req_action ],
3544
+            $this->_cpt_routes[$this->_req_action],
3545 3545
             'side',
3546 3546
             'core'
3547 3547
         );
@@ -3549,7 +3549,7 @@  discard block
 block discarded – undo
3549 3549
             'attendee_details_address',
3550 3550
             esc_html__('Address Details', 'event_espresso'),
3551 3551
             [$this, 'attendee_address_details'],
3552
-            $this->_cpt_routes[ $this->_req_action ],
3552
+            $this->_cpt_routes[$this->_req_action],
3553 3553
             'normal',
3554 3554
             'core'
3555 3555
         );
@@ -3557,7 +3557,7 @@  discard block
 block discarded – undo
3557 3557
             'attendee_registrations',
3558 3558
             esc_html__('Registrations for this Contact', 'event_espresso'),
3559 3559
             [$this, 'attendee_registrations_meta_box'],
3560
-            $this->_cpt_routes[ $this->_req_action ],
3560
+            $this->_cpt_routes[$this->_req_action],
3561 3561
             'normal',
3562 3562
             'high'
3563 3563
         );
@@ -3658,8 +3658,8 @@  discard block
 block discarded – undo
3658 3658
                 ]
3659 3659
             )
3660 3660
         );
3661
-        $template                             =
3662
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3661
+        $template =
3662
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3663 3663
         EEH_Template::display_template($template, $this->_template_args);
3664 3664
     }
3665 3665
 
@@ -3681,7 +3681,7 @@  discard block
 block discarded – undo
3681 3681
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3682 3682
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3683 3683
         $template                              =
3684
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3684
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3685 3685
         EEH_Template::display_template($template, $this->_template_args);
3686 3686
     }
3687 3687
 
@@ -3696,7 +3696,7 @@  discard block
 block discarded – undo
3696 3696
     public function after_title_form_fields($post)
3697 3697
     {
3698 3698
         if ($post->post_type === 'espresso_attendees') {
3699
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3699
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3700 3700
             $template_args['attendee'] = $this->_cpt_model_obj;
3701 3701
             EEH_Template::display_template($template, $template_args);
3702 3702
         }
@@ -3725,7 +3725,7 @@  discard block
 block discarded – undo
3725 3725
             // cycle thru checkboxes
3726 3726
             foreach ($ATT_IDs as $ATT_ID) {
3727 3727
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3728
-                if (! $updated) {
3728
+                if ( ! $updated) {
3729 3729
                     $success = 0;
3730 3730
                 }
3731 3731
             }
Please login to merge, or discard this patch.
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 1 patch
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -12,109 +12,109 @@  discard block
 block discarded – undo
12 12
 class EEW_Upcoming_Events extends EspressoWidget
13 13
 {
14 14
 
15
-    /**
16
-     * @var string
17
-     */
18
-    private $title;
19
-    /**
20
-     * @var string
21
-     */
22
-    private $events_category;
23
-
24
-    /**
25
-     * @var bool
26
-     */
27
-    private $show_expired;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    private $image_size;
33
-
34
-    /**
35
-     * @var bool
36
-     */
37
-    private $show_desc;
38
-
39
-    /**
40
-     * @var bool
41
-     */
42
-    private $show_dates;
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    private $date_limit;
48
-
49
-    /**
50
-     * @var string
51
-     */
52
-    private $date_range;
53
-
54
-    /**
55
-     * @var string
56
-     */
57
-    private $limit;
58
-
59
-    /**
60
-     * @var string
61
-     */
62
-    private $order;
63
-
64
-
65
-    /**
66
-     * Register widget with WordPress.
67
-     */
68
-    public function __construct()
69
-    {
70
-        parent::__construct(
71
-            esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
72
-            ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
73
-        );
74
-    }
75
-
76
-
77
-    /**
78
-     * Back-end widget form.
79
-     *
80
-     * @param array $instance Previously saved values from database.
81
-     * @return void
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     * @see WP_Widget::form()
85
-     */
86
-    public function form($instance)
87
-    {
88
-
89
-        EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
90
-        // Set up some default widget settings.
91
-        $defaults = [
92
-            'title'           => esc_html__('Upcoming Events', 'event_espresso'),
93
-            'category_name'   => '',
94
-            'show_expired'    => 0,
95
-            'show_desc'       => true,
96
-            'show_dates'      => true,
97
-            'show_everywhere' => false,
98
-            'date_limit'      => 2,
99
-            'limit'           => 10,
100
-            'sort'            => 'ASC',
101
-            'date_range'      => false,
102
-            'image_size'      => 'medium',
103
-        ];
104
-
105
-        $instance = wp_parse_args((array) $instance, $defaults);
106
-        // don't add HTML labels for EE_Form_Fields generated inputs
107
-        add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
108
-        $yes_no_values = [
109
-            EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110
-            EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111
-        ];
112
-        $sort_values   = [
113
-            EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114
-            EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115
-        ];
116
-
117
-        ?>
15
+	/**
16
+	 * @var string
17
+	 */
18
+	private $title;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	private $events_category;
23
+
24
+	/**
25
+	 * @var bool
26
+	 */
27
+	private $show_expired;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private $image_size;
33
+
34
+	/**
35
+	 * @var bool
36
+	 */
37
+	private $show_desc;
38
+
39
+	/**
40
+	 * @var bool
41
+	 */
42
+	private $show_dates;
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	private $date_limit;
48
+
49
+	/**
50
+	 * @var string
51
+	 */
52
+	private $date_range;
53
+
54
+	/**
55
+	 * @var string
56
+	 */
57
+	private $limit;
58
+
59
+	/**
60
+	 * @var string
61
+	 */
62
+	private $order;
63
+
64
+
65
+	/**
66
+	 * Register widget with WordPress.
67
+	 */
68
+	public function __construct()
69
+	{
70
+		parent::__construct(
71
+			esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
72
+			['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
73
+		);
74
+	}
75
+
76
+
77
+	/**
78
+	 * Back-end widget form.
79
+	 *
80
+	 * @param array $instance Previously saved values from database.
81
+	 * @return void
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 * @see WP_Widget::form()
85
+	 */
86
+	public function form($instance)
87
+	{
88
+
89
+		EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
90
+		// Set up some default widget settings.
91
+		$defaults = [
92
+			'title'           => esc_html__('Upcoming Events', 'event_espresso'),
93
+			'category_name'   => '',
94
+			'show_expired'    => 0,
95
+			'show_desc'       => true,
96
+			'show_dates'      => true,
97
+			'show_everywhere' => false,
98
+			'date_limit'      => 2,
99
+			'limit'           => 10,
100
+			'sort'            => 'ASC',
101
+			'date_range'      => false,
102
+			'image_size'      => 'medium',
103
+		];
104
+
105
+		$instance = wp_parse_args((array) $instance, $defaults);
106
+		// don't add HTML labels for EE_Form_Fields generated inputs
107
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
108
+		$yes_no_values = [
109
+			EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110
+			EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111
+		];
112
+		$sort_values   = [
113
+			EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114
+			EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115
+		];
116
+
117
+		?>
118 118
 
119 119
         <!-- Widget Title: Text Input -->
120 120
 
@@ -151,32 +151,32 @@  discard block
 block discarded – undo
151 151
                 <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?>
152 152
             </label>
153 153
             <?php
154
-            $show_expired_options   = $yes_no_values;
155
-            $show_expired_options[] = EE_Question_Option::new_instance(
156
-                ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
157
-            );
158
-            echo EEH_Form_Fields::select(
159
-                esc_html__('Show Expired Events:', 'event_espresso'),
160
-                $instance['show_expired'],
161
-                $show_expired_options,
162
-                $this->fieldName('show_expired'),
163
-                $this->fieldID('show_expired')
164
-            );
165
-            ?>
154
+			$show_expired_options   = $yes_no_values;
155
+			$show_expired_options[] = EE_Question_Option::new_instance(
156
+				['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
157
+			);
158
+			echo EEH_Form_Fields::select(
159
+				esc_html__('Show Expired Events:', 'event_espresso'),
160
+				$instance['show_expired'],
161
+				$show_expired_options,
162
+				$this->fieldName('show_expired'),
163
+				$this->fieldID('show_expired')
164
+			);
165
+			?>
166 166
         </p>
167 167
         <p>
168 168
             <label for="<?php echo $this->fieldID('sort'); ?>">
169 169
                 <?php esc_html_e('Sort Events:', 'event_espresso'); ?>
170 170
             </label>
171 171
             <?php
172
-            echo EEH_Form_Fields::select(
173
-                esc_html__('Sort Events:', 'event_espresso'),
174
-                $instance['sort'],
175
-                $sort_values,
176
-                $this->fieldName('sort'),
177
-                $this->fieldID('sort')
178
-            );
179
-            ?>
172
+			echo EEH_Form_Fields::select(
173
+				esc_html__('Sort Events:', 'event_espresso'),
174
+				$instance['sort'],
175
+				$sort_values,
176
+				$this->fieldName('sort'),
177
+				$this->fieldID('sort')
178
+			);
179
+			?>
180 180
         </p>
181 181
         <p>
182 182
             <label for="<?php echo $this->fieldID('image_size'); ?>">
@@ -190,42 +190,42 @@  discard block
 block discarded – undo
190 190
                 <?php esc_html_e('Show Description:', 'event_espresso'); ?>
191 191
             </label>
192 192
             <?php
193
-            echo EEH_Form_Fields::select(
194
-                esc_html__('Show Description:', 'event_espresso'),
195
-                $instance['show_desc'],
196
-                $yes_no_values,
197
-                $this->fieldName('show_desc'),
198
-                $this->fieldID('show_desc')
199
-            );
200
-            ?>
193
+			echo EEH_Form_Fields::select(
194
+				esc_html__('Show Description:', 'event_espresso'),
195
+				$instance['show_desc'],
196
+				$yes_no_values,
197
+				$this->fieldName('show_desc'),
198
+				$this->fieldID('show_desc')
199
+			);
200
+			?>
201 201
         </p>
202 202
         <p>
203 203
             <label for="<?php echo $this->fieldID('show_dates'); ?>">
204 204
                 <?php esc_html_e('Show Dates:', 'event_espresso'); ?>
205 205
             </label>
206 206
             <?php
207
-            echo EEH_Form_Fields::select(
208
-                esc_html__('Show Dates:', 'event_espresso'),
209
-                $instance['show_dates'],
210
-                $yes_no_values,
211
-                $this->fieldName('show_dates'),
212
-                $this->fieldID('show_dates')
213
-            );
214
-            ?>
207
+			echo EEH_Form_Fields::select(
208
+				esc_html__('Show Dates:', 'event_espresso'),
209
+				$instance['show_dates'],
210
+				$yes_no_values,
211
+				$this->fieldName('show_dates'),
212
+				$this->fieldID('show_dates')
213
+			);
214
+			?>
215 215
         </p>
216 216
         <p>
217 217
             <label for="<?php echo $this->fieldID('show_everywhere'); ?>">
218 218
                 <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?>
219 219
             </label>
220 220
             <?php
221
-            echo EEH_Form_Fields::select(
222
-                esc_html__('Show on all Pages:', 'event_espresso'),
223
-                $instance['show_everywhere'],
224
-                $yes_no_values,
225
-                $this->fieldName('show_everywhere'),
226
-                $this->fieldID('show_everywhere')
227
-            );
228
-            ?>
221
+			echo EEH_Form_Fields::select(
222
+				esc_html__('Show on all Pages:', 'event_espresso'),
223
+				$instance['show_everywhere'],
224
+				$yes_no_values,
225
+				$this->fieldName('show_everywhere'),
226
+				$this->fieldID('show_everywhere')
227
+			);
228
+			?>
229 229
         </p>
230 230
         <p>
231 231
             <label for="<?php echo $this->fieldID('date_limit'); ?>">
@@ -243,278 +243,278 @@  discard block
 block discarded – undo
243 243
                 <?php esc_html_e('Show Date Range:', 'event_espresso'); ?>
244 244
             </label>
245 245
             <?php
246
-            echo EEH_Form_Fields::select(
247
-                esc_html__('Show Date Range:', 'event_espresso'),
248
-                $instance['date_range'],
249
-                $yes_no_values,
250
-                $this->fieldName('date_range'),
251
-                $this->fieldID('date_range')
252
-            );
253
-            ?>
246
+			echo EEH_Form_Fields::select(
247
+				esc_html__('Show Date Range:', 'event_espresso'),
248
+				$instance['date_range'],
249
+				$yes_no_values,
250
+				$this->fieldName('date_range'),
251
+				$this->fieldID('date_range')
252
+			);
253
+			?>
254 254
             <span class="description">
255 255
                 <br />
256 256
                 <?php esc_html_e(
257
-                    'This setting will replace the list of dates in the widget.',
258
-                    'event_espresso'
259
-                ); ?>
257
+					'This setting will replace the list of dates in the widget.',
258
+					'event_espresso'
259
+				); ?>
260 260
             </span>
261 261
         </p>
262 262
 
263 263
         <?php
264
-    }
265
-
266
-
267
-    /**
268
-     * Sanitize widget form values as they are saved.
269
-     *
270
-     * @param array $new_instance Values just sent to be saved.
271
-     * @param array $old_instance Previously saved values from database.
272
-     *
273
-     * @return array Updated safe values to be saved.
274
-     * @see WP_Widget::update()
275
-     *
276
-     */
277
-    public function update($new_instance, $old_instance)
278
-    {
279
-        $instance                    = $old_instance;
280
-        $instance['title']           = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
281
-        $instance['category_name']   = $new_instance['category_name'];
282
-        $instance['show_expired']    = $new_instance['show_expired'];
283
-        $instance['limit']           = $new_instance['limit'];
284
-        $instance['sort']            = $new_instance['sort'];
285
-        $instance['image_size']      = $new_instance['image_size'];
286
-        $instance['show_desc']       = $new_instance['show_desc'];
287
-        $instance['show_dates']      = $new_instance['show_dates'];
288
-        $instance['show_everywhere'] = $new_instance['show_everywhere'];
289
-        $instance['date_limit']      = $new_instance['date_limit'];
290
-        $instance['date_range']      = $new_instance['date_range'];
291
-        return $instance;
292
-    }
293
-
294
-
295
-    /**
296
-     * Front-end display of widget.
297
-     *
298
-     * @param array $args     Widget arguments.
299
-     * @param array $instance Saved values from database.
300
-     * @throws EE_Error
301
-     * @throws ReflectionException
302
-     * @see WP_Widget::widget()
303
-     *
304
-     */
305
-    public function widget($args, $instance)
306
-    {
307
-
308
-        global $post;
309
-        // make sure there is some kinda post object
310
-        if ($post instanceof WP_Post) {
311
-            $before_widget = '';
312
-            $before_title  = '';
313
-            $after_title   = '';
314
-            $after_widget  = '';
315
-            // but NOT an events archives page, cuz that would be like two event lists on the same page
316
-            $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
317
-            if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
318
-                // let's use some of the event helper functions'
319
-                // make separate vars out of attributes
320
-                extract($args);
321
-
322
-                // grab widget settings
323
-                $this->parseWidgetSettings($instance);
324
-                $title = $this->widgetTitle();
325
-
326
-                // Before widget (defined by themes).
327
-                echo $before_widget;
328
-                // Display the widget title if one was input (before and after defined by themes).
329
-                if (! empty($title)) {
330
-                    echo $before_title . $title . $after_title;
331
-                }
332
-                echo $this->widgetContent($post);
333
-                // After widget (defined by themes).
334
-                echo $after_widget;
335
-            }
336
-        }
337
-    }
338
-
339
-
340
-    /**
341
-     * make_the_title_a_link
342
-     * callback for widget_title filter
343
-     *
344
-     * @param $title
345
-     * @return string
346
-     */
347
-    public function make_the_title_a_link($title)
348
-    {
349
-        return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
350
-    }
351
-
352
-
353
-    /**
354
-     * @param string $field_name
355
-     * @return string
356
-     * @since   4.10.14.p
357
-     */
358
-    public function fieldID($field_name)
359
-    {
360
-        return esc_attr(parent::get_field_id($field_name));
361
-    }
362
-
363
-
364
-    /**
365
-     * @param string $field_name
366
-     * @return string
367
-     * @since   4.10.14.p
368
-     */
369
-    public function fieldName($field_name)
370
-    {
371
-        return esc_attr(parent::get_field_name($field_name));
372
-    }
373
-
374
-
375
-    /**
376
-     * @param array $instance
377
-     * @throws EE_Error
378
-     * @throws ReflectionException
379
-     * @since   4.10.14.p
380
-     */
381
-    private function eventCategoriesSelector(array $instance)
382
-    {
383
-        $event_categories = [];
384
-        $categories       = EEM_Term::instance()->get_all_ee_categories(true);
385
-        if ($categories) {
386
-            foreach ($categories as $category) {
387
-                if ($category instanceof EE_Term) {
388
-                    $event_categories[] =
389
-                        EE_Question_Option::new_instance(
390
-                            [
391
-                                'QSO_value' => $category->get('slug'),
392
-                                'QSO_desc'  => $category->get('name'),
393
-                            ]
394
-                        );
395
-                }
396
-            }
397
-        }
398
-        array_unshift(
399
-            $event_categories,
400
-            EE_Question_Option::new_instance(
401
-                [
402
-                    'QSO_value' => '',
403
-                    'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
404
-                ]
405
-            )
406
-        );
407
-        echo EEH_Form_Fields::select(
408
-            esc_html__('Event Category:', 'event_espresso'),
409
-            $instance['category_name'],
410
-            $event_categories,
411
-            $this->fieldName('category_name'),
412
-            $this->fieldID('category_name')
413
-        );
414
-    }
415
-
416
-
417
-    /**
418
-     * @param array $instance
419
-     * @since   4.10.14.p
420
-     */
421
-    private function imageSizeSelector(array $instance)
422
-    {
423
-        $image_sizes = [];
424
-        $sizes       = get_intermediate_image_sizes();
425
-        if ($sizes) {
426
-            // loop thru images and create option objects out of them
427
-            foreach ($sizes as $image_size) {
428
-                $image_size = trim($image_size);
429
-                // no big images plz
430
-                if (! in_array($image_size, ['large', 'post-thumbnail'])) {
431
-                    $image_sizes[] =
432
-                        EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
433
-                }
434
-            }
435
-            $image_sizes[] =
436
-                EE_Question_Option::new_instance(
437
-                    ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
438
-                );
439
-        }
440
-        echo EEH_Form_Fields::select(
441
-            esc_html__('Image Size:', 'event_espresso'),
442
-            $instance['image_size'],
443
-            $image_sizes,
444
-            $this->fieldName('image_size'),
445
-            $this->fieldID('image_size')
446
-        );
447
-    }
448
-
449
-
450
-    /**
451
-     * @param array $instance
452
-     * @since   4.10.14.p
453
-     */
454
-    private function parseWidgetSettings(array $instance)
455
-    {
456
-        $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
457
-        $this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
458
-            ? $instance['category_name']
459
-            : false;
460
-        $this->show_expired = isset($instance['show_expired'])
461
-            ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
462
-            : 0;
463
-        $this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
464
-            ? $instance['image_size']
465
-            : 'medium';
466
-        $this->show_desc    = ! isset($instance['show_desc'])
467
-                              || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
468
-        $this->show_dates   = ! isset($instance['show_dates'])
469
-                              || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
470
-        $this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
471
-            ? $instance['date_limit']
472
-            : null;
473
-        $this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
474
-            ? $instance['date_range']
475
-            : false;
476
-        $this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
477
-        $this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
478
-            ? 'DESC'
479
-            : 'ASC';
480
-    }
481
-
482
-
483
-    /**
484
-     * @return mixed|void
485
-     * @since   4.10.14.p
486
-     */
487
-    private function widgetTitle()
488
-    {
489
-        // add function to make the title a link
490
-        add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
491
-        // filter the title
492
-        $title = apply_filters('widget_title', $this->title);
493
-        // remove the function from the filter, so it does not affect other widgets
494
-        remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
495
-        return $title;
496
-    }
497
-
498
-
499
-    /**
500
-     * @param WP_Post $post
501
-     * @return string
502
-     * @throws EE_Error
503
-     * @throws ReflectionException
504
-     * @since   4.10.14.p
505
-     */
506
-    private function widgetContent(WP_Post $post)
507
-    {
508
-        // run the query
509
-        $events = $this->getUpcomingEvents();
510
-        if (empty($events)) {
511
-            return '';
512
-        }
513
-        $list_items = '';
514
-        foreach ($events as $event) {
515
-            if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
516
-                $event_url = $this->eventUrl($event);
517
-                $list_items .= '
264
+	}
265
+
266
+
267
+	/**
268
+	 * Sanitize widget form values as they are saved.
269
+	 *
270
+	 * @param array $new_instance Values just sent to be saved.
271
+	 * @param array $old_instance Previously saved values from database.
272
+	 *
273
+	 * @return array Updated safe values to be saved.
274
+	 * @see WP_Widget::update()
275
+	 *
276
+	 */
277
+	public function update($new_instance, $old_instance)
278
+	{
279
+		$instance                    = $old_instance;
280
+		$instance['title']           = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
281
+		$instance['category_name']   = $new_instance['category_name'];
282
+		$instance['show_expired']    = $new_instance['show_expired'];
283
+		$instance['limit']           = $new_instance['limit'];
284
+		$instance['sort']            = $new_instance['sort'];
285
+		$instance['image_size']      = $new_instance['image_size'];
286
+		$instance['show_desc']       = $new_instance['show_desc'];
287
+		$instance['show_dates']      = $new_instance['show_dates'];
288
+		$instance['show_everywhere'] = $new_instance['show_everywhere'];
289
+		$instance['date_limit']      = $new_instance['date_limit'];
290
+		$instance['date_range']      = $new_instance['date_range'];
291
+		return $instance;
292
+	}
293
+
294
+
295
+	/**
296
+	 * Front-end display of widget.
297
+	 *
298
+	 * @param array $args     Widget arguments.
299
+	 * @param array $instance Saved values from database.
300
+	 * @throws EE_Error
301
+	 * @throws ReflectionException
302
+	 * @see WP_Widget::widget()
303
+	 *
304
+	 */
305
+	public function widget($args, $instance)
306
+	{
307
+
308
+		global $post;
309
+		// make sure there is some kinda post object
310
+		if ($post instanceof WP_Post) {
311
+			$before_widget = '';
312
+			$before_title  = '';
313
+			$after_title   = '';
314
+			$after_widget  = '';
315
+			// but NOT an events archives page, cuz that would be like two event lists on the same page
316
+			$show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
317
+			if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
318
+				// let's use some of the event helper functions'
319
+				// make separate vars out of attributes
320
+				extract($args);
321
+
322
+				// grab widget settings
323
+				$this->parseWidgetSettings($instance);
324
+				$title = $this->widgetTitle();
325
+
326
+				// Before widget (defined by themes).
327
+				echo $before_widget;
328
+				// Display the widget title if one was input (before and after defined by themes).
329
+				if (! empty($title)) {
330
+					echo $before_title . $title . $after_title;
331
+				}
332
+				echo $this->widgetContent($post);
333
+				// After widget (defined by themes).
334
+				echo $after_widget;
335
+			}
336
+		}
337
+	}
338
+
339
+
340
+	/**
341
+	 * make_the_title_a_link
342
+	 * callback for widget_title filter
343
+	 *
344
+	 * @param $title
345
+	 * @return string
346
+	 */
347
+	public function make_the_title_a_link($title)
348
+	{
349
+		return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
350
+	}
351
+
352
+
353
+	/**
354
+	 * @param string $field_name
355
+	 * @return string
356
+	 * @since   4.10.14.p
357
+	 */
358
+	public function fieldID($field_name)
359
+	{
360
+		return esc_attr(parent::get_field_id($field_name));
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param string $field_name
366
+	 * @return string
367
+	 * @since   4.10.14.p
368
+	 */
369
+	public function fieldName($field_name)
370
+	{
371
+		return esc_attr(parent::get_field_name($field_name));
372
+	}
373
+
374
+
375
+	/**
376
+	 * @param array $instance
377
+	 * @throws EE_Error
378
+	 * @throws ReflectionException
379
+	 * @since   4.10.14.p
380
+	 */
381
+	private function eventCategoriesSelector(array $instance)
382
+	{
383
+		$event_categories = [];
384
+		$categories       = EEM_Term::instance()->get_all_ee_categories(true);
385
+		if ($categories) {
386
+			foreach ($categories as $category) {
387
+				if ($category instanceof EE_Term) {
388
+					$event_categories[] =
389
+						EE_Question_Option::new_instance(
390
+							[
391
+								'QSO_value' => $category->get('slug'),
392
+								'QSO_desc'  => $category->get('name'),
393
+							]
394
+						);
395
+				}
396
+			}
397
+		}
398
+		array_unshift(
399
+			$event_categories,
400
+			EE_Question_Option::new_instance(
401
+				[
402
+					'QSO_value' => '',
403
+					'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
404
+				]
405
+			)
406
+		);
407
+		echo EEH_Form_Fields::select(
408
+			esc_html__('Event Category:', 'event_espresso'),
409
+			$instance['category_name'],
410
+			$event_categories,
411
+			$this->fieldName('category_name'),
412
+			$this->fieldID('category_name')
413
+		);
414
+	}
415
+
416
+
417
+	/**
418
+	 * @param array $instance
419
+	 * @since   4.10.14.p
420
+	 */
421
+	private function imageSizeSelector(array $instance)
422
+	{
423
+		$image_sizes = [];
424
+		$sizes       = get_intermediate_image_sizes();
425
+		if ($sizes) {
426
+			// loop thru images and create option objects out of them
427
+			foreach ($sizes as $image_size) {
428
+				$image_size = trim($image_size);
429
+				// no big images plz
430
+				if (! in_array($image_size, ['large', 'post-thumbnail'])) {
431
+					$image_sizes[] =
432
+						EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
433
+				}
434
+			}
435
+			$image_sizes[] =
436
+				EE_Question_Option::new_instance(
437
+					['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
438
+				);
439
+		}
440
+		echo EEH_Form_Fields::select(
441
+			esc_html__('Image Size:', 'event_espresso'),
442
+			$instance['image_size'],
443
+			$image_sizes,
444
+			$this->fieldName('image_size'),
445
+			$this->fieldID('image_size')
446
+		);
447
+	}
448
+
449
+
450
+	/**
451
+	 * @param array $instance
452
+	 * @since   4.10.14.p
453
+	 */
454
+	private function parseWidgetSettings(array $instance)
455
+	{
456
+		$this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
457
+		$this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
458
+			? $instance['category_name']
459
+			: false;
460
+		$this->show_expired = isset($instance['show_expired'])
461
+			? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
462
+			: 0;
463
+		$this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
464
+			? $instance['image_size']
465
+			: 'medium';
466
+		$this->show_desc    = ! isset($instance['show_desc'])
467
+							  || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
468
+		$this->show_dates   = ! isset($instance['show_dates'])
469
+							  || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
470
+		$this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
471
+			? $instance['date_limit']
472
+			: null;
473
+		$this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
474
+			? $instance['date_range']
475
+			: false;
476
+		$this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
477
+		$this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
478
+			? 'DESC'
479
+			: 'ASC';
480
+	}
481
+
482
+
483
+	/**
484
+	 * @return mixed|void
485
+	 * @since   4.10.14.p
486
+	 */
487
+	private function widgetTitle()
488
+	{
489
+		// add function to make the title a link
490
+		add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
491
+		// filter the title
492
+		$title = apply_filters('widget_title', $this->title);
493
+		// remove the function from the filter, so it does not affect other widgets
494
+		remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
495
+		return $title;
496
+	}
497
+
498
+
499
+	/**
500
+	 * @param WP_Post $post
501
+	 * @return string
502
+	 * @throws EE_Error
503
+	 * @throws ReflectionException
504
+	 * @since   4.10.14.p
505
+	 */
506
+	private function widgetContent(WP_Post $post)
507
+	{
508
+		// run the query
509
+		$events = $this->getUpcomingEvents();
510
+		if (empty($events)) {
511
+			return '';
512
+		}
513
+		$list_items = '';
514
+		foreach ($events as $event) {
515
+			if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
516
+				$event_url = $this->eventUrl($event);
517
+				$list_items .= '
518 518
                 <li id="ee-upcoming-events-widget-li-' . esc_attr($event->ID()) . '" 
519 519
                     class="ee-upcoming-events-widget-li"
520 520
                 >
@@ -525,194 +525,194 @@  discard block
 block discarded – undo
525 525
                     </h5>
526 526
                     ' . $this->eventWidgetContent($event, $event_url) . '
527 527
                 </li>';
528
-            }
529
-        }
530
-        return '
528
+			}
529
+		}
530
+		return '
531 531
             <ul class="ee-upcoming-events-widget-ul">
532 532
                 ' . $list_items . '
533 533
             </ul>';
534
-    }
535
-
536
-
537
-    /**
538
-     * @param EE_Event $event
539
-     * @return string|null
540
-     * @throws EE_Error
541
-     * @since   4.10.14.p
542
-     */
543
-    private function eventUrl(EE_Event $event)
544
-    {
545
-        return esc_url_raw(
546
-            apply_filters(
547
-                'FHEE_EEW_Upcoming_Events__widget__event_url',
548
-                $event->get_permalink(),
549
-                $event
550
-            )
551
-        );
552
-    }
553
-
554
-
555
-    /**
556
-     * @return EE_Base_Class[]
557
-     * @throws EE_Error
558
-     */
559
-    private function getUpcomingEvents()
560
-    {
561
-        return EEM_Event::instance()->get_all(
562
-            [
563
-                $this->queryWhereParams(),
564
-                'limit'    => '0,' . $this->limit,
565
-                'order_by' => 'Datetime.DTT_EVT_start',
566
-                'order'    => $this->order,
567
-                'group_by' => 'EVT_ID',
568
-            ]
569
-        );
570
-    }
571
-
572
-
573
-    /**
574
-     * @return mixed|void
575
-     * @throws EE_Error
576
-     * @since   4.10.14.p
577
-     */
578
-    private function queryWhereParams()
579
-    {
580
-        // start to build our where clause
581
-        $where = [
582
-            'status' => ['IN', ['publish', 'sold_out']],
583
-        ];
584
-        // add category
585
-        if ($this->events_category) {
586
-            $where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
587
-            $where['Term_Taxonomy.Term.slug'] = $this->events_category;
588
-        }
589
-        // if NOT expired then we want events that start today or in the future
590
-        // if NOT show expired then we want events that start today or in the future
591
-        if ($this->show_expired == 0) {
592
-            $where['Datetime.DTT_EVT_end'] = [
593
-                '>=',
594
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
595
-            ];
596
-        }
597
-        // if show ONLY expired we want events that ended prior to today
598
-        if ($this->show_expired == 2) {
599
-            $where['Datetime.DTT_EVT_end'] = [
600
-                '<=',
601
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
602
-            ];
603
-        }
604
-        // allow $where to be filtered
605
-        return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
606
-    }
607
-
608
-
609
-    /**
610
-     * @param EE_Event $event
611
-     * @return string
612
-     * @throws EE_Error
613
-     * @throws ReflectionException
614
-     * @since   4.10.14.p
615
-     */
616
-    private function linkClass(EE_Event $event)
617
-    {
618
-        // how big is the event name ?
619
-        $name_length = strlen($event->name());
620
-        switch ($name_length) {
621
-            case $name_length > 70:
622
-                return ' three-line';
623
-            case $name_length > 35:
624
-                return ' two-line';
625
-        }
626
-        return ' one-line';
627
-    }
628
-
629
-
630
-    /**
631
-     * @param EE_Event $event
632
-     * @param string   $event_url
633
-     * @return mixed|string|void
634
-     * @throws EE_Error
635
-     * @throws ReflectionException
636
-     * @since   4.10.14.p
637
-     */
638
-    private function eventWidgetContent(EE_Event $event, $event_url = '')
639
-    {
640
-        if (post_password_required($event->ID())) {
641
-            return apply_filters(
642
-                'FHEE_EEW_Upcoming_Events__widget__password_form',
643
-                get_the_password_form($event->ID()),
644
-                $event
645
-            );
646
-        }
647
-
648
-        $content = '';
649
-        if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
650
-            $content .= '
534
+	}
535
+
536
+
537
+	/**
538
+	 * @param EE_Event $event
539
+	 * @return string|null
540
+	 * @throws EE_Error
541
+	 * @since   4.10.14.p
542
+	 */
543
+	private function eventUrl(EE_Event $event)
544
+	{
545
+		return esc_url_raw(
546
+			apply_filters(
547
+				'FHEE_EEW_Upcoming_Events__widget__event_url',
548
+				$event->get_permalink(),
549
+				$event
550
+			)
551
+		);
552
+	}
553
+
554
+
555
+	/**
556
+	 * @return EE_Base_Class[]
557
+	 * @throws EE_Error
558
+	 */
559
+	private function getUpcomingEvents()
560
+	{
561
+		return EEM_Event::instance()->get_all(
562
+			[
563
+				$this->queryWhereParams(),
564
+				'limit'    => '0,' . $this->limit,
565
+				'order_by' => 'Datetime.DTT_EVT_start',
566
+				'order'    => $this->order,
567
+				'group_by' => 'EVT_ID',
568
+			]
569
+		);
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return mixed|void
575
+	 * @throws EE_Error
576
+	 * @since   4.10.14.p
577
+	 */
578
+	private function queryWhereParams()
579
+	{
580
+		// start to build our where clause
581
+		$where = [
582
+			'status' => ['IN', ['publish', 'sold_out']],
583
+		];
584
+		// add category
585
+		if ($this->events_category) {
586
+			$where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
587
+			$where['Term_Taxonomy.Term.slug'] = $this->events_category;
588
+		}
589
+		// if NOT expired then we want events that start today or in the future
590
+		// if NOT show expired then we want events that start today or in the future
591
+		if ($this->show_expired == 0) {
592
+			$where['Datetime.DTT_EVT_end'] = [
593
+				'>=',
594
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
595
+			];
596
+		}
597
+		// if show ONLY expired we want events that ended prior to today
598
+		if ($this->show_expired == 2) {
599
+			$where['Datetime.DTT_EVT_end'] = [
600
+				'<=',
601
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
602
+			];
603
+		}
604
+		// allow $where to be filtered
605
+		return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
606
+	}
607
+
608
+
609
+	/**
610
+	 * @param EE_Event $event
611
+	 * @return string
612
+	 * @throws EE_Error
613
+	 * @throws ReflectionException
614
+	 * @since   4.10.14.p
615
+	 */
616
+	private function linkClass(EE_Event $event)
617
+	{
618
+		// how big is the event name ?
619
+		$name_length = strlen($event->name());
620
+		switch ($name_length) {
621
+			case $name_length > 70:
622
+				return ' three-line';
623
+			case $name_length > 35:
624
+				return ' two-line';
625
+		}
626
+		return ' one-line';
627
+	}
628
+
629
+
630
+	/**
631
+	 * @param EE_Event $event
632
+	 * @param string   $event_url
633
+	 * @return mixed|string|void
634
+	 * @throws EE_Error
635
+	 * @throws ReflectionException
636
+	 * @since   4.10.14.p
637
+	 */
638
+	private function eventWidgetContent(EE_Event $event, $event_url = '')
639
+	{
640
+		if (post_password_required($event->ID())) {
641
+			return apply_filters(
642
+				'FHEE_EEW_Upcoming_Events__widget__password_form',
643
+				get_the_password_form($event->ID()),
644
+				$event
645
+			);
646
+		}
647
+
648
+		$content = '';
649
+		if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
650
+			$content .= '
651 651
                 <div class="ee-upcoming-events-widget-img-dv">
652 652
                     <a class="ee-upcoming-events-widget-img" href="' . $event_url . '">
653 653
                         ' . get_the_post_thumbnail($event->ID(), $this->image_size) . '
654 654
                     </a>
655 655
                 </div>';
656
-        }
657
-
658
-        if ($this->show_dates) {
659
-            $content .= $this->eventDates($event);
660
-        }
661
-
662
-        if ($this->show_desc) {
663
-            global $allowedtags;
664
-            $desc    = $event->short_description(25);
665
-            $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
666
-        }
667
-
668
-        return $content;
669
-    }
670
-
671
-
672
-    /**
673
-     * @param EE_Event $event
674
-     * @return string
675
-     * @throws EE_Error
676
-     * @throws ReflectionException
677
-     * @since   4.10.14.p
678
-     */
679
-    private function eventDates(EE_Event $event)
680
-    {
681
-        $date_format        = apply_filters(
682
-            'FHEE__espresso_event_date_range__date_format',
683
-            get_option('date_format')
684
-        );
685
-        $time_format        = apply_filters(
686
-            'FHEE__espresso_event_date_range__time_format',
687
-            get_option('time_format')
688
-        );
689
-        $single_date_format = apply_filters(
690
-            'FHEE__espresso_event_date_range__single_date_format',
691
-            get_option('date_format')
692
-        );
693
-        $single_time_format = apply_filters(
694
-            'FHEE__espresso_event_date_range__single_time_format',
695
-            get_option('time_format')
696
-        );
697
-        if ($this->date_range == true) {
698
-            return espresso_event_date_range(
699
-                $date_format,
700
-                $time_format,
701
-                $single_date_format,
702
-                $single_time_format,
703
-                $event->ID(),
704
-                false
705
-            );
706
-        }
707
-        return espresso_list_of_event_dates(
708
-            $event->ID(),
709
-            $date_format,
710
-            $time_format,
711
-            false,
712
-            null,
713
-            true,
714
-            true,
715
-            $this->date_limit
716
-        );
717
-    }
656
+		}
657
+
658
+		if ($this->show_dates) {
659
+			$content .= $this->eventDates($event);
660
+		}
661
+
662
+		if ($this->show_desc) {
663
+			global $allowedtags;
664
+			$desc    = $event->short_description(25);
665
+			$content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
666
+		}
667
+
668
+		return $content;
669
+	}
670
+
671
+
672
+	/**
673
+	 * @param EE_Event $event
674
+	 * @return string
675
+	 * @throws EE_Error
676
+	 * @throws ReflectionException
677
+	 * @since   4.10.14.p
678
+	 */
679
+	private function eventDates(EE_Event $event)
680
+	{
681
+		$date_format        = apply_filters(
682
+			'FHEE__espresso_event_date_range__date_format',
683
+			get_option('date_format')
684
+		);
685
+		$time_format        = apply_filters(
686
+			'FHEE__espresso_event_date_range__time_format',
687
+			get_option('time_format')
688
+		);
689
+		$single_date_format = apply_filters(
690
+			'FHEE__espresso_event_date_range__single_date_format',
691
+			get_option('date_format')
692
+		);
693
+		$single_time_format = apply_filters(
694
+			'FHEE__espresso_event_date_range__single_time_format',
695
+			get_option('time_format')
696
+		);
697
+		if ($this->date_range == true) {
698
+			return espresso_event_date_range(
699
+				$date_format,
700
+				$time_format,
701
+				$single_date_format,
702
+				$single_time_format,
703
+				$event->ID(),
704
+				false
705
+			);
706
+		}
707
+		return espresso_list_of_event_dates(
708
+			$event->ID(),
709
+			$date_format,
710
+			$time_format,
711
+			false,
712
+			null,
713
+			true,
714
+			true,
715
+			$this->date_limit
716
+		);
717
+	}
718 718
 }
Please login to merge, or discard this patch.
caffeinated/modules/events_archive_caff/EED_Events_Archive_Caff.module.php 1 patch
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -14,268 +14,268 @@
 block discarded – undo
14 14
 class EED_Events_Archive_Caff extends EED_Events_Archive
15 15
 {
16 16
 
17
-    /**
18
-     * @return EED_Events_Archive_Caff|EED_Module
19
-     */
20
-    public static function instance()
21
-    {
22
-        return parent::get_instance(__CLASS__);
23
-    }
17
+	/**
18
+	 * @return EED_Events_Archive_Caff|EED_Module
19
+	 */
20
+	public static function instance()
21
+	{
22
+		return parent::get_instance(__CLASS__);
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * set_hooks - for hooking into EE Core, other modules, etc
28
-     *
29
-     * @return    void
30
-     */
31
-    public static function set_hooks()
32
-    {
33
-    }
26
+	/**
27
+	 * set_hooks - for hooking into EE Core, other modules, etc
28
+	 *
29
+	 * @return    void
30
+	 */
31
+	public static function set_hooks()
32
+	{
33
+	}
34 34
 
35
-    /**
36
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
37
-     *
38
-     * @access    public
39
-     * @return    void
40
-     */
41
-    public static function set_hooks_admin()
42
-    {
43
-        self::setDefinitions();
44
-        add_action(
45
-            'AHEE__template_settings__template__before_settings_form',
46
-            array('EED_Events_Archive_Caff', 'template_settings_form'),
47
-            10
48
-        );
49
-        add_filter(
50
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
51
-            array('EED_Events_Archive_Caff', 'update_template_settings'),
52
-            10,
53
-            2
54
-        );
55
-        // AJAX
56
-        add_action(
57
-            'wp_ajax_espresso_update_event_archive_order',
58
-            array('EED_Events_Archive_Caff', 'update_event_archive_order')
59
-        );
60
-        add_action(
61
-            'wp_ajax_nopriv_espresso_update_event_archive_order',
62
-            array('EED_Events_Archive_Caff', 'update_event_archive_order')
63
-        );
64
-    }
35
+	/**
36
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
37
+	 *
38
+	 * @access    public
39
+	 * @return    void
40
+	 */
41
+	public static function set_hooks_admin()
42
+	{
43
+		self::setDefinitions();
44
+		add_action(
45
+			'AHEE__template_settings__template__before_settings_form',
46
+			array('EED_Events_Archive_Caff', 'template_settings_form'),
47
+			10
48
+		);
49
+		add_filter(
50
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
51
+			array('EED_Events_Archive_Caff', 'update_template_settings'),
52
+			10,
53
+			2
54
+		);
55
+		// AJAX
56
+		add_action(
57
+			'wp_ajax_espresso_update_event_archive_order',
58
+			array('EED_Events_Archive_Caff', 'update_event_archive_order')
59
+		);
60
+		add_action(
61
+			'wp_ajax_nopriv_espresso_update_event_archive_order',
62
+			array('EED_Events_Archive_Caff', 'update_event_archive_order')
63
+		);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * run - initial module setup
69
-     *
70
-     * @param    WP $WP
71
-     * @return    void
72
-     */
73
-    public function run($WP)
74
-    {
75
-    }
67
+	/**
68
+	 * run - initial module setup
69
+	 *
70
+	 * @param    WP $WP
71
+	 * @return    void
72
+	 */
73
+	public function run($WP)
74
+	{
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * Conditionally set constants if they haven't been defined yet.
80
-     */
81
-    public static function setDefinitions()
82
-    {
83
-        if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
84
-            define(
85
-                'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH',
86
-                str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/'
87
-            );
88
-            define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
89
-        }
90
-    }
78
+	/**
79
+	 * Conditionally set constants if they haven't been defined yet.
80
+	 */
81
+	public static function setDefinitions()
82
+	{
83
+		if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
84
+			define(
85
+				'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH',
86
+				str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/'
87
+			);
88
+			define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
89
+		}
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @return void
95
-     * @throws DomainException
96
-     * @throws InvalidArgumentException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidInterfaceException
99
-     */
100
-    public static function template_settings_form()
101
-    {
102
-        /** @var EE_Admin_Page_Loader $admin_page_loader */
103
-        $admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader');
104
-        // grab general settings admin page and remove the existing hook callback
105
-        $gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings');
106
-        if ($gen_set_admin instanceof General_Settings_Admin_Page) {
107
-            remove_action(
108
-                'AHEE__template_settings__template__before_settings_form',
109
-                array($gen_set_admin, 'template_settings_caff_features'),
110
-                100
111
-            );
112
-        }
113
-        // first just grab the template settings
114
-        $config = EE_Registry::instance()->CFG->template_settings;
115
-        // then if the Event Archive config is valid, use that, else create a new one
116
-        $config = $config instanceof EE_Template_Config
117
-                  && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
118
-            ? $config->EED_Events_Archive
119
-            : new EE_Events_Archive_Config();
120
-        $config = apply_filters(
121
-            'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
122
-            $config
123
-        );
124
-        $config->display_status_banner = isset($config->display_status_banner)
125
-            ? $config->display_status_banner
126
-            : 0;
127
-        $config->display_description = isset($config->display_description)
128
-            ? $config->display_description
129
-            : 1;
130
-        $config->display_ticket_selector = isset($config->display_ticket_selector)
131
-            ? $config->display_ticket_selector
132
-            : 0;
133
-        $config->display_datetimes = isset($config->display_datetimes)
134
-            ? $config->display_datetimes
135
-            : 1;
136
-        $config->display_venue = isset($config->display_venue)
137
-            ? $config->display_venue
138
-            : 0;
139
-        $config->display_expired_events = isset($config->display_expired_events)
140
-            ? $config->display_expired_events
141
-            : 0;
142
-        // display order options
143
-        $config->use_sortable_display_order = isset($config->use_sortable_display_order)
144
-            ? $config->use_sortable_display_order
145
-            : false;
146
-        $config->display_order_tickets = isset($config->display_order_tickets)
147
-            ? $config->display_order_tickets
148
-            : 120;
149
-        $config->display_order_datetimes = isset($config->display_order_datetimes)
150
-            ? $config->display_order_datetimes
151
-            : 110;
152
-        $config->display_order_event = isset($config->display_order_event)
153
-            ? $config->display_order_event
154
-            : 100;
155
-        $config->display_order_venue = isset($config->display_order_venue)
156
-            ? $config->display_order_venue
157
-            : 130;
158
-        // get template parts
159
-        $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
160
-        // convert to array so that we can add more properties
161
-        $config = get_object_vars($config);
162
-        $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
163
-            'event-archive-sortable-js',
164
-            '',
165
-            'archive-sortable-li archive-sortable-js'
166
-        );
167
-        EEH_Template::display_template(
168
-            EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
169
-            $config
170
-        );
171
-    }
93
+	/**
94
+	 * @return void
95
+	 * @throws DomainException
96
+	 * @throws InvalidArgumentException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidInterfaceException
99
+	 */
100
+	public static function template_settings_form()
101
+	{
102
+		/** @var EE_Admin_Page_Loader $admin_page_loader */
103
+		$admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader');
104
+		// grab general settings admin page and remove the existing hook callback
105
+		$gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings');
106
+		if ($gen_set_admin instanceof General_Settings_Admin_Page) {
107
+			remove_action(
108
+				'AHEE__template_settings__template__before_settings_form',
109
+				array($gen_set_admin, 'template_settings_caff_features'),
110
+				100
111
+			);
112
+		}
113
+		// first just grab the template settings
114
+		$config = EE_Registry::instance()->CFG->template_settings;
115
+		// then if the Event Archive config is valid, use that, else create a new one
116
+		$config = $config instanceof EE_Template_Config
117
+				  && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
118
+			? $config->EED_Events_Archive
119
+			: new EE_Events_Archive_Config();
120
+		$config = apply_filters(
121
+			'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
122
+			$config
123
+		);
124
+		$config->display_status_banner = isset($config->display_status_banner)
125
+			? $config->display_status_banner
126
+			: 0;
127
+		$config->display_description = isset($config->display_description)
128
+			? $config->display_description
129
+			: 1;
130
+		$config->display_ticket_selector = isset($config->display_ticket_selector)
131
+			? $config->display_ticket_selector
132
+			: 0;
133
+		$config->display_datetimes = isset($config->display_datetimes)
134
+			? $config->display_datetimes
135
+			: 1;
136
+		$config->display_venue = isset($config->display_venue)
137
+			? $config->display_venue
138
+			: 0;
139
+		$config->display_expired_events = isset($config->display_expired_events)
140
+			? $config->display_expired_events
141
+			: 0;
142
+		// display order options
143
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
144
+			? $config->use_sortable_display_order
145
+			: false;
146
+		$config->display_order_tickets = isset($config->display_order_tickets)
147
+			? $config->display_order_tickets
148
+			: 120;
149
+		$config->display_order_datetimes = isset($config->display_order_datetimes)
150
+			? $config->display_order_datetimes
151
+			: 110;
152
+		$config->display_order_event = isset($config->display_order_event)
153
+			? $config->display_order_event
154
+			: 100;
155
+		$config->display_order_venue = isset($config->display_order_venue)
156
+			? $config->display_order_venue
157
+			: 130;
158
+		// get template parts
159
+		$template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
160
+		// convert to array so that we can add more properties
161
+		$config = get_object_vars($config);
162
+		$config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
163
+			'event-archive-sortable-js',
164
+			'',
165
+			'archive-sortable-li archive-sortable-js'
166
+		);
167
+		EEH_Template::display_template(
168
+			EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
169
+			$config
170
+		);
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * @param EE_Template_Config $CFG
176
-     * @param array              $REQ
177
-     * @return EE_Template_Config
178
-     */
179
-    public static function update_template_settings($CFG, $REQ)
180
-    {
181
-        // unless we are resetting the config...
182
-        if (
183
-            ! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
184
-            || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
185
-        ) {
186
-            /** @var EE_Events_Archive_Config $config */
187
-            $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config
188
-                ? $CFG->EED_Events_Archive
189
-                : new EE_Events_Archive_Config();
174
+	/**
175
+	 * @param EE_Template_Config $CFG
176
+	 * @param array              $REQ
177
+	 * @return EE_Template_Config
178
+	 */
179
+	public static function update_template_settings($CFG, $REQ)
180
+	{
181
+		// unless we are resetting the config...
182
+		if (
183
+			! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
184
+			|| absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
185
+		) {
186
+			/** @var EE_Events_Archive_Config $config */
187
+			$config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config
188
+				? $CFG->EED_Events_Archive
189
+				: new EE_Events_Archive_Config();
190 190
 
191
-            $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
192
-                ? absint($REQ['EED_Events_Archive_display_status_banner'])
193
-                : 0;
194
-            $config->display_description = isset($REQ['EED_Events_Archive_display_description'])
195
-                ? absint($REQ['EED_Events_Archive_display_description'])
196
-                : 1;
197
-            $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
198
-                ? absint($REQ['EED_Events_Archive_display_ticket_selector'])
199
-                : 0;
200
-            $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes'])
201
-                ? absint($REQ['EED_Events_Archive_display_datetimes'])
202
-                : 1;
203
-            $config->display_venue = isset($REQ['EED_Events_Archive_display_venue'])
204
-                ? absint($REQ['EED_Events_Archive_display_venue'])
205
-                : 0;
206
-            $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
207
-                ? absint($REQ['EED_Events_Archive_display_expired_events'])
208
-                : 0;
209
-            $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order'])
210
-                ? absint($REQ['EED_Events_Archive_use_sortable_display_order'])
211
-                : 0;
212
-            $config->display_order_event = $config->display_order_event !== null
213
-                                           && $config->use_sortable_display_order
214
-                ? $config->display_order_event
215
-                : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
216
-            $config->display_order_datetimes = $config->display_order_datetimes !== null
217
-                                               && $config->use_sortable_display_order
218
-                ? $config->display_order_datetimes
219
-                : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
220
-            $config->display_order_tickets = $config->display_order_tickets !== null
221
-                                             && $config->use_sortable_display_order
222
-                ? $config->display_order_tickets
223
-                : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
224
-            $config->display_order_venue = $config->display_order_venue !== null
225
-                                           && $config->use_sortable_display_order
226
-                ? $config->display_order_venue
227
-                : EED_Events_Archive::EVENT_VENUES_PRIORITY;
228
-        } else {
229
-            $config = new EE_Events_Archive_Config();
230
-        }
191
+			$config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
192
+				? absint($REQ['EED_Events_Archive_display_status_banner'])
193
+				: 0;
194
+			$config->display_description = isset($REQ['EED_Events_Archive_display_description'])
195
+				? absint($REQ['EED_Events_Archive_display_description'])
196
+				: 1;
197
+			$config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
198
+				? absint($REQ['EED_Events_Archive_display_ticket_selector'])
199
+				: 0;
200
+			$config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes'])
201
+				? absint($REQ['EED_Events_Archive_display_datetimes'])
202
+				: 1;
203
+			$config->display_venue = isset($REQ['EED_Events_Archive_display_venue'])
204
+				? absint($REQ['EED_Events_Archive_display_venue'])
205
+				: 0;
206
+			$config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
207
+				? absint($REQ['EED_Events_Archive_display_expired_events'])
208
+				: 0;
209
+			$config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order'])
210
+				? absint($REQ['EED_Events_Archive_use_sortable_display_order'])
211
+				: 0;
212
+			$config->display_order_event = $config->display_order_event !== null
213
+										   && $config->use_sortable_display_order
214
+				? $config->display_order_event
215
+				: EED_Events_Archive::EVENT_DETAILS_PRIORITY;
216
+			$config->display_order_datetimes = $config->display_order_datetimes !== null
217
+											   && $config->use_sortable_display_order
218
+				? $config->display_order_datetimes
219
+				: EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
220
+			$config->display_order_tickets = $config->display_order_tickets !== null
221
+											 && $config->use_sortable_display_order
222
+				? $config->display_order_tickets
223
+				: EED_Events_Archive::EVENT_TICKETS_PRIORITY;
224
+			$config->display_order_venue = $config->display_order_venue !== null
225
+										   && $config->use_sortable_display_order
226
+				? $config->display_order_venue
227
+				: EED_Events_Archive::EVENT_VENUES_PRIORITY;
228
+		} else {
229
+			$config = new EE_Events_Archive_Config();
230
+		}
231 231
 
232
-        $CFG->EED_Events_Archive = $config;
233
-        do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
234
-        return $CFG;
235
-    }
232
+		$CFG->EED_Events_Archive = $config;
233
+		do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
234
+		return $CFG;
235
+	}
236 236
 
237 237
 
238
-    /**
239
-     * @return void
240
-     * @throws InvalidArgumentException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidInterfaceException
243
-     */
244
-    public static function update_event_archive_order()
245
-    {
246
-        /** @var EE_Config $config */
247
-        $config = EE_Registry::instance()->CFG;
248
-        $config_saved = false;
249
-        $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements');
250
-        if (! empty($template_parts)) {
251
-            $template_parts = explode(',', trim($template_parts, ','));
252
-            foreach ($template_parts as $key => $template_part) {
253
-                $template_part = "display_order_$template_part";
254
-                $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
255
-                if (
256
-                    $config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config
257
-                    && property_exists(
258
-                        $config->template_settings->EED_Events_Archive,
259
-                        $template_part
260
-                    )
261
-                ) {
262
-                    $config->template_settings->EED_Events_Archive->{$template_part} = $priority;
263
-                }
264
-                do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
265
-            }
266
-            $config_saved = $config->update_espresso_config(false, false);
267
-        }
268
-        if ($config_saved) {
269
-            EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
270
-        } else {
271
-            EE_Error::add_error(
272
-                esc_html__('Display Order was not updated.', 'event_espresso'),
273
-                __FILE__,
274
-                __FUNCTION__,
275
-                __LINE__
276
-            );
277
-        }
278
-        echo wp_json_encode(EE_Error::get_notices(false));
279
-        exit();
280
-    }
238
+	/**
239
+	 * @return void
240
+	 * @throws InvalidArgumentException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidInterfaceException
243
+	 */
244
+	public static function update_event_archive_order()
245
+	{
246
+		/** @var EE_Config $config */
247
+		$config = EE_Registry::instance()->CFG;
248
+		$config_saved = false;
249
+		$template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements');
250
+		if (! empty($template_parts)) {
251
+			$template_parts = explode(',', trim($template_parts, ','));
252
+			foreach ($template_parts as $key => $template_part) {
253
+				$template_part = "display_order_$template_part";
254
+				$priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
255
+				if (
256
+					$config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config
257
+					&& property_exists(
258
+						$config->template_settings->EED_Events_Archive,
259
+						$template_part
260
+					)
261
+				) {
262
+					$config->template_settings->EED_Events_Archive->{$template_part} = $priority;
263
+				}
264
+				do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
265
+			}
266
+			$config_saved = $config->update_espresso_config(false, false);
267
+		}
268
+		if ($config_saved) {
269
+			EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
270
+		} else {
271
+			EE_Error::add_error(
272
+				esc_html__('Display Order was not updated.', 'event_espresso'),
273
+				__FILE__,
274
+				__FUNCTION__,
275
+				__LINE__
276
+			);
277
+		}
278
+		echo wp_json_encode(EE_Error::get_notices(false));
279
+		exit();
280
+	}
281 281
 }
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 2 patches
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -14,474 +14,474 @@  discard block
 block discarded – undo
14 14
 class EED_Event_Single extends EED_Module
15 15
 {
16 16
 
17
-    const EVENT_DETAILS_PRIORITY = 100;
18
-    const EVENT_DATETIMES_PRIORITY = 110;
19
-    const EVENT_TICKETS_PRIORITY = 120;
20
-    const EVENT_VENUES_PRIORITY = 130;
21
-
22
-    /**
23
-     * @type bool $using_get_the_excerpt
24
-     */
25
-    protected static $using_get_the_excerpt = false;
26
-
27
-
28
-    /**
29
-     * @type EE_Template_Part_Manager $template_parts
30
-     */
31
-    protected $template_parts;
32
-
33
-
34
-    /**
35
-     * @return EED_Module|EED_Event_Single
36
-     */
37
-    public static function instance()
38
-    {
39
-        return parent::get_instance(__CLASS__);
40
-    }
41
-
42
-
43
-    /**
44
-     * set_hooks - for hooking into EE Core, other modules, etc
45
-     *
46
-     * @return void
47
-     * @throws InvalidArgumentException
48
-     * @throws InvalidDataTypeException
49
-     * @throws InvalidInterfaceException
50
-     */
51
-    public static function set_hooks()
52
-    {
53
-        add_filter('FHEE_run_EE_wp', '__return_true');
54
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
-        );
59
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
60
-        EE_Config::register_route(
61
-            $custom_post_types['espresso_events']['singular_slug'],
62
-            'Event_Single',
63
-            'run'
64
-        );
65
-    }
66
-
67
-    /**
68
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
-     *
70
-     * @return    void
71
-     */
72
-    public static function set_hooks_admin()
73
-    {
74
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
-    }
76
-
77
-
78
-    /**
79
-     * set_definitions
80
-     *
81
-     * @static
82
-     * @return void
83
-     */
84
-    public static function set_definitions()
85
-    {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
-    }
89
-
90
-
91
-    /**
92
-     * set_config
93
-     *
94
-     * @void
95
-     */
96
-    protected function set_config()
97
-    {
98
-        $this->set_config_section('template_settings');
99
-        $this->set_config_class('EE_Event_Single_Config');
100
-        $this->set_config_name('EED_Event_Single');
101
-    }
102
-
103
-
104
-    /**
105
-     * initialize_template_parts
106
-     *
107
-     * @param EE_Config_Base|EE_Event_Single_Config $config
108
-     * @return EE_Template_Part_Manager
109
-     */
110
-    public function initialize_template_parts(EE_Event_Single_Config $config = null)
111
-    {
112
-        /** @type EE_Event_Single_Config $config */
113
-        $config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
114
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
115
-        $template_parts = new EE_Template_Part_Manager();
116
-        $template_parts->add_template_part(
117
-            'tickets',
118
-            esc_html__('Ticket Selector', 'event_espresso'),
119
-            'content-espresso_events-tickets.php',
120
-            $config->display_order_tickets
121
-        );
122
-        $template_parts->add_template_part(
123
-            'datetimes',
124
-            esc_html__('Dates and Times', 'event_espresso'),
125
-            'content-espresso_events-datetimes.php',
126
-            $config->display_order_datetimes
127
-        );
128
-        $template_parts->add_template_part(
129
-            'event',
130
-            esc_html__('Event Description', 'event_espresso'),
131
-            'content-espresso_events-details.php',
132
-            $config->display_order_event
133
-        );
134
-        $template_parts->add_template_part(
135
-            'venue',
136
-            esc_html__('Venue Information', 'event_espresso'),
137
-            'content-espresso_events-venues.php',
138
-            $config->display_order_venue
139
-        );
140
-        do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
141
-        return $template_parts;
142
-    }
143
-
144
-
145
-    /**
146
-     * run - initial module setup
147
-     *
148
-     * @param WP $WP
149
-     * @return    void
150
-     */
151
-    public function run($WP)
152
-    {
153
-        // ensure valid EE_Events_Single_Config() object exists
154
-        $this->set_config();
155
-        // check what template is loaded
156
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
157
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
158
-        // load css
159
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
160
-    }
161
-
162
-
163
-    /**
164
-     * template_include
165
-     *
166
-     * @param    string $template
167
-     * @return    string
168
-     */
169
-    public function template_include($template)
170
-    {
171
-        global $post;
172
-        /** @type EE_Event_Single_Config $config */
173
-        $config = $this->config();
174
-        if ($config->display_status_banner_single) {
175
-            add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
176
-        }
177
-        // not a custom template?
178
-        if (
179
-            ! post_password_required($post)
180
-            && (
181
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
182
-                || EE_Registry::instance()
183
-                              ->load_core('Front_Controller')
184
-                              ->get_selected_template() !== 'single-espresso_events.php'
185
-            )
186
-        ) {
187
-            EEH_Template::load_espresso_theme_functions();
188
-            // then add extra event data via hooks
189
-            add_action('loop_start', array('EED_Event_Single', 'loop_start'));
190
-            add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
191
-            add_filter(
192
-                'the_content',
193
-                array('EED_Event_Single', 'event_details'),
194
-                EED_Event_Single::EVENT_DETAILS_PRIORITY
195
-            );
196
-            add_action('loop_end', array('EED_Event_Single', 'loop_end'));
197
-            // don't display entry meta because the existing theme will take car of that
198
-            add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
199
-        }
200
-        return $template;
201
-    }
202
-
203
-
204
-    /**
205
-     * loop_start
206
-     *
207
-     * @param    array $wp_query_array an array containing the WP_Query object
208
-     * @return    void
209
-     */
210
-    public static function loop_start($wp_query_array)
211
-    {
212
-        global $post;
213
-        do_action('AHEE_event_details_before_post', $post, $wp_query_array);
214
-    }
215
-
216
-
217
-    /**
218
-     * the_title
219
-     *
220
-     * @param    string $title
221
-     * @param    int    $id
222
-     * @return    string
223
-     */
224
-    public static function the_title($title = '', $id = 0)
225
-    {
226
-        global $post;
227
-        return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
228
-            ? espresso_event_status_banner($post->ID) . $title
229
-            : $title;
230
-    }
231
-
232
-
233
-    /**
234
-     * get_the_excerpt
235
-     * kinda hacky, but if a theme is using get_the_excerpt(),
236
-     * then we need to remove our filters on the_content()
237
-     *
238
-     * @param        string $excerpt
239
-     * @return        string
240
-     */
241
-    public static function get_the_excerpt($excerpt = '')
242
-    {
243
-        EED_Event_Single::$using_get_the_excerpt = true;
244
-        add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
245
-        return $excerpt;
246
-    }
247
-
248
-
249
-    /**
250
-     * end_get_the_excerpt
251
-     *
252
-     * @param  string $text
253
-     * @return string
254
-     */
255
-    public static function end_get_the_excerpt($text = '')
256
-    {
257
-        EED_Event_Single::$using_get_the_excerpt = false;
258
-        return $text;
259
-    }
260
-
261
-
262
-    /**
263
-     * event_details
264
-     *
265
-     * @param    string $content
266
-     * @return    string
267
-     */
268
-    public static function event_details($content)
269
-    {
270
-        global $post;
271
-        static $current_post_ID = 0;
272
-        if (
273
-            $current_post_ID !== $post->ID
274
-            && $post->post_type === 'espresso_events'
275
-            && ! EED_Event_Single::$using_get_the_excerpt
276
-            && ! post_password_required()
277
-        ) {
278
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
279
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
280
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
281
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
282
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
283
-            // so the following allows this filter to be applied multiple times, but only once for real
284
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
285
-            if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
286
-                // we need to first remove this callback from being applied to the_content()
287
-                // (otherwise it will recurse and blow up the interweb)
288
-                remove_filter(
289
-                    'the_content',
290
-                    array('EED_Event_Single', 'event_details'),
291
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
292
-                );
293
-                EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
294
-                );
295
-                $content = EEH_Template::locate_template('content-espresso_events-details.php');
296
-                $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
297
-                add_filter(
298
-                    'the_content',
299
-                    array('EED_Event_Single', 'event_details'),
300
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
301
-                );
302
-            } else {
303
-                $content = EED_Event_Single::use_filterable_display_order();
304
-            }
305
-        }
306
-        return $content;
307
-    }
308
-
309
-
310
-    /**
311
-     * use_filterable_display_order
312
-     *
313
-     * @return string
314
-     */
315
-    protected static function use_filterable_display_order()
316
-    {
317
-        // since the 'content-espresso_events-details.php' template might be used directly from within a theme,
318
-        // it uses the_content() for displaying the $post->post_content
319
-        // so in order to load a template that uses the_content()
320
-        // from within a callback being used to filter the_content(),
321
-        // we need to first remove this callback from being applied to the_content()
322
-        // (otherwise it will recurse and blow up the interweb)
323
-        remove_filter(
324
-            'the_content',
325
-            array('EED_Event_Single', 'event_details'),
326
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
327
-        );
328
-        // now add additional content
329
-        add_filter(
330
-            'the_content',
331
-            array('EED_Event_Single', 'event_datetimes'),
332
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY,
333
-            1
334
-        );
335
-        add_filter(
336
-            'the_content',
337
-            array('EED_Event_Single', 'event_tickets'),
338
-            EED_Event_Single::EVENT_TICKETS_PRIORITY,
339
-            1
340
-        );
341
-        add_filter(
342
-            'the_content',
343
-            array('EED_Event_Single', 'event_venues'),
344
-            EED_Event_Single::EVENT_VENUES_PRIORITY,
345
-            1
346
-        );
347
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
348
-        // now load our template
349
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
350
-        // now add our filter back in, plus some others
351
-        add_filter(
352
-            'the_content',
353
-            array('EED_Event_Single', 'event_details'),
354
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
355
-        );
356
-        remove_filter(
357
-            'the_content',
358
-            array('EED_Event_Single', 'event_datetimes'),
359
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY
360
-        );
361
-        remove_filter(
362
-            'the_content',
363
-            array('EED_Event_Single', 'event_tickets'),
364
-            EED_Event_Single::EVENT_TICKETS_PRIORITY
365
-        );
366
-        remove_filter(
367
-            'the_content',
368
-            array('EED_Event_Single', 'event_venues'),
369
-            EED_Event_Single::EVENT_VENUES_PRIORITY
370
-        );
371
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
372
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
373
-        return $content;
374
-    }
375
-
376
-
377
-    /**
378
-     * event_datetimes - adds datetimes ABOVE content
379
-     *
380
-     * @param        string $content
381
-     * @return        string
382
-     */
383
-    public static function event_datetimes($content)
384
-    {
385
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
-    }
387
-
388
-
389
-    /**
390
-     * event_tickets - adds tickets ABOVE content (which includes datetimes)
391
-     *
392
-     * @param        string $content
393
-     * @return        string
394
-     */
395
-    public static function event_tickets($content)
396
-    {
397
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
-    }
399
-
400
-
401
-    /**
402
-     * event_venues
403
-     *
404
-     * @param    string $content
405
-     * @return    string
406
-     */
407
-    public static function event_venue($content)
408
-    {
409
-        return EED_Event_Single::event_venues($content);
410
-    }
411
-
412
-
413
-    /**
414
-     * event_venues - adds venues BELOW content
415
-     *
416
-     * @param        string $content
417
-     * @return        string
418
-     */
419
-    public static function event_venues($content)
420
-    {
421
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
-    }
423
-
424
-
425
-    /**
426
-     * loop_end
427
-     *
428
-     * @param        array $wp_query_array an array containing the WP_Query object
429
-     * @return        void
430
-     */
431
-    public static function loop_end($wp_query_array)
432
-    {
433
-        global $post;
434
-        do_action('AHEE_event_details_after_post', $post, $wp_query_array);
435
-    }
436
-
437
-
438
-    /**
439
-     * wp_enqueue_scripts
440
-     *
441
-     * @return    void
442
-     */
443
-    public function wp_enqueue_scripts()
444
-    {
445
-        // get some style
446
-        if (
447
-            apply_filters('FHEE_enable_default_espresso_css', true)
448
-            && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
449
-        ) {
450
-            // first check uploads folder
451
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
-                wp_register_style(
453
-                    $this->theme,
454
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
-                    array('dashicons', 'espresso_default')
456
-                );
457
-            } else {
458
-                wp_register_style(
459
-                    $this->theme,
460
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
461
-                    array('dashicons', 'espresso_default')
462
-                );
463
-            }
464
-            wp_enqueue_script($this->theme);
465
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
466
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
467
-            }
468
-        }
469
-    }
470
-
471
-
472
-    /**
473
-     * display_venue
474
-     *
475
-     * @return    bool
476
-     */
477
-    public static function display_venue()
478
-    {
479
-        /** @type EE_Event_Single_Config $config */
480
-        $config = EED_Event_Single::instance()->config();
481
-        $display_venue = $config->display_venue === null ? true : $config->display_venue;
482
-        $venue_name = EEH_Venue_View::venue_name();
483
-        return $display_venue && ! empty($venue_name);
484
-    }
17
+	const EVENT_DETAILS_PRIORITY = 100;
18
+	const EVENT_DATETIMES_PRIORITY = 110;
19
+	const EVENT_TICKETS_PRIORITY = 120;
20
+	const EVENT_VENUES_PRIORITY = 130;
21
+
22
+	/**
23
+	 * @type bool $using_get_the_excerpt
24
+	 */
25
+	protected static $using_get_the_excerpt = false;
26
+
27
+
28
+	/**
29
+	 * @type EE_Template_Part_Manager $template_parts
30
+	 */
31
+	protected $template_parts;
32
+
33
+
34
+	/**
35
+	 * @return EED_Module|EED_Event_Single
36
+	 */
37
+	public static function instance()
38
+	{
39
+		return parent::get_instance(__CLASS__);
40
+	}
41
+
42
+
43
+	/**
44
+	 * set_hooks - for hooking into EE Core, other modules, etc
45
+	 *
46
+	 * @return void
47
+	 * @throws InvalidArgumentException
48
+	 * @throws InvalidDataTypeException
49
+	 * @throws InvalidInterfaceException
50
+	 */
51
+	public static function set_hooks()
52
+	{
53
+		add_filter('FHEE_run_EE_wp', '__return_true');
54
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
+		);
59
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
60
+		EE_Config::register_route(
61
+			$custom_post_types['espresso_events']['singular_slug'],
62
+			'Event_Single',
63
+			'run'
64
+		);
65
+	}
66
+
67
+	/**
68
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
+	 *
70
+	 * @return    void
71
+	 */
72
+	public static function set_hooks_admin()
73
+	{
74
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
+	}
76
+
77
+
78
+	/**
79
+	 * set_definitions
80
+	 *
81
+	 * @static
82
+	 * @return void
83
+	 */
84
+	public static function set_definitions()
85
+	{
86
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
+	}
89
+
90
+
91
+	/**
92
+	 * set_config
93
+	 *
94
+	 * @void
95
+	 */
96
+	protected function set_config()
97
+	{
98
+		$this->set_config_section('template_settings');
99
+		$this->set_config_class('EE_Event_Single_Config');
100
+		$this->set_config_name('EED_Event_Single');
101
+	}
102
+
103
+
104
+	/**
105
+	 * initialize_template_parts
106
+	 *
107
+	 * @param EE_Config_Base|EE_Event_Single_Config $config
108
+	 * @return EE_Template_Part_Manager
109
+	 */
110
+	public function initialize_template_parts(EE_Event_Single_Config $config = null)
111
+	{
112
+		/** @type EE_Event_Single_Config $config */
113
+		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
114
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
115
+		$template_parts = new EE_Template_Part_Manager();
116
+		$template_parts->add_template_part(
117
+			'tickets',
118
+			esc_html__('Ticket Selector', 'event_espresso'),
119
+			'content-espresso_events-tickets.php',
120
+			$config->display_order_tickets
121
+		);
122
+		$template_parts->add_template_part(
123
+			'datetimes',
124
+			esc_html__('Dates and Times', 'event_espresso'),
125
+			'content-espresso_events-datetimes.php',
126
+			$config->display_order_datetimes
127
+		);
128
+		$template_parts->add_template_part(
129
+			'event',
130
+			esc_html__('Event Description', 'event_espresso'),
131
+			'content-espresso_events-details.php',
132
+			$config->display_order_event
133
+		);
134
+		$template_parts->add_template_part(
135
+			'venue',
136
+			esc_html__('Venue Information', 'event_espresso'),
137
+			'content-espresso_events-venues.php',
138
+			$config->display_order_venue
139
+		);
140
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
141
+		return $template_parts;
142
+	}
143
+
144
+
145
+	/**
146
+	 * run - initial module setup
147
+	 *
148
+	 * @param WP $WP
149
+	 * @return    void
150
+	 */
151
+	public function run($WP)
152
+	{
153
+		// ensure valid EE_Events_Single_Config() object exists
154
+		$this->set_config();
155
+		// check what template is loaded
156
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
157
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
158
+		// load css
159
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
160
+	}
161
+
162
+
163
+	/**
164
+	 * template_include
165
+	 *
166
+	 * @param    string $template
167
+	 * @return    string
168
+	 */
169
+	public function template_include($template)
170
+	{
171
+		global $post;
172
+		/** @type EE_Event_Single_Config $config */
173
+		$config = $this->config();
174
+		if ($config->display_status_banner_single) {
175
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
176
+		}
177
+		// not a custom template?
178
+		if (
179
+			! post_password_required($post)
180
+			&& (
181
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
182
+				|| EE_Registry::instance()
183
+							  ->load_core('Front_Controller')
184
+							  ->get_selected_template() !== 'single-espresso_events.php'
185
+			)
186
+		) {
187
+			EEH_Template::load_espresso_theme_functions();
188
+			// then add extra event data via hooks
189
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
190
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
191
+			add_filter(
192
+				'the_content',
193
+				array('EED_Event_Single', 'event_details'),
194
+				EED_Event_Single::EVENT_DETAILS_PRIORITY
195
+			);
196
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
197
+			// don't display entry meta because the existing theme will take car of that
198
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
199
+		}
200
+		return $template;
201
+	}
202
+
203
+
204
+	/**
205
+	 * loop_start
206
+	 *
207
+	 * @param    array $wp_query_array an array containing the WP_Query object
208
+	 * @return    void
209
+	 */
210
+	public static function loop_start($wp_query_array)
211
+	{
212
+		global $post;
213
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
214
+	}
215
+
216
+
217
+	/**
218
+	 * the_title
219
+	 *
220
+	 * @param    string $title
221
+	 * @param    int    $id
222
+	 * @return    string
223
+	 */
224
+	public static function the_title($title = '', $id = 0)
225
+	{
226
+		global $post;
227
+		return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
228
+			? espresso_event_status_banner($post->ID) . $title
229
+			: $title;
230
+	}
231
+
232
+
233
+	/**
234
+	 * get_the_excerpt
235
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
236
+	 * then we need to remove our filters on the_content()
237
+	 *
238
+	 * @param        string $excerpt
239
+	 * @return        string
240
+	 */
241
+	public static function get_the_excerpt($excerpt = '')
242
+	{
243
+		EED_Event_Single::$using_get_the_excerpt = true;
244
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
245
+		return $excerpt;
246
+	}
247
+
248
+
249
+	/**
250
+	 * end_get_the_excerpt
251
+	 *
252
+	 * @param  string $text
253
+	 * @return string
254
+	 */
255
+	public static function end_get_the_excerpt($text = '')
256
+	{
257
+		EED_Event_Single::$using_get_the_excerpt = false;
258
+		return $text;
259
+	}
260
+
261
+
262
+	/**
263
+	 * event_details
264
+	 *
265
+	 * @param    string $content
266
+	 * @return    string
267
+	 */
268
+	public static function event_details($content)
269
+	{
270
+		global $post;
271
+		static $current_post_ID = 0;
272
+		if (
273
+			$current_post_ID !== $post->ID
274
+			&& $post->post_type === 'espresso_events'
275
+			&& ! EED_Event_Single::$using_get_the_excerpt
276
+			&& ! post_password_required()
277
+		) {
278
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
279
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
280
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
281
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
282
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
283
+			// so the following allows this filter to be applied multiple times, but only once for real
284
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
285
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
286
+				// we need to first remove this callback from being applied to the_content()
287
+				// (otherwise it will recurse and blow up the interweb)
288
+				remove_filter(
289
+					'the_content',
290
+					array('EED_Event_Single', 'event_details'),
291
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
292
+				);
293
+				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
294
+				);
295
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
296
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
297
+				add_filter(
298
+					'the_content',
299
+					array('EED_Event_Single', 'event_details'),
300
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
301
+				);
302
+			} else {
303
+				$content = EED_Event_Single::use_filterable_display_order();
304
+			}
305
+		}
306
+		return $content;
307
+	}
308
+
309
+
310
+	/**
311
+	 * use_filterable_display_order
312
+	 *
313
+	 * @return string
314
+	 */
315
+	protected static function use_filterable_display_order()
316
+	{
317
+		// since the 'content-espresso_events-details.php' template might be used directly from within a theme,
318
+		// it uses the_content() for displaying the $post->post_content
319
+		// so in order to load a template that uses the_content()
320
+		// from within a callback being used to filter the_content(),
321
+		// we need to first remove this callback from being applied to the_content()
322
+		// (otherwise it will recurse and blow up the interweb)
323
+		remove_filter(
324
+			'the_content',
325
+			array('EED_Event_Single', 'event_details'),
326
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
327
+		);
328
+		// now add additional content
329
+		add_filter(
330
+			'the_content',
331
+			array('EED_Event_Single', 'event_datetimes'),
332
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY,
333
+			1
334
+		);
335
+		add_filter(
336
+			'the_content',
337
+			array('EED_Event_Single', 'event_tickets'),
338
+			EED_Event_Single::EVENT_TICKETS_PRIORITY,
339
+			1
340
+		);
341
+		add_filter(
342
+			'the_content',
343
+			array('EED_Event_Single', 'event_venues'),
344
+			EED_Event_Single::EVENT_VENUES_PRIORITY,
345
+			1
346
+		);
347
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
348
+		// now load our template
349
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
350
+		// now add our filter back in, plus some others
351
+		add_filter(
352
+			'the_content',
353
+			array('EED_Event_Single', 'event_details'),
354
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
355
+		);
356
+		remove_filter(
357
+			'the_content',
358
+			array('EED_Event_Single', 'event_datetimes'),
359
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY
360
+		);
361
+		remove_filter(
362
+			'the_content',
363
+			array('EED_Event_Single', 'event_tickets'),
364
+			EED_Event_Single::EVENT_TICKETS_PRIORITY
365
+		);
366
+		remove_filter(
367
+			'the_content',
368
+			array('EED_Event_Single', 'event_venues'),
369
+			EED_Event_Single::EVENT_VENUES_PRIORITY
370
+		);
371
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
372
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
373
+		return $content;
374
+	}
375
+
376
+
377
+	/**
378
+	 * event_datetimes - adds datetimes ABOVE content
379
+	 *
380
+	 * @param        string $content
381
+	 * @return        string
382
+	 */
383
+	public static function event_datetimes($content)
384
+	{
385
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
+	}
387
+
388
+
389
+	/**
390
+	 * event_tickets - adds tickets ABOVE content (which includes datetimes)
391
+	 *
392
+	 * @param        string $content
393
+	 * @return        string
394
+	 */
395
+	public static function event_tickets($content)
396
+	{
397
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
+	}
399
+
400
+
401
+	/**
402
+	 * event_venues
403
+	 *
404
+	 * @param    string $content
405
+	 * @return    string
406
+	 */
407
+	public static function event_venue($content)
408
+	{
409
+		return EED_Event_Single::event_venues($content);
410
+	}
411
+
412
+
413
+	/**
414
+	 * event_venues - adds venues BELOW content
415
+	 *
416
+	 * @param        string $content
417
+	 * @return        string
418
+	 */
419
+	public static function event_venues($content)
420
+	{
421
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
+	}
423
+
424
+
425
+	/**
426
+	 * loop_end
427
+	 *
428
+	 * @param        array $wp_query_array an array containing the WP_Query object
429
+	 * @return        void
430
+	 */
431
+	public static function loop_end($wp_query_array)
432
+	{
433
+		global $post;
434
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
435
+	}
436
+
437
+
438
+	/**
439
+	 * wp_enqueue_scripts
440
+	 *
441
+	 * @return    void
442
+	 */
443
+	public function wp_enqueue_scripts()
444
+	{
445
+		// get some style
446
+		if (
447
+			apply_filters('FHEE_enable_default_espresso_css', true)
448
+			&& apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
449
+		) {
450
+			// first check uploads folder
451
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
+				wp_register_style(
453
+					$this->theme,
454
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
+					array('dashicons', 'espresso_default')
456
+				);
457
+			} else {
458
+				wp_register_style(
459
+					$this->theme,
460
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
461
+					array('dashicons', 'espresso_default')
462
+				);
463
+			}
464
+			wp_enqueue_script($this->theme);
465
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
466
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
467
+			}
468
+		}
469
+	}
470
+
471
+
472
+	/**
473
+	 * display_venue
474
+	 *
475
+	 * @return    bool
476
+	 */
477
+	public static function display_venue()
478
+	{
479
+		/** @type EE_Event_Single_Config $config */
480
+		$config = EED_Event_Single::instance()->config();
481
+		$display_venue = $config->display_venue === null ? true : $config->display_venue;
482
+		$venue_name = EEH_Venue_View::venue_name();
483
+		return $display_venue && ! empty($venue_name);
484
+	}
485 485
 }
486 486
 
487 487
 
@@ -493,5 +493,5 @@  discard block
 block discarded – undo
493 493
  */
494 494
 function espresso_display_venue_in_event_details()
495 495
 {
496
-    return EED_Event_Single::display_venue();
496
+	return EED_Event_Single::display_venue();
497 497
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function set_definitions()
85 85
     {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
86
+        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
87
+        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/');
88 88
     }
89 89
 
90 90
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     {
226 226
         global $post;
227 227
         return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
228
-            ? espresso_event_status_banner($post->ID) . $title
228
+            ? espresso_event_status_banner($post->ID).$title
229 229
             : $title;
230 230
     }
231 231
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public static function event_datetimes($content)
384 384
     {
385
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
385
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
386 386
     }
387 387
 
388 388
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
      */
395 395
     public static function event_tickets($content)
396 396
     {
397
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
397
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
398 398
     }
399 399
 
400 400
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public static function event_venues($content)
420 420
     {
421
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
421
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
422 422
     }
423 423
 
424 424
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
             && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
449 449
         ) {
450 450
             // first check uploads folder
451
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
451
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
452 452
                 wp_register_style(
453 453
                     $this->theme,
454
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
454
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
455 455
                     array('dashicons', 'espresso_default')
456 456
                 );
457 457
             } else {
458 458
                 wp_register_style(
459 459
                     $this->theme,
460
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
460
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
461 461
                     array('dashicons', 'espresso_default')
462 462
                 );
463 463
             }
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +1104 added lines, -1104 removed lines patch added patch discarded remove patch
@@ -16,1099 +16,1099 @@  discard block
 block discarded – undo
16 16
 class EED_Events_Archive extends EED_Module
17 17
 {
18 18
 
19
-    const EVENT_DETAILS_PRIORITY = 100;
20
-
21
-    const EVENT_DATETIMES_PRIORITY = 110;
22
-
23
-    const EVENT_TICKETS_PRIORITY = 120;
24
-
25
-    const EVENT_VENUES_PRIORITY = 130;
26
-
27
-
28
-    public static $espresso_event_list_ID = 0;
29
-
30
-    public static $espresso_grid_event_lists = array();
31
-
32
-    /**
33
-     * @type bool $using_get_the_excerpt
34
-     */
35
-    protected static $using_get_the_excerpt = false;
36
-
37
-    /**
38
-     * Used to flag when the event list is being called from an external iframe.
39
-     *
40
-     * @var bool $iframe
41
-     */
42
-    protected static $iframe = false;
43
-
44
-    /**
45
-     * @var EventListIframeEmbedButton $_iframe_embed_button
46
-     */
47
-    private static $_iframe_embed_button;
48
-
49
-    /**
50
-     * @type EE_Template_Part_Manager $template_parts
51
-     */
52
-    protected $template_parts;
53
-
54
-
55
-    /**
56
-     * @return EED_Events_Archive
57
-     */
58
-    public static function instance()
59
-    {
60
-        return parent::get_instance(__CLASS__);
61
-    }
62
-
63
-
64
-    /**
65
-     * set_hooks - for hooking into EE Core, other modules, etc
66
-     *
67
-     * @return void
68
-     * @throws InvalidArgumentException
69
-     * @throws InvalidDataTypeException
70
-     * @throws InvalidInterfaceException
71
-     */
72
-    public static function set_hooks()
73
-    {
74
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
75
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
76
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
77
-        );
78
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
79
-        EE_Config::register_route(
80
-            $custom_post_types['espresso_events']['plural_slug'],
81
-            'Events_Archive',
82
-            'run'
83
-        );
84
-        EE_Config::register_route(
85
-            'event_list',
86
-            'Events_Archive',
87
-            'event_list'
88
-        );
89
-        EE_Config::register_route(
90
-            'iframe',
91
-            'Events_Archive',
92
-            'event_list_iframe',
93
-            'event_list'
94
-        );
95
-        add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
96
-    }
97
-
98
-
99
-    /**
100
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
101
-     *
102
-     * @access    public
103
-     * @return    void
104
-     */
105
-    public static function set_hooks_admin()
106
-    {
107
-        add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
108
-        // hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
-        // to load assets for "espresso_events" page on the "default" route (action)
110
-        add_action(
111
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
-            array('EED_Events_Archive', 'event_list_iframe_embed_button'),
113
-            10
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     *    set_definitions
120
-     *
121
-     * @access    public
122
-     * @return    void
123
-     */
124
-    public static function set_definitions()
125
-    {
126
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
128
-    }
129
-
130
-
131
-    /**
132
-     * set up EE_Events_Archive_Config
133
-     */
134
-    protected function set_config()
135
-    {
136
-        $this->set_config_section('template_settings');
137
-        $this->set_config_class('EE_Events_Archive_Config');
138
-        $this->set_config_name('EED_Events_Archive');
139
-    }
140
-
141
-
142
-    /**
143
-     * @return EventListIframeEmbedButton
144
-     */
145
-    public static function get_iframe_embed_button()
146
-    {
147
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148
-            self::$_iframe_embed_button = new EventListIframeEmbedButton();
149
-        }
150
-        return self::$_iframe_embed_button;
151
-    }
152
-
153
-
154
-    /**
155
-     * event_list_iframe_embed_button
156
-     *
157
-     * @return    void
158
-     * @throws EE_Error
159
-     */
160
-    public static function event_list_iframe_embed_button()
161
-    {
162
-        $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
163
-        $iframe_embed_button->addEmbedButton();
164
-    }
165
-
166
-
167
-    /**
168
-     *    initialize_template_parts
169
-     *
170
-     * @access    public
171
-     * @param EE_Events_Archive_Config $config
172
-     * @return EE_Template_Part_Manager
173
-     */
174
-    public function initialize_template_parts(EE_Events_Archive_Config $config = null)
175
-    {
176
-        $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
177
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
178
-        $template_parts = new EE_Template_Part_Manager();
179
-        $template_parts->add_template_part(
180
-            'tickets',
181
-            esc_html__('Ticket Selector', 'event_espresso'),
182
-            'content-espresso_events-tickets.php',
183
-            $config->display_order_tickets
184
-        );
185
-        $template_parts->add_template_part(
186
-            'datetimes',
187
-            esc_html__('Dates and Times', 'event_espresso'),
188
-            'content-espresso_events-datetimes.php',
189
-            $config->display_order_datetimes
190
-        );
191
-        $template_parts->add_template_part(
192
-            'event',
193
-            esc_html__('Event Description', 'event_espresso'),
194
-            'content-espresso_events-details.php',
195
-            $config->display_order_event
196
-        );
197
-        $template_parts->add_template_part(
198
-            'venue',
199
-            esc_html__('Venue Information', 'event_espresso'),
200
-            'content-espresso_events-venues.php',
201
-            $config->display_order_venue
202
-        );
203
-        do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
204
-        return $template_parts;
205
-    }
206
-
207
-
208
-    /**
209
-     *    run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the
210
-     *    incoming request
211
-     *
212
-     * @access    public
213
-     * @param WP $WP
214
-     * @return    void
215
-     */
216
-    public function run($WP)
217
-    {
218
-        do_action('AHEE__EED_Events_Archive__before_run');
219
-        // ensure valid EE_Events_Archive_Config() object exists
220
-        $this->set_config();
221
-        /** @type EE_Events_Archive_Config $config */
222
-        $config = $this->config();
223
-        // load other required components
224
-        $this->load_event_list_assets();
225
-        // filter the WP posts_join, posts_where, and posts_orderby SQL clauses
226
-        // add query filters
227
-        EEH_Event_Query::add_query_filters();
228
-        // set params that will get used by the filters
229
-        EEH_Event_Query::set_query_params(
230
-            '',    // month
231
-            '',    // category
232
-            $config->display_expired_events,    // show_expired
233
-            'start_date',    // orderby
234
-            'ASC'    // sort
235
-        );
236
-        // check what template is loaded
237
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
238
-    }
239
-
240
-
241
-    /**
242
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
243
-     *
244
-     * @return    void
245
-     */
246
-    public function event_list()
247
-    {
248
-        // ensure valid EE_Events_Archive_Config() object exists
249
-        $this->set_config();
250
-        // load other required components
251
-        $this->load_event_list_assets();
252
-    }
253
-
254
-
255
-    /**
256
-     * @access    public
257
-     * @return    void
258
-     * @throws EE_Error
259
-     * @throws DomainException
260
-     */
261
-    public function event_list_iframe()
262
-    {
263
-        EED_Events_Archive::$iframe = true;
264
-        $event_list_iframe          = new EventsArchiveIframe($this);
265
-        $event_list_iframe->display();
266
-    }
267
-
268
-
269
-    /**
270
-     * @access public
271
-     * @return string
272
-     */
273
-    public static function is_iframe()
274
-    {
275
-        return EED_Events_Archive::$iframe;
276
-    }
277
-
278
-
279
-    /**
280
-     * @access public
281
-     * @return string
282
-     */
283
-    public static function link_target()
284
-    {
285
-        return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
286
-    }
287
-
288
-
289
-    /**
290
-     *    template_include
291
-     *
292
-     * @access    public
293
-     * @param string $template
294
-     * @return    string
295
-     */
296
-    public function template_include($template = '')
297
-    {
298
-        // don't add content filter for dedicated EE child themes or private posts
299
-        if (! EEH_Template::is_espresso_theme()) {
300
-            /** @type EE_Events_Archive_Config $config */
301
-            $config = $this->config();
302
-            // add status banner ?
303
-            if ($config->display_status_banner) {
304
-                add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
305
-            }
306
-            // if NOT a custom template
307
-            if (
308
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
309
-                || EE_Registry::instance()
310
-                              ->load_core('Front_Controller')
311
-                              ->get_selected_template() !== 'archive-espresso_events.php'
312
-            ) {
313
-                // don't display entry meta because the existing theme will take care of that
314
-                add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
315
-                // load functions.php file for the theme (loaded by WP if using child theme)
316
-                EEH_Template::load_espresso_theme_functions();
317
-                // because we don't know if the theme is using the_excerpt()
318
-                add_filter(
319
-                    'the_excerpt',
320
-                    array('EED_Events_Archive', 'event_details'),
321
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
322
-                );
323
-                // or the_content
324
-                add_filter(
325
-                    'the_content',
326
-                    array('EED_Events_Archive', 'event_details'),
327
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
328
-                );
329
-                // and just in case they are running get_the_excerpt() which DESTROYS things
330
-                add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
331
-                // don't display entry meta because the existing theme will take care of that
332
-                add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
333
-            }
334
-        }
335
-        return $template;
336
-    }
337
-
338
-
339
-    /**
340
-     *    get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters
341
-     *    on the_content()
342
-     *
343
-     * @access    public
344
-     * @param        string $excerpt
345
-     * @return        string
346
-     */
347
-    public static function get_the_excerpt($excerpt = '')
348
-    {
349
-        if (post_password_required()) {
350
-            return $excerpt;
351
-        }
352
-        if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
353
-            remove_filter(
354
-                'the_excerpt',
355
-                array('EED_Events_Archive', 'event_details'),
356
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
357
-            );
358
-            remove_filter(
359
-                'the_content',
360
-                array('EED_Events_Archive', 'event_details'),
361
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
362
-            );
363
-            $excerpt = EED_Events_Archive::event_details($excerpt);
364
-        } else {
365
-            EED_Events_Archive::$using_get_the_excerpt = true;
366
-            add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
367
-        }
368
-        return $excerpt;
369
-    }
370
-
371
-
372
-    /**
373
-     * end_get_the_excerpt
374
-     *
375
-     * @access public
376
-     * @param  string $text
377
-     * @return string
378
-     */
379
-    public static function end_get_the_excerpt($text = '')
380
-    {
381
-        EED_Events_Archive::$using_get_the_excerpt = false;
382
-        return $text;
383
-    }
384
-
385
-
386
-    /**
387
-     *    the_title
388
-     *
389
-     * @access        public
390
-     * @param        string $title
391
-     * @param        string $id
392
-     * @return        string
393
-     */
394
-    public static function the_title($title = '', $id = '')
395
-    {
396
-        global $post;
397
-        if ($post instanceof WP_Post) {
398
-            return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID == $id
399
-                ? espresso_event_status_banner($post->ID) . $title
400
-                : $title;
401
-        }
402
-        return $title;
403
-    }
404
-
405
-
406
-    /**
407
-     *    event_details
408
-     *
409
-     * @access    public
410
-     * @param        string $content
411
-     * @return        string
412
-     */
413
-    public static function event_details($content)
414
-    {
415
-        global $post;
416
-        static $current_post_ID = 0;
417
-        if (
418
-            $current_post_ID !== $post->ID
419
-            && $post->post_type === 'espresso_events'
420
-            && ! EED_Events_Archive::$using_get_the_excerpt
421
-            && ! post_password_required()
422
-            && (
423
-                apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
424
-                || ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
425
-            )
426
-        ) {
427
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
428
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
429
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
430
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
431
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
432
-            // so the following allows this filter to be applied multiple times, but only once for real
433
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
434
-            if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
435
-                $content = EED_Events_Archive::use_sortable_display_order();
436
-            } else {
437
-                $content = EED_Events_Archive::use_filterable_display_order();
438
-            }
439
-        }
440
-        return $content;
441
-    }
442
-
443
-
444
-    /**
445
-     *    use_sortable_display_order
446
-     *
447
-     * @access    protected
448
-     * @return string
449
-     */
450
-    protected static function use_sortable_display_order()
451
-    {
452
-        // no further password checks required atm
453
-        add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
454
-        // we need to first remove this callback from being applied to the_content() or the_excerpt()
455
-        // (otherwise it will recurse and blow up the interweb)
456
-        remove_filter(
457
-            'the_excerpt',
458
-            array('EED_Events_Archive', 'event_details'),
459
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
460
-        );
461
-        remove_filter(
462
-            'the_content',
463
-            array('EED_Events_Archive', 'event_details'),
464
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
465
-        );
466
-        remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
467
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
468
-        EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
469
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
470
-        $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
471
-        // re-add our main filters (or else the next event won't have them)
472
-        add_filter(
473
-            'the_excerpt',
474
-            array('EED_Events_Archive', 'event_details'),
475
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
476
-        );
477
-        add_filter(
478
-            'the_content',
479
-            array('EED_Events_Archive', 'event_details'),
480
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
481
-        );
482
-        add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
483
-        remove_filter(
484
-            'FHEE__EED_Events_Archive__event_details__no_post_password_required',
485
-            '__return_true'
486
-        );
487
-        return $content;
488
-    }
489
-
490
-
491
-    /**
492
-     *    use_filterable_display_order
493
-     *
494
-     * @access    protected
495
-     * @return    string
496
-     */
497
-    protected static function use_filterable_display_order()
498
-    {
499
-        // we need to first remove this callback from being applied to the_content()
500
-        // (otherwise it will recurse and blow up the interweb)
501
-        remove_filter(
502
-            'the_excerpt',
503
-            array('EED_Events_Archive', 'event_details'),
504
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
505
-        );
506
-        remove_filter(
507
-            'the_content',
508
-            array('EED_Events_Archive', 'event_details'),
509
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
510
-        );
511
-        remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
512
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
513
-        EED_Events_Archive::_add_additional_excerpt_filters();
514
-        EED_Events_Archive::_add_additional_content_filters();
515
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
516
-        // now load our template
517
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
518
-        // re-add our main filters (or else the next event won't have them)
519
-        add_filter(
520
-            'the_excerpt',
521
-            array('EED_Events_Archive', 'event_details'),
522
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
523
-        );
524
-        add_filter(
525
-            'the_content',
526
-            array('EED_Events_Archive', 'event_details'),
527
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
528
-        );
529
-        add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
530
-        // but remove the other filters so that they don't get applied to the next post
531
-        EED_Events_Archive::_remove_additional_events_archive_filters();
532
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
533
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
534
-        // return ! empty( $template ) ? $template : $content;
535
-        return $content;
536
-    }
537
-
538
-
539
-    /**
540
-     *    event_datetimes - adds datetimes ABOVE content
541
-     *
542
-     * @access    public
543
-     * @param        string $content
544
-     * @return        string
545
-     */
546
-    public static function event_datetimes($content)
547
-    {
548
-        if (post_password_required()) {
549
-            return $content;
550
-        }
551
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
552
-    }
553
-
554
-
555
-    /**
556
-     *    event_tickets - adds tickets ABOVE content (which includes datetimes)
557
-     *
558
-     * @access    public
559
-     * @param        string $content
560
-     * @return        string
561
-     */
562
-    public static function event_tickets($content)
563
-    {
564
-        if (post_password_required()) {
565
-            return $content;
566
-        }
567
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
568
-    }
569
-
570
-
571
-    /**
572
-     *    event_venues - adds venues BELOW content
573
-     *
574
-     * @access    public
575
-     * @param    string $content
576
-     * @return    string
577
-     */
578
-    public static function event_venue($content)
579
-    {
580
-        return EED_Events_Archive::event_venues($content);
581
-    }
582
-
583
-
584
-    /**
585
-     *    event_venues - adds venues BELOW content
586
-     *
587
-     * @access    public
588
-     * @param        string $content
589
-     * @return        string
590
-     */
591
-    public static function event_venues($content)
592
-    {
593
-        if (post_password_required()) {
594
-            return $content;
595
-        }
596
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
597
-    }
598
-
599
-
600
-    /**
601
-     *    _add_additional_content_filters
602
-     *
603
-     * @access    private
604
-     * @return        void
605
-     */
606
-    private static function _add_additional_excerpt_filters()
607
-    {
608
-        add_filter(
609
-            'the_excerpt',
610
-            array('EED_Events_Archive', 'event_datetimes'),
611
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
612
-        );
613
-        add_filter(
614
-            'the_excerpt',
615
-            array('EED_Events_Archive', 'event_tickets'),
616
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
617
-        );
618
-        add_filter(
619
-            'the_excerpt',
620
-            array('EED_Events_Archive', 'event_venues'),
621
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
622
-        );
623
-    }
624
-
625
-
626
-    /**
627
-     *    _add_additional_content_filters
628
-     *
629
-     * @access    private
630
-     * @return        void
631
-     */
632
-    private static function _add_additional_content_filters()
633
-    {
634
-        add_filter(
635
-            'the_content',
636
-            array('EED_Events_Archive', 'event_datetimes'),
637
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
638
-        );
639
-        add_filter(
640
-            'the_content',
641
-            array('EED_Events_Archive', 'event_tickets'),
642
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
643
-        );
644
-        add_filter(
645
-            'the_content',
646
-            array('EED_Events_Archive', 'event_venues'),
647
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
648
-        );
649
-    }
650
-
651
-
652
-    /**
653
-     *    _remove_additional_events_archive_filters
654
-     *
655
-     * @access    private
656
-     * @return        void
657
-     */
658
-    private static function _remove_additional_events_archive_filters()
659
-    {
660
-        remove_filter(
661
-            'the_excerpt',
662
-            array('EED_Events_Archive', 'event_datetimes'),
663
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
664
-        );
665
-        remove_filter(
666
-            'the_excerpt',
667
-            array('EED_Events_Archive', 'event_tickets'),
668
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
669
-        );
670
-        remove_filter(
671
-            'the_excerpt',
672
-            array('EED_Events_Archive', 'event_venues'),
673
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
674
-        );
675
-        remove_filter(
676
-            'the_content',
677
-            array('EED_Events_Archive', 'event_datetimes'),
678
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
679
-        );
680
-        remove_filter(
681
-            'the_content',
682
-            array('EED_Events_Archive', 'event_tickets'),
683
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
684
-        );
685
-        remove_filter(
686
-            'the_content',
687
-            array('EED_Events_Archive', 'event_venues'),
688
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
689
-        );
690
-    }
691
-
692
-
693
-    /**
694
-     *    remove_all_events_archive_filters
695
-     *
696
-     * @access    public
697
-     * @return        void
698
-     */
699
-    public static function remove_all_events_archive_filters()
700
-    {
701
-        // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
702
-        remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
703
-        remove_filter(
704
-            'the_excerpt',
705
-            array('EED_Events_Archive', 'event_details'),
706
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
707
-        );
708
-        remove_filter(
709
-            'the_excerpt',
710
-            array('EED_Events_Archive', 'event_datetimes'),
711
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
712
-        );
713
-        remove_filter(
714
-            'the_excerpt',
715
-            array('EED_Events_Archive', 'event_tickets'),
716
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
717
-        );
718
-        remove_filter(
719
-            'the_excerpt',
720
-            array('EED_Events_Archive', 'event_venues'),
721
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
722
-        );
723
-        remove_filter(
724
-            'the_content',
725
-            array('EED_Events_Archive', 'event_details'),
726
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
727
-        );
728
-        remove_filter(
729
-            'the_content',
730
-            array('EED_Events_Archive', 'event_datetimes'),
731
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
732
-        );
733
-        remove_filter(
734
-            'the_content',
735
-            array('EED_Events_Archive', 'event_tickets'),
736
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
737
-        );
738
-        remove_filter(
739
-            'the_content',
740
-            array('EED_Events_Archive', 'event_venues'),
741
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
742
-        );
743
-        // don't display entry meta because the existing theme will take care of that
744
-        remove_filter(
745
-            'FHEE__content_espresso_events_details_template__display_entry_meta',
746
-            '__return_false'
747
-        );
748
-    }
749
-
750
-
751
-    /**
752
-     *    load_event_list_assets
753
-     *
754
-     * @access    public
755
-     * @return    void
756
-     */
757
-    public function load_event_list_assets()
758
-    {
759
-        do_action('AHEE__EED_Events_Archive__before_load_assets');
760
-        add_filter('FHEE_load_EE_Session', '__return_true');
761
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
762
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
763
-        if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
764
-            add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
765
-        }
766
-    }
767
-
768
-
769
-    /**
770
-     *    wp_enqueue_scripts
771
-     *
772
-     * @access    public
773
-     * @return    void
774
-     */
775
-    public function wp_enqueue_scripts()
776
-    {
777
-        // get some style
778
-        if (apply_filters('FHEE_enable_default_espresso_css', false)) {
779
-            // first check uploads folder
780
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
781
-                wp_register_style(
782
-                    $this->theme,
783
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
784
-                    array('dashicons', 'espresso_default')
785
-                );
786
-            } else {
787
-            }
788
-            wp_enqueue_style($this->theme);
789
-        }
790
-    }
791
-
792
-
793
-    /**
794
-     *    template_settings_form
795
-     *
796
-     * @access    public
797
-     * @static
798
-     * @return    string
799
-     */
800
-    public static function template_settings_form()
801
-    {
802
-        $template_settings = EE_Registry::instance()->CFG->template_settings;
803
-        $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
804
-            ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
805
-        $template_settings->EED_Events_Archive = apply_filters(
806
-            'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
807
-            $template_settings->EED_Events_Archive
808
-        );
809
-        $events_archive_settings = array(
810
-            'display_status_banner' => 0,
811
-            'display_description' => 1,
812
-            'display_ticket_selector' => 0,
813
-            'display_datetimes' => 1,
814
-            'display_venue' => 0,
815
-            'display_expired_events' => 0,
816
-        );
817
-        $events_archive_settings = array_merge(
818
-            $events_archive_settings,
819
-            (array) $template_settings->EED_Events_Archive
820
-        );
821
-        EEH_Template::display_template(
822
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
823
-            $events_archive_settings
824
-        );
825
-    }
826
-
827
-
828
-    /**
829
-     *    update_template_settings
830
-     *
831
-     * @access    public
832
-     * @param    EE_Template_Config $CFG
833
-     * @param    array $REQ
834
-     * @return    EE_Template_Config
835
-     */
836
-    public static function update_template_settings($CFG, $REQ)
837
-    {
838
-        $CFG->EED_Events_Archive = new EE_Events_Archive_Config();
839
-        // unless we are resetting the config...
840
-        if (
841
-            ! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
842
-            || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
843
-        ) {
844
-            $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
845
-                ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
846
-            $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description'])
847
-                ? absint($REQ['EED_Events_Archive_display_description']) : 1;
848
-            $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
849
-                ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
850
-            $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint(
851
-                $REQ['EED_Events_Archive_display_datetimes']
852
-            ) : 1;
853
-            $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint(
854
-                $REQ['EED_Events_Archive_display_venue']
855
-            ) : 0;
856
-            $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
857
-                ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
858
-        }
859
-        return $CFG;
860
-    }
861
-
862
-
863
-    /**
864
-     *    event_list_css
865
-     *
866
-     * @access    public
867
-     * @param string $extra_class
868
-     * @return    string
869
-     */
870
-    public static function event_list_css($extra_class = '')
871
-    {
872
-        $event_list_css = ! empty($extra_class) ? array($extra_class) : array();
873
-        $event_list_css[] = 'espresso-event-list-event';
874
-        return implode(' ', $event_list_css);
875
-    }
876
-
877
-
878
-    /**
879
-     *    event_categories
880
-     *
881
-     * @access    public
882
-     * @return    array
883
-     */
884
-    public static function event_categories()
885
-    {
886
-        return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
887
-    }
888
-
889
-
890
-    /**
891
-     *    display_description
892
-     *
893
-     * @access    public
894
-     * @param $value
895
-     * @return    bool
896
-     */
897
-    public static function display_description($value)
898
-    {
899
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
900
-        $display_description = isset($config->display_description) ? $config->display_description : 1;
901
-        return $display_description === $value ? true : false;
902
-    }
903
-
904
-
905
-    /**
906
-     *    display_ticket_selector
907
-     *
908
-     * @access    public
909
-     * @return    bool
910
-     */
911
-    public static function display_ticket_selector()
912
-    {
913
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
914
-        return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false;
915
-    }
916
-
917
-
918
-    /**
919
-     *    display_venue
920
-     *
921
-     * @access    public
922
-     * @return    bool
923
-     */
924
-    public static function display_venue()
925
-    {
926
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
927
-        return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false;
928
-    }
929
-
930
-
931
-    /**
932
-     *    display_datetimes
933
-     *
934
-     * @access    public
935
-     * @return    bool
936
-     */
937
-    public static function display_datetimes()
938
-    {
939
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
940
-        return isset($config->display_datetimes) && $config->display_datetimes ? true : false;
941
-    }
942
-
943
-
944
-    /**
945
-     *    event_list_title
946
-     *
947
-     * @access    public
948
-     * @return    string
949
-     */
950
-    public static function event_list_title()
951
-    {
952
-        return apply_filters(
953
-            'FHEE__archive_espresso_events_template__upcoming_events_h1',
954
-            esc_html__('Upcoming Events', 'event_espresso')
955
-        );
956
-    }
957
-
958
-
959
-    // GRAVEYARD
960
-
961
-
962
-    /**
963
-     * @since 4.4.0
964
-     */
965
-    public static function _doing_it_wrong_notice($function = '')
966
-    {
967
-        EE_Error::doing_it_wrong(
968
-            __FUNCTION__,
969
-            sprintf(
970
-                esc_html__(
971
-                    'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s',
972
-                    'event_espresso'
973
-                ),
974
-                $function,
975
-                '<br />',
976
-                '4.6.0'
977
-            ),
978
-            '4.4.0'
979
-        );
980
-    }
981
-
982
-
983
-    /**
984
-     * @deprecated
985
-     * @since 4.4.0
986
-     */
987
-    public function get_post_data()
988
-    {
989
-        EEH_Event_Query::set_query_params();
990
-    }
991
-
992
-
993
-    /**
994
-     * @deprecated
995
-     * @since 4.4.0
996
-     */
997
-    public function posts_fields($SQL, WP_Query $wp_query)
998
-    {
999
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1000
-        return EEH_Event_Query::posts_fields($SQL, $wp_query);
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * @deprecated
1006
-     * @since 4.4.0
1007
-     */
1008
-    public static function posts_fields_sql_for_orderby($orderby_params = array())
1009
-    {
1010
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1011
-        return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
1012
-    }
1013
-
1014
-
1015
-    /**
1016
-     * @deprecated
1017
-     * @since 4.4.0
1018
-     */
1019
-    public function posts_join($SQL, WP_Query $wp_query)
1020
-    {
1021
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1022
-        return EEH_Event_Query::posts_join($SQL, $wp_query);
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * @deprecated
1028
-     * @since 4.4.0
1029
-     */
1030
-    public static function posts_join_sql_for_terms($join_terms = null)
1031
-    {
1032
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1033
-        return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
1034
-    }
1035
-
1036
-
1037
-    /**
1038
-     * @deprecated
1039
-     * @since 4.4.0
1040
-     */
1041
-    public static function posts_join_for_orderby($orderby_params = array())
1042
-    {
1043
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1044
-        return EEH_Event_Query::posts_join_for_orderby($orderby_params);
1045
-    }
1046
-
1047
-
1048
-    /**
1049
-     * @deprecated
1050
-     * @since 4.4.0
1051
-     */
1052
-    public function posts_where($SQL, WP_Query $wp_query)
1053
-    {
1054
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1055
-        return EEH_Event_Query::posts_where($SQL, $wp_query);
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * @deprecated
1061
-     * @since 4.4.0
1062
-     */
1063
-    public static function posts_where_sql_for_show_expired($show_expired = false)
1064
-    {
1065
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1066
-        return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1067
-    }
1068
-
1069
-
1070
-    /**
1071
-     * @deprecated
1072
-     * @since 4.4.0
1073
-     */
1074
-    public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1075
-    {
1076
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1077
-        return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * @deprecated
1083
-     * @since 4.4.0
1084
-     */
1085
-    public static function posts_where_sql_for_event_list_month($month = null)
1086
-    {
1087
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1088
-        return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1089
-    }
1090
-
1091
-
1092
-    /**
1093
-     * @deprecated
1094
-     * @since 4.4.0
1095
-     */
1096
-    public function posts_orderby($SQL, WP_Query $wp_query)
1097
-    {
1098
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1099
-        return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1100
-    }
1101
-
1102
-
1103
-    /**
1104
-     * @deprecated
1105
-     * @since 4.4.0
1106
-     */
1107
-    public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
1108
-    {
1109
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1110
-        return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1111
-    }
19
+	const EVENT_DETAILS_PRIORITY = 100;
20
+
21
+	const EVENT_DATETIMES_PRIORITY = 110;
22
+
23
+	const EVENT_TICKETS_PRIORITY = 120;
24
+
25
+	const EVENT_VENUES_PRIORITY = 130;
26
+
27
+
28
+	public static $espresso_event_list_ID = 0;
29
+
30
+	public static $espresso_grid_event_lists = array();
31
+
32
+	/**
33
+	 * @type bool $using_get_the_excerpt
34
+	 */
35
+	protected static $using_get_the_excerpt = false;
36
+
37
+	/**
38
+	 * Used to flag when the event list is being called from an external iframe.
39
+	 *
40
+	 * @var bool $iframe
41
+	 */
42
+	protected static $iframe = false;
43
+
44
+	/**
45
+	 * @var EventListIframeEmbedButton $_iframe_embed_button
46
+	 */
47
+	private static $_iframe_embed_button;
48
+
49
+	/**
50
+	 * @type EE_Template_Part_Manager $template_parts
51
+	 */
52
+	protected $template_parts;
53
+
54
+
55
+	/**
56
+	 * @return EED_Events_Archive
57
+	 */
58
+	public static function instance()
59
+	{
60
+		return parent::get_instance(__CLASS__);
61
+	}
62
+
63
+
64
+	/**
65
+	 * set_hooks - for hooking into EE Core, other modules, etc
66
+	 *
67
+	 * @return void
68
+	 * @throws InvalidArgumentException
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws InvalidInterfaceException
71
+	 */
72
+	public static function set_hooks()
73
+	{
74
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
75
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
76
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
77
+		);
78
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
79
+		EE_Config::register_route(
80
+			$custom_post_types['espresso_events']['plural_slug'],
81
+			'Events_Archive',
82
+			'run'
83
+		);
84
+		EE_Config::register_route(
85
+			'event_list',
86
+			'Events_Archive',
87
+			'event_list'
88
+		);
89
+		EE_Config::register_route(
90
+			'iframe',
91
+			'Events_Archive',
92
+			'event_list_iframe',
93
+			'event_list'
94
+		);
95
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
96
+	}
97
+
98
+
99
+	/**
100
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
101
+	 *
102
+	 * @access    public
103
+	 * @return    void
104
+	 */
105
+	public static function set_hooks_admin()
106
+	{
107
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
108
+		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
+		// to load assets for "espresso_events" page on the "default" route (action)
110
+		add_action(
111
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
113
+			10
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 *    set_definitions
120
+	 *
121
+	 * @access    public
122
+	 * @return    void
123
+	 */
124
+	public static function set_definitions()
125
+	{
126
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
128
+	}
129
+
130
+
131
+	/**
132
+	 * set up EE_Events_Archive_Config
133
+	 */
134
+	protected function set_config()
135
+	{
136
+		$this->set_config_section('template_settings');
137
+		$this->set_config_class('EE_Events_Archive_Config');
138
+		$this->set_config_name('EED_Events_Archive');
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return EventListIframeEmbedButton
144
+	 */
145
+	public static function get_iframe_embed_button()
146
+	{
147
+		if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148
+			self::$_iframe_embed_button = new EventListIframeEmbedButton();
149
+		}
150
+		return self::$_iframe_embed_button;
151
+	}
152
+
153
+
154
+	/**
155
+	 * event_list_iframe_embed_button
156
+	 *
157
+	 * @return    void
158
+	 * @throws EE_Error
159
+	 */
160
+	public static function event_list_iframe_embed_button()
161
+	{
162
+		$iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
163
+		$iframe_embed_button->addEmbedButton();
164
+	}
165
+
166
+
167
+	/**
168
+	 *    initialize_template_parts
169
+	 *
170
+	 * @access    public
171
+	 * @param EE_Events_Archive_Config $config
172
+	 * @return EE_Template_Part_Manager
173
+	 */
174
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null)
175
+	{
176
+		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
177
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
178
+		$template_parts = new EE_Template_Part_Manager();
179
+		$template_parts->add_template_part(
180
+			'tickets',
181
+			esc_html__('Ticket Selector', 'event_espresso'),
182
+			'content-espresso_events-tickets.php',
183
+			$config->display_order_tickets
184
+		);
185
+		$template_parts->add_template_part(
186
+			'datetimes',
187
+			esc_html__('Dates and Times', 'event_espresso'),
188
+			'content-espresso_events-datetimes.php',
189
+			$config->display_order_datetimes
190
+		);
191
+		$template_parts->add_template_part(
192
+			'event',
193
+			esc_html__('Event Description', 'event_espresso'),
194
+			'content-espresso_events-details.php',
195
+			$config->display_order_event
196
+		);
197
+		$template_parts->add_template_part(
198
+			'venue',
199
+			esc_html__('Venue Information', 'event_espresso'),
200
+			'content-espresso_events-venues.php',
201
+			$config->display_order_venue
202
+		);
203
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
204
+		return $template_parts;
205
+	}
206
+
207
+
208
+	/**
209
+	 *    run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the
210
+	 *    incoming request
211
+	 *
212
+	 * @access    public
213
+	 * @param WP $WP
214
+	 * @return    void
215
+	 */
216
+	public function run($WP)
217
+	{
218
+		do_action('AHEE__EED_Events_Archive__before_run');
219
+		// ensure valid EE_Events_Archive_Config() object exists
220
+		$this->set_config();
221
+		/** @type EE_Events_Archive_Config $config */
222
+		$config = $this->config();
223
+		// load other required components
224
+		$this->load_event_list_assets();
225
+		// filter the WP posts_join, posts_where, and posts_orderby SQL clauses
226
+		// add query filters
227
+		EEH_Event_Query::add_query_filters();
228
+		// set params that will get used by the filters
229
+		EEH_Event_Query::set_query_params(
230
+			'',    // month
231
+			'',    // category
232
+			$config->display_expired_events,    // show_expired
233
+			'start_date',    // orderby
234
+			'ASC'    // sort
235
+		);
236
+		// check what template is loaded
237
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
238
+	}
239
+
240
+
241
+	/**
242
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
243
+	 *
244
+	 * @return    void
245
+	 */
246
+	public function event_list()
247
+	{
248
+		// ensure valid EE_Events_Archive_Config() object exists
249
+		$this->set_config();
250
+		// load other required components
251
+		$this->load_event_list_assets();
252
+	}
253
+
254
+
255
+	/**
256
+	 * @access    public
257
+	 * @return    void
258
+	 * @throws EE_Error
259
+	 * @throws DomainException
260
+	 */
261
+	public function event_list_iframe()
262
+	{
263
+		EED_Events_Archive::$iframe = true;
264
+		$event_list_iframe          = new EventsArchiveIframe($this);
265
+		$event_list_iframe->display();
266
+	}
267
+
268
+
269
+	/**
270
+	 * @access public
271
+	 * @return string
272
+	 */
273
+	public static function is_iframe()
274
+	{
275
+		return EED_Events_Archive::$iframe;
276
+	}
277
+
278
+
279
+	/**
280
+	 * @access public
281
+	 * @return string
282
+	 */
283
+	public static function link_target()
284
+	{
285
+		return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
286
+	}
287
+
288
+
289
+	/**
290
+	 *    template_include
291
+	 *
292
+	 * @access    public
293
+	 * @param string $template
294
+	 * @return    string
295
+	 */
296
+	public function template_include($template = '')
297
+	{
298
+		// don't add content filter for dedicated EE child themes or private posts
299
+		if (! EEH_Template::is_espresso_theme()) {
300
+			/** @type EE_Events_Archive_Config $config */
301
+			$config = $this->config();
302
+			// add status banner ?
303
+			if ($config->display_status_banner) {
304
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
305
+			}
306
+			// if NOT a custom template
307
+			if (
308
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
309
+				|| EE_Registry::instance()
310
+							  ->load_core('Front_Controller')
311
+							  ->get_selected_template() !== 'archive-espresso_events.php'
312
+			) {
313
+				// don't display entry meta because the existing theme will take care of that
314
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
315
+				// load functions.php file for the theme (loaded by WP if using child theme)
316
+				EEH_Template::load_espresso_theme_functions();
317
+				// because we don't know if the theme is using the_excerpt()
318
+				add_filter(
319
+					'the_excerpt',
320
+					array('EED_Events_Archive', 'event_details'),
321
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
322
+				);
323
+				// or the_content
324
+				add_filter(
325
+					'the_content',
326
+					array('EED_Events_Archive', 'event_details'),
327
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
328
+				);
329
+				// and just in case they are running get_the_excerpt() which DESTROYS things
330
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
331
+				// don't display entry meta because the existing theme will take care of that
332
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
333
+			}
334
+		}
335
+		return $template;
336
+	}
337
+
338
+
339
+	/**
340
+	 *    get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters
341
+	 *    on the_content()
342
+	 *
343
+	 * @access    public
344
+	 * @param        string $excerpt
345
+	 * @return        string
346
+	 */
347
+	public static function get_the_excerpt($excerpt = '')
348
+	{
349
+		if (post_password_required()) {
350
+			return $excerpt;
351
+		}
352
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
353
+			remove_filter(
354
+				'the_excerpt',
355
+				array('EED_Events_Archive', 'event_details'),
356
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
357
+			);
358
+			remove_filter(
359
+				'the_content',
360
+				array('EED_Events_Archive', 'event_details'),
361
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
362
+			);
363
+			$excerpt = EED_Events_Archive::event_details($excerpt);
364
+		} else {
365
+			EED_Events_Archive::$using_get_the_excerpt = true;
366
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
367
+		}
368
+		return $excerpt;
369
+	}
370
+
371
+
372
+	/**
373
+	 * end_get_the_excerpt
374
+	 *
375
+	 * @access public
376
+	 * @param  string $text
377
+	 * @return string
378
+	 */
379
+	public static function end_get_the_excerpt($text = '')
380
+	{
381
+		EED_Events_Archive::$using_get_the_excerpt = false;
382
+		return $text;
383
+	}
384
+
385
+
386
+	/**
387
+	 *    the_title
388
+	 *
389
+	 * @access        public
390
+	 * @param        string $title
391
+	 * @param        string $id
392
+	 * @return        string
393
+	 */
394
+	public static function the_title($title = '', $id = '')
395
+	{
396
+		global $post;
397
+		if ($post instanceof WP_Post) {
398
+			return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID == $id
399
+				? espresso_event_status_banner($post->ID) . $title
400
+				: $title;
401
+		}
402
+		return $title;
403
+	}
404
+
405
+
406
+	/**
407
+	 *    event_details
408
+	 *
409
+	 * @access    public
410
+	 * @param        string $content
411
+	 * @return        string
412
+	 */
413
+	public static function event_details($content)
414
+	{
415
+		global $post;
416
+		static $current_post_ID = 0;
417
+		if (
418
+			$current_post_ID !== $post->ID
419
+			&& $post->post_type === 'espresso_events'
420
+			&& ! EED_Events_Archive::$using_get_the_excerpt
421
+			&& ! post_password_required()
422
+			&& (
423
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
424
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
425
+			)
426
+		) {
427
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
428
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
429
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
430
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
431
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
432
+			// so the following allows this filter to be applied multiple times, but only once for real
433
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
434
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
435
+				$content = EED_Events_Archive::use_sortable_display_order();
436
+			} else {
437
+				$content = EED_Events_Archive::use_filterable_display_order();
438
+			}
439
+		}
440
+		return $content;
441
+	}
442
+
443
+
444
+	/**
445
+	 *    use_sortable_display_order
446
+	 *
447
+	 * @access    protected
448
+	 * @return string
449
+	 */
450
+	protected static function use_sortable_display_order()
451
+	{
452
+		// no further password checks required atm
453
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
454
+		// we need to first remove this callback from being applied to the_content() or the_excerpt()
455
+		// (otherwise it will recurse and blow up the interweb)
456
+		remove_filter(
457
+			'the_excerpt',
458
+			array('EED_Events_Archive', 'event_details'),
459
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
460
+		);
461
+		remove_filter(
462
+			'the_content',
463
+			array('EED_Events_Archive', 'event_details'),
464
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
465
+		);
466
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
467
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
468
+		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
469
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
470
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
471
+		// re-add our main filters (or else the next event won't have them)
472
+		add_filter(
473
+			'the_excerpt',
474
+			array('EED_Events_Archive', 'event_details'),
475
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
476
+		);
477
+		add_filter(
478
+			'the_content',
479
+			array('EED_Events_Archive', 'event_details'),
480
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
481
+		);
482
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
483
+		remove_filter(
484
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
485
+			'__return_true'
486
+		);
487
+		return $content;
488
+	}
489
+
490
+
491
+	/**
492
+	 *    use_filterable_display_order
493
+	 *
494
+	 * @access    protected
495
+	 * @return    string
496
+	 */
497
+	protected static function use_filterable_display_order()
498
+	{
499
+		// we need to first remove this callback from being applied to the_content()
500
+		// (otherwise it will recurse and blow up the interweb)
501
+		remove_filter(
502
+			'the_excerpt',
503
+			array('EED_Events_Archive', 'event_details'),
504
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
505
+		);
506
+		remove_filter(
507
+			'the_content',
508
+			array('EED_Events_Archive', 'event_details'),
509
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
510
+		);
511
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
512
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
513
+		EED_Events_Archive::_add_additional_excerpt_filters();
514
+		EED_Events_Archive::_add_additional_content_filters();
515
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
516
+		// now load our template
517
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
518
+		// re-add our main filters (or else the next event won't have them)
519
+		add_filter(
520
+			'the_excerpt',
521
+			array('EED_Events_Archive', 'event_details'),
522
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
523
+		);
524
+		add_filter(
525
+			'the_content',
526
+			array('EED_Events_Archive', 'event_details'),
527
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
528
+		);
529
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
530
+		// but remove the other filters so that they don't get applied to the next post
531
+		EED_Events_Archive::_remove_additional_events_archive_filters();
532
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
533
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
534
+		// return ! empty( $template ) ? $template : $content;
535
+		return $content;
536
+	}
537
+
538
+
539
+	/**
540
+	 *    event_datetimes - adds datetimes ABOVE content
541
+	 *
542
+	 * @access    public
543
+	 * @param        string $content
544
+	 * @return        string
545
+	 */
546
+	public static function event_datetimes($content)
547
+	{
548
+		if (post_password_required()) {
549
+			return $content;
550
+		}
551
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
552
+	}
553
+
554
+
555
+	/**
556
+	 *    event_tickets - adds tickets ABOVE content (which includes datetimes)
557
+	 *
558
+	 * @access    public
559
+	 * @param        string $content
560
+	 * @return        string
561
+	 */
562
+	public static function event_tickets($content)
563
+	{
564
+		if (post_password_required()) {
565
+			return $content;
566
+		}
567
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
568
+	}
569
+
570
+
571
+	/**
572
+	 *    event_venues - adds venues BELOW content
573
+	 *
574
+	 * @access    public
575
+	 * @param    string $content
576
+	 * @return    string
577
+	 */
578
+	public static function event_venue($content)
579
+	{
580
+		return EED_Events_Archive::event_venues($content);
581
+	}
582
+
583
+
584
+	/**
585
+	 *    event_venues - adds venues BELOW content
586
+	 *
587
+	 * @access    public
588
+	 * @param        string $content
589
+	 * @return        string
590
+	 */
591
+	public static function event_venues($content)
592
+	{
593
+		if (post_password_required()) {
594
+			return $content;
595
+		}
596
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
597
+	}
598
+
599
+
600
+	/**
601
+	 *    _add_additional_content_filters
602
+	 *
603
+	 * @access    private
604
+	 * @return        void
605
+	 */
606
+	private static function _add_additional_excerpt_filters()
607
+	{
608
+		add_filter(
609
+			'the_excerpt',
610
+			array('EED_Events_Archive', 'event_datetimes'),
611
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
612
+		);
613
+		add_filter(
614
+			'the_excerpt',
615
+			array('EED_Events_Archive', 'event_tickets'),
616
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
617
+		);
618
+		add_filter(
619
+			'the_excerpt',
620
+			array('EED_Events_Archive', 'event_venues'),
621
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
622
+		);
623
+	}
624
+
625
+
626
+	/**
627
+	 *    _add_additional_content_filters
628
+	 *
629
+	 * @access    private
630
+	 * @return        void
631
+	 */
632
+	private static function _add_additional_content_filters()
633
+	{
634
+		add_filter(
635
+			'the_content',
636
+			array('EED_Events_Archive', 'event_datetimes'),
637
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
638
+		);
639
+		add_filter(
640
+			'the_content',
641
+			array('EED_Events_Archive', 'event_tickets'),
642
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
643
+		);
644
+		add_filter(
645
+			'the_content',
646
+			array('EED_Events_Archive', 'event_venues'),
647
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
648
+		);
649
+	}
650
+
651
+
652
+	/**
653
+	 *    _remove_additional_events_archive_filters
654
+	 *
655
+	 * @access    private
656
+	 * @return        void
657
+	 */
658
+	private static function _remove_additional_events_archive_filters()
659
+	{
660
+		remove_filter(
661
+			'the_excerpt',
662
+			array('EED_Events_Archive', 'event_datetimes'),
663
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
664
+		);
665
+		remove_filter(
666
+			'the_excerpt',
667
+			array('EED_Events_Archive', 'event_tickets'),
668
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
669
+		);
670
+		remove_filter(
671
+			'the_excerpt',
672
+			array('EED_Events_Archive', 'event_venues'),
673
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
674
+		);
675
+		remove_filter(
676
+			'the_content',
677
+			array('EED_Events_Archive', 'event_datetimes'),
678
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
679
+		);
680
+		remove_filter(
681
+			'the_content',
682
+			array('EED_Events_Archive', 'event_tickets'),
683
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
684
+		);
685
+		remove_filter(
686
+			'the_content',
687
+			array('EED_Events_Archive', 'event_venues'),
688
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
689
+		);
690
+	}
691
+
692
+
693
+	/**
694
+	 *    remove_all_events_archive_filters
695
+	 *
696
+	 * @access    public
697
+	 * @return        void
698
+	 */
699
+	public static function remove_all_events_archive_filters()
700
+	{
701
+		// remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
702
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
703
+		remove_filter(
704
+			'the_excerpt',
705
+			array('EED_Events_Archive', 'event_details'),
706
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
707
+		);
708
+		remove_filter(
709
+			'the_excerpt',
710
+			array('EED_Events_Archive', 'event_datetimes'),
711
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
712
+		);
713
+		remove_filter(
714
+			'the_excerpt',
715
+			array('EED_Events_Archive', 'event_tickets'),
716
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
717
+		);
718
+		remove_filter(
719
+			'the_excerpt',
720
+			array('EED_Events_Archive', 'event_venues'),
721
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
722
+		);
723
+		remove_filter(
724
+			'the_content',
725
+			array('EED_Events_Archive', 'event_details'),
726
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
727
+		);
728
+		remove_filter(
729
+			'the_content',
730
+			array('EED_Events_Archive', 'event_datetimes'),
731
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
732
+		);
733
+		remove_filter(
734
+			'the_content',
735
+			array('EED_Events_Archive', 'event_tickets'),
736
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
737
+		);
738
+		remove_filter(
739
+			'the_content',
740
+			array('EED_Events_Archive', 'event_venues'),
741
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
742
+		);
743
+		// don't display entry meta because the existing theme will take care of that
744
+		remove_filter(
745
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
746
+			'__return_false'
747
+		);
748
+	}
749
+
750
+
751
+	/**
752
+	 *    load_event_list_assets
753
+	 *
754
+	 * @access    public
755
+	 * @return    void
756
+	 */
757
+	public function load_event_list_assets()
758
+	{
759
+		do_action('AHEE__EED_Events_Archive__before_load_assets');
760
+		add_filter('FHEE_load_EE_Session', '__return_true');
761
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
762
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
763
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
764
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
765
+		}
766
+	}
767
+
768
+
769
+	/**
770
+	 *    wp_enqueue_scripts
771
+	 *
772
+	 * @access    public
773
+	 * @return    void
774
+	 */
775
+	public function wp_enqueue_scripts()
776
+	{
777
+		// get some style
778
+		if (apply_filters('FHEE_enable_default_espresso_css', false)) {
779
+			// first check uploads folder
780
+			if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
781
+				wp_register_style(
782
+					$this->theme,
783
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
784
+					array('dashicons', 'espresso_default')
785
+				);
786
+			} else {
787
+			}
788
+			wp_enqueue_style($this->theme);
789
+		}
790
+	}
791
+
792
+
793
+	/**
794
+	 *    template_settings_form
795
+	 *
796
+	 * @access    public
797
+	 * @static
798
+	 * @return    string
799
+	 */
800
+	public static function template_settings_form()
801
+	{
802
+		$template_settings = EE_Registry::instance()->CFG->template_settings;
803
+		$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
804
+			? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
805
+		$template_settings->EED_Events_Archive = apply_filters(
806
+			'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
807
+			$template_settings->EED_Events_Archive
808
+		);
809
+		$events_archive_settings = array(
810
+			'display_status_banner' => 0,
811
+			'display_description' => 1,
812
+			'display_ticket_selector' => 0,
813
+			'display_datetimes' => 1,
814
+			'display_venue' => 0,
815
+			'display_expired_events' => 0,
816
+		);
817
+		$events_archive_settings = array_merge(
818
+			$events_archive_settings,
819
+			(array) $template_settings->EED_Events_Archive
820
+		);
821
+		EEH_Template::display_template(
822
+			EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
823
+			$events_archive_settings
824
+		);
825
+	}
826
+
827
+
828
+	/**
829
+	 *    update_template_settings
830
+	 *
831
+	 * @access    public
832
+	 * @param    EE_Template_Config $CFG
833
+	 * @param    array $REQ
834
+	 * @return    EE_Template_Config
835
+	 */
836
+	public static function update_template_settings($CFG, $REQ)
837
+	{
838
+		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
839
+		// unless we are resetting the config...
840
+		if (
841
+			! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
842
+			|| absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
843
+		) {
844
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
845
+				? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
846
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description'])
847
+				? absint($REQ['EED_Events_Archive_display_description']) : 1;
848
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
849
+				? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
850
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint(
851
+				$REQ['EED_Events_Archive_display_datetimes']
852
+			) : 1;
853
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint(
854
+				$REQ['EED_Events_Archive_display_venue']
855
+			) : 0;
856
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
857
+				? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
858
+		}
859
+		return $CFG;
860
+	}
861
+
862
+
863
+	/**
864
+	 *    event_list_css
865
+	 *
866
+	 * @access    public
867
+	 * @param string $extra_class
868
+	 * @return    string
869
+	 */
870
+	public static function event_list_css($extra_class = '')
871
+	{
872
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
873
+		$event_list_css[] = 'espresso-event-list-event';
874
+		return implode(' ', $event_list_css);
875
+	}
876
+
877
+
878
+	/**
879
+	 *    event_categories
880
+	 *
881
+	 * @access    public
882
+	 * @return    array
883
+	 */
884
+	public static function event_categories()
885
+	{
886
+		return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
887
+	}
888
+
889
+
890
+	/**
891
+	 *    display_description
892
+	 *
893
+	 * @access    public
894
+	 * @param $value
895
+	 * @return    bool
896
+	 */
897
+	public static function display_description($value)
898
+	{
899
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
900
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
901
+		return $display_description === $value ? true : false;
902
+	}
903
+
904
+
905
+	/**
906
+	 *    display_ticket_selector
907
+	 *
908
+	 * @access    public
909
+	 * @return    bool
910
+	 */
911
+	public static function display_ticket_selector()
912
+	{
913
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
914
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false;
915
+	}
916
+
917
+
918
+	/**
919
+	 *    display_venue
920
+	 *
921
+	 * @access    public
922
+	 * @return    bool
923
+	 */
924
+	public static function display_venue()
925
+	{
926
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
927
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false;
928
+	}
929
+
930
+
931
+	/**
932
+	 *    display_datetimes
933
+	 *
934
+	 * @access    public
935
+	 * @return    bool
936
+	 */
937
+	public static function display_datetimes()
938
+	{
939
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
940
+		return isset($config->display_datetimes) && $config->display_datetimes ? true : false;
941
+	}
942
+
943
+
944
+	/**
945
+	 *    event_list_title
946
+	 *
947
+	 * @access    public
948
+	 * @return    string
949
+	 */
950
+	public static function event_list_title()
951
+	{
952
+		return apply_filters(
953
+			'FHEE__archive_espresso_events_template__upcoming_events_h1',
954
+			esc_html__('Upcoming Events', 'event_espresso')
955
+		);
956
+	}
957
+
958
+
959
+	// GRAVEYARD
960
+
961
+
962
+	/**
963
+	 * @since 4.4.0
964
+	 */
965
+	public static function _doing_it_wrong_notice($function = '')
966
+	{
967
+		EE_Error::doing_it_wrong(
968
+			__FUNCTION__,
969
+			sprintf(
970
+				esc_html__(
971
+					'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s',
972
+					'event_espresso'
973
+				),
974
+				$function,
975
+				'<br />',
976
+				'4.6.0'
977
+			),
978
+			'4.4.0'
979
+		);
980
+	}
981
+
982
+
983
+	/**
984
+	 * @deprecated
985
+	 * @since 4.4.0
986
+	 */
987
+	public function get_post_data()
988
+	{
989
+		EEH_Event_Query::set_query_params();
990
+	}
991
+
992
+
993
+	/**
994
+	 * @deprecated
995
+	 * @since 4.4.0
996
+	 */
997
+	public function posts_fields($SQL, WP_Query $wp_query)
998
+	{
999
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1000
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * @deprecated
1006
+	 * @since 4.4.0
1007
+	 */
1008
+	public static function posts_fields_sql_for_orderby($orderby_params = array())
1009
+	{
1010
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1011
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
1012
+	}
1013
+
1014
+
1015
+	/**
1016
+	 * @deprecated
1017
+	 * @since 4.4.0
1018
+	 */
1019
+	public function posts_join($SQL, WP_Query $wp_query)
1020
+	{
1021
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1022
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * @deprecated
1028
+	 * @since 4.4.0
1029
+	 */
1030
+	public static function posts_join_sql_for_terms($join_terms = null)
1031
+	{
1032
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1033
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
1034
+	}
1035
+
1036
+
1037
+	/**
1038
+	 * @deprecated
1039
+	 * @since 4.4.0
1040
+	 */
1041
+	public static function posts_join_for_orderby($orderby_params = array())
1042
+	{
1043
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1044
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
1045
+	}
1046
+
1047
+
1048
+	/**
1049
+	 * @deprecated
1050
+	 * @since 4.4.0
1051
+	 */
1052
+	public function posts_where($SQL, WP_Query $wp_query)
1053
+	{
1054
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1055
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * @deprecated
1061
+	 * @since 4.4.0
1062
+	 */
1063
+	public static function posts_where_sql_for_show_expired($show_expired = false)
1064
+	{
1065
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1066
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1067
+	}
1068
+
1069
+
1070
+	/**
1071
+	 * @deprecated
1072
+	 * @since 4.4.0
1073
+	 */
1074
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1075
+	{
1076
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1077
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * @deprecated
1083
+	 * @since 4.4.0
1084
+	 */
1085
+	public static function posts_where_sql_for_event_list_month($month = null)
1086
+	{
1087
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1088
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1089
+	}
1090
+
1091
+
1092
+	/**
1093
+	 * @deprecated
1094
+	 * @since 4.4.0
1095
+	 */
1096
+	public function posts_orderby($SQL, WP_Query $wp_query)
1097
+	{
1098
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1099
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1100
+	}
1101
+
1102
+
1103
+	/**
1104
+	 * @deprecated
1105
+	 * @since 4.4.0
1106
+	 */
1107
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
1108
+	{
1109
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1110
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1111
+	}
1112 1112
 }
1113 1113
 
1114 1114
 
@@ -1117,9 +1117,9 @@  discard block
 block discarded – undo
1117 1117
  */
1118 1118
 function espresso_get_event_list_ID()
1119 1119
 {
1120
-    EED_Events_Archive::$espresso_event_list_ID++;
1121
-    EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1122
-    return EED_Events_Archive::$espresso_event_list_ID;
1120
+	EED_Events_Archive::$espresso_event_list_ID++;
1121
+	EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1122
+	return EED_Events_Archive::$espresso_event_list_ID;
1123 1123
 }
1124 1124
 
1125 1125
 /**
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
  */
1128 1128
 function espresso_event_list_title()
1129 1129
 {
1130
-    return EED_Events_Archive::event_list_title();
1130
+	return EED_Events_Archive::event_list_title();
1131 1131
 }
1132 1132
 
1133 1133
 /**
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
  */
1137 1137
 function espresso_event_list_css($extra_class = '')
1138 1138
 {
1139
-    return EED_Events_Archive::event_list_css($extra_class);
1139
+	return EED_Events_Archive::event_list_css($extra_class);
1140 1140
 }
1141 1141
 
1142 1142
 /**
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
  */
1145 1145
 function espresso_get_event_categories()
1146 1146
 {
1147
-    return EED_Events_Archive::event_categories();
1147
+	return EED_Events_Archive::event_categories();
1148 1148
 }
1149 1149
 
1150 1150
 /**
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
  */
1153 1153
 function espresso_display_full_description_in_event_list()
1154 1154
 {
1155
-    return EED_Events_Archive::display_description(2);
1155
+	return EED_Events_Archive::display_description(2);
1156 1156
 }
1157 1157
 
1158 1158
 /**
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
  */
1161 1161
 function espresso_display_excerpt_in_event_list()
1162 1162
 {
1163
-    return EED_Events_Archive::display_description(1);
1163
+	return EED_Events_Archive::display_description(1);
1164 1164
 }
1165 1165
 
1166 1166
 /**
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
  */
1169 1169
 function espresso_display_ticket_selector_in_event_list()
1170 1170
 {
1171
-    return EED_Events_Archive::display_ticket_selector();
1171
+	return EED_Events_Archive::display_ticket_selector();
1172 1172
 }
1173 1173
 
1174 1174
 /**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
  */
1177 1177
 function espresso_display_venue_in_event_list()
1178 1178
 {
1179
-    return EED_Events_Archive::display_venue();
1179
+	return EED_Events_Archive::display_venue();
1180 1180
 }
1181 1181
 
1182 1182
 /**
@@ -1184,5 +1184,5 @@  discard block
 block discarded – undo
1184 1184
  */
1185 1185
 function espresso_display_datetimes_in_event_list()
1186 1186
 {
1187
-    return EED_Events_Archive::display_datetimes();
1187
+	return EED_Events_Archive::display_datetimes();
1188 1188
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function set_definitions()
125 125
     {
126
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
126
+        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
127
+        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
128 128
     }
129 129
 
130 130
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public static function get_iframe_embed_button()
146 146
     {
147
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
147
+        if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148 148
             self::$_iframe_embed_button = new EventListIframeEmbedButton();
149 149
         }
150 150
         return self::$_iframe_embed_button;
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
         EEH_Event_Query::add_query_filters();
228 228
         // set params that will get used by the filters
229 229
         EEH_Event_Query::set_query_params(
230
-            '',    // month
231
-            '',    // category
232
-            $config->display_expired_events,    // show_expired
233
-            'start_date',    // orderby
230
+            '', // month
231
+            '', // category
232
+            $config->display_expired_events, // show_expired
233
+            'start_date', // orderby
234 234
             'ASC'    // sort
235 235
         );
236 236
         // check what template is loaded
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     public function template_include($template = '')
297 297
     {
298 298
         // don't add content filter for dedicated EE child themes or private posts
299
-        if (! EEH_Template::is_espresso_theme()) {
299
+        if ( ! EEH_Template::is_espresso_theme()) {
300 300
             /** @type EE_Events_Archive_Config $config */
301 301
             $config = $this->config();
302 302
             // add status banner ?
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         global $post;
397 397
         if ($post instanceof WP_Post) {
398 398
             return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID == $id
399
-                ? espresso_event_status_banner($post->ID) . $title
399
+                ? espresso_event_status_banner($post->ID).$title
400 400
                 : $title;
401 401
         }
402 402
         return $title;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         if (post_password_required()) {
549 549
             return $content;
550 550
         }
551
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
551
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
552 552
     }
553 553
 
554 554
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         if (post_password_required()) {
565 565
             return $content;
566 566
         }
567
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
567
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
568 568
     }
569 569
 
570 570
 
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         if (post_password_required()) {
594 594
             return $content;
595 595
         }
596
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
596
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
597 597
     }
598 598
 
599 599
 
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
         // get some style
778 778
         if (apply_filters('FHEE_enable_default_espresso_css', false)) {
779 779
             // first check uploads folder
780
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
780
+            if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
781 781
                 wp_register_style(
782 782
                     $this->theme,
783
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
783
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
784 784
                     array('dashicons', 'espresso_default')
785 785
                 );
786 786
             } else {
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
             (array) $template_settings->EED_Events_Archive
820 820
         );
821 821
         EEH_Template::display_template(
822
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
822
+            EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php',
823 823
             $events_archive_settings
824 824
         );
825 825
     }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 2 patches
Indentation   +1304 added lines, -1304 removed lines patch added patch discarded remove patch
@@ -14,1308 +14,1308 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * Extend_Events_Admin_Page constructor.
19
-     *
20
-     * @param bool $routing
21
-     * @throws EE_Error
22
-     * @throws ReflectionException
23
-     */
24
-    public function __construct($routing = true)
25
-    {
26
-        parent::__construct($routing);
27
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
29
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
30
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
31
-        }
32
-    }
33
-
34
-
35
-    /**
36
-     * Sets routes.
37
-     *
38
-     * @throws EE_Error
39
-     */
40
-    protected function _extend_page_config()
41
-    {
42
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
-        // is there a evt_id in the request?
44
-        $EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
-        $EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
-        $TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
-        $new_page_routes    = [
48
-            'duplicate_event'          => [
49
-                'func'       => '_duplicate_event',
50
-                'capability' => 'ee_edit_event',
51
-                'obj_id'     => $EVT_ID,
52
-                'noheader'   => true,
53
-            ],
54
-            'ticket_list_table'        => [
55
-                'func'       => '_tickets_overview_list_table',
56
-                'capability' => 'ee_read_default_tickets',
57
-            ],
58
-            'trash_ticket'             => [
59
-                'func'       => '_trash_or_restore_ticket',
60
-                'capability' => 'ee_delete_default_ticket',
61
-                'obj_id'     => $TKT_ID,
62
-                'noheader'   => true,
63
-                'args'       => ['trash' => true],
64
-            ],
65
-            'trash_tickets'            => [
66
-                'func'       => '_trash_or_restore_ticket',
67
-                'capability' => 'ee_delete_default_tickets',
68
-                'noheader'   => true,
69
-                'args'       => ['trash' => true],
70
-            ],
71
-            'restore_ticket'           => [
72
-                'func'       => '_trash_or_restore_ticket',
73
-                'capability' => 'ee_delete_default_ticket',
74
-                'obj_id'     => $TKT_ID,
75
-                'noheader'   => true,
76
-            ],
77
-            'restore_tickets'          => [
78
-                'func'       => '_trash_or_restore_ticket',
79
-                'capability' => 'ee_delete_default_tickets',
80
-                'noheader'   => true,
81
-            ],
82
-            'delete_ticket'            => [
83
-                'func'       => '_delete_ticket',
84
-                'capability' => 'ee_delete_default_ticket',
85
-                'obj_id'     => $TKT_ID,
86
-                'noheader'   => true,
87
-            ],
88
-            'delete_tickets'           => [
89
-                'func'       => '_delete_ticket',
90
-                'capability' => 'ee_delete_default_tickets',
91
-                'noheader'   => true,
92
-            ],
93
-            'import_page'              => [
94
-                'func'       => '_import_page',
95
-                'capability' => 'import',
96
-            ],
97
-            'import'                   => [
98
-                'func'       => '_import_events',
99
-                'capability' => 'import',
100
-                'noheader'   => true,
101
-            ],
102
-            'import_events'            => [
103
-                'func'       => '_import_events',
104
-                'capability' => 'import',
105
-                'noheader'   => true,
106
-            ],
107
-            'export_events'            => [
108
-                'func'       => '_events_export',
109
-                'capability' => 'export',
110
-                'noheader'   => true,
111
-            ],
112
-            'export_categories'        => [
113
-                'func'       => '_categories_export',
114
-                'capability' => 'export',
115
-                'noheader'   => true,
116
-            ],
117
-            'sample_export_file'       => [
118
-                'func'       => '_sample_export_file',
119
-                'capability' => 'export',
120
-                'noheader'   => true,
121
-            ],
122
-            'update_template_settings' => [
123
-                'func'       => '_update_template_settings',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-        ];
128
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
129
-        // partial route/config override
130
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
131
-        $this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
132
-        $this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
133
-        $this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
134
-        $this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
135
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
136
-        // add tickets tab but only if there are more than one default ticket!
137
-        $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
138
-            [['TKT_is_default' => 1]],
139
-            'TKT_ID',
140
-            true
141
-        );
142
-        if ($ticket_count > 1) {
143
-            $new_page_config = [
144
-                'ticket_list_table' => [
145
-                    'nav'           => [
146
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
147
-                        'order' => 60,
148
-                    ],
149
-                    'list_table'    => 'Tickets_List_Table',
150
-                    'require_nonce' => false,
151
-                ],
152
-            ];
153
-        }
154
-        // template settings
155
-        $new_page_config['template_settings'] = [
156
-            'nav'           => [
157
-                'label' => esc_html__('Templates', 'event_espresso'),
158
-                'order' => 30,
159
-            ],
160
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
161
-            'help_tabs'     => [
162
-                'general_settings_templates_help_tab' => [
163
-                    'title'    => esc_html__('Templates', 'event_espresso'),
164
-                    'filename' => 'general_settings_templates',
165
-                ],
166
-            ],
167
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
168
-            // 'help_tour'     => array('Templates_Help_Tour'),
169
-            'require_nonce' => false,
170
-        ];
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
-        // add filters and actions
173
-        // modifying _views
174
-        add_filter(
175
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
-            [$this, 'add_additional_datetime_button'],
177
-            10,
178
-            2
179
-        );
180
-        add_filter(
181
-            'FHEE_event_datetime_metabox_clone_button_template',
182
-            [$this, 'add_datetime_clone_button'],
183
-            10,
184
-            2
185
-        );
186
-        add_filter(
187
-            'FHEE_event_datetime_metabox_timezones_template',
188
-            [$this, 'datetime_timezones_template'],
189
-            10,
190
-            2
191
-        );
192
-        // filters for event list table
193
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
194
-        add_filter(
195
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
-            [$this, 'extra_list_table_actions'],
197
-            10,
198
-            2
199
-        );
200
-        // legend item
201
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
202
-        add_action('admin_init', [$this, 'admin_init']);
203
-    }
204
-
205
-
206
-    /**
207
-     * admin_init
208
-     */
209
-    public function admin_init()
210
-    {
211
-        EE_Registry::$i18n_js_strings = array_merge(
212
-            EE_Registry::$i18n_js_strings,
213
-            [
214
-                'image_confirm'          => esc_html__(
215
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
216
-                    'event_espresso'
217
-                ),
218
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
219
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
220
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
221
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
222
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
223
-            ]
224
-        );
225
-    }
226
-
227
-
228
-    /**
229
-     * Add per page screen options to the default ticket list table view.
230
-     */
231
-    protected function _add_screen_options_ticket_list_table()
232
-    {
233
-        $this->_per_page_screen_option();
234
-    }
235
-
236
-
237
-    /**
238
-     * @param string $return
239
-     * @param int    $id
240
-     * @param string $new_title
241
-     * @param string $new_slug
242
-     * @return string
243
-     */
244
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
245
-    {
246
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
247
-        // make sure this is only when editing
248
-        if (! empty($id)) {
249
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
250
-                ['action' => 'duplicate_event', 'EVT_ID' => $id],
251
-                $this->_admin_base_url
252
-            );
253
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
254
-            $return .= '<a href="'
255
-                       . $href
256
-                       . '" title="'
257
-                       . $title
258
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
259
-                       . $title
260
-                       . '</a>';
261
-        }
262
-        return $return;
263
-    }
264
-
265
-
266
-    /**
267
-     * Set the list table views for the default ticket list table view.
268
-     */
269
-    public function _set_list_table_views_ticket_list_table()
270
-    {
271
-        $this->_views = [
272
-            'all'     => [
273
-                'slug'        => 'all',
274
-                'label'       => esc_html__('All', 'event_espresso'),
275
-                'count'       => 0,
276
-                'bulk_action' => [
277
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
278
-                ],
279
-            ],
280
-            'trashed' => [
281
-                'slug'        => 'trashed',
282
-                'label'       => esc_html__('Trash', 'event_espresso'),
283
-                'count'       => 0,
284
-                'bulk_action' => [
285
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
286
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
287
-                ],
288
-            ],
289
-        ];
290
-    }
291
-
292
-
293
-    /**
294
-     * Enqueue scripts and styles for the event editor.
295
-     */
296
-    public function load_scripts_styles_edit()
297
-    {
298
-        wp_register_script(
299
-            'ee-event-editor-heartbeat',
300
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
301
-            ['ee_admin_js', 'heartbeat'],
302
-            EVENT_ESPRESSO_VERSION,
303
-            true
304
-        );
305
-        wp_enqueue_script('ee-accounting');
306
-        // styles
307
-        wp_enqueue_style('espresso-ui-theme');
308
-        wp_enqueue_script('event_editor_js');
309
-        wp_enqueue_script('ee-event-editor-heartbeat');
310
-    }
311
-
312
-
313
-    /**
314
-     * Returns template for the additional datetime.
315
-     *
316
-     * @param string $template
317
-     * @param array  $template_args
318
-     * @return string
319
-     * @throws DomainException
320
-     */
321
-    public function add_additional_datetime_button($template, $template_args)
322
-    {
323
-        return EEH_Template::display_template(
324
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
325
-            $template_args,
326
-            true
327
-        );
328
-    }
329
-
330
-
331
-    /**
332
-     * Returns the template for cloning a datetime.
333
-     *
334
-     * @param $template
335
-     * @param $template_args
336
-     * @return string
337
-     * @throws DomainException
338
-     */
339
-    public function add_datetime_clone_button($template, $template_args)
340
-    {
341
-        return EEH_Template::display_template(
342
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
343
-            $template_args,
344
-            true
345
-        );
346
-    }
347
-
348
-
349
-    /**
350
-     * Returns the template for datetime timezones.
351
-     *
352
-     * @param $template
353
-     * @param $template_args
354
-     * @return string
355
-     * @throws DomainException
356
-     */
357
-    public function datetime_timezones_template($template, $template_args)
358
-    {
359
-        return EEH_Template::display_template(
360
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
361
-            $template_args,
362
-            true
363
-        );
364
-    }
365
-
366
-
367
-    /**
368
-     * Sets the views for the default list table view.
369
-     *
370
-     * @throws EE_Error
371
-     */
372
-    protected function _set_list_table_views_default()
373
-    {
374
-        parent::_set_list_table_views_default();
375
-        $new_views    = [
376
-            'today' => [
377
-                'slug'        => 'today',
378
-                'label'       => esc_html__('Today', 'event_espresso'),
379
-                'count'       => $this->total_events_today(),
380
-                'bulk_action' => [
381
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
382
-                ],
383
-            ],
384
-            'month' => [
385
-                'slug'        => 'month',
386
-                'label'       => esc_html__('This Month', 'event_espresso'),
387
-                'count'       => $this->total_events_this_month(),
388
-                'bulk_action' => [
389
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
390
-                ],
391
-            ],
392
-        ];
393
-        $this->_views = array_merge($this->_views, $new_views);
394
-    }
395
-
396
-
397
-    /**
398
-     * Returns the extra action links for the default list table view.
399
-     *
400
-     * @param array    $action_links
401
-     * @param EE_Event $event
402
-     * @return array
403
-     * @throws EE_Error
404
-     * @throws ReflectionException
405
-     */
406
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
407
-    {
408
-        if (
409
-            EE_Registry::instance()->CAP->current_user_can(
410
-                'ee_read_registrations',
411
-                'espresso_registrations_reports',
412
-                $event->ID()
413
-            )
414
-        ) {
415
-            $reports_query_args = [
416
-                'action' => 'reports',
417
-                'EVT_ID' => $event->ID(),
418
-            ];
419
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
420
-            $action_links[]     = '<a href="'
421
-                                  . $reports_link
422
-                                  . '" title="'
423
-                                  . esc_attr__('View Report', 'event_espresso')
424
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
425
-                                  . "\n\t";
426
-        }
427
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
428
-            EE_Registry::instance()->load_helper('MSG_Template');
429
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
430
-                'see_notifications_for',
431
-                null,
432
-                ['EVT_ID' => $event->ID()]
433
-            );
434
-        }
435
-        return $action_links;
436
-    }
437
-
438
-
439
-    /**
440
-     * @param $items
441
-     * @return mixed
442
-     */
443
-    public function additional_legend_items($items)
444
-    {
445
-        if (
446
-            EE_Registry::instance()->CAP->current_user_can(
447
-                'ee_read_registrations',
448
-                'espresso_registrations_reports'
449
-            )
450
-        ) {
451
-            $items['reports'] = [
452
-                'class' => 'dashicons dashicons-chart-bar',
453
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
454
-            ];
455
-        }
456
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
457
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
458
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
459
-                $items['view_related_messages'] = [
460
-                    'class' => $related_for_icon['css_class'],
461
-                    'desc'  => $related_for_icon['label'],
462
-                ];
463
-            }
464
-        }
465
-        return $items;
466
-    }
467
-
468
-
469
-    /**
470
-     * This is the callback method for the duplicate event route
471
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
472
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
473
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
474
-     * After duplication the redirect is to the new event edit page.
475
-     *
476
-     * @return void
477
-     * @throws EE_Error If EE_Event is not available with given ID
478
-     * @throws ReflectionException
479
-     * @access protected
480
-     */
481
-    protected function _duplicate_event()
482
-    {
483
-        // first make sure the ID for the event is in the request.
484
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
485
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
486
-        if (! $EVT_ID) {
487
-            EE_Error::add_error(
488
-                esc_html__(
489
-                    'In order to duplicate an event an Event ID is required.  None was given.',
490
-                    'event_espresso'
491
-                ),
492
-                __FILE__,
493
-                __FUNCTION__,
494
-                __LINE__
495
-            );
496
-            $this->_redirect_after_action(false, '', '', [], true);
497
-            return;
498
-        }
499
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
500
-        $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
501
-        if (! $orig_event instanceof EE_Event) {
502
-            throw new EE_Error(
503
-                sprintf(
504
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
505
-                    $EVT_ID
506
-                )
507
-            );
508
-        }
509
-        // k now let's clone the $orig_event before getting relations
510
-        $new_event = clone $orig_event;
511
-        // original datetimes
512
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
513
-        // other original relations
514
-        $orig_ven = $orig_event->get_many_related('Venue');
515
-        // reset the ID and modify other details to make it clear this is a dupe
516
-        $new_event->set('EVT_ID', 0);
517
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
518
-        $new_event->set('EVT_name', $new_name);
519
-        $new_event->set(
520
-            'EVT_slug',
521
-            wp_unique_post_slug(
522
-                sanitize_title($orig_event->name()),
523
-                0,
524
-                'publish',
525
-                'espresso_events',
526
-                0
527
-            )
528
-        );
529
-        $new_event->set('status', 'draft');
530
-        // duplicate discussion settings
531
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
532
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
533
-        // save the new event
534
-        $new_event->save();
535
-        // venues
536
-        foreach ($orig_ven as $ven) {
537
-            $new_event->_add_relation_to($ven, 'Venue');
538
-        }
539
-        $new_event->save();
540
-        // now we need to get the question group relations and handle that
541
-        // first primary question groups
542
-        $orig_primary_qgs = $orig_event->get_many_related(
543
-            'Question_Group',
544
-            [['Event_Question_Group.EQG_primary' => true]]
545
-        );
546
-        if (! empty($orig_primary_qgs)) {
547
-            foreach ($orig_primary_qgs as $obj) {
548
-                if ($obj instanceof EE_Question_Group) {
549
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
550
-                }
551
-            }
552
-        }
553
-        // next additional attendee question groups
554
-        $orig_additional_qgs = $orig_event->get_many_related(
555
-            'Question_Group',
556
-            [['Event_Question_Group.EQG_additional' => true]]
557
-        );
558
-        if (! empty($orig_additional_qgs)) {
559
-            foreach ($orig_additional_qgs as $obj) {
560
-                if ($obj instanceof EE_Question_Group) {
561
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
562
-                }
563
-            }
564
-        }
565
-
566
-        $new_event->save();
567
-
568
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
569
-        $cloned_tickets = [];
570
-        foreach ($orig_datetimes as $orig_dtt) {
571
-            if (! $orig_dtt instanceof EE_Datetime) {
572
-                continue;
573
-            }
574
-            $new_dtt      = clone $orig_dtt;
575
-            $orig_tickets = $orig_dtt->tickets();
576
-            // save new dtt then add to event
577
-            $new_dtt->set('DTT_ID', 0);
578
-            $new_dtt->set('DTT_sold', 0);
579
-            $new_dtt->set_reserved(0);
580
-            $new_dtt->save();
581
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
582
-            $new_event->save();
583
-            // now let's get the ticket relations setup.
584
-            foreach ((array) $orig_tickets as $orig_ticket) {
585
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
586
-                if (! $orig_ticket instanceof EE_Ticket) {
587
-                    continue;
588
-                }
589
-                // is this ticket archived?  If it is then let's skip
590
-                if ($orig_ticket->get('TKT_deleted')) {
591
-                    continue;
592
-                }
593
-                // does this original ticket already exist in the clone_tickets cache?
594
-                //  If so we'll just use the new ticket from it.
595
-                if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
596
-                    $new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
597
-                } else {
598
-                    $new_ticket = clone $orig_ticket;
599
-                    // get relations on the $orig_ticket that we need to setup.
600
-                    $orig_prices = $orig_ticket->prices();
601
-                    $new_ticket->set('TKT_ID', 0);
602
-                    $new_ticket->set('TKT_sold', 0);
603
-                    $new_ticket->set('TKT_reserved', 0);
604
-                    $new_ticket->save(); // make sure new ticket has ID.
605
-                    // price relations on new ticket need to be setup.
606
-                    foreach ($orig_prices as $orig_price) {
607
-                        $new_price = clone $orig_price;
608
-                        $new_price->set('PRC_ID', 0);
609
-                        $new_price->save();
610
-                        $new_ticket->_add_relation_to($new_price, 'Price');
611
-                        $new_ticket->save();
612
-                    }
613
-
614
-                    do_action(
615
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
616
-                        $orig_ticket,
617
-                        $new_ticket,
618
-                        $orig_prices,
619
-                        $orig_event,
620
-                        $orig_dtt,
621
-                        $new_dtt
622
-                    );
623
-                }
624
-                // k now we can add the new ticket as a relation to the new datetime
625
-                // and make sure its added to our cached $cloned_tickets array
626
-                // for use with later datetimes that have the same ticket.
627
-                $new_dtt->_add_relation_to($new_ticket, 'Ticket');
628
-                $new_dtt->save();
629
-                $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
630
-            }
631
-        }
632
-        // clone taxonomy information
633
-        $taxonomies_to_clone_with = apply_filters(
634
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
635
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
636
-        );
637
-        // get terms for original event (notice)
638
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
639
-        // loop through terms and add them to new event.
640
-        foreach ($orig_terms as $term) {
641
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
642
-        }
643
-
644
-        // duplicate other core WP_Post items for this event.
645
-        // post thumbnail (feature image).
646
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
647
-        if ($feature_image_id) {
648
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
649
-        }
650
-
651
-        // duplicate page_template setting
652
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
653
-        if ($page_template) {
654
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
655
-        }
656
-
657
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
658
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
659
-        if ($new_event->ID()) {
660
-            $redirect_args = [
661
-                'post'   => $new_event->ID(),
662
-                'action' => 'edit',
663
-            ];
664
-            EE_Error::add_success(
665
-                esc_html__(
666
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
667
-                    'event_espresso'
668
-                )
669
-            );
670
-        } else {
671
-            $redirect_args = [
672
-                'action' => 'default',
673
-            ];
674
-            EE_Error::add_error(
675
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
676
-                __FILE__,
677
-                __FUNCTION__,
678
-                __LINE__
679
-            );
680
-        }
681
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
682
-    }
683
-
684
-
685
-    /**
686
-     * Generates output for the import page.
687
-     *
688
-     * @throws EE_Error
689
-     */
690
-    protected function _import_page()
691
-    {
692
-        $title = esc_html__('Import', 'event_espresso');
693
-        $intro = esc_html__(
694
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
695
-            'event_espresso'
696
-        );
697
-
698
-        $form_url = EVENTS_ADMIN_URL;
699
-        $action   = 'import_events';
700
-        $type     = 'csv';
701
-
702
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
703
-            $title,
704
-            $intro,
705
-            $form_url,
706
-            $action,
707
-            $type
708
-        );
709
-
710
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
711
-            ['action' => 'sample_export_file'],
712
-            $this->_admin_base_url
713
-        );
714
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
715
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
716
-            $this->_template_args,
717
-            true
718
-        );
719
-        $this->display_admin_page_with_sidebar();
720
-    }
721
-
722
-
723
-    /**
724
-     * _import_events
725
-     * This handles displaying the screen and running imports for importing events.
726
-     *
727
-     * @return void
728
-     * @throws EE_Error
729
-     */
730
-    protected function _import_events()
731
-    {
732
-        require_once(EE_CLASSES . 'EE_Import.class.php');
733
-        $success = EE_Import::instance()->import();
734
-        $this->_redirect_after_action(
735
-            $success,
736
-            esc_html__('Import File', 'event_espresso'),
737
-            'ran',
738
-            ['action' => 'import_page'],
739
-            true
740
-        );
741
-    }
742
-
743
-
744
-    /**
745
-     * _events_export
746
-     * Will export all (or just the given event) to a Excel compatible file.
747
-     *
748
-     * @access protected
749
-     * @return void
750
-     */
751
-    protected function _events_export()
752
-    {
753
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
754
-        $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
755
-        $this->request->mergeRequestParams(
756
-            [
757
-                'export' => 'report',
758
-                'action' => 'all_event_data',
759
-                'EVT_ID' => $EVT_ID,
760
-            ]
761
-        );
762
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
763
-            require_once(EE_CLASSES . 'EE_Export.class.php');
764
-            $EE_Export = EE_Export::instance($this->request->requestParams());
765
-            $EE_Export->export();
766
-        }
767
-    }
768
-
769
-
770
-    /**
771
-     * handle category exports()
772
-     *
773
-     * @return void
774
-     */
775
-    protected function _categories_export()
776
-    {
777
-        $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
778
-        $this->request->mergeRequestParams(
779
-            [
780
-                'export' => 'report',
781
-                'action' => 'categories',
782
-                'EVT_ID' => $EVT_ID,
783
-            ]
784
-        );
785
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
786
-            require_once(EE_CLASSES . 'EE_Export.class.php');
787
-            $EE_Export = EE_Export::instance($this->request->requestParams());
788
-            $EE_Export->export();
789
-        }
790
-    }
791
-
792
-
793
-    /**
794
-     * Creates a sample CSV file for importing
795
-     */
796
-    protected function _sample_export_file()
797
-    {
798
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
799
-        EE_Export::instance()->export_sample();
800
-    }
801
-
802
-
803
-    /*************        Template Settings        *************/
804
-    /**
805
-     * Generates template settings page output
806
-     *
807
-     * @throws DomainException
808
-     * @throws EE_Error
809
-     */
810
-    protected function _template_settings()
811
-    {
812
-        $this->_template_args['values'] = $this->_yes_no_values;
813
-        /**
814
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
815
-         * from General_Settings_Admin_Page to here.
816
-         */
817
-        $this->_template_args = apply_filters(
818
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
819
-            $this->_template_args
820
-        );
821
-        $this->_set_add_edit_form_tags('update_template_settings');
822
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
823
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
824
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
825
-            $this->_template_args,
826
-            true
827
-        );
828
-        $this->display_admin_page_with_sidebar();
829
-    }
830
-
831
-
832
-    /**
833
-     * Handler for updating template settings.
834
-     *
835
-     * @throws EE_Error
836
-     */
837
-    protected function _update_template_settings()
838
-    {
839
-        /**
840
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
841
-         * from General_Settings_Admin_Page to here.
842
-         */
843
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
844
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
845
-            EE_Registry::instance()->CFG->template_settings,
846
-            $this->request->requestParams()
847
-        );
848
-        // update custom post type slugs and detect if we need to flush rewrite rules
849
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
850
-
851
-        $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
852
-
853
-        EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
854
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
855
-            : EEH_URL::slugify($event_cpt_slug, 'events');
856
-
857
-        $what    = esc_html__('Template Settings', 'event_espresso');
858
-        $success = $this->_update_espresso_configuration(
859
-            $what,
860
-            EE_Registry::instance()->CFG->template_settings,
861
-            __FILE__,
862
-            __FUNCTION__,
863
-            __LINE__
864
-        );
865
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
866
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
867
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
868
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
869
-            );
870
-            $rewrite_rules->flush();
871
-        }
872
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
873
-    }
874
-
875
-
876
-    /**
877
-     * _premium_event_editor_meta_boxes
878
-     * add all metaboxes related to the event_editor
879
-     *
880
-     * @access protected
881
-     * @return void
882
-     * @throws EE_Error
883
-     * @throws ReflectionException
884
-     */
885
-    protected function _premium_event_editor_meta_boxes()
886
-    {
887
-        $this->verify_cpt_object();
888
-        add_meta_box(
889
-            'espresso_event_editor_event_options',
890
-            esc_html__('Event Registration Options', 'event_espresso'),
891
-            [$this, 'registration_options_meta_box'],
892
-            $this->page_slug,
893
-            'side',
894
-            'core'
895
-        );
896
-    }
897
-
898
-
899
-    /**
900
-     * override caf metabox
901
-     *
902
-     * @return void
903
-     * @throws EE_Error
904
-     * @throws ReflectionException
905
-     */
906
-    public function registration_options_meta_box()
907
-    {
908
-        $yes_no_values = [
909
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
910
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
911
-        ];
912
-
913
-        $default_reg_status_values = EEM_Registration::reg_status_array(
914
-            [
915
-                EEM_Registration::status_id_cancelled,
916
-                EEM_Registration::status_id_declined,
917
-                EEM_Registration::status_id_incomplete,
918
-                EEM_Registration::status_id_wait_list,
919
-            ],
920
-            true
921
-        );
922
-
923
-        $template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
924
-        $template_args['_event']           = $this->_cpt_model_obj;
925
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
926
-
927
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
928
-            'default_reg_status',
929
-            $default_reg_status_values,
930
-            $this->_cpt_model_obj->default_registration_status()
931
-        );
932
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
933
-            'display_desc',
934
-            $yes_no_values,
935
-            $this->_cpt_model_obj->display_description()
936
-        );
937
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
938
-            'display_ticket_selector',
939
-            $yes_no_values,
940
-            $this->_cpt_model_obj->display_ticket_selector(),
941
-            '',
942
-            '',
943
-            false
944
-        );
945
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
946
-            'EVT_default_registration_status',
947
-            $default_reg_status_values,
948
-            $this->_cpt_model_obj->default_registration_status()
949
-        );
950
-        $template_args['additional_registration_options'] = apply_filters(
951
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
952
-            '',
953
-            $template_args,
954
-            $yes_no_values,
955
-            $default_reg_status_values
956
-        );
957
-        EEH_Template::display_template(
958
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
959
-            $template_args
960
-        );
961
-    }
962
-
963
-
964
-
965
-    /**
966
-     * wp_list_table_mods for caf
967
-     * ============================
968
-     */
969
-    /**
970
-     * hook into list table filters and provide filters for caffeinated list table
971
-     *
972
-     * @param array $old_filters    any existing filters present
973
-     * @param array $list_table_obj the list table object
974
-     * @return array                  new filters
975
-     * @throws EE_Error
976
-     * @throws ReflectionException
977
-     */
978
-    public function list_table_filters($old_filters, $list_table_obj)
979
-    {
980
-        $filters = [];
981
-        // first month/year filters
982
-        $filters[] = $this->espresso_event_months_dropdown();
983
-        $status    = $this->request->getRequestParam('status');
984
-        // active status dropdown
985
-        if ($status !== 'draft') {
986
-            $filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
987
-            $filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
988
-        }
989
-        // category filter
990
-        $filters[] = $this->category_dropdown();
991
-        return array_merge($old_filters, $filters);
992
-    }
993
-
994
-
995
-    /**
996
-     * espresso_event_months_dropdown
997
-     *
998
-     * @access public
999
-     * @return string                dropdown listing month/year selections for events.
1000
-     * @throws EE_Error
1001
-     */
1002
-    public function espresso_event_months_dropdown()
1003
-    {
1004
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1005
-        // Note we need to include any other filters that are set!
1006
-        return EEH_Form_Fields::generate_event_months_dropdown(
1007
-            $this->request->getRequestParam('month_range'),
1008
-            $this->request->getRequestParam('status'),
1009
-            $this->request->getRequestParam('EVT_CAT', 0, 'int'),
1010
-            $this->request->getRequestParam('active_status')
1011
-        );
1012
-    }
1013
-
1014
-
1015
-    /**
1016
-     * returns a list of "active" statuses on the event
1017
-     *
1018
-     * @param string $current_value whatever the current active status is
1019
-     * @return string
1020
-     */
1021
-    public function active_status_dropdown($current_value = '')
1022
-    {
1023
-        $select_name = 'active_status';
1024
-        $values      = [
1025
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1026
-            'active'   => esc_html__('Active', 'event_espresso'),
1027
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1028
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1029
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1030
-        ];
1031
-
1032
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1033
-    }
1034
-
1035
-
1036
-    /**
1037
-     * returns a list of "venues"
1038
-     *
1039
-     * @param string $current_value whatever the current active status is
1040
-     * @return string
1041
-     * @throws EE_Error
1042
-     * @throws ReflectionException
1043
-     */
1044
-    protected function venuesDropdown($current_value = '')
1045
-    {
1046
-        $values = [
1047
-            '' => esc_html__('All Venues', 'event_espresso'),
1048
-        ];
1049
-        // populate the list of venues.
1050
-        $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1051
-
1052
-        foreach ($venues as $venue) {
1053
-            $values[ $venue->ID() ] = $venue->name();
1054
-        }
1055
-
1056
-        return EEH_Form_Fields::select_input('venue', $values, $current_value, '', 'wide');
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * output a dropdown of the categories for the category filter on the event admin list table
1062
-     *
1063
-     * @access  public
1064
-     * @return string html
1065
-     * @throws EE_Error
1066
-     * @throws ReflectionException
1067
-     */
1068
-    public function category_dropdown()
1069
-    {
1070
-        return EEH_Form_Fields::generate_event_category_dropdown(
1071
-            $this->request->getRequestParam('EVT_CAT', -1, 'int')
1072
-        );
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * get total number of events today
1078
-     *
1079
-     * @access public
1080
-     * @return int
1081
-     * @throws EE_Error
1082
-     */
1083
-    public function total_events_today()
1084
-    {
1085
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1086
-            'DTT_EVT_start',
1087
-            date('Y-m-d') . ' 00:00:00',
1088
-            'Y-m-d H:i:s',
1089
-            'UTC'
1090
-        );
1091
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1092
-            'DTT_EVT_start',
1093
-            date('Y-m-d') . ' 23:59:59',
1094
-            'Y-m-d H:i:s',
1095
-            'UTC'
1096
-        );
1097
-        $where = [
1098
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1099
-        ];
1100
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * get total number of events this month
1106
-     *
1107
-     * @access public
1108
-     * @return int
1109
-     * @throws EE_Error
1110
-     */
1111
-    public function total_events_this_month()
1112
-    {
1113
-        // Dates
1114
-        $this_year_r     = date('Y');
1115
-        $this_month_r    = date('m');
1116
-        $days_this_month = date('t');
1117
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1118
-            'DTT_EVT_start',
1119
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1120
-            'Y-m-d H:i:s',
1121
-            'UTC'
1122
-        );
1123
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1124
-            'DTT_EVT_start',
1125
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1126
-            'Y-m-d H:i:s',
1127
-            'UTC'
1128
-        );
1129
-        $where           = [
1130
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1131
-        ];
1132
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1133
-    }
1134
-
1135
-
1136
-    /** DEFAULT TICKETS STUFF **/
1137
-
1138
-    /**
1139
-     * Output default tickets list table view.
1140
-     *
1141
-     * @throws EE_Error
1142
-     */
1143
-    public function _tickets_overview_list_table()
1144
-    {
1145
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1146
-        $this->display_admin_list_table_page_with_no_sidebar();
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * @param int  $per_page
1152
-     * @param bool $count
1153
-     * @param bool $trashed
1154
-     * @return EE_Soft_Delete_Base_Class[]|int
1155
-     * @throws EE_Error
1156
-     */
1157
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1158
-    {
1159
-        $orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1160
-        $order   = $this->request->getRequestParam('order', 'ASC');
1161
-        switch ($orderby) {
1162
-            case 'TKT_name':
1163
-                $orderby = ['TKT_name' => $order];
1164
-                break;
1165
-            case 'TKT_price':
1166
-                $orderby = ['TKT_price' => $order];
1167
-                break;
1168
-            case 'TKT_uses':
1169
-                $orderby = ['TKT_uses' => $order];
1170
-                break;
1171
-            case 'TKT_min':
1172
-                $orderby = ['TKT_min' => $order];
1173
-                break;
1174
-            case 'TKT_max':
1175
-                $orderby = ['TKT_max' => $order];
1176
-                break;
1177
-            case 'TKT_qty':
1178
-                $orderby = ['TKT_qty' => $order];
1179
-                break;
1180
-        }
1181
-
1182
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1183
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1184
-        $offset       = ($current_page - 1) * $per_page;
1185
-
1186
-        $where = [
1187
-            'TKT_is_default' => 1,
1188
-            'TKT_deleted'    => $trashed,
1189
-        ];
1190
-
1191
-        $search_term = $this->request->getRequestParam('s');
1192
-        if ($search_term) {
1193
-            $search_term = '%' . $search_term . '%';
1194
-            $where['OR'] = [
1195
-                'TKT_name'        => ['LIKE', $search_term],
1196
-                'TKT_description' => ['LIKE', $search_term],
1197
-            ];
1198
-        }
1199
-
1200
-        return $count
1201
-            ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1202
-            : EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1203
-                [
1204
-                    $where,
1205
-                    'order_by' => $orderby,
1206
-                    'limit'    => [$offset, $per_page],
1207
-                    'group_by' => 'TKT_ID',
1208
-                ]
1209
-            );
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     * @param bool $trash
1215
-     * @throws EE_Error
1216
-     */
1217
-    protected function _trash_or_restore_ticket($trash = false)
1218
-    {
1219
-        $success = 1;
1220
-        $TKT     = EEM_Ticket::instance();
1221
-        // checkboxes?
1222
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1223
-        if (! empty($checkboxes)) {
1224
-            // if array has more than one element then success message should be plural
1225
-            $success = count($checkboxes) > 1 ? 2 : 1;
1226
-            // cycle thru the boxes
1227
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1228
-                if ($trash) {
1229
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1230
-                        $success = 0;
1231
-                    }
1232
-                } else {
1233
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1234
-                        $success = 0;
1235
-                    }
1236
-                }
1237
-            }
1238
-        } else {
1239
-            // grab single id and trash
1240
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1241
-            if ($trash) {
1242
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1243
-                    $success = 0;
1244
-                }
1245
-            } else {
1246
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1247
-                    $success = 0;
1248
-                }
1249
-            }
1250
-        }
1251
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1252
-        $query_args  = [
1253
-            'action' => 'ticket_list_table',
1254
-            'status' => $trash ? '' : 'trashed',
1255
-        ];
1256
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * Handles trashing default ticket.
1262
-     *
1263
-     * @throws EE_Error
1264
-     * @throws ReflectionException
1265
-     */
1266
-    protected function _delete_ticket()
1267
-    {
1268
-        $success = 1;
1269
-        // checkboxes?
1270
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1271
-        if (! empty($checkboxes)) {
1272
-            // if array has more than one element then success message should be plural
1273
-            $success = count($checkboxes) > 1 ? 2 : 1;
1274
-            // cycle thru the boxes
1275
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1276
-                // delete
1277
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1278
-                    $success = 0;
1279
-                }
1280
-            }
1281
-        } else {
1282
-            // grab single id and trash
1283
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1284
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1285
-                $success = 0;
1286
-            }
1287
-        }
1288
-        $action_desc = 'deleted';
1289
-        $query_args  = [
1290
-            'action' => 'ticket_list_table',
1291
-            'status' => 'trashed',
1292
-        ];
1293
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1294
-        if (
1295
-            EEM_Ticket::instance()->count_deleted_and_undeleted(
1296
-                [['TKT_is_default' => 1]],
1297
-                'TKT_ID',
1298
-                true
1299
-            )
1300
-        ) {
1301
-            $query_args = [];
1302
-        }
1303
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1304
-    }
1305
-
1306
-
1307
-    /**
1308
-     * @param int $TKT_ID
1309
-     * @return bool|int
1310
-     * @throws EE_Error
1311
-     * @throws ReflectionException
1312
-     */
1313
-    protected function _delete_the_ticket($TKT_ID)
1314
-    {
1315
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1316
-        $ticket->_remove_relations('Datetime');
1317
-        // delete all related prices first
1318
-        $ticket->delete_related_permanently('Price');
1319
-        return $ticket->delete_permanently();
1320
-    }
17
+	/**
18
+	 * Extend_Events_Admin_Page constructor.
19
+	 *
20
+	 * @param bool $routing
21
+	 * @throws EE_Error
22
+	 * @throws ReflectionException
23
+	 */
24
+	public function __construct($routing = true)
25
+	{
26
+		parent::__construct($routing);
27
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
29
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
30
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
31
+		}
32
+	}
33
+
34
+
35
+	/**
36
+	 * Sets routes.
37
+	 *
38
+	 * @throws EE_Error
39
+	 */
40
+	protected function _extend_page_config()
41
+	{
42
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
+		// is there a evt_id in the request?
44
+		$EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
+		$EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
+		$TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
+		$new_page_routes    = [
48
+			'duplicate_event'          => [
49
+				'func'       => '_duplicate_event',
50
+				'capability' => 'ee_edit_event',
51
+				'obj_id'     => $EVT_ID,
52
+				'noheader'   => true,
53
+			],
54
+			'ticket_list_table'        => [
55
+				'func'       => '_tickets_overview_list_table',
56
+				'capability' => 'ee_read_default_tickets',
57
+			],
58
+			'trash_ticket'             => [
59
+				'func'       => '_trash_or_restore_ticket',
60
+				'capability' => 'ee_delete_default_ticket',
61
+				'obj_id'     => $TKT_ID,
62
+				'noheader'   => true,
63
+				'args'       => ['trash' => true],
64
+			],
65
+			'trash_tickets'            => [
66
+				'func'       => '_trash_or_restore_ticket',
67
+				'capability' => 'ee_delete_default_tickets',
68
+				'noheader'   => true,
69
+				'args'       => ['trash' => true],
70
+			],
71
+			'restore_ticket'           => [
72
+				'func'       => '_trash_or_restore_ticket',
73
+				'capability' => 'ee_delete_default_ticket',
74
+				'obj_id'     => $TKT_ID,
75
+				'noheader'   => true,
76
+			],
77
+			'restore_tickets'          => [
78
+				'func'       => '_trash_or_restore_ticket',
79
+				'capability' => 'ee_delete_default_tickets',
80
+				'noheader'   => true,
81
+			],
82
+			'delete_ticket'            => [
83
+				'func'       => '_delete_ticket',
84
+				'capability' => 'ee_delete_default_ticket',
85
+				'obj_id'     => $TKT_ID,
86
+				'noheader'   => true,
87
+			],
88
+			'delete_tickets'           => [
89
+				'func'       => '_delete_ticket',
90
+				'capability' => 'ee_delete_default_tickets',
91
+				'noheader'   => true,
92
+			],
93
+			'import_page'              => [
94
+				'func'       => '_import_page',
95
+				'capability' => 'import',
96
+			],
97
+			'import'                   => [
98
+				'func'       => '_import_events',
99
+				'capability' => 'import',
100
+				'noheader'   => true,
101
+			],
102
+			'import_events'            => [
103
+				'func'       => '_import_events',
104
+				'capability' => 'import',
105
+				'noheader'   => true,
106
+			],
107
+			'export_events'            => [
108
+				'func'       => '_events_export',
109
+				'capability' => 'export',
110
+				'noheader'   => true,
111
+			],
112
+			'export_categories'        => [
113
+				'func'       => '_categories_export',
114
+				'capability' => 'export',
115
+				'noheader'   => true,
116
+			],
117
+			'sample_export_file'       => [
118
+				'func'       => '_sample_export_file',
119
+				'capability' => 'export',
120
+				'noheader'   => true,
121
+			],
122
+			'update_template_settings' => [
123
+				'func'       => '_update_template_settings',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+		];
128
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
129
+		// partial route/config override
130
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
131
+		$this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
132
+		$this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
133
+		$this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
134
+		$this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
135
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
136
+		// add tickets tab but only if there are more than one default ticket!
137
+		$ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
138
+			[['TKT_is_default' => 1]],
139
+			'TKT_ID',
140
+			true
141
+		);
142
+		if ($ticket_count > 1) {
143
+			$new_page_config = [
144
+				'ticket_list_table' => [
145
+					'nav'           => [
146
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
147
+						'order' => 60,
148
+					],
149
+					'list_table'    => 'Tickets_List_Table',
150
+					'require_nonce' => false,
151
+				],
152
+			];
153
+		}
154
+		// template settings
155
+		$new_page_config['template_settings'] = [
156
+			'nav'           => [
157
+				'label' => esc_html__('Templates', 'event_espresso'),
158
+				'order' => 30,
159
+			],
160
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
161
+			'help_tabs'     => [
162
+				'general_settings_templates_help_tab' => [
163
+					'title'    => esc_html__('Templates', 'event_espresso'),
164
+					'filename' => 'general_settings_templates',
165
+				],
166
+			],
167
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
168
+			// 'help_tour'     => array('Templates_Help_Tour'),
169
+			'require_nonce' => false,
170
+		];
171
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
+		// add filters and actions
173
+		// modifying _views
174
+		add_filter(
175
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
+			[$this, 'add_additional_datetime_button'],
177
+			10,
178
+			2
179
+		);
180
+		add_filter(
181
+			'FHEE_event_datetime_metabox_clone_button_template',
182
+			[$this, 'add_datetime_clone_button'],
183
+			10,
184
+			2
185
+		);
186
+		add_filter(
187
+			'FHEE_event_datetime_metabox_timezones_template',
188
+			[$this, 'datetime_timezones_template'],
189
+			10,
190
+			2
191
+		);
192
+		// filters for event list table
193
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
194
+		add_filter(
195
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
+			[$this, 'extra_list_table_actions'],
197
+			10,
198
+			2
199
+		);
200
+		// legend item
201
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
202
+		add_action('admin_init', [$this, 'admin_init']);
203
+	}
204
+
205
+
206
+	/**
207
+	 * admin_init
208
+	 */
209
+	public function admin_init()
210
+	{
211
+		EE_Registry::$i18n_js_strings = array_merge(
212
+			EE_Registry::$i18n_js_strings,
213
+			[
214
+				'image_confirm'          => esc_html__(
215
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
216
+					'event_espresso'
217
+				),
218
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
219
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
220
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
221
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
222
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
223
+			]
224
+		);
225
+	}
226
+
227
+
228
+	/**
229
+	 * Add per page screen options to the default ticket list table view.
230
+	 */
231
+	protected function _add_screen_options_ticket_list_table()
232
+	{
233
+		$this->_per_page_screen_option();
234
+	}
235
+
236
+
237
+	/**
238
+	 * @param string $return
239
+	 * @param int    $id
240
+	 * @param string $new_title
241
+	 * @param string $new_slug
242
+	 * @return string
243
+	 */
244
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
245
+	{
246
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
247
+		// make sure this is only when editing
248
+		if (! empty($id)) {
249
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
250
+				['action' => 'duplicate_event', 'EVT_ID' => $id],
251
+				$this->_admin_base_url
252
+			);
253
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
254
+			$return .= '<a href="'
255
+					   . $href
256
+					   . '" title="'
257
+					   . $title
258
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
259
+					   . $title
260
+					   . '</a>';
261
+		}
262
+		return $return;
263
+	}
264
+
265
+
266
+	/**
267
+	 * Set the list table views for the default ticket list table view.
268
+	 */
269
+	public function _set_list_table_views_ticket_list_table()
270
+	{
271
+		$this->_views = [
272
+			'all'     => [
273
+				'slug'        => 'all',
274
+				'label'       => esc_html__('All', 'event_espresso'),
275
+				'count'       => 0,
276
+				'bulk_action' => [
277
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
278
+				],
279
+			],
280
+			'trashed' => [
281
+				'slug'        => 'trashed',
282
+				'label'       => esc_html__('Trash', 'event_espresso'),
283
+				'count'       => 0,
284
+				'bulk_action' => [
285
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
286
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
287
+				],
288
+			],
289
+		];
290
+	}
291
+
292
+
293
+	/**
294
+	 * Enqueue scripts and styles for the event editor.
295
+	 */
296
+	public function load_scripts_styles_edit()
297
+	{
298
+		wp_register_script(
299
+			'ee-event-editor-heartbeat',
300
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
301
+			['ee_admin_js', 'heartbeat'],
302
+			EVENT_ESPRESSO_VERSION,
303
+			true
304
+		);
305
+		wp_enqueue_script('ee-accounting');
306
+		// styles
307
+		wp_enqueue_style('espresso-ui-theme');
308
+		wp_enqueue_script('event_editor_js');
309
+		wp_enqueue_script('ee-event-editor-heartbeat');
310
+	}
311
+
312
+
313
+	/**
314
+	 * Returns template for the additional datetime.
315
+	 *
316
+	 * @param string $template
317
+	 * @param array  $template_args
318
+	 * @return string
319
+	 * @throws DomainException
320
+	 */
321
+	public function add_additional_datetime_button($template, $template_args)
322
+	{
323
+		return EEH_Template::display_template(
324
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
325
+			$template_args,
326
+			true
327
+		);
328
+	}
329
+
330
+
331
+	/**
332
+	 * Returns the template for cloning a datetime.
333
+	 *
334
+	 * @param $template
335
+	 * @param $template_args
336
+	 * @return string
337
+	 * @throws DomainException
338
+	 */
339
+	public function add_datetime_clone_button($template, $template_args)
340
+	{
341
+		return EEH_Template::display_template(
342
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
343
+			$template_args,
344
+			true
345
+		);
346
+	}
347
+
348
+
349
+	/**
350
+	 * Returns the template for datetime timezones.
351
+	 *
352
+	 * @param $template
353
+	 * @param $template_args
354
+	 * @return string
355
+	 * @throws DomainException
356
+	 */
357
+	public function datetime_timezones_template($template, $template_args)
358
+	{
359
+		return EEH_Template::display_template(
360
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
361
+			$template_args,
362
+			true
363
+		);
364
+	}
365
+
366
+
367
+	/**
368
+	 * Sets the views for the default list table view.
369
+	 *
370
+	 * @throws EE_Error
371
+	 */
372
+	protected function _set_list_table_views_default()
373
+	{
374
+		parent::_set_list_table_views_default();
375
+		$new_views    = [
376
+			'today' => [
377
+				'slug'        => 'today',
378
+				'label'       => esc_html__('Today', 'event_espresso'),
379
+				'count'       => $this->total_events_today(),
380
+				'bulk_action' => [
381
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
382
+				],
383
+			],
384
+			'month' => [
385
+				'slug'        => 'month',
386
+				'label'       => esc_html__('This Month', 'event_espresso'),
387
+				'count'       => $this->total_events_this_month(),
388
+				'bulk_action' => [
389
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
390
+				],
391
+			],
392
+		];
393
+		$this->_views = array_merge($this->_views, $new_views);
394
+	}
395
+
396
+
397
+	/**
398
+	 * Returns the extra action links for the default list table view.
399
+	 *
400
+	 * @param array    $action_links
401
+	 * @param EE_Event $event
402
+	 * @return array
403
+	 * @throws EE_Error
404
+	 * @throws ReflectionException
405
+	 */
406
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
407
+	{
408
+		if (
409
+			EE_Registry::instance()->CAP->current_user_can(
410
+				'ee_read_registrations',
411
+				'espresso_registrations_reports',
412
+				$event->ID()
413
+			)
414
+		) {
415
+			$reports_query_args = [
416
+				'action' => 'reports',
417
+				'EVT_ID' => $event->ID(),
418
+			];
419
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
420
+			$action_links[]     = '<a href="'
421
+								  . $reports_link
422
+								  . '" title="'
423
+								  . esc_attr__('View Report', 'event_espresso')
424
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
425
+								  . "\n\t";
426
+		}
427
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
428
+			EE_Registry::instance()->load_helper('MSG_Template');
429
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
430
+				'see_notifications_for',
431
+				null,
432
+				['EVT_ID' => $event->ID()]
433
+			);
434
+		}
435
+		return $action_links;
436
+	}
437
+
438
+
439
+	/**
440
+	 * @param $items
441
+	 * @return mixed
442
+	 */
443
+	public function additional_legend_items($items)
444
+	{
445
+		if (
446
+			EE_Registry::instance()->CAP->current_user_can(
447
+				'ee_read_registrations',
448
+				'espresso_registrations_reports'
449
+			)
450
+		) {
451
+			$items['reports'] = [
452
+				'class' => 'dashicons dashicons-chart-bar',
453
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
454
+			];
455
+		}
456
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
457
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
458
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
459
+				$items['view_related_messages'] = [
460
+					'class' => $related_for_icon['css_class'],
461
+					'desc'  => $related_for_icon['label'],
462
+				];
463
+			}
464
+		}
465
+		return $items;
466
+	}
467
+
468
+
469
+	/**
470
+	 * This is the callback method for the duplicate event route
471
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
472
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
473
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
474
+	 * After duplication the redirect is to the new event edit page.
475
+	 *
476
+	 * @return void
477
+	 * @throws EE_Error If EE_Event is not available with given ID
478
+	 * @throws ReflectionException
479
+	 * @access protected
480
+	 */
481
+	protected function _duplicate_event()
482
+	{
483
+		// first make sure the ID for the event is in the request.
484
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
485
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
486
+		if (! $EVT_ID) {
487
+			EE_Error::add_error(
488
+				esc_html__(
489
+					'In order to duplicate an event an Event ID is required.  None was given.',
490
+					'event_espresso'
491
+				),
492
+				__FILE__,
493
+				__FUNCTION__,
494
+				__LINE__
495
+			);
496
+			$this->_redirect_after_action(false, '', '', [], true);
497
+			return;
498
+		}
499
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
500
+		$orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
501
+		if (! $orig_event instanceof EE_Event) {
502
+			throw new EE_Error(
503
+				sprintf(
504
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
505
+					$EVT_ID
506
+				)
507
+			);
508
+		}
509
+		// k now let's clone the $orig_event before getting relations
510
+		$new_event = clone $orig_event;
511
+		// original datetimes
512
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
513
+		// other original relations
514
+		$orig_ven = $orig_event->get_many_related('Venue');
515
+		// reset the ID and modify other details to make it clear this is a dupe
516
+		$new_event->set('EVT_ID', 0);
517
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
518
+		$new_event->set('EVT_name', $new_name);
519
+		$new_event->set(
520
+			'EVT_slug',
521
+			wp_unique_post_slug(
522
+				sanitize_title($orig_event->name()),
523
+				0,
524
+				'publish',
525
+				'espresso_events',
526
+				0
527
+			)
528
+		);
529
+		$new_event->set('status', 'draft');
530
+		// duplicate discussion settings
531
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
532
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
533
+		// save the new event
534
+		$new_event->save();
535
+		// venues
536
+		foreach ($orig_ven as $ven) {
537
+			$new_event->_add_relation_to($ven, 'Venue');
538
+		}
539
+		$new_event->save();
540
+		// now we need to get the question group relations and handle that
541
+		// first primary question groups
542
+		$orig_primary_qgs = $orig_event->get_many_related(
543
+			'Question_Group',
544
+			[['Event_Question_Group.EQG_primary' => true]]
545
+		);
546
+		if (! empty($orig_primary_qgs)) {
547
+			foreach ($orig_primary_qgs as $obj) {
548
+				if ($obj instanceof EE_Question_Group) {
549
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
550
+				}
551
+			}
552
+		}
553
+		// next additional attendee question groups
554
+		$orig_additional_qgs = $orig_event->get_many_related(
555
+			'Question_Group',
556
+			[['Event_Question_Group.EQG_additional' => true]]
557
+		);
558
+		if (! empty($orig_additional_qgs)) {
559
+			foreach ($orig_additional_qgs as $obj) {
560
+				if ($obj instanceof EE_Question_Group) {
561
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
562
+				}
563
+			}
564
+		}
565
+
566
+		$new_event->save();
567
+
568
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
569
+		$cloned_tickets = [];
570
+		foreach ($orig_datetimes as $orig_dtt) {
571
+			if (! $orig_dtt instanceof EE_Datetime) {
572
+				continue;
573
+			}
574
+			$new_dtt      = clone $orig_dtt;
575
+			$orig_tickets = $orig_dtt->tickets();
576
+			// save new dtt then add to event
577
+			$new_dtt->set('DTT_ID', 0);
578
+			$new_dtt->set('DTT_sold', 0);
579
+			$new_dtt->set_reserved(0);
580
+			$new_dtt->save();
581
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
582
+			$new_event->save();
583
+			// now let's get the ticket relations setup.
584
+			foreach ((array) $orig_tickets as $orig_ticket) {
585
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
586
+				if (! $orig_ticket instanceof EE_Ticket) {
587
+					continue;
588
+				}
589
+				// is this ticket archived?  If it is then let's skip
590
+				if ($orig_ticket->get('TKT_deleted')) {
591
+					continue;
592
+				}
593
+				// does this original ticket already exist in the clone_tickets cache?
594
+				//  If so we'll just use the new ticket from it.
595
+				if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
596
+					$new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
597
+				} else {
598
+					$new_ticket = clone $orig_ticket;
599
+					// get relations on the $orig_ticket that we need to setup.
600
+					$orig_prices = $orig_ticket->prices();
601
+					$new_ticket->set('TKT_ID', 0);
602
+					$new_ticket->set('TKT_sold', 0);
603
+					$new_ticket->set('TKT_reserved', 0);
604
+					$new_ticket->save(); // make sure new ticket has ID.
605
+					// price relations on new ticket need to be setup.
606
+					foreach ($orig_prices as $orig_price) {
607
+						$new_price = clone $orig_price;
608
+						$new_price->set('PRC_ID', 0);
609
+						$new_price->save();
610
+						$new_ticket->_add_relation_to($new_price, 'Price');
611
+						$new_ticket->save();
612
+					}
613
+
614
+					do_action(
615
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
616
+						$orig_ticket,
617
+						$new_ticket,
618
+						$orig_prices,
619
+						$orig_event,
620
+						$orig_dtt,
621
+						$new_dtt
622
+					);
623
+				}
624
+				// k now we can add the new ticket as a relation to the new datetime
625
+				// and make sure its added to our cached $cloned_tickets array
626
+				// for use with later datetimes that have the same ticket.
627
+				$new_dtt->_add_relation_to($new_ticket, 'Ticket');
628
+				$new_dtt->save();
629
+				$cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
630
+			}
631
+		}
632
+		// clone taxonomy information
633
+		$taxonomies_to_clone_with = apply_filters(
634
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
635
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
636
+		);
637
+		// get terms for original event (notice)
638
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
639
+		// loop through terms and add them to new event.
640
+		foreach ($orig_terms as $term) {
641
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
642
+		}
643
+
644
+		// duplicate other core WP_Post items for this event.
645
+		// post thumbnail (feature image).
646
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
647
+		if ($feature_image_id) {
648
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
649
+		}
650
+
651
+		// duplicate page_template setting
652
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
653
+		if ($page_template) {
654
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
655
+		}
656
+
657
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
658
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
659
+		if ($new_event->ID()) {
660
+			$redirect_args = [
661
+				'post'   => $new_event->ID(),
662
+				'action' => 'edit',
663
+			];
664
+			EE_Error::add_success(
665
+				esc_html__(
666
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
667
+					'event_espresso'
668
+				)
669
+			);
670
+		} else {
671
+			$redirect_args = [
672
+				'action' => 'default',
673
+			];
674
+			EE_Error::add_error(
675
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
676
+				__FILE__,
677
+				__FUNCTION__,
678
+				__LINE__
679
+			);
680
+		}
681
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
682
+	}
683
+
684
+
685
+	/**
686
+	 * Generates output for the import page.
687
+	 *
688
+	 * @throws EE_Error
689
+	 */
690
+	protected function _import_page()
691
+	{
692
+		$title = esc_html__('Import', 'event_espresso');
693
+		$intro = esc_html__(
694
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
695
+			'event_espresso'
696
+		);
697
+
698
+		$form_url = EVENTS_ADMIN_URL;
699
+		$action   = 'import_events';
700
+		$type     = 'csv';
701
+
702
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
703
+			$title,
704
+			$intro,
705
+			$form_url,
706
+			$action,
707
+			$type
708
+		);
709
+
710
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
711
+			['action' => 'sample_export_file'],
712
+			$this->_admin_base_url
713
+		);
714
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
715
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
716
+			$this->_template_args,
717
+			true
718
+		);
719
+		$this->display_admin_page_with_sidebar();
720
+	}
721
+
722
+
723
+	/**
724
+	 * _import_events
725
+	 * This handles displaying the screen and running imports for importing events.
726
+	 *
727
+	 * @return void
728
+	 * @throws EE_Error
729
+	 */
730
+	protected function _import_events()
731
+	{
732
+		require_once(EE_CLASSES . 'EE_Import.class.php');
733
+		$success = EE_Import::instance()->import();
734
+		$this->_redirect_after_action(
735
+			$success,
736
+			esc_html__('Import File', 'event_espresso'),
737
+			'ran',
738
+			['action' => 'import_page'],
739
+			true
740
+		);
741
+	}
742
+
743
+
744
+	/**
745
+	 * _events_export
746
+	 * Will export all (or just the given event) to a Excel compatible file.
747
+	 *
748
+	 * @access protected
749
+	 * @return void
750
+	 */
751
+	protected function _events_export()
752
+	{
753
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
754
+		$EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
755
+		$this->request->mergeRequestParams(
756
+			[
757
+				'export' => 'report',
758
+				'action' => 'all_event_data',
759
+				'EVT_ID' => $EVT_ID,
760
+			]
761
+		);
762
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
763
+			require_once(EE_CLASSES . 'EE_Export.class.php');
764
+			$EE_Export = EE_Export::instance($this->request->requestParams());
765
+			$EE_Export->export();
766
+		}
767
+	}
768
+
769
+
770
+	/**
771
+	 * handle category exports()
772
+	 *
773
+	 * @return void
774
+	 */
775
+	protected function _categories_export()
776
+	{
777
+		$EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
778
+		$this->request->mergeRequestParams(
779
+			[
780
+				'export' => 'report',
781
+				'action' => 'categories',
782
+				'EVT_ID' => $EVT_ID,
783
+			]
784
+		);
785
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
786
+			require_once(EE_CLASSES . 'EE_Export.class.php');
787
+			$EE_Export = EE_Export::instance($this->request->requestParams());
788
+			$EE_Export->export();
789
+		}
790
+	}
791
+
792
+
793
+	/**
794
+	 * Creates a sample CSV file for importing
795
+	 */
796
+	protected function _sample_export_file()
797
+	{
798
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
799
+		EE_Export::instance()->export_sample();
800
+	}
801
+
802
+
803
+	/*************        Template Settings        *************/
804
+	/**
805
+	 * Generates template settings page output
806
+	 *
807
+	 * @throws DomainException
808
+	 * @throws EE_Error
809
+	 */
810
+	protected function _template_settings()
811
+	{
812
+		$this->_template_args['values'] = $this->_yes_no_values;
813
+		/**
814
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
815
+		 * from General_Settings_Admin_Page to here.
816
+		 */
817
+		$this->_template_args = apply_filters(
818
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
819
+			$this->_template_args
820
+		);
821
+		$this->_set_add_edit_form_tags('update_template_settings');
822
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
823
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
824
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
825
+			$this->_template_args,
826
+			true
827
+		);
828
+		$this->display_admin_page_with_sidebar();
829
+	}
830
+
831
+
832
+	/**
833
+	 * Handler for updating template settings.
834
+	 *
835
+	 * @throws EE_Error
836
+	 */
837
+	protected function _update_template_settings()
838
+	{
839
+		/**
840
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
841
+		 * from General_Settings_Admin_Page to here.
842
+		 */
843
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
844
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
845
+			EE_Registry::instance()->CFG->template_settings,
846
+			$this->request->requestParams()
847
+		);
848
+		// update custom post type slugs and detect if we need to flush rewrite rules
849
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
850
+
851
+		$event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
852
+
853
+		EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
854
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
855
+			: EEH_URL::slugify($event_cpt_slug, 'events');
856
+
857
+		$what    = esc_html__('Template Settings', 'event_espresso');
858
+		$success = $this->_update_espresso_configuration(
859
+			$what,
860
+			EE_Registry::instance()->CFG->template_settings,
861
+			__FILE__,
862
+			__FUNCTION__,
863
+			__LINE__
864
+		);
865
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
866
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
867
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
868
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
869
+			);
870
+			$rewrite_rules->flush();
871
+		}
872
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
873
+	}
874
+
875
+
876
+	/**
877
+	 * _premium_event_editor_meta_boxes
878
+	 * add all metaboxes related to the event_editor
879
+	 *
880
+	 * @access protected
881
+	 * @return void
882
+	 * @throws EE_Error
883
+	 * @throws ReflectionException
884
+	 */
885
+	protected function _premium_event_editor_meta_boxes()
886
+	{
887
+		$this->verify_cpt_object();
888
+		add_meta_box(
889
+			'espresso_event_editor_event_options',
890
+			esc_html__('Event Registration Options', 'event_espresso'),
891
+			[$this, 'registration_options_meta_box'],
892
+			$this->page_slug,
893
+			'side',
894
+			'core'
895
+		);
896
+	}
897
+
898
+
899
+	/**
900
+	 * override caf metabox
901
+	 *
902
+	 * @return void
903
+	 * @throws EE_Error
904
+	 * @throws ReflectionException
905
+	 */
906
+	public function registration_options_meta_box()
907
+	{
908
+		$yes_no_values = [
909
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
910
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
911
+		];
912
+
913
+		$default_reg_status_values = EEM_Registration::reg_status_array(
914
+			[
915
+				EEM_Registration::status_id_cancelled,
916
+				EEM_Registration::status_id_declined,
917
+				EEM_Registration::status_id_incomplete,
918
+				EEM_Registration::status_id_wait_list,
919
+			],
920
+			true
921
+		);
922
+
923
+		$template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
924
+		$template_args['_event']           = $this->_cpt_model_obj;
925
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
926
+
927
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
928
+			'default_reg_status',
929
+			$default_reg_status_values,
930
+			$this->_cpt_model_obj->default_registration_status()
931
+		);
932
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
933
+			'display_desc',
934
+			$yes_no_values,
935
+			$this->_cpt_model_obj->display_description()
936
+		);
937
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
938
+			'display_ticket_selector',
939
+			$yes_no_values,
940
+			$this->_cpt_model_obj->display_ticket_selector(),
941
+			'',
942
+			'',
943
+			false
944
+		);
945
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
946
+			'EVT_default_registration_status',
947
+			$default_reg_status_values,
948
+			$this->_cpt_model_obj->default_registration_status()
949
+		);
950
+		$template_args['additional_registration_options'] = apply_filters(
951
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
952
+			'',
953
+			$template_args,
954
+			$yes_no_values,
955
+			$default_reg_status_values
956
+		);
957
+		EEH_Template::display_template(
958
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
959
+			$template_args
960
+		);
961
+	}
962
+
963
+
964
+
965
+	/**
966
+	 * wp_list_table_mods for caf
967
+	 * ============================
968
+	 */
969
+	/**
970
+	 * hook into list table filters and provide filters for caffeinated list table
971
+	 *
972
+	 * @param array $old_filters    any existing filters present
973
+	 * @param array $list_table_obj the list table object
974
+	 * @return array                  new filters
975
+	 * @throws EE_Error
976
+	 * @throws ReflectionException
977
+	 */
978
+	public function list_table_filters($old_filters, $list_table_obj)
979
+	{
980
+		$filters = [];
981
+		// first month/year filters
982
+		$filters[] = $this->espresso_event_months_dropdown();
983
+		$status    = $this->request->getRequestParam('status');
984
+		// active status dropdown
985
+		if ($status !== 'draft') {
986
+			$filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
987
+			$filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
988
+		}
989
+		// category filter
990
+		$filters[] = $this->category_dropdown();
991
+		return array_merge($old_filters, $filters);
992
+	}
993
+
994
+
995
+	/**
996
+	 * espresso_event_months_dropdown
997
+	 *
998
+	 * @access public
999
+	 * @return string                dropdown listing month/year selections for events.
1000
+	 * @throws EE_Error
1001
+	 */
1002
+	public function espresso_event_months_dropdown()
1003
+	{
1004
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1005
+		// Note we need to include any other filters that are set!
1006
+		return EEH_Form_Fields::generate_event_months_dropdown(
1007
+			$this->request->getRequestParam('month_range'),
1008
+			$this->request->getRequestParam('status'),
1009
+			$this->request->getRequestParam('EVT_CAT', 0, 'int'),
1010
+			$this->request->getRequestParam('active_status')
1011
+		);
1012
+	}
1013
+
1014
+
1015
+	/**
1016
+	 * returns a list of "active" statuses on the event
1017
+	 *
1018
+	 * @param string $current_value whatever the current active status is
1019
+	 * @return string
1020
+	 */
1021
+	public function active_status_dropdown($current_value = '')
1022
+	{
1023
+		$select_name = 'active_status';
1024
+		$values      = [
1025
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1026
+			'active'   => esc_html__('Active', 'event_espresso'),
1027
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1028
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1029
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1030
+		];
1031
+
1032
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1033
+	}
1034
+
1035
+
1036
+	/**
1037
+	 * returns a list of "venues"
1038
+	 *
1039
+	 * @param string $current_value whatever the current active status is
1040
+	 * @return string
1041
+	 * @throws EE_Error
1042
+	 * @throws ReflectionException
1043
+	 */
1044
+	protected function venuesDropdown($current_value = '')
1045
+	{
1046
+		$values = [
1047
+			'' => esc_html__('All Venues', 'event_espresso'),
1048
+		];
1049
+		// populate the list of venues.
1050
+		$venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1051
+
1052
+		foreach ($venues as $venue) {
1053
+			$values[ $venue->ID() ] = $venue->name();
1054
+		}
1055
+
1056
+		return EEH_Form_Fields::select_input('venue', $values, $current_value, '', 'wide');
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * output a dropdown of the categories for the category filter on the event admin list table
1062
+	 *
1063
+	 * @access  public
1064
+	 * @return string html
1065
+	 * @throws EE_Error
1066
+	 * @throws ReflectionException
1067
+	 */
1068
+	public function category_dropdown()
1069
+	{
1070
+		return EEH_Form_Fields::generate_event_category_dropdown(
1071
+			$this->request->getRequestParam('EVT_CAT', -1, 'int')
1072
+		);
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * get total number of events today
1078
+	 *
1079
+	 * @access public
1080
+	 * @return int
1081
+	 * @throws EE_Error
1082
+	 */
1083
+	public function total_events_today()
1084
+	{
1085
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1086
+			'DTT_EVT_start',
1087
+			date('Y-m-d') . ' 00:00:00',
1088
+			'Y-m-d H:i:s',
1089
+			'UTC'
1090
+		);
1091
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1092
+			'DTT_EVT_start',
1093
+			date('Y-m-d') . ' 23:59:59',
1094
+			'Y-m-d H:i:s',
1095
+			'UTC'
1096
+		);
1097
+		$where = [
1098
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1099
+		];
1100
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * get total number of events this month
1106
+	 *
1107
+	 * @access public
1108
+	 * @return int
1109
+	 * @throws EE_Error
1110
+	 */
1111
+	public function total_events_this_month()
1112
+	{
1113
+		// Dates
1114
+		$this_year_r     = date('Y');
1115
+		$this_month_r    = date('m');
1116
+		$days_this_month = date('t');
1117
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1118
+			'DTT_EVT_start',
1119
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1120
+			'Y-m-d H:i:s',
1121
+			'UTC'
1122
+		);
1123
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1124
+			'DTT_EVT_start',
1125
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1126
+			'Y-m-d H:i:s',
1127
+			'UTC'
1128
+		);
1129
+		$where           = [
1130
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1131
+		];
1132
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1133
+	}
1134
+
1135
+
1136
+	/** DEFAULT TICKETS STUFF **/
1137
+
1138
+	/**
1139
+	 * Output default tickets list table view.
1140
+	 *
1141
+	 * @throws EE_Error
1142
+	 */
1143
+	public function _tickets_overview_list_table()
1144
+	{
1145
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1146
+		$this->display_admin_list_table_page_with_no_sidebar();
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * @param int  $per_page
1152
+	 * @param bool $count
1153
+	 * @param bool $trashed
1154
+	 * @return EE_Soft_Delete_Base_Class[]|int
1155
+	 * @throws EE_Error
1156
+	 */
1157
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1158
+	{
1159
+		$orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1160
+		$order   = $this->request->getRequestParam('order', 'ASC');
1161
+		switch ($orderby) {
1162
+			case 'TKT_name':
1163
+				$orderby = ['TKT_name' => $order];
1164
+				break;
1165
+			case 'TKT_price':
1166
+				$orderby = ['TKT_price' => $order];
1167
+				break;
1168
+			case 'TKT_uses':
1169
+				$orderby = ['TKT_uses' => $order];
1170
+				break;
1171
+			case 'TKT_min':
1172
+				$orderby = ['TKT_min' => $order];
1173
+				break;
1174
+			case 'TKT_max':
1175
+				$orderby = ['TKT_max' => $order];
1176
+				break;
1177
+			case 'TKT_qty':
1178
+				$orderby = ['TKT_qty' => $order];
1179
+				break;
1180
+		}
1181
+
1182
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1183
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1184
+		$offset       = ($current_page - 1) * $per_page;
1185
+
1186
+		$where = [
1187
+			'TKT_is_default' => 1,
1188
+			'TKT_deleted'    => $trashed,
1189
+		];
1190
+
1191
+		$search_term = $this->request->getRequestParam('s');
1192
+		if ($search_term) {
1193
+			$search_term = '%' . $search_term . '%';
1194
+			$where['OR'] = [
1195
+				'TKT_name'        => ['LIKE', $search_term],
1196
+				'TKT_description' => ['LIKE', $search_term],
1197
+			];
1198
+		}
1199
+
1200
+		return $count
1201
+			? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1202
+			: EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1203
+				[
1204
+					$where,
1205
+					'order_by' => $orderby,
1206
+					'limit'    => [$offset, $per_page],
1207
+					'group_by' => 'TKT_ID',
1208
+				]
1209
+			);
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 * @param bool $trash
1215
+	 * @throws EE_Error
1216
+	 */
1217
+	protected function _trash_or_restore_ticket($trash = false)
1218
+	{
1219
+		$success = 1;
1220
+		$TKT     = EEM_Ticket::instance();
1221
+		// checkboxes?
1222
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1223
+		if (! empty($checkboxes)) {
1224
+			// if array has more than one element then success message should be plural
1225
+			$success = count($checkboxes) > 1 ? 2 : 1;
1226
+			// cycle thru the boxes
1227
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1228
+				if ($trash) {
1229
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1230
+						$success = 0;
1231
+					}
1232
+				} else {
1233
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1234
+						$success = 0;
1235
+					}
1236
+				}
1237
+			}
1238
+		} else {
1239
+			// grab single id and trash
1240
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1241
+			if ($trash) {
1242
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1243
+					$success = 0;
1244
+				}
1245
+			} else {
1246
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1247
+					$success = 0;
1248
+				}
1249
+			}
1250
+		}
1251
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1252
+		$query_args  = [
1253
+			'action' => 'ticket_list_table',
1254
+			'status' => $trash ? '' : 'trashed',
1255
+		];
1256
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * Handles trashing default ticket.
1262
+	 *
1263
+	 * @throws EE_Error
1264
+	 * @throws ReflectionException
1265
+	 */
1266
+	protected function _delete_ticket()
1267
+	{
1268
+		$success = 1;
1269
+		// checkboxes?
1270
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1271
+		if (! empty($checkboxes)) {
1272
+			// if array has more than one element then success message should be plural
1273
+			$success = count($checkboxes) > 1 ? 2 : 1;
1274
+			// cycle thru the boxes
1275
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1276
+				// delete
1277
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1278
+					$success = 0;
1279
+				}
1280
+			}
1281
+		} else {
1282
+			// grab single id and trash
1283
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1284
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1285
+				$success = 0;
1286
+			}
1287
+		}
1288
+		$action_desc = 'deleted';
1289
+		$query_args  = [
1290
+			'action' => 'ticket_list_table',
1291
+			'status' => 'trashed',
1292
+		];
1293
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1294
+		if (
1295
+			EEM_Ticket::instance()->count_deleted_and_undeleted(
1296
+				[['TKT_is_default' => 1]],
1297
+				'TKT_ID',
1298
+				true
1299
+			)
1300
+		) {
1301
+			$query_args = [];
1302
+		}
1303
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1304
+	}
1305
+
1306
+
1307
+	/**
1308
+	 * @param int $TKT_ID
1309
+	 * @return bool|int
1310
+	 * @throws EE_Error
1311
+	 * @throws ReflectionException
1312
+	 */
1313
+	protected function _delete_the_ticket($TKT_ID)
1314
+	{
1315
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1316
+		$ticket->_remove_relations('Datetime');
1317
+		// delete all related prices first
1318
+		$ticket->delete_related_permanently('Price');
1319
+		return $ticket->delete_permanently();
1320
+	}
1321 1321
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     public function __construct($routing = true)
25 25
     {
26 26
         parent::__construct($routing);
27
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
29
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
30
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
27
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
29
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
30
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
31 31
         }
32 32
     }
33 33
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     protected function _extend_page_config()
41 41
     {
42
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
42
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
43 43
         // is there a evt_id in the request?
44 44
         $EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
45 45
         $EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             // 'help_tour'     => array('Templates_Help_Tour'),
169 169
             'require_nonce' => false,
170 170
         ];
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
171
+        $this->_page_config = array_merge($this->_page_config, $new_page_config);
172 172
         // add filters and actions
173 173
         // modifying _views
174 174
         add_filter(
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
247 247
         // make sure this is only when editing
248
-        if (! empty($id)) {
249
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
248
+        if ( ! empty($id)) {
249
+            $href = EE_Admin_Page::add_query_args_and_nonce(
250 250
                 ['action' => 'duplicate_event', 'EVT_ID' => $id],
251 251
                 $this->_admin_base_url
252 252
             );
253
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
253
+            $title = esc_attr__('Duplicate Event', 'event_espresso');
254 254
             $return .= '<a href="'
255 255
                        . $href
256 256
                        . '" title="'
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         wp_register_script(
299 299
             'ee-event-editor-heartbeat',
300
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
300
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
301 301
             ['ee_admin_js', 'heartbeat'],
302 302
             EVENT_ESPRESSO_VERSION,
303 303
             true
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     public function add_additional_datetime_button($template, $template_args)
322 322
     {
323 323
         return EEH_Template::display_template(
324
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
324
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
325 325
             $template_args,
326 326
             true
327 327
         );
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     public function add_datetime_clone_button($template, $template_args)
340 340
     {
341 341
         return EEH_Template::display_template(
342
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
342
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
343 343
             $template_args,
344 344
             true
345 345
         );
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     public function datetime_timezones_template($template, $template_args)
358 358
     {
359 359
         return EEH_Template::display_template(
360
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
360
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
361 361
             $template_args,
362 362
             true
363 363
         );
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     protected function _set_list_table_views_default()
373 373
     {
374 374
         parent::_set_list_table_views_default();
375
-        $new_views    = [
375
+        $new_views = [
376 376
             'today' => [
377 377
                 'slug'        => 'today',
378 378
                 'label'       => esc_html__('Today', 'event_espresso'),
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
         // first make sure the ID for the event is in the request.
484 484
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
485 485
         $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
486
-        if (! $EVT_ID) {
486
+        if ( ! $EVT_ID) {
487 487
             EE_Error::add_error(
488 488
                 esc_html__(
489 489
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
         }
499 499
         // k we've got EVT_ID so let's use that to get the event we'll duplicate
500 500
         $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
501
-        if (! $orig_event instanceof EE_Event) {
501
+        if ( ! $orig_event instanceof EE_Event) {
502 502
             throw new EE_Error(
503 503
                 sprintf(
504 504
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         $orig_ven = $orig_event->get_many_related('Venue');
515 515
         // reset the ID and modify other details to make it clear this is a dupe
516 516
         $new_event->set('EVT_ID', 0);
517
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
517
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
518 518
         $new_event->set('EVT_name', $new_name);
519 519
         $new_event->set(
520 520
             'EVT_slug',
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
             'Question_Group',
544 544
             [['Event_Question_Group.EQG_primary' => true]]
545 545
         );
546
-        if (! empty($orig_primary_qgs)) {
546
+        if ( ! empty($orig_primary_qgs)) {
547 547
             foreach ($orig_primary_qgs as $obj) {
548 548
                 if ($obj instanceof EE_Question_Group) {
549 549
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
             'Question_Group',
556 556
             [['Event_Question_Group.EQG_additional' => true]]
557 557
         );
558
-        if (! empty($orig_additional_qgs)) {
558
+        if ( ! empty($orig_additional_qgs)) {
559 559
             foreach ($orig_additional_qgs as $obj) {
560 560
                 if ($obj instanceof EE_Question_Group) {
561 561
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
         // k now that we have the new event saved we can loop through the datetimes and start adding relations.
569 569
         $cloned_tickets = [];
570 570
         foreach ($orig_datetimes as $orig_dtt) {
571
-            if (! $orig_dtt instanceof EE_Datetime) {
571
+            if ( ! $orig_dtt instanceof EE_Datetime) {
572 572
                 continue;
573 573
             }
574 574
             $new_dtt      = clone $orig_dtt;
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             // now let's get the ticket relations setup.
584 584
             foreach ((array) $orig_tickets as $orig_ticket) {
585 585
                 // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
586
-                if (! $orig_ticket instanceof EE_Ticket) {
586
+                if ( ! $orig_ticket instanceof EE_Ticket) {
587 587
                     continue;
588 588
                 }
589 589
                 // is this ticket archived?  If it is then let's skip
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
                 }
593 593
                 // does this original ticket already exist in the clone_tickets cache?
594 594
                 //  If so we'll just use the new ticket from it.
595
-                if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
596
-                    $new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
595
+                if (isset($cloned_tickets[$orig_ticket->ID()])) {
596
+                    $new_ticket = $cloned_tickets[$orig_ticket->ID()];
597 597
                 } else {
598 598
                     $new_ticket = clone $orig_ticket;
599 599
                     // get relations on the $orig_ticket that we need to setup.
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
                 // for use with later datetimes that have the same ticket.
627 627
                 $new_dtt->_add_relation_to($new_ticket, 'Ticket');
628 628
                 $new_dtt->save();
629
-                $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
629
+                $cloned_tickets[$orig_ticket->ID()] = $new_ticket;
630 630
             }
631 631
         }
632 632
         // clone taxonomy information
@@ -707,12 +707,12 @@  discard block
 block discarded – undo
707 707
             $type
708 708
         );
709 709
 
710
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
710
+        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
711 711
             ['action' => 'sample_export_file'],
712 712
             $this->_admin_base_url
713 713
         );
714 714
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
715
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
715
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
716 716
             $this->_template_args,
717 717
             true
718 718
         );
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
      */
730 730
     protected function _import_events()
731 731
     {
732
-        require_once(EE_CLASSES . 'EE_Import.class.php');
732
+        require_once(EE_CLASSES.'EE_Import.class.php');
733 733
         $success = EE_Import::instance()->import();
734 734
         $this->_redirect_after_action(
735 735
             $success,
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
                 'EVT_ID' => $EVT_ID,
760 760
             ]
761 761
         );
762
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
763
-            require_once(EE_CLASSES . 'EE_Export.class.php');
762
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
763
+            require_once(EE_CLASSES.'EE_Export.class.php');
764 764
             $EE_Export = EE_Export::instance($this->request->requestParams());
765 765
             $EE_Export->export();
766 766
         }
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
                 'EVT_ID' => $EVT_ID,
783 783
             ]
784 784
         );
785
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
786
-            require_once(EE_CLASSES . 'EE_Export.class.php');
785
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
786
+            require_once(EE_CLASSES.'EE_Export.class.php');
787 787
             $EE_Export = EE_Export::instance($this->request->requestParams());
788 788
             $EE_Export->export();
789 789
         }
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         $this->_set_add_edit_form_tags('update_template_settings');
822 822
         $this->_set_publish_post_box_vars(null, false, false, null, false);
823 823
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
824
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
824
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
825 825
             $this->_template_args,
826 826
             true
827 827
         );
@@ -924,17 +924,17 @@  discard block
 block discarded – undo
924 924
         $template_args['_event']           = $this->_cpt_model_obj;
925 925
         $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
926 926
 
927
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
927
+        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
928 928
             'default_reg_status',
929 929
             $default_reg_status_values,
930 930
             $this->_cpt_model_obj->default_registration_status()
931 931
         );
932
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
932
+        $template_args['display_description'] = EEH_Form_Fields::select_input(
933 933
             'display_desc',
934 934
             $yes_no_values,
935 935
             $this->_cpt_model_obj->display_description()
936 936
         );
937
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
937
+        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
938 938
             'display_ticket_selector',
939 939
             $yes_no_values,
940 940
             $this->_cpt_model_obj->display_ticket_selector(),
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
             $default_reg_status_values
956 956
         );
957 957
         EEH_Template::display_template(
958
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
958
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
959 959
             $template_args
960 960
         );
961 961
     }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
         $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1051 1051
 
1052 1052
         foreach ($venues as $venue) {
1053
-            $values[ $venue->ID() ] = $venue->name();
1053
+            $values[$venue->ID()] = $venue->name();
1054 1054
         }
1055 1055
 
1056 1056
         return EEH_Form_Fields::select_input('venue', $values, $current_value, '', 'wide');
@@ -1084,13 +1084,13 @@  discard block
 block discarded – undo
1084 1084
     {
1085 1085
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1086 1086
             'DTT_EVT_start',
1087
-            date('Y-m-d') . ' 00:00:00',
1087
+            date('Y-m-d').' 00:00:00',
1088 1088
             'Y-m-d H:i:s',
1089 1089
             'UTC'
1090 1090
         );
1091
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1091
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1092 1092
             'DTT_EVT_start',
1093
-            date('Y-m-d') . ' 23:59:59',
1093
+            date('Y-m-d').' 23:59:59',
1094 1094
             'Y-m-d H:i:s',
1095 1095
             'UTC'
1096 1096
         );
@@ -1116,17 +1116,17 @@  discard block
 block discarded – undo
1116 1116
         $days_this_month = date('t');
1117 1117
         $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1118 1118
             'DTT_EVT_start',
1119
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1119
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1120 1120
             'Y-m-d H:i:s',
1121 1121
             'UTC'
1122 1122
         );
1123
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1123
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1124 1124
             'DTT_EVT_start',
1125
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1125
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1126 1126
             'Y-m-d H:i:s',
1127 1127
             'UTC'
1128 1128
         );
1129
-        $where           = [
1129
+        $where = [
1130 1130
             'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1131 1131
         ];
1132 1132
         return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
         $search_term = $this->request->getRequestParam('s');
1192 1192
         if ($search_term) {
1193
-            $search_term = '%' . $search_term . '%';
1193
+            $search_term = '%'.$search_term.'%';
1194 1194
             $where['OR'] = [
1195 1195
                 'TKT_name'        => ['LIKE', $search_term],
1196 1196
                 'TKT_description' => ['LIKE', $search_term],
@@ -1220,17 +1220,17 @@  discard block
 block discarded – undo
1220 1220
         $TKT     = EEM_Ticket::instance();
1221 1221
         // checkboxes?
1222 1222
         $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1223
-        if (! empty($checkboxes)) {
1223
+        if ( ! empty($checkboxes)) {
1224 1224
             // if array has more than one element then success message should be plural
1225 1225
             $success = count($checkboxes) > 1 ? 2 : 1;
1226 1226
             // cycle thru the boxes
1227 1227
             while (list($TKT_ID, $value) = each($checkboxes)) {
1228 1228
                 if ($trash) {
1229
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1229
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1230 1230
                         $success = 0;
1231 1231
                     }
1232 1232
                 } else {
1233
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1233
+                    if ( ! $TKT->restore_by_ID($TKT_ID)) {
1234 1234
                         $success = 0;
1235 1235
                     }
1236 1236
                 }
@@ -1239,11 +1239,11 @@  discard block
 block discarded – undo
1239 1239
             // grab single id and trash
1240 1240
             $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1241 1241
             if ($trash) {
1242
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1242
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1243 1243
                     $success = 0;
1244 1244
                 }
1245 1245
             } else {
1246
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1246
+                if ( ! $TKT->restore_by_ID($TKT_ID)) {
1247 1247
                     $success = 0;
1248 1248
                 }
1249 1249
             }
@@ -1268,20 +1268,20 @@  discard block
 block discarded – undo
1268 1268
         $success = 1;
1269 1269
         // checkboxes?
1270 1270
         $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1271
-        if (! empty($checkboxes)) {
1271
+        if ( ! empty($checkboxes)) {
1272 1272
             // if array has more than one element then success message should be plural
1273 1273
             $success = count($checkboxes) > 1 ? 2 : 1;
1274 1274
             // cycle thru the boxes
1275 1275
             while (list($TKT_ID, $value) = each($checkboxes)) {
1276 1276
                 // delete
1277
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1277
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1278 1278
                     $success = 0;
1279 1279
                 }
1280 1280
             }
1281 1281
         } else {
1282 1282
             // grab single id and trash
1283 1283
             $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1284
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1284
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1285 1285
                 $success = 0;
1286 1286
             }
1287 1287
         }
Please login to merge, or discard this patch.
core/services/request/RequestParams.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -14,327 +14,327 @@
 block discarded – undo
14 14
 class RequestParams
15 15
 {
16 16
 
17
-    /**
18
-     * $_GET parameters
19
-     *
20
-     * @var array
21
-     */
22
-    protected $get;
23
-
24
-    /**
25
-     * $_POST parameters
26
-     *
27
-     * @var array
28
-     */
29
-    protected $post;
30
-
31
-    /**
32
-     * $_REQUEST parameters
33
-     *
34
-     * @var array
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RequestSanitizer
40
-     */
41
-    protected $sanitizer;
42
-
43
-
44
-    /**
45
-     * RequestParams constructor.
46
-     *
47
-     * @param RequestSanitizer $sanitizer
48
-     * @param array            $get
49
-     * @param array            $post
50
-     */
51
-    public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
-    {
53
-        $this->sanitizer = $sanitizer;
54
-        $this->get       = ! empty($get) ? $get : $_GET;
55
-        $this->post      = ! empty($post) ? $post : $_POST;
56
-        $this->request   = array_merge($this->get, $this->post);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return array
62
-     */
63
-    public function getParams()
64
-    {
65
-        return $this->get;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function postParams()
73
-    {
74
-        return $this->post;
75
-    }
76
-
77
-
78
-    /**
79
-     * returns contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams()
84
-    {
85
-        return $this->request;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string     $key
91
-     * @param mixed|null $value
92
-     * @param bool       $override_ee
93
-     * @return    void
94
-     */
95
-    public function setRequestParam($key, $value, $override_ee = false)
96
-    {
97
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
98
-        if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
-            $this->request[ $key ] = $value;
100
-        }
101
-    }
102
-
103
-
104
-    /**
105
-     * merges the incoming array of parameters into the existing request parameters
106
-     *
107
-     * @param array $request_params
108
-     * @return void
109
-     * @since   4.10.24.p
110
-     */
111
-    public function mergeRequestParams(array $request_params)
112
-    {
113
-        $this->request = array_merge($this->request, $request_params);
114
-    }
115
-
116
-
117
-    /**
118
-     * returns   the value for a request param if the given key exists
119
-     *
120
-     * @param string     $key
121
-     * @param mixed|null $default
122
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
-     * @param string     $delimiter for CSV type strings that should be returned as an array
125
-     * @return array|bool|float|int|string
126
-     */
127
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
-    {
129
-        return $this->sanitizer->clean(
130
-            $this->parameterDrillDown($key, $default, 'get'),
131
-            $type,
132
-            $is_array,
133
-            $delimiter
134
-        );
135
-    }
136
-
137
-
138
-    /**
139
-     * check if param exists
140
-     *
141
-     * @param string $key
142
-     * @return bool
143
-     */
144
-    public function requestParamIsSet($key)
145
-    {
146
-        return (bool) $this->parameterDrillDown($key);
147
-    }
148
-
149
-
150
-    /**
151
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
-     * and return the value for the first match found
153
-     * wildcards can be either of the following:
154
-     *      ? to represent a single character of any type
155
-     *      * to represent one or more characters of any type
156
-     *
157
-     * @param string     $pattern
158
-     * @param mixed|null $default
159
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
-     * @param string     $delimiter for CSV type strings that should be returned as an array
162
-     * @return array|bool|float|int|string
163
-     */
164
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
-    {
166
-        return $this->sanitizer->clean(
167
-            $this->parameterDrillDown($pattern, $default, 'match'),
168
-            $type,
169
-            $is_array,
170
-            $delimiter
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
177
-     * wildcards can be either of the following:
178
-     *      ? to represent a single character of any type
179
-     *      * to represent one or more characters of any type
180
-     * returns true if a match is found or false if not
181
-     *
182
-     * @param string $pattern
183
-     * @return bool
184
-     */
185
-    public function matches($pattern)
186
-    {
187
-        return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
-    }
189
-
190
-
191
-    /**
192
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
-     *                                      and used to search through the current request's parameter keys
195
-     * @param array  $request_params        The array of request parameters to search through
196
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
197
-     *                                      Default is null
198
-     * @param string $return                [optional] Controls what kind of value is returned.
199
-     *                                      Options are:
200
-     *                                      'bool' will return true or false if match is found or not
201
-     *                                      'key' will return the first key found that matches the supplied pattern
202
-     *                                      'value' will return the value for the first request parameter
203
-     *                                      whose key matches the supplied pattern
204
-     *                                      Default is 'value'
205
-     * @return boolean|string
206
-     */
207
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
208
-    {
209
-        $return = in_array($return, ['bool', 'key', 'value'], true)
210
-            ? $return
211
-            : 'is_set';
212
-        // replace wildcard chars with regex chars
213
-        $pattern = str_replace(
214
-            ['\*', '\?'],
215
-            ['.*', '.'],
216
-            preg_quote($pattern, '/')
217
-        );
218
-        foreach ($request_params as $key => $request_param) {
219
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
220
-                // return value for request param
221
-                if ($return === 'value') {
222
-                    return $request_param;
223
-                }
224
-                // or actual key or true just to indicate it was found
225
-                return $return === 'key' ? $key : true;
226
-            }
227
-        }
228
-        // match not found so return default value or false
229
-        return $return === 'value' ? $default : false;
230
-    }
231
-
232
-
233
-    /**
234
-     * the supplied key can be a simple string to represent a "top-level" request parameter
235
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
-     * by using square brackets to surround keys for deeper array elements.
237
-     * For example :
238
-     * if the supplied $key was: "first[second][third]"
239
-     * then this will attempt to drill down into the request parameter array to find a value.
240
-     * Given the following request parameters:
241
-     *  array(
242
-     *      'first' => array(
243
-     *          'second' => array(
244
-     *              'third' => 'has a value'
245
-     *          )
246
-     *      )
247
-     *  )
248
-     * would return true if default parameters were set
249
-     *
250
-     * @param string $callback
251
-     * @param        $key
252
-     * @param null   $default
253
-     * @param string $return
254
-     * @param mixed  $request_params
255
-     * @return bool|mixed|null
256
-     */
257
-    private function parameterDrillDown(
258
-        $key,
259
-        $default = null,
260
-        $callback = 'is_set',
261
-        $return = 'value',
262
-        $request_params = []
263
-    ) {
264
-        $callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
-            ? $callback
266
-            : 'is_set';
267
-        $request_params = ! empty($request_params)
268
-            ? $request_params
269
-            : $this->request;
270
-        // does incoming key represent an array like 'first[second][third]'  ?
271
-        if (strpos($key, '[') !== false) {
272
-            // turn it into an actual array
273
-            $key  = str_replace(']', '', $key);
274
-            $keys = explode('[', $key);
275
-            $key  = array_shift($keys);
276
-            if ($callback === 'match') {
277
-                $real_key = $this->match($key, $request_params, $default, 'key');
278
-                $key      = $real_key ?: $key;
279
-            }
280
-            // check if top level key exists
281
-            if (isset($request_params[ $key ])) {
282
-                // build a new key to pass along like: 'second[third]'
283
-                // or just 'second' depending on depth of keys
284
-                $key_string = array_shift($keys);
285
-                if (! empty($keys)) {
286
-                    $key_string .= '[' . implode('][', $keys) . ']';
287
-                }
288
-                return $this->parameterDrillDown(
289
-                    $key_string,
290
-                    $default,
291
-                    $callback,
292
-                    $return,
293
-                    $request_params[ $key ]
294
-                );
295
-            }
296
-        }
297
-        if ($callback === 'is_set') {
298
-            return isset($request_params[ $key ]);
299
-        }
300
-        if ($callback === 'match') {
301
-            return $this->match($key, $request_params, $default, $return);
302
-        }
303
-        return isset($request_params[ $key ])
304
-            ? $request_params[ $key ]
305
-            : $default;
306
-    }
307
-
308
-
309
-    /**
310
-     * remove param
311
-     *
312
-     * @param      $key
313
-     * @param bool $unset_from_global_too
314
-     */
315
-    public function unSetRequestParam($key, $unset_from_global_too = false)
316
-    {
317
-        // because unset may not actually remove var
318
-        $this->get[ $key ]     = null;
319
-        $this->post[ $key ]    = null;
320
-        $this->request[ $key ] = null;
321
-        unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
-        if ($unset_from_global_too) {
323
-            unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * remove params
330
-     *
331
-     * @param array $keys
332
-     * @param bool  $unset_from_global_too
333
-     */
334
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
-    {
336
-        foreach ($keys as $key) {
337
-            $this->unSetRequestParam($key, $unset_from_global_too);
338
-        }
339
-    }
17
+	/**
18
+	 * $_GET parameters
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $get;
23
+
24
+	/**
25
+	 * $_POST parameters
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $post;
30
+
31
+	/**
32
+	 * $_REQUEST parameters
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RequestSanitizer
40
+	 */
41
+	protected $sanitizer;
42
+
43
+
44
+	/**
45
+	 * RequestParams constructor.
46
+	 *
47
+	 * @param RequestSanitizer $sanitizer
48
+	 * @param array            $get
49
+	 * @param array            $post
50
+	 */
51
+	public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
+	{
53
+		$this->sanitizer = $sanitizer;
54
+		$this->get       = ! empty($get) ? $get : $_GET;
55
+		$this->post      = ! empty($post) ? $post : $_POST;
56
+		$this->request   = array_merge($this->get, $this->post);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return array
62
+	 */
63
+	public function getParams()
64
+	{
65
+		return $this->get;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function postParams()
73
+	{
74
+		return $this->post;
75
+	}
76
+
77
+
78
+	/**
79
+	 * returns contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams()
84
+	{
85
+		return $this->request;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string     $key
91
+	 * @param mixed|null $value
92
+	 * @param bool       $override_ee
93
+	 * @return    void
94
+	 */
95
+	public function setRequestParam($key, $value, $override_ee = false)
96
+	{
97
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
98
+		if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
+			$this->request[ $key ] = $value;
100
+		}
101
+	}
102
+
103
+
104
+	/**
105
+	 * merges the incoming array of parameters into the existing request parameters
106
+	 *
107
+	 * @param array $request_params
108
+	 * @return void
109
+	 * @since   4.10.24.p
110
+	 */
111
+	public function mergeRequestParams(array $request_params)
112
+	{
113
+		$this->request = array_merge($this->request, $request_params);
114
+	}
115
+
116
+
117
+	/**
118
+	 * returns   the value for a request param if the given key exists
119
+	 *
120
+	 * @param string     $key
121
+	 * @param mixed|null $default
122
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
125
+	 * @return array|bool|float|int|string
126
+	 */
127
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
+	{
129
+		return $this->sanitizer->clean(
130
+			$this->parameterDrillDown($key, $default, 'get'),
131
+			$type,
132
+			$is_array,
133
+			$delimiter
134
+		);
135
+	}
136
+
137
+
138
+	/**
139
+	 * check if param exists
140
+	 *
141
+	 * @param string $key
142
+	 * @return bool
143
+	 */
144
+	public function requestParamIsSet($key)
145
+	{
146
+		return (bool) $this->parameterDrillDown($key);
147
+	}
148
+
149
+
150
+	/**
151
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
+	 * and return the value for the first match found
153
+	 * wildcards can be either of the following:
154
+	 *      ? to represent a single character of any type
155
+	 *      * to represent one or more characters of any type
156
+	 *
157
+	 * @param string     $pattern
158
+	 * @param mixed|null $default
159
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
162
+	 * @return array|bool|float|int|string
163
+	 */
164
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
+	{
166
+		return $this->sanitizer->clean(
167
+			$this->parameterDrillDown($pattern, $default, 'match'),
168
+			$type,
169
+			$is_array,
170
+			$delimiter
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
177
+	 * wildcards can be either of the following:
178
+	 *      ? to represent a single character of any type
179
+	 *      * to represent one or more characters of any type
180
+	 * returns true if a match is found or false if not
181
+	 *
182
+	 * @param string $pattern
183
+	 * @return bool
184
+	 */
185
+	public function matches($pattern)
186
+	{
187
+		return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
+	}
189
+
190
+
191
+	/**
192
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
+	 *                                      and used to search through the current request's parameter keys
195
+	 * @param array  $request_params        The array of request parameters to search through
196
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
197
+	 *                                      Default is null
198
+	 * @param string $return                [optional] Controls what kind of value is returned.
199
+	 *                                      Options are:
200
+	 *                                      'bool' will return true or false if match is found or not
201
+	 *                                      'key' will return the first key found that matches the supplied pattern
202
+	 *                                      'value' will return the value for the first request parameter
203
+	 *                                      whose key matches the supplied pattern
204
+	 *                                      Default is 'value'
205
+	 * @return boolean|string
206
+	 */
207
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
208
+	{
209
+		$return = in_array($return, ['bool', 'key', 'value'], true)
210
+			? $return
211
+			: 'is_set';
212
+		// replace wildcard chars with regex chars
213
+		$pattern = str_replace(
214
+			['\*', '\?'],
215
+			['.*', '.'],
216
+			preg_quote($pattern, '/')
217
+		);
218
+		foreach ($request_params as $key => $request_param) {
219
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
220
+				// return value for request param
221
+				if ($return === 'value') {
222
+					return $request_param;
223
+				}
224
+				// or actual key or true just to indicate it was found
225
+				return $return === 'key' ? $key : true;
226
+			}
227
+		}
228
+		// match not found so return default value or false
229
+		return $return === 'value' ? $default : false;
230
+	}
231
+
232
+
233
+	/**
234
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
235
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
+	 * by using square brackets to surround keys for deeper array elements.
237
+	 * For example :
238
+	 * if the supplied $key was: "first[second][third]"
239
+	 * then this will attempt to drill down into the request parameter array to find a value.
240
+	 * Given the following request parameters:
241
+	 *  array(
242
+	 *      'first' => array(
243
+	 *          'second' => array(
244
+	 *              'third' => 'has a value'
245
+	 *          )
246
+	 *      )
247
+	 *  )
248
+	 * would return true if default parameters were set
249
+	 *
250
+	 * @param string $callback
251
+	 * @param        $key
252
+	 * @param null   $default
253
+	 * @param string $return
254
+	 * @param mixed  $request_params
255
+	 * @return bool|mixed|null
256
+	 */
257
+	private function parameterDrillDown(
258
+		$key,
259
+		$default = null,
260
+		$callback = 'is_set',
261
+		$return = 'value',
262
+		$request_params = []
263
+	) {
264
+		$callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
+			? $callback
266
+			: 'is_set';
267
+		$request_params = ! empty($request_params)
268
+			? $request_params
269
+			: $this->request;
270
+		// does incoming key represent an array like 'first[second][third]'  ?
271
+		if (strpos($key, '[') !== false) {
272
+			// turn it into an actual array
273
+			$key  = str_replace(']', '', $key);
274
+			$keys = explode('[', $key);
275
+			$key  = array_shift($keys);
276
+			if ($callback === 'match') {
277
+				$real_key = $this->match($key, $request_params, $default, 'key');
278
+				$key      = $real_key ?: $key;
279
+			}
280
+			// check if top level key exists
281
+			if (isset($request_params[ $key ])) {
282
+				// build a new key to pass along like: 'second[third]'
283
+				// or just 'second' depending on depth of keys
284
+				$key_string = array_shift($keys);
285
+				if (! empty($keys)) {
286
+					$key_string .= '[' . implode('][', $keys) . ']';
287
+				}
288
+				return $this->parameterDrillDown(
289
+					$key_string,
290
+					$default,
291
+					$callback,
292
+					$return,
293
+					$request_params[ $key ]
294
+				);
295
+			}
296
+		}
297
+		if ($callback === 'is_set') {
298
+			return isset($request_params[ $key ]);
299
+		}
300
+		if ($callback === 'match') {
301
+			return $this->match($key, $request_params, $default, $return);
302
+		}
303
+		return isset($request_params[ $key ])
304
+			? $request_params[ $key ]
305
+			: $default;
306
+	}
307
+
308
+
309
+	/**
310
+	 * remove param
311
+	 *
312
+	 * @param      $key
313
+	 * @param bool $unset_from_global_too
314
+	 */
315
+	public function unSetRequestParam($key, $unset_from_global_too = false)
316
+	{
317
+		// because unset may not actually remove var
318
+		$this->get[ $key ]     = null;
319
+		$this->post[ $key ]    = null;
320
+		$this->request[ $key ] = null;
321
+		unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
+		if ($unset_from_global_too) {
323
+			unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * remove params
330
+	 *
331
+	 * @param array $keys
332
+	 * @param bool  $unset_from_global_too
333
+	 */
334
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
+	{
336
+		foreach ($keys as $key) {
337
+			$this->unSetRequestParam($key, $unset_from_global_too);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.27.rc.005');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.27.rc.005');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.