Completed
Branch master (3457d3)
by
unknown
25:39 queued 23:21
created
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 2 patches
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -14,121 +14,121 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var SessionLifespan $session_lifespan
19
-     */
20
-    private $session_lifespan;
21
-
22
-    private $_status;
23
-
24
-
25
-    /**
26
-     * @param \Transactions_Admin_Page $admin_page
27
-     * @param SessionLifespan          $lifespan
28
-     */
29
-    public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
30
-    {
31
-        parent::__construct($admin_page);
32
-        $this->session_lifespan = $lifespan;
33
-        $this->_status = $this->_admin_page->get_transaction_status_array();
34
-    }
35
-
36
-
37
-    /**
38
-     *_setup_data
39
-     */
40
-    protected function _setup_data()
41
-    {
42
-        $this->_data = $this->_admin_page->get_transactions($this->_per_page);
43
-        $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
44
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
45
-    }
46
-
47
-
48
-    /**
49
-     *_set_properties
50
-     */
51
-    protected function _set_properties()
52
-    {
53
-        $this->_wp_list_args = array(
54
-            'singular' => esc_html__('transaction', 'event_espresso'),
55
-            'plural'   => esc_html__('transactions', 'event_espresso'),
56
-            'ajax'     => true,
57
-            'screen'   => $this->_admin_page->get_current_screen()->id,
58
-        );
59
-        $ID_column_name = esc_html__('ID', 'event_espresso');
60
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
61
-        $ID_column_name .= esc_html__('Transaction Date', 'event_espresso');
62
-        $ID_column_name .= '</span> ';
63
-        $this->_columns = array(
64
-            'TXN_ID'        => $ID_column_name,
65
-            'TXN_timestamp' => esc_html__('Transaction Date', 'event_espresso'),
66
-            'TXN_total'     => esc_html__('Total', 'event_espresso'),
67
-            'TXN_paid'      => esc_html__('Paid', 'event_espresso'),
68
-            'ATT_fname'     => esc_html__('Primary Registrant', 'event_espresso'),
69
-            'event_name'    => esc_html__('Event', 'event_espresso'),
70
-            'actions'       => esc_html__('Actions', 'event_espresso'),
71
-        );
72
-
73
-        $this->_sortable_columns = array(
74
-            'TXN_ID'        => array('TXN_ID' => false),
75
-            'event_name'    => array('event_name' => false),
76
-            'ATT_fname'     => array('ATT_fname' => false),
77
-            'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
78
-        );
79
-
80
-        $this->_primary_column = 'TXN_ID';
81
-
82
-        $this->_hidden_columns = array();
83
-    }
84
-
85
-
86
-    /**
87
-     * This simply sets up the row class for the table rows.
88
-     * Allows for easier overriding of child methods for setting up sorting.
89
-     *
90
-     * @param  EE_Transaction $transaction the current item
91
-     * @return string
92
-     * @throws \EE_Error
93
-     */
94
-    protected function _get_row_class($transaction)
95
-    {
96
-        $class = parent::_get_row_class($transaction);
97
-        // add status class
98
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
99
-        if ($this->_has_checkbox_column) {
100
-            $class .= ' has-checkbox-column';
101
-        }
102
-        return $class;
103
-    }
104
-
105
-
106
-    /**
107
-     * _get_table_filters
108
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
109
-     * get's shown in the table.
110
-     *
111
-     * @abstract
112
-     * @access protected
113
-     * @return array
114
-     */
115
-    protected function _get_table_filters()
116
-    {
117
-        $filters = array();
118
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
119
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
120
-            : date(
121
-                'm/d/Y',
122
-                strtotime('-10 year')
123
-            );
124
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
125
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
126
-            : date(
127
-                'm/d/Y',
128
-                current_time('timestamp')
129
-            );
130
-        ob_start();
131
-        ?>
17
+	/**
18
+	 * @var SessionLifespan $session_lifespan
19
+	 */
20
+	private $session_lifespan;
21
+
22
+	private $_status;
23
+
24
+
25
+	/**
26
+	 * @param \Transactions_Admin_Page $admin_page
27
+	 * @param SessionLifespan          $lifespan
28
+	 */
29
+	public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
30
+	{
31
+		parent::__construct($admin_page);
32
+		$this->session_lifespan = $lifespan;
33
+		$this->_status = $this->_admin_page->get_transaction_status_array();
34
+	}
35
+
36
+
37
+	/**
38
+	 *_setup_data
39
+	 */
40
+	protected function _setup_data()
41
+	{
42
+		$this->_data = $this->_admin_page->get_transactions($this->_per_page);
43
+		$status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
44
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
45
+	}
46
+
47
+
48
+	/**
49
+	 *_set_properties
50
+	 */
51
+	protected function _set_properties()
52
+	{
53
+		$this->_wp_list_args = array(
54
+			'singular' => esc_html__('transaction', 'event_espresso'),
55
+			'plural'   => esc_html__('transactions', 'event_espresso'),
56
+			'ajax'     => true,
57
+			'screen'   => $this->_admin_page->get_current_screen()->id,
58
+		);
59
+		$ID_column_name = esc_html__('ID', 'event_espresso');
60
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
61
+		$ID_column_name .= esc_html__('Transaction Date', 'event_espresso');
62
+		$ID_column_name .= '</span> ';
63
+		$this->_columns = array(
64
+			'TXN_ID'        => $ID_column_name,
65
+			'TXN_timestamp' => esc_html__('Transaction Date', 'event_espresso'),
66
+			'TXN_total'     => esc_html__('Total', 'event_espresso'),
67
+			'TXN_paid'      => esc_html__('Paid', 'event_espresso'),
68
+			'ATT_fname'     => esc_html__('Primary Registrant', 'event_espresso'),
69
+			'event_name'    => esc_html__('Event', 'event_espresso'),
70
+			'actions'       => esc_html__('Actions', 'event_espresso'),
71
+		);
72
+
73
+		$this->_sortable_columns = array(
74
+			'TXN_ID'        => array('TXN_ID' => false),
75
+			'event_name'    => array('event_name' => false),
76
+			'ATT_fname'     => array('ATT_fname' => false),
77
+			'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
78
+		);
79
+
80
+		$this->_primary_column = 'TXN_ID';
81
+
82
+		$this->_hidden_columns = array();
83
+	}
84
+
85
+
86
+	/**
87
+	 * This simply sets up the row class for the table rows.
88
+	 * Allows for easier overriding of child methods for setting up sorting.
89
+	 *
90
+	 * @param  EE_Transaction $transaction the current item
91
+	 * @return string
92
+	 * @throws \EE_Error
93
+	 */
94
+	protected function _get_row_class($transaction)
95
+	{
96
+		$class = parent::_get_row_class($transaction);
97
+		// add status class
98
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
99
+		if ($this->_has_checkbox_column) {
100
+			$class .= ' has-checkbox-column';
101
+		}
102
+		return $class;
103
+	}
104
+
105
+
106
+	/**
107
+	 * _get_table_filters
108
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
109
+	 * get's shown in the table.
110
+	 *
111
+	 * @abstract
112
+	 * @access protected
113
+	 * @return array
114
+	 */
115
+	protected function _get_table_filters()
116
+	{
117
+		$filters = array();
118
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
119
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
120
+			: date(
121
+				'm/d/Y',
122
+				strtotime('-10 year')
123
+			);
124
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
125
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
126
+			: date(
127
+				'm/d/Y',
128
+				current_time('timestamp')
129
+			);
130
+		ob_start();
131
+		?>
132 132
         <label for="txn-filter-start-date">Display Transactions from </label>
133 133
         <input class="datepicker"
134 134
                id="txn-filter-start-date"
@@ -146,585 +146,585 @@  discard block
 block discarded – undo
146 146
                value="<?php echo esc_html($end_date); ?>"
147 147
         />
148 148
         <?php
149
-        $filters[] = ob_get_contents();
150
-        ob_end_clean();
151
-        return $filters;
152
-    }
153
-
154
-
155
-    /**
156
-     *_add_view_counts
157
-     */
158
-    protected function _add_view_counts()
159
-    {
160
-        foreach ($this->_views as $view) {
161
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
162
-        }
163
-    }
164
-
165
-
166
-    /**
167
-     *    column TXN_ID
168
-     *
169
-     * @param \EE_Transaction $transaction
170
-     * @return string
171
-     * @throws \EE_Error
172
-     */
173
-    public function column_TXN_ID(EE_Transaction $transaction)
174
-    {
175
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
176
-            array(
177
-                'action' => 'view_transaction',
178
-                'TXN_ID' => $transaction->ID(),
179
-            ),
180
-            TXN_ADMIN_URL
181
-        );
182
-        $content = '<a href="' . $view_lnk_url . '"'
183
-                   . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
184
-                   . $transaction->ID()
185
-                   . '</a>';
186
-
187
-        // txn timestamp
188
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
189
-        return $content;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param \EE_Transaction $transaction
195
-     * @return string
196
-     * @throws EE_Error
197
-     * @throws InvalidArgumentException
198
-     * @throws InvalidDataTypeException
199
-     * @throws InvalidInterfaceException
200
-     */
201
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
202
-    {
203
-        // is TXN less than 2 hours old ?
204
-        if (
205
-            ($transaction->failed() || $transaction->is_abandoned())
206
-            && $this->session_lifespan->expiration() < $transaction->datetime(false, true)
207
-        ) {
208
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
209
-        } else {
210
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
211
-        }
212
-        return $timestamp;
213
-    }
214
-
215
-
216
-    /**
217
-     *    column_cb
218
-     *
219
-     * @param \EE_Transaction $transaction
220
-     * @return string
221
-     * @throws \EE_Error
222
-     */
223
-    public function column_cb($transaction)
224
-    {
225
-        return sprintf(
226
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
227
-            $this->_wp_list_args['singular'],
228
-            $transaction->ID()
229
-        );
230
-    }
231
-
232
-
233
-    /**
234
-     *    column_TXN_timestamp
235
-     *
236
-     * @param \EE_Transaction $transaction
237
-     * @return string
238
-     * @throws \EE_Error
239
-     */
240
-    public function column_TXN_timestamp(EE_Transaction $transaction)
241
-    {
242
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
-            array(
244
-                'action' => 'view_transaction',
245
-                'TXN_ID' => $transaction->ID(),
246
-            ),
247
-            TXN_ADMIN_URL
248
-        );
249
-        $txn_date = '<a href="' . $view_lnk_url . '"'
250
-                    . ' aria-label="'
251
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
252
-                    . $this->_get_txn_timestamp($transaction)
253
-                    . '</a>';
254
-        // status
255
-        $txn_date .= '<br><span class="ee-status-text-small">'
256
-                    . EEH_Template::pretty_status(
257
-                        $transaction->status_ID(),
258
-                        false,
259
-                        'sentence'
260
-                    )
261
-                     . '</span>';
262
-        return $txn_date;
263
-    }
264
-
265
-
266
-    /**
267
-     *    column_TXN_total
268
-     *
269
-     * @param \EE_Transaction $transaction
270
-     * @return string
271
-     * @throws \EE_Error
272
-     */
273
-    public function column_TXN_total(EE_Transaction $transaction)
274
-    {
275
-        if ($transaction->get('TXN_total') > 0) {
276
-            return '<span class="txn-pad-rght">'
277
-                   . apply_filters(
278
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
279
-                       $transaction->get_pretty('TXN_total'),
280
-                       $transaction
281
-                   )
282
-                   . '</span>';
283
-        } else {
284
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
285
-        }
286
-    }
287
-
288
-
289
-    /**
290
-     *    column_TXN_paid
291
-     *
292
-     * @param \EE_Transaction $transaction
293
-     * @return mixed|string
294
-     * @throws \EE_Error
295
-     */
296
-    public function column_TXN_paid(EE_Transaction $transaction)
297
-    {
298
-        $transaction_total = $transaction->get('TXN_total');
299
-        $transaction_paid = $transaction->get('TXN_paid');
300
-
301
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
302
-            // monies owing
303
-            $span_class = 'txn-overview-part-payment-spn';
304
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
305
-                // paid in full
306
-                $span_class = 'txn-overview-full-payment-spn';
307
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
308
-                // no payments made
309
-                $span_class = 'txn-overview-no-payment-spn';
310
-            }
311
-        } else {
312
-            // transaction_total == 0 so this is a free event
313
-            $span_class = 'txn-overview-free-event-spn';
314
-        }
315
-
316
-        $payment_method = $transaction->payment_method();
317
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
318
-            ? $payment_method->admin_name()
319
-            : esc_html__('Unknown', 'event_espresso');
320
-
321
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
322
-                   . $transaction->get_pretty('TXN_paid')
323
-                   . '</span>';
324
-        if ($transaction_paid > 0) {
325
-            $content .= '<br><span class="ee-status-text-small">'
326
-                        . sprintf(
327
-                            esc_html__('...via %s', 'event_espresso'),
328
-                            $payment_method_name
329
-                        )
330
-                        . '</span>';
331
-        }
332
-        return $content;
333
-    }
334
-
335
-
336
-    /**
337
-     *    column_ATT_fname
338
-     *
339
-     * @param \EE_Transaction $transaction
340
-     * @return string
341
-     * @throws EE_Error
342
-     * @throws InvalidArgumentException
343
-     * @throws InvalidDataTypeException
344
-     * @throws InvalidInterfaceException
345
-     */
346
-    public function column_ATT_fname(EE_Transaction $transaction)
347
-    {
348
-        $primary_reg = $transaction->primary_registration();
349
-        $attendee = $primary_reg->get_first_related('Attendee');
350
-        if ($attendee instanceof EE_Attendee) {
351
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
352
-                array(
353
-                    'action'  => 'view_registration',
354
-                    '_REG_ID' => $primary_reg->ID(),
355
-                ),
356
-                REG_ADMIN_URL
357
-            );
358
-            $content = EE_Registry::instance()->CAP->current_user_can(
359
-                'ee_read_registration',
360
-                'espresso_registrations_view_registration',
361
-                $primary_reg->ID()
362
-            )
363
-                ? '<a href="' . $edit_lnk_url . '"'
364
-                  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
365
-                  . $attendee->full_name()
366
-                  . '</a>'
367
-                : $attendee->full_name();
368
-            $content .= '<br>' . $attendee->email();
369
-            return $content;
370
-        }
371
-        return $transaction->failed() || $transaction->is_abandoned()
372
-            ? esc_html__('no contact record.', 'event_espresso')
373
-            : esc_html__(
374
-                'No contact record, because the transaction was abandoned or the registration process failed.',
375
-                'event_espresso'
376
-            );
377
-    }
378
-
379
-
380
-    /**
381
-     *    column_ATT_email
382
-     *
383
-     * @param \EE_Transaction $transaction
384
-     * @return string
385
-     * @throws \EE_Error
386
-     */
387
-    public function column_ATT_email(EE_Transaction $transaction)
388
-    {
389
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
390
-        if (! empty($attendee)) {
391
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
392
-                   . $attendee->get('ATT_email')
393
-                   . '</a>';
394
-        } else {
395
-            return $transaction->failed() || $transaction->is_abandoned()
396
-                ? esc_html__('no contact record.', 'event_espresso')
397
-                : esc_html__(
398
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
399
-                    'event_espresso'
400
-                );
401
-        }
402
-    }
403
-
404
-
405
-    /**
406
-     *    column_event_name
407
-     *
408
-     * @param \EE_Transaction $transaction
409
-     * @return string
410
-     * @throws EE_Error
411
-     * @throws InvalidArgumentException
412
-     * @throws InvalidDataTypeException
413
-     * @throws InvalidInterfaceException
414
-     */
415
-    public function column_event_name(EE_Transaction $transaction)
416
-    {
417
-        $actions = array();
418
-        $event = $transaction->primary_registration()->get_first_related('Event');
419
-        if (! empty($event)) {
420
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
421
-                array('action' => 'edit', 'post' => $event->ID()),
422
-                EVENTS_ADMIN_URL
423
-            );
424
-            $event_name = $event->get('EVT_name');
425
-
426
-            // filter this view by transactions for this event
427
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
428
-                array(
429
-                    'action' => 'default',
430
-                    'EVT_ID' => $event->ID(),
431
-                )
432
-            );
433
-            if (
434
-                empty($this->_req_data['EVT_ID'])
435
-                && EE_Registry::instance()->CAP->current_user_can(
436
-                    'ee_edit_event',
437
-                    'espresso_events_edit',
438
-                    $event->ID()
439
-                )
440
-            ) {
441
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
442
-                                              . ' aria-label="' . esc_attr__(
443
-                                                  'Filter transactions by this event',
444
-                                                  'event_espresso'
445
-                                              ) . '">'
446
-                                              . esc_html__('View Transactions for this event', 'event_espresso')
447
-                                              . '</a>';
448
-            }
449
-
450
-            return sprintf(
451
-                '%1$s %2$s',
452
-                EE_Registry::instance()->CAP->current_user_can(
453
-                    'ee_edit_event',
454
-                    'espresso_events_edit',
455
-                    $event->ID()
456
-                )
457
-                    ? '<a href="' . $edit_event_url . '"'
458
-                      . ' aria-label="'
459
-                      . sprintf(
460
-                          esc_attr__('Edit Event: %s', 'event_espresso'),
461
-                          $event->get('EVT_name')
462
-                      )
463
-                      . '">'
464
-                      . wp_trim_words(
465
-                          $event_name,
466
-                          30,
467
-                          '...'
468
-                      )
469
-                      . '</a>'
470
-                    : wp_trim_words($event_name, 30, '...'),
471
-                $this->row_actions($actions)
472
-            );
473
-        } else {
474
-            return esc_html__(
475
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
476
-                'event_espresso'
477
-            );
478
-        }
479
-    }
480
-
481
-
482
-    /**
483
-     *    column_actions
484
-     *
485
-     * @param \EE_Transaction $transaction
486
-     * @return string
487
-     * @throws \EE_Error
488
-     */
489
-    public function column_actions(EE_Transaction $transaction)
490
-    {
491
-        return $this->_action_string(
492
-            $this->get_transaction_details_link($transaction)
493
-            . $this->get_invoice_link($transaction)
494
-            . $this->get_receipt_link($transaction)
495
-            . $this->get_primary_registration_details_link($transaction)
496
-            . $this->get_send_payment_reminder_trigger_link($transaction)
497
-            . $this->get_payment_overview_link($transaction)
498
-            . $this->get_related_messages_link($transaction),
499
-            $transaction,
500
-            'ul',
501
-            'txn-overview-actions-ul'
502
-        );
503
-    }
504
-
505
-
506
-    /**
507
-     * Get the transaction details link.
508
-     *
509
-     * @param EE_Transaction $transaction
510
-     * @return string
511
-     * @throws EE_Error
512
-     */
513
-    protected function get_transaction_details_link(EE_Transaction $transaction)
514
-    {
515
-        $url = EE_Admin_Page::add_query_args_and_nonce(
516
-            array(
517
-                'action' => 'view_transaction',
518
-                'TXN_ID' => $transaction->ID(),
519
-            ),
520
-            TXN_ADMIN_URL
521
-        );
522
-        return '
149
+		$filters[] = ob_get_contents();
150
+		ob_end_clean();
151
+		return $filters;
152
+	}
153
+
154
+
155
+	/**
156
+	 *_add_view_counts
157
+	 */
158
+	protected function _add_view_counts()
159
+	{
160
+		foreach ($this->_views as $view) {
161
+			$this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
162
+		}
163
+	}
164
+
165
+
166
+	/**
167
+	 *    column TXN_ID
168
+	 *
169
+	 * @param \EE_Transaction $transaction
170
+	 * @return string
171
+	 * @throws \EE_Error
172
+	 */
173
+	public function column_TXN_ID(EE_Transaction $transaction)
174
+	{
175
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
176
+			array(
177
+				'action' => 'view_transaction',
178
+				'TXN_ID' => $transaction->ID(),
179
+			),
180
+			TXN_ADMIN_URL
181
+		);
182
+		$content = '<a href="' . $view_lnk_url . '"'
183
+				   . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
184
+				   . $transaction->ID()
185
+				   . '</a>';
186
+
187
+		// txn timestamp
188
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
189
+		return $content;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param \EE_Transaction $transaction
195
+	 * @return string
196
+	 * @throws EE_Error
197
+	 * @throws InvalidArgumentException
198
+	 * @throws InvalidDataTypeException
199
+	 * @throws InvalidInterfaceException
200
+	 */
201
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
202
+	{
203
+		// is TXN less than 2 hours old ?
204
+		if (
205
+			($transaction->failed() || $transaction->is_abandoned())
206
+			&& $this->session_lifespan->expiration() < $transaction->datetime(false, true)
207
+		) {
208
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
209
+		} else {
210
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
211
+		}
212
+		return $timestamp;
213
+	}
214
+
215
+
216
+	/**
217
+	 *    column_cb
218
+	 *
219
+	 * @param \EE_Transaction $transaction
220
+	 * @return string
221
+	 * @throws \EE_Error
222
+	 */
223
+	public function column_cb($transaction)
224
+	{
225
+		return sprintf(
226
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
227
+			$this->_wp_list_args['singular'],
228
+			$transaction->ID()
229
+		);
230
+	}
231
+
232
+
233
+	/**
234
+	 *    column_TXN_timestamp
235
+	 *
236
+	 * @param \EE_Transaction $transaction
237
+	 * @return string
238
+	 * @throws \EE_Error
239
+	 */
240
+	public function column_TXN_timestamp(EE_Transaction $transaction)
241
+	{
242
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
+			array(
244
+				'action' => 'view_transaction',
245
+				'TXN_ID' => $transaction->ID(),
246
+			),
247
+			TXN_ADMIN_URL
248
+		);
249
+		$txn_date = '<a href="' . $view_lnk_url . '"'
250
+					. ' aria-label="'
251
+					. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
252
+					. $this->_get_txn_timestamp($transaction)
253
+					. '</a>';
254
+		// status
255
+		$txn_date .= '<br><span class="ee-status-text-small">'
256
+					. EEH_Template::pretty_status(
257
+						$transaction->status_ID(),
258
+						false,
259
+						'sentence'
260
+					)
261
+					 . '</span>';
262
+		return $txn_date;
263
+	}
264
+
265
+
266
+	/**
267
+	 *    column_TXN_total
268
+	 *
269
+	 * @param \EE_Transaction $transaction
270
+	 * @return string
271
+	 * @throws \EE_Error
272
+	 */
273
+	public function column_TXN_total(EE_Transaction $transaction)
274
+	{
275
+		if ($transaction->get('TXN_total') > 0) {
276
+			return '<span class="txn-pad-rght">'
277
+				   . apply_filters(
278
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
279
+					   $transaction->get_pretty('TXN_total'),
280
+					   $transaction
281
+				   )
282
+				   . '</span>';
283
+		} else {
284
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
285
+		}
286
+	}
287
+
288
+
289
+	/**
290
+	 *    column_TXN_paid
291
+	 *
292
+	 * @param \EE_Transaction $transaction
293
+	 * @return mixed|string
294
+	 * @throws \EE_Error
295
+	 */
296
+	public function column_TXN_paid(EE_Transaction $transaction)
297
+	{
298
+		$transaction_total = $transaction->get('TXN_total');
299
+		$transaction_paid = $transaction->get('TXN_paid');
300
+
301
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
302
+			// monies owing
303
+			$span_class = 'txn-overview-part-payment-spn';
304
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
305
+				// paid in full
306
+				$span_class = 'txn-overview-full-payment-spn';
307
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
308
+				// no payments made
309
+				$span_class = 'txn-overview-no-payment-spn';
310
+			}
311
+		} else {
312
+			// transaction_total == 0 so this is a free event
313
+			$span_class = 'txn-overview-free-event-spn';
314
+		}
315
+
316
+		$payment_method = $transaction->payment_method();
317
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
318
+			? $payment_method->admin_name()
319
+			: esc_html__('Unknown', 'event_espresso');
320
+
321
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
322
+				   . $transaction->get_pretty('TXN_paid')
323
+				   . '</span>';
324
+		if ($transaction_paid > 0) {
325
+			$content .= '<br><span class="ee-status-text-small">'
326
+						. sprintf(
327
+							esc_html__('...via %s', 'event_espresso'),
328
+							$payment_method_name
329
+						)
330
+						. '</span>';
331
+		}
332
+		return $content;
333
+	}
334
+
335
+
336
+	/**
337
+	 *    column_ATT_fname
338
+	 *
339
+	 * @param \EE_Transaction $transaction
340
+	 * @return string
341
+	 * @throws EE_Error
342
+	 * @throws InvalidArgumentException
343
+	 * @throws InvalidDataTypeException
344
+	 * @throws InvalidInterfaceException
345
+	 */
346
+	public function column_ATT_fname(EE_Transaction $transaction)
347
+	{
348
+		$primary_reg = $transaction->primary_registration();
349
+		$attendee = $primary_reg->get_first_related('Attendee');
350
+		if ($attendee instanceof EE_Attendee) {
351
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
352
+				array(
353
+					'action'  => 'view_registration',
354
+					'_REG_ID' => $primary_reg->ID(),
355
+				),
356
+				REG_ADMIN_URL
357
+			);
358
+			$content = EE_Registry::instance()->CAP->current_user_can(
359
+				'ee_read_registration',
360
+				'espresso_registrations_view_registration',
361
+				$primary_reg->ID()
362
+			)
363
+				? '<a href="' . $edit_lnk_url . '"'
364
+				  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
365
+				  . $attendee->full_name()
366
+				  . '</a>'
367
+				: $attendee->full_name();
368
+			$content .= '<br>' . $attendee->email();
369
+			return $content;
370
+		}
371
+		return $transaction->failed() || $transaction->is_abandoned()
372
+			? esc_html__('no contact record.', 'event_espresso')
373
+			: esc_html__(
374
+				'No contact record, because the transaction was abandoned or the registration process failed.',
375
+				'event_espresso'
376
+			);
377
+	}
378
+
379
+
380
+	/**
381
+	 *    column_ATT_email
382
+	 *
383
+	 * @param \EE_Transaction $transaction
384
+	 * @return string
385
+	 * @throws \EE_Error
386
+	 */
387
+	public function column_ATT_email(EE_Transaction $transaction)
388
+	{
389
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
390
+		if (! empty($attendee)) {
391
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
392
+				   . $attendee->get('ATT_email')
393
+				   . '</a>';
394
+		} else {
395
+			return $transaction->failed() || $transaction->is_abandoned()
396
+				? esc_html__('no contact record.', 'event_espresso')
397
+				: esc_html__(
398
+					'No contact record, because the transaction was abandoned or the registration process failed.',
399
+					'event_espresso'
400
+				);
401
+		}
402
+	}
403
+
404
+
405
+	/**
406
+	 *    column_event_name
407
+	 *
408
+	 * @param \EE_Transaction $transaction
409
+	 * @return string
410
+	 * @throws EE_Error
411
+	 * @throws InvalidArgumentException
412
+	 * @throws InvalidDataTypeException
413
+	 * @throws InvalidInterfaceException
414
+	 */
415
+	public function column_event_name(EE_Transaction $transaction)
416
+	{
417
+		$actions = array();
418
+		$event = $transaction->primary_registration()->get_first_related('Event');
419
+		if (! empty($event)) {
420
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
421
+				array('action' => 'edit', 'post' => $event->ID()),
422
+				EVENTS_ADMIN_URL
423
+			);
424
+			$event_name = $event->get('EVT_name');
425
+
426
+			// filter this view by transactions for this event
427
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
428
+				array(
429
+					'action' => 'default',
430
+					'EVT_ID' => $event->ID(),
431
+				)
432
+			);
433
+			if (
434
+				empty($this->_req_data['EVT_ID'])
435
+				&& EE_Registry::instance()->CAP->current_user_can(
436
+					'ee_edit_event',
437
+					'espresso_events_edit',
438
+					$event->ID()
439
+				)
440
+			) {
441
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
442
+											  . ' aria-label="' . esc_attr__(
443
+												  'Filter transactions by this event',
444
+												  'event_espresso'
445
+											  ) . '">'
446
+											  . esc_html__('View Transactions for this event', 'event_espresso')
447
+											  . '</a>';
448
+			}
449
+
450
+			return sprintf(
451
+				'%1$s %2$s',
452
+				EE_Registry::instance()->CAP->current_user_can(
453
+					'ee_edit_event',
454
+					'espresso_events_edit',
455
+					$event->ID()
456
+				)
457
+					? '<a href="' . $edit_event_url . '"'
458
+					  . ' aria-label="'
459
+					  . sprintf(
460
+						  esc_attr__('Edit Event: %s', 'event_espresso'),
461
+						  $event->get('EVT_name')
462
+					  )
463
+					  . '">'
464
+					  . wp_trim_words(
465
+						  $event_name,
466
+						  30,
467
+						  '...'
468
+					  )
469
+					  . '</a>'
470
+					: wp_trim_words($event_name, 30, '...'),
471
+				$this->row_actions($actions)
472
+			);
473
+		} else {
474
+			return esc_html__(
475
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
476
+				'event_espresso'
477
+			);
478
+		}
479
+	}
480
+
481
+
482
+	/**
483
+	 *    column_actions
484
+	 *
485
+	 * @param \EE_Transaction $transaction
486
+	 * @return string
487
+	 * @throws \EE_Error
488
+	 */
489
+	public function column_actions(EE_Transaction $transaction)
490
+	{
491
+		return $this->_action_string(
492
+			$this->get_transaction_details_link($transaction)
493
+			. $this->get_invoice_link($transaction)
494
+			. $this->get_receipt_link($transaction)
495
+			. $this->get_primary_registration_details_link($transaction)
496
+			. $this->get_send_payment_reminder_trigger_link($transaction)
497
+			. $this->get_payment_overview_link($transaction)
498
+			. $this->get_related_messages_link($transaction),
499
+			$transaction,
500
+			'ul',
501
+			'txn-overview-actions-ul'
502
+		);
503
+	}
504
+
505
+
506
+	/**
507
+	 * Get the transaction details link.
508
+	 *
509
+	 * @param EE_Transaction $transaction
510
+	 * @return string
511
+	 * @throws EE_Error
512
+	 */
513
+	protected function get_transaction_details_link(EE_Transaction $transaction)
514
+	{
515
+		$url = EE_Admin_Page::add_query_args_and_nonce(
516
+			array(
517
+				'action' => 'view_transaction',
518
+				'TXN_ID' => $transaction->ID(),
519
+			),
520
+			TXN_ADMIN_URL
521
+		);
522
+		return '
523 523
 			<li>
524 524
 				<a href="' . $url . '"'
525
-               . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
525
+			   . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
526 526
 					<span class="dashicons dashicons-cart"></span>
527 527
 				</a>
528 528
 			</li>';
529
-    }
530
-
531
-
532
-    /**
533
-     * Get the invoice link for the given registration.
534
-     *
535
-     * @param EE_Transaction $transaction
536
-     * @return string
537
-     * @throws EE_Error
538
-     */
539
-    protected function get_invoice_link(EE_Transaction $transaction)
540
-    {
541
-        $registration = $transaction->primary_registration();
542
-        if ($registration instanceof EE_Registration) {
543
-            $url = $registration->invoice_url();
544
-            // only show invoice link if message type is active.
545
-            if (
546
-                $registration->attendee() instanceof EE_Attendee
547
-                && EEH_MSG_Template::is_mt_active('invoice')
548
-            ) {
549
-                return '
529
+	}
530
+
531
+
532
+	/**
533
+	 * Get the invoice link for the given registration.
534
+	 *
535
+	 * @param EE_Transaction $transaction
536
+	 * @return string
537
+	 * @throws EE_Error
538
+	 */
539
+	protected function get_invoice_link(EE_Transaction $transaction)
540
+	{
541
+		$registration = $transaction->primary_registration();
542
+		if ($registration instanceof EE_Registration) {
543
+			$url = $registration->invoice_url();
544
+			// only show invoice link if message type is active.
545
+			if (
546
+				$registration->attendee() instanceof EE_Attendee
547
+				&& EEH_MSG_Template::is_mt_active('invoice')
548
+			) {
549
+				return '
550 550
                 <li>
551 551
                     <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
552
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
552
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
553 553
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
554 554
                     </a>
555 555
                 </li>';
556
-            }
557
-        }
558
-        return '';
559
-    }
560
-
561
-
562
-    /**
563
-     * Get the receipt link for the transaction.
564
-     *
565
-     * @param EE_Transaction $transaction
566
-     * @return string
567
-     * @throws EE_Error
568
-     */
569
-    protected function get_receipt_link(EE_Transaction $transaction)
570
-    {
571
-        $registration = $transaction->primary_registration();
572
-        if ($registration instanceof EE_Registration) {
573
-            $url = $registration->receipt_url();
574
-            // only show receipt link if message type is active.
575
-            if (
576
-                $registration->attendee() instanceof EE_Attendee
577
-                && EEH_MSG_Template::is_mt_active('receipt')
578
-            ) {
579
-                return '
556
+			}
557
+		}
558
+		return '';
559
+	}
560
+
561
+
562
+	/**
563
+	 * Get the receipt link for the transaction.
564
+	 *
565
+	 * @param EE_Transaction $transaction
566
+	 * @return string
567
+	 * @throws EE_Error
568
+	 */
569
+	protected function get_receipt_link(EE_Transaction $transaction)
570
+	{
571
+		$registration = $transaction->primary_registration();
572
+		if ($registration instanceof EE_Registration) {
573
+			$url = $registration->receipt_url();
574
+			// only show receipt link if message type is active.
575
+			if (
576
+				$registration->attendee() instanceof EE_Attendee
577
+				&& EEH_MSG_Template::is_mt_active('receipt')
578
+			) {
579
+				return '
580 580
 			<li>
581 581
 				<a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
582
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
582
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
583 583
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
584 584
 				</a>
585 585
 			</li>';
586
-            }
587
-        }
588
-        return '';
589
-    }
590
-
591
-
592
-    /**
593
-     * Get the link to view the details for the primary registration.
594
-     *
595
-     * @param EE_Transaction $transaction
596
-     * @return string
597
-     * @throws EE_Error
598
-     * @throws InvalidArgumentException
599
-     * @throws InvalidDataTypeException
600
-     * @throws InvalidInterfaceException
601
-     */
602
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
603
-    {
604
-        $registration = $transaction->primary_registration();
605
-        if ($registration instanceof EE_Registration) {
606
-            $url = EE_Admin_Page::add_query_args_and_nonce(
607
-                array(
608
-                    'action'  => 'view_registration',
609
-                    '_REG_ID' => $registration->ID(),
610
-                ),
611
-                REG_ADMIN_URL
612
-            );
613
-            return EE_Registry::instance()->CAP->current_user_can(
614
-                'ee_read_registration',
615
-                'espresso_registrations_view_registration',
616
-                $registration->ID()
617
-            )
618
-                ? '
586
+			}
587
+		}
588
+		return '';
589
+	}
590
+
591
+
592
+	/**
593
+	 * Get the link to view the details for the primary registration.
594
+	 *
595
+	 * @param EE_Transaction $transaction
596
+	 * @return string
597
+	 * @throws EE_Error
598
+	 * @throws InvalidArgumentException
599
+	 * @throws InvalidDataTypeException
600
+	 * @throws InvalidInterfaceException
601
+	 */
602
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
603
+	{
604
+		$registration = $transaction->primary_registration();
605
+		if ($registration instanceof EE_Registration) {
606
+			$url = EE_Admin_Page::add_query_args_and_nonce(
607
+				array(
608
+					'action'  => 'view_registration',
609
+					'_REG_ID' => $registration->ID(),
610
+				),
611
+				REG_ADMIN_URL
612
+			);
613
+			return EE_Registry::instance()->CAP->current_user_can(
614
+				'ee_read_registration',
615
+				'espresso_registrations_view_registration',
616
+				$registration->ID()
617
+			)
618
+				? '
619 619
 				<li>
620 620
 					<a href="' . $url . '"'
621
-                  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
621
+				  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
622 622
 						<span class="dashicons dashicons-clipboard"></span>
623 623
 					</a>
624 624
 				</li>'
625
-                : '';
626
-        }
627
-        return '';
628
-    }
629
-
630
-
631
-    /**
632
-     * Get send payment reminder trigger link
633
-     *
634
-     * @param EE_Transaction $transaction
635
-     * @return string
636
-     * @throws EE_Error
637
-     * @throws InvalidArgumentException
638
-     * @throws InvalidDataTypeException
639
-     * @throws InvalidInterfaceException
640
-     */
641
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
642
-    {
643
-        $registration = $transaction->primary_registration();
644
-        if (
645
-            $registration instanceof EE_Registration
646
-            && $registration->attendee() instanceof EE_Attendee
647
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
648
-            && ! in_array(
649
-                $transaction->status_ID(),
650
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
651
-                true
652
-            )
653
-            && EE_Registry::instance()->CAP->current_user_can(
654
-                'ee_send_message',
655
-                'espresso_transactions_send_payment_reminder'
656
-            )
657
-        ) {
658
-            $url = EE_Admin_Page::add_query_args_and_nonce(
659
-                array(
660
-                    'action' => 'send_payment_reminder',
661
-                    'TXN_ID' => $transaction->ID(),
662
-                ),
663
-                TXN_ADMIN_URL
664
-            );
665
-            return '
625
+				: '';
626
+		}
627
+		return '';
628
+	}
629
+
630
+
631
+	/**
632
+	 * Get send payment reminder trigger link
633
+	 *
634
+	 * @param EE_Transaction $transaction
635
+	 * @return string
636
+	 * @throws EE_Error
637
+	 * @throws InvalidArgumentException
638
+	 * @throws InvalidDataTypeException
639
+	 * @throws InvalidInterfaceException
640
+	 */
641
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
642
+	{
643
+		$registration = $transaction->primary_registration();
644
+		if (
645
+			$registration instanceof EE_Registration
646
+			&& $registration->attendee() instanceof EE_Attendee
647
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
648
+			&& ! in_array(
649
+				$transaction->status_ID(),
650
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
651
+				true
652
+			)
653
+			&& EE_Registry::instance()->CAP->current_user_can(
654
+				'ee_send_message',
655
+				'espresso_transactions_send_payment_reminder'
656
+			)
657
+		) {
658
+			$url = EE_Admin_Page::add_query_args_and_nonce(
659
+				array(
660
+					'action' => 'send_payment_reminder',
661
+					'TXN_ID' => $transaction->ID(),
662
+				),
663
+				TXN_ADMIN_URL
664
+			);
665
+			return '
666 666
             <li>
667 667
                 <a href="' . $url . '"'
668
-                   . ' aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
668
+				   . ' aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
669 669
                     <span class="dashicons dashicons-email-alt"></span>
670 670
                 </a>
671 671
             </li>';
672
-        }
673
-        return '';
674
-    }
675
-
676
-
677
-    /**
678
-     * Get link to filtered view in the message activity list table of messages for this transaction.
679
-     *
680
-     * @param EE_Transaction $transaction
681
-     * @return string
682
-     * @throws EE_Error
683
-     * @throws InvalidArgumentException
684
-     * @throws InvalidDataTypeException
685
-     * @throws InvalidInterfaceException
686
-     */
687
-    protected function get_related_messages_link(EE_Transaction $transaction)
688
-    {
689
-        $url = EEH_MSG_Template::get_message_action_link(
690
-            'see_notifications_for',
691
-            null,
692
-            array('TXN_ID' => $transaction->ID())
693
-        );
694
-        return EE_Registry::instance()->CAP->current_user_can(
695
-            'ee_read_global_messages',
696
-            'view_filtered_messages'
697
-        )
698
-            ? '<li>' . $url . '</li>'
699
-            : '';
700
-    }
701
-
702
-
703
-    /**
704
-     * Return the link to make a payment on the frontend
705
-     *
706
-     * @param EE_Transaction $transaction
707
-     * @return string
708
-     * @throws EE_Error
709
-     */
710
-    protected function get_payment_overview_link(EE_Transaction $transaction)
711
-    {
712
-        $registration = $transaction->primary_registration();
713
-        if (
714
-            $registration instanceof EE_Registration
715
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
716
-            && $registration->owes_monies_and_can_pay()
717
-        ) {
718
-            return '
672
+		}
673
+		return '';
674
+	}
675
+
676
+
677
+	/**
678
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
679
+	 *
680
+	 * @param EE_Transaction $transaction
681
+	 * @return string
682
+	 * @throws EE_Error
683
+	 * @throws InvalidArgumentException
684
+	 * @throws InvalidDataTypeException
685
+	 * @throws InvalidInterfaceException
686
+	 */
687
+	protected function get_related_messages_link(EE_Transaction $transaction)
688
+	{
689
+		$url = EEH_MSG_Template::get_message_action_link(
690
+			'see_notifications_for',
691
+			null,
692
+			array('TXN_ID' => $transaction->ID())
693
+		);
694
+		return EE_Registry::instance()->CAP->current_user_can(
695
+			'ee_read_global_messages',
696
+			'view_filtered_messages'
697
+		)
698
+			? '<li>' . $url . '</li>'
699
+			: '';
700
+	}
701
+
702
+
703
+	/**
704
+	 * Return the link to make a payment on the frontend
705
+	 *
706
+	 * @param EE_Transaction $transaction
707
+	 * @return string
708
+	 * @throws EE_Error
709
+	 */
710
+	protected function get_payment_overview_link(EE_Transaction $transaction)
711
+	{
712
+		$registration = $transaction->primary_registration();
713
+		if (
714
+			$registration instanceof EE_Registration
715
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
716
+			&& $registration->owes_monies_and_can_pay()
717
+		) {
718
+			return '
719 719
             <li>
720 720
                 <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
721
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
722
-                   . ' class="tiny-text">
721
+				   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
722
+				   . ' class="tiny-text">
723 723
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
724 724
                 </a>
725 725
             </li>
726 726
             ';
727
-        }
728
-        return '';
729
-    }
727
+		}
728
+		return '';
729
+	}
730 730
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         $class = parent::_get_row_class($transaction);
97 97
         // add status class
98
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
98
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
99 99
         if ($this->_has_checkbox_column) {
100 100
             $class .= ' has-checkbox-column';
101 101
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     protected function _add_view_counts()
159 159
     {
160 160
         foreach ($this->_views as $view) {
161
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
161
+            $this->_views[$view['slug']]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
162 162
         }
163 163
     }
164 164
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
             ),
180 180
             TXN_ADMIN_URL
181 181
         );
182
-        $content = '<a href="' . $view_lnk_url . '"'
183
-                   . ' aria-label="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
182
+        $content = '<a href="'.$view_lnk_url.'"'
183
+                   . ' aria-label="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
184 184
                    . $transaction->ID()
185 185
                    . '</a>';
186 186
 
187 187
         // txn timestamp
188
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
188
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
189 189
         return $content;
190 190
     }
191 191
 
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
             ),
247 247
             TXN_ADMIN_URL
248 248
         );
249
-        $txn_date = '<a href="' . $view_lnk_url . '"'
249
+        $txn_date = '<a href="'.$view_lnk_url.'"'
250 250
                     . ' aria-label="'
251
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
251
+                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
252 252
                     . $this->_get_txn_timestamp($transaction)
253 253
                     . '</a>';
254 254
         // status
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                    )
282 282
                    . '</span>';
283 283
         } else {
284
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
284
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
285 285
         }
286 286
     }
287 287
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             ? $payment_method->admin_name()
319 319
             : esc_html__('Unknown', 'event_espresso');
320 320
 
321
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
321
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
322 322
                    . $transaction->get_pretty('TXN_paid')
323 323
                    . '</span>';
324 324
         if ($transaction_paid > 0) {
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
                 'espresso_registrations_view_registration',
361 361
                 $primary_reg->ID()
362 362
             )
363
-                ? '<a href="' . $edit_lnk_url . '"'
364
-                  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
363
+                ? '<a href="'.$edit_lnk_url.'"'
364
+                  . ' aria-label="'.esc_attr__('View Registration Details', 'event_espresso').'">'
365 365
                   . $attendee->full_name()
366 366
                   . '</a>'
367 367
                 : $attendee->full_name();
368
-            $content .= '<br>' . $attendee->email();
368
+            $content .= '<br>'.$attendee->email();
369 369
             return $content;
370 370
         }
371 371
         return $transaction->failed() || $transaction->is_abandoned()
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
     public function column_ATT_email(EE_Transaction $transaction)
388 388
     {
389 389
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
390
-        if (! empty($attendee)) {
391
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
390
+        if ( ! empty($attendee)) {
391
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
392 392
                    . $attendee->get('ATT_email')
393 393
                    . '</a>';
394 394
         } else {
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     {
417 417
         $actions = array();
418 418
         $event = $transaction->primary_registration()->get_first_related('Event');
419
-        if (! empty($event)) {
419
+        if ( ! empty($event)) {
420 420
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
421 421
                 array('action' => 'edit', 'post' => $event->ID()),
422 422
                 EVENTS_ADMIN_URL
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
                     $event->ID()
439 439
                 )
440 440
             ) {
441
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
442
-                                              . ' aria-label="' . esc_attr__(
441
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
442
+                                              . ' aria-label="'.esc_attr__(
443 443
                                                   'Filter transactions by this event',
444 444
                                                   'event_espresso'
445
-                                              ) . '">'
445
+                                              ).'">'
446 446
                                               . esc_html__('View Transactions for this event', 'event_espresso')
447 447
                                               . '</a>';
448 448
             }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                     'espresso_events_edit',
455 455
                     $event->ID()
456 456
                 )
457
-                    ? '<a href="' . $edit_event_url . '"'
457
+                    ? '<a href="'.$edit_event_url.'"'
458 458
                       . ' aria-label="'
459 459
                       . sprintf(
460 460
                           esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
         );
522 522
         return '
523 523
 			<li>
524
-				<a href="' . $url . '"'
525
-               . ' aria-label="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
524
+				<a href="' . $url.'"'
525
+               . ' aria-label="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
526 526
 					<span class="dashicons dashicons-cart"></span>
527 527
 				</a>
528 528
 			</li>';
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
             ) {
549 549
                 return '
550 550
                 <li>
551
-                    <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
552
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
551
+                    <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
552
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
553 553
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
554 554
                     </a>
555 555
                 </li>';
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
             ) {
579 579
                 return '
580 580
 			<li>
581
-				<a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
582
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
581
+				<a aria-label="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
582
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
583 583
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
584 584
 				</a>
585 585
 			</li>';
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
             )
618 618
                 ? '
619 619
 				<li>
620
-					<a href="' . $url . '"'
621
-                  . ' aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
620
+					<a href="' . $url.'"'
621
+                  . ' aria-label="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
622 622
 						<span class="dashicons dashicons-clipboard"></span>
623 623
 					</a>
624 624
 				</li>'
@@ -664,8 +664,8 @@  discard block
 block discarded – undo
664 664
             );
665 665
             return '
666 666
             <li>
667
-                <a href="' . $url . '"'
668
-                   . ' aria-label="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
667
+                <a href="' . $url.'"'
668
+                   . ' aria-label="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
669 669
                     <span class="dashicons dashicons-email-alt"></span>
670 670
                 </a>
671 671
             </li>';
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
             'ee_read_global_messages',
696 696
             'view_filtered_messages'
697 697
         )
698
-            ? '<li>' . $url . '</li>'
698
+            ? '<li>'.$url.'</li>'
699 699
             : '';
700 700
     }
701 701
 
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
         ) {
718 718
             return '
719 719
             <li>
720
-                <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
721
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
720
+                <a aria-label="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
721
+                   . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
722 722
                    . ' class="tiny-text">
723 723
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
724 724
                 </a>
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks.class.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -15,95 +15,95 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class espresso_events_Registration_Form_Hooks extends EE_Admin_Hooks
17 17
 {
18
-    /**
19
-     * @var EE_Event|null
20
-     */
21
-    protected $_event;
22
-
23
-
24
-    protected function _set_hooks_properties()
25
-    {
26
-
27
-        $this->_name      = 'registration_form';
28
-        $this->_metaboxes = [
29
-            0 => [
30
-                'page_route' => ['edit', 'create_new'],
31
-                'func'       => 'primary_questions',
32
-                'label'      => esc_html__('Questions for Primary Registrant', 'event_espresso'),
33
-                'priority'   => 'default',
34
-                'context'    => 'side',
35
-            ],
36
-        ];
37
-
38
-        // hook into the handler for saving question groups
39
-        add_filter(
40
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
41
-            [$this, 'modify_callbacks'],
42
-            10
43
-        );
44
-
45
-        // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already
46
-        // restricted by page)
47
-        add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2);
48
-    }
49
-
50
-
51
-    /**
52
-     * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook
53
-     *
54
-     * @param $callbacks
55
-     * @return array
56
-     */
57
-    public function modify_callbacks($callbacks)
58
-    {
59
-        // now let's add the question group callback
60
-        $callbacks[] = [$this, 'primary_question_group_update'];
61
-        return $callbacks;
62
-    }
63
-
64
-
65
-    /**
66
-     * Hooked into revision restores.
67
-     *
68
-     * @param $post_id
69
-     * @param $revision_id
70
-     * @return EE_Base_Class
71
-     * @throws EE_Error
72
-     * @throws InvalidArgumentException
73
-     * @throws InvalidDataTypeException
74
-     * @throws InvalidInterfaceException
75
-     */
76
-    public function restore_revision($post_id, $revision_id)
77
-    {
78
-        $post_evt = EEM_Event::instance()->get_one_by_ID($post_id);
79
-        // restore revision for primary questions
80
-        if ($post_evt instanceof EE_Event) {
81
-            $post_evt->restore_revision(
82
-                $revision_id,
83
-                ['Question_Group'],
84
-                ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]]
85
-            );
86
-        }
87
-        return $post_evt;
88
-    }
89
-
90
-
91
-    /**
92
-     * Content of metabox.
93
-     *
94
-     * @param $post_id
95
-     * @param $post
96
-     * @throws EE_Error
97
-     * @throws InvalidArgumentException
98
-     * @throws InvalidDataTypeException
99
-     * @throws InvalidInterfaceException
100
-     * @throws ReflectionException
101
-     */
102
-    public function primary_questions($post_id, $post)
103
-    {
104
-        $this->_event = $this->_adminpage_obj->get_event_object();
105
-        $event_id     = $this->_event->ID();
106
-        ?>
18
+	/**
19
+	 * @var EE_Event|null
20
+	 */
21
+	protected $_event;
22
+
23
+
24
+	protected function _set_hooks_properties()
25
+	{
26
+
27
+		$this->_name      = 'registration_form';
28
+		$this->_metaboxes = [
29
+			0 => [
30
+				'page_route' => ['edit', 'create_new'],
31
+				'func'       => 'primary_questions',
32
+				'label'      => esc_html__('Questions for Primary Registrant', 'event_espresso'),
33
+				'priority'   => 'default',
34
+				'context'    => 'side',
35
+			],
36
+		];
37
+
38
+		// hook into the handler for saving question groups
39
+		add_filter(
40
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
41
+			[$this, 'modify_callbacks'],
42
+			10
43
+		);
44
+
45
+		// hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already
46
+		// restricted by page)
47
+		add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2);
48
+	}
49
+
50
+
51
+	/**
52
+	 * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook
53
+	 *
54
+	 * @param $callbacks
55
+	 * @return array
56
+	 */
57
+	public function modify_callbacks($callbacks)
58
+	{
59
+		// now let's add the question group callback
60
+		$callbacks[] = [$this, 'primary_question_group_update'];
61
+		return $callbacks;
62
+	}
63
+
64
+
65
+	/**
66
+	 * Hooked into revision restores.
67
+	 *
68
+	 * @param $post_id
69
+	 * @param $revision_id
70
+	 * @return EE_Base_Class
71
+	 * @throws EE_Error
72
+	 * @throws InvalidArgumentException
73
+	 * @throws InvalidDataTypeException
74
+	 * @throws InvalidInterfaceException
75
+	 */
76
+	public function restore_revision($post_id, $revision_id)
77
+	{
78
+		$post_evt = EEM_Event::instance()->get_one_by_ID($post_id);
79
+		// restore revision for primary questions
80
+		if ($post_evt instanceof EE_Event) {
81
+			$post_evt->restore_revision(
82
+				$revision_id,
83
+				['Question_Group'],
84
+				['Question_Group' => ['Event_Question_Group.EQG_primary' => true]]
85
+			);
86
+		}
87
+		return $post_evt;
88
+	}
89
+
90
+
91
+	/**
92
+	 * Content of metabox.
93
+	 *
94
+	 * @param $post_id
95
+	 * @param $post
96
+	 * @throws EE_Error
97
+	 * @throws InvalidArgumentException
98
+	 * @throws InvalidDataTypeException
99
+	 * @throws InvalidInterfaceException
100
+	 * @throws ReflectionException
101
+	 */
102
+	public function primary_questions($post_id, $post)
103
+	{
104
+		$this->_event = $this->_adminpage_obj->get_event_object();
105
+		$event_id     = $this->_event->ID();
106
+		?>
107 107
         <div class="inside">
108 108
             <p>
109 109
                 <strong>
@@ -111,64 +111,64 @@  discard block
 block discarded – undo
111 111
                 </strong>
112 112
                 <br />
113 113
                 <?php
114
-                printf(
115
-                    esc_html__(
116
-                        'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events',
117
-                        'event_espresso'
118
-                    ),
119
-                    '<a href="admin.php?page=espresso_registration_form" target="_blank">',
120
-                    '</a>'
121
-                )
122
-                ?>
114
+				printf(
115
+					esc_html__(
116
+						'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events',
117
+						'event_espresso'
118
+					),
119
+					'<a href="admin.php?page=espresso_registration_form" target="_blank">',
120
+					'</a>'
121
+				)
122
+				?>
123 123
             </p>
124 124
             <?php
125 125
 
126
-            $qsg_where['QSG_deleted'] = false;
127
-            $query_params             = apply_filters(
128
-                'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters',
129
-                [$qsg_where, 'order_by' => ['QSG_order' => 'ASC']]
130
-            );
131
-            $QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
132
-            $EQGs                     = ! empty($event_id)
133
-                ? $this->_event->get_many_related(
134
-                    'Question_Group',
135
-                    [['Event_Question_Group.EQG_primary' => true]]
136
-                )
137
-                : [];
138
-            $EQGids                   = array_keys($EQGs);
139
-
140
-            if (! empty($QSGs)) {
141
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
142
-                foreach ($QSGs as $QSG) {
143
-                    $QSG_ID          = absint($QSG->ID());
144
-                    $checked         = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1
145
-                        ? ' checked'
146
-                        : '';
147
-                    $visibility      = $QSG->get('QSG_system') === 1
148
-                        ? ' style="visibility:hidden"'
149
-                        : '';
150
-                    $edit_query_args = $this->_adminpage_obj->is_caf()
151
-                        ? [
152
-                            'action' => 'edit_question_group',
153
-                            'QSG_ID' => $QSG_ID,
154
-                        ]
155
-                        : ['action' => 'question_groups'];
156
-                    $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
157
-                        $edit_query_args,
158
-                        EE_FORMS_ADMIN_URL
159
-                    );
160
-                    $edit_link_title = sprintf(
161
-                        esc_attr__('Edit %s Group', 'event_espresso'),
162
-                        $QSG->get('QSG_name')
163
-                    );
164
-
165
-                    $html .= '
126
+			$qsg_where['QSG_deleted'] = false;
127
+			$query_params             = apply_filters(
128
+				'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters',
129
+				[$qsg_where, 'order_by' => ['QSG_order' => 'ASC']]
130
+			);
131
+			$QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
132
+			$EQGs                     = ! empty($event_id)
133
+				? $this->_event->get_many_related(
134
+					'Question_Group',
135
+					[['Event_Question_Group.EQG_primary' => true]]
136
+				)
137
+				: [];
138
+			$EQGids                   = array_keys($EQGs);
139
+
140
+			if (! empty($QSGs)) {
141
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
142
+				foreach ($QSGs as $QSG) {
143
+					$QSG_ID          = absint($QSG->ID());
144
+					$checked         = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1
145
+						? ' checked'
146
+						: '';
147
+					$visibility      = $QSG->get('QSG_system') === 1
148
+						? ' style="visibility:hidden"'
149
+						: '';
150
+					$edit_query_args = $this->_adminpage_obj->is_caf()
151
+						? [
152
+							'action' => 'edit_question_group',
153
+							'QSG_ID' => $QSG_ID,
154
+						]
155
+						: ['action' => 'question_groups'];
156
+					$edit_link       = EE_Admin_Page::add_query_args_and_nonce(
157
+						$edit_query_args,
158
+						EE_FORMS_ADMIN_URL
159
+					);
160
+					$edit_link_title = sprintf(
161
+						esc_attr__('Edit %s Group', 'event_espresso'),
162
+						$QSG->get('QSG_name')
163
+					);
164
+
165
+					$html .= '
166 166
 					<p id="event-question-group-' . $QSG_ID . '">
167 167
 						<input value="' . $QSG_ID . '" 
168 168
 						    type="checkbox"
169 169
 						    name="question_groups[' . $QSG_ID . ']" '
170
-                             . $visibility
171
-                             . $checked . ' 
170
+							 . $visibility
171
+							 . $checked . ' 
172 172
                         />
173 173
 						<a href="' . esc_url_raw($edit_link) . '" 
174 174
 						    aria-label="' . esc_attr($edit_link_title) . '" 
@@ -177,62 +177,62 @@  discard block
 block discarded – undo
177 177
 						    ' . $QSG->get('QSG_name') . '
178 178
                         </a>
179 179
 					</p>';
180
-                }
181
-                $html .= count($QSGs) > 10 ? '</div>' : '';
182
-                echo wp_kses($html, AllowedTags::getWithFormTags());
183
-            } else {
184
-                esc_html_e(
185
-                    'There seems to be a problem with your questions. Please contact [email protected]',
186
-                    'event_espresso'
187
-                );
188
-            }
189
-            do_action('AHEE_event_editor_questions_notice');
190
-            ?>
180
+				}
181
+				$html .= count($QSGs) > 10 ? '</div>' : '';
182
+				echo wp_kses($html, AllowedTags::getWithFormTags());
183
+			} else {
184
+				esc_html_e(
185
+					'There seems to be a problem with your questions. Please contact [email protected]',
186
+					'event_espresso'
187
+				);
188
+			}
189
+			do_action('AHEE_event_editor_questions_notice');
190
+			?>
191 191
         </div>
192 192
         <?php
193
-    }
194
-
195
-
196
-    /**
197
-     * @param EE_Event $event
198
-     * @param array    $data
199
-     * @return bool
200
-     * @throws EE_Error
201
-     * @throws ReflectionException
202
-     */
203
-    public function primary_question_group_update($event, $data)
204
-    {
205
-        $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : [];
206
-        $added_qgs       = array_keys($question_groups);
207
-        $success         = true;
208
-
209
-        // let's get all current question groups associated with this event.
210
-        $current_qgs = $event->get_many_related(
211
-            'Question_Group',
212
-            [['Event_Question_Group.EQG_primary' => true]]
213
-        );
214
-        $current_qgs = array_keys($current_qgs); // we just want the ids
215
-
216
-        // now let's get the groups selected in the editor and update (IF we have data)
217
-        if (! empty($question_groups)) {
218
-            foreach ($question_groups as $QSG_ID => $val) {
219
-                // add to event
220
-                if ($val) {
221
-                    $qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
222
-                }
223
-                // trip success to false if result is empty
224
-                $success = ! empty($qg) ? $success : false;
225
-            }
226
-        }
227
-
228
-        // wait a minute... are there question groups missing in the saved groups that ARE with the current event?
229
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
230
-
231
-        foreach ($removed_qgs as $QSG_ID) {
232
-            $qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
233
-            // trip success to false if result is empty
234
-            $success = ! empty($qg) ? $success : false;
235
-        }
236
-        return $success;
237
-    }
193
+	}
194
+
195
+
196
+	/**
197
+	 * @param EE_Event $event
198
+	 * @param array    $data
199
+	 * @return bool
200
+	 * @throws EE_Error
201
+	 * @throws ReflectionException
202
+	 */
203
+	public function primary_question_group_update($event, $data)
204
+	{
205
+		$question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : [];
206
+		$added_qgs       = array_keys($question_groups);
207
+		$success         = true;
208
+
209
+		// let's get all current question groups associated with this event.
210
+		$current_qgs = $event->get_many_related(
211
+			'Question_Group',
212
+			[['Event_Question_Group.EQG_primary' => true]]
213
+		);
214
+		$current_qgs = array_keys($current_qgs); // we just want the ids
215
+
216
+		// now let's get the groups selected in the editor and update (IF we have data)
217
+		if (! empty($question_groups)) {
218
+			foreach ($question_groups as $QSG_ID => $val) {
219
+				// add to event
220
+				if ($val) {
221
+					$qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
222
+				}
223
+				// trip success to false if result is empty
224
+				$success = ! empty($qg) ? $success : false;
225
+			}
226
+		}
227
+
228
+		// wait a minute... are there question groups missing in the saved groups that ARE with the current event?
229
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
230
+
231
+		foreach ($removed_qgs as $QSG_ID) {
232
+			$qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
233
+			// trip success to false if result is empty
234
+			$success = ! empty($qg) ? $success : false;
235
+		}
236
+		return $success;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                     [['Event_Question_Group.EQG_primary' => true]]
136 136
                 )
137 137
                 : [];
138
-            $EQGids                   = array_keys($EQGs);
138
+            $EQGids = array_keys($EQGs);
139 139
 
140
-            if (! empty($QSGs)) {
140
+            if ( ! empty($QSGs)) {
141 141
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
142 142
                 foreach ($QSGs as $QSG) {
143 143
                     $QSG_ID          = absint($QSG->ID());
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                             'QSG_ID' => $QSG_ID,
154 154
                         ]
155 155
                         : ['action' => 'question_groups'];
156
-                    $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
156
+                    $edit_link = EE_Admin_Page::add_query_args_and_nonce(
157 157
                         $edit_query_args,
158 158
                         EE_FORMS_ADMIN_URL
159 159
                     );
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
                     );
164 164
 
165 165
                     $html .= '
166
-					<p id="event-question-group-' . $QSG_ID . '">
167
-						<input value="' . $QSG_ID . '" 
166
+					<p id="event-question-group-' . $QSG_ID.'">
167
+						<input value="' . $QSG_ID.'" 
168 168
 						    type="checkbox"
169
-						    name="question_groups[' . $QSG_ID . ']" '
169
+						    name="question_groups[' . $QSG_ID.']" '
170 170
                              . $visibility
171
-                             . $checked . ' 
171
+                             . $checked.' 
172 172
                         />
173
-						<a href="' . esc_url_raw($edit_link) . '" 
174
-						    aria-label="' . esc_attr($edit_link_title) . '" 
173
+						<a href="' . esc_url_raw($edit_link).'" 
174
+						    aria-label="' . esc_attr($edit_link_title).'" 
175 175
 						    target="_blank"
176 176
 						    >
177
-						    ' . $QSG->get('QSG_name') . '
177
+						    ' . $QSG->get('QSG_name').'
178 178
                         </a>
179 179
 					</p>';
180 180
                 }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $current_qgs = array_keys($current_qgs); // we just want the ids
215 215
 
216 216
         // now let's get the groups selected in the editor and update (IF we have data)
217
-        if (! empty($question_groups)) {
217
+        if ( ! empty($question_groups)) {
218 218
             foreach ($question_groups as $QSG_ID => $val) {
219 219
                 // add to event
220 220
                 if ($val) {
Please login to merge, or discard this patch.
registration_form/Registration_Form_Questions_Admin_List_Table.class.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -15,166 +15,166 @@
 block discarded – undo
15 15
  */
16 16
 class Registration_Form_Questions_Admin_List_Table extends EE_Admin_List_Table
17 17
 {
18
-    public function __construct($admin_page)
19
-    {
20
-        parent::__construct($admin_page);
21
-    }
22
-
23
-
24
-    protected function _setup_data()
25
-    {
26
-        if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
27
-            $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
28
-        } else {
29
-            $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
30
-        }
31
-        $this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true);
32
-    }
33
-
34
-
35
-    protected function _set_properties()
36
-    {
37
-        $this->_wp_list_args = array(
38
-            'singular' => esc_html__('question', 'event_espresso'),
39
-            'plural'   => esc_html__('questions', 'event_espresso'),
40
-            'ajax'     => true, // for now,
41
-            'screen'   => $this->_admin_page->get_current_screen()->id,
42
-        );
43
-
44
-        $this->_columns = array(
45
-            'cb'           => '<input type="checkbox" />',
46
-            'id'           => esc_html__('ID', 'event_espresso'),
47
-            'display_text' => esc_html__('Question', 'event_espresso'),
48
-            'admin_label'  => esc_html__('Admin Label', 'event_espresso'),
49
-            'type'         => esc_html__('Type', 'event_espresso'),
50
-            'values'       => esc_html__('Values', 'event_espresso'),
51
-            'required'     => esc_html__('Req', 'event_espresso'),
52
-        );
53
-
54
-        $this->_sortable_columns = array(
55
-            'id'           => array('QST_ID' => false),
56
-            'display_text' => array('QST_display_text' => false),
57
-        );
58
-
59
-        $this->_hidden_columns = array();
60
-    }
61
-
62
-
63
-    // not needed
64
-    protected function _get_table_filters()
65
-    {
66
-        return array();
67
-    }
68
-
69
-
70
-    protected function _add_view_counts()
71
-    {
72
-        $this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true);
73
-        if (
74
-            EE_Registry::instance()->CAP->current_user_can(
75
-                'ee_delete_questions',
76
-                'espresso_registration_form_trash_question'
77
-            )
78
-        ) {
79
-            $this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true);
80
-        }
81
-    }
82
-
83
-
84
-    public function column_cb($item)
85
-    {
86
-        $system_question = $item->is_system_question();
87
-        $related_answer_count = $item->count_related('Answer');
88
-        $lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
89
-            ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock';
90
-        return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
91
-            ? '<span class="' . $lock_icon . '"></span>' . sprintf(
92
-                '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
93
-                $item->ID()
94
-            ) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
95
-    }
96
-
97
-
98
-    public function column_id(EE_Question $item)
99
-    {
100
-        $content = $item->ID();
101
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>';
102
-        return $content;
103
-    }
104
-
105
-
106
-    public function column_display_text(EE_Question $item)
107
-    {
108
-        $system_question = $item->is_system_question();
109
-
110
-        if (! defined('REG_ADMIN_URL')) {
111
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
112
-        }
113
-
114
-        $edit_query_args = array(
115
-            'action' => 'edit_question',
116
-            'QST_ID' => $item->ID(),
117
-        );
118
-
119
-        if (
120
-            EE_Registry::instance()->CAP->current_user_can(
121
-                'ee_edit_question',
122
-                'espresso_registration_form_edit_question',
123
-                $item->ID()
124
-            )
125
-        ) {
126
-            $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
127
-
128
-            $actions = array(
129
-                'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__(
130
-                    'Edit Event',
131
-                    'event_espresso'
132
-                ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
133
-            );
134
-        }
135
-
136
-
137
-        $content = EE_Registry::instance()->CAP->current_user_can(
138
-            'ee_edit_question',
139
-            'espresso_registration_form_edit_question',
140
-            $item->ID()
141
-        ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>'
142
-            : $item->display_text();
143
-        $content .= $this->row_actions($actions);
144
-        return $content;
145
-    }
146
-
147
-
148
-    public function column_admin_label(EE_Question $item)
149
-    {
150
-        return $item->admin_label();
151
-    }
152
-
153
-
154
-    public function column_values(EE_Question $item)
155
-    {
156
-        $optionNames = array();
157
-        $options = $item->options();
158
-        if (empty($options)) {
159
-            return "N/A";
160
-        } else {
161
-            foreach ($options as $optionID => $option) {
162
-                /* @var $option EE_Question_Option */
163
-                $optionNames[] = $option->value();
164
-            }
165
-            return implode(', ', $optionNames);
166
-        }
167
-    }
168
-
169
-
170
-    public function column_type(EE_Question $item)
171
-    {
172
-        return $item->type();
173
-    }
174
-
175
-
176
-    public function column_required(EE_Question $item)
177
-    {
178
-        return $item->required() ? 'Yes' : '';
179
-    }
18
+	public function __construct($admin_page)
19
+	{
20
+		parent::__construct($admin_page);
21
+	}
22
+
23
+
24
+	protected function _setup_data()
25
+	{
26
+		if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
27
+			$this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
28
+		} else {
29
+			$this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
30
+		}
31
+		$this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true);
32
+	}
33
+
34
+
35
+	protected function _set_properties()
36
+	{
37
+		$this->_wp_list_args = array(
38
+			'singular' => esc_html__('question', 'event_espresso'),
39
+			'plural'   => esc_html__('questions', 'event_espresso'),
40
+			'ajax'     => true, // for now,
41
+			'screen'   => $this->_admin_page->get_current_screen()->id,
42
+		);
43
+
44
+		$this->_columns = array(
45
+			'cb'           => '<input type="checkbox" />',
46
+			'id'           => esc_html__('ID', 'event_espresso'),
47
+			'display_text' => esc_html__('Question', 'event_espresso'),
48
+			'admin_label'  => esc_html__('Admin Label', 'event_espresso'),
49
+			'type'         => esc_html__('Type', 'event_espresso'),
50
+			'values'       => esc_html__('Values', 'event_espresso'),
51
+			'required'     => esc_html__('Req', 'event_espresso'),
52
+		);
53
+
54
+		$this->_sortable_columns = array(
55
+			'id'           => array('QST_ID' => false),
56
+			'display_text' => array('QST_display_text' => false),
57
+		);
58
+
59
+		$this->_hidden_columns = array();
60
+	}
61
+
62
+
63
+	// not needed
64
+	protected function _get_table_filters()
65
+	{
66
+		return array();
67
+	}
68
+
69
+
70
+	protected function _add_view_counts()
71
+	{
72
+		$this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true);
73
+		if (
74
+			EE_Registry::instance()->CAP->current_user_can(
75
+				'ee_delete_questions',
76
+				'espresso_registration_form_trash_question'
77
+			)
78
+		) {
79
+			$this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true);
80
+		}
81
+	}
82
+
83
+
84
+	public function column_cb($item)
85
+	{
86
+		$system_question = $item->is_system_question();
87
+		$related_answer_count = $item->count_related('Answer');
88
+		$lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
89
+			? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock';
90
+		return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
91
+			? '<span class="' . $lock_icon . '"></span>' . sprintf(
92
+				'<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
93
+				$item->ID()
94
+			) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
95
+	}
96
+
97
+
98
+	public function column_id(EE_Question $item)
99
+	{
100
+		$content = $item->ID();
101
+		$content .= '  <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>';
102
+		return $content;
103
+	}
104
+
105
+
106
+	public function column_display_text(EE_Question $item)
107
+	{
108
+		$system_question = $item->is_system_question();
109
+
110
+		if (! defined('REG_ADMIN_URL')) {
111
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
112
+		}
113
+
114
+		$edit_query_args = array(
115
+			'action' => 'edit_question',
116
+			'QST_ID' => $item->ID(),
117
+		);
118
+
119
+		if (
120
+			EE_Registry::instance()->CAP->current_user_can(
121
+				'ee_edit_question',
122
+				'espresso_registration_form_edit_question',
123
+				$item->ID()
124
+			)
125
+		) {
126
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
127
+
128
+			$actions = array(
129
+				'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__(
130
+					'Edit Event',
131
+					'event_espresso'
132
+				) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
133
+			);
134
+		}
135
+
136
+
137
+		$content = EE_Registry::instance()->CAP->current_user_can(
138
+			'ee_edit_question',
139
+			'espresso_registration_form_edit_question',
140
+			$item->ID()
141
+		) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>'
142
+			: $item->display_text();
143
+		$content .= $this->row_actions($actions);
144
+		return $content;
145
+	}
146
+
147
+
148
+	public function column_admin_label(EE_Question $item)
149
+	{
150
+		return $item->admin_label();
151
+	}
152
+
153
+
154
+	public function column_values(EE_Question $item)
155
+	{
156
+		$optionNames = array();
157
+		$options = $item->options();
158
+		if (empty($options)) {
159
+			return "N/A";
160
+		} else {
161
+			foreach ($options as $optionID => $option) {
162
+				/* @var $option EE_Question_Option */
163
+				$optionNames[] = $option->value();
164
+			}
165
+			return implode(', ', $optionNames);
166
+		}
167
+	}
168
+
169
+
170
+	public function column_type(EE_Question $item)
171
+	{
172
+		return $item->type();
173
+	}
174
+
175
+
176
+	public function column_required(EE_Question $item)
177
+	{
178
+		return $item->required() ? 'Yes' : '';
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $system_question = $item->is_system_question();
87 87
         $related_answer_count = $item->count_related('Answer');
88
-        $lock_icon = (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
88
+        $lock_icon = ( ! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
89 89
             ? 'ee-lock-icon ee-alternate-color' : 'ee-lock-icon ee-system-lock';
90
-        return $system_question || (! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
91
-            ? '<span class="' . $lock_icon . '"></span>' . sprintf(
90
+        return $system_question || ( ! $system_question && $related_answer_count > 0 && $this->_view == 'trash')
91
+            ? '<span class="'.$lock_icon.'"></span>'.sprintf(
92 92
                 '<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />',
93 93
                 $item->ID()
94 94
             ) : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function column_id(EE_Question $item)
99 99
     {
100 100
         $content = $item->ID();
101
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->display_text() . '</span>';
101
+        $content .= '  <span class="show-on-mobile-view-only">'.$item->display_text().'</span>';
102 102
         return $content;
103 103
     }
104 104
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     {
108 108
         $system_question = $item->is_system_question();
109 109
 
110
-        if (! defined('REG_ADMIN_URL')) {
110
+        if ( ! defined('REG_ADMIN_URL')) {
111 111
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
112 112
         }
113 113
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
             $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
127 127
 
128 128
             $actions = array(
129
-                'edit' => '<a href="' . $edit_link . '" aria-label="' . esc_attr__(
129
+                'edit' => '<a href="'.$edit_link.'" aria-label="'.esc_attr__(
130 130
                     'Edit Event',
131 131
                     'event_espresso'
132
-                ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
132
+                ).'">'.esc_html__('Edit', 'event_espresso').'</a>',
133 133
             );
134 134
         }
135 135
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             'ee_edit_question',
139 139
             'espresso_registration_form_edit_question',
140 140
             $item->ID()
141
-        ) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>'
141
+        ) ? '<strong><a class="row-title" href="'.$edit_link.'">'.$item->display_text().'</a></strong>'
142 142
             : $item->display_text();
143 143
         $content .= $this->row_actions($actions);
144 144
         return $content;
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_List_Table.class.php 2 patches
Indentation   +595 added lines, -595 removed lines patch added patch discarded remove patch
@@ -14,599 +14,599 @@
 block discarded – undo
14 14
  */
15 15
 class Events_Admin_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var EE_Datetime
19
-     */
20
-    private $_dtt;
21
-
22
-
23
-    /**
24
-     * Initial setup of data properties for the list table.
25
-     */
26
-    protected function _setup_data()
27
-    {
28
-        $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
29
-        $this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
30
-    }
31
-
32
-
33
-    /**
34
-     * Set up of additional properties for the list table.
35
-     */
36
-    protected function _set_properties()
37
-    {
38
-        $this->_wp_list_args = array(
39
-            'singular' => esc_html__('event', 'event_espresso'),
40
-            'plural'   => esc_html__('events', 'event_espresso'),
41
-            'ajax'     => true, // for now
42
-            'screen'   => $this->_admin_page->get_current_screen()->id,
43
-        );
44
-        $this->_columns = array(
45
-            'cb'              => '<input type="checkbox" />',
46
-            'id'              => esc_html__('ID', 'event_espresso'),
47
-            'name'            => esc_html__('Name', 'event_espresso'),
48
-            'author'          => esc_html__('Author', 'event_espresso'),
49
-            'venue'           => esc_html__('Venue', 'event_espresso'),
50
-            'start_date_time' => esc_html__('Event Start', 'event_espresso'),
51
-            'reg_begins'      => esc_html__('On Sale', 'event_espresso'),
52
-            'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">'
53
-                                 . '<span class="screen-reader-text">'
54
-                                 . esc_html__('Approved Registrations', 'event_espresso')
55
-                                 . '</span>'
56
-                                 . '</span>',
57
-            // 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'),
58
-            'actions'         => esc_html__('Actions', 'event_espresso'),
59
-        );
60
-        $this->addConditionalColumns();
61
-        $this->_sortable_columns = array(
62
-            'id'              => array('EVT_ID' => true),
63
-            'name'            => array('EVT_name' => false),
64
-            'author'          => array('EVT_wp_user' => false),
65
-            'venue'           => array('Venue.VNU_name' => false),
66
-            'start_date_time' => array('Datetime.DTT_EVT_start' => false),
67
-            'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
68
-        );
69
-
70
-        $this->_primary_column = 'id';
71
-        $this->_hidden_columns = array('author', 'event_category');
72
-    }
73
-
74
-
75
-    /**
76
-     * @return array
77
-     */
78
-    protected function _get_table_filters()
79
-    {
80
-        return array(); // no filters with decaf
81
-    }
82
-
83
-
84
-    /**
85
-     * Setup of views properties.
86
-     *
87
-     * @throws InvalidDataTypeException
88
-     * @throws InvalidInterfaceException
89
-     * @throws InvalidArgumentException
90
-     */
91
-    protected function _add_view_counts()
92
-    {
93
-        $this->_views['all']['count'] = $this->_admin_page->total_events();
94
-        $this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
95
-        if (
96
-            EE_Registry::instance()->CAP->current_user_can(
97
-                'ee_delete_events',
98
-                'espresso_events_trash_events'
99
-            )
100
-        ) {
101
-            $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
102
-        }
103
-    }
104
-
105
-
106
-    /**
107
-     * @param EE_Event $item
108
-     * @return string
109
-     * @throws EE_Error
110
-     */
111
-    protected function _get_row_class($item)
112
-    {
113
-        $class = parent::_get_row_class($item);
114
-        // add status class
115
-        $class .= $item instanceof EE_Event
116
-            ? ' ee-status-strip event-status-' . $item->get_active_status()
117
-            : '';
118
-        if ($this->_has_checkbox_column) {
119
-            $class .= ' has-checkbox-column';
120
-        }
121
-        return $class;
122
-    }
123
-
124
-
125
-    /**
126
-     * @param EE_Event $item
127
-     * @return string
128
-     * @throws EE_Error
129
-     */
130
-    public function column_status(EE_Event $item)
131
-    {
132
-        return '<span class="ee-status-strip ee-status-strip-td event-status-'
133
-               . $item->get_active_status()
134
-               . '"></span>';
135
-    }
136
-
137
-
138
-    /**
139
-     * @param  EE_Event $item
140
-     * @return string
141
-     * @throws EE_Error
142
-     */
143
-    public function column_cb($item)
144
-    {
145
-        if (! $item instanceof EE_Event) {
146
-            return '';
147
-        }
148
-        $this->_dtt = $item->primary_datetime(); // set this for use in other columns
149
-        return sprintf(
150
-            '<input type="checkbox" name="EVT_IDs[]" value="%s" />',
151
-            $item->ID()
152
-        );
153
-    }
154
-
155
-
156
-    /**
157
-     * @param EE_Event $item
158
-     * @return mixed|string
159
-     * @throws EE_Error
160
-     */
161
-    public function column_id(EE_Event $item)
162
-    {
163
-        $content = $item->ID();
164
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
165
-        return $content;
166
-    }
167
-
168
-
169
-    /**
170
-     * @param EE_Event $item
171
-     * @return string
172
-     * @throws EE_Error
173
-     * @throws InvalidArgumentException
174
-     * @throws InvalidDataTypeException
175
-     * @throws InvalidInterfaceException
176
-     */
177
-    public function column_name(EE_Event $item)
178
-    {
179
-        $edit_query_args = array(
180
-            'action' => 'edit',
181
-            'post'   => $item->ID(),
182
-        );
183
-        $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
184
-        $actions = $this->_column_name_action_setup($item);
185
-        $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
186
-        $content = '<strong><a class="row-title" href="'
187
-                   . $edit_link . '">'
188
-                   . $item->name()
189
-                   . '</a></strong>'
190
-                   . $status;
191
-        $content .= '<br><span class="ee-status-text-small">'
192
-                    . EEH_Template::pretty_status(
193
-                        $item->get_active_status(),
194
-                        false,
195
-                        'sentence'
196
-                    )
197
-                    . '</span>';
198
-        $content .= $this->row_actions($actions);
199
-        return $content;
200
-    }
201
-
202
-
203
-    /**
204
-     * Just a method for setting up the actions for the name column
205
-     *
206
-     * @param EE_Event $item
207
-     * @return array array of actions
208
-     * @throws EE_Error
209
-     * @throws InvalidArgumentException
210
-     * @throws InvalidDataTypeException
211
-     * @throws InvalidInterfaceException
212
-     */
213
-    protected function _column_name_action_setup(EE_Event $item)
214
-    {
215
-        // todo: remove when attendees is active
216
-        if (! defined('REG_ADMIN_URL')) {
217
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
218
-        }
219
-        $actions = array();
220
-        $restore_event_link = '';
221
-        $delete_event_link = '';
222
-        $trash_event_link = '';
223
-        if (
224
-            EE_Registry::instance()->CAP->current_user_can(
225
-                'ee_edit_event',
226
-                'espresso_events_edit',
227
-                $item->ID()
228
-            )
229
-        ) {
230
-            $edit_query_args = array(
231
-                'action' => 'edit',
232
-                'post'   => $item->ID(),
233
-            );
234
-            $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
235
-            $actions['edit'] = '<a href="' . $edit_link . '"'
236
-                               . ' aria-label="'
237
-                               /* Translators: The name of the event */
238
-                               . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name())
239
-                               . '">'
240
-                               . esc_html__('Edit', 'event_espresso')
241
-                               . '</a>';
242
-        }
243
-        if (
244
-            EE_Registry::instance()->CAP->current_user_can(
245
-                'ee_read_registrations',
246
-                'espresso_registrations_view_registration'
247
-            )
248
-            && EE_Registry::instance()->CAP->current_user_can(
249
-                'ee_read_event',
250
-                'espresso_registrations_view_registration',
251
-                $item->ID()
252
-            )
253
-        ) {
254
-            $attendees_query_args = array(
255
-                'action'   => 'default',
256
-                'event_id' => $item->ID(),
257
-            );
258
-            $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
259
-            $actions['attendees'] = '<a href="' . $attendees_link . '"'
260
-                                    . ' aria-label="'
261
-                                    . sprintf(
262
-                                        /* Translators: The name of the event */
263
-                                        esc_attr__('View Registrations for the event: %s', 'event_espresso'),
264
-                                        $item->name()
265
-                                    )
266
-                                    . '">'
267
-                                    . esc_html__('Registrations', 'event_espresso')
268
-                                    . '</a>';
269
-        }
270
-        if (
271
-            EE_Registry::instance()->CAP->current_user_can(
272
-                'ee_delete_event',
273
-                'espresso_events_trash_event',
274
-                $item->ID()
275
-            )
276
-        ) {
277
-            $trash_event_query_args = array(
278
-                'action' => 'trash_event',
279
-                'EVT_ID' => $item->ID(),
280
-            );
281
-            $trash_event_link = EE_Admin_Page::add_query_args_and_nonce(
282
-                $trash_event_query_args,
283
-                EVENTS_ADMIN_URL
284
-            );
285
-        }
286
-        if (
287
-            EE_Registry::instance()->CAP->current_user_can(
288
-                'ee_delete_event',
289
-                'espresso_events_restore_event',
290
-                $item->ID()
291
-            )
292
-        ) {
293
-            $restore_event_query_args = array(
294
-                'action' => 'restore_event',
295
-                'EVT_ID' => $item->ID(),
296
-            );
297
-            $restore_event_link = EE_Admin_Page::add_query_args_and_nonce(
298
-                $restore_event_query_args,
299
-                EVENTS_ADMIN_URL
300
-            );
301
-        }
302
-        if (
303
-            EE_Registry::instance()->CAP->current_user_can(
304
-                'ee_delete_event',
305
-                'espresso_events_delete_event',
306
-                $item->ID()
307
-            )
308
-        ) {
309
-            $delete_event_query_args = array(
310
-                'action' => 'delete_event',
311
-                'EVT_ID' => $item->ID(),
312
-            );
313
-            $delete_event_link = EE_Admin_Page::add_query_args_and_nonce(
314
-                $delete_event_query_args,
315
-                EVENTS_ADMIN_URL
316
-            );
317
-        }
318
-        $view_link = get_permalink($item->ID());
319
-        $actions['view'] = '<a href="' . $view_link . '"'
320
-                           . ' aria-label="'
321
-                           /* Translators: The name of the event */
322
-                           . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name())
323
-                           . '">'
324
-                           . esc_html__('View', 'event_espresso')
325
-                           . '</a>';
326
-        if ($item->get('status') === 'trash') {
327
-            if (
328
-                EE_Registry::instance()->CAP->current_user_can(
329
-                    'ee_delete_event',
330
-                    'espresso_events_restore_event',
331
-                    $item->ID()
332
-                )
333
-            ) {
334
-                $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
335
-                                                 . ' aria-label="'
336
-                                                 . sprintf(
337
-                                                     /* Translators: The name of the event */
338
-                                                     esc_attr__(
339
-                                                         'Restore from Trash the event: %s',
340
-                                                         'event_espresso'
341
-                                                     ),
342
-                                                     $item->name()
343
-                                                 )
344
-                                                 . '">'
345
-                                                 . esc_html__('Restore from Trash', 'event_espresso')
346
-                                                 . '</a>';
347
-            }
348
-            if (
349
-                EE_Registry::instance()->CAP->current_user_can(
350
-                    'ee_delete_event',
351
-                    'espresso_events_delete_event',
352
-                    $item->ID()
353
-                )
354
-            ) {
355
-                $actions['delete'] = '<a href="' . $delete_event_link . '"'
356
-                                     . ' aria-label="'
357
-                                     . sprintf(
358
-                                         /* Translators: The name of the event. */
359
-                                         esc_attr__('Delete Permanently the event: %s', 'event_espresso'),
360
-                                         $item->name()
361
-                                     )
362
-                                     . '">'
363
-                                     . esc_html__('Delete Permanently', 'event_espresso')
364
-                                     . '</a>';
365
-            }
366
-        } else {
367
-            if (
368
-                EE_Registry::instance()->CAP->current_user_can(
369
-                    'ee_delete_event',
370
-                    'espresso_events_trash_event',
371
-                    $item->ID()
372
-                )
373
-            ) {
374
-                $actions['move to trash'] = '<a href="' . $trash_event_link . '"'
375
-                                            . ' aria-label="'
376
-                                            . sprintf(
377
-                                                /* Translators: The name of the event */
378
-                                                esc_attr__('Move the event %s to the trash.', 'event_espresso'),
379
-                                                $item->name()
380
-                                            )
381
-                                            . '">'
382
-                                            . esc_html__('Trash', 'event_espresso')
383
-                                            . '</a>';
384
-            }
385
-        }
386
-        return $actions;
387
-    }
388
-
389
-
390
-    /**
391
-     * @param EE_Event $item
392
-     * @return string
393
-     * @throws EE_Error
394
-     */
395
-    public function column_author(EE_Event $item)
396
-    {
397
-        // user author info
398
-        $event_author = get_userdata($item->wp_user());
399
-        $gravatar = get_avatar($item->wp_user(), '15');
400
-        // filter link
401
-        $query_args = array(
402
-            'action'      => 'default',
403
-            'EVT_wp_user' => $item->wp_user(),
404
-        );
405
-        $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
406
-        return $gravatar . '  <a href="' . $filter_url . '"'
407
-               . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
408
-               . $event_author->display_name
409
-               . '</a>';
410
-    }
411
-
412
-
413
-    /**
414
-     * @param EE_Event $event
415
-     * @return string
416
-     * @throws EE_Error
417
-     */
418
-    public function column_event_category(EE_Event $event)
419
-    {
420
-        $event_categories = $event->get_all_event_categories();
421
-        return implode(
422
-            ', ',
423
-            array_map(
424
-                function (EE_Term $category) {
425
-                    return $category->name();
426
-                },
427
-                $event_categories
428
-            )
429
-        );
430
-    }
431
-
432
-
433
-    /**
434
-     * @param EE_Event $item
435
-     * @return string
436
-     * @throws EE_Error
437
-     */
438
-    public function column_venue(EE_Event $item)
439
-    {
440
-        $venue = $item->get_first_related('Venue');
441
-        return ! empty($venue)
442
-            ? $venue->name()
443
-            : '';
444
-    }
445
-
446
-
447
-    /**
448
-     * @param EE_Event $item
449
-     * @return string
450
-     * @throws EE_Error
451
-     */
452
-    public function column_start_date_time(EE_Event $item)
453
-    {
454
-        return $this->_dtt instanceof EE_Datetime
455
-            ? $this->_dtt->get_i18n_datetime('DTT_EVT_start')
456
-            : esc_html__('No Date was saved for this Event', 'event_espresso');
457
-    }
458
-
459
-
460
-    /**
461
-     * @param EE_Event $item
462
-     * @return string
463
-     * @throws EE_Error
464
-     */
465
-    public function column_reg_begins(EE_Event $item)
466
-    {
467
-        $reg_start = $item->get_ticket_with_earliest_start_time();
468
-        return $reg_start instanceof EE_Ticket
469
-            ? $reg_start->get_i18n_datetime('TKT_start_date')
470
-            : esc_html__('No Tickets have been setup for this Event', 'event_espresso');
471
-    }
472
-
473
-
474
-    /**
475
-     * @param EE_Event $item
476
-     * @return int|string
477
-     * @throws EE_Error
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidDataTypeException
480
-     * @throws InvalidInterfaceException
481
-     */
482
-    public function column_attendees(EE_Event $item)
483
-    {
484
-        $attendees_query_args = array(
485
-            'action'   => 'default',
486
-            'event_id' => $item->ID(),
487
-        );
488
-        $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
489
-        $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
490
-        return EE_Registry::instance()->CAP->current_user_can(
491
-            'ee_read_event',
492
-            'espresso_registrations_view_registration',
493
-            $item->ID()
494
-        )
495
-               && EE_Registry::instance()->CAP->current_user_can(
496
-                   'ee_read_registrations',
497
-                   'espresso_registrations_view_registration'
498
-               )
499
-            ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
500
-            : $registered_attendees;
501
-    }
502
-
503
-
504
-    /**
505
-     * @param EE_Event $item
506
-     * @return float
507
-     * @throws EE_Error
508
-     * @throws InvalidArgumentException
509
-     * @throws InvalidDataTypeException
510
-     * @throws InvalidInterfaceException
511
-     */
512
-    public function column_tkts_sold(EE_Event $item)
513
-    {
514
-        return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
515
-    }
516
-
517
-
518
-    /**
519
-     * @param EE_Event $item
520
-     * @return string
521
-     * @throws EE_Error
522
-     * @throws InvalidArgumentException
523
-     * @throws InvalidDataTypeException
524
-     * @throws InvalidInterfaceException
525
-     */
526
-    public function column_actions(EE_Event $item)
527
-    {
528
-        // todo: remove when attendees is active
529
-        if (! defined('REG_ADMIN_URL')) {
530
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
531
-        }
532
-        $action_links = array();
533
-        $view_link = get_permalink($item->ID());
534
-        $action_links[] = '<a href="' . $view_link . '"'
535
-                          . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
536
-        $action_links[] = '<div class="dashicons dashicons-search"></div></a>';
537
-        if (
538
-            EE_Registry::instance()->CAP->current_user_can(
539
-                'ee_edit_event',
540
-                'espresso_events_edit',
541
-                $item->ID()
542
-            )
543
-        ) {
544
-            $edit_query_args = array(
545
-                'action' => 'edit',
546
-                'post'   => $item->ID(),
547
-            );
548
-            $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
549
-            $action_links[] = '<a href="' . $edit_link . '"'
550
-                              . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">'
551
-                              . '<div class="ee-icon ee-icon-calendar-edit"></div>'
552
-                              . '</a>';
553
-        }
554
-        if (
555
-            EE_Registry::instance()->CAP->current_user_can(
556
-                'ee_read_registrations',
557
-                'espresso_registrations_view_registration'
558
-            ) && EE_Registry::instance()->CAP->current_user_can(
559
-                'ee_read_event',
560
-                'espresso_registrations_view_registration',
561
-                $item->ID()
562
-            )
563
-        ) {
564
-            $attendees_query_args = array(
565
-                'action'   => 'default',
566
-                'event_id' => $item->ID(),
567
-            );
568
-            $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
569
-            $action_links[] = '<a href="' . $attendees_link . '"'
570
-                              . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">'
571
-                              . '<div class="dashicons dashicons-groups"></div>'
572
-                              . '</a>';
573
-        }
574
-        $action_links = apply_filters(
575
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
576
-            $action_links,
577
-            $item
578
-        );
579
-        return $this->_action_string(
580
-            implode("\n\t", $action_links),
581
-            $item,
582
-            'div'
583
-        );
584
-    }
585
-
586
-
587
-    /**
588
-     * Helper for adding columns conditionally
589
-     *
590
-     * @throws EE_Error
591
-     * @throws InvalidArgumentException
592
-     * @throws InvalidDataTypeException
593
-     * @throws InvalidInterfaceException
594
-     */
595
-    private function addConditionalColumns()
596
-    {
597
-        $event_category_count = EEM_Term::instance()->count(
598
-            [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]]
599
-        );
600
-        if ($event_category_count === 0) {
601
-            return;
602
-        }
603
-        $column_array = [];
604
-        foreach ($this->_columns as $column => $column_label) {
605
-            $column_array[ $column ] = $column_label;
606
-            if ($column === 'venue') {
607
-                $column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
608
-            }
609
-        }
610
-        $this->_columns = $column_array;
611
-    }
17
+	/**
18
+	 * @var EE_Datetime
19
+	 */
20
+	private $_dtt;
21
+
22
+
23
+	/**
24
+	 * Initial setup of data properties for the list table.
25
+	 */
26
+	protected function _setup_data()
27
+	{
28
+		$this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
29
+		$this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
30
+	}
31
+
32
+
33
+	/**
34
+	 * Set up of additional properties for the list table.
35
+	 */
36
+	protected function _set_properties()
37
+	{
38
+		$this->_wp_list_args = array(
39
+			'singular' => esc_html__('event', 'event_espresso'),
40
+			'plural'   => esc_html__('events', 'event_espresso'),
41
+			'ajax'     => true, // for now
42
+			'screen'   => $this->_admin_page->get_current_screen()->id,
43
+		);
44
+		$this->_columns = array(
45
+			'cb'              => '<input type="checkbox" />',
46
+			'id'              => esc_html__('ID', 'event_espresso'),
47
+			'name'            => esc_html__('Name', 'event_espresso'),
48
+			'author'          => esc_html__('Author', 'event_espresso'),
49
+			'venue'           => esc_html__('Venue', 'event_espresso'),
50
+			'start_date_time' => esc_html__('Event Start', 'event_espresso'),
51
+			'reg_begins'      => esc_html__('On Sale', 'event_espresso'),
52
+			'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">'
53
+								 . '<span class="screen-reader-text">'
54
+								 . esc_html__('Approved Registrations', 'event_espresso')
55
+								 . '</span>'
56
+								 . '</span>',
57
+			// 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'),
58
+			'actions'         => esc_html__('Actions', 'event_espresso'),
59
+		);
60
+		$this->addConditionalColumns();
61
+		$this->_sortable_columns = array(
62
+			'id'              => array('EVT_ID' => true),
63
+			'name'            => array('EVT_name' => false),
64
+			'author'          => array('EVT_wp_user' => false),
65
+			'venue'           => array('Venue.VNU_name' => false),
66
+			'start_date_time' => array('Datetime.DTT_EVT_start' => false),
67
+			'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
68
+		);
69
+
70
+		$this->_primary_column = 'id';
71
+		$this->_hidden_columns = array('author', 'event_category');
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return array
77
+	 */
78
+	protected function _get_table_filters()
79
+	{
80
+		return array(); // no filters with decaf
81
+	}
82
+
83
+
84
+	/**
85
+	 * Setup of views properties.
86
+	 *
87
+	 * @throws InvalidDataTypeException
88
+	 * @throws InvalidInterfaceException
89
+	 * @throws InvalidArgumentException
90
+	 */
91
+	protected function _add_view_counts()
92
+	{
93
+		$this->_views['all']['count'] = $this->_admin_page->total_events();
94
+		$this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
95
+		if (
96
+			EE_Registry::instance()->CAP->current_user_can(
97
+				'ee_delete_events',
98
+				'espresso_events_trash_events'
99
+			)
100
+		) {
101
+			$this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
102
+		}
103
+	}
104
+
105
+
106
+	/**
107
+	 * @param EE_Event $item
108
+	 * @return string
109
+	 * @throws EE_Error
110
+	 */
111
+	protected function _get_row_class($item)
112
+	{
113
+		$class = parent::_get_row_class($item);
114
+		// add status class
115
+		$class .= $item instanceof EE_Event
116
+			? ' ee-status-strip event-status-' . $item->get_active_status()
117
+			: '';
118
+		if ($this->_has_checkbox_column) {
119
+			$class .= ' has-checkbox-column';
120
+		}
121
+		return $class;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param EE_Event $item
127
+	 * @return string
128
+	 * @throws EE_Error
129
+	 */
130
+	public function column_status(EE_Event $item)
131
+	{
132
+		return '<span class="ee-status-strip ee-status-strip-td event-status-'
133
+			   . $item->get_active_status()
134
+			   . '"></span>';
135
+	}
136
+
137
+
138
+	/**
139
+	 * @param  EE_Event $item
140
+	 * @return string
141
+	 * @throws EE_Error
142
+	 */
143
+	public function column_cb($item)
144
+	{
145
+		if (! $item instanceof EE_Event) {
146
+			return '';
147
+		}
148
+		$this->_dtt = $item->primary_datetime(); // set this for use in other columns
149
+		return sprintf(
150
+			'<input type="checkbox" name="EVT_IDs[]" value="%s" />',
151
+			$item->ID()
152
+		);
153
+	}
154
+
155
+
156
+	/**
157
+	 * @param EE_Event $item
158
+	 * @return mixed|string
159
+	 * @throws EE_Error
160
+	 */
161
+	public function column_id(EE_Event $item)
162
+	{
163
+		$content = $item->ID();
164
+		$content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
165
+		return $content;
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param EE_Event $item
171
+	 * @return string
172
+	 * @throws EE_Error
173
+	 * @throws InvalidArgumentException
174
+	 * @throws InvalidDataTypeException
175
+	 * @throws InvalidInterfaceException
176
+	 */
177
+	public function column_name(EE_Event $item)
178
+	{
179
+		$edit_query_args = array(
180
+			'action' => 'edit',
181
+			'post'   => $item->ID(),
182
+		);
183
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
184
+		$actions = $this->_column_name_action_setup($item);
185
+		$status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
186
+		$content = '<strong><a class="row-title" href="'
187
+				   . $edit_link . '">'
188
+				   . $item->name()
189
+				   . '</a></strong>'
190
+				   . $status;
191
+		$content .= '<br><span class="ee-status-text-small">'
192
+					. EEH_Template::pretty_status(
193
+						$item->get_active_status(),
194
+						false,
195
+						'sentence'
196
+					)
197
+					. '</span>';
198
+		$content .= $this->row_actions($actions);
199
+		return $content;
200
+	}
201
+
202
+
203
+	/**
204
+	 * Just a method for setting up the actions for the name column
205
+	 *
206
+	 * @param EE_Event $item
207
+	 * @return array array of actions
208
+	 * @throws EE_Error
209
+	 * @throws InvalidArgumentException
210
+	 * @throws InvalidDataTypeException
211
+	 * @throws InvalidInterfaceException
212
+	 */
213
+	protected function _column_name_action_setup(EE_Event $item)
214
+	{
215
+		// todo: remove when attendees is active
216
+		if (! defined('REG_ADMIN_URL')) {
217
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
218
+		}
219
+		$actions = array();
220
+		$restore_event_link = '';
221
+		$delete_event_link = '';
222
+		$trash_event_link = '';
223
+		if (
224
+			EE_Registry::instance()->CAP->current_user_can(
225
+				'ee_edit_event',
226
+				'espresso_events_edit',
227
+				$item->ID()
228
+			)
229
+		) {
230
+			$edit_query_args = array(
231
+				'action' => 'edit',
232
+				'post'   => $item->ID(),
233
+			);
234
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
235
+			$actions['edit'] = '<a href="' . $edit_link . '"'
236
+							   . ' aria-label="'
237
+							   /* Translators: The name of the event */
238
+							   . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name())
239
+							   . '">'
240
+							   . esc_html__('Edit', 'event_espresso')
241
+							   . '</a>';
242
+		}
243
+		if (
244
+			EE_Registry::instance()->CAP->current_user_can(
245
+				'ee_read_registrations',
246
+				'espresso_registrations_view_registration'
247
+			)
248
+			&& EE_Registry::instance()->CAP->current_user_can(
249
+				'ee_read_event',
250
+				'espresso_registrations_view_registration',
251
+				$item->ID()
252
+			)
253
+		) {
254
+			$attendees_query_args = array(
255
+				'action'   => 'default',
256
+				'event_id' => $item->ID(),
257
+			);
258
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
259
+			$actions['attendees'] = '<a href="' . $attendees_link . '"'
260
+									. ' aria-label="'
261
+									. sprintf(
262
+										/* Translators: The name of the event */
263
+										esc_attr__('View Registrations for the event: %s', 'event_espresso'),
264
+										$item->name()
265
+									)
266
+									. '">'
267
+									. esc_html__('Registrations', 'event_espresso')
268
+									. '</a>';
269
+		}
270
+		if (
271
+			EE_Registry::instance()->CAP->current_user_can(
272
+				'ee_delete_event',
273
+				'espresso_events_trash_event',
274
+				$item->ID()
275
+			)
276
+		) {
277
+			$trash_event_query_args = array(
278
+				'action' => 'trash_event',
279
+				'EVT_ID' => $item->ID(),
280
+			);
281
+			$trash_event_link = EE_Admin_Page::add_query_args_and_nonce(
282
+				$trash_event_query_args,
283
+				EVENTS_ADMIN_URL
284
+			);
285
+		}
286
+		if (
287
+			EE_Registry::instance()->CAP->current_user_can(
288
+				'ee_delete_event',
289
+				'espresso_events_restore_event',
290
+				$item->ID()
291
+			)
292
+		) {
293
+			$restore_event_query_args = array(
294
+				'action' => 'restore_event',
295
+				'EVT_ID' => $item->ID(),
296
+			);
297
+			$restore_event_link = EE_Admin_Page::add_query_args_and_nonce(
298
+				$restore_event_query_args,
299
+				EVENTS_ADMIN_URL
300
+			);
301
+		}
302
+		if (
303
+			EE_Registry::instance()->CAP->current_user_can(
304
+				'ee_delete_event',
305
+				'espresso_events_delete_event',
306
+				$item->ID()
307
+			)
308
+		) {
309
+			$delete_event_query_args = array(
310
+				'action' => 'delete_event',
311
+				'EVT_ID' => $item->ID(),
312
+			);
313
+			$delete_event_link = EE_Admin_Page::add_query_args_and_nonce(
314
+				$delete_event_query_args,
315
+				EVENTS_ADMIN_URL
316
+			);
317
+		}
318
+		$view_link = get_permalink($item->ID());
319
+		$actions['view'] = '<a href="' . $view_link . '"'
320
+						   . ' aria-label="'
321
+						   /* Translators: The name of the event */
322
+						   . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name())
323
+						   . '">'
324
+						   . esc_html__('View', 'event_espresso')
325
+						   . '</a>';
326
+		if ($item->get('status') === 'trash') {
327
+			if (
328
+				EE_Registry::instance()->CAP->current_user_can(
329
+					'ee_delete_event',
330
+					'espresso_events_restore_event',
331
+					$item->ID()
332
+				)
333
+			) {
334
+				$actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
335
+												 . ' aria-label="'
336
+												 . sprintf(
337
+													 /* Translators: The name of the event */
338
+													 esc_attr__(
339
+														 'Restore from Trash the event: %s',
340
+														 'event_espresso'
341
+													 ),
342
+													 $item->name()
343
+												 )
344
+												 . '">'
345
+												 . esc_html__('Restore from Trash', 'event_espresso')
346
+												 . '</a>';
347
+			}
348
+			if (
349
+				EE_Registry::instance()->CAP->current_user_can(
350
+					'ee_delete_event',
351
+					'espresso_events_delete_event',
352
+					$item->ID()
353
+				)
354
+			) {
355
+				$actions['delete'] = '<a href="' . $delete_event_link . '"'
356
+									 . ' aria-label="'
357
+									 . sprintf(
358
+										 /* Translators: The name of the event. */
359
+										 esc_attr__('Delete Permanently the event: %s', 'event_espresso'),
360
+										 $item->name()
361
+									 )
362
+									 . '">'
363
+									 . esc_html__('Delete Permanently', 'event_espresso')
364
+									 . '</a>';
365
+			}
366
+		} else {
367
+			if (
368
+				EE_Registry::instance()->CAP->current_user_can(
369
+					'ee_delete_event',
370
+					'espresso_events_trash_event',
371
+					$item->ID()
372
+				)
373
+			) {
374
+				$actions['move to trash'] = '<a href="' . $trash_event_link . '"'
375
+											. ' aria-label="'
376
+											. sprintf(
377
+												/* Translators: The name of the event */
378
+												esc_attr__('Move the event %s to the trash.', 'event_espresso'),
379
+												$item->name()
380
+											)
381
+											. '">'
382
+											. esc_html__('Trash', 'event_espresso')
383
+											. '</a>';
384
+			}
385
+		}
386
+		return $actions;
387
+	}
388
+
389
+
390
+	/**
391
+	 * @param EE_Event $item
392
+	 * @return string
393
+	 * @throws EE_Error
394
+	 */
395
+	public function column_author(EE_Event $item)
396
+	{
397
+		// user author info
398
+		$event_author = get_userdata($item->wp_user());
399
+		$gravatar = get_avatar($item->wp_user(), '15');
400
+		// filter link
401
+		$query_args = array(
402
+			'action'      => 'default',
403
+			'EVT_wp_user' => $item->wp_user(),
404
+		);
405
+		$filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
406
+		return $gravatar . '  <a href="' . $filter_url . '"'
407
+			   . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
408
+			   . $event_author->display_name
409
+			   . '</a>';
410
+	}
411
+
412
+
413
+	/**
414
+	 * @param EE_Event $event
415
+	 * @return string
416
+	 * @throws EE_Error
417
+	 */
418
+	public function column_event_category(EE_Event $event)
419
+	{
420
+		$event_categories = $event->get_all_event_categories();
421
+		return implode(
422
+			', ',
423
+			array_map(
424
+				function (EE_Term $category) {
425
+					return $category->name();
426
+				},
427
+				$event_categories
428
+			)
429
+		);
430
+	}
431
+
432
+
433
+	/**
434
+	 * @param EE_Event $item
435
+	 * @return string
436
+	 * @throws EE_Error
437
+	 */
438
+	public function column_venue(EE_Event $item)
439
+	{
440
+		$venue = $item->get_first_related('Venue');
441
+		return ! empty($venue)
442
+			? $venue->name()
443
+			: '';
444
+	}
445
+
446
+
447
+	/**
448
+	 * @param EE_Event $item
449
+	 * @return string
450
+	 * @throws EE_Error
451
+	 */
452
+	public function column_start_date_time(EE_Event $item)
453
+	{
454
+		return $this->_dtt instanceof EE_Datetime
455
+			? $this->_dtt->get_i18n_datetime('DTT_EVT_start')
456
+			: esc_html__('No Date was saved for this Event', 'event_espresso');
457
+	}
458
+
459
+
460
+	/**
461
+	 * @param EE_Event $item
462
+	 * @return string
463
+	 * @throws EE_Error
464
+	 */
465
+	public function column_reg_begins(EE_Event $item)
466
+	{
467
+		$reg_start = $item->get_ticket_with_earliest_start_time();
468
+		return $reg_start instanceof EE_Ticket
469
+			? $reg_start->get_i18n_datetime('TKT_start_date')
470
+			: esc_html__('No Tickets have been setup for this Event', 'event_espresso');
471
+	}
472
+
473
+
474
+	/**
475
+	 * @param EE_Event $item
476
+	 * @return int|string
477
+	 * @throws EE_Error
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidDataTypeException
480
+	 * @throws InvalidInterfaceException
481
+	 */
482
+	public function column_attendees(EE_Event $item)
483
+	{
484
+		$attendees_query_args = array(
485
+			'action'   => 'default',
486
+			'event_id' => $item->ID(),
487
+		);
488
+		$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
489
+		$registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
490
+		return EE_Registry::instance()->CAP->current_user_can(
491
+			'ee_read_event',
492
+			'espresso_registrations_view_registration',
493
+			$item->ID()
494
+		)
495
+			   && EE_Registry::instance()->CAP->current_user_can(
496
+				   'ee_read_registrations',
497
+				   'espresso_registrations_view_registration'
498
+			   )
499
+			? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
500
+			: $registered_attendees;
501
+	}
502
+
503
+
504
+	/**
505
+	 * @param EE_Event $item
506
+	 * @return float
507
+	 * @throws EE_Error
508
+	 * @throws InvalidArgumentException
509
+	 * @throws InvalidDataTypeException
510
+	 * @throws InvalidInterfaceException
511
+	 */
512
+	public function column_tkts_sold(EE_Event $item)
513
+	{
514
+		return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param EE_Event $item
520
+	 * @return string
521
+	 * @throws EE_Error
522
+	 * @throws InvalidArgumentException
523
+	 * @throws InvalidDataTypeException
524
+	 * @throws InvalidInterfaceException
525
+	 */
526
+	public function column_actions(EE_Event $item)
527
+	{
528
+		// todo: remove when attendees is active
529
+		if (! defined('REG_ADMIN_URL')) {
530
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
531
+		}
532
+		$action_links = array();
533
+		$view_link = get_permalink($item->ID());
534
+		$action_links[] = '<a href="' . $view_link . '"'
535
+						  . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
536
+		$action_links[] = '<div class="dashicons dashicons-search"></div></a>';
537
+		if (
538
+			EE_Registry::instance()->CAP->current_user_can(
539
+				'ee_edit_event',
540
+				'espresso_events_edit',
541
+				$item->ID()
542
+			)
543
+		) {
544
+			$edit_query_args = array(
545
+				'action' => 'edit',
546
+				'post'   => $item->ID(),
547
+			);
548
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
549
+			$action_links[] = '<a href="' . $edit_link . '"'
550
+							  . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">'
551
+							  . '<div class="ee-icon ee-icon-calendar-edit"></div>'
552
+							  . '</a>';
553
+		}
554
+		if (
555
+			EE_Registry::instance()->CAP->current_user_can(
556
+				'ee_read_registrations',
557
+				'espresso_registrations_view_registration'
558
+			) && EE_Registry::instance()->CAP->current_user_can(
559
+				'ee_read_event',
560
+				'espresso_registrations_view_registration',
561
+				$item->ID()
562
+			)
563
+		) {
564
+			$attendees_query_args = array(
565
+				'action'   => 'default',
566
+				'event_id' => $item->ID(),
567
+			);
568
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
569
+			$action_links[] = '<a href="' . $attendees_link . '"'
570
+							  . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">'
571
+							  . '<div class="dashicons dashicons-groups"></div>'
572
+							  . '</a>';
573
+		}
574
+		$action_links = apply_filters(
575
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
576
+			$action_links,
577
+			$item
578
+		);
579
+		return $this->_action_string(
580
+			implode("\n\t", $action_links),
581
+			$item,
582
+			'div'
583
+		);
584
+	}
585
+
586
+
587
+	/**
588
+	 * Helper for adding columns conditionally
589
+	 *
590
+	 * @throws EE_Error
591
+	 * @throws InvalidArgumentException
592
+	 * @throws InvalidDataTypeException
593
+	 * @throws InvalidInterfaceException
594
+	 */
595
+	private function addConditionalColumns()
596
+	{
597
+		$event_category_count = EEM_Term::instance()->count(
598
+			[['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]]
599
+		);
600
+		if ($event_category_count === 0) {
601
+			return;
602
+		}
603
+		$column_array = [];
604
+		foreach ($this->_columns as $column => $column_label) {
605
+			$column_array[ $column ] = $column_label;
606
+			if ($column === 'venue') {
607
+				$column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
608
+			}
609
+		}
610
+		$this->_columns = $column_array;
611
+	}
612 612
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $class = parent::_get_row_class($item);
114 114
         // add status class
115 115
         $class .= $item instanceof EE_Event
116
-            ? ' ee-status-strip event-status-' . $item->get_active_status()
116
+            ? ' ee-status-strip event-status-'.$item->get_active_status()
117 117
             : '';
118 118
         if ($this->_has_checkbox_column) {
119 119
             $class .= ' has-checkbox-column';
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function column_cb($item)
144 144
     {
145
-        if (! $item instanceof EE_Event) {
145
+        if ( ! $item instanceof EE_Event) {
146 146
             return '';
147 147
         }
148 148
         $this->_dtt = $item->primary_datetime(); // set this for use in other columns
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     public function column_id(EE_Event $item)
162 162
     {
163 163
         $content = $item->ID();
164
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
164
+        $content .= '  <span class="show-on-mobile-view-only">'.$item->name().'</span>';
165 165
         return $content;
166 166
     }
167 167
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $actions = $this->_column_name_action_setup($item);
185 185
         $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
186 186
         $content = '<strong><a class="row-title" href="'
187
-                   . $edit_link . '">'
187
+                   . $edit_link.'">'
188 188
                    . $item->name()
189 189
                    . '</a></strong>'
190 190
                    . $status;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     protected function _column_name_action_setup(EE_Event $item)
214 214
     {
215 215
         // todo: remove when attendees is active
216
-        if (! defined('REG_ADMIN_URL')) {
216
+        if ( ! defined('REG_ADMIN_URL')) {
217 217
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
218 218
         }
219 219
         $actions = array();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                 'post'   => $item->ID(),
233 233
             );
234 234
             $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
235
-            $actions['edit'] = '<a href="' . $edit_link . '"'
235
+            $actions['edit'] = '<a href="'.$edit_link.'"'
236 236
                                . ' aria-label="'
237 237
                                /* Translators: The name of the event */
238 238
                                . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name())
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 'event_id' => $item->ID(),
257 257
             );
258 258
             $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
259
-            $actions['attendees'] = '<a href="' . $attendees_link . '"'
259
+            $actions['attendees'] = '<a href="'.$attendees_link.'"'
260 260
                                     . ' aria-label="'
261 261
                                     . sprintf(
262 262
                                         /* Translators: The name of the event */
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             );
317 317
         }
318 318
         $view_link = get_permalink($item->ID());
319
-        $actions['view'] = '<a href="' . $view_link . '"'
319
+        $actions['view'] = '<a href="'.$view_link.'"'
320 320
                            . ' aria-label="'
321 321
                            /* Translators: The name of the event */
322 322
                            . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name())
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                     $item->ID()
332 332
                 )
333 333
             ) {
334
-                $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
334
+                $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'"'
335 335
                                                  . ' aria-label="'
336 336
                                                  . sprintf(
337 337
                                                      /* Translators: The name of the event */
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                     $item->ID()
353 353
                 )
354 354
             ) {
355
-                $actions['delete'] = '<a href="' . $delete_event_link . '"'
355
+                $actions['delete'] = '<a href="'.$delete_event_link.'"'
356 356
                                      . ' aria-label="'
357 357
                                      . sprintf(
358 358
                                          /* Translators: The name of the event. */
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                     $item->ID()
372 372
                 )
373 373
             ) {
374
-                $actions['move to trash'] = '<a href="' . $trash_event_link . '"'
374
+                $actions['move to trash'] = '<a href="'.$trash_event_link.'"'
375 375
                                             . ' aria-label="'
376 376
                                             . sprintf(
377 377
                                                 /* Translators: The name of the event */
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
             'EVT_wp_user' => $item->wp_user(),
404 404
         );
405 405
         $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
406
-        return $gravatar . '  <a href="' . $filter_url . '"'
407
-               . ' aria-label="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
406
+        return $gravatar.'  <a href="'.$filter_url.'"'
407
+               . ' aria-label="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">'
408 408
                . $event_author->display_name
409 409
                . '</a>';
410 410
     }
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
         return implode(
422 422
             ', ',
423 423
             array_map(
424
-                function (EE_Term $category) {
424
+                function(EE_Term $category) {
425 425
                     return $category->name();
426 426
                 },
427 427
                 $event_categories
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                    'ee_read_registrations',
497 497
                    'espresso_registrations_view_registration'
498 498
                )
499
-            ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
499
+            ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>'
500 500
             : $registered_attendees;
501 501
     }
502 502
 
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
     public function column_actions(EE_Event $item)
527 527
     {
528 528
         // todo: remove when attendees is active
529
-        if (! defined('REG_ADMIN_URL')) {
529
+        if ( ! defined('REG_ADMIN_URL')) {
530 530
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
531 531
         }
532 532
         $action_links = array();
533 533
         $view_link = get_permalink($item->ID());
534
-        $action_links[] = '<a href="' . $view_link . '"'
535
-                          . ' aria-label="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
534
+        $action_links[] = '<a href="'.$view_link.'"'
535
+                          . ' aria-label="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">';
536 536
         $action_links[] = '<div class="dashicons dashicons-search"></div></a>';
537 537
         if (
538 538
             EE_Registry::instance()->CAP->current_user_can(
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
                 'post'   => $item->ID(),
547 547
             );
548 548
             $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
549
-            $action_links[] = '<a href="' . $edit_link . '"'
550
-                              . ' aria-label="' . esc_attr__('Edit Event', 'event_espresso') . '">'
549
+            $action_links[] = '<a href="'.$edit_link.'"'
550
+                              . ' aria-label="'.esc_attr__('Edit Event', 'event_espresso').'">'
551 551
                               . '<div class="ee-icon ee-icon-calendar-edit"></div>'
552 552
                               . '</a>';
553 553
         }
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
                 'event_id' => $item->ID(),
567 567
             );
568 568
             $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
569
-            $action_links[] = '<a href="' . $attendees_link . '"'
570
-                              . ' aria-label="' . esc_attr__('View Registrants', 'event_espresso') . '">'
569
+            $action_links[] = '<a href="'.$attendees_link.'"'
570
+                              . ' aria-label="'.esc_attr__('View Registrants', 'event_espresso').'">'
571 571
                               . '<div class="dashicons dashicons-groups"></div>'
572 572
                               . '</a>';
573 573
         }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
         }
603 603
         $column_array = [];
604 604
         foreach ($this->_columns as $column => $column_label) {
605
-            $column_array[ $column ] = $column_label;
605
+            $column_array[$column] = $column_label;
606 606
             if ($column === 'venue') {
607 607
                 $column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
608 608
             }
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Template_List_Table.class.php 2 patches
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -10,368 +10,368 @@
 block discarded – undo
10 10
  */
11 11
 class Messages_Template_List_Table extends EE_Admin_List_Table
12 12
 {
13
-    /**
14
-     * @var Messages_Admin_Page
15
-     */
16
-    protected $_admin_page;
17
-
18
-
19
-    /**
20
-     * @return Messages_Admin_Page
21
-     */
22
-    public function get_admin_page()
23
-    {
24
-        return $this->_admin_page;
25
-    }
26
-
27
-
28
-    /**
29
-     * Setup data object
30
-     *
31
-     * @throws EE_Error
32
-     */
33
-    protected function _setup_data()
34
-    {
35
-        $this->_data           = $this->get_admin_page()->get_message_templates(
36
-            $this->_per_page,
37
-            $this->_view
38
-        );
39
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
40
-            $this->_per_page,
41
-            $this->_view,
42
-            true,
43
-            true
44
-        );
45
-    }
46
-
47
-
48
-    /**
49
-     * Set internal properties
50
-     */
51
-    protected function _set_properties()
52
-    {
53
-        $this->_wp_list_args = [
54
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
55
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
56
-            'ajax'     => true, // for now,
57
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
58
-        ];
59
-        $this->_columns      = [
60
-            // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61
-            'message_type' => esc_html__('Message Type', 'event_espresso'),
62
-            'messenger'    => esc_html__('Messenger', 'event_espresso'),
63
-            'description'  => esc_html__('Description', 'event_espresso'),
64
-        ];
65
-
66
-        $this->_sortable_columns = [
67
-            'messenger' => ['MTP_messenger' => true],
68
-        ];
69
-
70
-        $this->_hidden_columns = [];
71
-    }
72
-
73
-
74
-    /**
75
-     * Overriding the single_row method from parent to verify whether the $item has an accessible
76
-     * message_type or messenger object before generating the row.
77
-     *
78
-     * @param EE_Message_Template_Group $item
79
-     * @return void
80
-     * @throws EE_Error
81
-     */
82
-    public function single_row($item)
83
-    {
84
-        if (
85
-            ! $item->message_type_obj() instanceof EE_message_type
86
-            || ! $item->messenger_obj() instanceof EE_messenger
87
-        ) {
88
-            return;
89
-        }
90
-
91
-        parent::single_row($item);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return array
97
-     * @throws EE_Error
98
-     */
99
-    protected function _get_table_filters()
100
-    {
101
-        $filters = [];
102
-
103
-        // get select inputs
104
-        $select_inputs = [
105
-            $this->_get_messengers_dropdown_filter(),
106
-            $this->_get_message_types_dropdown_filter(),
107
-        ];
108
-
109
-        // set filters to select inputs if they aren't empty
110
-        foreach ($select_inputs as $select_input) {
111
-            if ($select_input) {
112
-                $filters[] = $select_input;
113
-            }
114
-        }
115
-        return $filters;
116
-    }
117
-
118
-
119
-    /**
120
-     * We're just removing the search box for message templates, not needed.
121
-     *
122
-     * @param string $text
123
-     * @param string $input_id
124
-     * @return string ;
125
-     */
126
-    public function search_box($text, $input_id)
127
-    {
128
-        return '';
129
-    }
130
-
131
-
132
-    /**
133
-     * Add counts to the _views property
134
-     *
135
-     * @throws EE_Error
136
-     */
137
-    protected function _add_view_counts()
138
-    {
139
-        foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
-                $this->_per_page,
142
-                $view,
143
-                true,
144
-                true
145
-            );
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * @param EE_Message_Template_Group $item
152
-     * @return string
153
-     */
154
-    public function column_cb($item)
155
-    {
156
-        return '';
157
-    }
158
-
159
-
160
-    /**
161
-     * @param EE_Message_Template_Group $item
162
-     * @return string
163
-     * @throws EE_Error
164
-     */
165
-    public function column_description($item)
166
-    {
167
-        return '<p>' . $item->message_type_obj()->description . '</p>';
168
-    }
169
-
170
-
171
-    /**
172
-     * @param EE_Message_Template_Group $item
173
-     * @return string
174
-     * @throws EE_Error
175
-     * @throws ReflectionException
176
-     */
177
-    public function column_messenger($item)
178
-    {
179
-        // Return the name contents
180
-        return sprintf(
181
-            '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
182
-            /* $1%s */
183
-            ucwords($item->messenger_obj()->label['singular']),
184
-            /* $2%s */
185
-            $item->GRP_ID(),
186
-            /* %4$s */
187
-            $this->_get_context_links($item),
188
-            $this->row_actions($this->_get_actions_for_messenger_column($item))
189
-        );
190
-    }
191
-
192
-
193
-    /**
194
-     * column_message_type
195
-     *
196
-     * @param EE_Message_Template_Group $item message info for the row
197
-     * @return string message_type name
198
-     * @throws EE_Error
199
-     */
200
-    public function column_message_type($item)
201
-    {
202
-        return ucwords($item->message_type_obj()->label['singular']);
203
-    }
204
-
205
-
206
-    /**
207
-     * Generate dropdown filter select input for messengers
208
-     *
209
-     * @param bool $global
210
-     * @return string
211
-     * @throws EE_Error
212
-     */
213
-    protected function _get_messengers_dropdown_filter($global = true)
214
-    {
215
-        $messenger_options                                   = [];
216
-        $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
217
-            [
218
-                [
219
-                    'MTP_is_active' => true,
220
-                    'MTP_is_global' => $global,
221
-                ],
222
-                'group_by' => 'MTP_messenger',
223
-            ]
224
-        );
225
-
226
-        foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
227
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
228
-                $messenger                            = $active_message_template_group->messenger_obj();
229
-                $messenger_name                       = $active_message_template_group->messenger();
230
-                $messenger_label                      = $messenger instanceof EE_messenger
231
-                    ? $messenger->label['singular']
232
-                    : $messenger_name;
233
-                $messenger_options[ $messenger_name ] = ucwords($messenger_label);
234
-            }
235
-        }
236
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
237
-    }
238
-
239
-
240
-    /**
241
-     * Generate dropdown filter select input for message types
242
-     *
243
-     * @param bool $global
244
-     * @return string
245
-     * @throws EE_Error
246
-     */
247
-    protected function _get_message_types_dropdown_filter($global = true)
248
-    {
249
-        $message_type_options                                   = [];
250
-        $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
251
-            [
252
-                [
253
-                    'MTP_is_active' => true,
254
-                    'MTP_is_global' => $global,
255
-                ],
256
-                'group_by' => 'MTP_message_type',
257
-            ]
258
-        );
259
-
260
-        foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
261
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
262
-                $message_type                               = $active_message_template_group->message_type_obj();
263
-                $message_type_name                          = $active_message_template_group->message_type();
264
-                $message_type_label                         = $message_type instanceof EE_message_type
265
-                    ? $message_type->label['singular']
266
-                    : $message_type_name;
267
-                $message_type_options[ $message_type_name ] = ucwords($message_type_label);
268
-            }
269
-        }
270
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
271
-    }
272
-
273
-
274
-    /**
275
-     * Return the edit url for the message template group.
276
-     *
277
-     * @param EE_Message_Template_Group $item
278
-     * @return string
279
-     * @throws EE_Error
280
-     * @throws ReflectionException
281
-     */
282
-    protected function _get_edit_url(EE_Message_Template_Group $item)
283
-    {
284
-        $edit_url = '';
285
-        // edit link but only if item isn't trashed.
286
-        if (
287
-            ! $item->get('MTP_deleted')
288
-            && EE_Registry::instance()->CAP->current_user_can(
289
-                'ee_edit_message',
290
-                'espresso_messages_edit_message_template',
291
-                $item->ID()
292
-            )
293
-        ) {
294
-            $edit_url = EE_Admin_Page::add_query_args_and_nonce(
295
-                [
296
-                    'action' => 'edit_message_template',
297
-                    'id'     => $item->GRP_ID(),
298
-                ],
299
-                EE_MSG_ADMIN_URL
300
-            );
301
-        }
302
-        return $edit_url;
303
-    }
304
-
305
-
306
-    /**
307
-     * Get the context link string for the messenger column.
308
-     *
309
-     * @param EE_Message_Template_Group $item
310
-     * @return string
311
-     * @throws EE_Error
312
-     * @throws ReflectionException
313
-     */
314
-    protected function _get_context_links(EE_Message_Template_Group $item)
315
-    {
316
-        // first check if we even show the context links or not.
317
-        if (
318
-            ! EE_Registry::instance()->CAP->current_user_can(
319
-                'ee_edit_message',
320
-                'espresso_messages_edit_message_template',
321
-                $item->ID()
322
-            )
323
-            || $item->get('MTP_deleted')
324
-        ) {
325
-            return '';
326
-        }
327
-        // we want to display the contexts in here, so we need to set them up
328
-        $c_label           = $item->context_label();
329
-        $c_configs         = $item->contexts_config();
330
-        $context_array     = [];
331
-        $context_templates = $item->context_templates();
332
-        foreach ($context_templates as $context => $template_fields) {
333
-            $mtp_to          = ! empty($template_fields['to'])
334
-                               && $template_fields['to'] instanceof EE_Message_Template
335
-                ? $template_fields['to']->get('MTP_content')
336
-                : null;
337
-            $inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
338
-                               || ! $item->is_context_active($context)
339
-                ? ' mtp-inactive'
340
-                : '';
341
-            $context_title   = sprintf(
342
-            /* translators: Placeholder represents the context label. Example "Edit Event Admin" */
343
-                esc_html__('Edit %1$s', 'event_espresso'),
344
-                ucwords($c_configs[ $context ]['label'])
345
-            );
346
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
347
-                [
348
-                    'action'  => 'edit_message_template',
349
-                    'id'      => $item->GRP_ID(),
350
-                    'context' => $context,
351
-                ],
352
-                EE_MSG_ADMIN_URL
353
-            );
354
-            $context_array[] = '<a href="' . $edit_link . '"'
355
-                               . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
356
-                               . ' aria-label="' . esc_attr__('Edit Context', 'event_espresso') . '">'
357
-                               . $context_title
358
-                               . '</a>';
359
-        }
360
-
361
-        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
362
-    }
363
-
364
-
365
-    /**
366
-     * Returns the actions for the messenger column.
367
-     *
368
-     * Note: Children classes may override this, so do not remove it.
369
-     *
370
-     * @param EE_Message_Template_Group $item
371
-     * @return array
372
-     */
373
-    protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
374
-    {
375
-        return [];
376
-    }
13
+	/**
14
+	 * @var Messages_Admin_Page
15
+	 */
16
+	protected $_admin_page;
17
+
18
+
19
+	/**
20
+	 * @return Messages_Admin_Page
21
+	 */
22
+	public function get_admin_page()
23
+	{
24
+		return $this->_admin_page;
25
+	}
26
+
27
+
28
+	/**
29
+	 * Setup data object
30
+	 *
31
+	 * @throws EE_Error
32
+	 */
33
+	protected function _setup_data()
34
+	{
35
+		$this->_data           = $this->get_admin_page()->get_message_templates(
36
+			$this->_per_page,
37
+			$this->_view
38
+		);
39
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
40
+			$this->_per_page,
41
+			$this->_view,
42
+			true,
43
+			true
44
+		);
45
+	}
46
+
47
+
48
+	/**
49
+	 * Set internal properties
50
+	 */
51
+	protected function _set_properties()
52
+	{
53
+		$this->_wp_list_args = [
54
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
55
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
56
+			'ajax'     => true, // for now,
57
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
58
+		];
59
+		$this->_columns      = [
60
+			// 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61
+			'message_type' => esc_html__('Message Type', 'event_espresso'),
62
+			'messenger'    => esc_html__('Messenger', 'event_espresso'),
63
+			'description'  => esc_html__('Description', 'event_espresso'),
64
+		];
65
+
66
+		$this->_sortable_columns = [
67
+			'messenger' => ['MTP_messenger' => true],
68
+		];
69
+
70
+		$this->_hidden_columns = [];
71
+	}
72
+
73
+
74
+	/**
75
+	 * Overriding the single_row method from parent to verify whether the $item has an accessible
76
+	 * message_type or messenger object before generating the row.
77
+	 *
78
+	 * @param EE_Message_Template_Group $item
79
+	 * @return void
80
+	 * @throws EE_Error
81
+	 */
82
+	public function single_row($item)
83
+	{
84
+		if (
85
+			! $item->message_type_obj() instanceof EE_message_type
86
+			|| ! $item->messenger_obj() instanceof EE_messenger
87
+		) {
88
+			return;
89
+		}
90
+
91
+		parent::single_row($item);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return array
97
+	 * @throws EE_Error
98
+	 */
99
+	protected function _get_table_filters()
100
+	{
101
+		$filters = [];
102
+
103
+		// get select inputs
104
+		$select_inputs = [
105
+			$this->_get_messengers_dropdown_filter(),
106
+			$this->_get_message_types_dropdown_filter(),
107
+		];
108
+
109
+		// set filters to select inputs if they aren't empty
110
+		foreach ($select_inputs as $select_input) {
111
+			if ($select_input) {
112
+				$filters[] = $select_input;
113
+			}
114
+		}
115
+		return $filters;
116
+	}
117
+
118
+
119
+	/**
120
+	 * We're just removing the search box for message templates, not needed.
121
+	 *
122
+	 * @param string $text
123
+	 * @param string $input_id
124
+	 * @return string ;
125
+	 */
126
+	public function search_box($text, $input_id)
127
+	{
128
+		return '';
129
+	}
130
+
131
+
132
+	/**
133
+	 * Add counts to the _views property
134
+	 *
135
+	 * @throws EE_Error
136
+	 */
137
+	protected function _add_view_counts()
138
+	{
139
+		foreach ($this->_views as $view => $args) {
140
+			$this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
+				$this->_per_page,
142
+				$view,
143
+				true,
144
+				true
145
+			);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * @param EE_Message_Template_Group $item
152
+	 * @return string
153
+	 */
154
+	public function column_cb($item)
155
+	{
156
+		return '';
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param EE_Message_Template_Group $item
162
+	 * @return string
163
+	 * @throws EE_Error
164
+	 */
165
+	public function column_description($item)
166
+	{
167
+		return '<p>' . $item->message_type_obj()->description . '</p>';
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param EE_Message_Template_Group $item
173
+	 * @return string
174
+	 * @throws EE_Error
175
+	 * @throws ReflectionException
176
+	 */
177
+	public function column_messenger($item)
178
+	{
179
+		// Return the name contents
180
+		return sprintf(
181
+			'%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
182
+			/* $1%s */
183
+			ucwords($item->messenger_obj()->label['singular']),
184
+			/* $2%s */
185
+			$item->GRP_ID(),
186
+			/* %4$s */
187
+			$this->_get_context_links($item),
188
+			$this->row_actions($this->_get_actions_for_messenger_column($item))
189
+		);
190
+	}
191
+
192
+
193
+	/**
194
+	 * column_message_type
195
+	 *
196
+	 * @param EE_Message_Template_Group $item message info for the row
197
+	 * @return string message_type name
198
+	 * @throws EE_Error
199
+	 */
200
+	public function column_message_type($item)
201
+	{
202
+		return ucwords($item->message_type_obj()->label['singular']);
203
+	}
204
+
205
+
206
+	/**
207
+	 * Generate dropdown filter select input for messengers
208
+	 *
209
+	 * @param bool $global
210
+	 * @return string
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function _get_messengers_dropdown_filter($global = true)
214
+	{
215
+		$messenger_options                                   = [];
216
+		$active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
217
+			[
218
+				[
219
+					'MTP_is_active' => true,
220
+					'MTP_is_global' => $global,
221
+				],
222
+				'group_by' => 'MTP_messenger',
223
+			]
224
+		);
225
+
226
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
227
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
228
+				$messenger                            = $active_message_template_group->messenger_obj();
229
+				$messenger_name                       = $active_message_template_group->messenger();
230
+				$messenger_label                      = $messenger instanceof EE_messenger
231
+					? $messenger->label['singular']
232
+					: $messenger_name;
233
+				$messenger_options[ $messenger_name ] = ucwords($messenger_label);
234
+			}
235
+		}
236
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
237
+	}
238
+
239
+
240
+	/**
241
+	 * Generate dropdown filter select input for message types
242
+	 *
243
+	 * @param bool $global
244
+	 * @return string
245
+	 * @throws EE_Error
246
+	 */
247
+	protected function _get_message_types_dropdown_filter($global = true)
248
+	{
249
+		$message_type_options                                   = [];
250
+		$active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
251
+			[
252
+				[
253
+					'MTP_is_active' => true,
254
+					'MTP_is_global' => $global,
255
+				],
256
+				'group_by' => 'MTP_message_type',
257
+			]
258
+		);
259
+
260
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
261
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
262
+				$message_type                               = $active_message_template_group->message_type_obj();
263
+				$message_type_name                          = $active_message_template_group->message_type();
264
+				$message_type_label                         = $message_type instanceof EE_message_type
265
+					? $message_type->label['singular']
266
+					: $message_type_name;
267
+				$message_type_options[ $message_type_name ] = ucwords($message_type_label);
268
+			}
269
+		}
270
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
271
+	}
272
+
273
+
274
+	/**
275
+	 * Return the edit url for the message template group.
276
+	 *
277
+	 * @param EE_Message_Template_Group $item
278
+	 * @return string
279
+	 * @throws EE_Error
280
+	 * @throws ReflectionException
281
+	 */
282
+	protected function _get_edit_url(EE_Message_Template_Group $item)
283
+	{
284
+		$edit_url = '';
285
+		// edit link but only if item isn't trashed.
286
+		if (
287
+			! $item->get('MTP_deleted')
288
+			&& EE_Registry::instance()->CAP->current_user_can(
289
+				'ee_edit_message',
290
+				'espresso_messages_edit_message_template',
291
+				$item->ID()
292
+			)
293
+		) {
294
+			$edit_url = EE_Admin_Page::add_query_args_and_nonce(
295
+				[
296
+					'action' => 'edit_message_template',
297
+					'id'     => $item->GRP_ID(),
298
+				],
299
+				EE_MSG_ADMIN_URL
300
+			);
301
+		}
302
+		return $edit_url;
303
+	}
304
+
305
+
306
+	/**
307
+	 * Get the context link string for the messenger column.
308
+	 *
309
+	 * @param EE_Message_Template_Group $item
310
+	 * @return string
311
+	 * @throws EE_Error
312
+	 * @throws ReflectionException
313
+	 */
314
+	protected function _get_context_links(EE_Message_Template_Group $item)
315
+	{
316
+		// first check if we even show the context links or not.
317
+		if (
318
+			! EE_Registry::instance()->CAP->current_user_can(
319
+				'ee_edit_message',
320
+				'espresso_messages_edit_message_template',
321
+				$item->ID()
322
+			)
323
+			|| $item->get('MTP_deleted')
324
+		) {
325
+			return '';
326
+		}
327
+		// we want to display the contexts in here, so we need to set them up
328
+		$c_label           = $item->context_label();
329
+		$c_configs         = $item->contexts_config();
330
+		$context_array     = [];
331
+		$context_templates = $item->context_templates();
332
+		foreach ($context_templates as $context => $template_fields) {
333
+			$mtp_to          = ! empty($template_fields['to'])
334
+							   && $template_fields['to'] instanceof EE_Message_Template
335
+				? $template_fields['to']->get('MTP_content')
336
+				: null;
337
+			$inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
338
+							   || ! $item->is_context_active($context)
339
+				? ' mtp-inactive'
340
+				: '';
341
+			$context_title   = sprintf(
342
+			/* translators: Placeholder represents the context label. Example "Edit Event Admin" */
343
+				esc_html__('Edit %1$s', 'event_espresso'),
344
+				ucwords($c_configs[ $context ]['label'])
345
+			);
346
+			$edit_link       = EE_Admin_Page::add_query_args_and_nonce(
347
+				[
348
+					'action'  => 'edit_message_template',
349
+					'id'      => $item->GRP_ID(),
350
+					'context' => $context,
351
+				],
352
+				EE_MSG_ADMIN_URL
353
+			);
354
+			$context_array[] = '<a href="' . $edit_link . '"'
355
+							   . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
356
+							   . ' aria-label="' . esc_attr__('Edit Context', 'event_espresso') . '">'
357
+							   . $context_title
358
+							   . '</a>';
359
+		}
360
+
361
+		return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
362
+	}
363
+
364
+
365
+	/**
366
+	 * Returns the actions for the messenger column.
367
+	 *
368
+	 * Note: Children classes may override this, so do not remove it.
369
+	 *
370
+	 * @param EE_Message_Template_Group $item
371
+	 * @return array
372
+	 */
373
+	protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
374
+	{
375
+		return [];
376
+	}
377 377
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     protected function _setup_data()
34 34
     {
35
-        $this->_data           = $this->get_admin_page()->get_message_templates(
35
+        $this->_data = $this->get_admin_page()->get_message_templates(
36 36
             $this->_per_page,
37 37
             $this->_view
38 38
         );
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             'ajax'     => true, // for now,
57 57
             'screen'   => $this->get_admin_page()->get_current_screen()->id,
58 58
         ];
59
-        $this->_columns      = [
59
+        $this->_columns = [
60 60
             // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61 61
             'message_type' => esc_html__('Message Type', 'event_espresso'),
62 62
             'messenger'    => esc_html__('Messenger', 'event_espresso'),
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     protected function _add_view_counts()
138 138
     {
139 139
         foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
140
+            $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
141 141
                 $this->_per_page,
142 142
                 $view,
143 143
                 true,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function column_description($item)
166 166
     {
167
-        return '<p>' . $item->message_type_obj()->description . '</p>';
167
+        return '<p>'.$item->message_type_obj()->description.'</p>';
168 168
     }
169 169
 
170 170
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 $messenger_label                      = $messenger instanceof EE_messenger
231 231
                     ? $messenger->label['singular']
232 232
                     : $messenger_name;
233
-                $messenger_options[ $messenger_name ] = ucwords($messenger_label);
233
+                $messenger_options[$messenger_name] = ucwords($messenger_label);
234 234
             }
235 235
         }
236 236
         return $this->get_admin_page()->get_messengers_select_input($messenger_options);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                 $message_type_label                         = $message_type instanceof EE_message_type
265 265
                     ? $message_type->label['singular']
266 266
                     : $message_type_name;
267
-                $message_type_options[ $message_type_name ] = ucwords($message_type_label);
267
+                $message_type_options[$message_type_name] = ucwords($message_type_label);
268 268
             }
269 269
         }
270 270
         return $this->get_admin_page()->get_message_types_select_input($message_type_options);
@@ -330,20 +330,20 @@  discard block
 block discarded – undo
330 330
         $context_array     = [];
331 331
         $context_templates = $item->context_templates();
332 332
         foreach ($context_templates as $context => $template_fields) {
333
-            $mtp_to          = ! empty($template_fields['to'])
333
+            $mtp_to = ! empty($template_fields['to'])
334 334
                                && $template_fields['to'] instanceof EE_Message_Template
335 335
                 ? $template_fields['to']->get('MTP_content')
336 336
                 : null;
337
-            $inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
337
+            $inactive_class = (empty($mtp_to) && ! empty($template_fields['to']))
338 338
                                || ! $item->is_context_active($context)
339 339
                 ? ' mtp-inactive'
340 340
                 : '';
341
-            $context_title   = sprintf(
341
+            $context_title = sprintf(
342 342
             /* translators: Placeholder represents the context label. Example "Edit Event Admin" */
343 343
                 esc_html__('Edit %1$s', 'event_espresso'),
344
-                ucwords($c_configs[ $context ]['label'])
344
+                ucwords($c_configs[$context]['label'])
345 345
             );
346
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
346
+            $edit_link = EE_Admin_Page::add_query_args_and_nonce(
347 347
                 [
348 348
                     'action'  => 'edit_message_template',
349 349
                     'id'      => $item->GRP_ID(),
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
                 ],
352 352
                 EE_MSG_ADMIN_URL
353 353
             );
354
-            $context_array[] = '<a href="' . $edit_link . '"'
355
-                               . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
356
-                               . ' aria-label="' . esc_attr__('Edit Context', 'event_espresso') . '">'
354
+            $context_array[] = '<a href="'.$edit_link.'"'
355
+                               . ' class="'."{$item->message_type()}-{$context}-edit-link{$inactive_class}".'"'
356
+                               . ' aria-label="'.esc_attr__('Edit Context', 'event_espresso').'">'
357 357
                                . $context_title
358 358
                                . '</a>';
359 359
         }
360 360
 
361
-        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
361
+        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $context_array);
362 362
     }
363 363
 
364 364
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function getRegistrationModel()
95 95
     {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
96
+        if ( ! $this->registration_model instanceof EEM_Registration) {
97 97
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98 98
         }
99 99
         return $this->registration_model;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function getAttendeeModel()
111 111
     {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
112
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
113 113
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114 114
         }
115 115
         return $this->attendee_model;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getEventModel()
127 127
     {
128
-        if (! $this->event_model instanceof EEM_Event) {
128
+        if ( ! $this->event_model instanceof EEM_Event) {
129 129
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
130 130
         }
131 131
         return $this->event_model;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function getStatusModel()
143 143
     {
144
-        if (! $this->status_model instanceof EEM_Status) {
144
+        if ( ! $this->status_model instanceof EEM_Status) {
145 145
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
146 146
         }
147 147
         return $this->status_model;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         // style
753 753
         wp_register_style(
754 754
             'espresso_reg',
755
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
755
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
756 756
             ['ee-admin-css'],
757 757
             EVENT_ESPRESSO_VERSION
758 758
         );
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         // script
761 761
         wp_register_script(
762 762
             'espresso_reg',
763
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
763
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
764 764
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
765 765
             EVENT_ESPRESSO_VERSION,
766 766
             true
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
             'att_publish_text' => sprintf(
785 785
             /* translators: The date and time */
786 786
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
787
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
787
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
788 788
             ),
789 789
         ];
790 790
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         wp_dequeue_style('espresso_reg');
816 816
         wp_register_style(
817 817
             'espresso_att',
818
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
818
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
819 819
             ['ee-admin-css'],
820 820
             EVENT_ESPRESSO_VERSION
821 821
         );
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     {
828 828
         wp_register_script(
829 829
             'ee-spco-for-admin',
830
-            REG_ASSETS_URL . 'spco_for_admin.js',
830
+            REG_ASSETS_URL.'spco_for_admin.js',
831 831
             ['underscore', 'jquery'],
832 832
             EVENT_ESPRESSO_VERSION,
833 833
             true
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             'no_approve_registrations' => 'not_approved_registration',
876 876
             'cancel_registrations'     => 'cancelled_registration',
877 877
         ];
878
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
878
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
879 879
             'ee_send_message',
880 880
             'batch_send_messages'
881 881
         );
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
981 981
                 ],
982 982
             ];
983
-            $this->_views['trash']      = [
983
+            $this->_views['trash'] = [
984 984
                 'slug'        => 'trash',
985 985
                 'label'       => esc_html__('Trash', 'event_espresso'),
986 986
                 'count'       => 0,
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
         }
1081 1081
         $sc_items = [
1082 1082
             'approved_status'   => [
1083
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1083
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1084 1084
                 'desc'  => EEH_Template::pretty_status(
1085 1085
                     EEM_Registration::status_id_approved,
1086 1086
                     false,
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
                 ),
1089 1089
             ],
1090 1090
             'pending_status'    => [
1091
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1091
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1092 1092
                 'desc'  => EEH_Template::pretty_status(
1093 1093
                     EEM_Registration::status_id_pending_payment,
1094 1094
                     false,
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
                 ),
1097 1097
             ],
1098 1098
             'wait_list'         => [
1099
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1099
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1100 1100
                 'desc'  => EEH_Template::pretty_status(
1101 1101
                     EEM_Registration::status_id_wait_list,
1102 1102
                     false,
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                 ),
1105 1105
             ],
1106 1106
             'incomplete_status' => [
1107
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1107
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1108 1108
                 'desc'  => EEH_Template::pretty_status(
1109 1109
                     EEM_Registration::status_id_incomplete,
1110 1110
                     false,
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
                 ),
1113 1113
             ],
1114 1114
             'not_approved'      => [
1115
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1115
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1116 1116
                 'desc'  => EEH_Template::pretty_status(
1117 1117
                     EEM_Registration::status_id_not_approved,
1118 1118
                     false,
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                 ),
1121 1121
             ],
1122 1122
             'declined_status'   => [
1123
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1123
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1124 1124
                 'desc'  => EEH_Template::pretty_status(
1125 1125
                     EEM_Registration::status_id_declined,
1126 1126
                     false,
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                 ),
1129 1129
             ],
1130 1130
             'cancelled_status'  => [
1131
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1131
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1132 1132
                 'desc'  => EEH_Template::pretty_status(
1133 1133
                     EEM_Registration::status_id_cancelled,
1134 1134
                     false,
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
                 $EVT_ID
1189 1189
             )
1190 1190
         ) {
1191
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1191
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1192 1192
                 'new_registration',
1193 1193
                 'add-registrant',
1194 1194
                 ['event_id' => $EVT_ID],
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
                 ],
1347 1347
                 REG_ADMIN_URL
1348 1348
             );
1349
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1349
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350 1350
                 [
1351 1351
                     'action' => 'default',
1352 1352
                     'EVT_ID' => $event_id,
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                 ],
1355 1355
                 admin_url('admin.php')
1356 1356
             );
1357
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1357
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1358 1358
                 [
1359 1359
                     'page'   => 'espresso_events',
1360 1360
                     'action' => 'edit',
@@ -1363,12 +1363,12 @@  discard block
 block discarded – undo
1363 1363
                 admin_url('admin.php')
1364 1364
             );
1365 1365
             // next and previous links
1366
-            $next_reg                                      = $this->_registration->next(
1366
+            $next_reg = $this->_registration->next(
1367 1367
                 null,
1368 1368
                 [],
1369 1369
                 'REG_ID'
1370 1370
             );
1371
-            $this->_template_args['next_registration']     = $next_reg
1371
+            $this->_template_args['next_registration'] = $next_reg
1372 1372
                 ? $this->_next_link(
1373 1373
                     EE_Admin_Page::add_query_args_and_nonce(
1374 1374
                         [
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1381 1381
                 )
1382 1382
                 : '';
1383
-            $previous_reg                                  = $this->_registration->previous(
1383
+            $previous_reg = $this->_registration->previous(
1384 1384
                 null,
1385 1385
                 [],
1386 1386
                 'REG_ID'
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
                 )
1399 1399
                 : '';
1400 1400
             // grab header
1401
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1401
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1402 1402
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1403 1403
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1404 1404
                 $template_path,
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
                                 EEH_HTML::strong(
1553 1553
                                     $this->_registration->pretty_status(),
1554 1554
                                     '',
1555
-                                    'status-' . $this->_registration->status_ID(),
1555
+                                    'status-'.$this->_registration->status_ID(),
1556 1556
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1557 1557
                                 )
1558 1558
                             )
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
                 $this->_registration->ID()
1569 1569
             )
1570 1570
         ) {
1571
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1571
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1572 1572
                 $this->_get_reg_statuses(),
1573 1573
                 [
1574 1574
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
                     ),
1586 1586
                 ]
1587 1587
             );
1588
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1588
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1589 1589
                 [
1590 1590
                     'html_class'      => 'button-primary',
1591 1591
                     'html_label_text' => '&nbsp;',
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
     protected function _get_reg_statuses()
1611 1611
     {
1612 1612
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1613
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1613
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1614 1614
         // get current reg status
1615 1615
         $current_status = $this->_registration->status_ID();
1616 1616
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
             $current_status !== EEM_Registration::status_id_pending_payment
1619 1619
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1620 1620
         ) {
1621
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1621
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1622 1622
         }
1623 1623
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1624 1624
     }
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
         $success = false;
1710 1710
         // typecast $REG_IDs
1711 1711
         $REG_IDs = (array) $REG_IDs;
1712
-        if (! empty($REG_IDs)) {
1712
+        if ( ! empty($REG_IDs)) {
1713 1713
             $success = true;
1714 1714
             // set default status if none is passed
1715 1715
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
             $action,
1870 1870
             $notify
1871 1871
         );
1872
-        $method = $action . '_registration';
1872
+        $method = $action.'_registration';
1873 1873
         if (method_exists($this, $method)) {
1874 1874
             $this->$method($notify);
1875 1875
         }
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
         $filters        = new EE_Line_Item_Filter_Collection();
2020 2020
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2021 2021
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2022
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2022
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2023 2023
             $filters,
2024 2024
             $transaction->total_line_item()
2025 2025
         );
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
             $filtered_line_item_tree,
2033 2033
             ['EE_Registration' => $this->_registration]
2034 2034
         );
2035
-        $attendee                                = $this->_registration->attendee();
2035
+        $attendee = $this->_registration->attendee();
2036 2036
         if (
2037 2037
             EE_Registry::instance()->CAP->current_user_can(
2038 2038
                 'ee_read_transaction',
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
                 'Payment method response',
2115 2115
                 'event_espresso'
2116 2116
             );
2117
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2117
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2118 2118
         }
2119 2119
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2120 2120
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2145 2145
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2146 2146
         $template_path                                                        =
2147
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2147
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2148 2148
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2149 2149
     }
2150 2150
 
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2183 2183
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2184 2184
             $template_path                                     =
2185
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2185
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2186 2186
             EEH_Template::display_template($template_path, $this->_template_args);
2187 2187
         }
2188 2188
     }
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
     public function form_before_question_group($output)
2199 2199
     {
2200 2200
         EE_Error::doing_it_wrong(
2201
-            __CLASS__ . '::' . __FUNCTION__,
2201
+            __CLASS__.'::'.__FUNCTION__,
2202 2202
             esc_html__(
2203 2203
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2204 2204
                 'event_espresso'
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
     public function form_after_question_group($output)
2223 2223
     {
2224 2224
         EE_Error::doing_it_wrong(
2225
-            __CLASS__ . '::' . __FUNCTION__,
2225
+            __CLASS__.'::'.__FUNCTION__,
2226 2226
             esc_html__(
2227 2227
                 '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.',
2228 2228
                 'event_espresso'
@@ -2259,7 +2259,7 @@  discard block
 block discarded – undo
2259 2259
     public function form_form_field_label_wrap($label)
2260 2260
     {
2261 2261
         EE_Error::doing_it_wrong(
2262
-            __CLASS__ . '::' . __FUNCTION__,
2262
+            __CLASS__.'::'.__FUNCTION__,
2263 2263
             esc_html__(
2264 2264
                 '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.',
2265 2265
                 'event_espresso'
@@ -2269,7 +2269,7 @@  discard block
 block discarded – undo
2269 2269
         return '
2270 2270
 			<tr>
2271 2271
 				<th>
2272
-					' . $label . '
2272
+					' . $label.'
2273 2273
 				</th>';
2274 2274
     }
2275 2275
 
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
     public function form_form_field_input__wrap($input)
2285 2285
     {
2286 2286
         EE_Error::doing_it_wrong(
2287
-            __CLASS__ . '::' . __FUNCTION__,
2287
+            __CLASS__.'::'.__FUNCTION__,
2288 2288
             esc_html__(
2289 2289
                 '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.',
2290 2290
                 'event_espresso'
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
         );
2294 2294
         return '
2295 2295
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2296
-					' . $input . '
2296
+					' . $input.'
2297 2297
 				</td>
2298 2298
 			</tr>';
2299 2299
     }
@@ -2342,8 +2342,8 @@  discard block
 block discarded – undo
2342 2342
      */
2343 2343
     protected function _get_reg_custom_questions_form($REG_ID)
2344 2344
     {
2345
-        if (! $this->_reg_custom_questions_form) {
2346
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2345
+        if ( ! $this->_reg_custom_questions_form) {
2346
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2347 2347
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2348 2348
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2349 2349
             );
@@ -2366,7 +2366,7 @@  discard block
 block discarded – undo
2366 2366
      */
2367 2367
     private function _save_reg_custom_questions_form($REG_ID = 0)
2368 2368
     {
2369
-        if (! $REG_ID) {
2369
+        if ( ! $REG_ID) {
2370 2370
             EE_Error::add_error(
2371 2371
                 esc_html__(
2372 2372
                     'An error occurred. No registration ID was received.',
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
         if ($form->is_valid()) {
2384 2384
             foreach ($form->subforms() as $question_group_form) {
2385 2385
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2386
-                    $where_conditions    = [
2386
+                    $where_conditions = [
2387 2387
                         'QST_ID' => $question_id,
2388 2388
                         'REG_ID' => $REG_ID,
2389 2389
                     ];
@@ -2424,7 +2424,7 @@  discard block
 block discarded – undo
2424 2424
         $REG = $this->getRegistrationModel();
2425 2425
         // get all other registrations on this transaction, and cache
2426 2426
         // the attendees for them so we don't have to run another query using force_join
2427
-        $registrations                           = $REG->get_all(
2427
+        $registrations = $REG->get_all(
2428 2428
             [
2429 2429
                 [
2430 2430
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2458,23 +2458,23 @@  discard block
 block discarded – undo
2458 2458
                 $attendee                                                      = $registration->attendee()
2459 2459
                     ? $registration->attendee()
2460 2460
                     : $this->getAttendeeModel()->create_default_object();
2461
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2461
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2462
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2463
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2464
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2465
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2466
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2467 2467
                     ', ',
2468 2468
                     $attendee->full_address_as_array()
2469 2469
                 );
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2470
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2471 2471
                     [
2472 2472
                         'action' => 'edit_attendee',
2473 2473
                         'post'   => $attendee->ID(),
2474 2474
                     ],
2475 2475
                     REG_ADMIN_URL
2476 2476
                 );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2477
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2478 2478
                     $registration->event_obj() instanceof EE_Event
2479 2479
                         ? $registration->event_obj()->name()
2480 2480
                         : '';
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
             }
2483 2483
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2484 2484
         }
2485
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2485
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2486 2486
         EEH_Template::display_template($template_path, $this->_template_args);
2487 2487
     }
2488 2488
 
@@ -2508,11 +2508,11 @@  discard block
 block discarded – undo
2508 2508
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2509 2509
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2510 2510
         // primary registration object (that way we know if we need to show create button or not)
2511
-        if (! $this->_registration->is_primary_registrant()) {
2511
+        if ( ! $this->_registration->is_primary_registrant()) {
2512 2512
             $primary_registration = $this->_registration->get_primary_registration();
2513 2513
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2514 2514
                 : null;
2515
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2515
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2516 2516
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2517 2517
                 // custom attendee object so let's not worry about the primary reg.
2518 2518
                 $primary_registration = null;
@@ -2527,7 +2527,7 @@  discard block
 block discarded – undo
2527 2527
         $this->_template_args['phone']             = $attendee->phone();
2528 2528
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2529 2529
         // edit link
2530
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2530
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2531 2531
             [
2532 2532
                 'action' => 'edit_attendee',
2533 2533
                 'post'   => $attendee->ID(),
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
         );
2537 2537
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2538 2538
         // create link
2539
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2539
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2540 2540
             ? EE_Admin_Page::add_query_args_and_nonce(
2541 2541
                 [
2542 2542
                     'action'  => 'duplicate_attendee',
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2548 2548
         $this->_template_args['att_check']    = $att_check;
2549 2549
         $template_path                        =
2550
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2550
+            REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2551 2551
         EEH_Template::display_template($template_path, $this->_template_args);
2552 2552
     }
2553 2553
 
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
             /** @var EE_Registration $REG */
2592 2592
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2593 2593
             $payments = $REG->registration_payments();
2594
-            if (! empty($payments)) {
2594
+            if ( ! empty($payments)) {
2595 2595
                 $name           = $REG->attendee() instanceof EE_Attendee
2596 2596
                     ? $REG->attendee()->full_name()
2597 2597
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2655,17 +2655,17 @@  discard block
 block discarded – undo
2655 2655
         // Checkboxes
2656 2656
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2657 2657
 
2658
-        if (! empty($REG_IDs)) {
2658
+        if ( ! empty($REG_IDs)) {
2659 2659
             // if array has more than one element than success message should be plural
2660 2660
             $success = count($REG_IDs) > 1 ? 2 : 1;
2661 2661
             // cycle thru checkboxes
2662 2662
             foreach ($REG_IDs as $REG_ID) {
2663 2663
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2664
-                if (! $REG instanceof EE_Registration) {
2664
+                if ( ! $REG instanceof EE_Registration) {
2665 2665
                     continue;
2666 2666
                 }
2667 2667
                 $deleted = $this->_delete_registration($REG);
2668
-                if (! $deleted) {
2668
+                if ( ! $deleted) {
2669 2669
                     $success = 0;
2670 2670
                 }
2671 2671
             }
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2703 2703
         // registrations on the transaction that are NOT trashed.
2704 2704
         $TXN = $REG->get_first_related('Transaction');
2705
-        if (! $TXN instanceof EE_Transaction) {
2705
+        if ( ! $TXN instanceof EE_Transaction) {
2706 2706
             EE_Error::add_error(
2707 2707
                 sprintf(
2708 2708
                     esc_html__(
@@ -2720,11 +2720,11 @@  discard block
 block discarded – undo
2720 2720
         $REGS        = $TXN->get_many_related('Registration');
2721 2721
         $all_trashed = true;
2722 2722
         foreach ($REGS as $registration) {
2723
-            if (! $registration->get('REG_deleted')) {
2723
+            if ( ! $registration->get('REG_deleted')) {
2724 2724
                 $all_trashed = false;
2725 2725
             }
2726 2726
         }
2727
-        if (! $all_trashed) {
2727
+        if ( ! $all_trashed) {
2728 2728
             EE_Error::add_error(
2729 2729
                 esc_html__(
2730 2730
                     '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.',
@@ -2786,7 +2786,7 @@  discard block
 block discarded – undo
2786 2786
      */
2787 2787
     public function new_registration()
2788 2788
     {
2789
-        if (! $this->_set_reg_event()) {
2789
+        if ( ! $this->_set_reg_event()) {
2790 2790
             throw new EE_Error(
2791 2791
                 esc_html__(
2792 2792
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2818,7 +2818,7 @@  discard block
 block discarded – undo
2818 2818
                 ],
2819 2819
                 EVENTS_ADMIN_URL
2820 2820
             );
2821
-            $edit_event_lnk                     = '<a href="'
2821
+            $edit_event_lnk = '<a href="'
2822 2822
                                                   . $edit_event_url
2823 2823
                                                   . '" aria-label="'
2824 2824
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2836,7 +2836,7 @@  discard block
 block discarded – undo
2836 2836
         }
2837 2837
         // grab header
2838 2838
         $template_path                              =
2839
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2839
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2840 2840
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2841 2841
             $template_path,
2842 2842
             $this->_template_args,
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
                 '</b>'
2878 2878
             );
2879 2879
             return '
2880
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2880
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2881 2881
 	<script >
2882 2882
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2883 2883
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2919,7 +2919,7 @@  discard block
 block discarded – undo
2919 2919
                 );
2920 2920
                 $template_args['content']                          =
2921 2921
                     EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2922
-                $template_args['content']                          .= '</div>';
2922
+                $template_args['content'] .= '</div>';
2923 2923
                 $template_args['step_button_text']                 = esc_html__(
2924 2924
                     'Add Tickets and Continue to Registrant Details',
2925 2925
                     'event_espresso'
@@ -2946,7 +2946,7 @@  discard block
 block discarded – undo
2946 2946
         // we come back to the process_registration_step route.
2947 2947
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2948 2948
         return EEH_Template::display_template(
2949
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2949
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2950 2950
             $template_args,
2951 2951
             true
2952 2952
         );
@@ -2969,7 +2969,7 @@  discard block
 block discarded – undo
2969 2969
         }
2970 2970
 
2971 2971
         $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2972
-        if (! $EVT_ID) {
2972
+        if ( ! $EVT_ID) {
2973 2973
             return false;
2974 2974
         }
2975 2975
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3039,7 +3039,7 @@  discard block
 block discarded – undo
3039 3039
                 }
3040 3040
                 break;
3041 3041
             case 'questions':
3042
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3042
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3043 3043
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3044 3044
                 }
3045 3045
                 // process registration
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
                         $grand_total->save_this_and_descendants_to_txn();
3051 3051
                     }
3052 3052
                 }
3053
-                if (! $transaction instanceof EE_Transaction) {
3053
+                if ( ! $transaction instanceof EE_Transaction) {
3054 3054
                     $query_args = [
3055 3055
                         'action'                  => 'new_registration',
3056 3056
                         'processing_registration' => 2,
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
                     return;
3073 3073
                 }
3074 3074
                 // maybe update status, and make sure to save transaction if not done already
3075
-                if (! $transaction->update_status_based_on_total_paid()) {
3075
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3076 3076
                     $transaction->save();
3077 3077
                 }
3078 3078
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3154,7 +3154,7 @@  discard block
 block discarded – undo
3154 3154
     public function get_attendees($per_page, $count = false, $trash = false)
3155 3155
     {
3156 3156
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3157
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3157
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3158 3158
         $orderby = $this->request->getRequestParam('orderby');
3159 3159
         switch ($orderby) {
3160 3160
             case 'ATT_ID':
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
         $_where       = [];
3178 3178
         $search_term  = $this->request->getRequestParam('s');
3179 3179
         if ($search_term) {
3180
-            $search_term  = '%' . $search_term . '%';
3180
+            $search_term  = '%'.$search_term.'%';
3181 3181
             $_where['OR'] = [
3182 3182
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3183 3183
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3204,7 +3204,7 @@  discard block
 block discarded – undo
3204 3204
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3205 3205
             'limit'         => $limit,
3206 3206
         ];
3207
-        if (! $count) {
3207
+        if ( ! $count) {
3208 3208
             $query_args['order_by'] = [$orderby => $sort];
3209 3209
         }
3210 3210
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3249,9 +3249,9 @@  discard block
 block discarded – undo
3249 3249
         $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3250 3250
             ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3251 3251
             : null;
3252
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3252
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3253 3253
             $filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3254
-            $report_params  = $this->$method_name_for_getting_query_params($filters);
3254
+            $report_params = $this->$method_name_for_getting_query_params($filters);
3255 3255
             wp_redirect(
3256 3256
                 EE_Admin_Page::add_query_args_and_nonce(
3257 3257
                     [
@@ -3276,8 +3276,8 @@  discard block
 block discarded – undo
3276 3276
             ];
3277 3277
             // Merge required request args, overriding any currently set
3278 3278
             $request_args = array_merge($request_args, $required_request_args);
3279
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3280
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3279
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3280
+                require_once(EE_CLASSES.'EE_Export.class.php');
3281 3281
                 $EE_Export = EE_Export::instance($request_args);
3282 3282
                 $EE_Export->export();
3283 3283
             }
@@ -3298,8 +3298,8 @@  discard block
 block discarded – undo
3298 3298
 
3299 3299
     public function _contact_list_export()
3300 3300
     {
3301
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3302
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3301
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3302
+            require_once(EE_CLASSES.'EE_Export.class.php');
3303 3303
             $EE_Export = EE_Export::instance($this->request->requestParams());
3304 3304
             $EE_Export->export_attendees();
3305 3305
         }
@@ -3308,7 +3308,7 @@  discard block
 block discarded – undo
3308 3308
 
3309 3309
     public function _contact_list_report()
3310 3310
     {
3311
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3311
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3312 3312
             wp_redirect(
3313 3313
                 EE_Admin_Page::add_query_args_and_nonce(
3314 3314
                     [
@@ -3320,8 +3320,8 @@  discard block
 block discarded – undo
3320 3320
                 )
3321 3321
             );
3322 3322
         } else {
3323
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3324
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3323
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3324
+                require_once(EE_CLASSES.'EE_Export.class.php');
3325 3325
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3326 3326
                 $EE_Export->report_attendees();
3327 3327
             }
@@ -3348,7 +3348,7 @@  discard block
 block discarded – undo
3348 3348
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3349 3349
         $action = $this->request->getRequestParam('return', 'default');
3350 3350
         // verify we have necessary info
3351
-        if (! $REG_ID) {
3351
+        if ( ! $REG_ID) {
3352 3352
             EE_Error::add_error(
3353 3353
                 esc_html__(
3354 3354
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3363,7 +3363,7 @@  discard block
 block discarded – undo
3363 3363
         }
3364 3364
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3365 3365
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3366
-        if (! $registration instanceof EE_Registration) {
3366
+        if ( ! $registration instanceof EE_Registration) {
3367 3367
             throw new RuntimeException(
3368 3368
                 sprintf(
3369 3369
                     esc_html__(
@@ -3502,16 +3502,16 @@  discard block
 block discarded – undo
3502 3502
         $this->verify_cpt_object();
3503 3503
         remove_meta_box(
3504 3504
             'postexcerpt',
3505
-            $this->_cpt_routes[ $this->_req_action ],
3505
+            $this->_cpt_routes[$this->_req_action],
3506 3506
             'normal'
3507 3507
         );
3508
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3508
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3509 3509
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3510 3510
             add_meta_box(
3511 3511
                 'postexcerpt',
3512 3512
                 esc_html__('Short Biography', 'event_espresso'),
3513 3513
                 'post_excerpt_meta_box',
3514
-                $this->_cpt_routes[ $this->_req_action ],
3514
+                $this->_cpt_routes[$this->_req_action],
3515 3515
                 'normal'
3516 3516
             );
3517 3517
         }
@@ -3520,7 +3520,7 @@  discard block
 block discarded – undo
3520 3520
                 'commentsdiv',
3521 3521
                 esc_html__('Notes on the Contact', 'event_espresso'),
3522 3522
                 'post_comment_meta_box',
3523
-                $this->_cpt_routes[ $this->_req_action ],
3523
+                $this->_cpt_routes[$this->_req_action],
3524 3524
                 'normal',
3525 3525
                 'core'
3526 3526
             );
@@ -3529,7 +3529,7 @@  discard block
 block discarded – undo
3529 3529
             'attendee_contact_info',
3530 3530
             esc_html__('Contact Info', 'event_espresso'),
3531 3531
             [$this, 'attendee_contact_info'],
3532
-            $this->_cpt_routes[ $this->_req_action ],
3532
+            $this->_cpt_routes[$this->_req_action],
3533 3533
             'side',
3534 3534
             'core'
3535 3535
         );
@@ -3537,7 +3537,7 @@  discard block
 block discarded – undo
3537 3537
             'attendee_details_address',
3538 3538
             esc_html__('Address Details', 'event_espresso'),
3539 3539
             [$this, 'attendee_address_details'],
3540
-            $this->_cpt_routes[ $this->_req_action ],
3540
+            $this->_cpt_routes[$this->_req_action],
3541 3541
             'normal',
3542 3542
             'core'
3543 3543
         );
@@ -3545,7 +3545,7 @@  discard block
 block discarded – undo
3545 3545
             'attendee_registrations',
3546 3546
             esc_html__('Registrations for this Contact', 'event_espresso'),
3547 3547
             [$this, 'attendee_registrations_meta_box'],
3548
-            $this->_cpt_routes[ $this->_req_action ],
3548
+            $this->_cpt_routes[$this->_req_action],
3549 3549
             'normal',
3550 3550
             'high'
3551 3551
         );
@@ -3646,8 +3646,8 @@  discard block
 block discarded – undo
3646 3646
                 ]
3647 3647
             )
3648 3648
         );
3649
-        $template                             =
3650
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3649
+        $template =
3650
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3651 3651
         EEH_Template::display_template($template, $this->_template_args);
3652 3652
     }
3653 3653
 
@@ -3669,7 +3669,7 @@  discard block
 block discarded – undo
3669 3669
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3670 3670
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3671 3671
         $template                              =
3672
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3672
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3673 3673
         EEH_Template::display_template($template, $this->_template_args);
3674 3674
     }
3675 3675
 
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
     public function after_title_form_fields($post)
3685 3685
     {
3686 3686
         if ($post->post_type === 'espresso_attendees') {
3687
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3687
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3688 3688
             $template_args['attendee'] = $this->_cpt_model_obj;
3689 3689
             EEH_Template::display_template($template, $template_args);
3690 3690
         }
@@ -3713,7 +3713,7 @@  discard block
 block discarded – undo
3713 3713
             // cycle thru checkboxes
3714 3714
             foreach ($ATT_IDs as $ATT_ID) {
3715 3715
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3716
-                if (! $updated) {
3716
+                if ( ! $updated) {
3717 3717
                     $success = 0;
3718 3718
                 }
3719 3719
             }
Please login to merge, or discard this patch.
Indentation   +3680 added lines, -3680 removed lines patch added patch discarded remove patch
@@ -21,2225 +21,2225 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
23 23
 {
24
-    /**
25
-     * @var EE_Registration
26
-     */
27
-    private $_registration;
28
-
29
-    /**
30
-     * @var EE_Event
31
-     */
32
-    private $_reg_event;
33
-
34
-    /**
35
-     * @var EE_Session
36
-     */
37
-    private $_session;
38
-
39
-    /**
40
-     * @var array
41
-     */
42
-    private static $_reg_status;
43
-
44
-    /**
45
-     * Form for displaying the custom questions for this registration.
46
-     * This gets used a few times throughout the request so its best to cache it
47
-     *
48
-     * @var EE_Registration_Custom_Questions_Form
49
-     */
50
-    protected $_reg_custom_questions_form = null;
51
-
52
-    /**
53
-     * @var EEM_Registration $registration_model
54
-     */
55
-    private $registration_model;
56
-
57
-    /**
58
-     * @var EEM_Attendee $attendee_model
59
-     */
60
-    private $attendee_model;
61
-
62
-    /**
63
-     * @var EEM_Event $event_model
64
-     */
65
-    private $event_model;
66
-
67
-    /**
68
-     * @var EEM_Status $status_model
69
-     */
70
-    private $status_model;
71
-
72
-
73
-    /**
74
-     * @param bool $routing
75
-     * @throws EE_Error
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidInterfaceException
79
-     * @throws ReflectionException
80
-     */
81
-    public function __construct($routing = true)
82
-    {
83
-        parent::__construct($routing);
84
-        add_action('wp_loaded', [$this, 'wp_loaded']);
85
-    }
86
-
87
-
88
-    /**
89
-     * @return EEM_Registration
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     * @since 4.10.2.p
94
-     */
95
-    protected function getRegistrationModel()
96
-    {
97
-        if (! $this->registration_model instanceof EEM_Registration) {
98
-            $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
99
-        }
100
-        return $this->registration_model;
101
-    }
102
-
103
-
104
-    /**
105
-     * @return EEM_Attendee
106
-     * @throws InvalidArgumentException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     * @since 4.10.2.p
110
-     */
111
-    protected function getAttendeeModel()
112
-    {
113
-        if (! $this->attendee_model instanceof EEM_Attendee) {
114
-            $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
115
-        }
116
-        return $this->attendee_model;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return EEM_Event
122
-     * @throws InvalidArgumentException
123
-     * @throws InvalidDataTypeException
124
-     * @throws InvalidInterfaceException
125
-     * @since 4.10.2.p
126
-     */
127
-    protected function getEventModel()
128
-    {
129
-        if (! $this->event_model instanceof EEM_Event) {
130
-            $this->event_model = $this->getLoader()->getShared('EEM_Event');
131
-        }
132
-        return $this->event_model;
133
-    }
134
-
135
-
136
-    /**
137
-     * @return EEM_Status
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidInterfaceException
141
-     * @since 4.10.2.p
142
-     */
143
-    protected function getStatusModel()
144
-    {
145
-        if (! $this->status_model instanceof EEM_Status) {
146
-            $this->status_model = $this->getLoader()->getShared('EEM_Status');
147
-        }
148
-        return $this->status_model;
149
-    }
150
-
151
-
152
-    public function wp_loaded()
153
-    {
154
-        // when adding a new registration...
155
-        $action = $this->request->getRequestParam('action');
156
-        if ($action === 'new_registration') {
157
-            EE_System::do_not_cache();
158
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
159
-                // and it's NOT the attendee information reg step
160
-                // force cookie expiration by setting time to last week
161
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
162
-                // and update the global
163
-                $_COOKIE['ee_registration_added'] = 0;
164
-            }
165
-        }
166
-    }
167
-
168
-
169
-    protected function _init_page_props()
170
-    {
171
-        $this->page_slug        = REG_PG_SLUG;
172
-        $this->_admin_base_url  = REG_ADMIN_URL;
173
-        $this->_admin_base_path = REG_ADMIN;
174
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
175
-        $this->_cpt_routes      = [
176
-            'add_new_attendee' => 'espresso_attendees',
177
-            'edit_attendee'    => 'espresso_attendees',
178
-            'insert_attendee'  => 'espresso_attendees',
179
-            'update_attendee'  => 'espresso_attendees',
180
-        ];
181
-        $this->_cpt_model_names = [
182
-            'add_new_attendee' => 'EEM_Attendee',
183
-            'edit_attendee'    => 'EEM_Attendee',
184
-        ];
185
-        $this->_cpt_edit_routes = [
186
-            'espresso_attendees' => 'edit_attendee',
187
-        ];
188
-        $this->_pagenow_map     = [
189
-            'add_new_attendee' => 'post-new.php',
190
-            'edit_attendee'    => 'post.php',
191
-            'trash'            => 'post.php',
192
-        ];
193
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
194
-        // add filters so that the comment urls don't take users to a confusing 404 page
195
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
196
-    }
197
-
198
-
199
-    /**
200
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
201
-     * @param WP_Comment $comment The current comment object.
202
-     * @return string
203
-     */
204
-    public function clear_comment_link($link, WP_Comment $comment)
205
-    {
206
-        // gotta make sure this only happens on this route
207
-        $post_type = get_post_type($comment->comment_post_ID);
208
-        if ($post_type === 'espresso_attendees') {
209
-            return '#commentsdiv';
210
-        }
211
-        return $link;
212
-    }
213
-
214
-
215
-    protected function _ajax_hooks()
216
-    {
217
-        // todo: all hooks for registrations ajax goes in here
218
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
219
-    }
220
-
221
-
222
-    protected function _define_page_props()
223
-    {
224
-        $this->_admin_page_title = $this->page_label;
225
-        $this->_labels           = [
226
-            'buttons'                      => [
227
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
228
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
229
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
230
-                'csv_reg_report'      => esc_html__('Registrations 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'       => [$this, '_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'       => [$this, '_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
-                'qtips'         => ['Registration_List_Table_Tips'],
573
-                'list_table'    => 'EE_Registrations_List_Table',
574
-                'require_nonce' => false,
575
-            ],
576
-            'view_registration' => [
577
-                'nav'           => [
578
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
579
-                    'order'      => 15,
580
-                    'url'        => $REG_ID
581
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
-                        : $this->_admin_base_url,
583
-                    'persistent' => false,
584
-                ],
585
-                'help_tabs'     => [
586
-                    'registrations_details_help_tab'                    => [
587
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
588
-                        'filename' => 'registrations_details',
589
-                    ],
590
-                    'registrations_details_table_help_tab'              => [
591
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
-                        'filename' => 'registrations_details_table',
593
-                    ],
594
-                    'registrations_details_form_answers_help_tab'       => [
595
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
-                        'filename' => 'registrations_details_form_answers',
597
-                    ],
598
-                    'registrations_details_registrant_details_help_tab' => [
599
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
600
-                        'filename' => 'registrations_details_registrant_details',
601
-                    ],
602
-                ],
603
-                'metaboxes'     => array_merge(
604
-                    $this->_default_espresso_metaboxes,
605
-                    ['_registration_details_metaboxes']
606
-                ),
607
-                'require_nonce' => false,
608
-            ],
609
-            'new_registration'  => [
610
-                'nav'           => [
611
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
-                    'url'        => '#',
613
-                    'order'      => 15,
614
-                    'persistent' => false,
615
-                ],
616
-                'metaboxes'     => $this->_default_espresso_metaboxes,
617
-                'labels'        => [
618
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
-                ],
620
-                'require_nonce' => false,
621
-            ],
622
-            'add_new_attendee'  => [
623
-                'nav'           => [
624
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
625
-                    'order'      => 15,
626
-                    'persistent' => false,
627
-                ],
628
-                'metaboxes'     => array_merge(
629
-                    $this->_default_espresso_metaboxes,
630
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
631
-                ),
632
-                'require_nonce' => false,
633
-            ],
634
-            'edit_attendee'     => [
635
-                'nav'           => [
636
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
-                    'order'      => 15,
638
-                    'persistent' => false,
639
-                    'url'        => $ATT_ID
640
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
-                        : $this->_admin_base_url,
642
-                ],
643
-                'metaboxes'     => ['attendee_editor_metaboxes'],
644
-                'require_nonce' => false,
645
-            ],
646
-            'contact_list'      => [
647
-                'nav'           => [
648
-                    'label' => esc_html__('Contact List', 'event_espresso'),
649
-                    'order' => 20,
650
-                ],
651
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
652
-                'help_tabs'     => [
653
-                    'registrations_contact_list_help_tab'                       => [
654
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
655
-                        'filename' => 'registrations_contact_list',
656
-                    ],
657
-                    'registrations_contact-list_table_column_headings_help_tab' => [
658
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
659
-                        'filename' => 'registrations_contact_list_table_column_headings',
660
-                    ],
661
-                    'registrations_contact_list_views_help_tab'                 => [
662
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
663
-                        'filename' => 'registrations_contact_list_views',
664
-                    ],
665
-                    'registrations_contact_list_other_help_tab'                 => [
666
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
667
-                        'filename' => 'registrations_contact_list_other',
668
-                    ],
669
-                ],
670
-                'metaboxes'     => [],
671
-                'require_nonce' => false,
672
-            ],
673
-            // override default cpt routes
674
-            'create_new'        => '',
675
-            'edit'              => '',
676
-        ];
677
-    }
678
-
679
-
680
-    /**
681
-     * The below methods aren't used by this class currently
682
-     */
683
-    protected function _add_screen_options()
684
-    {
685
-    }
686
-
687
-
688
-    protected function _add_feature_pointers()
689
-    {
690
-    }
691
-
692
-
693
-    public function admin_init()
694
-    {
695
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
696
-            'click "Update Registration Questions" to save your changes',
697
-            'event_espresso'
698
-        );
699
-    }
700
-
701
-
702
-    public function admin_notices()
703
-    {
704
-    }
705
-
706
-
707
-    public function admin_footer_scripts()
708
-    {
709
-    }
710
-
711
-
712
-    /**
713
-     * get list of registration statuses
714
-     *
715
-     * @return void
716
-     * @throws EE_Error
717
-     */
718
-    private function _get_registration_status_array()
719
-    {
720
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
721
-    }
722
-
723
-
724
-    /**
725
-     * @throws InvalidArgumentException
726
-     * @throws InvalidDataTypeException
727
-     * @throws InvalidInterfaceException
728
-     * @since 4.10.2.p
729
-     */
730
-    protected function _add_screen_options_default()
731
-    {
732
-        $this->_per_page_screen_option();
733
-    }
734
-
735
-
736
-    /**
737
-     * @throws InvalidArgumentException
738
-     * @throws InvalidDataTypeException
739
-     * @throws InvalidInterfaceException
740
-     * @since 4.10.2.p
741
-     */
742
-    protected function _add_screen_options_contact_list()
743
-    {
744
-        $page_title              = $this->_admin_page_title;
745
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
746
-        $this->_per_page_screen_option();
747
-        $this->_admin_page_title = $page_title;
748
-    }
749
-
750
-
751
-    public function load_scripts_styles()
752
-    {
753
-        // style
754
-        wp_register_style(
755
-            'espresso_reg',
756
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
757
-            ['ee-admin-css'],
758
-            EVENT_ESPRESSO_VERSION
759
-        );
760
-        wp_enqueue_style('espresso_reg');
761
-        // script
762
-        wp_register_script(
763
-            'espresso_reg',
764
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
765
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
766
-            EVENT_ESPRESSO_VERSION,
767
-            true
768
-        );
769
-        wp_enqueue_script('espresso_reg');
770
-    }
771
-
772
-
773
-    /**
774
-     * @throws EE_Error
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidDataTypeException
777
-     * @throws InvalidInterfaceException
778
-     * @throws ReflectionException
779
-     * @since 4.10.2.p
780
-     */
781
-    public function load_scripts_styles_edit_attendee()
782
-    {
783
-        // stuff to only show up on our attendee edit details page.
784
-        $attendee_details_translations = [
785
-            'att_publish_text' => sprintf(
786
-            /* translators: The date and time */
787
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
788
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
789
-            ),
790
-        ];
791
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
792
-        wp_enqueue_script('jquery-validate');
793
-    }
794
-
795
-
796
-    /**
797
-     * @throws EE_Error
798
-     * @throws InvalidArgumentException
799
-     * @throws InvalidDataTypeException
800
-     * @throws InvalidInterfaceException
801
-     * @throws ReflectionException
802
-     * @since 4.10.2.p
803
-     */
804
-    public function load_scripts_styles_view_registration()
805
-    {
806
-        // styles
807
-        wp_enqueue_style('espresso-ui-theme');
808
-        // scripts
809
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
810
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
811
-    }
812
-
813
-
814
-    public function load_scripts_styles_contact_list()
815
-    {
816
-        wp_dequeue_style('espresso_reg');
817
-        wp_register_style(
818
-            'espresso_att',
819
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
820
-            ['ee-admin-css'],
821
-            EVENT_ESPRESSO_VERSION
822
-        );
823
-        wp_enqueue_style('espresso_att');
824
-    }
825
-
826
-
827
-    public function load_scripts_styles_new_registration()
828
-    {
829
-        wp_register_script(
830
-            'ee-spco-for-admin',
831
-            REG_ASSETS_URL . 'spco_for_admin.js',
832
-            ['underscore', 'jquery'],
833
-            EVENT_ESPRESSO_VERSION,
834
-            true
835
-        );
836
-        wp_enqueue_script('ee-spco-for-admin');
837
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
838
-        EE_Form_Section_Proper::wp_enqueue_scripts();
839
-        EED_Ticket_Selector::load_tckt_slctr_assets();
840
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
841
-    }
842
-
843
-
844
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
845
-    {
846
-        add_filter('FHEE_load_EE_messages', '__return_true');
847
-    }
848
-
849
-
850
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
851
-    {
852
-        add_filter('FHEE_load_EE_messages', '__return_true');
853
-    }
854
-
855
-
856
-    /**
857
-     * @throws EE_Error
858
-     * @throws InvalidArgumentException
859
-     * @throws InvalidDataTypeException
860
-     * @throws InvalidInterfaceException
861
-     * @throws ReflectionException
862
-     * @since 4.10.2.p
863
-     */
864
-    protected function _set_list_table_views_default()
865
-    {
866
-        // for notification related bulk actions we need to make sure only active messengers have an option.
867
-        EED_Messages::set_autoloaders();
868
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
869
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
870
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
871
-        // key= bulk_action_slug, value= message type.
872
-        $match_array = [
873
-            'approve_registrations'    => 'registration',
874
-            'decline_registrations'    => 'declined_registration',
875
-            'pending_registrations'    => 'pending_approval',
876
-            'no_approve_registrations' => 'not_approved_registration',
877
-            'cancel_registrations'     => 'cancelled_registration',
878
-        ];
879
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
880
-            'ee_send_message',
881
-            'batch_send_messages'
882
-        );
883
-        /** setup reg status bulk actions **/
884
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
885
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
886
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
887
-                'Approve and Notify Registrations',
888
-                'event_espresso'
889
-            );
890
-        }
891
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
892
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
893
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
894
-                'Decline and Notify Registrations',
895
-                'event_espresso'
896
-            );
897
-        }
898
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
899
-            'Set Registrations to Pending Payment',
900
-            'event_espresso'
901
-        );
902
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
903
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
904
-                'Set Registrations to Pending Payment and Notify',
905
-                'event_espresso'
906
-            );
907
-        }
908
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
909
-            'Set Registrations to Not Approved',
910
-            'event_espresso'
911
-        );
912
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
913
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
914
-                'Set Registrations to Not Approved and Notify',
915
-                'event_espresso'
916
-            );
917
-        }
918
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
919
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
920
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
921
-                'Cancel Registrations and Notify',
922
-                'event_espresso'
923
-            );
924
-        }
925
-        $def_reg_status_actions = apply_filters(
926
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
927
-            $def_reg_status_actions,
928
-            $active_mts,
929
-            $can_send
930
-        );
931
-
932
-        $this->_views = [
933
-            'all'   => [
934
-                'slug'        => 'all',
935
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
936
-                'count'       => 0,
937
-                'bulk_action' => array_merge(
938
-                    $def_reg_status_actions,
939
-                    [
940
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
941
-                    ]
942
-                ),
943
-            ],
944
-            'month' => [
945
-                'slug'        => 'month',
946
-                'label'       => esc_html__('This Month', 'event_espresso'),
947
-                'count'       => 0,
948
-                'bulk_action' => array_merge(
949
-                    $def_reg_status_actions,
950
-                    [
951
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
952
-                    ]
953
-                ),
954
-            ],
955
-            'today' => [
956
-                'slug'        => 'today',
957
-                'label'       => sprintf(
958
-                    esc_html__('Today - %s', 'event_espresso'),
959
-                    date('M d, Y', current_time('timestamp'))
960
-                ),
961
-                'count'       => 0,
962
-                'bulk_action' => array_merge(
963
-                    $def_reg_status_actions,
964
-                    [
965
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
966
-                    ]
967
-                ),
968
-            ],
969
-        ];
970
-        if (
971
-            EE_Registry::instance()->CAP->current_user_can(
972
-                'ee_delete_registrations',
973
-                'espresso_registrations_delete_registration'
974
-            )
975
-        ) {
976
-            $this->_views['incomplete'] = [
977
-                'slug'        => 'incomplete',
978
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
979
-                'count'       => 0,
980
-                'bulk_action' => [
981
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
982
-                ],
983
-            ];
984
-            $this->_views['trash']      = [
985
-                'slug'        => 'trash',
986
-                'label'       => esc_html__('Trash', 'event_espresso'),
987
-                'count'       => 0,
988
-                'bulk_action' => [
989
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
990
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
991
-                ],
992
-            ];
993
-        }
994
-    }
995
-
996
-
997
-    protected function _set_list_table_views_contact_list()
998
-    {
999
-        $this->_views = [
1000
-            'in_use' => [
1001
-                'slug'        => 'in_use',
1002
-                'label'       => esc_html__('In Use', 'event_espresso'),
1003
-                'count'       => 0,
1004
-                'bulk_action' => [
1005
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1006
-                ],
1007
-            ],
1008
-        ];
1009
-        if (
1010
-            EE_Registry::instance()->CAP->current_user_can(
1011
-                'ee_delete_contacts',
1012
-                'espresso_registrations_trash_attendees'
1013
-            )
1014
-        ) {
1015
-            $this->_views['trash'] = [
1016
-                'slug'        => 'trash',
1017
-                'label'       => esc_html__('Trash', 'event_espresso'),
1018
-                'count'       => 0,
1019
-                'bulk_action' => [
1020
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1021
-                ],
1022
-            ];
1023
-        }
1024
-    }
1025
-
1026
-
1027
-    /**
1028
-     * @return array
1029
-     * @throws EE_Error
1030
-     */
1031
-    protected function _registration_legend_items()
1032
-    {
1033
-        $fc_items = [
1034
-            'star-icon'        => [
1035
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1036
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1037
-            ],
1038
-            'view_details'     => [
1039
-                'class' => 'dashicons dashicons-clipboard',
1040
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1041
-            ],
1042
-            'edit_attendee'    => [
1043
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1044
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1045
-            ],
1046
-            'view_transaction' => [
1047
-                'class' => 'dashicons dashicons-cart',
1048
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1049
-            ],
1050
-            'view_invoice'     => [
1051
-                'class' => 'dashicons dashicons-media-spreadsheet',
1052
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1053
-            ],
1054
-        ];
1055
-        if (
1056
-            EE_Registry::instance()->CAP->current_user_can(
1057
-                'ee_send_message',
1058
-                'espresso_registrations_resend_registration'
1059
-            )
1060
-        ) {
1061
-            $fc_items['resend_registration'] = [
1062
-                'class' => 'dashicons dashicons-email-alt',
1063
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1064
-            ];
1065
-        } else {
1066
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1067
-        }
1068
-        if (
1069
-            EE_Registry::instance()->CAP->current_user_can(
1070
-                'ee_read_global_messages',
1071
-                'view_filtered_messages'
1072
-            )
1073
-        ) {
1074
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1075
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1076
-                $fc_items['view_related_messages'] = [
1077
-                    'class' => $related_for_icon['css_class'],
1078
-                    'desc'  => $related_for_icon['label'],
1079
-                ];
1080
-            }
1081
-        }
1082
-        $sc_items = [
1083
-            'approved_status'   => [
1084
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1085
-                'desc'  => EEH_Template::pretty_status(
1086
-                    EEM_Registration::status_id_approved,
1087
-                    false,
1088
-                    'sentence'
1089
-                ),
1090
-            ],
1091
-            'pending_status'    => [
1092
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1093
-                'desc'  => EEH_Template::pretty_status(
1094
-                    EEM_Registration::status_id_pending_payment,
1095
-                    false,
1096
-                    'sentence'
1097
-                ),
1098
-            ],
1099
-            'wait_list'         => [
1100
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1101
-                'desc'  => EEH_Template::pretty_status(
1102
-                    EEM_Registration::status_id_wait_list,
1103
-                    false,
1104
-                    'sentence'
1105
-                ),
1106
-            ],
1107
-            'incomplete_status' => [
1108
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1109
-                'desc'  => EEH_Template::pretty_status(
1110
-                    EEM_Registration::status_id_incomplete,
1111
-                    false,
1112
-                    'sentence'
1113
-                ),
1114
-            ],
1115
-            'not_approved'      => [
1116
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1117
-                'desc'  => EEH_Template::pretty_status(
1118
-                    EEM_Registration::status_id_not_approved,
1119
-                    false,
1120
-                    'sentence'
1121
-                ),
1122
-            ],
1123
-            'declined_status'   => [
1124
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1125
-                'desc'  => EEH_Template::pretty_status(
1126
-                    EEM_Registration::status_id_declined,
1127
-                    false,
1128
-                    'sentence'
1129
-                ),
1130
-            ],
1131
-            'cancelled_status'  => [
1132
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1133
-                'desc'  => EEH_Template::pretty_status(
1134
-                    EEM_Registration::status_id_cancelled,
1135
-                    false,
1136
-                    'sentence'
1137
-                ),
1138
-            ],
1139
-        ];
1140
-        return array_merge($fc_items, $sc_items);
1141
-    }
1142
-
1143
-
1144
-
1145
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1146
-
1147
-
1148
-    /**
1149
-     * @throws DomainException
1150
-     * @throws EE_Error
1151
-     * @throws InvalidArgumentException
1152
-     * @throws InvalidDataTypeException
1153
-     * @throws InvalidInterfaceException
1154
-     */
1155
-    protected function _registrations_overview_list_table()
1156
-    {
1157
-        $this->appendAddNewRegistrationButtonToPageTitle();
1158
-        $header_text                  = '';
1159
-        $admin_page_header_decorators = [
1160
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1161
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1162
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1163
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1164
-        ];
1165
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1166
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1167
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1168
-        }
1169
-        $this->_template_args['admin_page_header'] = $header_text;
1170
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1171
-        $this->display_admin_list_table_page_with_no_sidebar();
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * @throws EE_Error
1177
-     * @throws InvalidArgumentException
1178
-     * @throws InvalidDataTypeException
1179
-     * @throws InvalidInterfaceException
1180
-     */
1181
-    private function appendAddNewRegistrationButtonToPageTitle()
1182
-    {
1183
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1184
-        if (
1185
-            $EVT_ID
1186
-            && EE_Registry::instance()->CAP->current_user_can(
1187
-                'ee_edit_registrations',
1188
-                'espresso_registrations_new_registration',
1189
-                $EVT_ID
1190
-            )
1191
-        ) {
1192
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1193
-                'new_registration',
1194
-                'add-registrant',
1195
-                ['event_id' => $EVT_ID],
1196
-                'add-new-h2'
1197
-            );
1198
-        }
1199
-    }
1200
-
1201
-
1202
-    /**
1203
-     * This sets the _registration property for the registration details screen
1204
-     *
1205
-     * @return void
1206
-     * @throws EE_Error
1207
-     * @throws InvalidArgumentException
1208
-     * @throws InvalidDataTypeException
1209
-     * @throws InvalidInterfaceException
1210
-     */
1211
-    private function _set_registration_object()
1212
-    {
1213
-        // get out if we've already set the object
1214
-        if ($this->_registration instanceof EE_Registration) {
1215
-            return;
1216
-        }
1217
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1218
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1219
-            return;
1220
-        }
1221
-        $error_msg = sprintf(
1222
-            esc_html__(
1223
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1224
-                'event_espresso'
1225
-            ),
1226
-            $REG_ID
1227
-        );
1228
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1229
-        $this->_registration = null;
1230
-    }
1231
-
1232
-
1233
-    /**
1234
-     * Used to retrieve registrations for the list table.
1235
-     *
1236
-     * @param int  $per_page
1237
-     * @param bool $count
1238
-     * @param bool $this_month
1239
-     * @param bool $today
1240
-     * @return EE_Registration[]|int
1241
-     * @throws EE_Error
1242
-     * @throws InvalidArgumentException
1243
-     * @throws InvalidDataTypeException
1244
-     * @throws InvalidInterfaceException
1245
-     */
1246
-    public function get_registrations(
1247
-        $per_page = 10,
1248
-        $count = false,
1249
-        $this_month = false,
1250
-        $today = false
1251
-    ) {
1252
-        if ($this_month) {
1253
-            $this->request->setRequestParam('status', 'month');
1254
-        }
1255
-        if ($today) {
1256
-            $this->request->setRequestParam('status', 'today');
1257
-        }
1258
-        $query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1259
-        /**
1260
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
-         *
1262
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
-         *                      or if you have the development copy of EE you can view this at the path:
1265
-         *                      /docs/G--Model-System/model-query-params.md
1266
-         */
1267
-        $query_params['group_by'] = '';
1268
-
1269
-        return $count
1270
-            ? $this->getRegistrationModel()->count($query_params)
1271
-            /** @type EE_Registration[] */
1272
-            : $this->getRegistrationModel()->get_all($query_params);
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1278
-     * Note: this listens to values on the request for some of the query parameters.
1279
-     *
1280
-     * @param array $request
1281
-     * @param int   $per_page
1282
-     * @param bool  $count
1283
-     * @return array
1284
-     * @throws EE_Error
1285
-     * @throws InvalidArgumentException
1286
-     * @throws InvalidDataTypeException
1287
-     * @throws InvalidInterfaceException
1288
-     */
1289
-    protected function _get_registration_query_parameters(
1290
-        $request = [],
1291
-        $per_page = 10,
1292
-        $count = false
1293
-    ) {
1294
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1295
-        $list_table_query_builder = $this->getLoader()->getNew(
1296
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1297
-            [null, null, $request]
1298
-        );
1299
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1300
-    }
1301
-
1302
-
1303
-    public function get_registration_status_array()
1304
-    {
1305
-        return self::$_reg_status;
1306
-    }
1307
-
1308
-
1309
-
1310
-
1311
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1312
-    /**
1313
-     * generates HTML for the View Registration Details Admin page
1314
-     *
1315
-     * @return void
1316
-     * @throws DomainException
1317
-     * @throws EE_Error
1318
-     * @throws InvalidArgumentException
1319
-     * @throws InvalidDataTypeException
1320
-     * @throws InvalidInterfaceException
1321
-     * @throws EntityNotFoundException
1322
-     * @throws ReflectionException
1323
-     */
1324
-    protected function _registration_details()
1325
-    {
1326
-        $this->_template_args = [];
1327
-        $this->_set_registration_object();
1328
-        if (is_object($this->_registration)) {
1329
-            $transaction                                   = $this->_registration->transaction()
1330
-                ? $this->_registration->transaction()
1331
-                : EE_Transaction::new_instance();
1332
-            $this->_session                                = $transaction->session_data();
1333
-            $event_id                                      = $this->_registration->event_ID();
1334
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1335
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1336
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1337
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1338
-            $this->_template_args['grand_total']           = $transaction->total();
1339
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1340
-            // link back to overview
1341
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1342
-            $this->_template_args['registration']                = $this->_registration;
1343
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
-                [
1345
-                    'action'   => 'default',
1346
-                    'event_id' => $event_id,
1347
-                ],
1348
-                REG_ADMIN_URL
1349
-            );
1350
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1351
-                [
1352
-                    'action' => 'default',
1353
-                    'EVT_ID' => $event_id,
1354
-                    'page'   => 'espresso_transactions',
1355
-                ],
1356
-                admin_url('admin.php')
1357
-            );
1358
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1359
-                [
1360
-                    'page'   => 'espresso_events',
1361
-                    'action' => 'edit',
1362
-                    'post'   => $event_id,
1363
-                ],
1364
-                admin_url('admin.php')
1365
-            );
1366
-            // next and previous links
1367
-            $next_reg                                      = $this->_registration->next(
1368
-                null,
1369
-                [],
1370
-                'REG_ID'
1371
-            );
1372
-            $this->_template_args['next_registration']     = $next_reg
1373
-                ? $this->_next_link(
1374
-                    EE_Admin_Page::add_query_args_and_nonce(
1375
-                        [
1376
-                            'action'  => 'view_registration',
1377
-                            '_REG_ID' => $next_reg['REG_ID'],
1378
-                        ],
1379
-                        REG_ADMIN_URL
1380
-                    ),
1381
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1382
-                )
1383
-                : '';
1384
-            $previous_reg                                  = $this->_registration->previous(
1385
-                null,
1386
-                [],
1387
-                'REG_ID'
1388
-            );
1389
-            $this->_template_args['previous_registration'] = $previous_reg
1390
-                ? $this->_previous_link(
1391
-                    EE_Admin_Page::add_query_args_and_nonce(
1392
-                        [
1393
-                            'action'  => 'view_registration',
1394
-                            '_REG_ID' => $previous_reg['REG_ID'],
1395
-                        ],
1396
-                        REG_ADMIN_URL
1397
-                    ),
1398
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1399
-                )
1400
-                : '';
1401
-            // grab header
1402
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1403
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1404
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1405
-                $template_path,
1406
-                $this->_template_args,
1407
-                true
1408
-            );
1409
-        } else {
1410
-            $this->_template_args['admin_page_header'] = '';
1411
-            $this->_display_espresso_notices();
1412
-        }
1413
-        // the details template wrapper
1414
-        $this->display_admin_page_with_sidebar();
1415
-    }
1416
-
1417
-
1418
-    /**
1419
-     * @throws EE_Error
1420
-     * @throws InvalidArgumentException
1421
-     * @throws InvalidDataTypeException
1422
-     * @throws InvalidInterfaceException
1423
-     * @throws ReflectionException
1424
-     * @since 4.10.2.p
1425
-     */
1426
-    protected function _registration_details_metaboxes()
1427
-    {
1428
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1429
-        $this->_set_registration_object();
1430
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1431
-        add_meta_box(
1432
-            'edit-reg-status-mbox',
1433
-            esc_html__('Registration Status', 'event_espresso'),
1434
-            [$this, 'set_reg_status_buttons_metabox'],
1435
-            $this->_wp_page_slug,
1436
-            'normal',
1437
-            'high'
1438
-        );
1439
-        add_meta_box(
1440
-            'edit-reg-details-mbox',
1441
-            esc_html__('Registration Details', 'event_espresso'),
1442
-            [$this, '_reg_details_meta_box'],
1443
-            $this->_wp_page_slug,
1444
-            'normal',
1445
-            'high'
1446
-        );
1447
-        if (
1448
-            $attendee instanceof EE_Attendee
1449
-            && EE_Registry::instance()->CAP->current_user_can(
1450
-                'ee_read_registration',
1451
-                'edit-reg-questions-mbox',
1452
-                $this->_registration->ID()
1453
-            )
1454
-        ) {
1455
-            add_meta_box(
1456
-                'edit-reg-questions-mbox',
1457
-                esc_html__('Registration Form Answers', 'event_espresso'),
1458
-                [$this, '_reg_questions_meta_box'],
1459
-                $this->_wp_page_slug,
1460
-                'normal',
1461
-                'high'
1462
-            );
1463
-        }
1464
-        add_meta_box(
1465
-            'edit-reg-registrant-mbox',
1466
-            esc_html__('Contact Details', 'event_espresso'),
1467
-            [$this, '_reg_registrant_side_meta_box'],
1468
-            $this->_wp_page_slug,
1469
-            'side',
1470
-            'high'
1471
-        );
1472
-        if ($this->_registration->group_size() > 1) {
1473
-            add_meta_box(
1474
-                'edit-reg-attendees-mbox',
1475
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1476
-                [$this, '_reg_attendees_meta_box'],
1477
-                $this->_wp_page_slug,
1478
-                'normal',
1479
-                'high'
1480
-            );
1481
-        }
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * set_reg_status_buttons_metabox
1487
-     *
1488
-     * @return void
1489
-     * @throws EE_Error
1490
-     * @throws EntityNotFoundException
1491
-     * @throws InvalidArgumentException
1492
-     * @throws InvalidDataTypeException
1493
-     * @throws InvalidInterfaceException
1494
-     * @throws ReflectionException
1495
-     */
1496
-    public function set_reg_status_buttons_metabox()
1497
-    {
1498
-        $this->_set_registration_object();
1499
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1500
-        $output                 = $change_reg_status_form->form_open(
1501
-            self::add_query_args_and_nonce(
1502
-                [
1503
-                    'action' => 'change_reg_status',
1504
-                ],
1505
-                REG_ADMIN_URL
1506
-            )
1507
-        );
1508
-        $output                 .= $change_reg_status_form->get_html();
1509
-        $output                 .= $change_reg_status_form->form_close();
1510
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1511
-    }
1512
-
1513
-
1514
-    /**
1515
-     * @return EE_Form_Section_Proper
1516
-     * @throws EE_Error
1517
-     * @throws InvalidArgumentException
1518
-     * @throws InvalidDataTypeException
1519
-     * @throws InvalidInterfaceException
1520
-     * @throws EntityNotFoundException
1521
-     * @throws ReflectionException
1522
-     */
1523
-    protected function _generate_reg_status_change_form()
1524
-    {
1525
-        $reg_status_change_form_array = [
1526
-            'name'            => 'reg_status_change_form',
1527
-            'html_id'         => 'reg-status-change-form',
1528
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1529
-            'subsections'     => [
1530
-                'return'         => new EE_Hidden_Input(
1531
-                    [
1532
-                        'name'    => 'return',
1533
-                        'default' => 'view_registration',
1534
-                    ]
1535
-                ),
1536
-                'REG_ID'         => new EE_Hidden_Input(
1537
-                    [
1538
-                        'name'    => 'REG_ID',
1539
-                        'default' => $this->_registration->ID(),
1540
-                    ]
1541
-                ),
1542
-                'current_status' => new EE_Form_Section_HTML(
1543
-                    EEH_HTML::table(
1544
-                        EEH_HTML::tr(
1545
-                            EEH_HTML::th(
1546
-                                EEH_HTML::label(
1547
-                                    EEH_HTML::strong(
1548
-                                        esc_html__('Current Registration Status', 'event_espresso')
1549
-                                    )
1550
-                                )
1551
-                            )
1552
-                            . EEH_HTML::td(
1553
-                                EEH_HTML::strong(
1554
-                                    $this->_registration->pretty_status(),
1555
-                                    '',
1556
-                                    'status-' . $this->_registration->status_ID(),
1557
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1558
-                                )
1559
-                            )
1560
-                        )
1561
-                    )
1562
-                ),
1563
-            ],
1564
-        ];
1565
-        if (
1566
-            EE_Registry::instance()->CAP->current_user_can(
1567
-                'ee_edit_registration',
1568
-                'toggle_registration_status',
1569
-                $this->_registration->ID()
1570
-            )
1571
-        ) {
1572
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1573
-                $this->_get_reg_statuses(),
1574
-                [
1575
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1576
-                    'default'         => $this->_registration->status_ID(),
1577
-                ]
1578
-            );
1579
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1580
-                [
1581
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1582
-                    'default'         => false,
1583
-                    'html_help_text'  => esc_html__(
1584
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1585
-                        'event_espresso'
1586
-                    ),
1587
-                ]
1588
-            );
1589
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1590
-                [
1591
-                    'html_class'      => 'button-primary',
1592
-                    'html_label_text' => '&nbsp;',
1593
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1594
-                ]
1595
-            );
1596
-        }
1597
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1598
-    }
1599
-
1600
-
1601
-    /**
1602
-     * Returns an array of all the buttons for the various statuses and switch status actions
1603
-     *
1604
-     * @return array
1605
-     * @throws EE_Error
1606
-     * @throws InvalidArgumentException
1607
-     * @throws InvalidDataTypeException
1608
-     * @throws InvalidInterfaceException
1609
-     * @throws EntityNotFoundException
1610
-     */
1611
-    protected function _get_reg_statuses()
1612
-    {
1613
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1614
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1615
-        // get current reg status
1616
-        $current_status = $this->_registration->status_ID();
1617
-        // is registration for free event? This will determine whether to display the pending payment option
1618
-        if (
1619
-            $current_status !== EEM_Registration::status_id_pending_payment
1620
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1621
-        ) {
1622
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1623
-        }
1624
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1625
-    }
1626
-
1627
-
1628
-    /**
1629
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1630
-     *
1631
-     * @param bool $status REG status given for changing registrations to.
1632
-     * @param bool $notify Whether to send messages notifications or not.
1633
-     * @return array (array with reg_id(s) updated and whether update was successful.
1634
-     * @throws DomainException
1635
-     * @throws EE_Error
1636
-     * @throws EntityNotFoundException
1637
-     * @throws InvalidArgumentException
1638
-     * @throws InvalidDataTypeException
1639
-     * @throws InvalidInterfaceException
1640
-     * @throws ReflectionException
1641
-     * @throws RuntimeException
1642
-     */
1643
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1644
-    {
1645
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1646
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1647
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1648
-
1649
-        // sanitize $REG_IDs
1650
-        $REG_IDs = array_map('absint', $REG_IDs);
1651
-        // and remove empty entries
1652
-        $REG_IDs = array_filter($REG_IDs);
1653
-
1654
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1655
-
1656
-        /**
1657
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1658
-         * Currently this value is used downstream by the _process_resend_registration method.
1659
-         *
1660
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1661
-         * @param bool                     $status           The status registrations were changed to.
1662
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1663
-         * @param Registrations_Admin_Page $admin_page_object
1664
-         */
1665
-        $REG_ID = apply_filters(
1666
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1667
-            $result['REG_ID'],
1668
-            $status,
1669
-            $result['success'],
1670
-            $this
1671
-        );
1672
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1673
-
1674
-        // notify?
1675
-        if (
1676
-            $notify
1677
-            && $result['success']
1678
-            && ! empty($REG_ID)
1679
-            && EE_Registry::instance()->CAP->current_user_can(
1680
-                'ee_send_message',
1681
-                'espresso_registrations_resend_registration'
1682
-            )
1683
-        ) {
1684
-            $this->_process_resend_registration();
1685
-        }
1686
-        return $result;
1687
-    }
1688
-
1689
-
1690
-    /**
1691
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1692
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1693
-     *
1694
-     * @param array  $REG_IDs
1695
-     * @param string $status
1696
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1697
-     *                       slug sent with setting the registration status.
1698
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1699
-     * @throws EE_Error
1700
-     * @throws InvalidArgumentException
1701
-     * @throws InvalidDataTypeException
1702
-     * @throws InvalidInterfaceException
1703
-     * @throws ReflectionException
1704
-     * @throws RuntimeException
1705
-     * @throws EntityNotFoundException
1706
-     * @throws DomainException
1707
-     */
1708
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1709
-    {
1710
-        $success = false;
1711
-        // typecast $REG_IDs
1712
-        $REG_IDs = (array) $REG_IDs;
1713
-        if (! empty($REG_IDs)) {
1714
-            $success = true;
1715
-            // set default status if none is passed
1716
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1717
-            $status_context = $notify
1718
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1719
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1720
-            // loop through REG_ID's and change status
1721
-            foreach ($REG_IDs as $REG_ID) {
1722
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1723
-                if ($registration instanceof EE_Registration) {
1724
-                    $registration->set_status(
1725
-                        $status,
1726
-                        false,
1727
-                        new Context(
1728
-                            $status_context,
1729
-                            esc_html__(
1730
-                                'Manually triggered status change on a Registration Admin Page route.',
1731
-                                'event_espresso'
1732
-                            )
1733
-                        )
1734
-                    );
1735
-                    $result = $registration->save();
1736
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1737
-                    $success = $result !== false ? $success : false;
1738
-                }
1739
-            }
1740
-        }
1741
-
1742
-        // return $success and processed registrations
1743
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1744
-    }
1745
-
1746
-
1747
-    /**
1748
-     * Common logic for setting up success message and redirecting to appropriate route
1749
-     *
1750
-     * @param string $STS_ID status id for the registration changed to
1751
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1752
-     * @return void
1753
-     * @throws DomainException
1754
-     * @throws EE_Error
1755
-     * @throws EntityNotFoundException
1756
-     * @throws InvalidArgumentException
1757
-     * @throws InvalidDataTypeException
1758
-     * @throws InvalidInterfaceException
1759
-     * @throws ReflectionException
1760
-     * @throws RuntimeException
1761
-     */
1762
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1763
-    {
1764
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1765
-            : ['success' => false];
1766
-        $success = isset($result['success']) && $result['success'];
1767
-        // setup success message
1768
-        if ($success) {
1769
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1770
-                $msg = sprintf(
1771
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1772
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1773
-                );
1774
-            } else {
1775
-                $msg = sprintf(
1776
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1777
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1778
-                );
1779
-            }
1780
-            EE_Error::add_success($msg);
1781
-        } else {
1782
-            EE_Error::add_error(
1783
-                esc_html__(
1784
-                    'Something went wrong, and the status was not changed',
1785
-                    'event_espresso'
1786
-                ),
1787
-                __FILE__,
1788
-                __LINE__,
1789
-                __FUNCTION__
1790
-            );
1791
-        }
1792
-        $return = $this->request->getRequestParam('return');
1793
-        $route  = $return === 'view_registration'
1794
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1795
-            : ['action' => 'default'];
1796
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1797
-        $this->_redirect_after_action($success, '', '', $route, true);
1798
-    }
1799
-
1800
-
1801
-    /**
1802
-     * incoming reg status change from reg details page.
1803
-     *
1804
-     * @return void
1805
-     * @throws EE_Error
1806
-     * @throws EntityNotFoundException
1807
-     * @throws InvalidArgumentException
1808
-     * @throws InvalidDataTypeException
1809
-     * @throws InvalidInterfaceException
1810
-     * @throws ReflectionException
1811
-     * @throws RuntimeException
1812
-     * @throws DomainException
1813
-     */
1814
-    protected function _change_reg_status()
1815
-    {
1816
-        $this->request->setRequestParam('return', 'view_registration');
1817
-        // set notify based on whether the send notifications toggle is set or not
1818
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1819
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1820
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1821
-        switch ($reg_status) {
1822
-            case EEM_Registration::status_id_approved:
1823
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1824
-                $this->approve_registration($notify);
1825
-                break;
1826
-            case EEM_Registration::status_id_pending_payment:
1827
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1828
-                $this->pending_registration($notify);
1829
-                break;
1830
-            case EEM_Registration::status_id_not_approved:
1831
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1832
-                $this->not_approve_registration($notify);
1833
-                break;
1834
-            case EEM_Registration::status_id_declined:
1835
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1836
-                $this->decline_registration($notify);
1837
-                break;
1838
-            case EEM_Registration::status_id_cancelled:
1839
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1840
-                $this->cancel_registration($notify);
1841
-                break;
1842
-            case EEM_Registration::status_id_wait_list:
1843
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1844
-                $this->wait_list_registration($notify);
1845
-                break;
1846
-            case EEM_Registration::status_id_incomplete:
1847
-            default:
1848
-                $this->request->unSetRequestParam('return');
1849
-                $this->_reg_status_change_return('');
1850
-                break;
1851
-        }
1852
-    }
1853
-
1854
-
1855
-    /**
1856
-     * Callback for bulk action routes.
1857
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1858
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1859
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1860
-     * when an action is happening on just a single registration).
1861
-     *
1862
-     * @param      $action
1863
-     * @param bool $notify
1864
-     */
1865
-    protected function bulk_action_on_registrations($action, $notify = false)
1866
-    {
1867
-        do_action(
1868
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1869
-            $this,
1870
-            $action,
1871
-            $notify
1872
-        );
1873
-        $method = $action . '_registration';
1874
-        if (method_exists($this, $method)) {
1875
-            $this->$method($notify);
1876
-        }
1877
-    }
1878
-
1879
-
1880
-    /**
1881
-     * approve_registration
1882
-     *
1883
-     * @param bool $notify whether or not to notify the registrant about their approval.
1884
-     * @return void
1885
-     * @throws EE_Error
1886
-     * @throws EntityNotFoundException
1887
-     * @throws InvalidArgumentException
1888
-     * @throws InvalidDataTypeException
1889
-     * @throws InvalidInterfaceException
1890
-     * @throws ReflectionException
1891
-     * @throws RuntimeException
1892
-     * @throws DomainException
1893
-     */
1894
-    protected function approve_registration($notify = false)
1895
-    {
1896
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1897
-    }
1898
-
1899
-
1900
-    /**
1901
-     * decline_registration
1902
-     *
1903
-     * @param bool $notify whether or not to notify the registrant about their status change.
1904
-     * @return void
1905
-     * @throws EE_Error
1906
-     * @throws EntityNotFoundException
1907
-     * @throws InvalidArgumentException
1908
-     * @throws InvalidDataTypeException
1909
-     * @throws InvalidInterfaceException
1910
-     * @throws ReflectionException
1911
-     * @throws RuntimeException
1912
-     * @throws DomainException
1913
-     */
1914
-    protected function decline_registration($notify = false)
1915
-    {
1916
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
-    }
1918
-
1919
-
1920
-    /**
1921
-     * cancel_registration
1922
-     *
1923
-     * @param bool $notify whether or not to notify the registrant about their status change.
1924
-     * @return void
1925
-     * @throws EE_Error
1926
-     * @throws EntityNotFoundException
1927
-     * @throws InvalidArgumentException
1928
-     * @throws InvalidDataTypeException
1929
-     * @throws InvalidInterfaceException
1930
-     * @throws ReflectionException
1931
-     * @throws RuntimeException
1932
-     * @throws DomainException
1933
-     */
1934
-    protected function cancel_registration($notify = false)
1935
-    {
1936
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1937
-    }
1938
-
1939
-
1940
-    /**
1941
-     * not_approve_registration
1942
-     *
1943
-     * @param bool $notify whether or not to notify the registrant about their status change.
1944
-     * @return void
1945
-     * @throws EE_Error
1946
-     * @throws EntityNotFoundException
1947
-     * @throws InvalidArgumentException
1948
-     * @throws InvalidDataTypeException
1949
-     * @throws InvalidInterfaceException
1950
-     * @throws ReflectionException
1951
-     * @throws RuntimeException
1952
-     * @throws DomainException
1953
-     */
1954
-    protected function not_approve_registration($notify = false)
1955
-    {
1956
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1957
-    }
1958
-
1959
-
1960
-    /**
1961
-     * decline_registration
1962
-     *
1963
-     * @param bool $notify whether or not to notify the registrant about their status change.
1964
-     * @return void
1965
-     * @throws EE_Error
1966
-     * @throws EntityNotFoundException
1967
-     * @throws InvalidArgumentException
1968
-     * @throws InvalidDataTypeException
1969
-     * @throws InvalidInterfaceException
1970
-     * @throws ReflectionException
1971
-     * @throws RuntimeException
1972
-     * @throws DomainException
1973
-     */
1974
-    protected function pending_registration($notify = false)
1975
-    {
1976
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1977
-    }
1978
-
1979
-
1980
-    /**
1981
-     * waitlist_registration
1982
-     *
1983
-     * @param bool $notify whether or not to notify the registrant about their status change.
1984
-     * @return void
1985
-     * @throws EE_Error
1986
-     * @throws EntityNotFoundException
1987
-     * @throws InvalidArgumentException
1988
-     * @throws InvalidDataTypeException
1989
-     * @throws InvalidInterfaceException
1990
-     * @throws ReflectionException
1991
-     * @throws RuntimeException
1992
-     * @throws DomainException
1993
-     */
1994
-    protected function wait_list_registration($notify = false)
1995
-    {
1996
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
-    }
1998
-
1999
-
2000
-    /**
2001
-     * generates HTML for the Registration main meta box
2002
-     *
2003
-     * @return void
2004
-     * @throws DomainException
2005
-     * @throws EE_Error
2006
-     * @throws InvalidArgumentException
2007
-     * @throws InvalidDataTypeException
2008
-     * @throws InvalidInterfaceException
2009
-     * @throws ReflectionException
2010
-     * @throws EntityNotFoundException
2011
-     */
2012
-    public function _reg_details_meta_box()
2013
-    {
2014
-        EEH_Autoloader::register_line_item_display_autoloaders();
2015
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2016
-        EE_Registry::instance()->load_helper('Line_Item');
2017
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2018
-            : EE_Transaction::new_instance();
2019
-        $this->_session = $transaction->session_data();
2020
-        $filters        = new EE_Line_Item_Filter_Collection();
2021
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2022
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2023
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2024
-            $filters,
2025
-            $transaction->total_line_item()
2026
-        );
2027
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2028
-        $line_item_display                       = new EE_Line_Item_Display(
2029
-            'reg_admin_table',
2030
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2031
-        );
2032
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2033
-            $filtered_line_item_tree,
2034
-            ['EE_Registration' => $this->_registration]
2035
-        );
2036
-        $attendee                                = $this->_registration->attendee();
2037
-        if (
2038
-            EE_Registry::instance()->CAP->current_user_can(
2039
-                'ee_read_transaction',
2040
-                'espresso_transactions_view_transaction'
2041
-            )
2042
-        ) {
2043
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2044
-                EE_Admin_Page::add_query_args_and_nonce(
2045
-                    [
2046
-                        'action' => 'view_transaction',
2047
-                        'TXN_ID' => $transaction->ID(),
2048
-                    ],
2049
-                    TXN_ADMIN_URL
2050
-                ),
2051
-                esc_html__(' View Transaction', 'event_espresso'),
2052
-                'button secondary-button right',
2053
-                'dashicons dashicons-cart'
2054
-            );
2055
-        } else {
2056
-            $this->_template_args['view_transaction_button'] = '';
2057
-        }
2058
-        if (
2059
-            $attendee instanceof EE_Attendee
2060
-            && EE_Registry::instance()->CAP->current_user_can(
2061
-                'ee_send_message',
2062
-                'espresso_registrations_resend_registration'
2063
-            )
2064
-        ) {
2065
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2066
-                EE_Admin_Page::add_query_args_and_nonce(
2067
-                    [
2068
-                        'action'      => 'resend_registration',
2069
-                        '_REG_ID'     => $this->_registration->ID(),
2070
-                        'redirect_to' => 'view_registration',
2071
-                    ],
2072
-                    REG_ADMIN_URL
2073
-                ),
2074
-                esc_html__(' Resend Registration', 'event_espresso'),
2075
-                'button secondary-button right',
2076
-                'dashicons dashicons-email-alt'
2077
-            );
2078
-        } else {
2079
-            $this->_template_args['resend_registration_button'] = '';
2080
-        }
2081
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2082
-        $payment                               = $transaction->get_first_related('Payment');
2083
-        $payment                               = ! $payment instanceof EE_Payment
2084
-            ? EE_Payment::new_instance()
2085
-            : $payment;
2086
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2087
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2088
-            ? EE_Payment_Method::new_instance()
2089
-            : $payment_method;
2090
-        $reg_details                           = [
2091
-            'payment_method'       => $payment_method->name(),
2092
-            'response_msg'         => $payment->gateway_response(),
2093
-            'registration_id'      => $this->_registration->get('REG_code'),
2094
-            'registration_session' => $this->_registration->session_ID(),
2095
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2096
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2097
-        ];
2098
-        if (isset($reg_details['registration_id'])) {
2099
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2100
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2101
-                'Registration ID',
2102
-                'event_espresso'
2103
-            );
2104
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2105
-        }
2106
-        if (isset($reg_details['payment_method'])) {
2107
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2108
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2109
-                'Most Recent Payment Method',
2110
-                'event_espresso'
2111
-            );
2112
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2113
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2114
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2115
-                'Payment method response',
2116
-                'event_espresso'
2117
-            );
2118
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2119
-        }
2120
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2121
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2122
-            'Registration Session',
2123
-            'event_espresso'
2124
-        );
2125
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2126
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2127
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2128
-            'Registration placed from IP',
2129
-            'event_espresso'
2130
-        );
2131
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2132
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2133
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2134
-            'Registrant User Agent',
2135
-            'event_espresso'
2136
-        );
2137
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2138
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2139
-            [
2140
-                'action'   => 'default',
2141
-                'event_id' => $this->_registration->event_ID(),
2142
-            ],
2143
-            REG_ADMIN_URL
2144
-        );
2145
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2146
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2147
-        $template_path                                                        =
2148
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2149
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2150
-    }
2151
-
2152
-
2153
-    /**
2154
-     * generates HTML for the Registration Questions meta box.
2155
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2156
-     * otherwise uses new forms system
2157
-     *
2158
-     * @return void
2159
-     * @throws DomainException
2160
-     * @throws EE_Error
2161
-     * @throws InvalidArgumentException
2162
-     * @throws InvalidDataTypeException
2163
-     * @throws InvalidInterfaceException
2164
-     * @throws ReflectionException
2165
-     */
2166
-    public function _reg_questions_meta_box()
2167
-    {
2168
-        // allow someone to override this method entirely
2169
-        if (
2170
-            apply_filters(
2171
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2172
-                true,
2173
-                $this,
2174
-                $this->_registration
2175
-            )
2176
-        ) {
2177
-            $form                                              = $this->_get_reg_custom_questions_form(
2178
-                $this->_registration->ID()
2179
-            );
2180
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2181
-                ? $form->get_html_and_js()
2182
-                : '';
2183
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2184
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2185
-            $template_path                                     =
2186
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2187
-            EEH_Template::display_template($template_path, $this->_template_args);
2188
-        }
2189
-    }
2190
-
2191
-
2192
-    /**
2193
-     * form_before_question_group
2194
-     *
2195
-     * @param string $output
2196
-     * @return        string
2197
-     * @deprecated    as of 4.8.32.rc.000
2198
-     */
2199
-    public function form_before_question_group($output)
2200
-    {
2201
-        EE_Error::doing_it_wrong(
2202
-            __CLASS__ . '::' . __FUNCTION__,
2203
-            esc_html__(
2204
-                '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.',
2205
-                'event_espresso'
2206
-            ),
2207
-            '4.8.32.rc.000'
2208
-        );
2209
-        return '
24
+	/**
25
+	 * @var EE_Registration
26
+	 */
27
+	private $_registration;
28
+
29
+	/**
30
+	 * @var EE_Event
31
+	 */
32
+	private $_reg_event;
33
+
34
+	/**
35
+	 * @var EE_Session
36
+	 */
37
+	private $_session;
38
+
39
+	/**
40
+	 * @var array
41
+	 */
42
+	private static $_reg_status;
43
+
44
+	/**
45
+	 * Form for displaying the custom questions for this registration.
46
+	 * This gets used a few times throughout the request so its best to cache it
47
+	 *
48
+	 * @var EE_Registration_Custom_Questions_Form
49
+	 */
50
+	protected $_reg_custom_questions_form = null;
51
+
52
+	/**
53
+	 * @var EEM_Registration $registration_model
54
+	 */
55
+	private $registration_model;
56
+
57
+	/**
58
+	 * @var EEM_Attendee $attendee_model
59
+	 */
60
+	private $attendee_model;
61
+
62
+	/**
63
+	 * @var EEM_Event $event_model
64
+	 */
65
+	private $event_model;
66
+
67
+	/**
68
+	 * @var EEM_Status $status_model
69
+	 */
70
+	private $status_model;
71
+
72
+
73
+	/**
74
+	 * @param bool $routing
75
+	 * @throws EE_Error
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidInterfaceException
79
+	 * @throws ReflectionException
80
+	 */
81
+	public function __construct($routing = true)
82
+	{
83
+		parent::__construct($routing);
84
+		add_action('wp_loaded', [$this, 'wp_loaded']);
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return EEM_Registration
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 * @since 4.10.2.p
94
+	 */
95
+	protected function getRegistrationModel()
96
+	{
97
+		if (! $this->registration_model instanceof EEM_Registration) {
98
+			$this->registration_model = $this->getLoader()->getShared('EEM_Registration');
99
+		}
100
+		return $this->registration_model;
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return EEM_Attendee
106
+	 * @throws InvalidArgumentException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 * @since 4.10.2.p
110
+	 */
111
+	protected function getAttendeeModel()
112
+	{
113
+		if (! $this->attendee_model instanceof EEM_Attendee) {
114
+			$this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
115
+		}
116
+		return $this->attendee_model;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return EEM_Event
122
+	 * @throws InvalidArgumentException
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws InvalidInterfaceException
125
+	 * @since 4.10.2.p
126
+	 */
127
+	protected function getEventModel()
128
+	{
129
+		if (! $this->event_model instanceof EEM_Event) {
130
+			$this->event_model = $this->getLoader()->getShared('EEM_Event');
131
+		}
132
+		return $this->event_model;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @return EEM_Status
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidInterfaceException
141
+	 * @since 4.10.2.p
142
+	 */
143
+	protected function getStatusModel()
144
+	{
145
+		if (! $this->status_model instanceof EEM_Status) {
146
+			$this->status_model = $this->getLoader()->getShared('EEM_Status');
147
+		}
148
+		return $this->status_model;
149
+	}
150
+
151
+
152
+	public function wp_loaded()
153
+	{
154
+		// when adding a new registration...
155
+		$action = $this->request->getRequestParam('action');
156
+		if ($action === 'new_registration') {
157
+			EE_System::do_not_cache();
158
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
159
+				// and it's NOT the attendee information reg step
160
+				// force cookie expiration by setting time to last week
161
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
162
+				// and update the global
163
+				$_COOKIE['ee_registration_added'] = 0;
164
+			}
165
+		}
166
+	}
167
+
168
+
169
+	protected function _init_page_props()
170
+	{
171
+		$this->page_slug        = REG_PG_SLUG;
172
+		$this->_admin_base_url  = REG_ADMIN_URL;
173
+		$this->_admin_base_path = REG_ADMIN;
174
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
175
+		$this->_cpt_routes      = [
176
+			'add_new_attendee' => 'espresso_attendees',
177
+			'edit_attendee'    => 'espresso_attendees',
178
+			'insert_attendee'  => 'espresso_attendees',
179
+			'update_attendee'  => 'espresso_attendees',
180
+		];
181
+		$this->_cpt_model_names = [
182
+			'add_new_attendee' => 'EEM_Attendee',
183
+			'edit_attendee'    => 'EEM_Attendee',
184
+		];
185
+		$this->_cpt_edit_routes = [
186
+			'espresso_attendees' => 'edit_attendee',
187
+		];
188
+		$this->_pagenow_map     = [
189
+			'add_new_attendee' => 'post-new.php',
190
+			'edit_attendee'    => 'post.php',
191
+			'trash'            => 'post.php',
192
+		];
193
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
194
+		// add filters so that the comment urls don't take users to a confusing 404 page
195
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
196
+	}
197
+
198
+
199
+	/**
200
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
201
+	 * @param WP_Comment $comment The current comment object.
202
+	 * @return string
203
+	 */
204
+	public function clear_comment_link($link, WP_Comment $comment)
205
+	{
206
+		// gotta make sure this only happens on this route
207
+		$post_type = get_post_type($comment->comment_post_ID);
208
+		if ($post_type === 'espresso_attendees') {
209
+			return '#commentsdiv';
210
+		}
211
+		return $link;
212
+	}
213
+
214
+
215
+	protected function _ajax_hooks()
216
+	{
217
+		// todo: all hooks for registrations ajax goes in here
218
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
219
+	}
220
+
221
+
222
+	protected function _define_page_props()
223
+	{
224
+		$this->_admin_page_title = $this->page_label;
225
+		$this->_labels           = [
226
+			'buttons'                      => [
227
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
228
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
229
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
230
+				'csv_reg_report'      => esc_html__('Registrations 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'       => [$this, '_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'       => [$this, '_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
+				'qtips'         => ['Registration_List_Table_Tips'],
573
+				'list_table'    => 'EE_Registrations_List_Table',
574
+				'require_nonce' => false,
575
+			],
576
+			'view_registration' => [
577
+				'nav'           => [
578
+					'label'      => esc_html__('REG Details', 'event_espresso'),
579
+					'order'      => 15,
580
+					'url'        => $REG_ID
581
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
+						: $this->_admin_base_url,
583
+					'persistent' => false,
584
+				],
585
+				'help_tabs'     => [
586
+					'registrations_details_help_tab'                    => [
587
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
588
+						'filename' => 'registrations_details',
589
+					],
590
+					'registrations_details_table_help_tab'              => [
591
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
+						'filename' => 'registrations_details_table',
593
+					],
594
+					'registrations_details_form_answers_help_tab'       => [
595
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
+						'filename' => 'registrations_details_form_answers',
597
+					],
598
+					'registrations_details_registrant_details_help_tab' => [
599
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
600
+						'filename' => 'registrations_details_registrant_details',
601
+					],
602
+				],
603
+				'metaboxes'     => array_merge(
604
+					$this->_default_espresso_metaboxes,
605
+					['_registration_details_metaboxes']
606
+				),
607
+				'require_nonce' => false,
608
+			],
609
+			'new_registration'  => [
610
+				'nav'           => [
611
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
+					'url'        => '#',
613
+					'order'      => 15,
614
+					'persistent' => false,
615
+				],
616
+				'metaboxes'     => $this->_default_espresso_metaboxes,
617
+				'labels'        => [
618
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
+				],
620
+				'require_nonce' => false,
621
+			],
622
+			'add_new_attendee'  => [
623
+				'nav'           => [
624
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
625
+					'order'      => 15,
626
+					'persistent' => false,
627
+				],
628
+				'metaboxes'     => array_merge(
629
+					$this->_default_espresso_metaboxes,
630
+					['_publish_post_box', 'attendee_editor_metaboxes']
631
+				),
632
+				'require_nonce' => false,
633
+			],
634
+			'edit_attendee'     => [
635
+				'nav'           => [
636
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
+					'order'      => 15,
638
+					'persistent' => false,
639
+					'url'        => $ATT_ID
640
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
+						: $this->_admin_base_url,
642
+				],
643
+				'metaboxes'     => ['attendee_editor_metaboxes'],
644
+				'require_nonce' => false,
645
+			],
646
+			'contact_list'      => [
647
+				'nav'           => [
648
+					'label' => esc_html__('Contact List', 'event_espresso'),
649
+					'order' => 20,
650
+				],
651
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
652
+				'help_tabs'     => [
653
+					'registrations_contact_list_help_tab'                       => [
654
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
655
+						'filename' => 'registrations_contact_list',
656
+					],
657
+					'registrations_contact-list_table_column_headings_help_tab' => [
658
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
659
+						'filename' => 'registrations_contact_list_table_column_headings',
660
+					],
661
+					'registrations_contact_list_views_help_tab'                 => [
662
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
663
+						'filename' => 'registrations_contact_list_views',
664
+					],
665
+					'registrations_contact_list_other_help_tab'                 => [
666
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
667
+						'filename' => 'registrations_contact_list_other',
668
+					],
669
+				],
670
+				'metaboxes'     => [],
671
+				'require_nonce' => false,
672
+			],
673
+			// override default cpt routes
674
+			'create_new'        => '',
675
+			'edit'              => '',
676
+		];
677
+	}
678
+
679
+
680
+	/**
681
+	 * The below methods aren't used by this class currently
682
+	 */
683
+	protected function _add_screen_options()
684
+	{
685
+	}
686
+
687
+
688
+	protected function _add_feature_pointers()
689
+	{
690
+	}
691
+
692
+
693
+	public function admin_init()
694
+	{
695
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
696
+			'click "Update Registration Questions" to save your changes',
697
+			'event_espresso'
698
+		);
699
+	}
700
+
701
+
702
+	public function admin_notices()
703
+	{
704
+	}
705
+
706
+
707
+	public function admin_footer_scripts()
708
+	{
709
+	}
710
+
711
+
712
+	/**
713
+	 * get list of registration statuses
714
+	 *
715
+	 * @return void
716
+	 * @throws EE_Error
717
+	 */
718
+	private function _get_registration_status_array()
719
+	{
720
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
721
+	}
722
+
723
+
724
+	/**
725
+	 * @throws InvalidArgumentException
726
+	 * @throws InvalidDataTypeException
727
+	 * @throws InvalidInterfaceException
728
+	 * @since 4.10.2.p
729
+	 */
730
+	protected function _add_screen_options_default()
731
+	{
732
+		$this->_per_page_screen_option();
733
+	}
734
+
735
+
736
+	/**
737
+	 * @throws InvalidArgumentException
738
+	 * @throws InvalidDataTypeException
739
+	 * @throws InvalidInterfaceException
740
+	 * @since 4.10.2.p
741
+	 */
742
+	protected function _add_screen_options_contact_list()
743
+	{
744
+		$page_title              = $this->_admin_page_title;
745
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
746
+		$this->_per_page_screen_option();
747
+		$this->_admin_page_title = $page_title;
748
+	}
749
+
750
+
751
+	public function load_scripts_styles()
752
+	{
753
+		// style
754
+		wp_register_style(
755
+			'espresso_reg',
756
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
757
+			['ee-admin-css'],
758
+			EVENT_ESPRESSO_VERSION
759
+		);
760
+		wp_enqueue_style('espresso_reg');
761
+		// script
762
+		wp_register_script(
763
+			'espresso_reg',
764
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
765
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
766
+			EVENT_ESPRESSO_VERSION,
767
+			true
768
+		);
769
+		wp_enqueue_script('espresso_reg');
770
+	}
771
+
772
+
773
+	/**
774
+	 * @throws EE_Error
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws InvalidInterfaceException
778
+	 * @throws ReflectionException
779
+	 * @since 4.10.2.p
780
+	 */
781
+	public function load_scripts_styles_edit_attendee()
782
+	{
783
+		// stuff to only show up on our attendee edit details page.
784
+		$attendee_details_translations = [
785
+			'att_publish_text' => sprintf(
786
+			/* translators: The date and time */
787
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
788
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
789
+			),
790
+		];
791
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
792
+		wp_enqueue_script('jquery-validate');
793
+	}
794
+
795
+
796
+	/**
797
+	 * @throws EE_Error
798
+	 * @throws InvalidArgumentException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws InvalidInterfaceException
801
+	 * @throws ReflectionException
802
+	 * @since 4.10.2.p
803
+	 */
804
+	public function load_scripts_styles_view_registration()
805
+	{
806
+		// styles
807
+		wp_enqueue_style('espresso-ui-theme');
808
+		// scripts
809
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
810
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
811
+	}
812
+
813
+
814
+	public function load_scripts_styles_contact_list()
815
+	{
816
+		wp_dequeue_style('espresso_reg');
817
+		wp_register_style(
818
+			'espresso_att',
819
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
820
+			['ee-admin-css'],
821
+			EVENT_ESPRESSO_VERSION
822
+		);
823
+		wp_enqueue_style('espresso_att');
824
+	}
825
+
826
+
827
+	public function load_scripts_styles_new_registration()
828
+	{
829
+		wp_register_script(
830
+			'ee-spco-for-admin',
831
+			REG_ASSETS_URL . 'spco_for_admin.js',
832
+			['underscore', 'jquery'],
833
+			EVENT_ESPRESSO_VERSION,
834
+			true
835
+		);
836
+		wp_enqueue_script('ee-spco-for-admin');
837
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
838
+		EE_Form_Section_Proper::wp_enqueue_scripts();
839
+		EED_Ticket_Selector::load_tckt_slctr_assets();
840
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
841
+	}
842
+
843
+
844
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
845
+	{
846
+		add_filter('FHEE_load_EE_messages', '__return_true');
847
+	}
848
+
849
+
850
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
851
+	{
852
+		add_filter('FHEE_load_EE_messages', '__return_true');
853
+	}
854
+
855
+
856
+	/**
857
+	 * @throws EE_Error
858
+	 * @throws InvalidArgumentException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws InvalidInterfaceException
861
+	 * @throws ReflectionException
862
+	 * @since 4.10.2.p
863
+	 */
864
+	protected function _set_list_table_views_default()
865
+	{
866
+		// for notification related bulk actions we need to make sure only active messengers have an option.
867
+		EED_Messages::set_autoloaders();
868
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
869
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
870
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
871
+		// key= bulk_action_slug, value= message type.
872
+		$match_array = [
873
+			'approve_registrations'    => 'registration',
874
+			'decline_registrations'    => 'declined_registration',
875
+			'pending_registrations'    => 'pending_approval',
876
+			'no_approve_registrations' => 'not_approved_registration',
877
+			'cancel_registrations'     => 'cancelled_registration',
878
+		];
879
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
880
+			'ee_send_message',
881
+			'batch_send_messages'
882
+		);
883
+		/** setup reg status bulk actions **/
884
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
885
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
886
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
887
+				'Approve and Notify Registrations',
888
+				'event_espresso'
889
+			);
890
+		}
891
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
892
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
893
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
894
+				'Decline and Notify Registrations',
895
+				'event_espresso'
896
+			);
897
+		}
898
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
899
+			'Set Registrations to Pending Payment',
900
+			'event_espresso'
901
+		);
902
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
903
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
904
+				'Set Registrations to Pending Payment and Notify',
905
+				'event_espresso'
906
+			);
907
+		}
908
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
909
+			'Set Registrations to Not Approved',
910
+			'event_espresso'
911
+		);
912
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
913
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
914
+				'Set Registrations to Not Approved and Notify',
915
+				'event_espresso'
916
+			);
917
+		}
918
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
919
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
920
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
921
+				'Cancel Registrations and Notify',
922
+				'event_espresso'
923
+			);
924
+		}
925
+		$def_reg_status_actions = apply_filters(
926
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
927
+			$def_reg_status_actions,
928
+			$active_mts,
929
+			$can_send
930
+		);
931
+
932
+		$this->_views = [
933
+			'all'   => [
934
+				'slug'        => 'all',
935
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
936
+				'count'       => 0,
937
+				'bulk_action' => array_merge(
938
+					$def_reg_status_actions,
939
+					[
940
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
941
+					]
942
+				),
943
+			],
944
+			'month' => [
945
+				'slug'        => 'month',
946
+				'label'       => esc_html__('This Month', 'event_espresso'),
947
+				'count'       => 0,
948
+				'bulk_action' => array_merge(
949
+					$def_reg_status_actions,
950
+					[
951
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
952
+					]
953
+				),
954
+			],
955
+			'today' => [
956
+				'slug'        => 'today',
957
+				'label'       => sprintf(
958
+					esc_html__('Today - %s', 'event_espresso'),
959
+					date('M d, Y', current_time('timestamp'))
960
+				),
961
+				'count'       => 0,
962
+				'bulk_action' => array_merge(
963
+					$def_reg_status_actions,
964
+					[
965
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
966
+					]
967
+				),
968
+			],
969
+		];
970
+		if (
971
+			EE_Registry::instance()->CAP->current_user_can(
972
+				'ee_delete_registrations',
973
+				'espresso_registrations_delete_registration'
974
+			)
975
+		) {
976
+			$this->_views['incomplete'] = [
977
+				'slug'        => 'incomplete',
978
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
979
+				'count'       => 0,
980
+				'bulk_action' => [
981
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
982
+				],
983
+			];
984
+			$this->_views['trash']      = [
985
+				'slug'        => 'trash',
986
+				'label'       => esc_html__('Trash', 'event_espresso'),
987
+				'count'       => 0,
988
+				'bulk_action' => [
989
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
990
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
991
+				],
992
+			];
993
+		}
994
+	}
995
+
996
+
997
+	protected function _set_list_table_views_contact_list()
998
+	{
999
+		$this->_views = [
1000
+			'in_use' => [
1001
+				'slug'        => 'in_use',
1002
+				'label'       => esc_html__('In Use', 'event_espresso'),
1003
+				'count'       => 0,
1004
+				'bulk_action' => [
1005
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1006
+				],
1007
+			],
1008
+		];
1009
+		if (
1010
+			EE_Registry::instance()->CAP->current_user_can(
1011
+				'ee_delete_contacts',
1012
+				'espresso_registrations_trash_attendees'
1013
+			)
1014
+		) {
1015
+			$this->_views['trash'] = [
1016
+				'slug'        => 'trash',
1017
+				'label'       => esc_html__('Trash', 'event_espresso'),
1018
+				'count'       => 0,
1019
+				'bulk_action' => [
1020
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1021
+				],
1022
+			];
1023
+		}
1024
+	}
1025
+
1026
+
1027
+	/**
1028
+	 * @return array
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	protected function _registration_legend_items()
1032
+	{
1033
+		$fc_items = [
1034
+			'star-icon'        => [
1035
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1036
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1037
+			],
1038
+			'view_details'     => [
1039
+				'class' => 'dashicons dashicons-clipboard',
1040
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1041
+			],
1042
+			'edit_attendee'    => [
1043
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1044
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1045
+			],
1046
+			'view_transaction' => [
1047
+				'class' => 'dashicons dashicons-cart',
1048
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1049
+			],
1050
+			'view_invoice'     => [
1051
+				'class' => 'dashicons dashicons-media-spreadsheet',
1052
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1053
+			],
1054
+		];
1055
+		if (
1056
+			EE_Registry::instance()->CAP->current_user_can(
1057
+				'ee_send_message',
1058
+				'espresso_registrations_resend_registration'
1059
+			)
1060
+		) {
1061
+			$fc_items['resend_registration'] = [
1062
+				'class' => 'dashicons dashicons-email-alt',
1063
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1064
+			];
1065
+		} else {
1066
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1067
+		}
1068
+		if (
1069
+			EE_Registry::instance()->CAP->current_user_can(
1070
+				'ee_read_global_messages',
1071
+				'view_filtered_messages'
1072
+			)
1073
+		) {
1074
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1075
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1076
+				$fc_items['view_related_messages'] = [
1077
+					'class' => $related_for_icon['css_class'],
1078
+					'desc'  => $related_for_icon['label'],
1079
+				];
1080
+			}
1081
+		}
1082
+		$sc_items = [
1083
+			'approved_status'   => [
1084
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1085
+				'desc'  => EEH_Template::pretty_status(
1086
+					EEM_Registration::status_id_approved,
1087
+					false,
1088
+					'sentence'
1089
+				),
1090
+			],
1091
+			'pending_status'    => [
1092
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1093
+				'desc'  => EEH_Template::pretty_status(
1094
+					EEM_Registration::status_id_pending_payment,
1095
+					false,
1096
+					'sentence'
1097
+				),
1098
+			],
1099
+			'wait_list'         => [
1100
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1101
+				'desc'  => EEH_Template::pretty_status(
1102
+					EEM_Registration::status_id_wait_list,
1103
+					false,
1104
+					'sentence'
1105
+				),
1106
+			],
1107
+			'incomplete_status' => [
1108
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1109
+				'desc'  => EEH_Template::pretty_status(
1110
+					EEM_Registration::status_id_incomplete,
1111
+					false,
1112
+					'sentence'
1113
+				),
1114
+			],
1115
+			'not_approved'      => [
1116
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1117
+				'desc'  => EEH_Template::pretty_status(
1118
+					EEM_Registration::status_id_not_approved,
1119
+					false,
1120
+					'sentence'
1121
+				),
1122
+			],
1123
+			'declined_status'   => [
1124
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1125
+				'desc'  => EEH_Template::pretty_status(
1126
+					EEM_Registration::status_id_declined,
1127
+					false,
1128
+					'sentence'
1129
+				),
1130
+			],
1131
+			'cancelled_status'  => [
1132
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1133
+				'desc'  => EEH_Template::pretty_status(
1134
+					EEM_Registration::status_id_cancelled,
1135
+					false,
1136
+					'sentence'
1137
+				),
1138
+			],
1139
+		];
1140
+		return array_merge($fc_items, $sc_items);
1141
+	}
1142
+
1143
+
1144
+
1145
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1146
+
1147
+
1148
+	/**
1149
+	 * @throws DomainException
1150
+	 * @throws EE_Error
1151
+	 * @throws InvalidArgumentException
1152
+	 * @throws InvalidDataTypeException
1153
+	 * @throws InvalidInterfaceException
1154
+	 */
1155
+	protected function _registrations_overview_list_table()
1156
+	{
1157
+		$this->appendAddNewRegistrationButtonToPageTitle();
1158
+		$header_text                  = '';
1159
+		$admin_page_header_decorators = [
1160
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1161
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1162
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1163
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1164
+		];
1165
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1166
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1167
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1168
+		}
1169
+		$this->_template_args['admin_page_header'] = $header_text;
1170
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1171
+		$this->display_admin_list_table_page_with_no_sidebar();
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * @throws EE_Error
1177
+	 * @throws InvalidArgumentException
1178
+	 * @throws InvalidDataTypeException
1179
+	 * @throws InvalidInterfaceException
1180
+	 */
1181
+	private function appendAddNewRegistrationButtonToPageTitle()
1182
+	{
1183
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1184
+		if (
1185
+			$EVT_ID
1186
+			&& EE_Registry::instance()->CAP->current_user_can(
1187
+				'ee_edit_registrations',
1188
+				'espresso_registrations_new_registration',
1189
+				$EVT_ID
1190
+			)
1191
+		) {
1192
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1193
+				'new_registration',
1194
+				'add-registrant',
1195
+				['event_id' => $EVT_ID],
1196
+				'add-new-h2'
1197
+			);
1198
+		}
1199
+	}
1200
+
1201
+
1202
+	/**
1203
+	 * This sets the _registration property for the registration details screen
1204
+	 *
1205
+	 * @return void
1206
+	 * @throws EE_Error
1207
+	 * @throws InvalidArgumentException
1208
+	 * @throws InvalidDataTypeException
1209
+	 * @throws InvalidInterfaceException
1210
+	 */
1211
+	private function _set_registration_object()
1212
+	{
1213
+		// get out if we've already set the object
1214
+		if ($this->_registration instanceof EE_Registration) {
1215
+			return;
1216
+		}
1217
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1218
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1219
+			return;
1220
+		}
1221
+		$error_msg = sprintf(
1222
+			esc_html__(
1223
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1224
+				'event_espresso'
1225
+			),
1226
+			$REG_ID
1227
+		);
1228
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1229
+		$this->_registration = null;
1230
+	}
1231
+
1232
+
1233
+	/**
1234
+	 * Used to retrieve registrations for the list table.
1235
+	 *
1236
+	 * @param int  $per_page
1237
+	 * @param bool $count
1238
+	 * @param bool $this_month
1239
+	 * @param bool $today
1240
+	 * @return EE_Registration[]|int
1241
+	 * @throws EE_Error
1242
+	 * @throws InvalidArgumentException
1243
+	 * @throws InvalidDataTypeException
1244
+	 * @throws InvalidInterfaceException
1245
+	 */
1246
+	public function get_registrations(
1247
+		$per_page = 10,
1248
+		$count = false,
1249
+		$this_month = false,
1250
+		$today = false
1251
+	) {
1252
+		if ($this_month) {
1253
+			$this->request->setRequestParam('status', 'month');
1254
+		}
1255
+		if ($today) {
1256
+			$this->request->setRequestParam('status', 'today');
1257
+		}
1258
+		$query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1259
+		/**
1260
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
+		 *
1262
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
+		 *                      or if you have the development copy of EE you can view this at the path:
1265
+		 *                      /docs/G--Model-System/model-query-params.md
1266
+		 */
1267
+		$query_params['group_by'] = '';
1268
+
1269
+		return $count
1270
+			? $this->getRegistrationModel()->count($query_params)
1271
+			/** @type EE_Registration[] */
1272
+			: $this->getRegistrationModel()->get_all($query_params);
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1278
+	 * Note: this listens to values on the request for some of the query parameters.
1279
+	 *
1280
+	 * @param array $request
1281
+	 * @param int   $per_page
1282
+	 * @param bool  $count
1283
+	 * @return array
1284
+	 * @throws EE_Error
1285
+	 * @throws InvalidArgumentException
1286
+	 * @throws InvalidDataTypeException
1287
+	 * @throws InvalidInterfaceException
1288
+	 */
1289
+	protected function _get_registration_query_parameters(
1290
+		$request = [],
1291
+		$per_page = 10,
1292
+		$count = false
1293
+	) {
1294
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1295
+		$list_table_query_builder = $this->getLoader()->getNew(
1296
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1297
+			[null, null, $request]
1298
+		);
1299
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1300
+	}
1301
+
1302
+
1303
+	public function get_registration_status_array()
1304
+	{
1305
+		return self::$_reg_status;
1306
+	}
1307
+
1308
+
1309
+
1310
+
1311
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1312
+	/**
1313
+	 * generates HTML for the View Registration Details Admin page
1314
+	 *
1315
+	 * @return void
1316
+	 * @throws DomainException
1317
+	 * @throws EE_Error
1318
+	 * @throws InvalidArgumentException
1319
+	 * @throws InvalidDataTypeException
1320
+	 * @throws InvalidInterfaceException
1321
+	 * @throws EntityNotFoundException
1322
+	 * @throws ReflectionException
1323
+	 */
1324
+	protected function _registration_details()
1325
+	{
1326
+		$this->_template_args = [];
1327
+		$this->_set_registration_object();
1328
+		if (is_object($this->_registration)) {
1329
+			$transaction                                   = $this->_registration->transaction()
1330
+				? $this->_registration->transaction()
1331
+				: EE_Transaction::new_instance();
1332
+			$this->_session                                = $transaction->session_data();
1333
+			$event_id                                      = $this->_registration->event_ID();
1334
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1335
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1336
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1337
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1338
+			$this->_template_args['grand_total']           = $transaction->total();
1339
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1340
+			// link back to overview
1341
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1342
+			$this->_template_args['registration']                = $this->_registration;
1343
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
+				[
1345
+					'action'   => 'default',
1346
+					'event_id' => $event_id,
1347
+				],
1348
+				REG_ADMIN_URL
1349
+			);
1350
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1351
+				[
1352
+					'action' => 'default',
1353
+					'EVT_ID' => $event_id,
1354
+					'page'   => 'espresso_transactions',
1355
+				],
1356
+				admin_url('admin.php')
1357
+			);
1358
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1359
+				[
1360
+					'page'   => 'espresso_events',
1361
+					'action' => 'edit',
1362
+					'post'   => $event_id,
1363
+				],
1364
+				admin_url('admin.php')
1365
+			);
1366
+			// next and previous links
1367
+			$next_reg                                      = $this->_registration->next(
1368
+				null,
1369
+				[],
1370
+				'REG_ID'
1371
+			);
1372
+			$this->_template_args['next_registration']     = $next_reg
1373
+				? $this->_next_link(
1374
+					EE_Admin_Page::add_query_args_and_nonce(
1375
+						[
1376
+							'action'  => 'view_registration',
1377
+							'_REG_ID' => $next_reg['REG_ID'],
1378
+						],
1379
+						REG_ADMIN_URL
1380
+					),
1381
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1382
+				)
1383
+				: '';
1384
+			$previous_reg                                  = $this->_registration->previous(
1385
+				null,
1386
+				[],
1387
+				'REG_ID'
1388
+			);
1389
+			$this->_template_args['previous_registration'] = $previous_reg
1390
+				? $this->_previous_link(
1391
+					EE_Admin_Page::add_query_args_and_nonce(
1392
+						[
1393
+							'action'  => 'view_registration',
1394
+							'_REG_ID' => $previous_reg['REG_ID'],
1395
+						],
1396
+						REG_ADMIN_URL
1397
+					),
1398
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1399
+				)
1400
+				: '';
1401
+			// grab header
1402
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1403
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1404
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1405
+				$template_path,
1406
+				$this->_template_args,
1407
+				true
1408
+			);
1409
+		} else {
1410
+			$this->_template_args['admin_page_header'] = '';
1411
+			$this->_display_espresso_notices();
1412
+		}
1413
+		// the details template wrapper
1414
+		$this->display_admin_page_with_sidebar();
1415
+	}
1416
+
1417
+
1418
+	/**
1419
+	 * @throws EE_Error
1420
+	 * @throws InvalidArgumentException
1421
+	 * @throws InvalidDataTypeException
1422
+	 * @throws InvalidInterfaceException
1423
+	 * @throws ReflectionException
1424
+	 * @since 4.10.2.p
1425
+	 */
1426
+	protected function _registration_details_metaboxes()
1427
+	{
1428
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1429
+		$this->_set_registration_object();
1430
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1431
+		add_meta_box(
1432
+			'edit-reg-status-mbox',
1433
+			esc_html__('Registration Status', 'event_espresso'),
1434
+			[$this, 'set_reg_status_buttons_metabox'],
1435
+			$this->_wp_page_slug,
1436
+			'normal',
1437
+			'high'
1438
+		);
1439
+		add_meta_box(
1440
+			'edit-reg-details-mbox',
1441
+			esc_html__('Registration Details', 'event_espresso'),
1442
+			[$this, '_reg_details_meta_box'],
1443
+			$this->_wp_page_slug,
1444
+			'normal',
1445
+			'high'
1446
+		);
1447
+		if (
1448
+			$attendee instanceof EE_Attendee
1449
+			&& EE_Registry::instance()->CAP->current_user_can(
1450
+				'ee_read_registration',
1451
+				'edit-reg-questions-mbox',
1452
+				$this->_registration->ID()
1453
+			)
1454
+		) {
1455
+			add_meta_box(
1456
+				'edit-reg-questions-mbox',
1457
+				esc_html__('Registration Form Answers', 'event_espresso'),
1458
+				[$this, '_reg_questions_meta_box'],
1459
+				$this->_wp_page_slug,
1460
+				'normal',
1461
+				'high'
1462
+			);
1463
+		}
1464
+		add_meta_box(
1465
+			'edit-reg-registrant-mbox',
1466
+			esc_html__('Contact Details', 'event_espresso'),
1467
+			[$this, '_reg_registrant_side_meta_box'],
1468
+			$this->_wp_page_slug,
1469
+			'side',
1470
+			'high'
1471
+		);
1472
+		if ($this->_registration->group_size() > 1) {
1473
+			add_meta_box(
1474
+				'edit-reg-attendees-mbox',
1475
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1476
+				[$this, '_reg_attendees_meta_box'],
1477
+				$this->_wp_page_slug,
1478
+				'normal',
1479
+				'high'
1480
+			);
1481
+		}
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * set_reg_status_buttons_metabox
1487
+	 *
1488
+	 * @return void
1489
+	 * @throws EE_Error
1490
+	 * @throws EntityNotFoundException
1491
+	 * @throws InvalidArgumentException
1492
+	 * @throws InvalidDataTypeException
1493
+	 * @throws InvalidInterfaceException
1494
+	 * @throws ReflectionException
1495
+	 */
1496
+	public function set_reg_status_buttons_metabox()
1497
+	{
1498
+		$this->_set_registration_object();
1499
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1500
+		$output                 = $change_reg_status_form->form_open(
1501
+			self::add_query_args_and_nonce(
1502
+				[
1503
+					'action' => 'change_reg_status',
1504
+				],
1505
+				REG_ADMIN_URL
1506
+			)
1507
+		);
1508
+		$output                 .= $change_reg_status_form->get_html();
1509
+		$output                 .= $change_reg_status_form->form_close();
1510
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1511
+	}
1512
+
1513
+
1514
+	/**
1515
+	 * @return EE_Form_Section_Proper
1516
+	 * @throws EE_Error
1517
+	 * @throws InvalidArgumentException
1518
+	 * @throws InvalidDataTypeException
1519
+	 * @throws InvalidInterfaceException
1520
+	 * @throws EntityNotFoundException
1521
+	 * @throws ReflectionException
1522
+	 */
1523
+	protected function _generate_reg_status_change_form()
1524
+	{
1525
+		$reg_status_change_form_array = [
1526
+			'name'            => 'reg_status_change_form',
1527
+			'html_id'         => 'reg-status-change-form',
1528
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1529
+			'subsections'     => [
1530
+				'return'         => new EE_Hidden_Input(
1531
+					[
1532
+						'name'    => 'return',
1533
+						'default' => 'view_registration',
1534
+					]
1535
+				),
1536
+				'REG_ID'         => new EE_Hidden_Input(
1537
+					[
1538
+						'name'    => 'REG_ID',
1539
+						'default' => $this->_registration->ID(),
1540
+					]
1541
+				),
1542
+				'current_status' => new EE_Form_Section_HTML(
1543
+					EEH_HTML::table(
1544
+						EEH_HTML::tr(
1545
+							EEH_HTML::th(
1546
+								EEH_HTML::label(
1547
+									EEH_HTML::strong(
1548
+										esc_html__('Current Registration Status', 'event_espresso')
1549
+									)
1550
+								)
1551
+							)
1552
+							. EEH_HTML::td(
1553
+								EEH_HTML::strong(
1554
+									$this->_registration->pretty_status(),
1555
+									'',
1556
+									'status-' . $this->_registration->status_ID(),
1557
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1558
+								)
1559
+							)
1560
+						)
1561
+					)
1562
+				),
1563
+			],
1564
+		];
1565
+		if (
1566
+			EE_Registry::instance()->CAP->current_user_can(
1567
+				'ee_edit_registration',
1568
+				'toggle_registration_status',
1569
+				$this->_registration->ID()
1570
+			)
1571
+		) {
1572
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1573
+				$this->_get_reg_statuses(),
1574
+				[
1575
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1576
+					'default'         => $this->_registration->status_ID(),
1577
+				]
1578
+			);
1579
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1580
+				[
1581
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1582
+					'default'         => false,
1583
+					'html_help_text'  => esc_html__(
1584
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1585
+						'event_espresso'
1586
+					),
1587
+				]
1588
+			);
1589
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1590
+				[
1591
+					'html_class'      => 'button-primary',
1592
+					'html_label_text' => '&nbsp;',
1593
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1594
+				]
1595
+			);
1596
+		}
1597
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1598
+	}
1599
+
1600
+
1601
+	/**
1602
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1603
+	 *
1604
+	 * @return array
1605
+	 * @throws EE_Error
1606
+	 * @throws InvalidArgumentException
1607
+	 * @throws InvalidDataTypeException
1608
+	 * @throws InvalidInterfaceException
1609
+	 * @throws EntityNotFoundException
1610
+	 */
1611
+	protected function _get_reg_statuses()
1612
+	{
1613
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1614
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1615
+		// get current reg status
1616
+		$current_status = $this->_registration->status_ID();
1617
+		// is registration for free event? This will determine whether to display the pending payment option
1618
+		if (
1619
+			$current_status !== EEM_Registration::status_id_pending_payment
1620
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1621
+		) {
1622
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1623
+		}
1624
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1625
+	}
1626
+
1627
+
1628
+	/**
1629
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1630
+	 *
1631
+	 * @param bool $status REG status given for changing registrations to.
1632
+	 * @param bool $notify Whether to send messages notifications or not.
1633
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1634
+	 * @throws DomainException
1635
+	 * @throws EE_Error
1636
+	 * @throws EntityNotFoundException
1637
+	 * @throws InvalidArgumentException
1638
+	 * @throws InvalidDataTypeException
1639
+	 * @throws InvalidInterfaceException
1640
+	 * @throws ReflectionException
1641
+	 * @throws RuntimeException
1642
+	 */
1643
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1644
+	{
1645
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1646
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1647
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1648
+
1649
+		// sanitize $REG_IDs
1650
+		$REG_IDs = array_map('absint', $REG_IDs);
1651
+		// and remove empty entries
1652
+		$REG_IDs = array_filter($REG_IDs);
1653
+
1654
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1655
+
1656
+		/**
1657
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1658
+		 * Currently this value is used downstream by the _process_resend_registration method.
1659
+		 *
1660
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1661
+		 * @param bool                     $status           The status registrations were changed to.
1662
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1663
+		 * @param Registrations_Admin_Page $admin_page_object
1664
+		 */
1665
+		$REG_ID = apply_filters(
1666
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1667
+			$result['REG_ID'],
1668
+			$status,
1669
+			$result['success'],
1670
+			$this
1671
+		);
1672
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1673
+
1674
+		// notify?
1675
+		if (
1676
+			$notify
1677
+			&& $result['success']
1678
+			&& ! empty($REG_ID)
1679
+			&& EE_Registry::instance()->CAP->current_user_can(
1680
+				'ee_send_message',
1681
+				'espresso_registrations_resend_registration'
1682
+			)
1683
+		) {
1684
+			$this->_process_resend_registration();
1685
+		}
1686
+		return $result;
1687
+	}
1688
+
1689
+
1690
+	/**
1691
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1692
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1693
+	 *
1694
+	 * @param array  $REG_IDs
1695
+	 * @param string $status
1696
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1697
+	 *                       slug sent with setting the registration status.
1698
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1699
+	 * @throws EE_Error
1700
+	 * @throws InvalidArgumentException
1701
+	 * @throws InvalidDataTypeException
1702
+	 * @throws InvalidInterfaceException
1703
+	 * @throws ReflectionException
1704
+	 * @throws RuntimeException
1705
+	 * @throws EntityNotFoundException
1706
+	 * @throws DomainException
1707
+	 */
1708
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1709
+	{
1710
+		$success = false;
1711
+		// typecast $REG_IDs
1712
+		$REG_IDs = (array) $REG_IDs;
1713
+		if (! empty($REG_IDs)) {
1714
+			$success = true;
1715
+			// set default status if none is passed
1716
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1717
+			$status_context = $notify
1718
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1719
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1720
+			// loop through REG_ID's and change status
1721
+			foreach ($REG_IDs as $REG_ID) {
1722
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1723
+				if ($registration instanceof EE_Registration) {
1724
+					$registration->set_status(
1725
+						$status,
1726
+						false,
1727
+						new Context(
1728
+							$status_context,
1729
+							esc_html__(
1730
+								'Manually triggered status change on a Registration Admin Page route.',
1731
+								'event_espresso'
1732
+							)
1733
+						)
1734
+					);
1735
+					$result = $registration->save();
1736
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1737
+					$success = $result !== false ? $success : false;
1738
+				}
1739
+			}
1740
+		}
1741
+
1742
+		// return $success and processed registrations
1743
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1744
+	}
1745
+
1746
+
1747
+	/**
1748
+	 * Common logic for setting up success message and redirecting to appropriate route
1749
+	 *
1750
+	 * @param string $STS_ID status id for the registration changed to
1751
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1752
+	 * @return void
1753
+	 * @throws DomainException
1754
+	 * @throws EE_Error
1755
+	 * @throws EntityNotFoundException
1756
+	 * @throws InvalidArgumentException
1757
+	 * @throws InvalidDataTypeException
1758
+	 * @throws InvalidInterfaceException
1759
+	 * @throws ReflectionException
1760
+	 * @throws RuntimeException
1761
+	 */
1762
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1763
+	{
1764
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1765
+			: ['success' => false];
1766
+		$success = isset($result['success']) && $result['success'];
1767
+		// setup success message
1768
+		if ($success) {
1769
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1770
+				$msg = sprintf(
1771
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1772
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1773
+				);
1774
+			} else {
1775
+				$msg = sprintf(
1776
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1777
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1778
+				);
1779
+			}
1780
+			EE_Error::add_success($msg);
1781
+		} else {
1782
+			EE_Error::add_error(
1783
+				esc_html__(
1784
+					'Something went wrong, and the status was not changed',
1785
+					'event_espresso'
1786
+				),
1787
+				__FILE__,
1788
+				__LINE__,
1789
+				__FUNCTION__
1790
+			);
1791
+		}
1792
+		$return = $this->request->getRequestParam('return');
1793
+		$route  = $return === 'view_registration'
1794
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1795
+			: ['action' => 'default'];
1796
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1797
+		$this->_redirect_after_action($success, '', '', $route, true);
1798
+	}
1799
+
1800
+
1801
+	/**
1802
+	 * incoming reg status change from reg details page.
1803
+	 *
1804
+	 * @return void
1805
+	 * @throws EE_Error
1806
+	 * @throws EntityNotFoundException
1807
+	 * @throws InvalidArgumentException
1808
+	 * @throws InvalidDataTypeException
1809
+	 * @throws InvalidInterfaceException
1810
+	 * @throws ReflectionException
1811
+	 * @throws RuntimeException
1812
+	 * @throws DomainException
1813
+	 */
1814
+	protected function _change_reg_status()
1815
+	{
1816
+		$this->request->setRequestParam('return', 'view_registration');
1817
+		// set notify based on whether the send notifications toggle is set or not
1818
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1819
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1820
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1821
+		switch ($reg_status) {
1822
+			case EEM_Registration::status_id_approved:
1823
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1824
+				$this->approve_registration($notify);
1825
+				break;
1826
+			case EEM_Registration::status_id_pending_payment:
1827
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1828
+				$this->pending_registration($notify);
1829
+				break;
1830
+			case EEM_Registration::status_id_not_approved:
1831
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1832
+				$this->not_approve_registration($notify);
1833
+				break;
1834
+			case EEM_Registration::status_id_declined:
1835
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1836
+				$this->decline_registration($notify);
1837
+				break;
1838
+			case EEM_Registration::status_id_cancelled:
1839
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1840
+				$this->cancel_registration($notify);
1841
+				break;
1842
+			case EEM_Registration::status_id_wait_list:
1843
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1844
+				$this->wait_list_registration($notify);
1845
+				break;
1846
+			case EEM_Registration::status_id_incomplete:
1847
+			default:
1848
+				$this->request->unSetRequestParam('return');
1849
+				$this->_reg_status_change_return('');
1850
+				break;
1851
+		}
1852
+	}
1853
+
1854
+
1855
+	/**
1856
+	 * Callback for bulk action routes.
1857
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1858
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1859
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1860
+	 * when an action is happening on just a single registration).
1861
+	 *
1862
+	 * @param      $action
1863
+	 * @param bool $notify
1864
+	 */
1865
+	protected function bulk_action_on_registrations($action, $notify = false)
1866
+	{
1867
+		do_action(
1868
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1869
+			$this,
1870
+			$action,
1871
+			$notify
1872
+		);
1873
+		$method = $action . '_registration';
1874
+		if (method_exists($this, $method)) {
1875
+			$this->$method($notify);
1876
+		}
1877
+	}
1878
+
1879
+
1880
+	/**
1881
+	 * approve_registration
1882
+	 *
1883
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1884
+	 * @return void
1885
+	 * @throws EE_Error
1886
+	 * @throws EntityNotFoundException
1887
+	 * @throws InvalidArgumentException
1888
+	 * @throws InvalidDataTypeException
1889
+	 * @throws InvalidInterfaceException
1890
+	 * @throws ReflectionException
1891
+	 * @throws RuntimeException
1892
+	 * @throws DomainException
1893
+	 */
1894
+	protected function approve_registration($notify = false)
1895
+	{
1896
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1897
+	}
1898
+
1899
+
1900
+	/**
1901
+	 * decline_registration
1902
+	 *
1903
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1904
+	 * @return void
1905
+	 * @throws EE_Error
1906
+	 * @throws EntityNotFoundException
1907
+	 * @throws InvalidArgumentException
1908
+	 * @throws InvalidDataTypeException
1909
+	 * @throws InvalidInterfaceException
1910
+	 * @throws ReflectionException
1911
+	 * @throws RuntimeException
1912
+	 * @throws DomainException
1913
+	 */
1914
+	protected function decline_registration($notify = false)
1915
+	{
1916
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
+	}
1918
+
1919
+
1920
+	/**
1921
+	 * cancel_registration
1922
+	 *
1923
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1924
+	 * @return void
1925
+	 * @throws EE_Error
1926
+	 * @throws EntityNotFoundException
1927
+	 * @throws InvalidArgumentException
1928
+	 * @throws InvalidDataTypeException
1929
+	 * @throws InvalidInterfaceException
1930
+	 * @throws ReflectionException
1931
+	 * @throws RuntimeException
1932
+	 * @throws DomainException
1933
+	 */
1934
+	protected function cancel_registration($notify = false)
1935
+	{
1936
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1937
+	}
1938
+
1939
+
1940
+	/**
1941
+	 * not_approve_registration
1942
+	 *
1943
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1944
+	 * @return void
1945
+	 * @throws EE_Error
1946
+	 * @throws EntityNotFoundException
1947
+	 * @throws InvalidArgumentException
1948
+	 * @throws InvalidDataTypeException
1949
+	 * @throws InvalidInterfaceException
1950
+	 * @throws ReflectionException
1951
+	 * @throws RuntimeException
1952
+	 * @throws DomainException
1953
+	 */
1954
+	protected function not_approve_registration($notify = false)
1955
+	{
1956
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1957
+	}
1958
+
1959
+
1960
+	/**
1961
+	 * decline_registration
1962
+	 *
1963
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1964
+	 * @return void
1965
+	 * @throws EE_Error
1966
+	 * @throws EntityNotFoundException
1967
+	 * @throws InvalidArgumentException
1968
+	 * @throws InvalidDataTypeException
1969
+	 * @throws InvalidInterfaceException
1970
+	 * @throws ReflectionException
1971
+	 * @throws RuntimeException
1972
+	 * @throws DomainException
1973
+	 */
1974
+	protected function pending_registration($notify = false)
1975
+	{
1976
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1977
+	}
1978
+
1979
+
1980
+	/**
1981
+	 * waitlist_registration
1982
+	 *
1983
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1984
+	 * @return void
1985
+	 * @throws EE_Error
1986
+	 * @throws EntityNotFoundException
1987
+	 * @throws InvalidArgumentException
1988
+	 * @throws InvalidDataTypeException
1989
+	 * @throws InvalidInterfaceException
1990
+	 * @throws ReflectionException
1991
+	 * @throws RuntimeException
1992
+	 * @throws DomainException
1993
+	 */
1994
+	protected function wait_list_registration($notify = false)
1995
+	{
1996
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
+	}
1998
+
1999
+
2000
+	/**
2001
+	 * generates HTML for the Registration main meta box
2002
+	 *
2003
+	 * @return void
2004
+	 * @throws DomainException
2005
+	 * @throws EE_Error
2006
+	 * @throws InvalidArgumentException
2007
+	 * @throws InvalidDataTypeException
2008
+	 * @throws InvalidInterfaceException
2009
+	 * @throws ReflectionException
2010
+	 * @throws EntityNotFoundException
2011
+	 */
2012
+	public function _reg_details_meta_box()
2013
+	{
2014
+		EEH_Autoloader::register_line_item_display_autoloaders();
2015
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2016
+		EE_Registry::instance()->load_helper('Line_Item');
2017
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2018
+			: EE_Transaction::new_instance();
2019
+		$this->_session = $transaction->session_data();
2020
+		$filters        = new EE_Line_Item_Filter_Collection();
2021
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2022
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2023
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2024
+			$filters,
2025
+			$transaction->total_line_item()
2026
+		);
2027
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2028
+		$line_item_display                       = new EE_Line_Item_Display(
2029
+			'reg_admin_table',
2030
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2031
+		);
2032
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2033
+			$filtered_line_item_tree,
2034
+			['EE_Registration' => $this->_registration]
2035
+		);
2036
+		$attendee                                = $this->_registration->attendee();
2037
+		if (
2038
+			EE_Registry::instance()->CAP->current_user_can(
2039
+				'ee_read_transaction',
2040
+				'espresso_transactions_view_transaction'
2041
+			)
2042
+		) {
2043
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2044
+				EE_Admin_Page::add_query_args_and_nonce(
2045
+					[
2046
+						'action' => 'view_transaction',
2047
+						'TXN_ID' => $transaction->ID(),
2048
+					],
2049
+					TXN_ADMIN_URL
2050
+				),
2051
+				esc_html__(' View Transaction', 'event_espresso'),
2052
+				'button secondary-button right',
2053
+				'dashicons dashicons-cart'
2054
+			);
2055
+		} else {
2056
+			$this->_template_args['view_transaction_button'] = '';
2057
+		}
2058
+		if (
2059
+			$attendee instanceof EE_Attendee
2060
+			&& EE_Registry::instance()->CAP->current_user_can(
2061
+				'ee_send_message',
2062
+				'espresso_registrations_resend_registration'
2063
+			)
2064
+		) {
2065
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2066
+				EE_Admin_Page::add_query_args_and_nonce(
2067
+					[
2068
+						'action'      => 'resend_registration',
2069
+						'_REG_ID'     => $this->_registration->ID(),
2070
+						'redirect_to' => 'view_registration',
2071
+					],
2072
+					REG_ADMIN_URL
2073
+				),
2074
+				esc_html__(' Resend Registration', 'event_espresso'),
2075
+				'button secondary-button right',
2076
+				'dashicons dashicons-email-alt'
2077
+			);
2078
+		} else {
2079
+			$this->_template_args['resend_registration_button'] = '';
2080
+		}
2081
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2082
+		$payment                               = $transaction->get_first_related('Payment');
2083
+		$payment                               = ! $payment instanceof EE_Payment
2084
+			? EE_Payment::new_instance()
2085
+			: $payment;
2086
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2087
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2088
+			? EE_Payment_Method::new_instance()
2089
+			: $payment_method;
2090
+		$reg_details                           = [
2091
+			'payment_method'       => $payment_method->name(),
2092
+			'response_msg'         => $payment->gateway_response(),
2093
+			'registration_id'      => $this->_registration->get('REG_code'),
2094
+			'registration_session' => $this->_registration->session_ID(),
2095
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2096
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2097
+		];
2098
+		if (isset($reg_details['registration_id'])) {
2099
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2100
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2101
+				'Registration ID',
2102
+				'event_espresso'
2103
+			);
2104
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2105
+		}
2106
+		if (isset($reg_details['payment_method'])) {
2107
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2108
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2109
+				'Most Recent Payment Method',
2110
+				'event_espresso'
2111
+			);
2112
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2113
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2114
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2115
+				'Payment method response',
2116
+				'event_espresso'
2117
+			);
2118
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2119
+		}
2120
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2121
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2122
+			'Registration Session',
2123
+			'event_espresso'
2124
+		);
2125
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2126
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2127
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2128
+			'Registration placed from IP',
2129
+			'event_espresso'
2130
+		);
2131
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2132
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2133
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2134
+			'Registrant User Agent',
2135
+			'event_espresso'
2136
+		);
2137
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2138
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2139
+			[
2140
+				'action'   => 'default',
2141
+				'event_id' => $this->_registration->event_ID(),
2142
+			],
2143
+			REG_ADMIN_URL
2144
+		);
2145
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2146
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2147
+		$template_path                                                        =
2148
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2149
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2150
+	}
2151
+
2152
+
2153
+	/**
2154
+	 * generates HTML for the Registration Questions meta box.
2155
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2156
+	 * otherwise uses new forms system
2157
+	 *
2158
+	 * @return void
2159
+	 * @throws DomainException
2160
+	 * @throws EE_Error
2161
+	 * @throws InvalidArgumentException
2162
+	 * @throws InvalidDataTypeException
2163
+	 * @throws InvalidInterfaceException
2164
+	 * @throws ReflectionException
2165
+	 */
2166
+	public function _reg_questions_meta_box()
2167
+	{
2168
+		// allow someone to override this method entirely
2169
+		if (
2170
+			apply_filters(
2171
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2172
+				true,
2173
+				$this,
2174
+				$this->_registration
2175
+			)
2176
+		) {
2177
+			$form                                              = $this->_get_reg_custom_questions_form(
2178
+				$this->_registration->ID()
2179
+			);
2180
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2181
+				? $form->get_html_and_js()
2182
+				: '';
2183
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2184
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2185
+			$template_path                                     =
2186
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2187
+			EEH_Template::display_template($template_path, $this->_template_args);
2188
+		}
2189
+	}
2190
+
2191
+
2192
+	/**
2193
+	 * form_before_question_group
2194
+	 *
2195
+	 * @param string $output
2196
+	 * @return        string
2197
+	 * @deprecated    as of 4.8.32.rc.000
2198
+	 */
2199
+	public function form_before_question_group($output)
2200
+	{
2201
+		EE_Error::doing_it_wrong(
2202
+			__CLASS__ . '::' . __FUNCTION__,
2203
+			esc_html__(
2204
+				'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.',
2205
+				'event_espresso'
2206
+			),
2207
+			'4.8.32.rc.000'
2208
+		);
2209
+		return '
2210 2210
 	<table class="form-table ee-width-100">
2211 2211
 		<tbody>
2212 2212
 			';
2213
-    }
2214
-
2215
-
2216
-    /**
2217
-     * form_after_question_group
2218
-     *
2219
-     * @param string $output
2220
-     * @return        string
2221
-     * @deprecated    as of 4.8.32.rc.000
2222
-     */
2223
-    public function form_after_question_group($output)
2224
-    {
2225
-        EE_Error::doing_it_wrong(
2226
-            __CLASS__ . '::' . __FUNCTION__,
2227
-            esc_html__(
2228
-                '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.',
2229
-                'event_espresso'
2230
-            ),
2231
-            '4.8.32.rc.000'
2232
-        );
2233
-        return '
2213
+	}
2214
+
2215
+
2216
+	/**
2217
+	 * form_after_question_group
2218
+	 *
2219
+	 * @param string $output
2220
+	 * @return        string
2221
+	 * @deprecated    as of 4.8.32.rc.000
2222
+	 */
2223
+	public function form_after_question_group($output)
2224
+	{
2225
+		EE_Error::doing_it_wrong(
2226
+			__CLASS__ . '::' . __FUNCTION__,
2227
+			esc_html__(
2228
+				'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.',
2229
+				'event_espresso'
2230
+			),
2231
+			'4.8.32.rc.000'
2232
+		);
2233
+		return '
2234 2234
 			<tr class="hide-if-no-js">
2235 2235
 				<th> </th>
2236 2236
 				<td class="reg-admin-edit-attendee-question-td">
2237 2237
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'
2238
-               . esc_attr__('click to edit question', 'event_espresso')
2239
-               . '">
2238
+			   . esc_attr__('click to edit question', 'event_espresso')
2239
+			   . '">
2240 2240
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2241
-               . esc_html__('edit the above question group', 'event_espresso')
2242
-               . '</span>
2241
+			   . esc_html__('edit the above question group', 'event_espresso')
2242
+			   . '</span>
2243 2243
 						<div class="dashicons dashicons-edit"></div>
2244 2244
 					</a>
2245 2245
 				</td>
@@ -2247,641 +2247,641 @@  discard block
 block discarded – undo
2247 2247
 		</tbody>
2248 2248
 	</table>
2249 2249
 ';
2250
-    }
2251
-
2252
-
2253
-    /**
2254
-     * form_form_field_label_wrap
2255
-     *
2256
-     * @param string $label
2257
-     * @return        string
2258
-     * @deprecated    as of 4.8.32.rc.000
2259
-     */
2260
-    public function form_form_field_label_wrap($label)
2261
-    {
2262
-        EE_Error::doing_it_wrong(
2263
-            __CLASS__ . '::' . __FUNCTION__,
2264
-            esc_html__(
2265
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
-                'event_espresso'
2267
-            ),
2268
-            '4.8.32.rc.000'
2269
-        );
2270
-        return '
2250
+	}
2251
+
2252
+
2253
+	/**
2254
+	 * form_form_field_label_wrap
2255
+	 *
2256
+	 * @param string $label
2257
+	 * @return        string
2258
+	 * @deprecated    as of 4.8.32.rc.000
2259
+	 */
2260
+	public function form_form_field_label_wrap($label)
2261
+	{
2262
+		EE_Error::doing_it_wrong(
2263
+			__CLASS__ . '::' . __FUNCTION__,
2264
+			esc_html__(
2265
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
+				'event_espresso'
2267
+			),
2268
+			'4.8.32.rc.000'
2269
+		);
2270
+		return '
2271 2271
 			<tr>
2272 2272
 				<th>
2273 2273
 					' . $label . '
2274 2274
 				</th>';
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     * form_form_field_input__wrap
2280
-     *
2281
-     * @param string $input
2282
-     * @return        string
2283
-     * @deprecated    as of 4.8.32.rc.000
2284
-     */
2285
-    public function form_form_field_input__wrap($input)
2286
-    {
2287
-        EE_Error::doing_it_wrong(
2288
-            __CLASS__ . '::' . __FUNCTION__,
2289
-            esc_html__(
2290
-                '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.',
2291
-                'event_espresso'
2292
-            ),
2293
-            '4.8.32.rc.000'
2294
-        );
2295
-        return '
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 * form_form_field_input__wrap
2280
+	 *
2281
+	 * @param string $input
2282
+	 * @return        string
2283
+	 * @deprecated    as of 4.8.32.rc.000
2284
+	 */
2285
+	public function form_form_field_input__wrap($input)
2286
+	{
2287
+		EE_Error::doing_it_wrong(
2288
+			__CLASS__ . '::' . __FUNCTION__,
2289
+			esc_html__(
2290
+				'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.',
2291
+				'event_espresso'
2292
+			),
2293
+			'4.8.32.rc.000'
2294
+		);
2295
+		return '
2296 2296
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2297 2297
 					' . $input . '
2298 2298
 				</td>
2299 2299
 			</tr>';
2300
-    }
2301
-
2302
-
2303
-    /**
2304
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2305
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2306
-     * to display the page
2307
-     *
2308
-     * @return void
2309
-     * @throws EE_Error
2310
-     * @throws InvalidArgumentException
2311
-     * @throws InvalidDataTypeException
2312
-     * @throws InvalidInterfaceException
2313
-     * @throws ReflectionException
2314
-     */
2315
-    protected function _update_attendee_registration_form()
2316
-    {
2317
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2318
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2319
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2320
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2321
-            if ($success) {
2322
-                $what  = esc_html__('Registration Form', 'event_espresso');
2323
-                $route = $REG_ID
2324
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2325
-                    : ['action' => 'default'];
2326
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2327
-            }
2328
-        }
2329
-    }
2330
-
2331
-
2332
-    /**
2333
-     * Gets the form for saving registrations custom questions (if done
2334
-     * previously retrieves the cached form object, which may have validation errors in it)
2335
-     *
2336
-     * @param int $REG_ID
2337
-     * @return EE_Registration_Custom_Questions_Form
2338
-     * @throws EE_Error
2339
-     * @throws InvalidArgumentException
2340
-     * @throws InvalidDataTypeException
2341
-     * @throws InvalidInterfaceException
2342
-     * @throws ReflectionException
2343
-     */
2344
-    protected function _get_reg_custom_questions_form($REG_ID)
2345
-    {
2346
-        if (! $this->_reg_custom_questions_form) {
2347
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
-            );
2351
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
-        }
2353
-        return $this->_reg_custom_questions_form;
2354
-    }
2355
-
2356
-
2357
-    /**
2358
-     * Saves
2359
-     *
2360
-     * @param bool $REG_ID
2361
-     * @return bool
2362
-     * @throws EE_Error
2363
-     * @throws InvalidArgumentException
2364
-     * @throws InvalidDataTypeException
2365
-     * @throws InvalidInterfaceException
2366
-     * @throws ReflectionException
2367
-     */
2368
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2369
-    {
2370
-        if (! $REG_ID) {
2371
-            EE_Error::add_error(
2372
-                esc_html__(
2373
-                    'An error occurred. No registration ID was received.',
2374
-                    'event_espresso'
2375
-                ),
2376
-                __FILE__,
2377
-                __FUNCTION__,
2378
-                __LINE__
2379
-            );
2380
-        }
2381
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2382
-        $form->receive_form_submission($this->request->requestParams());
2383
-        $success = false;
2384
-        if ($form->is_valid()) {
2385
-            foreach ($form->subforms() as $question_group_form) {
2386
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2387
-                    $where_conditions    = [
2388
-                        'QST_ID' => $question_id,
2389
-                        'REG_ID' => $REG_ID,
2390
-                    ];
2391
-                    $possibly_new_values = [
2392
-                        'ANS_value' => $input->normalized_value(),
2393
-                    ];
2394
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2395
-                    if ($answer instanceof EE_Answer) {
2396
-                        $success = $answer->save($possibly_new_values);
2397
-                    } else {
2398
-                        // insert it then
2399
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2400
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2401
-                        $success     = $answer->save();
2402
-                    }
2403
-                }
2404
-            }
2405
-        } else {
2406
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2407
-        }
2408
-        return $success;
2409
-    }
2410
-
2411
-
2412
-    /**
2413
-     * generates HTML for the Registration main meta box
2414
-     *
2415
-     * @return void
2416
-     * @throws DomainException
2417
-     * @throws EE_Error
2418
-     * @throws InvalidArgumentException
2419
-     * @throws InvalidDataTypeException
2420
-     * @throws InvalidInterfaceException
2421
-     * @throws ReflectionException
2422
-     */
2423
-    public function _reg_attendees_meta_box()
2424
-    {
2425
-        $REG = $this->getRegistrationModel();
2426
-        // get all other registrations on this transaction, and cache
2427
-        // the attendees for them so we don't have to run another query using force_join
2428
-        $registrations                           = $REG->get_all(
2429
-            [
2430
-                [
2431
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2432
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2433
-                ],
2434
-                'force_join'               => ['Attendee'],
2435
-                'default_where_conditions' => 'other_models_only',
2436
-            ]
2437
-        );
2438
-        $this->_template_args['attendees']       = [];
2439
-        $this->_template_args['attendee_notice'] = '';
2440
-        if (
2441
-            empty($registrations)
2442
-            || (is_array($registrations)
2443
-                && ! EEH_Array::get_one_item_from_array($registrations))
2444
-        ) {
2445
-            EE_Error::add_error(
2446
-                esc_html__(
2447
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2448
-                    'event_espresso'
2449
-                ),
2450
-                __FILE__,
2451
-                __FUNCTION__,
2452
-                __LINE__
2453
-            );
2454
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2455
-        } else {
2456
-            $att_nmbr = 1;
2457
-            foreach ($registrations as $registration) {
2458
-                /* @var $registration EE_Registration */
2459
-                $attendee                                                      = $registration->attendee()
2460
-                    ? $registration->attendee()
2461
-                    : $this->getAttendeeModel()->create_default_object();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2467
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
-                    ', ',
2469
-                    $attendee->full_address_as_array()
2470
-                );
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2472
-                    [
2473
-                        'action' => 'edit_attendee',
2474
-                        'post'   => $attendee->ID(),
2475
-                    ],
2476
-                    REG_ADMIN_URL
2477
-                );
2478
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2479
-                    $registration->event_obj() instanceof EE_Event
2480
-                        ? $registration->event_obj()->name()
2481
-                        : '';
2482
-                $att_nmbr++;
2483
-            }
2484
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
-        }
2486
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
-        EEH_Template::display_template($template_path, $this->_template_args);
2488
-    }
2489
-
2490
-
2491
-    /**
2492
-     * generates HTML for the Edit Registration side meta box
2493
-     *
2494
-     * @return void
2495
-     * @throws DomainException
2496
-     * @throws EE_Error
2497
-     * @throws InvalidArgumentException
2498
-     * @throws InvalidDataTypeException
2499
-     * @throws InvalidInterfaceException
2500
-     * @throws ReflectionException
2501
-     */
2502
-    public function _reg_registrant_side_meta_box()
2503
-    {
2504
-        /*@var $attendee EE_Attendee */
2505
-        $att_check = $this->_registration->attendee();
2506
-        $attendee  = $att_check instanceof EE_Attendee
2507
-            ? $att_check
2508
-            : $this->getAttendeeModel()->create_default_object();
2509
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2510
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2511
-        // primary registration object (that way we know if we need to show create button or not)
2512
-        if (! $this->_registration->is_primary_registrant()) {
2513
-            $primary_registration = $this->_registration->get_primary_registration();
2514
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2515
-                : null;
2516
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2517
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2518
-                // custom attendee object so let's not worry about the primary reg.
2519
-                $primary_registration = null;
2520
-            }
2521
-        } else {
2522
-            $primary_registration = null;
2523
-        }
2524
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2525
-        $this->_template_args['fname']             = $attendee->fname();
2526
-        $this->_template_args['lname']             = $attendee->lname();
2527
-        $this->_template_args['email']             = $attendee->email();
2528
-        $this->_template_args['phone']             = $attendee->phone();
2529
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2530
-        // edit link
2531
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2532
-            [
2533
-                'action' => 'edit_attendee',
2534
-                'post'   => $attendee->ID(),
2535
-            ],
2536
-            REG_ADMIN_URL
2537
-        );
2538
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2539
-        // create link
2540
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2541
-            ? EE_Admin_Page::add_query_args_and_nonce(
2542
-                [
2543
-                    'action'  => 'duplicate_attendee',
2544
-                    '_REG_ID' => $this->_registration->ID(),
2545
-                ],
2546
-                REG_ADMIN_URL
2547
-            ) : '';
2548
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2549
-        $this->_template_args['att_check']    = $att_check;
2550
-        $template_path                        =
2551
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
-        EEH_Template::display_template($template_path, $this->_template_args);
2553
-    }
2554
-
2555
-
2556
-    /**
2557
-     * trash or restore registrations
2558
-     *
2559
-     * @param boolean $trash whether to archive or restore
2560
-     * @return void
2561
-     * @throws DomainException
2562
-     * @throws EE_Error
2563
-     * @throws EntityNotFoundException
2564
-     * @throws InvalidArgumentException
2565
-     * @throws InvalidDataTypeException
2566
-     * @throws InvalidInterfaceException
2567
-     * @throws ReflectionException
2568
-     * @throws RuntimeException
2569
-     * @throws UnexpectedEntityException
2570
-     */
2571
-    protected function _trash_or_restore_registrations($trash = true)
2572
-    {
2573
-        // if empty _REG_ID then get out because there's nothing to do
2574
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2575
-        if (empty($REG_IDs)) {
2576
-            EE_Error::add_error(
2577
-                sprintf(
2578
-                    esc_html__(
2579
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2580
-                        'event_espresso'
2581
-                    ),
2582
-                    $trash ? 'trash' : 'restore'
2583
-                ),
2584
-                __FILE__,
2585
-                __LINE__,
2586
-                __FUNCTION__
2587
-            );
2588
-            $this->_redirect_after_action(false, '', '', [], true);
2589
-        }
2590
-        $success        = 0;
2591
-        $overwrite_msgs = false;
2592
-        // Checkboxes
2593
-        $reg_count = count($REG_IDs);
2594
-        // cycle thru checkboxes
2595
-        foreach ($REG_IDs as $REG_ID) {
2596
-            /** @var EE_Registration $REG */
2597
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2598
-            $payments = $REG->registration_payments();
2599
-            if (! empty($payments)) {
2600
-                $name           = $REG->attendee() instanceof EE_Attendee
2601
-                    ? $REG->attendee()->full_name()
2602
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2603
-                $overwrite_msgs = true;
2604
-                EE_Error::add_error(
2605
-                    sprintf(
2606
-                        esc_html__(
2607
-                            '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.',
2608
-                            'event_espresso'
2609
-                        ),
2610
-                        $name
2611
-                    ),
2612
-                    __FILE__,
2613
-                    __FUNCTION__,
2614
-                    __LINE__
2615
-                );
2616
-                // can't trash this registration because it has payments.
2617
-                continue;
2618
-            }
2619
-            $updated = $trash ? $REG->delete() : $REG->restore();
2620
-            if ($updated) {
2621
-                $success++;
2622
-            }
2623
-        }
2624
-        $this->_redirect_after_action(
2625
-            $success === $reg_count, // were ALL registrations affected?
2626
-            $success > 1
2627
-                ? esc_html__('Registrations', 'event_espresso')
2628
-                : esc_html__('Registration', 'event_espresso'),
2629
-            $trash
2630
-                ? esc_html__('moved to the trash', 'event_espresso')
2631
-                : esc_html__('restored', 'event_espresso'),
2632
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2633
-            $overwrite_msgs
2634
-        );
2635
-    }
2636
-
2637
-
2638
-    /**
2639
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2640
-     * registration but also.
2641
-     * 1. Removing relations to EE_Attendee
2642
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2643
-     * ALSO trashed.
2644
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2645
-     * 4. Removing relationships between all tickets and the related registrations
2646
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2647
-     * 6. Deleting permanently any related Checkins.
2648
-     *
2649
-     * @return void
2650
-     * @throws EE_Error
2651
-     * @throws InvalidArgumentException
2652
-     * @throws InvalidDataTypeException
2653
-     * @throws InvalidInterfaceException
2654
-     * @throws ReflectionException
2655
-     */
2656
-    protected function _delete_registrations()
2657
-    {
2658
-        $REG_MDL = $this->getRegistrationModel();
2659
-        $success = 0;
2660
-        // Checkboxes
2661
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2662
-
2663
-        if (! empty($REG_IDs)) {
2664
-            // if array has more than one element than success message should be plural
2665
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2666
-            // cycle thru checkboxes
2667
-            foreach ($REG_IDs as $REG_ID) {
2668
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2669
-                if (! $REG instanceof EE_Registration) {
2670
-                    continue;
2671
-                }
2672
-                $deleted = $this->_delete_registration($REG);
2673
-                if (! $deleted) {
2674
-                    $success = 0;
2675
-                }
2676
-            }
2677
-        }
2678
-
2679
-        $what        = $success > 1
2680
-            ? esc_html__('Registrations', 'event_espresso')
2681
-            : esc_html__('Registration', 'event_espresso');
2682
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2683
-        $this->_redirect_after_action(
2684
-            $success,
2685
-            $what,
2686
-            $action_desc,
2687
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2688
-            true
2689
-        );
2690
-    }
2691
-
2692
-
2693
-    /**
2694
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2695
-     * models get affected.
2696
-     *
2697
-     * @param EE_Registration $REG registration to be deleted permanently
2698
-     * @return bool true = successful deletion, false = fail.
2699
-     * @throws EE_Error
2700
-     * @throws InvalidArgumentException
2701
-     * @throws InvalidDataTypeException
2702
-     * @throws InvalidInterfaceException
2703
-     * @throws ReflectionException
2704
-     */
2705
-    protected function _delete_registration(EE_Registration $REG)
2706
-    {
2707
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2708
-        // registrations on the transaction that are NOT trashed.
2709
-        $TXN = $REG->get_first_related('Transaction');
2710
-        if (! $TXN instanceof EE_Transaction) {
2711
-            EE_Error::add_error(
2712
-                sprintf(
2713
-                    esc_html__(
2714
-                        '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.',
2715
-                        'event_espresso'
2716
-                    ),
2717
-                    $REG->id()
2718
-                ),
2719
-                __FILE__,
2720
-                __FUNCTION__,
2721
-                __LINE__
2722
-            );
2723
-            return false;
2724
-        }
2725
-        $REGS        = $TXN->get_many_related('Registration');
2726
-        $all_trashed = true;
2727
-        foreach ($REGS as $registration) {
2728
-            if (! $registration->get('REG_deleted')) {
2729
-                $all_trashed = false;
2730
-            }
2731
-        }
2732
-        if (! $all_trashed) {
2733
-            EE_Error::add_error(
2734
-                esc_html__(
2735
-                    '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.',
2736
-                    'event_espresso'
2737
-                ),
2738
-                __FILE__,
2739
-                __FUNCTION__,
2740
-                __LINE__
2741
-            );
2742
-            return false;
2743
-        }
2744
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2745
-        // separately from THIS one).
2746
-        foreach ($REGS as $registration) {
2747
-            // delete related answers
2748
-            $registration->delete_related_permanently('Answer');
2749
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2750
-            $attendee = $registration->get_first_related('Attendee');
2751
-            if ($attendee instanceof EE_Attendee) {
2752
-                $registration->_remove_relation_to($attendee, 'Attendee');
2753
-            }
2754
-            // now remove relationships to tickets on this registration.
2755
-            $registration->_remove_relations('Ticket');
2756
-            // now delete permanently the checkins related to this registration.
2757
-            $registration->delete_related_permanently('Checkin');
2758
-            if ($registration->ID() === $REG->ID()) {
2759
-                continue;
2760
-            } //we don't want to delete permanently the existing registration just yet.
2761
-            // remove relation to transaction for these registrations if NOT the existing registrations
2762
-            $registration->_remove_relations('Transaction');
2763
-            // delete permanently any related messages.
2764
-            $registration->delete_related_permanently('Message');
2765
-            // now delete this registration permanently
2766
-            $registration->delete_permanently();
2767
-        }
2768
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2769
-        // (the transaction and line items should be all that's left).
2770
-        // delete the line items related to the transaction for this registration.
2771
-        $TXN->delete_related_permanently('Line_Item');
2772
-        // we need to remove all the relationships on the transaction
2773
-        $TXN->delete_related_permanently('Payment');
2774
-        $TXN->delete_related_permanently('Extra_Meta');
2775
-        $TXN->delete_related_permanently('Message');
2776
-        // now we can delete this REG permanently (and the transaction of course)
2777
-        $REG->delete_related_permanently('Transaction');
2778
-        return $REG->delete_permanently();
2779
-    }
2780
-
2781
-
2782
-    /**
2783
-     *    generates HTML for the Register New Attendee Admin page
2784
-     *
2785
-     * @throws DomainException
2786
-     * @throws EE_Error
2787
-     * @throws InvalidArgumentException
2788
-     * @throws InvalidDataTypeException
2789
-     * @throws InvalidInterfaceException
2790
-     * @throws ReflectionException
2791
-     */
2792
-    public function new_registration()
2793
-    {
2794
-        if (! $this->_set_reg_event()) {
2795
-            throw new EE_Error(
2796
-                esc_html__(
2797
-                    'Unable to continue with registering because there is no Event ID in the request',
2798
-                    'event_espresso'
2799
-                )
2800
-            );
2801
-        }
2802
-        /** @var CurrentPage $current_page */
2803
-        $current_page = $this->loader->getShared(CurrentPage::class);
2804
-        $current_page->setEspressoPage(true);
2805
-        // gotta start with a clean slate if we're not coming here via ajax
2806
-        if (
2807
-            ! $this->request->isAjax()
2808
-            && (
2809
-                ! $this->request->requestParamIsSet('processing_registration')
2810
-                || $this->request->requestParamIsSet('step_error')
2811
-            )
2812
-        ) {
2813
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2814
-        }
2815
-        $this->_template_args['event_name'] = '';
2816
-        // event name
2817
-        if ($this->_reg_event) {
2818
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2819
-            $edit_event_url                     = self::add_query_args_and_nonce(
2820
-                [
2821
-                    'action' => 'edit',
2822
-                    'post'   => $this->_reg_event->ID(),
2823
-                ],
2824
-                EVENTS_ADMIN_URL
2825
-            );
2826
-            $edit_event_lnk                     = '<a href="'
2827
-                                                  . $edit_event_url
2828
-                                                  . '" aria-label="'
2829
-                                                  . esc_attr__('Edit ', 'event_espresso')
2830
-                                                  . $this->_reg_event->name()
2831
-                                                  . '">'
2832
-                                                  . esc_html__('Edit Event', 'event_espresso')
2833
-                                                  . '</a>';
2834
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2835
-                                                   . $edit_event_lnk
2836
-                                                   . '</span>';
2837
-        }
2838
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2839
-        if ($this->request->isAjax()) {
2840
-            $this->_return_json();
2841
-        }
2842
-        // grab header
2843
-        $template_path                              =
2844
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2845
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2846
-            $template_path,
2847
-            $this->_template_args,
2848
-            true
2849
-        );
2850
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2851
-        // the details template wrapper
2852
-        $this->display_admin_page_with_sidebar();
2853
-    }
2854
-
2855
-
2856
-    /**
2857
-     * This returns the content for a registration step
2858
-     *
2859
-     * @return string html
2860
-     * @throws DomainException
2861
-     * @throws EE_Error
2862
-     * @throws InvalidArgumentException
2863
-     * @throws InvalidDataTypeException
2864
-     * @throws InvalidInterfaceException
2865
-     * @throws ReflectionException
2866
-     */
2867
-    protected function _get_registration_step_content()
2868
-    {
2869
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2870
-            $warning_msg = sprintf(
2871
-                esc_html__(
2872
-                    '%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',
2873
-                    'event_espresso'
2874
-                ),
2875
-                '<br />',
2876
-                '<h3 class="important-notice">',
2877
-                '</h3>',
2878
-                '<div class="float-right">',
2879
-                '<span id="redirect_timer" class="important-notice">30</span>',
2880
-                '</div>',
2881
-                '<b>',
2882
-                '</b>'
2883
-            );
2884
-            return '
2300
+	}
2301
+
2302
+
2303
+	/**
2304
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2305
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2306
+	 * to display the page
2307
+	 *
2308
+	 * @return void
2309
+	 * @throws EE_Error
2310
+	 * @throws InvalidArgumentException
2311
+	 * @throws InvalidDataTypeException
2312
+	 * @throws InvalidInterfaceException
2313
+	 * @throws ReflectionException
2314
+	 */
2315
+	protected function _update_attendee_registration_form()
2316
+	{
2317
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2318
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2319
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2320
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2321
+			if ($success) {
2322
+				$what  = esc_html__('Registration Form', 'event_espresso');
2323
+				$route = $REG_ID
2324
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2325
+					: ['action' => 'default'];
2326
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2327
+			}
2328
+		}
2329
+	}
2330
+
2331
+
2332
+	/**
2333
+	 * Gets the form for saving registrations custom questions (if done
2334
+	 * previously retrieves the cached form object, which may have validation errors in it)
2335
+	 *
2336
+	 * @param int $REG_ID
2337
+	 * @return EE_Registration_Custom_Questions_Form
2338
+	 * @throws EE_Error
2339
+	 * @throws InvalidArgumentException
2340
+	 * @throws InvalidDataTypeException
2341
+	 * @throws InvalidInterfaceException
2342
+	 * @throws ReflectionException
2343
+	 */
2344
+	protected function _get_reg_custom_questions_form($REG_ID)
2345
+	{
2346
+		if (! $this->_reg_custom_questions_form) {
2347
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
+			);
2351
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
+		}
2353
+		return $this->_reg_custom_questions_form;
2354
+	}
2355
+
2356
+
2357
+	/**
2358
+	 * Saves
2359
+	 *
2360
+	 * @param bool $REG_ID
2361
+	 * @return bool
2362
+	 * @throws EE_Error
2363
+	 * @throws InvalidArgumentException
2364
+	 * @throws InvalidDataTypeException
2365
+	 * @throws InvalidInterfaceException
2366
+	 * @throws ReflectionException
2367
+	 */
2368
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2369
+	{
2370
+		if (! $REG_ID) {
2371
+			EE_Error::add_error(
2372
+				esc_html__(
2373
+					'An error occurred. No registration ID was received.',
2374
+					'event_espresso'
2375
+				),
2376
+				__FILE__,
2377
+				__FUNCTION__,
2378
+				__LINE__
2379
+			);
2380
+		}
2381
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2382
+		$form->receive_form_submission($this->request->requestParams());
2383
+		$success = false;
2384
+		if ($form->is_valid()) {
2385
+			foreach ($form->subforms() as $question_group_form) {
2386
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2387
+					$where_conditions    = [
2388
+						'QST_ID' => $question_id,
2389
+						'REG_ID' => $REG_ID,
2390
+					];
2391
+					$possibly_new_values = [
2392
+						'ANS_value' => $input->normalized_value(),
2393
+					];
2394
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2395
+					if ($answer instanceof EE_Answer) {
2396
+						$success = $answer->save($possibly_new_values);
2397
+					} else {
2398
+						// insert it then
2399
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2400
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2401
+						$success     = $answer->save();
2402
+					}
2403
+				}
2404
+			}
2405
+		} else {
2406
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2407
+		}
2408
+		return $success;
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * generates HTML for the Registration main meta box
2414
+	 *
2415
+	 * @return void
2416
+	 * @throws DomainException
2417
+	 * @throws EE_Error
2418
+	 * @throws InvalidArgumentException
2419
+	 * @throws InvalidDataTypeException
2420
+	 * @throws InvalidInterfaceException
2421
+	 * @throws ReflectionException
2422
+	 */
2423
+	public function _reg_attendees_meta_box()
2424
+	{
2425
+		$REG = $this->getRegistrationModel();
2426
+		// get all other registrations on this transaction, and cache
2427
+		// the attendees for them so we don't have to run another query using force_join
2428
+		$registrations                           = $REG->get_all(
2429
+			[
2430
+				[
2431
+					'TXN_ID' => $this->_registration->transaction_ID(),
2432
+					'REG_ID' => ['!=', $this->_registration->ID()],
2433
+				],
2434
+				'force_join'               => ['Attendee'],
2435
+				'default_where_conditions' => 'other_models_only',
2436
+			]
2437
+		);
2438
+		$this->_template_args['attendees']       = [];
2439
+		$this->_template_args['attendee_notice'] = '';
2440
+		if (
2441
+			empty($registrations)
2442
+			|| (is_array($registrations)
2443
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2444
+		) {
2445
+			EE_Error::add_error(
2446
+				esc_html__(
2447
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2448
+					'event_espresso'
2449
+				),
2450
+				__FILE__,
2451
+				__FUNCTION__,
2452
+				__LINE__
2453
+			);
2454
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2455
+		} else {
2456
+			$att_nmbr = 1;
2457
+			foreach ($registrations as $registration) {
2458
+				/* @var $registration EE_Registration */
2459
+				$attendee                                                      = $registration->attendee()
2460
+					? $registration->attendee()
2461
+					: $this->getAttendeeModel()->create_default_object();
2462
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2463
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2464
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2465
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2466
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2467
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
+					', ',
2469
+					$attendee->full_address_as_array()
2470
+				);
2471
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2472
+					[
2473
+						'action' => 'edit_attendee',
2474
+						'post'   => $attendee->ID(),
2475
+					],
2476
+					REG_ADMIN_URL
2477
+				);
2478
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2479
+					$registration->event_obj() instanceof EE_Event
2480
+						? $registration->event_obj()->name()
2481
+						: '';
2482
+				$att_nmbr++;
2483
+			}
2484
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
+		}
2486
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
+		EEH_Template::display_template($template_path, $this->_template_args);
2488
+	}
2489
+
2490
+
2491
+	/**
2492
+	 * generates HTML for the Edit Registration side meta box
2493
+	 *
2494
+	 * @return void
2495
+	 * @throws DomainException
2496
+	 * @throws EE_Error
2497
+	 * @throws InvalidArgumentException
2498
+	 * @throws InvalidDataTypeException
2499
+	 * @throws InvalidInterfaceException
2500
+	 * @throws ReflectionException
2501
+	 */
2502
+	public function _reg_registrant_side_meta_box()
2503
+	{
2504
+		/*@var $attendee EE_Attendee */
2505
+		$att_check = $this->_registration->attendee();
2506
+		$attendee  = $att_check instanceof EE_Attendee
2507
+			? $att_check
2508
+			: $this->getAttendeeModel()->create_default_object();
2509
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2510
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2511
+		// primary registration object (that way we know if we need to show create button or not)
2512
+		if (! $this->_registration->is_primary_registrant()) {
2513
+			$primary_registration = $this->_registration->get_primary_registration();
2514
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2515
+				: null;
2516
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2517
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2518
+				// custom attendee object so let's not worry about the primary reg.
2519
+				$primary_registration = null;
2520
+			}
2521
+		} else {
2522
+			$primary_registration = null;
2523
+		}
2524
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2525
+		$this->_template_args['fname']             = $attendee->fname();
2526
+		$this->_template_args['lname']             = $attendee->lname();
2527
+		$this->_template_args['email']             = $attendee->email();
2528
+		$this->_template_args['phone']             = $attendee->phone();
2529
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2530
+		// edit link
2531
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2532
+			[
2533
+				'action' => 'edit_attendee',
2534
+				'post'   => $attendee->ID(),
2535
+			],
2536
+			REG_ADMIN_URL
2537
+		);
2538
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2539
+		// create link
2540
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2541
+			? EE_Admin_Page::add_query_args_and_nonce(
2542
+				[
2543
+					'action'  => 'duplicate_attendee',
2544
+					'_REG_ID' => $this->_registration->ID(),
2545
+				],
2546
+				REG_ADMIN_URL
2547
+			) : '';
2548
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2549
+		$this->_template_args['att_check']    = $att_check;
2550
+		$template_path                        =
2551
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
+		EEH_Template::display_template($template_path, $this->_template_args);
2553
+	}
2554
+
2555
+
2556
+	/**
2557
+	 * trash or restore registrations
2558
+	 *
2559
+	 * @param boolean $trash whether to archive or restore
2560
+	 * @return void
2561
+	 * @throws DomainException
2562
+	 * @throws EE_Error
2563
+	 * @throws EntityNotFoundException
2564
+	 * @throws InvalidArgumentException
2565
+	 * @throws InvalidDataTypeException
2566
+	 * @throws InvalidInterfaceException
2567
+	 * @throws ReflectionException
2568
+	 * @throws RuntimeException
2569
+	 * @throws UnexpectedEntityException
2570
+	 */
2571
+	protected function _trash_or_restore_registrations($trash = true)
2572
+	{
2573
+		// if empty _REG_ID then get out because there's nothing to do
2574
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2575
+		if (empty($REG_IDs)) {
2576
+			EE_Error::add_error(
2577
+				sprintf(
2578
+					esc_html__(
2579
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2580
+						'event_espresso'
2581
+					),
2582
+					$trash ? 'trash' : 'restore'
2583
+				),
2584
+				__FILE__,
2585
+				__LINE__,
2586
+				__FUNCTION__
2587
+			);
2588
+			$this->_redirect_after_action(false, '', '', [], true);
2589
+		}
2590
+		$success        = 0;
2591
+		$overwrite_msgs = false;
2592
+		// Checkboxes
2593
+		$reg_count = count($REG_IDs);
2594
+		// cycle thru checkboxes
2595
+		foreach ($REG_IDs as $REG_ID) {
2596
+			/** @var EE_Registration $REG */
2597
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2598
+			$payments = $REG->registration_payments();
2599
+			if (! empty($payments)) {
2600
+				$name           = $REG->attendee() instanceof EE_Attendee
2601
+					? $REG->attendee()->full_name()
2602
+					: esc_html__('Unknown Attendee', 'event_espresso');
2603
+				$overwrite_msgs = true;
2604
+				EE_Error::add_error(
2605
+					sprintf(
2606
+						esc_html__(
2607
+							'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.',
2608
+							'event_espresso'
2609
+						),
2610
+						$name
2611
+					),
2612
+					__FILE__,
2613
+					__FUNCTION__,
2614
+					__LINE__
2615
+				);
2616
+				// can't trash this registration because it has payments.
2617
+				continue;
2618
+			}
2619
+			$updated = $trash ? $REG->delete() : $REG->restore();
2620
+			if ($updated) {
2621
+				$success++;
2622
+			}
2623
+		}
2624
+		$this->_redirect_after_action(
2625
+			$success === $reg_count, // were ALL registrations affected?
2626
+			$success > 1
2627
+				? esc_html__('Registrations', 'event_espresso')
2628
+				: esc_html__('Registration', 'event_espresso'),
2629
+			$trash
2630
+				? esc_html__('moved to the trash', 'event_espresso')
2631
+				: esc_html__('restored', 'event_espresso'),
2632
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2633
+			$overwrite_msgs
2634
+		);
2635
+	}
2636
+
2637
+
2638
+	/**
2639
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2640
+	 * registration but also.
2641
+	 * 1. Removing relations to EE_Attendee
2642
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2643
+	 * ALSO trashed.
2644
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2645
+	 * 4. Removing relationships between all tickets and the related registrations
2646
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2647
+	 * 6. Deleting permanently any related Checkins.
2648
+	 *
2649
+	 * @return void
2650
+	 * @throws EE_Error
2651
+	 * @throws InvalidArgumentException
2652
+	 * @throws InvalidDataTypeException
2653
+	 * @throws InvalidInterfaceException
2654
+	 * @throws ReflectionException
2655
+	 */
2656
+	protected function _delete_registrations()
2657
+	{
2658
+		$REG_MDL = $this->getRegistrationModel();
2659
+		$success = 0;
2660
+		// Checkboxes
2661
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2662
+
2663
+		if (! empty($REG_IDs)) {
2664
+			// if array has more than one element than success message should be plural
2665
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2666
+			// cycle thru checkboxes
2667
+			foreach ($REG_IDs as $REG_ID) {
2668
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2669
+				if (! $REG instanceof EE_Registration) {
2670
+					continue;
2671
+				}
2672
+				$deleted = $this->_delete_registration($REG);
2673
+				if (! $deleted) {
2674
+					$success = 0;
2675
+				}
2676
+			}
2677
+		}
2678
+
2679
+		$what        = $success > 1
2680
+			? esc_html__('Registrations', 'event_espresso')
2681
+			: esc_html__('Registration', 'event_espresso');
2682
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2683
+		$this->_redirect_after_action(
2684
+			$success,
2685
+			$what,
2686
+			$action_desc,
2687
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2688
+			true
2689
+		);
2690
+	}
2691
+
2692
+
2693
+	/**
2694
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2695
+	 * models get affected.
2696
+	 *
2697
+	 * @param EE_Registration $REG registration to be deleted permanently
2698
+	 * @return bool true = successful deletion, false = fail.
2699
+	 * @throws EE_Error
2700
+	 * @throws InvalidArgumentException
2701
+	 * @throws InvalidDataTypeException
2702
+	 * @throws InvalidInterfaceException
2703
+	 * @throws ReflectionException
2704
+	 */
2705
+	protected function _delete_registration(EE_Registration $REG)
2706
+	{
2707
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2708
+		// registrations on the transaction that are NOT trashed.
2709
+		$TXN = $REG->get_first_related('Transaction');
2710
+		if (! $TXN instanceof EE_Transaction) {
2711
+			EE_Error::add_error(
2712
+				sprintf(
2713
+					esc_html__(
2714
+						'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.',
2715
+						'event_espresso'
2716
+					),
2717
+					$REG->id()
2718
+				),
2719
+				__FILE__,
2720
+				__FUNCTION__,
2721
+				__LINE__
2722
+			);
2723
+			return false;
2724
+		}
2725
+		$REGS        = $TXN->get_many_related('Registration');
2726
+		$all_trashed = true;
2727
+		foreach ($REGS as $registration) {
2728
+			if (! $registration->get('REG_deleted')) {
2729
+				$all_trashed = false;
2730
+			}
2731
+		}
2732
+		if (! $all_trashed) {
2733
+			EE_Error::add_error(
2734
+				esc_html__(
2735
+					'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.',
2736
+					'event_espresso'
2737
+				),
2738
+				__FILE__,
2739
+				__FUNCTION__,
2740
+				__LINE__
2741
+			);
2742
+			return false;
2743
+		}
2744
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2745
+		// separately from THIS one).
2746
+		foreach ($REGS as $registration) {
2747
+			// delete related answers
2748
+			$registration->delete_related_permanently('Answer');
2749
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2750
+			$attendee = $registration->get_first_related('Attendee');
2751
+			if ($attendee instanceof EE_Attendee) {
2752
+				$registration->_remove_relation_to($attendee, 'Attendee');
2753
+			}
2754
+			// now remove relationships to tickets on this registration.
2755
+			$registration->_remove_relations('Ticket');
2756
+			// now delete permanently the checkins related to this registration.
2757
+			$registration->delete_related_permanently('Checkin');
2758
+			if ($registration->ID() === $REG->ID()) {
2759
+				continue;
2760
+			} //we don't want to delete permanently the existing registration just yet.
2761
+			// remove relation to transaction for these registrations if NOT the existing registrations
2762
+			$registration->_remove_relations('Transaction');
2763
+			// delete permanently any related messages.
2764
+			$registration->delete_related_permanently('Message');
2765
+			// now delete this registration permanently
2766
+			$registration->delete_permanently();
2767
+		}
2768
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2769
+		// (the transaction and line items should be all that's left).
2770
+		// delete the line items related to the transaction for this registration.
2771
+		$TXN->delete_related_permanently('Line_Item');
2772
+		// we need to remove all the relationships on the transaction
2773
+		$TXN->delete_related_permanently('Payment');
2774
+		$TXN->delete_related_permanently('Extra_Meta');
2775
+		$TXN->delete_related_permanently('Message');
2776
+		// now we can delete this REG permanently (and the transaction of course)
2777
+		$REG->delete_related_permanently('Transaction');
2778
+		return $REG->delete_permanently();
2779
+	}
2780
+
2781
+
2782
+	/**
2783
+	 *    generates HTML for the Register New Attendee Admin page
2784
+	 *
2785
+	 * @throws DomainException
2786
+	 * @throws EE_Error
2787
+	 * @throws InvalidArgumentException
2788
+	 * @throws InvalidDataTypeException
2789
+	 * @throws InvalidInterfaceException
2790
+	 * @throws ReflectionException
2791
+	 */
2792
+	public function new_registration()
2793
+	{
2794
+		if (! $this->_set_reg_event()) {
2795
+			throw new EE_Error(
2796
+				esc_html__(
2797
+					'Unable to continue with registering because there is no Event ID in the request',
2798
+					'event_espresso'
2799
+				)
2800
+			);
2801
+		}
2802
+		/** @var CurrentPage $current_page */
2803
+		$current_page = $this->loader->getShared(CurrentPage::class);
2804
+		$current_page->setEspressoPage(true);
2805
+		// gotta start with a clean slate if we're not coming here via ajax
2806
+		if (
2807
+			! $this->request->isAjax()
2808
+			&& (
2809
+				! $this->request->requestParamIsSet('processing_registration')
2810
+				|| $this->request->requestParamIsSet('step_error')
2811
+			)
2812
+		) {
2813
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2814
+		}
2815
+		$this->_template_args['event_name'] = '';
2816
+		// event name
2817
+		if ($this->_reg_event) {
2818
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2819
+			$edit_event_url                     = self::add_query_args_and_nonce(
2820
+				[
2821
+					'action' => 'edit',
2822
+					'post'   => $this->_reg_event->ID(),
2823
+				],
2824
+				EVENTS_ADMIN_URL
2825
+			);
2826
+			$edit_event_lnk                     = '<a href="'
2827
+												  . $edit_event_url
2828
+												  . '" aria-label="'
2829
+												  . esc_attr__('Edit ', 'event_espresso')
2830
+												  . $this->_reg_event->name()
2831
+												  . '">'
2832
+												  . esc_html__('Edit Event', 'event_espresso')
2833
+												  . '</a>';
2834
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2835
+												   . $edit_event_lnk
2836
+												   . '</span>';
2837
+		}
2838
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2839
+		if ($this->request->isAjax()) {
2840
+			$this->_return_json();
2841
+		}
2842
+		// grab header
2843
+		$template_path                              =
2844
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2845
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2846
+			$template_path,
2847
+			$this->_template_args,
2848
+			true
2849
+		);
2850
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2851
+		// the details template wrapper
2852
+		$this->display_admin_page_with_sidebar();
2853
+	}
2854
+
2855
+
2856
+	/**
2857
+	 * This returns the content for a registration step
2858
+	 *
2859
+	 * @return string html
2860
+	 * @throws DomainException
2861
+	 * @throws EE_Error
2862
+	 * @throws InvalidArgumentException
2863
+	 * @throws InvalidDataTypeException
2864
+	 * @throws InvalidInterfaceException
2865
+	 * @throws ReflectionException
2866
+	 */
2867
+	protected function _get_registration_step_content()
2868
+	{
2869
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2870
+			$warning_msg = sprintf(
2871
+				esc_html__(
2872
+					'%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',
2873
+					'event_espresso'
2874
+				),
2875
+				'<br />',
2876
+				'<h3 class="important-notice">',
2877
+				'</h3>',
2878
+				'<div class="float-right">',
2879
+				'<span id="redirect_timer" class="important-notice">30</span>',
2880
+				'</div>',
2881
+				'<b>',
2882
+				'</b>'
2883
+			);
2884
+			return '
2885 2885
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2886 2886
 	<script >
2887 2887
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2894,846 +2894,846 @@  discard block
 block discarded – undo
2894 2894
 	        }
2895 2895
 	    }, 800 );
2896 2896
 	</script >';
2897
-        }
2898
-        $template_args = [
2899
-            'title'                    => '',
2900
-            'content'                  => '',
2901
-            'step_button_text'         => '',
2902
-            'show_notification_toggle' => false,
2903
-        ];
2904
-        // to indicate we're processing a new registration
2905
-        $hidden_fields = [
2906
-            'processing_registration' => [
2907
-                'type'  => 'hidden',
2908
-                'value' => 0,
2909
-            ],
2910
-            'event_id'                => [
2911
-                'type'  => 'hidden',
2912
-                'value' => $this->_reg_event->ID(),
2913
-            ],
2914
-        ];
2915
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2916
-        $cart = EE_Registry::instance()->SSN->cart();
2917
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2918
-        switch ($step) {
2919
-            case 'ticket':
2920
-                $hidden_fields['processing_registration']['value'] = 1;
2921
-                $template_args['title']                            = esc_html__(
2922
-                    'Step One: Select the Ticket for this registration',
2923
-                    'event_espresso'
2924
-                );
2925
-                $template_args['content']                          =
2926
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2927
-                $template_args['content']                          .= '</div>';
2928
-                $template_args['step_button_text']                 = esc_html__(
2929
-                    'Add Tickets and Continue to Registrant Details',
2930
-                    'event_espresso'
2931
-                );
2932
-                $template_args['show_notification_toggle']         = false;
2933
-                break;
2934
-            case 'questions':
2935
-                $hidden_fields['processing_registration']['value'] = 2;
2936
-                $template_args['title']                            = esc_html__(
2937
-                    'Step Two: Add Registrant Details for this Registration',
2938
-                    'event_espresso'
2939
-                );
2940
-                // in theory, we should be able to run EED_SPCO at this point
2941
-                // because the cart should have been set up properly by the first process_reg_step run.
2942
-                $template_args['content']                  =
2943
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2944
-                $template_args['step_button_text']         = esc_html__(
2945
-                    'Save Registration and Continue to Details',
2946
-                    'event_espresso'
2947
-                );
2948
-                $template_args['show_notification_toggle'] = true;
2949
-                break;
2950
-        }
2951
-        // we come back to the process_registration_step route.
2952
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2953
-        return EEH_Template::display_template(
2954
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2955
-            $template_args,
2956
-            true
2957
-        );
2958
-    }
2959
-
2960
-
2961
-    /**
2962
-     * set_reg_event
2963
-     *
2964
-     * @return bool
2965
-     * @throws EE_Error
2966
-     * @throws InvalidArgumentException
2967
-     * @throws InvalidDataTypeException
2968
-     * @throws InvalidInterfaceException
2969
-     */
2970
-    private function _set_reg_event()
2971
-    {
2972
-        if (is_object($this->_reg_event)) {
2973
-            return true;
2974
-        }
2975
-
2976
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2977
-        if (! $EVT_ID) {
2978
-            return false;
2979
-        }
2980
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2981
-        return true;
2982
-    }
2983
-
2984
-
2985
-    /**
2986
-     * process_reg_step
2987
-     *
2988
-     * @return void
2989
-     * @throws DomainException
2990
-     * @throws EE_Error
2991
-     * @throws InvalidArgumentException
2992
-     * @throws InvalidDataTypeException
2993
-     * @throws InvalidInterfaceException
2994
-     * @throws ReflectionException
2995
-     * @throws RuntimeException
2996
-     */
2997
-    public function process_reg_step()
2998
-    {
2999
-        EE_System::do_not_cache();
3000
-        $this->_set_reg_event();
3001
-        /** @var CurrentPage $current_page */
3002
-        $current_page = $this->loader->getShared(CurrentPage::class);
3003
-        $current_page->setEspressoPage(true);
3004
-        $this->request->setRequestParam('uts', time());
3005
-        // what step are we on?
3006
-        $cart = EE_Registry::instance()->SSN->cart();
3007
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3008
-        // if doing ajax then we need to verify the nonce
3009
-        if ($this->request->isAjax()) {
3010
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3011
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3012
-        }
3013
-        switch ($step) {
3014
-            case 'ticket':
3015
-                // process ticket selection
3016
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3017
-                if ($success) {
3018
-                    EE_Error::add_success(
3019
-                        esc_html__(
3020
-                            'Tickets Selected. Now complete the registration.',
3021
-                            'event_espresso'
3022
-                        )
3023
-                    );
3024
-                } else {
3025
-                    $this->request->setRequestParam('step_error', true);
3026
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3027
-                }
3028
-                if ($this->request->isAjax()) {
3029
-                    $this->new_registration(); // display next step
3030
-                } else {
3031
-                    $query_args = [
3032
-                        'action'                  => 'new_registration',
3033
-                        'processing_registration' => 1,
3034
-                        'event_id'                => $this->_reg_event->ID(),
3035
-                        'uts'                     => time(),
3036
-                    ];
3037
-                    $this->_redirect_after_action(
3038
-                        false,
3039
-                        '',
3040
-                        '',
3041
-                        $query_args,
3042
-                        true
3043
-                    );
3044
-                }
3045
-                break;
3046
-            case 'questions':
3047
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3048
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3049
-                }
3050
-                // process registration
3051
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3052
-                if ($cart instanceof EE_Cart) {
3053
-                    $grand_total = $cart->get_grand_total();
3054
-                    if ($grand_total instanceof EE_Line_Item) {
3055
-                        $grand_total->save_this_and_descendants_to_txn();
3056
-                    }
3057
-                }
3058
-                if (! $transaction instanceof EE_Transaction) {
3059
-                    $query_args = [
3060
-                        'action'                  => 'new_registration',
3061
-                        'processing_registration' => 2,
3062
-                        'event_id'                => $this->_reg_event->ID(),
3063
-                        'uts'                     => time(),
3064
-                    ];
3065
-                    if ($this->request->isAjax()) {
3066
-                        // display registration form again because there are errors (maybe validation?)
3067
-                        $this->new_registration();
3068
-                        return;
3069
-                    }
3070
-                    $this->_redirect_after_action(
3071
-                        false,
3072
-                        '',
3073
-                        '',
3074
-                        $query_args,
3075
-                        true
3076
-                    );
3077
-                    return;
3078
-                }
3079
-                // maybe update status, and make sure to save transaction if not done already
3080
-                if (! $transaction->update_status_based_on_total_paid()) {
3081
-                    $transaction->save();
3082
-                }
3083
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3084
-                $query_args = [
3085
-                    'action'        => 'redirect_to_txn',
3086
-                    'TXN_ID'        => $transaction->ID(),
3087
-                    'EVT_ID'        => $this->_reg_event->ID(),
3088
-                    'event_name'    => urlencode($this->_reg_event->name()),
3089
-                    'redirect_from' => 'new_registration',
3090
-                ];
3091
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3092
-                break;
3093
-        }
3094
-        // what are you looking here for?  Should be nothing to do at this point.
3095
-    }
3096
-
3097
-
3098
-    /**
3099
-     * redirect_to_txn
3100
-     *
3101
-     * @return void
3102
-     * @throws EE_Error
3103
-     * @throws InvalidArgumentException
3104
-     * @throws InvalidDataTypeException
3105
-     * @throws InvalidInterfaceException
3106
-     * @throws ReflectionException
3107
-     */
3108
-    public function redirect_to_txn()
3109
-    {
3110
-        EE_System::do_not_cache();
3111
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3112
-        $query_args = [
3113
-            'action' => 'view_transaction',
3114
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3115
-            'page'   => 'espresso_transactions',
3116
-        ];
3117
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3118
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3119
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3120
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3121
-        }
3122
-        EE_Error::add_success(
3123
-            esc_html__(
3124
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3125
-                'event_espresso'
3126
-            )
3127
-        );
3128
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3129
-    }
3130
-
3131
-
3132
-    /**
3133
-     * generates HTML for the Attendee Contact List
3134
-     *
3135
-     * @return void
3136
-     * @throws DomainException
3137
-     * @throws EE_Error
3138
-     */
3139
-    protected function _attendee_contact_list_table()
3140
-    {
3141
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3142
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3143
-        $this->display_admin_list_table_page_with_no_sidebar();
3144
-    }
3145
-
3146
-
3147
-    /**
3148
-     * get_attendees
3149
-     *
3150
-     * @param      $per_page
3151
-     * @param bool $count whether to return count or data.
3152
-     * @param bool $trash
3153
-     * @return array|int
3154
-     * @throws EE_Error
3155
-     * @throws InvalidArgumentException
3156
-     * @throws InvalidDataTypeException
3157
-     * @throws InvalidInterfaceException
3158
-     */
3159
-    public function get_attendees($per_page, $count = false, $trash = false)
3160
-    {
3161
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3162
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3163
-        $orderby = $this->request->getRequestParam('orderby');
3164
-        switch ($orderby) {
3165
-            case 'ATT_ID':
3166
-            case 'ATT_fname':
3167
-            case 'ATT_email':
3168
-            case 'ATT_city':
3169
-            case 'STA_ID':
3170
-            case 'CNT_ID':
3171
-                break;
3172
-            case 'Registration_Count':
3173
-                $orderby = 'Registration_Count';
3174
-                break;
3175
-            default:
3176
-                $orderby = 'ATT_lname';
3177
-        }
3178
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3179
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3180
-        $per_page     = absint($per_page) ? $per_page : 10;
3181
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3182
-        $_where       = [];
3183
-        $search_term  = $this->request->getRequestParam('s');
3184
-        if ($search_term) {
3185
-            $search_term  = '%' . $search_term . '%';
3186
-            $_where['OR'] = [
3187
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3188
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3189
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3190
-                'ATT_fname'                         => ['LIKE', $search_term],
3191
-                'ATT_lname'                         => ['LIKE', $search_term],
3192
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3193
-                'ATT_email'                         => ['LIKE', $search_term],
3194
-                'ATT_address'                       => ['LIKE', $search_term],
3195
-                'ATT_address2'                      => ['LIKE', $search_term],
3196
-                'ATT_city'                          => ['LIKE', $search_term],
3197
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3198
-                'State.STA_name'                    => ['LIKE', $search_term],
3199
-                'ATT_phone'                         => ['LIKE', $search_term],
3200
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3201
-                'Registration.REG_code'             => ['LIKE', $search_term],
3202
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3203
-            ];
3204
-        }
3205
-        $offset     = ($current_page - 1) * $per_page;
3206
-        $limit      = $count ? null : [$offset, $per_page];
3207
-        $query_args = [
3208
-            $_where,
3209
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3210
-            'limit'         => $limit,
3211
-        ];
3212
-        if (! $count) {
3213
-            $query_args['order_by'] = [$orderby => $sort];
3214
-        }
3215
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3216
-        return $count
3217
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3218
-            : $this->getAttendeeModel()->get_all($query_args);
3219
-    }
3220
-
3221
-
3222
-    /**
3223
-     * This is just taking care of resending the registration confirmation
3224
-     *
3225
-     * @return void
3226
-     * @throws EE_Error
3227
-     * @throws InvalidArgumentException
3228
-     * @throws InvalidDataTypeException
3229
-     * @throws InvalidInterfaceException
3230
-     * @throws ReflectionException
3231
-     */
3232
-    protected function _resend_registration()
3233
-    {
3234
-        $this->_process_resend_registration();
3235
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3236
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3237
-        $query_args  = $redirect_to
3238
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3239
-            : ['action' => 'default'];
3240
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3241
-    }
3242
-
3243
-
3244
-    /**
3245
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3246
-     * to use when selecting registrations
3247
-     *
3248
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3249
-     *                                                     the query parameters from the request
3250
-     * @return void ends the request with a redirect or download
3251
-     */
3252
-    public function _registrations_report_base($method_name_for_getting_query_params)
3253
-    {
3254
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3255
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3256
-            : null;
3257
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3258
-            $filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3259
-            $report_params  = $this->$method_name_for_getting_query_params($filters);
3260
-            wp_redirect(
3261
-                EE_Admin_Page::add_query_args_and_nonce(
3262
-                    [
3263
-                        'page'        => 'espresso_batch',
3264
-                        'batch'       => 'file',
3265
-                        'EVT_ID'      => $EVT_ID,
3266
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3267
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3268
-                        'filters'     => urlencode(serialize($report_params)),
3269
-                        'use_filters' => $this->request->getRequestParam('use_filters', false, DataType::BOOL)
3270
-                    ]
3271
-                )
3272
-            );
3273
-        } else {
3274
-            // Pull the current request params
3275
-            $request_args = $this->request->requestParams();
3276
-            // Set the required request_args to be passed to the export
3277
-            $required_request_args = [
3278
-                'export' => 'report',
3279
-                'action' => 'registrations_report_for_event',
3280
-                'EVT_ID' => $EVT_ID,
3281
-            ];
3282
-            // Merge required request args, overriding any currently set
3283
-            $request_args = array_merge($request_args, $required_request_args);
3284
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3285
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3286
-                $EE_Export = EE_Export::instance($request_args);
3287
-                $EE_Export->export();
3288
-            }
3289
-        }
3290
-    }
3291
-
3292
-
3293
-    /**
3294
-     * Creates a registration report using only query parameters in the request
3295
-     *
3296
-     * @return void
3297
-     */
3298
-    public function _registrations_report()
3299
-    {
3300
-        $this->_registrations_report_base('_get_registration_query_parameters');
3301
-    }
3302
-
3303
-
3304
-    public function _contact_list_export()
3305
-    {
3306
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3307
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3308
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3309
-            $EE_Export->export_attendees();
3310
-        }
3311
-    }
3312
-
3313
-
3314
-    public function _contact_list_report()
3315
-    {
3316
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3317
-            wp_redirect(
3318
-                EE_Admin_Page::add_query_args_and_nonce(
3319
-                    [
3320
-                        'page'        => 'espresso_batch',
3321
-                        'batch'       => 'file',
3322
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3323
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3324
-                    ]
3325
-                )
3326
-            );
3327
-        } else {
3328
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3329
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3330
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3331
-                $EE_Export->report_attendees();
3332
-            }
3333
-        }
3334
-    }
3335
-
3336
-
3337
-
3338
-
3339
-
3340
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3341
-    /**
3342
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3343
-     *
3344
-     * @return void
3345
-     * @throws EE_Error
3346
-     * @throws InvalidArgumentException
3347
-     * @throws InvalidDataTypeException
3348
-     * @throws InvalidInterfaceException
3349
-     * @throws ReflectionException
3350
-     */
3351
-    protected function _duplicate_attendee()
3352
-    {
3353
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3354
-        $action = $this->request->getRequestParam('return', 'default');
3355
-        // verify we have necessary info
3356
-        if (! $REG_ID) {
3357
-            EE_Error::add_error(
3358
-                esc_html__(
3359
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3360
-                    'event_espresso'
3361
-                ),
3362
-                __FILE__,
3363
-                __LINE__,
3364
-                __FUNCTION__
3365
-            );
3366
-            $query_args = ['action' => $action];
3367
-            $this->_redirect_after_action('', '', '', $query_args, true);
3368
-        }
3369
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3370
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3371
-        if (! $registration instanceof EE_Registration) {
3372
-            throw new RuntimeException(
3373
-                sprintf(
3374
-                    esc_html__(
3375
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3376
-                        'event_espresso'
3377
-                    ),
3378
-                    $REG_ID
3379
-                )
3380
-            );
3381
-        }
3382
-        $attendee = $registration->attendee();
3383
-        // remove relation of existing attendee on registration
3384
-        $registration->_remove_relation_to($attendee, 'Attendee');
3385
-        // new attendee
3386
-        $new_attendee = clone $attendee;
3387
-        $new_attendee->set('ATT_ID', 0);
3388
-        $new_attendee->save();
3389
-        // add new attendee to reg
3390
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3391
-        EE_Error::add_success(
3392
-            esc_html__(
3393
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3394
-                'event_espresso'
3395
-            )
3396
-        );
3397
-        // redirect to edit page for attendee
3398
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3399
-        $this->_redirect_after_action('', '', '', $query_args, true);
3400
-    }
3401
-
3402
-
3403
-    /**
3404
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3405
-     *
3406
-     * @param int     $post_id
3407
-     * @param WP_Post $post
3408
-     * @throws DomainException
3409
-     * @throws EE_Error
3410
-     * @throws InvalidArgumentException
3411
-     * @throws InvalidDataTypeException
3412
-     * @throws InvalidInterfaceException
3413
-     * @throws LogicException
3414
-     * @throws InvalidFormSubmissionException
3415
-     * @throws ReflectionException
3416
-     */
3417
-    protected function _insert_update_cpt_item($post_id, $post)
3418
-    {
3419
-        $success  = true;
3420
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3421
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3422
-            : null;
3423
-        // for attendee updates
3424
-        if ($attendee instanceof EE_Attendee) {
3425
-            // note we should only be UPDATING attendees at this point.
3426
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3427
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3428
-            $updated_fields = [
3429
-                'ATT_fname'     => $fname,
3430
-                'ATT_lname'     => $lname,
3431
-                'ATT_full_name' => "{$fname} {$lname}",
3432
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3433
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3434
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3435
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3436
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3437
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3438
-            ];
3439
-            foreach ($updated_fields as $field => $value) {
3440
-                $attendee->set($field, $value);
3441
-            }
3442
-
3443
-            // process contact details metabox form handler (which will also save the attendee)
3444
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3445
-            $success              = $contact_details_form->process($this->request->requestParams());
3446
-
3447
-            $attendee_update_callbacks = apply_filters(
3448
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3449
-                []
3450
-            );
3451
-            foreach ($attendee_update_callbacks as $a_callback) {
3452
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3453
-                    throw new EE_Error(
3454
-                        sprintf(
3455
-                            esc_html__(
3456
-                                '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.',
3457
-                                'event_espresso'
3458
-                            ),
3459
-                            $a_callback
3460
-                        )
3461
-                    );
3462
-                }
3463
-            }
3464
-        }
3465
-
3466
-        if ($success === false) {
3467
-            EE_Error::add_error(
3468
-                esc_html__(
3469
-                    'Something went wrong with updating the meta table data for the registration.',
3470
-                    'event_espresso'
3471
-                ),
3472
-                __FILE__,
3473
-                __FUNCTION__,
3474
-                __LINE__
3475
-            );
3476
-        }
3477
-    }
3478
-
3479
-
3480
-    public function trash_cpt_item($post_id)
3481
-    {
3482
-    }
3483
-
3484
-
3485
-    public function delete_cpt_item($post_id)
3486
-    {
3487
-    }
3488
-
3489
-
3490
-    public function restore_cpt_item($post_id)
3491
-    {
3492
-    }
3493
-
3494
-
3495
-    protected function _restore_cpt_item($post_id, $revision_id)
3496
-    {
3497
-    }
3498
-
3499
-
3500
-    /**
3501
-     * @throws EE_Error
3502
-     * @throws ReflectionException
3503
-     * @since 4.10.2.p
3504
-     */
3505
-    public function attendee_editor_metaboxes()
3506
-    {
3507
-        $this->verify_cpt_object();
3508
-        remove_meta_box(
3509
-            'postexcerpt',
3510
-            $this->_cpt_routes[ $this->_req_action ],
3511
-            'normal'
3512
-        );
3513
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3514
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3515
-            add_meta_box(
3516
-                'postexcerpt',
3517
-                esc_html__('Short Biography', 'event_espresso'),
3518
-                'post_excerpt_meta_box',
3519
-                $this->_cpt_routes[ $this->_req_action ],
3520
-                'normal'
3521
-            );
3522
-        }
3523
-        if (post_type_supports('espresso_attendees', 'comments')) {
3524
-            add_meta_box(
3525
-                'commentsdiv',
3526
-                esc_html__('Notes on the Contact', 'event_espresso'),
3527
-                'post_comment_meta_box',
3528
-                $this->_cpt_routes[ $this->_req_action ],
3529
-                'normal',
3530
-                'core'
3531
-            );
3532
-        }
3533
-        add_meta_box(
3534
-            'attendee_contact_info',
3535
-            esc_html__('Contact Info', 'event_espresso'),
3536
-            [$this, 'attendee_contact_info'],
3537
-            $this->_cpt_routes[ $this->_req_action ],
3538
-            'side',
3539
-            'core'
3540
-        );
3541
-        add_meta_box(
3542
-            'attendee_details_address',
3543
-            esc_html__('Address Details', 'event_espresso'),
3544
-            [$this, 'attendee_address_details'],
3545
-            $this->_cpt_routes[ $this->_req_action ],
3546
-            'normal',
3547
-            'core'
3548
-        );
3549
-        add_meta_box(
3550
-            'attendee_registrations',
3551
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3552
-            [$this, 'attendee_registrations_meta_box'],
3553
-            $this->_cpt_routes[ $this->_req_action ],
3554
-            'normal',
3555
-            'high'
3556
-        );
3557
-    }
3558
-
3559
-
3560
-    /**
3561
-     * Metabox for attendee contact info
3562
-     *
3563
-     * @param WP_Post $post wp post object
3564
-     * @return void attendee contact info ( and form )
3565
-     * @throws EE_Error
3566
-     * @throws InvalidArgumentException
3567
-     * @throws InvalidDataTypeException
3568
-     * @throws InvalidInterfaceException
3569
-     * @throws LogicException
3570
-     * @throws DomainException
3571
-     */
3572
-    public function attendee_contact_info($post)
3573
-    {
3574
-        // get attendee object ( should already have it )
3575
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3576
-        $form->enqueueStylesAndScripts();
3577
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3578
-    }
3579
-
3580
-
3581
-    /**
3582
-     * Return form handler for the contact details metabox
3583
-     *
3584
-     * @param EE_Attendee $attendee
3585
-     * @return AttendeeContactDetailsMetaboxFormHandler
3586
-     * @throws DomainException
3587
-     * @throws InvalidArgumentException
3588
-     * @throws InvalidDataTypeException
3589
-     * @throws InvalidInterfaceException
3590
-     */
3591
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3592
-    {
3593
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3594
-    }
3595
-
3596
-
3597
-    /**
3598
-     * Metabox for attendee details
3599
-     *
3600
-     * @param WP_Post $post wp post object
3601
-     * @throws EE_Error
3602
-     * @throws ReflectionException
3603
-     */
3604
-    public function attendee_address_details($post)
3605
-    {
3606
-        // get attendee object (should already have it)
3607
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3608
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3609
-            new EE_Question_Form_Input(
3610
-                EE_Question::new_instance(
3611
-                    [
3612
-                        'QST_ID'           => 0,
3613
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3614
-                        'QST_system'       => 'admin-state',
3615
-                    ]
3616
-                ),
3617
-                EE_Answer::new_instance(
3618
-                    [
3619
-                        'ANS_ID'    => 0,
3620
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3621
-                    ]
3622
-                ),
3623
-                [
3624
-                    'input_id'       => 'STA_ID',
3625
-                    'input_name'     => 'STA_ID',
3626
-                    'input_prefix'   => '',
3627
-                    'append_qstn_id' => false,
3628
-                ]
3629
-            )
3630
-        );
3631
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3632
-            new EE_Question_Form_Input(
3633
-                EE_Question::new_instance(
3634
-                    [
3635
-                        'QST_ID'           => 0,
3636
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3637
-                        'QST_system'       => 'admin-country',
3638
-                    ]
3639
-                ),
3640
-                EE_Answer::new_instance(
3641
-                    [
3642
-                        'ANS_ID'    => 0,
3643
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3644
-                    ]
3645
-                ),
3646
-                [
3647
-                    'input_id'       => 'CNT_ISO',
3648
-                    'input_name'     => 'CNT_ISO',
3649
-                    'input_prefix'   => '',
3650
-                    'append_qstn_id' => false,
3651
-                ]
3652
-            )
3653
-        );
3654
-        $template                             =
3655
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3656
-        EEH_Template::display_template($template, $this->_template_args);
3657
-    }
3658
-
3659
-
3660
-    /**
3661
-     * _attendee_details
3662
-     *
3663
-     * @param $post
3664
-     * @return void
3665
-     * @throws DomainException
3666
-     * @throws EE_Error
3667
-     * @throws InvalidArgumentException
3668
-     * @throws InvalidDataTypeException
3669
-     * @throws InvalidInterfaceException
3670
-     * @throws ReflectionException
3671
-     */
3672
-    public function attendee_registrations_meta_box($post)
3673
-    {
3674
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3675
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3676
-        $template                              =
3677
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3678
-        EEH_Template::display_template($template, $this->_template_args);
3679
-    }
3680
-
3681
-
3682
-    /**
3683
-     * add in the form fields for the attendee edit
3684
-     *
3685
-     * @param WP_Post $post wp post object
3686
-     * @return void echos html for new form.
3687
-     * @throws DomainException
3688
-     */
3689
-    public function after_title_form_fields($post)
3690
-    {
3691
-        if ($post->post_type === 'espresso_attendees') {
3692
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3693
-            $template_args['attendee'] = $this->_cpt_model_obj;
3694
-            EEH_Template::display_template($template, $template_args);
3695
-        }
3696
-    }
3697
-
3698
-
3699
-    /**
3700
-     * _trash_or_restore_attendee
3701
-     *
3702
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3703
-     * @return void
3704
-     * @throws EE_Error
3705
-     * @throws InvalidArgumentException
3706
-     * @throws InvalidDataTypeException
3707
-     * @throws InvalidInterfaceException
3708
-     */
3709
-    protected function _trash_or_restore_attendees($trash = true)
3710
-    {
3711
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3712
-        $status = $trash ? 'trash' : 'publish';
3713
-        // Checkboxes
3714
-        if ($this->request->requestParamIsSet('checkbox')) {
3715
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3716
-            // if array has more than one element than success message should be plural
3717
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3718
-            // cycle thru checkboxes
3719
-            foreach ($ATT_IDs as $ATT_ID) {
3720
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3721
-                if (! $updated) {
3722
-                    $success = 0;
3723
-                }
3724
-            }
3725
-        } else {
3726
-            // grab single id and delete
3727
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3728
-            // update attendee
3729
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3730
-        }
3731
-        $what        = $success > 1
3732
-            ? esc_html__('Contacts', 'event_espresso')
3733
-            : esc_html__('Contact', 'event_espresso');
3734
-        $action_desc = $trash
3735
-            ? esc_html__('moved to the trash', 'event_espresso')
3736
-            : esc_html__('restored', 'event_espresso');
3737
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3738
-    }
2897
+		}
2898
+		$template_args = [
2899
+			'title'                    => '',
2900
+			'content'                  => '',
2901
+			'step_button_text'         => '',
2902
+			'show_notification_toggle' => false,
2903
+		];
2904
+		// to indicate we're processing a new registration
2905
+		$hidden_fields = [
2906
+			'processing_registration' => [
2907
+				'type'  => 'hidden',
2908
+				'value' => 0,
2909
+			],
2910
+			'event_id'                => [
2911
+				'type'  => 'hidden',
2912
+				'value' => $this->_reg_event->ID(),
2913
+			],
2914
+		];
2915
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2916
+		$cart = EE_Registry::instance()->SSN->cart();
2917
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2918
+		switch ($step) {
2919
+			case 'ticket':
2920
+				$hidden_fields['processing_registration']['value'] = 1;
2921
+				$template_args['title']                            = esc_html__(
2922
+					'Step One: Select the Ticket for this registration',
2923
+					'event_espresso'
2924
+				);
2925
+				$template_args['content']                          =
2926
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2927
+				$template_args['content']                          .= '</div>';
2928
+				$template_args['step_button_text']                 = esc_html__(
2929
+					'Add Tickets and Continue to Registrant Details',
2930
+					'event_espresso'
2931
+				);
2932
+				$template_args['show_notification_toggle']         = false;
2933
+				break;
2934
+			case 'questions':
2935
+				$hidden_fields['processing_registration']['value'] = 2;
2936
+				$template_args['title']                            = esc_html__(
2937
+					'Step Two: Add Registrant Details for this Registration',
2938
+					'event_espresso'
2939
+				);
2940
+				// in theory, we should be able to run EED_SPCO at this point
2941
+				// because the cart should have been set up properly by the first process_reg_step run.
2942
+				$template_args['content']                  =
2943
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2944
+				$template_args['step_button_text']         = esc_html__(
2945
+					'Save Registration and Continue to Details',
2946
+					'event_espresso'
2947
+				);
2948
+				$template_args['show_notification_toggle'] = true;
2949
+				break;
2950
+		}
2951
+		// we come back to the process_registration_step route.
2952
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2953
+		return EEH_Template::display_template(
2954
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2955
+			$template_args,
2956
+			true
2957
+		);
2958
+	}
2959
+
2960
+
2961
+	/**
2962
+	 * set_reg_event
2963
+	 *
2964
+	 * @return bool
2965
+	 * @throws EE_Error
2966
+	 * @throws InvalidArgumentException
2967
+	 * @throws InvalidDataTypeException
2968
+	 * @throws InvalidInterfaceException
2969
+	 */
2970
+	private function _set_reg_event()
2971
+	{
2972
+		if (is_object($this->_reg_event)) {
2973
+			return true;
2974
+		}
2975
+
2976
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2977
+		if (! $EVT_ID) {
2978
+			return false;
2979
+		}
2980
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2981
+		return true;
2982
+	}
2983
+
2984
+
2985
+	/**
2986
+	 * process_reg_step
2987
+	 *
2988
+	 * @return void
2989
+	 * @throws DomainException
2990
+	 * @throws EE_Error
2991
+	 * @throws InvalidArgumentException
2992
+	 * @throws InvalidDataTypeException
2993
+	 * @throws InvalidInterfaceException
2994
+	 * @throws ReflectionException
2995
+	 * @throws RuntimeException
2996
+	 */
2997
+	public function process_reg_step()
2998
+	{
2999
+		EE_System::do_not_cache();
3000
+		$this->_set_reg_event();
3001
+		/** @var CurrentPage $current_page */
3002
+		$current_page = $this->loader->getShared(CurrentPage::class);
3003
+		$current_page->setEspressoPage(true);
3004
+		$this->request->setRequestParam('uts', time());
3005
+		// what step are we on?
3006
+		$cart = EE_Registry::instance()->SSN->cart();
3007
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3008
+		// if doing ajax then we need to verify the nonce
3009
+		if ($this->request->isAjax()) {
3010
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3011
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3012
+		}
3013
+		switch ($step) {
3014
+			case 'ticket':
3015
+				// process ticket selection
3016
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3017
+				if ($success) {
3018
+					EE_Error::add_success(
3019
+						esc_html__(
3020
+							'Tickets Selected. Now complete the registration.',
3021
+							'event_espresso'
3022
+						)
3023
+					);
3024
+				} else {
3025
+					$this->request->setRequestParam('step_error', true);
3026
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3027
+				}
3028
+				if ($this->request->isAjax()) {
3029
+					$this->new_registration(); // display next step
3030
+				} else {
3031
+					$query_args = [
3032
+						'action'                  => 'new_registration',
3033
+						'processing_registration' => 1,
3034
+						'event_id'                => $this->_reg_event->ID(),
3035
+						'uts'                     => time(),
3036
+					];
3037
+					$this->_redirect_after_action(
3038
+						false,
3039
+						'',
3040
+						'',
3041
+						$query_args,
3042
+						true
3043
+					);
3044
+				}
3045
+				break;
3046
+			case 'questions':
3047
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3048
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3049
+				}
3050
+				// process registration
3051
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3052
+				if ($cart instanceof EE_Cart) {
3053
+					$grand_total = $cart->get_grand_total();
3054
+					if ($grand_total instanceof EE_Line_Item) {
3055
+						$grand_total->save_this_and_descendants_to_txn();
3056
+					}
3057
+				}
3058
+				if (! $transaction instanceof EE_Transaction) {
3059
+					$query_args = [
3060
+						'action'                  => 'new_registration',
3061
+						'processing_registration' => 2,
3062
+						'event_id'                => $this->_reg_event->ID(),
3063
+						'uts'                     => time(),
3064
+					];
3065
+					if ($this->request->isAjax()) {
3066
+						// display registration form again because there are errors (maybe validation?)
3067
+						$this->new_registration();
3068
+						return;
3069
+					}
3070
+					$this->_redirect_after_action(
3071
+						false,
3072
+						'',
3073
+						'',
3074
+						$query_args,
3075
+						true
3076
+					);
3077
+					return;
3078
+				}
3079
+				// maybe update status, and make sure to save transaction if not done already
3080
+				if (! $transaction->update_status_based_on_total_paid()) {
3081
+					$transaction->save();
3082
+				}
3083
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3084
+				$query_args = [
3085
+					'action'        => 'redirect_to_txn',
3086
+					'TXN_ID'        => $transaction->ID(),
3087
+					'EVT_ID'        => $this->_reg_event->ID(),
3088
+					'event_name'    => urlencode($this->_reg_event->name()),
3089
+					'redirect_from' => 'new_registration',
3090
+				];
3091
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3092
+				break;
3093
+		}
3094
+		// what are you looking here for?  Should be nothing to do at this point.
3095
+	}
3096
+
3097
+
3098
+	/**
3099
+	 * redirect_to_txn
3100
+	 *
3101
+	 * @return void
3102
+	 * @throws EE_Error
3103
+	 * @throws InvalidArgumentException
3104
+	 * @throws InvalidDataTypeException
3105
+	 * @throws InvalidInterfaceException
3106
+	 * @throws ReflectionException
3107
+	 */
3108
+	public function redirect_to_txn()
3109
+	{
3110
+		EE_System::do_not_cache();
3111
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3112
+		$query_args = [
3113
+			'action' => 'view_transaction',
3114
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3115
+			'page'   => 'espresso_transactions',
3116
+		];
3117
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3118
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3119
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3120
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3121
+		}
3122
+		EE_Error::add_success(
3123
+			esc_html__(
3124
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3125
+				'event_espresso'
3126
+			)
3127
+		);
3128
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3129
+	}
3130
+
3131
+
3132
+	/**
3133
+	 * generates HTML for the Attendee Contact List
3134
+	 *
3135
+	 * @return void
3136
+	 * @throws DomainException
3137
+	 * @throws EE_Error
3138
+	 */
3139
+	protected function _attendee_contact_list_table()
3140
+	{
3141
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3142
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3143
+		$this->display_admin_list_table_page_with_no_sidebar();
3144
+	}
3145
+
3146
+
3147
+	/**
3148
+	 * get_attendees
3149
+	 *
3150
+	 * @param      $per_page
3151
+	 * @param bool $count whether to return count or data.
3152
+	 * @param bool $trash
3153
+	 * @return array|int
3154
+	 * @throws EE_Error
3155
+	 * @throws InvalidArgumentException
3156
+	 * @throws InvalidDataTypeException
3157
+	 * @throws InvalidInterfaceException
3158
+	 */
3159
+	public function get_attendees($per_page, $count = false, $trash = false)
3160
+	{
3161
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3162
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3163
+		$orderby = $this->request->getRequestParam('orderby');
3164
+		switch ($orderby) {
3165
+			case 'ATT_ID':
3166
+			case 'ATT_fname':
3167
+			case 'ATT_email':
3168
+			case 'ATT_city':
3169
+			case 'STA_ID':
3170
+			case 'CNT_ID':
3171
+				break;
3172
+			case 'Registration_Count':
3173
+				$orderby = 'Registration_Count';
3174
+				break;
3175
+			default:
3176
+				$orderby = 'ATT_lname';
3177
+		}
3178
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3179
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3180
+		$per_page     = absint($per_page) ? $per_page : 10;
3181
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3182
+		$_where       = [];
3183
+		$search_term  = $this->request->getRequestParam('s');
3184
+		if ($search_term) {
3185
+			$search_term  = '%' . $search_term . '%';
3186
+			$_where['OR'] = [
3187
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3188
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3189
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3190
+				'ATT_fname'                         => ['LIKE', $search_term],
3191
+				'ATT_lname'                         => ['LIKE', $search_term],
3192
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3193
+				'ATT_email'                         => ['LIKE', $search_term],
3194
+				'ATT_address'                       => ['LIKE', $search_term],
3195
+				'ATT_address2'                      => ['LIKE', $search_term],
3196
+				'ATT_city'                          => ['LIKE', $search_term],
3197
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3198
+				'State.STA_name'                    => ['LIKE', $search_term],
3199
+				'ATT_phone'                         => ['LIKE', $search_term],
3200
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3201
+				'Registration.REG_code'             => ['LIKE', $search_term],
3202
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3203
+			];
3204
+		}
3205
+		$offset     = ($current_page - 1) * $per_page;
3206
+		$limit      = $count ? null : [$offset, $per_page];
3207
+		$query_args = [
3208
+			$_where,
3209
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3210
+			'limit'         => $limit,
3211
+		];
3212
+		if (! $count) {
3213
+			$query_args['order_by'] = [$orderby => $sort];
3214
+		}
3215
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3216
+		return $count
3217
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3218
+			: $this->getAttendeeModel()->get_all($query_args);
3219
+	}
3220
+
3221
+
3222
+	/**
3223
+	 * This is just taking care of resending the registration confirmation
3224
+	 *
3225
+	 * @return void
3226
+	 * @throws EE_Error
3227
+	 * @throws InvalidArgumentException
3228
+	 * @throws InvalidDataTypeException
3229
+	 * @throws InvalidInterfaceException
3230
+	 * @throws ReflectionException
3231
+	 */
3232
+	protected function _resend_registration()
3233
+	{
3234
+		$this->_process_resend_registration();
3235
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3236
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3237
+		$query_args  = $redirect_to
3238
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3239
+			: ['action' => 'default'];
3240
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3241
+	}
3242
+
3243
+
3244
+	/**
3245
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3246
+	 * to use when selecting registrations
3247
+	 *
3248
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3249
+	 *                                                     the query parameters from the request
3250
+	 * @return void ends the request with a redirect or download
3251
+	 */
3252
+	public function _registrations_report_base($method_name_for_getting_query_params)
3253
+	{
3254
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3255
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3256
+			: null;
3257
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3258
+			$filters = $this->request->getRequestParam('filters', [], DataType::STRING, true);
3259
+			$report_params  = $this->$method_name_for_getting_query_params($filters);
3260
+			wp_redirect(
3261
+				EE_Admin_Page::add_query_args_and_nonce(
3262
+					[
3263
+						'page'        => 'espresso_batch',
3264
+						'batch'       => 'file',
3265
+						'EVT_ID'      => $EVT_ID,
3266
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3267
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3268
+						'filters'     => urlencode(serialize($report_params)),
3269
+						'use_filters' => $this->request->getRequestParam('use_filters', false, DataType::BOOL)
3270
+					]
3271
+				)
3272
+			);
3273
+		} else {
3274
+			// Pull the current request params
3275
+			$request_args = $this->request->requestParams();
3276
+			// Set the required request_args to be passed to the export
3277
+			$required_request_args = [
3278
+				'export' => 'report',
3279
+				'action' => 'registrations_report_for_event',
3280
+				'EVT_ID' => $EVT_ID,
3281
+			];
3282
+			// Merge required request args, overriding any currently set
3283
+			$request_args = array_merge($request_args, $required_request_args);
3284
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3285
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3286
+				$EE_Export = EE_Export::instance($request_args);
3287
+				$EE_Export->export();
3288
+			}
3289
+		}
3290
+	}
3291
+
3292
+
3293
+	/**
3294
+	 * Creates a registration report using only query parameters in the request
3295
+	 *
3296
+	 * @return void
3297
+	 */
3298
+	public function _registrations_report()
3299
+	{
3300
+		$this->_registrations_report_base('_get_registration_query_parameters');
3301
+	}
3302
+
3303
+
3304
+	public function _contact_list_export()
3305
+	{
3306
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3307
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3308
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3309
+			$EE_Export->export_attendees();
3310
+		}
3311
+	}
3312
+
3313
+
3314
+	public function _contact_list_report()
3315
+	{
3316
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3317
+			wp_redirect(
3318
+				EE_Admin_Page::add_query_args_and_nonce(
3319
+					[
3320
+						'page'        => 'espresso_batch',
3321
+						'batch'       => 'file',
3322
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3323
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3324
+					]
3325
+				)
3326
+			);
3327
+		} else {
3328
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3329
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3330
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3331
+				$EE_Export->report_attendees();
3332
+			}
3333
+		}
3334
+	}
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3341
+	/**
3342
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3343
+	 *
3344
+	 * @return void
3345
+	 * @throws EE_Error
3346
+	 * @throws InvalidArgumentException
3347
+	 * @throws InvalidDataTypeException
3348
+	 * @throws InvalidInterfaceException
3349
+	 * @throws ReflectionException
3350
+	 */
3351
+	protected function _duplicate_attendee()
3352
+	{
3353
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3354
+		$action = $this->request->getRequestParam('return', 'default');
3355
+		// verify we have necessary info
3356
+		if (! $REG_ID) {
3357
+			EE_Error::add_error(
3358
+				esc_html__(
3359
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3360
+					'event_espresso'
3361
+				),
3362
+				__FILE__,
3363
+				__LINE__,
3364
+				__FUNCTION__
3365
+			);
3366
+			$query_args = ['action' => $action];
3367
+			$this->_redirect_after_action('', '', '', $query_args, true);
3368
+		}
3369
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3370
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3371
+		if (! $registration instanceof EE_Registration) {
3372
+			throw new RuntimeException(
3373
+				sprintf(
3374
+					esc_html__(
3375
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3376
+						'event_espresso'
3377
+					),
3378
+					$REG_ID
3379
+				)
3380
+			);
3381
+		}
3382
+		$attendee = $registration->attendee();
3383
+		// remove relation of existing attendee on registration
3384
+		$registration->_remove_relation_to($attendee, 'Attendee');
3385
+		// new attendee
3386
+		$new_attendee = clone $attendee;
3387
+		$new_attendee->set('ATT_ID', 0);
3388
+		$new_attendee->save();
3389
+		// add new attendee to reg
3390
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3391
+		EE_Error::add_success(
3392
+			esc_html__(
3393
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3394
+				'event_espresso'
3395
+			)
3396
+		);
3397
+		// redirect to edit page for attendee
3398
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3399
+		$this->_redirect_after_action('', '', '', $query_args, true);
3400
+	}
3401
+
3402
+
3403
+	/**
3404
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3405
+	 *
3406
+	 * @param int     $post_id
3407
+	 * @param WP_Post $post
3408
+	 * @throws DomainException
3409
+	 * @throws EE_Error
3410
+	 * @throws InvalidArgumentException
3411
+	 * @throws InvalidDataTypeException
3412
+	 * @throws InvalidInterfaceException
3413
+	 * @throws LogicException
3414
+	 * @throws InvalidFormSubmissionException
3415
+	 * @throws ReflectionException
3416
+	 */
3417
+	protected function _insert_update_cpt_item($post_id, $post)
3418
+	{
3419
+		$success  = true;
3420
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3421
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3422
+			: null;
3423
+		// for attendee updates
3424
+		if ($attendee instanceof EE_Attendee) {
3425
+			// note we should only be UPDATING attendees at this point.
3426
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3427
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3428
+			$updated_fields = [
3429
+				'ATT_fname'     => $fname,
3430
+				'ATT_lname'     => $lname,
3431
+				'ATT_full_name' => "{$fname} {$lname}",
3432
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3433
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3434
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3435
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3436
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3437
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3438
+			];
3439
+			foreach ($updated_fields as $field => $value) {
3440
+				$attendee->set($field, $value);
3441
+			}
3442
+
3443
+			// process contact details metabox form handler (which will also save the attendee)
3444
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3445
+			$success              = $contact_details_form->process($this->request->requestParams());
3446
+
3447
+			$attendee_update_callbacks = apply_filters(
3448
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3449
+				[]
3450
+			);
3451
+			foreach ($attendee_update_callbacks as $a_callback) {
3452
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3453
+					throw new EE_Error(
3454
+						sprintf(
3455
+							esc_html__(
3456
+								'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.',
3457
+								'event_espresso'
3458
+							),
3459
+							$a_callback
3460
+						)
3461
+					);
3462
+				}
3463
+			}
3464
+		}
3465
+
3466
+		if ($success === false) {
3467
+			EE_Error::add_error(
3468
+				esc_html__(
3469
+					'Something went wrong with updating the meta table data for the registration.',
3470
+					'event_espresso'
3471
+				),
3472
+				__FILE__,
3473
+				__FUNCTION__,
3474
+				__LINE__
3475
+			);
3476
+		}
3477
+	}
3478
+
3479
+
3480
+	public function trash_cpt_item($post_id)
3481
+	{
3482
+	}
3483
+
3484
+
3485
+	public function delete_cpt_item($post_id)
3486
+	{
3487
+	}
3488
+
3489
+
3490
+	public function restore_cpt_item($post_id)
3491
+	{
3492
+	}
3493
+
3494
+
3495
+	protected function _restore_cpt_item($post_id, $revision_id)
3496
+	{
3497
+	}
3498
+
3499
+
3500
+	/**
3501
+	 * @throws EE_Error
3502
+	 * @throws ReflectionException
3503
+	 * @since 4.10.2.p
3504
+	 */
3505
+	public function attendee_editor_metaboxes()
3506
+	{
3507
+		$this->verify_cpt_object();
3508
+		remove_meta_box(
3509
+			'postexcerpt',
3510
+			$this->_cpt_routes[ $this->_req_action ],
3511
+			'normal'
3512
+		);
3513
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3514
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3515
+			add_meta_box(
3516
+				'postexcerpt',
3517
+				esc_html__('Short Biography', 'event_espresso'),
3518
+				'post_excerpt_meta_box',
3519
+				$this->_cpt_routes[ $this->_req_action ],
3520
+				'normal'
3521
+			);
3522
+		}
3523
+		if (post_type_supports('espresso_attendees', 'comments')) {
3524
+			add_meta_box(
3525
+				'commentsdiv',
3526
+				esc_html__('Notes on the Contact', 'event_espresso'),
3527
+				'post_comment_meta_box',
3528
+				$this->_cpt_routes[ $this->_req_action ],
3529
+				'normal',
3530
+				'core'
3531
+			);
3532
+		}
3533
+		add_meta_box(
3534
+			'attendee_contact_info',
3535
+			esc_html__('Contact Info', 'event_espresso'),
3536
+			[$this, 'attendee_contact_info'],
3537
+			$this->_cpt_routes[ $this->_req_action ],
3538
+			'side',
3539
+			'core'
3540
+		);
3541
+		add_meta_box(
3542
+			'attendee_details_address',
3543
+			esc_html__('Address Details', 'event_espresso'),
3544
+			[$this, 'attendee_address_details'],
3545
+			$this->_cpt_routes[ $this->_req_action ],
3546
+			'normal',
3547
+			'core'
3548
+		);
3549
+		add_meta_box(
3550
+			'attendee_registrations',
3551
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3552
+			[$this, 'attendee_registrations_meta_box'],
3553
+			$this->_cpt_routes[ $this->_req_action ],
3554
+			'normal',
3555
+			'high'
3556
+		);
3557
+	}
3558
+
3559
+
3560
+	/**
3561
+	 * Metabox for attendee contact info
3562
+	 *
3563
+	 * @param WP_Post $post wp post object
3564
+	 * @return void attendee contact info ( and form )
3565
+	 * @throws EE_Error
3566
+	 * @throws InvalidArgumentException
3567
+	 * @throws InvalidDataTypeException
3568
+	 * @throws InvalidInterfaceException
3569
+	 * @throws LogicException
3570
+	 * @throws DomainException
3571
+	 */
3572
+	public function attendee_contact_info($post)
3573
+	{
3574
+		// get attendee object ( should already have it )
3575
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3576
+		$form->enqueueStylesAndScripts();
3577
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3578
+	}
3579
+
3580
+
3581
+	/**
3582
+	 * Return form handler for the contact details metabox
3583
+	 *
3584
+	 * @param EE_Attendee $attendee
3585
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3586
+	 * @throws DomainException
3587
+	 * @throws InvalidArgumentException
3588
+	 * @throws InvalidDataTypeException
3589
+	 * @throws InvalidInterfaceException
3590
+	 */
3591
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3592
+	{
3593
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3594
+	}
3595
+
3596
+
3597
+	/**
3598
+	 * Metabox for attendee details
3599
+	 *
3600
+	 * @param WP_Post $post wp post object
3601
+	 * @throws EE_Error
3602
+	 * @throws ReflectionException
3603
+	 */
3604
+	public function attendee_address_details($post)
3605
+	{
3606
+		// get attendee object (should already have it)
3607
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3608
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3609
+			new EE_Question_Form_Input(
3610
+				EE_Question::new_instance(
3611
+					[
3612
+						'QST_ID'           => 0,
3613
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3614
+						'QST_system'       => 'admin-state',
3615
+					]
3616
+				),
3617
+				EE_Answer::new_instance(
3618
+					[
3619
+						'ANS_ID'    => 0,
3620
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3621
+					]
3622
+				),
3623
+				[
3624
+					'input_id'       => 'STA_ID',
3625
+					'input_name'     => 'STA_ID',
3626
+					'input_prefix'   => '',
3627
+					'append_qstn_id' => false,
3628
+				]
3629
+			)
3630
+		);
3631
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3632
+			new EE_Question_Form_Input(
3633
+				EE_Question::new_instance(
3634
+					[
3635
+						'QST_ID'           => 0,
3636
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3637
+						'QST_system'       => 'admin-country',
3638
+					]
3639
+				),
3640
+				EE_Answer::new_instance(
3641
+					[
3642
+						'ANS_ID'    => 0,
3643
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3644
+					]
3645
+				),
3646
+				[
3647
+					'input_id'       => 'CNT_ISO',
3648
+					'input_name'     => 'CNT_ISO',
3649
+					'input_prefix'   => '',
3650
+					'append_qstn_id' => false,
3651
+				]
3652
+			)
3653
+		);
3654
+		$template                             =
3655
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3656
+		EEH_Template::display_template($template, $this->_template_args);
3657
+	}
3658
+
3659
+
3660
+	/**
3661
+	 * _attendee_details
3662
+	 *
3663
+	 * @param $post
3664
+	 * @return void
3665
+	 * @throws DomainException
3666
+	 * @throws EE_Error
3667
+	 * @throws InvalidArgumentException
3668
+	 * @throws InvalidDataTypeException
3669
+	 * @throws InvalidInterfaceException
3670
+	 * @throws ReflectionException
3671
+	 */
3672
+	public function attendee_registrations_meta_box($post)
3673
+	{
3674
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3675
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3676
+		$template                              =
3677
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3678
+		EEH_Template::display_template($template, $this->_template_args);
3679
+	}
3680
+
3681
+
3682
+	/**
3683
+	 * add in the form fields for the attendee edit
3684
+	 *
3685
+	 * @param WP_Post $post wp post object
3686
+	 * @return void echos html for new form.
3687
+	 * @throws DomainException
3688
+	 */
3689
+	public function after_title_form_fields($post)
3690
+	{
3691
+		if ($post->post_type === 'espresso_attendees') {
3692
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3693
+			$template_args['attendee'] = $this->_cpt_model_obj;
3694
+			EEH_Template::display_template($template, $template_args);
3695
+		}
3696
+	}
3697
+
3698
+
3699
+	/**
3700
+	 * _trash_or_restore_attendee
3701
+	 *
3702
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3703
+	 * @return void
3704
+	 * @throws EE_Error
3705
+	 * @throws InvalidArgumentException
3706
+	 * @throws InvalidDataTypeException
3707
+	 * @throws InvalidInterfaceException
3708
+	 */
3709
+	protected function _trash_or_restore_attendees($trash = true)
3710
+	{
3711
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3712
+		$status = $trash ? 'trash' : 'publish';
3713
+		// Checkboxes
3714
+		if ($this->request->requestParamIsSet('checkbox')) {
3715
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3716
+			// if array has more than one element than success message should be plural
3717
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3718
+			// cycle thru checkboxes
3719
+			foreach ($ATT_IDs as $ATT_ID) {
3720
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3721
+				if (! $updated) {
3722
+					$success = 0;
3723
+				}
3724
+			}
3725
+		} else {
3726
+			// grab single id and delete
3727
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3728
+			// update attendee
3729
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3730
+		}
3731
+		$what        = $success > 1
3732
+			? esc_html__('Contacts', 'event_espresso')
3733
+			: esc_html__('Contact', 'event_espresso');
3734
+		$action_desc = $trash
3735
+			? esc_html__('moved to the trash', 'event_espresso')
3736
+			: esc_html__('restored', 'event_espresso');
3737
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3738
+	}
3739 3739
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 2 patches
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -12,382 +12,382 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
14 14
 {
15
-    /**
16
-     * Initial setup of data (called by parent).
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->_view !== 'trash'
21
-            ? $this->_admin_page->get_attendees($this->_per_page)
22
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
23
-        $this->_all_data_count = $this->_view !== 'trash'
24
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
25
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
26
-    }
27
-
28
-
29
-    /**
30
-     * Initial setup of properties.
31
-     */
32
-    protected function _set_properties()
33
-    {
34
-        $this->_wp_list_args = array(
35
-            'singular' => esc_html__('attendee', 'event_espresso'),
36
-            'plural'   => esc_html__('attendees', 'event_espresso'),
37
-            'ajax'     => true,
38
-            'screen'   => $this->_admin_page->get_current_screen()->id,
39
-        );
40
-
41
-        $this->_columns = array(
42
-            'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
-            'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
-            'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
-            'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
-            'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
-            'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
-            'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
-            'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
-            'ATT_city'           => esc_html__('City', 'event_espresso'),
51
-            'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
-            'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
-        );
54
-
55
-        $this->_sortable_columns = array(
56
-            'ATT_ID'             => array('ATT_ID' => false),
57
-            'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
-            'ATT_fname'          => array('ATT_fname' => false),
59
-            'ATT_email'          => array('ATT_email' => false),
60
-            'Registration_Count' => array('Registration_Count' => false),
61
-            'ATT_city'           => array('ATT_city' => false),
62
-            'STA_ID'             => array('STA_ID' => false),
63
-            'CNT_ISO'            => array('CNT_ISO' => false),
64
-        );
65
-
66
-        $this->_hidden_columns = array(
67
-            'ATT_phone',
68
-            'ATT_address',
69
-            'ATT_city',
70
-            'STA_ID',
71
-            'CNT_ISO',
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * Initial setup of filters
78
-     *
79
-     * @return array
80
-     */
81
-    protected function _get_table_filters()
82
-    {
83
-        return array();
84
-    }
85
-
86
-
87
-    /**
88
-     * Initial setup of counts for views
89
-     *
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     */
94
-    protected function _add_view_counts()
95
-    {
96
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
-        if (
98
-            EE_Registry::instance()->CAP->current_user_can(
99
-                'ee_delete_contacts',
100
-                'espresso_registrations_delete_registration'
101
-            )
102
-        ) {
103
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
-        }
105
-    }
106
-
107
-
108
-    /**
109
-     * Get count of attendees.
110
-     *
111
-     * @return int
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    protected function _get_attendees_count()
118
-    {
119
-        return EEM_Attendee::instance()->count();
120
-    }
121
-
122
-
123
-    /**
124
-     * Checkbox column
125
-     *
126
-     * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
-     * @return string
128
-     * @throws EE_Error
129
-     */
130
-    public function column_cb($attendee)
131
-    {
132
-        if (! $attendee instanceof EE_Attendee) {
133
-            return '';
134
-        }
135
-        return sprintf(
136
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
-            $attendee->ID()
138
-        );
139
-    }
140
-
141
-
142
-    /**
143
-     * ATT_ID column
144
-     *
145
-     * @param EE_Attendee $attendee
146
-     * @return string
147
-     * @throws EE_Error
148
-     */
149
-    public function column_ATT_ID(EE_Attendee $attendee)
150
-    {
151
-        $content = $attendee->ID();
152
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
-        return $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * ATT_lname column
160
-     *
161
-     * @param EE_Attendee $attendee
162
-     * @return string
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidInterfaceException
166
-     * @throws EE_Error
167
-     */
168
-    public function column_ATT_lname(EE_Attendee $attendee)
169
-    {
170
-        // edit attendee link
171
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
-            array(
173
-                'action' => 'edit_attendee',
174
-                'post'   => $attendee->ID(),
175
-            ),
176
-            REG_ADMIN_URL
177
-        );
178
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
179
-            'ee_edit_contacts',
180
-            'espresso_registrations_edit_attendee'
181
-        )
182
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
185
-            : $attendee->lname();
186
-        return $name_link;
187
-    }
188
-
189
-
190
-    /**
191
-     * ATT_fname column
192
-     *
193
-     * @param EE_Attendee $attendee
194
-     * @return string
195
-     * @throws InvalidArgumentException
196
-     * @throws InvalidDataTypeException
197
-     * @throws InvalidInterfaceException
198
-     * @throws EE_Error
199
-     */
200
-    public function column_ATT_fname(EE_Attendee $attendee)
201
-    {
202
-        // Build row actions
203
-        $actions = array();
204
-        // edit attendee link
205
-        if (
206
-            EE_Registry::instance()->CAP->current_user_can(
207
-                'ee_edit_contacts',
208
-                'espresso_registrations_edit_attendee'
209
-            )
210
-        ) {
211
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
-                array(
213
-                    'action' => 'edit_attendee',
214
-                    'post'   => $attendee->ID(),
215
-                ),
216
-                REG_ADMIN_URL
217
-            );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
221
-        }
222
-
223
-        if ($this->_view === 'in_use') {
224
-            // trash attendee link
225
-            if (
226
-                EE_Registry::instance()->CAP->current_user_can(
227
-                    'ee_delete_contacts',
228
-                    'espresso_registrations_trash_attendees'
229
-                )
230
-            ) {
231
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
-                    array(
233
-                        'action' => 'trash_attendee',
234
-                        'ATT_ID' => $attendee->ID(),
235
-                    ),
236
-                    REG_ADMIN_URL
237
-                );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
239
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
-            }
242
-        } else {
243
-            if (
244
-                EE_Registry::instance()->CAP->current_user_can(
245
-                    'ee_delete_contacts',
246
-                    'espresso_registrations_restore_attendees'
247
-                )
248
-            ) {
249
-                // restore attendee link
250
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
-                    array(
252
-                        'action' => 'restore_attendees',
253
-                        'ATT_ID' => $attendee->ID(),
254
-                    ),
255
-                    REG_ADMIN_URL
256
-                );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
260
-            }
261
-        }
262
-
263
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
-            array(
265
-                'action' => 'edit_attendee',
266
-                'post'   => $attendee->ID(),
267
-            ),
268
-            REG_ADMIN_URL
269
-        );
270
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
271
-            'ee_edit_contacts',
272
-            'espresso_registrations_edit_attendee'
273
-        )
274
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
-            : $attendee->fname();
277
-
278
-        // Return the name contents
279
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
-    }
281
-
282
-
283
-    /**
284
-     * Email Column
285
-     *
286
-     * @param EE_Attendee $attendee
287
-     * @return string
288
-     * @throws EE_Error
289
-     */
290
-    public function column_ATT_email(EE_Attendee $attendee)
291
-    {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
-    }
294
-
295
-
296
-    /**
297
-     * Column displaying count of registrations attached to Attendee.
298
-     *
299
-     * @param EE_Attendee $attendee
300
-     * @return string
301
-     * @throws EE_Error
302
-     */
303
-    public function column_Registration_Count(EE_Attendee $attendee)
304
-    {
305
-        $link = EEH_URL::add_query_args_and_nonce(
306
-            array(
307
-                'action' => 'default',
308
-                'ATT_ID' => $attendee->ID(),
309
-            ),
310
-            REG_ADMIN_URL
311
-        );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
-    }
314
-
315
-
316
-    /**
317
-     * ATT_address column
318
-     *
319
-     * @param EE_Attendee $attendee
320
-     * @return mixed
321
-     * @throws EE_Error
322
-     */
323
-    public function column_ATT_address(EE_Attendee $attendee)
324
-    {
325
-        return $attendee->address();
326
-    }
327
-
328
-
329
-    /**
330
-     * ATT_city column
331
-     *
332
-     * @param EE_Attendee $attendee
333
-     * @return mixed
334
-     * @throws EE_Error
335
-     */
336
-    public function column_ATT_city(EE_Attendee $attendee)
337
-    {
338
-        return $attendee->city();
339
-    }
340
-
341
-
342
-    /**
343
-     * State Column
344
-     *
345
-     * @param EE_Attendee $attendee
346
-     * @return string
347
-     * @throws EE_Error
348
-     * @throws InvalidArgumentException
349
-     * @throws InvalidDataTypeException
350
-     * @throws InvalidInterfaceException
351
-     */
352
-    public function column_STA_ID(EE_Attendee $attendee)
353
-    {
354
-        $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
357
-            : $attendee->state_ID();
358
-        return ! is_numeric($state) ? $state : '';
359
-    }
360
-
361
-
362
-    /**
363
-     * Country Column
364
-     *
365
-     * @param EE_Attendee $attendee
366
-     * @return string
367
-     * @throws EE_Error
368
-     * @throws InvalidArgumentException
369
-     * @throws InvalidDataTypeException
370
-     * @throws InvalidInterfaceException
371
-     */
372
-    public function column_CNT_ISO(EE_Attendee $attendee)
373
-    {
374
-        $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
-            : $attendee->country_ID();
378
-        return ! is_numeric($country) ? $country : '';
379
-    }
380
-
381
-
382
-    /**
383
-     * Phone Number column
384
-     *
385
-     * @param EE_Attendee $attendee
386
-     * @return mixed
387
-     * @throws EE_Error
388
-     */
389
-    public function column_ATT_phone(EE_Attendee $attendee)
390
-    {
391
-        return $attendee->phone();
392
-    }
15
+	/**
16
+	 * Initial setup of data (called by parent).
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->_view !== 'trash'
21
+			? $this->_admin_page->get_attendees($this->_per_page)
22
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
23
+		$this->_all_data_count = $this->_view !== 'trash'
24
+			? $this->_admin_page->get_attendees($this->_per_page, true)
25
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
26
+	}
27
+
28
+
29
+	/**
30
+	 * Initial setup of properties.
31
+	 */
32
+	protected function _set_properties()
33
+	{
34
+		$this->_wp_list_args = array(
35
+			'singular' => esc_html__('attendee', 'event_espresso'),
36
+			'plural'   => esc_html__('attendees', 'event_espresso'),
37
+			'ajax'     => true,
38
+			'screen'   => $this->_admin_page->get_current_screen()->id,
39
+		);
40
+
41
+		$this->_columns = array(
42
+			'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
+			'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
+			'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
+			'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
+			'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
+			'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
+			'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
+			'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
+			'ATT_city'           => esc_html__('City', 'event_espresso'),
51
+			'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
+			'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
+		);
54
+
55
+		$this->_sortable_columns = array(
56
+			'ATT_ID'             => array('ATT_ID' => false),
57
+			'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
+			'ATT_fname'          => array('ATT_fname' => false),
59
+			'ATT_email'          => array('ATT_email' => false),
60
+			'Registration_Count' => array('Registration_Count' => false),
61
+			'ATT_city'           => array('ATT_city' => false),
62
+			'STA_ID'             => array('STA_ID' => false),
63
+			'CNT_ISO'            => array('CNT_ISO' => false),
64
+		);
65
+
66
+		$this->_hidden_columns = array(
67
+			'ATT_phone',
68
+			'ATT_address',
69
+			'ATT_city',
70
+			'STA_ID',
71
+			'CNT_ISO',
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * Initial setup of filters
78
+	 *
79
+	 * @return array
80
+	 */
81
+	protected function _get_table_filters()
82
+	{
83
+		return array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * Initial setup of counts for views
89
+	 *
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 */
94
+	protected function _add_view_counts()
95
+	{
96
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
+		if (
98
+			EE_Registry::instance()->CAP->current_user_can(
99
+				'ee_delete_contacts',
100
+				'espresso_registrations_delete_registration'
101
+			)
102
+		) {
103
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
+		}
105
+	}
106
+
107
+
108
+	/**
109
+	 * Get count of attendees.
110
+	 *
111
+	 * @return int
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	protected function _get_attendees_count()
118
+	{
119
+		return EEM_Attendee::instance()->count();
120
+	}
121
+
122
+
123
+	/**
124
+	 * Checkbox column
125
+	 *
126
+	 * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
+	 * @return string
128
+	 * @throws EE_Error
129
+	 */
130
+	public function column_cb($attendee)
131
+	{
132
+		if (! $attendee instanceof EE_Attendee) {
133
+			return '';
134
+		}
135
+		return sprintf(
136
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
+			$attendee->ID()
138
+		);
139
+	}
140
+
141
+
142
+	/**
143
+	 * ATT_ID column
144
+	 *
145
+	 * @param EE_Attendee $attendee
146
+	 * @return string
147
+	 * @throws EE_Error
148
+	 */
149
+	public function column_ATT_ID(EE_Attendee $attendee)
150
+	{
151
+		$content = $attendee->ID();
152
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
+		return $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * ATT_lname column
160
+	 *
161
+	 * @param EE_Attendee $attendee
162
+	 * @return string
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidInterfaceException
166
+	 * @throws EE_Error
167
+	 */
168
+	public function column_ATT_lname(EE_Attendee $attendee)
169
+	{
170
+		// edit attendee link
171
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
+			array(
173
+				'action' => 'edit_attendee',
174
+				'post'   => $attendee->ID(),
175
+			),
176
+			REG_ADMIN_URL
177
+		);
178
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
179
+			'ee_edit_contacts',
180
+			'espresso_registrations_edit_attendee'
181
+		)
182
+			? '<a href="' . $edit_lnk_url . '" aria-label="'
183
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
+			  . $attendee->lname() . '</a>'
185
+			: $attendee->lname();
186
+		return $name_link;
187
+	}
188
+
189
+
190
+	/**
191
+	 * ATT_fname column
192
+	 *
193
+	 * @param EE_Attendee $attendee
194
+	 * @return string
195
+	 * @throws InvalidArgumentException
196
+	 * @throws InvalidDataTypeException
197
+	 * @throws InvalidInterfaceException
198
+	 * @throws EE_Error
199
+	 */
200
+	public function column_ATT_fname(EE_Attendee $attendee)
201
+	{
202
+		// Build row actions
203
+		$actions = array();
204
+		// edit attendee link
205
+		if (
206
+			EE_Registry::instance()->CAP->current_user_can(
207
+				'ee_edit_contacts',
208
+				'espresso_registrations_edit_attendee'
209
+			)
210
+		) {
211
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
+				array(
213
+					'action' => 'edit_attendee',
214
+					'post'   => $attendee->ID(),
215
+				),
216
+				REG_ADMIN_URL
217
+			);
218
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
219
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
221
+		}
222
+
223
+		if ($this->_view === 'in_use') {
224
+			// trash attendee link
225
+			if (
226
+				EE_Registry::instance()->CAP->current_user_can(
227
+					'ee_delete_contacts',
228
+					'espresso_registrations_trash_attendees'
229
+				)
230
+			) {
231
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
+					array(
233
+						'action' => 'trash_attendee',
234
+						'ATT_ID' => $attendee->ID(),
235
+					),
236
+					REG_ADMIN_URL
237
+				);
238
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
239
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
240
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
+			}
242
+		} else {
243
+			if (
244
+				EE_Registry::instance()->CAP->current_user_can(
245
+					'ee_delete_contacts',
246
+					'espresso_registrations_restore_attendees'
247
+				)
248
+			) {
249
+				// restore attendee link
250
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
+					array(
252
+						'action' => 'restore_attendees',
253
+						'ATT_ID' => $attendee->ID(),
254
+					),
255
+					REG_ADMIN_URL
256
+				);
257
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
258
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
260
+			}
261
+		}
262
+
263
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
+			array(
265
+				'action' => 'edit_attendee',
266
+				'post'   => $attendee->ID(),
267
+			),
268
+			REG_ADMIN_URL
269
+		);
270
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
271
+			'ee_edit_contacts',
272
+			'espresso_registrations_edit_attendee'
273
+		)
274
+			? '<a href="' . $edit_lnk_url . '" aria-label="'
275
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
+			: $attendee->fname();
277
+
278
+		// Return the name contents
279
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
+	}
281
+
282
+
283
+	/**
284
+	 * Email Column
285
+	 *
286
+	 * @param EE_Attendee $attendee
287
+	 * @return string
288
+	 * @throws EE_Error
289
+	 */
290
+	public function column_ATT_email(EE_Attendee $attendee)
291
+	{
292
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
+	}
294
+
295
+
296
+	/**
297
+	 * Column displaying count of registrations attached to Attendee.
298
+	 *
299
+	 * @param EE_Attendee $attendee
300
+	 * @return string
301
+	 * @throws EE_Error
302
+	 */
303
+	public function column_Registration_Count(EE_Attendee $attendee)
304
+	{
305
+		$link = EEH_URL::add_query_args_and_nonce(
306
+			array(
307
+				'action' => 'default',
308
+				'ATT_ID' => $attendee->ID(),
309
+			),
310
+			REG_ADMIN_URL
311
+		);
312
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
+	}
314
+
315
+
316
+	/**
317
+	 * ATT_address column
318
+	 *
319
+	 * @param EE_Attendee $attendee
320
+	 * @return mixed
321
+	 * @throws EE_Error
322
+	 */
323
+	public function column_ATT_address(EE_Attendee $attendee)
324
+	{
325
+		return $attendee->address();
326
+	}
327
+
328
+
329
+	/**
330
+	 * ATT_city column
331
+	 *
332
+	 * @param EE_Attendee $attendee
333
+	 * @return mixed
334
+	 * @throws EE_Error
335
+	 */
336
+	public function column_ATT_city(EE_Attendee $attendee)
337
+	{
338
+		return $attendee->city();
339
+	}
340
+
341
+
342
+	/**
343
+	 * State Column
344
+	 *
345
+	 * @param EE_Attendee $attendee
346
+	 * @return string
347
+	 * @throws EE_Error
348
+	 * @throws InvalidArgumentException
349
+	 * @throws InvalidDataTypeException
350
+	 * @throws InvalidInterfaceException
351
+	 */
352
+	public function column_STA_ID(EE_Attendee $attendee)
353
+	{
354
+		$states = EEM_State::instance()->get_all_states();
355
+		$state = isset($states[ $attendee->state_ID() ])
356
+			? $states[ $attendee->state_ID() ]->get('STA_name')
357
+			: $attendee->state_ID();
358
+		return ! is_numeric($state) ? $state : '';
359
+	}
360
+
361
+
362
+	/**
363
+	 * Country Column
364
+	 *
365
+	 * @param EE_Attendee $attendee
366
+	 * @return string
367
+	 * @throws EE_Error
368
+	 * @throws InvalidArgumentException
369
+	 * @throws InvalidDataTypeException
370
+	 * @throws InvalidInterfaceException
371
+	 */
372
+	public function column_CNT_ISO(EE_Attendee $attendee)
373
+	{
374
+		$countries = EEM_Country::instance()->get_all_countries();
375
+		$country = isset($countries[ $attendee->country_ID() ])
376
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
+			: $attendee->country_ID();
378
+		return ! is_numeric($country) ? $country : '';
379
+	}
380
+
381
+
382
+	/**
383
+	 * Phone Number column
384
+	 *
385
+	 * @param EE_Attendee $attendee
386
+	 * @return mixed
387
+	 * @throws EE_Error
388
+	 */
389
+	public function column_ATT_phone(EE_Attendee $attendee)
390
+	{
391
+		return $attendee->phone();
392
+	}
393 393
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function column_cb($attendee)
131 131
     {
132
-        if (! $attendee instanceof EE_Attendee) {
132
+        if ( ! $attendee instanceof EE_Attendee) {
133 133
             return '';
134 134
         }
135 135
         return sprintf(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $content = $attendee->ID();
152 152
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
153
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
154 154
         return $content;
155 155
     }
156 156
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
             'ee_edit_contacts',
180 180
             'espresso_registrations_edit_attendee'
181 181
         )
182
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
182
+            ? '<a href="'.$edit_lnk_url.'" aria-label="'
183
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
184
+              . $attendee->lname().'</a>'
185 185
             : $attendee->lname();
186 186
         return $name_link;
187 187
     }
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
                 ),
216 216
                 REG_ADMIN_URL
217 217
             );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
218
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" aria-label="'
219
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
220
+                               . esc_html__('Edit', 'event_espresso').'</a>';
221 221
         }
222 222
 
223 223
         if ($this->_view === 'in_use') {
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
                     ),
236 236
                     REG_ADMIN_URL
237 237
                 );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
238
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" aria-label="'
239 239
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
240
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
241 241
             }
242 242
         } else {
243 243
             if (
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
                     ),
255 255
                     REG_ADMIN_URL
256 256
                 );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
257
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" aria-label="'
258
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
259
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
260 260
             }
261 261
         }
262 262
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
             'ee_edit_contacts',
272 272
             'espresso_registrations_edit_attendee'
273 273
         )
274
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
274
+            ? '<a href="'.$edit_lnk_url.'" aria-label="'
275
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
276 276
             : $attendee->fname();
277 277
 
278 278
         // Return the name contents
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function column_ATT_email(EE_Attendee $attendee)
291 291
     {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
292
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
293 293
     }
294 294
 
295 295
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             ),
310 310
             REG_ADMIN_URL
311 311
         );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
312
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
313 313
     }
314 314
 
315 315
 
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     public function column_STA_ID(EE_Attendee $attendee)
353 353
     {
354 354
         $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
355
+        $state = isset($states[$attendee->state_ID()])
356
+            ? $states[$attendee->state_ID()]->get('STA_name')
357 357
             : $attendee->state_ID();
358 358
         return ! is_numeric($state) ? $state : '';
359 359
     }
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
     public function column_CNT_ISO(EE_Attendee $attendee)
373 373
     {
374 374
         $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
375
+        $country = isset($countries[$attendee->country_ID()])
376
+            ? $countries[$attendee->country_ID()]->get('CNT_name')
377 377
             : $attendee->country_ID();
378 378
         return ! is_numeric($country) ? $country : '';
379 379
     }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +966 added lines, -966 removed lines patch added patch discarded remove patch
@@ -14,827 +14,827 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_Registrations_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var Registrations_Admin_Page
19
-     */
20
-    protected $_admin_page;
21
-
22
-    /**
23
-     * @var array
24
-     */
25
-    private $_status;
26
-
27
-    /**
28
-     * An array of transaction details for the related transaction to the registration being processed.
29
-     * This is set via the _set_related_details method.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $_transaction_details = [];
34
-
35
-    /**
36
-     * An array of event details for the related event to the registration being processed.
37
-     * This is set via the _set_related_details method.
38
-     *
39
-     * @var array
40
-     */
41
-    protected $_event_details = [];
42
-
43
-
44
-    /**
45
-     * @param Registrations_Admin_Page $admin_page
46
-     */
47
-    public function __construct(Registrations_Admin_Page $admin_page)
48
-    {
49
-        $req_data = $admin_page->get_request_data();
50
-        if (! empty($req_data['event_id'])) {
51
-            $extra_query_args = [];
52
-            foreach ($admin_page->get_views() as $view_details) {
53
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
54
-            }
55
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
56
-        }
57
-        parent::__construct($admin_page);
58
-        $this->_status = $this->_admin_page->get_registration_status_array();
59
-    }
60
-
61
-
62
-    /**
63
-     * @return void
64
-     * @throws EE_Error
65
-     */
66
-    protected function _setup_data()
67
-    {
68
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
69
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
70
-    }
71
-
72
-
73
-    /**
74
-     * @return void
75
-     */
76
-    protected function _set_properties()
77
-    {
78
-        $return_url          = $this->getReturnUrl();
79
-        $this->_wp_list_args = [
80
-            'singular' => esc_html__('registration', 'event_espresso'),
81
-            'plural'   => esc_html__('registrations', 'event_espresso'),
82
-            'ajax'     => true,
83
-            'screen'   => $this->_admin_page->get_current_screen()->id,
84
-        ];
85
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
86
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
87
-        $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
88
-        $ID_column_name      .= '</span> ';
89
-
90
-        $EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
91
-        $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
92
-
93
-        if ($EVT_ID) {
94
-            $this->_columns        = [
95
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
96
-                '_REG_ID'          => $ID_column_name,
97
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
98
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
99
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
100
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
101
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
102
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
103
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
104
-                'actions'          => esc_html__('Actions', 'event_espresso'),
105
-            ];
106
-        } else {
107
-            $this->_columns        = [
108
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
109
-                '_REG_ID'          => $ID_column_name,
110
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
111
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
112
-                'event_name'       => esc_html__('Event', 'event_espresso'),
113
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
114
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
115
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
116
-                'actions'          => esc_html__('Actions', 'event_espresso'),
117
-            ];
118
-        }
119
-
120
-        $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
121
-        if (! empty($csv_report)) {
122
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
123
-        }
124
-
125
-        $this->_primary_column   = '_REG_ID';
126
-        $this->_sortable_columns = [
127
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
128
-            /**
129
-             * Allows users to change the default sort if they wish.
130
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
131
-             * name.
132
-             */
133
-            'ATT_fname'     => [
134
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
135
-                true,
136
-                $this,
137
-            ]
138
-                ? ['ATT_lname' => false]
139
-                : ['ATT_fname' => false],
140
-            'event_name'    => ['event_name' => false],
141
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
142
-            '_REG_ID'       => ['_REG_ID' => false],
143
-        ];
144
-        $this->_hidden_columns   = [];
145
-    }
146
-
147
-
148
-    /**
149
-     * This simply sets up the row class for the table rows.
150
-     * Allows for easier overriding of child methods for setting up sorting.
151
-     *
152
-     * @param EE_Registration $item the current item
153
-     * @return string
154
-     */
155
-    protected function _get_row_class($item)
156
-    {
157
-        $class = parent::_get_row_class($item);
158
-        // add status class
159
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
160
-        if ($this->_has_checkbox_column) {
161
-            $class .= ' has-checkbox-column';
162
-        }
163
-        return $class;
164
-    }
165
-
166
-
167
-    /**
168
-     * Set the $_transaction_details property if not set yet.
169
-     *
170
-     * @param EE_Registration $registration
171
-     * @throws EE_Error
172
-     * @throws InvalidArgumentException
173
-     * @throws ReflectionException
174
-     * @throws InvalidDataTypeException
175
-     * @throws InvalidInterfaceException
176
-     */
177
-    protected function _set_related_details(EE_Registration $registration)
178
-    {
179
-        $transaction                = $registration->get_first_related('Transaction');
180
-        $status                     = $transaction instanceof EE_Transaction
181
-            ? $transaction->status_ID()
182
-            : EEM_Transaction::failed_status_code;
183
-        $this->_transaction_details = [
184
-            'transaction' => $transaction,
185
-            'status'      => $status,
186
-            'id'          => $transaction instanceof EE_Transaction
187
-                ? $transaction->ID()
188
-                : 0,
189
-            'title_attr'  => sprintf(
190
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
191
-                EEH_Template::pretty_status($status, false, 'sentence')
192
-            ),
193
-        ];
194
-        try {
195
-            $event = $registration->event();
196
-        } catch (EntityNotFoundException $e) {
197
-            $event = null;
198
-        }
199
-        $status               = $event instanceof EE_Event
200
-            ? $event->get_active_status()
201
-            : EE_Datetime::inactive;
202
-        $this->_event_details = [
203
-            'event'      => $event,
204
-            'status'     => $status,
205
-            'id'         => $event instanceof EE_Event
206
-                ? $event->ID()
207
-                : 0,
208
-            'title_attr' => sprintf(
209
-                esc_html__('Edit Event (%s)', 'event_espresso'),
210
-                EEH_Template::pretty_status($status, false, 'sentence')
211
-            ),
212
-        ];
213
-    }
214
-
215
-
216
-    /**
217
-     *    _get_table_filters
218
-     *
219
-     * @return array
220
-     * @throws EE_Error
221
-     * @throws ReflectionException
222
-     */
223
-    protected function _get_table_filters()
224
-    {
225
-        $filters = [];
226
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
227
-        // methods.
228
-        $cur_date     = isset($this->_req_data['month_range'])
229
-            ? $this->_req_data['month_range']
230
-            : '';
231
-        $cur_category = isset($this->_req_data['EVT_CAT'])
232
-            ? $this->_req_data['EVT_CAT']
233
-            : -1;
234
-        $reg_status   = isset($this->_req_data['_reg_status'])
235
-            ? $this->_req_data['_reg_status']
236
-            : '';
237
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
238
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
239
-        $status       = [];
240
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
241
-        foreach ($this->_status as $key => $value) {
242
-            $status[] = ['id' => $key, 'text' => $value];
243
-        }
244
-        if ($this->_view !== 'incomplete') {
245
-            $filters[] = EEH_Form_Fields::select_input(
246
-                '_reg_status',
247
-                $status,
248
-                isset($this->_req_data['_reg_status'])
249
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
250
-                    : ''
251
-            );
252
-        }
253
-        if (isset($this->_req_data['event_id'])) {
254
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
255
-        }
256
-        return $filters;
257
-    }
258
-
259
-
260
-    /**
261
-     * @return void
262
-     * @throws EE_Error
263
-     * @throws InvalidArgumentException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidInterfaceException
266
-     */
267
-    protected function _add_view_counts()
268
-    {
269
-        $this->_views['all']['count']   = $this->_total_registrations();
270
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
271
-        $this->_views['today']['count'] = $this->_total_registrations_today();
272
-        if (
273
-            EE_Registry::instance()->CAP->current_user_can(
274
-                'ee_delete_registrations',
275
-                'espresso_registrations_trash_registrations'
276
-            )
277
-        ) {
278
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
279
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
280
-        }
281
-    }
282
-
283
-
284
-    /**
285
-     * @param string $view
286
-     * @return int
287
-     * @throws EE_Error
288
-     * @throws InvalidArgumentException
289
-     * @throws InvalidDataTypeException
290
-     * @throws InvalidInterfaceException
291
-     */
292
-    protected function _total_registrations($view = '')
293
-    {
294
-        $_where = [];
295
-        $EVT_ID = isset($this->_req_data['event_id'])
296
-            ? absint($this->_req_data['event_id'])
297
-            : false;
298
-        if ($EVT_ID) {
299
-            $_where['EVT_ID'] = $EVT_ID;
300
-        }
301
-        switch ($view) {
302
-            case 'trash':
303
-                return EEM_Registration::instance()->count_deleted([$_where]);
304
-            case 'incomplete':
305
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
306
-                break;
307
-            default:
308
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
309
-        }
310
-        return EEM_Registration::instance()->count([$_where]);
311
-    }
312
-
313
-
314
-    /**
315
-     * @return int
316
-     * @throws EE_Error
317
-     * @throws InvalidArgumentException
318
-     * @throws InvalidDataTypeException
319
-     * @throws InvalidInterfaceException
320
-     */
321
-    protected function _total_registrations_this_month()
322
-    {
323
-        $EVT_ID          = isset($this->_req_data['event_id'])
324
-            ? absint($this->_req_data['event_id'])
325
-            : false;
326
-        $_where          = $EVT_ID
327
-            ? ['EVT_ID' => $EVT_ID]
328
-            : [];
329
-        $this_year_r     = date('Y', current_time('timestamp'));
330
-        $time_start      = ' 00:00:00';
331
-        $time_end        = ' 23:59:59';
332
-        $this_month_r    = date('m', current_time('timestamp'));
333
-        $days_this_month = date('t', current_time('timestamp'));
334
-        // setup date query.
335
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
336
-            'REG_date',
337
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
338
-            'Y-m-d H:i:s'
339
-        );
340
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
341
-            'REG_date',
342
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
343
-            'Y-m-d H:i:s'
344
-        );
345
-        $_where['REG_date'] = [
346
-            'BETWEEN',
347
-            [
348
-                $beginning_string,
349
-                $end_string,
350
-            ],
351
-        ];
352
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
353
-        return EEM_Registration::instance()->count([$_where]);
354
-    }
355
-
356
-
357
-    /**
358
-     * @return int
359
-     * @throws EE_Error
360
-     * @throws InvalidArgumentException
361
-     * @throws InvalidDataTypeException
362
-     * @throws InvalidInterfaceException
363
-     */
364
-    protected function _total_registrations_today()
365
-    {
366
-        $EVT_ID             = isset($this->_req_data['event_id'])
367
-            ? absint($this->_req_data['event_id'])
368
-            : false;
369
-        $_where             = $EVT_ID
370
-            ? ['EVT_ID' => $EVT_ID]
371
-            : [];
372
-        $current_date       = date('Y-m-d', current_time('timestamp'));
373
-        $time_start         = ' 00:00:00';
374
-        $time_end           = ' 23:59:59';
375
-        $_where['REG_date'] = [
376
-            'BETWEEN',
377
-            [
378
-                EEM_Registration::instance()->convert_datetime_for_query(
379
-                    'REG_date',
380
-                    $current_date . $time_start,
381
-                    'Y-m-d H:i:s'
382
-                ),
383
-                EEM_Registration::instance()->convert_datetime_for_query(
384
-                    'REG_date',
385
-                    $current_date . $time_end,
386
-                    'Y-m-d H:i:s'
387
-                ),
388
-            ],
389
-        ];
390
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
391
-        return EEM_Registration::instance()->count([$_where]);
392
-    }
393
-
394
-
395
-    /**
396
-     * @param EE_Registration $item
397
-     * @return string
398
-     * @throws EE_Error
399
-     * @throws InvalidArgumentException
400
-     * @throws InvalidDataTypeException
401
-     * @throws InvalidInterfaceException
402
-     * @throws ReflectionException
403
-     */
404
-    public function column_cb($item)
405
-    {
406
-        /** checkbox/lock **/
407
-        $transaction   = $item->get_first_related('Transaction');
408
-        $payment_count = $transaction instanceof EE_Transaction
409
-            ? $transaction->count_related('Payment')
410
-            : 0;
411
-        return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
412
-            'ee_edit_registration',
413
-            'registration_list_table_checkbox_input',
414
-            $item->ID()
415
-        )
416
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
417
-              . '<span class="ee-lock-icon"></span>'
418
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
419
-    }
420
-
421
-
422
-    /**
423
-     * @param EE_Registration $item
424
-     * @return string
425
-     * @throws EE_Error
426
-     * @throws InvalidArgumentException
427
-     * @throws InvalidDataTypeException
428
-     * @throws InvalidInterfaceException
429
-     * @throws ReflectionException
430
-     */
431
-    public function column__REG_ID(EE_Registration $item)
432
-    {
433
-        $attendee = $item->attendee();
434
-        $content  = $item->ID();
435
-        $content  .= '<div class="show-on-mobile-view-only">';
436
-        $content  .= '<br>';
437
-        $content  .= $attendee instanceof EE_Attendee
438
-            ? $attendee->full_name()
439
-            : '';
440
-        $content  .= '&nbsp;';
441
-        $content  .= sprintf(
442
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
443
-            $item->count(),
444
-            $item->group_size()
445
-        );
446
-        $content  .= '<br>';
447
-        $content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
448
-        $content  .= '</div>';
449
-        return $content;
450
-    }
451
-
452
-
453
-    /**
454
-     * @param EE_Registration $item
455
-     * @return string
456
-     * @throws EE_Error
457
-     * @throws InvalidArgumentException
458
-     * @throws InvalidDataTypeException
459
-     * @throws InvalidInterfaceException
460
-     * @throws ReflectionException
461
-     */
462
-    public function column__REG_date(EE_Registration $item)
463
-    {
464
-        $this->_set_related_details($item);
465
-        // Build row actions
466
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
467
-            [
468
-                'action' => 'view_transaction',
469
-                'TXN_ID' => $this->_transaction_details['id'],
470
-            ],
471
-            TXN_ADMIN_URL
472
-        );
473
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
474
-            'ee_read_transaction',
475
-            'espresso_transactions_view_transaction'
476
-        )
477
-            ? '<a class="ee-status-color-'
478
-              . $this->_transaction_details['status']
479
-              . '" href="'
480
-              . $view_lnk_url
481
-              . '" aria-label="'
482
-              . esc_attr($this->_transaction_details['title_attr'])
483
-              . '">'
484
-              . $item->get_i18n_datetime('REG_date')
485
-              . '</a>'
486
-            : $item->get_i18n_datetime('REG_date');
487
-        $view_link    .= '<br><span class="ee-status-text-small">'
488
-                         . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489
-                         . '</span>';
490
-        return $view_link;
491
-    }
492
-
493
-
494
-    /**
495
-     * @param EE_Registration $item
496
-     * @return string
497
-     * @throws EE_Error
498
-     * @throws InvalidArgumentException
499
-     * @throws InvalidDataTypeException
500
-     * @throws InvalidInterfaceException
501
-     * @throws ReflectionException
502
-     */
503
-    public function column_event_name(EE_Registration $item)
504
-    {
505
-        $this->_set_related_details($item);
506
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
507
-        $EVT_ID     = $item->event_ID();
508
-        $event_name = $item->event_name();
509
-        $event_name =
510
-            $event_name
511
-                ?: esc_html__("No Associated Event", 'event_espresso');
512
-        $event_name = wp_trim_words($event_name, 30, '...');
513
-        if ($EVT_ID) {
514
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
515
-                ['action' => 'edit', 'post' => $EVT_ID],
516
-                EVENTS_ADMIN_URL
517
-            );
518
-            $edit_event              =
519
-                EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520
-                    ? '<a class="ee-status-color-'
521
-                      . $this->_event_details['status']
522
-                      . '" href="'
523
-                      . $edit_event_url
524
-                      . '" aria-label="'
525
-                      . esc_attr($this->_event_details['title_attr'])
526
-                      . '">'
527
-                      . $event_name
528
-                      . '</a>'
529
-                    : $event_name;
530
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" aria-label="';
532
-            $actions['event_filter'] .= sprintf(
533
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534
-                $event_name
535
-            );
536
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
537
-        } else {
538
-            $edit_event              = $event_name;
539
-            $actions['event_filter'] = '';
540
-        }
541
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
542
-    }
543
-
544
-
545
-    /**
546
-     * @param EE_Registration $item
547
-     * @return string
548
-     * @throws EE_Error
549
-     * @throws InvalidArgumentException
550
-     * @throws InvalidDataTypeException
551
-     * @throws InvalidInterfaceException
552
-     * @throws ReflectionException
553
-     */
554
-    public function column_DTT_EVT_start(EE_Registration $item)
555
-    {
556
-        $datetime_strings = [];
557
-        $ticket           = $item->ticket();
558
-        if ($ticket instanceof EE_Ticket) {
559
-            $remove_defaults = ['default_where_conditions' => 'none'];
560
-            $datetimes       = $ticket->datetimes($remove_defaults);
561
-            foreach ($datetimes as $datetime) {
562
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
563
-            }
564
-            return $this->generateDisplayForDatetimes($datetime_strings);
565
-        }
566
-        return esc_html__('There is no ticket on this registration', 'event_espresso');
567
-    }
568
-
569
-
570
-    /**
571
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
572
-     *
573
-     * @param array $datetime_strings
574
-     * @return string
575
-     */
576
-    public function generateDisplayForDateTimes(array $datetime_strings)
577
-    {
578
-        $content       = '<div class="ee-registration-event-datetimes-container">';
579
-        $expand_toggle = count($datetime_strings) > 1
580
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
581
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582
-            : '';
583
-        // get first item for initial visibility
584
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
585
-        $content .= $expand_toggle;
586
-        if ($datetime_strings) {
587
-            $content .= '<div style="clear:both"></div>';
588
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
589
-            $content .= implode("<br />", $datetime_strings);
590
-            $content .= '</div>';
591
-        }
592
-        $content .= '</div>';
593
-        return $content;
594
-    }
595
-
596
-
597
-    /**
598
-     * @param EE_Registration $item
599
-     * @return string
600
-     * @throws EE_Error
601
-     * @throws InvalidArgumentException
602
-     * @throws InvalidDataTypeException
603
-     * @throws InvalidInterfaceException
604
-     * @throws ReflectionException
605
-     */
606
-    public function column_ATT_fname(EE_Registration $item)
607
-    {
608
-        $attendee      = $item->attendee();
609
-        $edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
610
-            [
611
-                'action'  => 'view_registration',
612
-                '_REG_ID' => $item->ID(),
613
-            ],
614
-            REG_ADMIN_URL
615
-        );
616
-        $attendee_name = $attendee instanceof EE_Attendee
617
-            ? $attendee->full_name()
618
-            : '';
619
-        $link          = EE_Registry::instance()->CAP->current_user_can(
620
-            'ee_read_registration',
621
-            'espresso_registrations_view_registration',
622
-            $item->ID()
623
-        )
624
-            ? '<a href="'
625
-              . $edit_lnk_url
626
-              . '" aria-label="'
627
-              . esc_attr__('View Registration Details', 'event_espresso')
628
-              . '">'
629
-              . $attendee_name
630
-              . '</a>'
631
-            : $attendee_name;
632
-        $link          .= $item->count() === 1
633
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634
-            : '';
635
-        $t             = $item->get_first_related('Transaction');
636
-        $payment_count = $t instanceof EE_Transaction
637
-            ? $t->count_related('Payment')
638
-            : 0;
639
-        // append group count to name
640
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641
-        // append reg_code
642
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643
-        // reg status text for accessibility
644
-        $link   .= '<br><span class="ee-status-text-small">'
645
-                   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646
-                   . '</span>';
647
-        $action = ['_REG_ID' => $item->ID()];
648
-        if (isset($this->_req_data['event_id'])) {
649
-            $action['event_id'] = $item->event_ID();
650
-        }
651
-        // trash/restore/delete actions
652
-        $actions = [];
653
-        if (
654
-            $this->_view !== 'trash'
655
-            && $payment_count === 0
656
-            && EE_Registry::instance()->CAP->current_user_can(
657
-                'ee_delete_registration',
658
-                'espresso_registrations_trash_registrations',
659
-                $item->ID()
660
-            )
661
-        ) {
662
-            $action['action'] = 'trash_registrations';
663
-            $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
664
-                $action,
665
-                REG_ADMIN_URL
666
-            );
667
-            $actions['trash'] = '<a href="'
668
-                                . $trash_lnk_url
669
-                                . '" aria-label="'
670
-                                . esc_attr__('Trash Registration', 'event_espresso')
671
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
672
-        } elseif ($this->_view === 'trash') {
673
-            // restore registration link
674
-            if (
675
-                EE_Registry::instance()->CAP->current_user_can(
676
-                    'ee_delete_registration',
677
-                    'espresso_registrations_restore_registrations',
678
-                    $item->ID()
679
-                )
680
-            ) {
681
-                $action['action']   = 'restore_registrations';
682
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
683
-                    $action,
684
-                    REG_ADMIN_URL
685
-                );
686
-                $actions['restore'] = '
17
+	/**
18
+	 * @var Registrations_Admin_Page
19
+	 */
20
+	protected $_admin_page;
21
+
22
+	/**
23
+	 * @var array
24
+	 */
25
+	private $_status;
26
+
27
+	/**
28
+	 * An array of transaction details for the related transaction to the registration being processed.
29
+	 * This is set via the _set_related_details method.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $_transaction_details = [];
34
+
35
+	/**
36
+	 * An array of event details for the related event to the registration being processed.
37
+	 * This is set via the _set_related_details method.
38
+	 *
39
+	 * @var array
40
+	 */
41
+	protected $_event_details = [];
42
+
43
+
44
+	/**
45
+	 * @param Registrations_Admin_Page $admin_page
46
+	 */
47
+	public function __construct(Registrations_Admin_Page $admin_page)
48
+	{
49
+		$req_data = $admin_page->get_request_data();
50
+		if (! empty($req_data['event_id'])) {
51
+			$extra_query_args = [];
52
+			foreach ($admin_page->get_views() as $view_details) {
53
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
54
+			}
55
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
56
+		}
57
+		parent::__construct($admin_page);
58
+		$this->_status = $this->_admin_page->get_registration_status_array();
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return void
64
+	 * @throws EE_Error
65
+	 */
66
+	protected function _setup_data()
67
+	{
68
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
69
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return void
75
+	 */
76
+	protected function _set_properties()
77
+	{
78
+		$return_url          = $this->getReturnUrl();
79
+		$this->_wp_list_args = [
80
+			'singular' => esc_html__('registration', 'event_espresso'),
81
+			'plural'   => esc_html__('registrations', 'event_espresso'),
82
+			'ajax'     => true,
83
+			'screen'   => $this->_admin_page->get_current_screen()->id,
84
+		];
85
+		$ID_column_name      = esc_html__('ID', 'event_espresso');
86
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
87
+		$ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
88
+		$ID_column_name      .= '</span> ';
89
+
90
+		$EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
91
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
92
+
93
+		if ($EVT_ID) {
94
+			$this->_columns        = [
95
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
96
+				'_REG_ID'          => $ID_column_name,
97
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
98
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
99
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
100
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
101
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
102
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
103
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
104
+				'actions'          => esc_html__('Actions', 'event_espresso'),
105
+			];
106
+		} else {
107
+			$this->_columns        = [
108
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
109
+				'_REG_ID'          => $ID_column_name,
110
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
111
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
112
+				'event_name'       => esc_html__('Event', 'event_espresso'),
113
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
114
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
115
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
116
+				'actions'          => esc_html__('Actions', 'event_espresso'),
117
+			];
118
+		}
119
+
120
+		$csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
121
+		if (! empty($csv_report)) {
122
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
123
+		}
124
+
125
+		$this->_primary_column   = '_REG_ID';
126
+		$this->_sortable_columns = [
127
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
128
+			/**
129
+			 * Allows users to change the default sort if they wish.
130
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
131
+			 * name.
132
+			 */
133
+			'ATT_fname'     => [
134
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
135
+				true,
136
+				$this,
137
+			]
138
+				? ['ATT_lname' => false]
139
+				: ['ATT_fname' => false],
140
+			'event_name'    => ['event_name' => false],
141
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
142
+			'_REG_ID'       => ['_REG_ID' => false],
143
+		];
144
+		$this->_hidden_columns   = [];
145
+	}
146
+
147
+
148
+	/**
149
+	 * This simply sets up the row class for the table rows.
150
+	 * Allows for easier overriding of child methods for setting up sorting.
151
+	 *
152
+	 * @param EE_Registration $item the current item
153
+	 * @return string
154
+	 */
155
+	protected function _get_row_class($item)
156
+	{
157
+		$class = parent::_get_row_class($item);
158
+		// add status class
159
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
160
+		if ($this->_has_checkbox_column) {
161
+			$class .= ' has-checkbox-column';
162
+		}
163
+		return $class;
164
+	}
165
+
166
+
167
+	/**
168
+	 * Set the $_transaction_details property if not set yet.
169
+	 *
170
+	 * @param EE_Registration $registration
171
+	 * @throws EE_Error
172
+	 * @throws InvalidArgumentException
173
+	 * @throws ReflectionException
174
+	 * @throws InvalidDataTypeException
175
+	 * @throws InvalidInterfaceException
176
+	 */
177
+	protected function _set_related_details(EE_Registration $registration)
178
+	{
179
+		$transaction                = $registration->get_first_related('Transaction');
180
+		$status                     = $transaction instanceof EE_Transaction
181
+			? $transaction->status_ID()
182
+			: EEM_Transaction::failed_status_code;
183
+		$this->_transaction_details = [
184
+			'transaction' => $transaction,
185
+			'status'      => $status,
186
+			'id'          => $transaction instanceof EE_Transaction
187
+				? $transaction->ID()
188
+				: 0,
189
+			'title_attr'  => sprintf(
190
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
191
+				EEH_Template::pretty_status($status, false, 'sentence')
192
+			),
193
+		];
194
+		try {
195
+			$event = $registration->event();
196
+		} catch (EntityNotFoundException $e) {
197
+			$event = null;
198
+		}
199
+		$status               = $event instanceof EE_Event
200
+			? $event->get_active_status()
201
+			: EE_Datetime::inactive;
202
+		$this->_event_details = [
203
+			'event'      => $event,
204
+			'status'     => $status,
205
+			'id'         => $event instanceof EE_Event
206
+				? $event->ID()
207
+				: 0,
208
+			'title_attr' => sprintf(
209
+				esc_html__('Edit Event (%s)', 'event_espresso'),
210
+				EEH_Template::pretty_status($status, false, 'sentence')
211
+			),
212
+		];
213
+	}
214
+
215
+
216
+	/**
217
+	 *    _get_table_filters
218
+	 *
219
+	 * @return array
220
+	 * @throws EE_Error
221
+	 * @throws ReflectionException
222
+	 */
223
+	protected function _get_table_filters()
224
+	{
225
+		$filters = [];
226
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
227
+		// methods.
228
+		$cur_date     = isset($this->_req_data['month_range'])
229
+			? $this->_req_data['month_range']
230
+			: '';
231
+		$cur_category = isset($this->_req_data['EVT_CAT'])
232
+			? $this->_req_data['EVT_CAT']
233
+			: -1;
234
+		$reg_status   = isset($this->_req_data['_reg_status'])
235
+			? $this->_req_data['_reg_status']
236
+			: '';
237
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
238
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
239
+		$status       = [];
240
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
241
+		foreach ($this->_status as $key => $value) {
242
+			$status[] = ['id' => $key, 'text' => $value];
243
+		}
244
+		if ($this->_view !== 'incomplete') {
245
+			$filters[] = EEH_Form_Fields::select_input(
246
+				'_reg_status',
247
+				$status,
248
+				isset($this->_req_data['_reg_status'])
249
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
250
+					: ''
251
+			);
252
+		}
253
+		if (isset($this->_req_data['event_id'])) {
254
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
255
+		}
256
+		return $filters;
257
+	}
258
+
259
+
260
+	/**
261
+	 * @return void
262
+	 * @throws EE_Error
263
+	 * @throws InvalidArgumentException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidInterfaceException
266
+	 */
267
+	protected function _add_view_counts()
268
+	{
269
+		$this->_views['all']['count']   = $this->_total_registrations();
270
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
271
+		$this->_views['today']['count'] = $this->_total_registrations_today();
272
+		if (
273
+			EE_Registry::instance()->CAP->current_user_can(
274
+				'ee_delete_registrations',
275
+				'espresso_registrations_trash_registrations'
276
+			)
277
+		) {
278
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
279
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
280
+		}
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param string $view
286
+	 * @return int
287
+	 * @throws EE_Error
288
+	 * @throws InvalidArgumentException
289
+	 * @throws InvalidDataTypeException
290
+	 * @throws InvalidInterfaceException
291
+	 */
292
+	protected function _total_registrations($view = '')
293
+	{
294
+		$_where = [];
295
+		$EVT_ID = isset($this->_req_data['event_id'])
296
+			? absint($this->_req_data['event_id'])
297
+			: false;
298
+		if ($EVT_ID) {
299
+			$_where['EVT_ID'] = $EVT_ID;
300
+		}
301
+		switch ($view) {
302
+			case 'trash':
303
+				return EEM_Registration::instance()->count_deleted([$_where]);
304
+			case 'incomplete':
305
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
306
+				break;
307
+			default:
308
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
309
+		}
310
+		return EEM_Registration::instance()->count([$_where]);
311
+	}
312
+
313
+
314
+	/**
315
+	 * @return int
316
+	 * @throws EE_Error
317
+	 * @throws InvalidArgumentException
318
+	 * @throws InvalidDataTypeException
319
+	 * @throws InvalidInterfaceException
320
+	 */
321
+	protected function _total_registrations_this_month()
322
+	{
323
+		$EVT_ID          = isset($this->_req_data['event_id'])
324
+			? absint($this->_req_data['event_id'])
325
+			: false;
326
+		$_where          = $EVT_ID
327
+			? ['EVT_ID' => $EVT_ID]
328
+			: [];
329
+		$this_year_r     = date('Y', current_time('timestamp'));
330
+		$time_start      = ' 00:00:00';
331
+		$time_end        = ' 23:59:59';
332
+		$this_month_r    = date('m', current_time('timestamp'));
333
+		$days_this_month = date('t', current_time('timestamp'));
334
+		// setup date query.
335
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
336
+			'REG_date',
337
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
338
+			'Y-m-d H:i:s'
339
+		);
340
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
341
+			'REG_date',
342
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
343
+			'Y-m-d H:i:s'
344
+		);
345
+		$_where['REG_date'] = [
346
+			'BETWEEN',
347
+			[
348
+				$beginning_string,
349
+				$end_string,
350
+			],
351
+		];
352
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
353
+		return EEM_Registration::instance()->count([$_where]);
354
+	}
355
+
356
+
357
+	/**
358
+	 * @return int
359
+	 * @throws EE_Error
360
+	 * @throws InvalidArgumentException
361
+	 * @throws InvalidDataTypeException
362
+	 * @throws InvalidInterfaceException
363
+	 */
364
+	protected function _total_registrations_today()
365
+	{
366
+		$EVT_ID             = isset($this->_req_data['event_id'])
367
+			? absint($this->_req_data['event_id'])
368
+			: false;
369
+		$_where             = $EVT_ID
370
+			? ['EVT_ID' => $EVT_ID]
371
+			: [];
372
+		$current_date       = date('Y-m-d', current_time('timestamp'));
373
+		$time_start         = ' 00:00:00';
374
+		$time_end           = ' 23:59:59';
375
+		$_where['REG_date'] = [
376
+			'BETWEEN',
377
+			[
378
+				EEM_Registration::instance()->convert_datetime_for_query(
379
+					'REG_date',
380
+					$current_date . $time_start,
381
+					'Y-m-d H:i:s'
382
+				),
383
+				EEM_Registration::instance()->convert_datetime_for_query(
384
+					'REG_date',
385
+					$current_date . $time_end,
386
+					'Y-m-d H:i:s'
387
+				),
388
+			],
389
+		];
390
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
391
+		return EEM_Registration::instance()->count([$_where]);
392
+	}
393
+
394
+
395
+	/**
396
+	 * @param EE_Registration $item
397
+	 * @return string
398
+	 * @throws EE_Error
399
+	 * @throws InvalidArgumentException
400
+	 * @throws InvalidDataTypeException
401
+	 * @throws InvalidInterfaceException
402
+	 * @throws ReflectionException
403
+	 */
404
+	public function column_cb($item)
405
+	{
406
+		/** checkbox/lock **/
407
+		$transaction   = $item->get_first_related('Transaction');
408
+		$payment_count = $transaction instanceof EE_Transaction
409
+			? $transaction->count_related('Payment')
410
+			: 0;
411
+		return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
412
+			'ee_edit_registration',
413
+			'registration_list_table_checkbox_input',
414
+			$item->ID()
415
+		)
416
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
417
+			  . '<span class="ee-lock-icon"></span>'
418
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
419
+	}
420
+
421
+
422
+	/**
423
+	 * @param EE_Registration $item
424
+	 * @return string
425
+	 * @throws EE_Error
426
+	 * @throws InvalidArgumentException
427
+	 * @throws InvalidDataTypeException
428
+	 * @throws InvalidInterfaceException
429
+	 * @throws ReflectionException
430
+	 */
431
+	public function column__REG_ID(EE_Registration $item)
432
+	{
433
+		$attendee = $item->attendee();
434
+		$content  = $item->ID();
435
+		$content  .= '<div class="show-on-mobile-view-only">';
436
+		$content  .= '<br>';
437
+		$content  .= $attendee instanceof EE_Attendee
438
+			? $attendee->full_name()
439
+			: '';
440
+		$content  .= '&nbsp;';
441
+		$content  .= sprintf(
442
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
443
+			$item->count(),
444
+			$item->group_size()
445
+		);
446
+		$content  .= '<br>';
447
+		$content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
448
+		$content  .= '</div>';
449
+		return $content;
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param EE_Registration $item
455
+	 * @return string
456
+	 * @throws EE_Error
457
+	 * @throws InvalidArgumentException
458
+	 * @throws InvalidDataTypeException
459
+	 * @throws InvalidInterfaceException
460
+	 * @throws ReflectionException
461
+	 */
462
+	public function column__REG_date(EE_Registration $item)
463
+	{
464
+		$this->_set_related_details($item);
465
+		// Build row actions
466
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
467
+			[
468
+				'action' => 'view_transaction',
469
+				'TXN_ID' => $this->_transaction_details['id'],
470
+			],
471
+			TXN_ADMIN_URL
472
+		);
473
+		$view_link    = EE_Registry::instance()->CAP->current_user_can(
474
+			'ee_read_transaction',
475
+			'espresso_transactions_view_transaction'
476
+		)
477
+			? '<a class="ee-status-color-'
478
+			  . $this->_transaction_details['status']
479
+			  . '" href="'
480
+			  . $view_lnk_url
481
+			  . '" aria-label="'
482
+			  . esc_attr($this->_transaction_details['title_attr'])
483
+			  . '">'
484
+			  . $item->get_i18n_datetime('REG_date')
485
+			  . '</a>'
486
+			: $item->get_i18n_datetime('REG_date');
487
+		$view_link    .= '<br><span class="ee-status-text-small">'
488
+						 . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489
+						 . '</span>';
490
+		return $view_link;
491
+	}
492
+
493
+
494
+	/**
495
+	 * @param EE_Registration $item
496
+	 * @return string
497
+	 * @throws EE_Error
498
+	 * @throws InvalidArgumentException
499
+	 * @throws InvalidDataTypeException
500
+	 * @throws InvalidInterfaceException
501
+	 * @throws ReflectionException
502
+	 */
503
+	public function column_event_name(EE_Registration $item)
504
+	{
505
+		$this->_set_related_details($item);
506
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
507
+		$EVT_ID     = $item->event_ID();
508
+		$event_name = $item->event_name();
509
+		$event_name =
510
+			$event_name
511
+				?: esc_html__("No Associated Event", 'event_espresso');
512
+		$event_name = wp_trim_words($event_name, 30, '...');
513
+		if ($EVT_ID) {
514
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
515
+				['action' => 'edit', 'post' => $EVT_ID],
516
+				EVENTS_ADMIN_URL
517
+			);
518
+			$edit_event              =
519
+				EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520
+					? '<a class="ee-status-color-'
521
+					  . $this->_event_details['status']
522
+					  . '" href="'
523
+					  . $edit_event_url
524
+					  . '" aria-label="'
525
+					  . esc_attr($this->_event_details['title_attr'])
526
+					  . '">'
527
+					  . $event_name
528
+					  . '</a>'
529
+					: $event_name;
530
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" aria-label="';
532
+			$actions['event_filter'] .= sprintf(
533
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534
+				$event_name
535
+			);
536
+			$actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
537
+		} else {
538
+			$edit_event              = $event_name;
539
+			$actions['event_filter'] = '';
540
+		}
541
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
542
+	}
543
+
544
+
545
+	/**
546
+	 * @param EE_Registration $item
547
+	 * @return string
548
+	 * @throws EE_Error
549
+	 * @throws InvalidArgumentException
550
+	 * @throws InvalidDataTypeException
551
+	 * @throws InvalidInterfaceException
552
+	 * @throws ReflectionException
553
+	 */
554
+	public function column_DTT_EVT_start(EE_Registration $item)
555
+	{
556
+		$datetime_strings = [];
557
+		$ticket           = $item->ticket();
558
+		if ($ticket instanceof EE_Ticket) {
559
+			$remove_defaults = ['default_where_conditions' => 'none'];
560
+			$datetimes       = $ticket->datetimes($remove_defaults);
561
+			foreach ($datetimes as $datetime) {
562
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
563
+			}
564
+			return $this->generateDisplayForDatetimes($datetime_strings);
565
+		}
566
+		return esc_html__('There is no ticket on this registration', 'event_espresso');
567
+	}
568
+
569
+
570
+	/**
571
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
572
+	 *
573
+	 * @param array $datetime_strings
574
+	 * @return string
575
+	 */
576
+	public function generateDisplayForDateTimes(array $datetime_strings)
577
+	{
578
+		$content       = '<div class="ee-registration-event-datetimes-container">';
579
+		$expand_toggle = count($datetime_strings) > 1
580
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
581
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582
+			: '';
583
+		// get first item for initial visibility
584
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
585
+		$content .= $expand_toggle;
586
+		if ($datetime_strings) {
587
+			$content .= '<div style="clear:both"></div>';
588
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
589
+			$content .= implode("<br />", $datetime_strings);
590
+			$content .= '</div>';
591
+		}
592
+		$content .= '</div>';
593
+		return $content;
594
+	}
595
+
596
+
597
+	/**
598
+	 * @param EE_Registration $item
599
+	 * @return string
600
+	 * @throws EE_Error
601
+	 * @throws InvalidArgumentException
602
+	 * @throws InvalidDataTypeException
603
+	 * @throws InvalidInterfaceException
604
+	 * @throws ReflectionException
605
+	 */
606
+	public function column_ATT_fname(EE_Registration $item)
607
+	{
608
+		$attendee      = $item->attendee();
609
+		$edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
610
+			[
611
+				'action'  => 'view_registration',
612
+				'_REG_ID' => $item->ID(),
613
+			],
614
+			REG_ADMIN_URL
615
+		);
616
+		$attendee_name = $attendee instanceof EE_Attendee
617
+			? $attendee->full_name()
618
+			: '';
619
+		$link          = EE_Registry::instance()->CAP->current_user_can(
620
+			'ee_read_registration',
621
+			'espresso_registrations_view_registration',
622
+			$item->ID()
623
+		)
624
+			? '<a href="'
625
+			  . $edit_lnk_url
626
+			  . '" aria-label="'
627
+			  . esc_attr__('View Registration Details', 'event_espresso')
628
+			  . '">'
629
+			  . $attendee_name
630
+			  . '</a>'
631
+			: $attendee_name;
632
+		$link          .= $item->count() === 1
633
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634
+			: '';
635
+		$t             = $item->get_first_related('Transaction');
636
+		$payment_count = $t instanceof EE_Transaction
637
+			? $t->count_related('Payment')
638
+			: 0;
639
+		// append group count to name
640
+		$link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641
+		// append reg_code
642
+		$link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643
+		// reg status text for accessibility
644
+		$link   .= '<br><span class="ee-status-text-small">'
645
+				   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646
+				   . '</span>';
647
+		$action = ['_REG_ID' => $item->ID()];
648
+		if (isset($this->_req_data['event_id'])) {
649
+			$action['event_id'] = $item->event_ID();
650
+		}
651
+		// trash/restore/delete actions
652
+		$actions = [];
653
+		if (
654
+			$this->_view !== 'trash'
655
+			&& $payment_count === 0
656
+			&& EE_Registry::instance()->CAP->current_user_can(
657
+				'ee_delete_registration',
658
+				'espresso_registrations_trash_registrations',
659
+				$item->ID()
660
+			)
661
+		) {
662
+			$action['action'] = 'trash_registrations';
663
+			$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
664
+				$action,
665
+				REG_ADMIN_URL
666
+			);
667
+			$actions['trash'] = '<a href="'
668
+								. $trash_lnk_url
669
+								. '" aria-label="'
670
+								. esc_attr__('Trash Registration', 'event_espresso')
671
+								. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
672
+		} elseif ($this->_view === 'trash') {
673
+			// restore registration link
674
+			if (
675
+				EE_Registry::instance()->CAP->current_user_can(
676
+					'ee_delete_registration',
677
+					'espresso_registrations_restore_registrations',
678
+					$item->ID()
679
+				)
680
+			) {
681
+				$action['action']   = 'restore_registrations';
682
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
683
+					$action,
684
+					REG_ADMIN_URL
685
+				);
686
+				$actions['restore'] = '
687 687
                     <a href="' . $restore_lnk_url . '" 
688 688
                        aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
689 689
                    >
690 690
                        ' . esc_html__('Restore', 'event_espresso') . '
691 691
                    </a>';
692
-            }
693
-            if (
694
-                EE_Registry::instance()->CAP->current_user_can(
695
-                    'ee_delete_registration',
696
-                    'espresso_registrations_ee_delete_registrations',
697
-                    $item->ID()
698
-                )
699
-            ) {
700
-                $action['action']  = 'delete_registrations';
701
-                $delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
702
-                    $action,
703
-                    REG_ADMIN_URL
704
-                );
705
-                $actions['delete'] = '
692
+			}
693
+			if (
694
+				EE_Registry::instance()->CAP->current_user_can(
695
+					'ee_delete_registration',
696
+					'espresso_registrations_ee_delete_registrations',
697
+					$item->ID()
698
+				)
699
+			) {
700
+				$action['action']  = 'delete_registrations';
701
+				$delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
702
+					$action,
703
+					REG_ADMIN_URL
704
+				);
705
+				$actions['delete'] = '
706 706
                     <a href="' . $delete_lnk_url . '" 
707 707
                        aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
708 708
                     >
709 709
                         ' . esc_html__('Delete', 'event_espresso') . '
710 710
                     </a>';
711
-            }
712
-        }
713
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
-    }
715
-
716
-
717
-    /**
718
-     * @param EE_Registration $item
719
-     * @return string
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws InvalidDataTypeException
723
-     * @throws InvalidInterfaceException
724
-     * @throws ReflectionException
725
-     */
726
-    public function column_ATT_email(EE_Registration $item)
727
-    {
728
-        $attendee = $item->get_first_related('Attendee');
729
-        return ! $attendee instanceof EE_Attendee
730
-            ? esc_html__('No attached contact record.', 'event_espresso')
731
-            : $attendee->email();
732
-    }
733
-
734
-
735
-    /**
736
-     * @param EE_Registration $item
737
-     * @return string
738
-     */
739
-    public function column__REG_count(EE_Registration $item)
740
-    {
741
-        return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
742
-    }
743
-
744
-
745
-    /**
746
-     * @param EE_Registration $item
747
-     * @return string
748
-     * @throws EE_Error
749
-     * @throws ReflectionException
750
-     */
751
-    public function column_PRC_amount(EE_Registration $item)
752
-    {
753
-        $ticket   = $item->ticket();
754
-        $req_data = $this->_admin_page->get_request_data();
755
-        $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
757
-            : '';
758
-        if ($item->final_price() > 0) {
759
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
760
-        } else {
761
-            // free event
762
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
763
-                        . esc_html__('free', 'event_espresso')
764
-                        . '</span>';
765
-        }
766
-        return $content;
767
-    }
768
-
769
-
770
-    /**
771
-     * @param EE_Registration $item
772
-     * @return string
773
-     * @throws EE_Error
774
-     * @throws ReflectionException
775
-     */
776
-    public function column__REG_final_price(EE_Registration $item)
777
-    {
778
-        $ticket   = $item->ticket();
779
-        $req_data = $this->_admin_page->get_request_data();
780
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781
-            ? ''
782
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
-        return $content;
785
-    }
786
-
787
-
788
-    /**
789
-     * @param EE_Registration $item
790
-     * @return string
791
-     * @throws EE_Error
792
-     */
793
-    public function column__REG_paid(EE_Registration $item)
794
-    {
795
-        $payment_method      = $item->payment_method();
796
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
797
-            ? $payment_method->admin_name()
798
-            : esc_html__('Unknown', 'event_espresso');
799
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
800
-        if ($item->paid() > 0) {
801
-            $content .= '<br><span class="ee-status-text-small">'
802
-                        . sprintf(
803
-                            esc_html__('...via %s', 'event_espresso'),
804
-                            $payment_method_name
805
-                        )
806
-                        . '</span>';
807
-        }
808
-        return $content;
809
-    }
810
-
811
-
812
-    /**
813
-     * @param EE_Registration $item
814
-     * @return string
815
-     * @throws EE_Error
816
-     * @throws EntityNotFoundException
817
-     * @throws InvalidArgumentException
818
-     * @throws InvalidDataTypeException
819
-     * @throws InvalidInterfaceException
820
-     * @throws ReflectionException
821
-     */
822
-    public function column_TXN_total(EE_Registration $item)
823
-    {
824
-        if ($item->transaction()) {
825
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
826
-                [
827
-                    'action' => 'view_transaction',
828
-                    'TXN_ID' => $item->transaction_ID(),
829
-                ],
830
-                TXN_ADMIN_URL
831
-            );
832
-            return EE_Registry::instance()->CAP->current_user_can(
833
-                'ee_read_transaction',
834
-                'espresso_transactions_view_transaction',
835
-                $item->transaction_ID()
836
-            )
837
-                ? '<span class="reg-pad-rght">
711
+			}
712
+		}
713
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
+	}
715
+
716
+
717
+	/**
718
+	 * @param EE_Registration $item
719
+	 * @return string
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws InvalidDataTypeException
723
+	 * @throws InvalidInterfaceException
724
+	 * @throws ReflectionException
725
+	 */
726
+	public function column_ATT_email(EE_Registration $item)
727
+	{
728
+		$attendee = $item->get_first_related('Attendee');
729
+		return ! $attendee instanceof EE_Attendee
730
+			? esc_html__('No attached contact record.', 'event_espresso')
731
+			: $attendee->email();
732
+	}
733
+
734
+
735
+	/**
736
+	 * @param EE_Registration $item
737
+	 * @return string
738
+	 */
739
+	public function column__REG_count(EE_Registration $item)
740
+	{
741
+		return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
742
+	}
743
+
744
+
745
+	/**
746
+	 * @param EE_Registration $item
747
+	 * @return string
748
+	 * @throws EE_Error
749
+	 * @throws ReflectionException
750
+	 */
751
+	public function column_PRC_amount(EE_Registration $item)
752
+	{
753
+		$ticket   = $item->ticket();
754
+		$req_data = $this->_admin_page->get_request_data();
755
+		$content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
+			? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
757
+			: '';
758
+		if ($item->final_price() > 0) {
759
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
760
+		} else {
761
+			// free event
762
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
763
+						. esc_html__('free', 'event_espresso')
764
+						. '</span>';
765
+		}
766
+		return $content;
767
+	}
768
+
769
+
770
+	/**
771
+	 * @param EE_Registration $item
772
+	 * @return string
773
+	 * @throws EE_Error
774
+	 * @throws ReflectionException
775
+	 */
776
+	public function column__REG_final_price(EE_Registration $item)
777
+	{
778
+		$ticket   = $item->ticket();
779
+		$req_data = $this->_admin_page->get_request_data();
780
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781
+			? ''
782
+			: '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
+		$content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
+		return $content;
785
+	}
786
+
787
+
788
+	/**
789
+	 * @param EE_Registration $item
790
+	 * @return string
791
+	 * @throws EE_Error
792
+	 */
793
+	public function column__REG_paid(EE_Registration $item)
794
+	{
795
+		$payment_method      = $item->payment_method();
796
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
797
+			? $payment_method->admin_name()
798
+			: esc_html__('Unknown', 'event_espresso');
799
+		$content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
800
+		if ($item->paid() > 0) {
801
+			$content .= '<br><span class="ee-status-text-small">'
802
+						. sprintf(
803
+							esc_html__('...via %s', 'event_espresso'),
804
+							$payment_method_name
805
+						)
806
+						. '</span>';
807
+		}
808
+		return $content;
809
+	}
810
+
811
+
812
+	/**
813
+	 * @param EE_Registration $item
814
+	 * @return string
815
+	 * @throws EE_Error
816
+	 * @throws EntityNotFoundException
817
+	 * @throws InvalidArgumentException
818
+	 * @throws InvalidDataTypeException
819
+	 * @throws InvalidInterfaceException
820
+	 * @throws ReflectionException
821
+	 */
822
+	public function column_TXN_total(EE_Registration $item)
823
+	{
824
+		if ($item->transaction()) {
825
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
826
+				[
827
+					'action' => 'view_transaction',
828
+					'TXN_ID' => $item->transaction_ID(),
829
+				],
830
+				TXN_ADMIN_URL
831
+			);
832
+			return EE_Registry::instance()->CAP->current_user_can(
833
+				'ee_read_transaction',
834
+				'espresso_transactions_view_transaction',
835
+				$item->transaction_ID()
836
+			)
837
+				? '<span class="reg-pad-rght">
838 838
                     <a class="status-' . $item->transaction()->status_ID() . '" 
839 839
                        href="' . $view_txn_lnk_url . '"  
840 840
                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
@@ -842,45 +842,45 @@  discard block
 block discarded – undo
842 842
                         ' . $item->transaction()->pretty_total() . '
843 843
                     </a>
844 844
                   </span>'
845
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
846
-        } else {
847
-            return esc_html__("None", "event_espresso");
848
-        }
849
-    }
850
-
851
-
852
-    /**
853
-     * @param EE_Registration $item
854
-     * @return string
855
-     * @throws EE_Error
856
-     * @throws EntityNotFoundException
857
-     * @throws InvalidArgumentException
858
-     * @throws InvalidDataTypeException
859
-     * @throws InvalidInterfaceException
860
-     * @throws ReflectionException
861
-     */
862
-    public function column_TXN_paid(EE_Registration $item)
863
-    {
864
-        if ($item->count() === 1) {
865
-            $transaction = $item->transaction()
866
-                ? $item->transaction()
867
-                : EE_Transaction::new_instance();
868
-            if ($transaction->paid() >= $transaction->total()) {
869
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
870
-            } else {
871
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
872
-                    [
873
-                        'action' => 'view_transaction',
874
-                        'TXN_ID' => $item->transaction_ID(),
875
-                    ],
876
-                    TXN_ADMIN_URL
877
-                );
878
-                return EE_Registry::instance()->CAP->current_user_can(
879
-                    'ee_read_transaction',
880
-                    'espresso_transactions_view_transaction',
881
-                    $item->transaction_ID()
882
-                )
883
-                    ? '<span class="reg-pad-rght">
845
+				: '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
846
+		} else {
847
+			return esc_html__("None", "event_espresso");
848
+		}
849
+	}
850
+
851
+
852
+	/**
853
+	 * @param EE_Registration $item
854
+	 * @return string
855
+	 * @throws EE_Error
856
+	 * @throws EntityNotFoundException
857
+	 * @throws InvalidArgumentException
858
+	 * @throws InvalidDataTypeException
859
+	 * @throws InvalidInterfaceException
860
+	 * @throws ReflectionException
861
+	 */
862
+	public function column_TXN_paid(EE_Registration $item)
863
+	{
864
+		if ($item->count() === 1) {
865
+			$transaction = $item->transaction()
866
+				? $item->transaction()
867
+				: EE_Transaction::new_instance();
868
+			if ($transaction->paid() >= $transaction->total()) {
869
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
870
+			} else {
871
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
872
+					[
873
+						'action' => 'view_transaction',
874
+						'TXN_ID' => $item->transaction_ID(),
875
+					],
876
+					TXN_ADMIN_URL
877
+				);
878
+				return EE_Registry::instance()->CAP->current_user_can(
879
+					'ee_read_transaction',
880
+					'espresso_transactions_view_transaction',
881
+					$item->transaction_ID()
882
+				)
883
+					? '<span class="reg-pad-rght">
884 884
                         <a class="status-' . $transaction->status_ID() . '" 
885 885
                            href="' . $view_txn_lnk_url . '"  
886 886
                            aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
@@ -888,46 +888,46 @@  discard block
 block discarded – undo
888 888
                             ' . $item->transaction()->pretty_paid() . '
889 889
                         </a>
890 890
                        <span>'
891
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
892
-            }
893
-        }
894
-        return '&nbsp;';
895
-    }
896
-
897
-
898
-    /**
899
-     * column_actions
900
-     *
901
-     * @param EE_Registration $item
902
-     * @return string
903
-     * @throws EE_Error
904
-     * @throws InvalidArgumentException
905
-     * @throws InvalidDataTypeException
906
-     * @throws InvalidInterfaceException
907
-     * @throws ReflectionException
908
-     */
909
-    public function column_actions(EE_Registration $item)
910
-    {
911
-        $actions  = [];
912
-        $attendee = $item->attendee();
913
-        $this->_set_related_details($item);
914
-
915
-        // Build row actions
916
-        if (
917
-            EE_Registry::instance()->CAP->current_user_can(
918
-                'ee_read_registration',
919
-                'espresso_registrations_view_registration',
920
-                $item->ID()
921
-            )
922
-        ) {
923
-            $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
924
-                [
925
-                    'action'  => 'view_registration',
926
-                    '_REG_ID' => $item->ID(),
927
-                ],
928
-                REG_ADMIN_URL
929
-            );
930
-            $actions['view_lnk'] = '
891
+					: '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
892
+			}
893
+		}
894
+		return '&nbsp;';
895
+	}
896
+
897
+
898
+	/**
899
+	 * column_actions
900
+	 *
901
+	 * @param EE_Registration $item
902
+	 * @return string
903
+	 * @throws EE_Error
904
+	 * @throws InvalidArgumentException
905
+	 * @throws InvalidDataTypeException
906
+	 * @throws InvalidInterfaceException
907
+	 * @throws ReflectionException
908
+	 */
909
+	public function column_actions(EE_Registration $item)
910
+	{
911
+		$actions  = [];
912
+		$attendee = $item->attendee();
913
+		$this->_set_related_details($item);
914
+
915
+		// Build row actions
916
+		if (
917
+			EE_Registry::instance()->CAP->current_user_can(
918
+				'ee_read_registration',
919
+				'espresso_registrations_view_registration',
920
+				$item->ID()
921
+			)
922
+		) {
923
+			$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
924
+				[
925
+					'action'  => 'view_registration',
926
+					'_REG_ID' => $item->ID(),
927
+				],
928
+				REG_ADMIN_URL
929
+			);
930
+			$actions['view_lnk'] = '
931 931
             <li>
932 932
                 <a href="' . $view_lnk_url . '" 
933 933
                    aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" 
@@ -936,23 +936,23 @@  discard block
 block discarded – undo
936 936
 				    <div class="dashicons dashicons-clipboard"></div>
937 937
 			    </a>
938 938
 			</li>';
939
-        }
940
-
941
-        if (
942
-            $attendee instanceof EE_Attendee
943
-            && EE_Registry::instance()->CAP->current_user_can(
944
-                'ee_edit_contacts',
945
-                'espresso_registrations_edit_attendee'
946
-            )
947
-        ) {
948
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
949
-                [
950
-                    'action' => 'edit_attendee',
951
-                    'post'   => $item->attendee_ID(),
952
-                ],
953
-                REG_ADMIN_URL
954
-            );
955
-            $actions['edit_lnk'] = '
939
+		}
940
+
941
+		if (
942
+			$attendee instanceof EE_Attendee
943
+			&& EE_Registry::instance()->CAP->current_user_can(
944
+				'ee_edit_contacts',
945
+				'espresso_registrations_edit_attendee'
946
+			)
947
+		) {
948
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
949
+				[
950
+					'action' => 'edit_attendee',
951
+					'post'   => $item->attendee_ID(),
952
+				],
953
+				REG_ADMIN_URL
954
+			);
955
+			$actions['edit_lnk'] = '
956 956
 			<li>
957 957
 			    <a href="' . $edit_lnk_url . '" 
958 958
                    aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" 
@@ -961,25 +961,25 @@  discard block
 block discarded – undo
961 961
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
962 962
                 </a>
963 963
 			</li>';
964
-        }
965
-
966
-        if (
967
-            $attendee instanceof EE_Attendee
968
-            && EE_Registry::instance()->CAP->current_user_can(
969
-                'ee_send_message',
970
-                'espresso_registrations_resend_registration',
971
-                $item->ID()
972
-            )
973
-        ) {
974
-            $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
975
-                [
976
-                    'action'  => 'resend_registration',
977
-                    '_REG_ID' => $item->ID(),
978
-                ],
979
-                REG_ADMIN_URL,
980
-                true
981
-            );
982
-            $actions['resend_reg_lnk'] = '
964
+		}
965
+
966
+		if (
967
+			$attendee instanceof EE_Attendee
968
+			&& EE_Registry::instance()->CAP->current_user_can(
969
+				'ee_send_message',
970
+				'espresso_registrations_resend_registration',
971
+				$item->ID()
972
+			)
973
+		) {
974
+			$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
975
+				[
976
+					'action'  => 'resend_registration',
977
+					'_REG_ID' => $item->ID(),
978
+				],
979
+				REG_ADMIN_URL,
980
+				true
981
+			);
982
+			$actions['resend_reg_lnk'] = '
983 983
 			<li>
984 984
 			    <a href="' . $resend_reg_lnk_url . '" 
985 985
 			       aria-label="' . esc_attr__('Resend Registration Details', 'event_espresso') . '" 
@@ -988,23 +988,23 @@  discard block
 block discarded – undo
988 988
 			        <div class="dashicons dashicons-email-alt"></div>
989 989
 			    </a>
990 990
             </li>';
991
-        }
992
-
993
-        if (
994
-            EE_Registry::instance()->CAP->current_user_can(
995
-                'ee_read_transaction',
996
-                'espresso_transactions_view_transaction',
997
-                $this->_transaction_details['id']
998
-            )
999
-        ) {
1000
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1001
-                [
1002
-                    'action' => 'view_transaction',
1003
-                    'TXN_ID' => $this->_transaction_details['id'],
1004
-                ],
1005
-                TXN_ADMIN_URL
1006
-            );
1007
-            $actions['view_txn_lnk'] = '
991
+		}
992
+
993
+		if (
994
+			EE_Registry::instance()->CAP->current_user_can(
995
+				'ee_read_transaction',
996
+				'espresso_transactions_view_transaction',
997
+				$this->_transaction_details['id']
998
+			)
999
+		) {
1000
+			$view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1001
+				[
1002
+					'action' => 'view_transaction',
1003
+					'TXN_ID' => $this->_transaction_details['id'],
1004
+				],
1005
+				TXN_ADMIN_URL
1006
+			);
1007
+			$actions['view_txn_lnk'] = '
1008 1008
 			<li>
1009 1009
                 <a class="ee-status-color-' . $this->_transaction_details['status'] . ' tiny-text" 
1010 1010
                    href="' . $view_txn_lnk_url . '"  
@@ -1013,15 +1013,15 @@  discard block
 block discarded – undo
1013 1013
                     <div class="dashicons dashicons-cart"></div>
1014 1014
                 </a>
1015 1015
 			</li>';
1016
-        }
1017
-
1018
-        // only show invoice link if message type is active.
1019
-        if (
1020
-            $attendee instanceof EE_Attendee
1021
-            && $item->is_primary_registrant()
1022
-            && EEH_MSG_Template::is_mt_active('invoice')
1023
-        ) {
1024
-            $actions['dl_invoice_lnk'] = '
1016
+		}
1017
+
1018
+		// only show invoice link if message type is active.
1019
+		if (
1020
+			$attendee instanceof EE_Attendee
1021
+			&& $item->is_primary_registrant()
1022
+			&& EEH_MSG_Template::is_mt_active('invoice')
1023
+		) {
1024
+			$actions['dl_invoice_lnk'] = '
1025 1025
             <li>
1026 1026
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '" 
1027 1027
                    class="tiny-text"
@@ -1031,23 +1031,23 @@  discard block
 block discarded – undo
1031 1031
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1032 1032
                 </a>
1033 1033
             </li>';
1034
-        }
1034
+		}
1035 1035
 
1036
-        // message list table link (filtered by REG_ID
1037
-        if (
1038
-            EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1039
-        ) {
1040
-            $actions['filtered_messages_link'] = '
1036
+		// message list table link (filtered by REG_ID
1037
+		if (
1038
+			EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1039
+		) {
1040
+			$actions['filtered_messages_link'] = '
1041 1041
             <li>
1042 1042
                 ' . EEH_MSG_Template::get_message_action_link(
1043
-                'see_notifications_for',
1044
-                null,
1045
-                ['_REG_ID' => $item->ID()]
1046
-            ) . '
1043
+				'see_notifications_for',
1044
+				null,
1045
+				['_REG_ID' => $item->ID()]
1046
+			) . '
1047 1047
             </li>';
1048
-        }
1048
+		}
1049 1049
 
1050
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1051
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1052
-    }
1050
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1051
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1052
+	}
1053 1053
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
     public function __construct(Registrations_Admin_Page $admin_page)
48 48
     {
49 49
         $req_data = $admin_page->get_request_data();
50
-        if (! empty($req_data['event_id'])) {
50
+        if ( ! empty($req_data['event_id'])) {
51 51
             $extra_query_args = [];
52 52
             foreach ($admin_page->get_views() as $view_details) {
53
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
53
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
54 54
             }
55 55
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
56 56
         }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'ajax'     => true,
83 83
             'screen'   => $this->_admin_page->get_current_screen()->id,
84 84
         ];
85
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
85
+        $ID_column_name = esc_html__('ID', 'event_espresso');
86 86
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
87 87
         $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
88 88
         $ID_column_name      .= '</span> ';
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
92 92
 
93 93
         if ($EVT_ID) {
94
-            $this->_columns        = [
94
+            $this->_columns = [
95 95
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
96 96
                 '_REG_ID'          => $ID_column_name,
97 97
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 'actions'          => esc_html__('Actions', 'event_espresso'),
105 105
             ];
106 106
         } else {
107
-            $this->_columns        = [
107
+            $this->_columns = [
108 108
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
109 109
                 '_REG_ID'          => $ID_column_name,
110 110
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
121
-        if (! empty($csv_report)) {
121
+        if ( ! empty($csv_report)) {
122 122
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
123 123
         }
124 124
 
125 125
         $this->_primary_column   = '_REG_ID';
126 126
         $this->_sortable_columns = [
127
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
127
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
128 128
             /**
129 129
              * Allows users to change the default sort if they wish.
130 130
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
142 142
             '_REG_ID'       => ['_REG_ID' => false],
143 143
         ];
144
-        $this->_hidden_columns   = [];
144
+        $this->_hidden_columns = [];
145 145
     }
146 146
 
147 147
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     {
157 157
         $class = parent::_get_row_class($item);
158 158
         // add status class
159
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
159
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
160 160
         if ($this->_has_checkbox_column) {
161 161
             $class .= ' has-checkbox-column';
162 162
         }
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
         $this_month_r    = date('m', current_time('timestamp'));
333 333
         $days_this_month = date('t', current_time('timestamp'));
334 334
         // setup date query.
335
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
335
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
336 336
             'REG_date',
337
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
337
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
338 338
             'Y-m-d H:i:s'
339 339
         );
340
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
340
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
341 341
             'REG_date',
342
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
342
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
343 343
             'Y-m-d H:i:s'
344 344
         );
345 345
         $_where['REG_date'] = [
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 $end_string,
350 350
             ],
351 351
         ];
352
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
352
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
353 353
         return EEM_Registration::instance()->count([$_where]);
354 354
     }
355 355
 
@@ -377,17 +377,17 @@  discard block
 block discarded – undo
377 377
             [
378 378
                 EEM_Registration::instance()->convert_datetime_for_query(
379 379
                     'REG_date',
380
-                    $current_date . $time_start,
380
+                    $current_date.$time_start,
381 381
                     'Y-m-d H:i:s'
382 382
                 ),
383 383
                 EEM_Registration::instance()->convert_datetime_for_query(
384 384
                     'REG_date',
385
-                    $current_date . $time_end,
385
+                    $current_date.$time_end,
386 386
                     'Y-m-d H:i:s'
387 387
                 ),
388 388
             ],
389 389
         ];
390
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
390
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
391 391
         return EEM_Registration::instance()->count([$_where]);
392 392
     }
393 393
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
             ],
471 471
             TXN_ADMIN_URL
472 472
         );
473
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
473
+        $view_link = EE_Registry::instance()->CAP->current_user_can(
474 474
             'ee_read_transaction',
475 475
             'espresso_transactions_view_transaction'
476 476
         )
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
               . $item->get_i18n_datetime('REG_date')
485 485
               . '</a>'
486 486
             : $item->get_i18n_datetime('REG_date');
487
-        $view_link    .= '<br><span class="ee-status-text-small">'
487
+        $view_link .= '<br><span class="ee-status-text-small">'
488 488
                          . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489 489
                          . '</span>';
490 490
         return $view_link;
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
                 ?: esc_html__("No Associated Event", 'event_espresso');
512 512
         $event_name = wp_trim_words($event_name, 30, '...');
513 513
         if ($EVT_ID) {
514
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
514
+            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
515 515
                 ['action' => 'edit', 'post' => $EVT_ID],
516 516
                 EVENTS_ADMIN_URL
517 517
             );
518
-            $edit_event              =
518
+            $edit_event =
519 519
                 EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520 520
                     ? '<a class="ee-status-color-'
521 521
                       . $this->_event_details['status']
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
                       . '</a>'
529 529
                     : $event_name;
530 530
             $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" aria-label="';
531
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" aria-label="';
532 532
             $actions['event_filter'] .= sprintf(
533 533
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534 534
                 $event_name
535 535
             );
536
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
536
+            $actions['event_filter'] .= '">'.esc_html__('View Registrations', 'event_espresso').'</a>';
537 537
         } else {
538 538
             $edit_event              = $event_name;
539 539
             $actions['event_filter'] = '';
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
     {
578 578
         $content       = '<div class="ee-registration-event-datetimes-container">';
579 579
         $expand_toggle = count($datetime_strings) > 1
580
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
580
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
581 581
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582 582
             : '';
583 583
         // get first item for initial visibility
584
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
584
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
585 585
         $content .= $expand_toggle;
586 586
         if ($datetime_strings) {
587 587
             $content .= '<div style="clear:both"></div>';
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
               . $attendee_name
630 630
               . '</a>'
631 631
             : $attendee_name;
632
-        $link          .= $item->count() === 1
632
+        $link .= $item->count() === 1
633 633
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634 634
             : '';
635 635
         $t             = $item->get_first_related('Transaction');
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
             ? $t->count_related('Payment')
638 638
             : 0;
639 639
         // append group count to name
640
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
640
+        $link .= '&nbsp;'.sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641 641
         // append reg_code
642
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
642
+        $link .= '<br>'.sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643 643
         // reg status text for accessibility
644
-        $link   .= '<br><span class="ee-status-text-small">'
644
+        $link .= '<br><span class="ee-status-text-small">'
645 645
                    . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646 646
                    . '</span>';
647 647
         $action = ['_REG_ID' => $item->ID()];
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                                 . $trash_lnk_url
669 669
                                 . '" aria-label="'
670 670
                                 . esc_attr__('Trash Registration', 'event_espresso')
671
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
671
+                                . '">'.esc_html__('Trash', 'event_espresso').'</a>';
672 672
         } elseif ($this->_view === 'trash') {
673 673
             // restore registration link
674 674
             if (
@@ -684,10 +684,10 @@  discard block
 block discarded – undo
684 684
                     REG_ADMIN_URL
685 685
                 );
686 686
                 $actions['restore'] = '
687
-                    <a href="' . $restore_lnk_url . '" 
688
-                       aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
687
+                    <a href="' . $restore_lnk_url.'" 
688
+                       aria-label="' . esc_attr__('Restore Registration', 'event_espresso').'"
689 689
                    >
690
-                       ' . esc_html__('Restore', 'event_espresso') . '
690
+                       ' . esc_html__('Restore', 'event_espresso').'
691 691
                    </a>';
692 692
             }
693 693
             if (
@@ -703,10 +703,10 @@  discard block
 block discarded – undo
703 703
                     REG_ADMIN_URL
704 704
                 );
705 705
                 $actions['delete'] = '
706
-                    <a href="' . $delete_lnk_url . '" 
707
-                       aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
706
+                    <a href="' . $delete_lnk_url.'" 
707
+                       aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso').'"
708 708
                     >
709
-                        ' . esc_html__('Delete', 'event_espresso') . '
709
+                        ' . esc_html__('Delete', 'event_espresso').'
710 710
                     </a>';
711 711
             }
712 712
         }
@@ -753,10 +753,10 @@  discard block
 block discarded – undo
753 753
         $ticket   = $item->ticket();
754 754
         $req_data = $this->_admin_page->get_request_data();
755 755
         $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
756
+            ? '<span class="TKT_name">'.$ticket->name().'</span><br />'
757 757
             : '';
758 758
         if ($item->final_price() > 0) {
759
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
759
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
760 760
         } else {
761 761
             // free event
762 762
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
         $req_data = $this->_admin_page->get_request_data();
780 780
         $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781 781
             ? ''
782
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
782
+            : '<span class="TKT_name">'.$ticket->name().'</span><br />';
783
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
784 784
         return $content;
785 785
     }
786 786
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         $payment_method_name = $payment_method instanceof EE_Payment_Method
797 797
             ? $payment_method->admin_name()
798 798
             : esc_html__('Unknown', 'event_espresso');
799
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
799
+        $content             = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
800 800
         if ($item->paid() > 0) {
801 801
             $content .= '<br><span class="ee-status-text-small">'
802 802
                         . sprintf(
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
                 $item->transaction_ID()
836 836
             )
837 837
                 ? '<span class="reg-pad-rght">
838
-                    <a class="status-' . $item->transaction()->status_ID() . '" 
839
-                       href="' . $view_txn_lnk_url . '"  
840
-                       aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
838
+                    <a class="status-' . $item->transaction()->status_ID().'" 
839
+                       href="' . $view_txn_lnk_url.'"  
840
+                       aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
841 841
                     >
842
-                        ' . $item->transaction()->pretty_total() . '
842
+                        ' . $item->transaction()->pretty_total().'
843 843
                     </a>
844 844
                   </span>'
845
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
845
+                : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
846 846
         } else {
847 847
             return esc_html__("None", "event_espresso");
848 848
         }
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
                     $item->transaction_ID()
882 882
                 )
883 883
                     ? '<span class="reg-pad-rght">
884
-                        <a class="status-' . $transaction->status_ID() . '" 
885
-                           href="' . $view_txn_lnk_url . '"  
886
-                           aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
884
+                        <a class="status-' . $transaction->status_ID().'" 
885
+                           href="' . $view_txn_lnk_url.'"  
886
+                           aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
887 887
                         >
888
-                            ' . $item->transaction()->pretty_paid() . '
888
+                            ' . $item->transaction()->pretty_paid().'
889 889
                         </a>
890 890
                        <span>'
891
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
891
+                    : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
892 892
             }
893 893
         }
894 894
         return '&nbsp;';
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
             );
930 930
             $actions['view_lnk'] = '
931 931
             <li>
932
-                <a href="' . $view_lnk_url . '" 
933
-                   aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '" 
932
+                <a href="' . $view_lnk_url.'" 
933
+                   aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'" 
934 934
                    class="tiny-text"
935 935
                >
936 936
 				    <div class="dashicons dashicons-clipboard"></div>
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
             );
955 955
             $actions['edit_lnk'] = '
956 956
 			<li>
957
-			    <a href="' . $edit_lnk_url . '" 
958
-                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" 
957
+			    <a href="' . $edit_lnk_url.'" 
958
+                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso').'" 
959 959
                    class="tiny-text"
960 960
                 >
961 961
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
             );
982 982
             $actions['resend_reg_lnk'] = '
983 983
 			<li>
984
-			    <a href="' . $resend_reg_lnk_url . '" 
985
-			       aria-label="' . esc_attr__('Resend Registration Details', 'event_espresso') . '" 
984
+			    <a href="' . $resend_reg_lnk_url.'" 
985
+			       aria-label="' . esc_attr__('Resend Registration Details', 'event_espresso').'" 
986 986
 			       class="tiny-text"
987 987
                 >
988 988
 			        <div class="dashicons dashicons-email-alt"></div>
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
                 $this->_transaction_details['id']
998 998
             )
999 999
         ) {
1000
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1000
+            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1001 1001
                 [
1002 1002
                     'action' => 'view_transaction',
1003 1003
                     'TXN_ID' => $this->_transaction_details['id'],
@@ -1006,9 +1006,9 @@  discard block
 block discarded – undo
1006 1006
             );
1007 1007
             $actions['view_txn_lnk'] = '
1008 1008
 			<li>
1009
-                <a class="ee-status-color-' . $this->_transaction_details['status'] . ' tiny-text" 
1010
-                   href="' . $view_txn_lnk_url . '"  
1011
-                   aria-label="' . $this->_transaction_details['title_attr'] . '"
1009
+                <a class="ee-status-color-' . $this->_transaction_details['status'].' tiny-text" 
1010
+                   href="' . $view_txn_lnk_url.'"  
1011
+                   aria-label="' . $this->_transaction_details['title_attr'].'"
1012 1012
                 >
1013 1013
                     <div class="dashicons dashicons-cart"></div>
1014 1014
                 </a>
@@ -1023,9 +1023,9 @@  discard block
 block discarded – undo
1023 1023
         ) {
1024 1024
             $actions['dl_invoice_lnk'] = '
1025 1025
             <li>
1026
-                <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '" 
1026
+                <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" 
1027 1027
                    class="tiny-text"
1028
-                   href="' . $item->invoice_url() . '" 
1028
+                   href="' . $item->invoice_url().'" 
1029 1029
                    target="_blank" 
1030 1030
                 >
1031 1031
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
                 'see_notifications_for',
1044 1044
                 null,
1045 1045
                 ['_REG_ID' => $item->ID()]
1046
-            ) . '
1046
+            ).'
1047 1047
             </li>';
1048 1048
         }
1049 1049
 
Please login to merge, or discard this patch.
templates/reg_admin_details_side_meta_box_registrant.template.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 
55 55
 <div class="contact-details-buttons">
56 56
     <?php
57
-    if (
58
-        $att_check instanceof EE_Attendee
59
-        && EE_Registry::instance()->CAP->current_user_can(
60
-            'ee_edit_contact',
61
-            'view_or_edit_contact_button',
62
-            $att_check->ID()
63
-        )
64
-    ) :
65
-        ?>
57
+	if (
58
+		$att_check instanceof EE_Attendee
59
+		&& EE_Registry::instance()->CAP->current_user_can(
60
+			'ee_edit_contact',
61
+			'view_or_edit_contact_button',
62
+			$att_check->ID()
63
+		)
64
+	) :
65
+		?>
66 66
         <a class="button button-small" href="<?php echo esc_url_raw($att_edit_link); ?>"
67 67
            aria-label="<?php echo esc_attr($att_edit_label); ?>"
68 68
         >
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
         <?php if (! empty($create_link)) : ?>
73 73
         <a class="button button-small" href="<?php echo esc_url_raw($create_link); ?>"
74 74
            aria-label="<?php esc_attr_e(
75
-               'This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
76
-               'event_espresso'
77
-           ); ?>"
75
+			   'This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
76
+			   'event_espresso'
77
+		   ); ?>"
78 78
         >
79 79
             <span class="ee-icon ee-icon-user-add-new"></span>
80 80
             <?php echo esc_html($create_label); ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
37 37
             <?php esc_html_e('Phone #', 'event_espresso'); ?>
38 38
         </span>
39
-        <?php if (! empty($phone)) : ?>
39
+        <?php if ( ! empty($phone)) : ?>
40 40
             <a href="tel:<?php echo esc_attr($phone); ?>">
41 41
                 <?php echo esc_html($phone); ?>
42 42
             </a>
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             <span class="ee-icon ee-icon-user-edit"></span>
70 70
             <?php echo esc_html($att_edit_label); ?>
71 71
         </a>
72
-        <?php if (! empty($create_link)) : ?>
72
+        <?php if ( ! empty($create_link)) : ?>
73 73
         <a class="button button-small" href="<?php echo esc_url_raw($create_link); ?>"
74 74
            aria-label="<?php esc_attr_e(
75 75
                'This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
Please login to merge, or discard this patch.