Completed
Branch ADMIN-REFRESH (d518e6)
by
unknown
03:00 queued 24s
created
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1023 added lines, -1023 removed lines patch added patch discarded remove patch
@@ -15,1069 +15,1069 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * @var Registrations_Admin_Page
20
-     */
21
-    protected $_admin_page;
22
-
23
-    /**
24
-     * @var array
25
-     */
26
-    private $_status;
27
-
28
-    /**
29
-     * An array of transaction details for the related transaction to the registration being processed.
30
-     * This is set via the _set_related_details method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_transaction_details = [];
35
-
36
-    /**
37
-     * An array of event details for the related event to the registration being processed.
38
-     * This is set via the _set_related_details method.
39
-     *
40
-     * @var array
41
-     */
42
-    protected $_event_details = [];
43
-
44
-
45
-    /**
46
-     * @param Registrations_Admin_Page $admin_page
47
-     */
48
-    public function __construct(Registrations_Admin_Page $admin_page)
49
-    {
50
-        $req_data = $admin_page->get_request_data();
51
-        if (! empty($req_data['event_id'])) {
52
-            $extra_query_args = [];
53
-            foreach ($admin_page->get_views() as $view_details) {
54
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
-            }
56
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57
-        }
58
-        parent::__construct($admin_page);
59
-        $this->_status = $this->_admin_page->get_registration_status_array();
60
-    }
61
-
62
-
63
-    /**
64
-     * @return void
65
-     * @throws EE_Error
66
-     */
67
-    protected function _setup_data()
68
-    {
69
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
70
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
71
-    }
72
-
73
-
74
-    /**
75
-     * @return void
76
-     */
77
-    protected function _set_properties()
78
-    {
79
-        $return_url          = $this->getReturnUrl();
80
-        $this->_wp_list_args = [
81
-            'singular' => esc_html__('registration', 'event_espresso'),
82
-            'plural'   => esc_html__('registrations', 'event_espresso'),
83
-            'ajax'     => true,
84
-            'screen'   => $this->_admin_page->get_current_screen()->id,
85
-        ];
86
-        $req_data            = $this->_admin_page->get_request_data();
87
-        if (isset($req_data['event_id'])) {
88
-            $this->_columns        = [
89
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
90
-                'id'          => esc_html__('ID', 'event_espresso'),
91
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
92
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
93
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
94
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
95
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
96
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
97
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
98
-                'actions' => $this->actionsColumnHeader(),
99
-            ];
100
-            $this->_bottom_buttons = [
101
-                'report' => [
102
-                    'route'         => 'registrations_report',
103
-                    'extra_request' => [
104
-                        'EVT_ID'     => $this->_req_data['event_id'] ?? null,
105
-                        'return_url' => $return_url,
106
-                    ],
107
-                ],
108
-            ];
109
-        } else {
110
-            $this->_columns        = [
111
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
112
-                'id'          => esc_html__('ID', 'event_espresso'),
113
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
114
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
115
-                'event_name'       => esc_html__('Event', 'event_espresso'),
116
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
117
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
118
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
119
-                'actions' => $this->actionsColumnHeader(),
120
-            ];
121
-            $this->_bottom_buttons = [
122
-                'report_all' => [
123
-                    'route'         => 'registrations_report',
124
-                    'extra_request' => [
125
-                        'return_url' => $return_url,
126
-                    ],
127
-                ],
128
-            ];
129
-        }
130
-        $this->_bottom_buttons['report_filtered'] = [
131
-            'route'         => 'registrations_report',
132
-            'extra_request' => [
133
-                'use_filters' => true,
134
-                'return_url'  => $return_url,
135
-            ],
136
-        ];
137
-        $filters                                  = array_diff_key(
138
-            $this->_req_data,
139
-            array_flip(
140
-                [
141
-                    'page',
142
-                    'action',
143
-                    'default_nonce',
144
-                ]
145
-            )
146
-        );
147
-        if (! empty($filters)) {
148
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
149
-        }
150
-        $this->_primary_column   = 'id';
151
-        $this->_sortable_columns = [
152
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
153
-            /**
154
-             * Allows users to change the default sort if they wish.
155
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
156
-             * name.
157
-             */
158
-            'ATT_fname'     => [
159
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
160
-                true,
161
-                $this,
162
-            ]
163
-                ? ['ATT_lname' => false]
164
-                : ['ATT_fname' => false],
165
-            'event_name'    => ['event_name' => false],
166
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
167
-            'id'       => ['REG_ID' => false],
168
-        ];
169
-        $this->_hidden_columns   = [];
170
-    }
171
-
172
-
173
-    /**
174
-     * This simply sets up the row class for the table rows.
175
-     * Allows for easier overriding of child methods for setting up sorting.
176
-     *
177
-     * @param EE_Registration $registration the current item
178
-     * @return string
179
-     */
180
-    protected function _get_row_class($registration)
181
-    {
182
-        $class = parent::_get_row_class($registration);
183
-        if ($this->_has_checkbox_column) {
184
-            $class .= ' has-checkbox-column';
185
-        }
186
-        return $class;
187
-    }
188
-
189
-
190
-    /**
191
-     * Set the $_transaction_details property if not set yet.
192
-     *
193
-     * @param EE_Registration $registration
194
-     * @throws EE_Error
195
-     * @throws InvalidArgumentException
196
-     * @throws ReflectionException
197
-     * @throws InvalidDataTypeException
198
-     * @throws InvalidInterfaceException
199
-     */
200
-    protected function _set_related_details(EE_Registration $registration)
201
-    {
202
-        $transaction                = $registration->get_first_related('Transaction');
203
-        $status                     = $transaction instanceof EE_Transaction
204
-            ? $transaction->status_ID()
205
-            : EEM_Transaction::failed_status_code;
206
-        $this->_transaction_details = [
207
-            'transaction' => $transaction,
208
-            'status'      => $status,
209
-            'id'          => $transaction instanceof EE_Transaction
210
-                ? $transaction->ID()
211
-                : 0,
212
-            'title_attr'  => sprintf(
213
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
214
-                EEH_Template::pretty_status($status, false, 'sentence')
215
-            ),
216
-        ];
217
-        try {
218
-            $event = $registration->event();
219
-        } catch (EntityNotFoundException $e) {
220
-            $event = null;
221
-        }
222
-        $status               = $event instanceof EE_Event
223
-            ? $event->get_active_status()
224
-            : EE_Datetime::inactive;
225
-        $this->_event_details = [
226
-            'event'      => $event,
227
-            'status'     => $status,
228
-            'id'         => $event instanceof EE_Event
229
-                ? $event->ID()
230
-                : 0,
231
-            'title_attr' => sprintf(
232
-                esc_html__('Edit Event (%s)', 'event_espresso'),
233
-                EEH_Template::pretty_status($status, false, 'sentence')
234
-            ),
235
-        ];
236
-    }
237
-
238
-
239
-    /**
240
-     *    _get_table_filters
241
-     *
242
-     * @return array
243
-     */
244
-    protected function _get_table_filters()
245
-    {
246
-        $filters = [];
247
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
248
-        // methods.
249
-        $cur_date     = isset($this->_req_data['month_range'])
250
-            ? $this->_req_data['month_range']
251
-            : '';
252
-        $cur_category = isset($this->_req_data['EVT_CAT'])
253
-            ? $this->_req_data['EVT_CAT']
254
-            : -1;
255
-        $reg_status   = isset($this->_req_data['_reg_status'])
256
-            ? $this->_req_data['_reg_status']
257
-            : '';
258
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
259
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
260
-        $status       = [];
261
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
262
-        foreach ($this->_status as $key => $value) {
263
-            $status[] = ['id' => $key, 'text' => $value];
264
-        }
265
-        if ($this->_view !== 'incomplete') {
266
-            $filters[] = EEH_Form_Fields::select_input(
267
-                '_reg_status',
268
-                $status,
269
-                isset($this->_req_data['_reg_status'])
270
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
271
-                    : ''
272
-            );
273
-        }
274
-        if (isset($this->_req_data['event_id'])) {
275
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
276
-        }
277
-        return $filters;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return void
283
-     * @throws EE_Error
284
-     * @throws InvalidArgumentException
285
-     * @throws InvalidDataTypeException
286
-     * @throws InvalidInterfaceException
287
-     */
288
-    protected function _add_view_counts()
289
-    {
290
-        $this->_views['all']['count']   = $this->_total_registrations();
291
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
292
-        $this->_views['today']['count'] = $this->_total_registrations_today();
293
-        if (
294
-            EE_Registry::instance()->CAP->current_user_can(
295
-                'ee_delete_registrations',
296
-                'espresso_registrations_trash_registrations'
297
-            )
298
-        ) {
299
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
300
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
301
-        }
302
-    }
303
-
304
-
305
-    /**
306
-     * @param string $view
307
-     * @return int
308
-     * @throws EE_Error
309
-     * @throws InvalidArgumentException
310
-     * @throws InvalidDataTypeException
311
-     * @throws InvalidInterfaceException
312
-     */
313
-    protected function _total_registrations($view = '')
314
-    {
315
-        $_where = [];
316
-        $EVT_ID = isset($this->_req_data['event_id'])
317
-            ? absint($this->_req_data['event_id'])
318
-            : false;
319
-        if ($EVT_ID) {
320
-            $_where['EVT_ID'] = $EVT_ID;
321
-        }
322
-        switch ($view) {
323
-            case 'trash':
324
-                return EEM_Registration::instance()->count_deleted([$_where]);
325
-            case 'incomplete':
326
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
327
-                break;
328
-            default:
329
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
330
-        }
331
-        return EEM_Registration::instance()->count([$_where]);
332
-    }
333
-
334
-
335
-    /**
336
-     * @return int
337
-     * @throws EE_Error
338
-     * @throws InvalidArgumentException
339
-     * @throws InvalidDataTypeException
340
-     * @throws InvalidInterfaceException
341
-     */
342
-    protected function _total_registrations_this_month()
343
-    {
344
-        $EVT_ID          = isset($this->_req_data['event_id'])
345
-            ? absint($this->_req_data['event_id'])
346
-            : false;
347
-        $_where          = $EVT_ID
348
-            ? ['EVT_ID' => $EVT_ID]
349
-            : [];
350
-        $this_year_r     = date('Y', current_time('timestamp'));
351
-        $time_start      = ' 00:00:00';
352
-        $time_end        = ' 23:59:59';
353
-        $this_month_r    = date('m', current_time('timestamp'));
354
-        $days_this_month = date('t', current_time('timestamp'));
355
-        // setup date query.
356
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
357
-            'REG_date',
358
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
359
-            'Y-m-d H:i:s'
360
-        );
361
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
362
-            'REG_date',
363
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
364
-            'Y-m-d H:i:s'
365
-        );
366
-        $_where['REG_date'] = [
367
-            'BETWEEN',
368
-            [
369
-                $beginning_string,
370
-                $end_string,
371
-            ],
372
-        ];
373
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
374
-        return EEM_Registration::instance()->count([$_where]);
375
-    }
376
-
377
-
378
-    /**
379
-     * @return int
380
-     * @throws EE_Error
381
-     * @throws InvalidArgumentException
382
-     * @throws InvalidDataTypeException
383
-     * @throws InvalidInterfaceException
384
-     */
385
-    protected function _total_registrations_today()
386
-    {
387
-        $EVT_ID             = isset($this->_req_data['event_id'])
388
-            ? absint($this->_req_data['event_id'])
389
-            : false;
390
-        $_where             = $EVT_ID
391
-            ? ['EVT_ID' => $EVT_ID]
392
-            : [];
393
-        $current_date       = date('Y-m-d', current_time('timestamp'));
394
-        $time_start         = ' 00:00:00';
395
-        $time_end           = ' 23:59:59';
396
-        $_where['REG_date'] = [
397
-            'BETWEEN',
398
-            [
399
-                EEM_Registration::instance()->convert_datetime_for_query(
400
-                    'REG_date',
401
-                    $current_date . $time_start,
402
-                    'Y-m-d H:i:s'
403
-                ),
404
-                EEM_Registration::instance()->convert_datetime_for_query(
405
-                    'REG_date',
406
-                    $current_date . $time_end,
407
-                    'Y-m-d H:i:s'
408
-                ),
409
-            ],
410
-        ];
411
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
412
-        return EEM_Registration::instance()->count([$_where]);
413
-    }
414
-
415
-
416
-    /**
417
-     * @param EE_Registration $registration
418
-     * @return string
419
-     * @throws EE_Error
420
-     * @throws InvalidArgumentException
421
-     * @throws InvalidDataTypeException
422
-     * @throws InvalidInterfaceException
423
-     * @throws ReflectionException
424
-     */
425
-    public function column_cb($registration)
426
-    {
427
-        /** checkbox/lock **/
428
-        $REG_ID = $registration->ID();
429
-        $transaction   = $registration->get_first_related('Transaction');
430
-        $payment_count = $transaction instanceof EE_Transaction
431
-            ? $transaction->count_related('Payment')
432
-            : 0;
433
-        $content = $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
434
-            'ee_edit_registration',
435
-            'registration_list_table_checkbox_input',
436
-            $REG_ID
437
-        )
438
-            ? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /><span class="dashicons dashicons-lock"></span>'
439
-            : '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
440
-
441
-        return $this->columnContent('cb', $content, 'center');
442
-    }
443
-
444
-
445
-    /**
446
-     * @param EE_Registration $registration
447
-     * @return string
448
-     * @throws EE_Error
449
-     * @throws InvalidArgumentException
450
-     * @throws InvalidDataTypeException
451
-     * @throws InvalidInterfaceException
452
-     * @throws ReflectionException
453
-     */
454
-    public function column_id(EE_Registration $registration)
455
-    {
456
-        $content  = $registration->ID();
457
-        $attendee = $registration->attendee();
458
-
459
-        $content .= '<span class="show-on-mobile-view-only">';
460
-        $content  .= $attendee instanceof EE_Attendee
461
-            ? $attendee->full_name()
462
-            : '';
463
-
464
-        return $this->columnContent('id', $content, 'end');
465
-    }
466
-
467
-
468
-    /**
469
-     * @param EE_Registration $registration
470
-     * @return string
471
-     * @throws EE_Error
472
-     * @throws InvalidArgumentException
473
-     * @throws InvalidDataTypeException
474
-     * @throws InvalidInterfaceException
475
-     * @throws ReflectionException
476
-     */
477
-    public function column__REG_date(EE_Registration $registration)
478
-    {
479
-        $this->_set_related_details($registration);
480
-        // Build row actions
481
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
482
-            [
483
-                'action' => 'view_transaction',
484
-                'TXN_ID' => $this->_transaction_details['id'],
485
-            ],
486
-            TXN_ADMIN_URL
487
-        );
488
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
489
-            'ee_read_transaction',
490
-            'espresso_transactions_view_transaction'
491
-        )
492
-            ? '<a class="ee-aria-tooltip ee-status-color-' . $this->_transaction_details['status'] . '" href="'
493
-              . $view_lnk_url
494
-              . '" aria-label="'
495
-              . esc_attr($this->_transaction_details['title_attr'])
496
-              . '">'
497
-              . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
498
-              . '</a>'
499
-            : $registration->get_i18n_datetime('REG_date');
500
-        $view_link    .= ' <span class="ee-status-text-small">'
501
-                         . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
502
-                         . '</span>';
503
-
504
-        return $this->columnContent('_REG_date', $view_link);
505
-    }
506
-
507
-
508
-    /**
509
-     * @param EE_Registration $registration
510
-     * @return string
511
-     * @throws EE_Error
512
-     * @throws InvalidArgumentException
513
-     * @throws InvalidDataTypeException
514
-     * @throws InvalidInterfaceException
515
-     * @throws ReflectionException
516
-     */
517
-    public function column_event_name(EE_Registration $registration)
518
-    {
519
-        $this->_set_related_details($registration);
520
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
521
-        $EVT_ID     = $registration->event_ID();
522
-        $event_name = $registration->event_name();
523
-        $event_name =
524
-            $event_name
525
-                ?: esc_html__("No Associated Event", 'event_espresso');
526
-        $event_name = wp_trim_words($event_name, 30, '...');
527
-        if ($EVT_ID) {
528
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
529
-                ['action' => 'edit', 'post' => $EVT_ID],
530
-                EVENTS_ADMIN_URL
531
-            );
532
-            $edit_event              =
533
-                EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
534
-                    ? '<a class="ee-aria-tooltip ee-status-color-'
535
-                      . $this->_event_details['status']
536
-                      . '" href="'
537
-                      . $edit_event_url
538
-                      . '" aria-label="'
539
-                      . esc_attr($this->_event_details['title_attr'])
540
-                      . '">'
541
-                      . $event_name
542
-                      . '</a>'
543
-                    : $event_name;
544
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
545
-            $actions['event_filter'] = '<a class="ee-aria-tooltip" href="' . $edit_event_url . '" aria-label="';
546
-            $actions['event_filter'] .= sprintf(
547
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
548
-                $event_name
549
-            );
550
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
551
-        } else {
552
-            $edit_event              = $event_name;
553
-            $actions['event_filter'] = '';
554
-        }
555
-        $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
556
-
557
-        return $this->columnContent('event_name', $content);
558
-    }
559
-
560
-
561
-    /**
562
-     * @param EE_Registration $registration
563
-     * @return string
564
-     * @throws EE_Error
565
-     * @throws InvalidArgumentException
566
-     * @throws InvalidDataTypeException
567
-     * @throws InvalidInterfaceException
568
-     * @throws ReflectionException
569
-     */
570
-    public function column_DTT_EVT_start(EE_Registration $registration)
571
-    {
572
-        $datetime_strings = [];
573
-        $ticket           = $registration->ticket();
574
-        if ($ticket instanceof EE_Ticket) {
575
-            $remove_defaults = ['default_where_conditions' => 'none'];
576
-            $datetimes       = $ticket->datetimes($remove_defaults);
577
-            foreach ($datetimes as $datetime) {
578
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
579
-            }
580
-            $content = $this->generateDisplayForDatetimes($datetime_strings);
581
-        } else {
582
-            $content = esc_html__('There is no ticket on this registration', 'event_espresso');
583
-        }
584
-        return $this->columnContent('DTT_EVT_start', $content);
585
-    }
586
-
587
-
588
-    /**
589
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
590
-     *
591
-     * @param array $datetime_strings
592
-     * @return string
593
-     */
594
-    public function generateDisplayForDateTimes(array $datetime_strings)
595
-    {
596
-        $content       = '<div class="ee-registration-event-datetimes-container">';
597
-        $expand_toggle = count($datetime_strings) > 1
598
-            ? ' <span aria-label="' . esc_attr__('Click to view all dates', 'event_espresso')
599
-              . '" class="ee-aria-tooltip ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
600
-            : '';
601
-        // get first item for initial visibility
602
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
603
-        $content .= $expand_toggle;
604
-        if ($datetime_strings) {
605
-            $content .= '<div style="clear:both"></div>';
606
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
607
-            $content .= implode("<br />", $datetime_strings);
608
-            $content .= '</div>';
609
-        }
610
-        $content .= '</div>';
611
-        return $content;
612
-    }
613
-
614
-
615
-    /**
616
-     * @param EE_Registration $registration
617
-     * @return string
618
-     * @throws EE_Error
619
-     * @throws InvalidArgumentException
620
-     * @throws InvalidDataTypeException
621
-     * @throws InvalidInterfaceException
622
-     * @throws ReflectionException
623
-     */
624
-    public function column_ATT_fname(EE_Registration $registration)
625
-    {
626
-        $attendee      = $registration->attendee();
627
-        $edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
628
-            [
629
-                'action'  => 'view_registration',
630
-                '_REG_ID' => $registration->ID(),
631
-            ],
632
-            REG_ADMIN_URL
633
-        );
634
-        $attendee_name = $attendee instanceof EE_Attendee
635
-            ? $attendee->full_name()
636
-            : '';
637
-
638
-        $status        = esc_attr($registration->status_ID());
639
-        $pretty_status = EEH_Template::pretty_status($status, false, 'sentence');
640
-        $status_dot    = '';
641
-
642
-        $content       = '
18
+	/**
19
+	 * @var Registrations_Admin_Page
20
+	 */
21
+	protected $_admin_page;
22
+
23
+	/**
24
+	 * @var array
25
+	 */
26
+	private $_status;
27
+
28
+	/**
29
+	 * An array of transaction details for the related transaction to the registration being processed.
30
+	 * This is set via the _set_related_details method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_transaction_details = [];
35
+
36
+	/**
37
+	 * An array of event details for the related event to the registration being processed.
38
+	 * This is set via the _set_related_details method.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $_event_details = [];
43
+
44
+
45
+	/**
46
+	 * @param Registrations_Admin_Page $admin_page
47
+	 */
48
+	public function __construct(Registrations_Admin_Page $admin_page)
49
+	{
50
+		$req_data = $admin_page->get_request_data();
51
+		if (! empty($req_data['event_id'])) {
52
+			$extra_query_args = [];
53
+			foreach ($admin_page->get_views() as $view_details) {
54
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
+			}
56
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57
+		}
58
+		parent::__construct($admin_page);
59
+		$this->_status = $this->_admin_page->get_registration_status_array();
60
+	}
61
+
62
+
63
+	/**
64
+	 * @return void
65
+	 * @throws EE_Error
66
+	 */
67
+	protected function _setup_data()
68
+	{
69
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
70
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return void
76
+	 */
77
+	protected function _set_properties()
78
+	{
79
+		$return_url          = $this->getReturnUrl();
80
+		$this->_wp_list_args = [
81
+			'singular' => esc_html__('registration', 'event_espresso'),
82
+			'plural'   => esc_html__('registrations', 'event_espresso'),
83
+			'ajax'     => true,
84
+			'screen'   => $this->_admin_page->get_current_screen()->id,
85
+		];
86
+		$req_data            = $this->_admin_page->get_request_data();
87
+		if (isset($req_data['event_id'])) {
88
+			$this->_columns        = [
89
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
90
+				'id'          => esc_html__('ID', 'event_espresso'),
91
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
92
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
93
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
94
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
95
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
96
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
97
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
98
+				'actions' => $this->actionsColumnHeader(),
99
+			];
100
+			$this->_bottom_buttons = [
101
+				'report' => [
102
+					'route'         => 'registrations_report',
103
+					'extra_request' => [
104
+						'EVT_ID'     => $this->_req_data['event_id'] ?? null,
105
+						'return_url' => $return_url,
106
+					],
107
+				],
108
+			];
109
+		} else {
110
+			$this->_columns        = [
111
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
112
+				'id'          => esc_html__('ID', 'event_espresso'),
113
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
114
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
115
+				'event_name'       => esc_html__('Event', 'event_espresso'),
116
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
117
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
118
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
119
+				'actions' => $this->actionsColumnHeader(),
120
+			];
121
+			$this->_bottom_buttons = [
122
+				'report_all' => [
123
+					'route'         => 'registrations_report',
124
+					'extra_request' => [
125
+						'return_url' => $return_url,
126
+					],
127
+				],
128
+			];
129
+		}
130
+		$this->_bottom_buttons['report_filtered'] = [
131
+			'route'         => 'registrations_report',
132
+			'extra_request' => [
133
+				'use_filters' => true,
134
+				'return_url'  => $return_url,
135
+			],
136
+		];
137
+		$filters                                  = array_diff_key(
138
+			$this->_req_data,
139
+			array_flip(
140
+				[
141
+					'page',
142
+					'action',
143
+					'default_nonce',
144
+				]
145
+			)
146
+		);
147
+		if (! empty($filters)) {
148
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
149
+		}
150
+		$this->_primary_column   = 'id';
151
+		$this->_sortable_columns = [
152
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
153
+			/**
154
+			 * Allows users to change the default sort if they wish.
155
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
156
+			 * name.
157
+			 */
158
+			'ATT_fname'     => [
159
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
160
+				true,
161
+				$this,
162
+			]
163
+				? ['ATT_lname' => false]
164
+				: ['ATT_fname' => false],
165
+			'event_name'    => ['event_name' => false],
166
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
167
+			'id'       => ['REG_ID' => false],
168
+		];
169
+		$this->_hidden_columns   = [];
170
+	}
171
+
172
+
173
+	/**
174
+	 * This simply sets up the row class for the table rows.
175
+	 * Allows for easier overriding of child methods for setting up sorting.
176
+	 *
177
+	 * @param EE_Registration $registration the current item
178
+	 * @return string
179
+	 */
180
+	protected function _get_row_class($registration)
181
+	{
182
+		$class = parent::_get_row_class($registration);
183
+		if ($this->_has_checkbox_column) {
184
+			$class .= ' has-checkbox-column';
185
+		}
186
+		return $class;
187
+	}
188
+
189
+
190
+	/**
191
+	 * Set the $_transaction_details property if not set yet.
192
+	 *
193
+	 * @param EE_Registration $registration
194
+	 * @throws EE_Error
195
+	 * @throws InvalidArgumentException
196
+	 * @throws ReflectionException
197
+	 * @throws InvalidDataTypeException
198
+	 * @throws InvalidInterfaceException
199
+	 */
200
+	protected function _set_related_details(EE_Registration $registration)
201
+	{
202
+		$transaction                = $registration->get_first_related('Transaction');
203
+		$status                     = $transaction instanceof EE_Transaction
204
+			? $transaction->status_ID()
205
+			: EEM_Transaction::failed_status_code;
206
+		$this->_transaction_details = [
207
+			'transaction' => $transaction,
208
+			'status'      => $status,
209
+			'id'          => $transaction instanceof EE_Transaction
210
+				? $transaction->ID()
211
+				: 0,
212
+			'title_attr'  => sprintf(
213
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
214
+				EEH_Template::pretty_status($status, false, 'sentence')
215
+			),
216
+		];
217
+		try {
218
+			$event = $registration->event();
219
+		} catch (EntityNotFoundException $e) {
220
+			$event = null;
221
+		}
222
+		$status               = $event instanceof EE_Event
223
+			? $event->get_active_status()
224
+			: EE_Datetime::inactive;
225
+		$this->_event_details = [
226
+			'event'      => $event,
227
+			'status'     => $status,
228
+			'id'         => $event instanceof EE_Event
229
+				? $event->ID()
230
+				: 0,
231
+			'title_attr' => sprintf(
232
+				esc_html__('Edit Event (%s)', 'event_espresso'),
233
+				EEH_Template::pretty_status($status, false, 'sentence')
234
+			),
235
+		];
236
+	}
237
+
238
+
239
+	/**
240
+	 *    _get_table_filters
241
+	 *
242
+	 * @return array
243
+	 */
244
+	protected function _get_table_filters()
245
+	{
246
+		$filters = [];
247
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
248
+		// methods.
249
+		$cur_date     = isset($this->_req_data['month_range'])
250
+			? $this->_req_data['month_range']
251
+			: '';
252
+		$cur_category = isset($this->_req_data['EVT_CAT'])
253
+			? $this->_req_data['EVT_CAT']
254
+			: -1;
255
+		$reg_status   = isset($this->_req_data['_reg_status'])
256
+			? $this->_req_data['_reg_status']
257
+			: '';
258
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
259
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
260
+		$status       = [];
261
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
262
+		foreach ($this->_status as $key => $value) {
263
+			$status[] = ['id' => $key, 'text' => $value];
264
+		}
265
+		if ($this->_view !== 'incomplete') {
266
+			$filters[] = EEH_Form_Fields::select_input(
267
+				'_reg_status',
268
+				$status,
269
+				isset($this->_req_data['_reg_status'])
270
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
271
+					: ''
272
+			);
273
+		}
274
+		if (isset($this->_req_data['event_id'])) {
275
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
276
+		}
277
+		return $filters;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return void
283
+	 * @throws EE_Error
284
+	 * @throws InvalidArgumentException
285
+	 * @throws InvalidDataTypeException
286
+	 * @throws InvalidInterfaceException
287
+	 */
288
+	protected function _add_view_counts()
289
+	{
290
+		$this->_views['all']['count']   = $this->_total_registrations();
291
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
292
+		$this->_views['today']['count'] = $this->_total_registrations_today();
293
+		if (
294
+			EE_Registry::instance()->CAP->current_user_can(
295
+				'ee_delete_registrations',
296
+				'espresso_registrations_trash_registrations'
297
+			)
298
+		) {
299
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
300
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
301
+		}
302
+	}
303
+
304
+
305
+	/**
306
+	 * @param string $view
307
+	 * @return int
308
+	 * @throws EE_Error
309
+	 * @throws InvalidArgumentException
310
+	 * @throws InvalidDataTypeException
311
+	 * @throws InvalidInterfaceException
312
+	 */
313
+	protected function _total_registrations($view = '')
314
+	{
315
+		$_where = [];
316
+		$EVT_ID = isset($this->_req_data['event_id'])
317
+			? absint($this->_req_data['event_id'])
318
+			: false;
319
+		if ($EVT_ID) {
320
+			$_where['EVT_ID'] = $EVT_ID;
321
+		}
322
+		switch ($view) {
323
+			case 'trash':
324
+				return EEM_Registration::instance()->count_deleted([$_where]);
325
+			case 'incomplete':
326
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
327
+				break;
328
+			default:
329
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
330
+		}
331
+		return EEM_Registration::instance()->count([$_where]);
332
+	}
333
+
334
+
335
+	/**
336
+	 * @return int
337
+	 * @throws EE_Error
338
+	 * @throws InvalidArgumentException
339
+	 * @throws InvalidDataTypeException
340
+	 * @throws InvalidInterfaceException
341
+	 */
342
+	protected function _total_registrations_this_month()
343
+	{
344
+		$EVT_ID          = isset($this->_req_data['event_id'])
345
+			? absint($this->_req_data['event_id'])
346
+			: false;
347
+		$_where          = $EVT_ID
348
+			? ['EVT_ID' => $EVT_ID]
349
+			: [];
350
+		$this_year_r     = date('Y', current_time('timestamp'));
351
+		$time_start      = ' 00:00:00';
352
+		$time_end        = ' 23:59:59';
353
+		$this_month_r    = date('m', current_time('timestamp'));
354
+		$days_this_month = date('t', current_time('timestamp'));
355
+		// setup date query.
356
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
357
+			'REG_date',
358
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
359
+			'Y-m-d H:i:s'
360
+		);
361
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
362
+			'REG_date',
363
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
364
+			'Y-m-d H:i:s'
365
+		);
366
+		$_where['REG_date'] = [
367
+			'BETWEEN',
368
+			[
369
+				$beginning_string,
370
+				$end_string,
371
+			],
372
+		];
373
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
374
+		return EEM_Registration::instance()->count([$_where]);
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return int
380
+	 * @throws EE_Error
381
+	 * @throws InvalidArgumentException
382
+	 * @throws InvalidDataTypeException
383
+	 * @throws InvalidInterfaceException
384
+	 */
385
+	protected function _total_registrations_today()
386
+	{
387
+		$EVT_ID             = isset($this->_req_data['event_id'])
388
+			? absint($this->_req_data['event_id'])
389
+			: false;
390
+		$_where             = $EVT_ID
391
+			? ['EVT_ID' => $EVT_ID]
392
+			: [];
393
+		$current_date       = date('Y-m-d', current_time('timestamp'));
394
+		$time_start         = ' 00:00:00';
395
+		$time_end           = ' 23:59:59';
396
+		$_where['REG_date'] = [
397
+			'BETWEEN',
398
+			[
399
+				EEM_Registration::instance()->convert_datetime_for_query(
400
+					'REG_date',
401
+					$current_date . $time_start,
402
+					'Y-m-d H:i:s'
403
+				),
404
+				EEM_Registration::instance()->convert_datetime_for_query(
405
+					'REG_date',
406
+					$current_date . $time_end,
407
+					'Y-m-d H:i:s'
408
+				),
409
+			],
410
+		];
411
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
412
+		return EEM_Registration::instance()->count([$_where]);
413
+	}
414
+
415
+
416
+	/**
417
+	 * @param EE_Registration $registration
418
+	 * @return string
419
+	 * @throws EE_Error
420
+	 * @throws InvalidArgumentException
421
+	 * @throws InvalidDataTypeException
422
+	 * @throws InvalidInterfaceException
423
+	 * @throws ReflectionException
424
+	 */
425
+	public function column_cb($registration)
426
+	{
427
+		/** checkbox/lock **/
428
+		$REG_ID = $registration->ID();
429
+		$transaction   = $registration->get_first_related('Transaction');
430
+		$payment_count = $transaction instanceof EE_Transaction
431
+			? $transaction->count_related('Payment')
432
+			: 0;
433
+		$content = $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
434
+			'ee_edit_registration',
435
+			'registration_list_table_checkbox_input',
436
+			$REG_ID
437
+		)
438
+			? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /><span class="dashicons dashicons-lock"></span>'
439
+			: '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
440
+
441
+		return $this->columnContent('cb', $content, 'center');
442
+	}
443
+
444
+
445
+	/**
446
+	 * @param EE_Registration $registration
447
+	 * @return string
448
+	 * @throws EE_Error
449
+	 * @throws InvalidArgumentException
450
+	 * @throws InvalidDataTypeException
451
+	 * @throws InvalidInterfaceException
452
+	 * @throws ReflectionException
453
+	 */
454
+	public function column_id(EE_Registration $registration)
455
+	{
456
+		$content  = $registration->ID();
457
+		$attendee = $registration->attendee();
458
+
459
+		$content .= '<span class="show-on-mobile-view-only">';
460
+		$content  .= $attendee instanceof EE_Attendee
461
+			? $attendee->full_name()
462
+			: '';
463
+
464
+		return $this->columnContent('id', $content, 'end');
465
+	}
466
+
467
+
468
+	/**
469
+	 * @param EE_Registration $registration
470
+	 * @return string
471
+	 * @throws EE_Error
472
+	 * @throws InvalidArgumentException
473
+	 * @throws InvalidDataTypeException
474
+	 * @throws InvalidInterfaceException
475
+	 * @throws ReflectionException
476
+	 */
477
+	public function column__REG_date(EE_Registration $registration)
478
+	{
479
+		$this->_set_related_details($registration);
480
+		// Build row actions
481
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
482
+			[
483
+				'action' => 'view_transaction',
484
+				'TXN_ID' => $this->_transaction_details['id'],
485
+			],
486
+			TXN_ADMIN_URL
487
+		);
488
+		$view_link    = EE_Registry::instance()->CAP->current_user_can(
489
+			'ee_read_transaction',
490
+			'espresso_transactions_view_transaction'
491
+		)
492
+			? '<a class="ee-aria-tooltip ee-status-color-' . $this->_transaction_details['status'] . '" href="'
493
+			  . $view_lnk_url
494
+			  . '" aria-label="'
495
+			  . esc_attr($this->_transaction_details['title_attr'])
496
+			  . '">'
497
+			  . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
498
+			  . '</a>'
499
+			: $registration->get_i18n_datetime('REG_date');
500
+		$view_link    .= ' <span class="ee-status-text-small">'
501
+						 . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
502
+						 . '</span>';
503
+
504
+		return $this->columnContent('_REG_date', $view_link);
505
+	}
506
+
507
+
508
+	/**
509
+	 * @param EE_Registration $registration
510
+	 * @return string
511
+	 * @throws EE_Error
512
+	 * @throws InvalidArgumentException
513
+	 * @throws InvalidDataTypeException
514
+	 * @throws InvalidInterfaceException
515
+	 * @throws ReflectionException
516
+	 */
517
+	public function column_event_name(EE_Registration $registration)
518
+	{
519
+		$this->_set_related_details($registration);
520
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
521
+		$EVT_ID     = $registration->event_ID();
522
+		$event_name = $registration->event_name();
523
+		$event_name =
524
+			$event_name
525
+				?: esc_html__("No Associated Event", 'event_espresso');
526
+		$event_name = wp_trim_words($event_name, 30, '...');
527
+		if ($EVT_ID) {
528
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
529
+				['action' => 'edit', 'post' => $EVT_ID],
530
+				EVENTS_ADMIN_URL
531
+			);
532
+			$edit_event              =
533
+				EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
534
+					? '<a class="ee-aria-tooltip ee-status-color-'
535
+					  . $this->_event_details['status']
536
+					  . '" href="'
537
+					  . $edit_event_url
538
+					  . '" aria-label="'
539
+					  . esc_attr($this->_event_details['title_attr'])
540
+					  . '">'
541
+					  . $event_name
542
+					  . '</a>'
543
+					: $event_name;
544
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
545
+			$actions['event_filter'] = '<a class="ee-aria-tooltip" href="' . $edit_event_url . '" aria-label="';
546
+			$actions['event_filter'] .= sprintf(
547
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
548
+				$event_name
549
+			);
550
+			$actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
551
+		} else {
552
+			$edit_event              = $event_name;
553
+			$actions['event_filter'] = '';
554
+		}
555
+		$content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
556
+
557
+		return $this->columnContent('event_name', $content);
558
+	}
559
+
560
+
561
+	/**
562
+	 * @param EE_Registration $registration
563
+	 * @return string
564
+	 * @throws EE_Error
565
+	 * @throws InvalidArgumentException
566
+	 * @throws InvalidDataTypeException
567
+	 * @throws InvalidInterfaceException
568
+	 * @throws ReflectionException
569
+	 */
570
+	public function column_DTT_EVT_start(EE_Registration $registration)
571
+	{
572
+		$datetime_strings = [];
573
+		$ticket           = $registration->ticket();
574
+		if ($ticket instanceof EE_Ticket) {
575
+			$remove_defaults = ['default_where_conditions' => 'none'];
576
+			$datetimes       = $ticket->datetimes($remove_defaults);
577
+			foreach ($datetimes as $datetime) {
578
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
579
+			}
580
+			$content = $this->generateDisplayForDatetimes($datetime_strings);
581
+		} else {
582
+			$content = esc_html__('There is no ticket on this registration', 'event_espresso');
583
+		}
584
+		return $this->columnContent('DTT_EVT_start', $content);
585
+	}
586
+
587
+
588
+	/**
589
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
590
+	 *
591
+	 * @param array $datetime_strings
592
+	 * @return string
593
+	 */
594
+	public function generateDisplayForDateTimes(array $datetime_strings)
595
+	{
596
+		$content       = '<div class="ee-registration-event-datetimes-container">';
597
+		$expand_toggle = count($datetime_strings) > 1
598
+			? ' <span aria-label="' . esc_attr__('Click to view all dates', 'event_espresso')
599
+			  . '" class="ee-aria-tooltip ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
600
+			: '';
601
+		// get first item for initial visibility
602
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
603
+		$content .= $expand_toggle;
604
+		if ($datetime_strings) {
605
+			$content .= '<div style="clear:both"></div>';
606
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
607
+			$content .= implode("<br />", $datetime_strings);
608
+			$content .= '</div>';
609
+		}
610
+		$content .= '</div>';
611
+		return $content;
612
+	}
613
+
614
+
615
+	/**
616
+	 * @param EE_Registration $registration
617
+	 * @return string
618
+	 * @throws EE_Error
619
+	 * @throws InvalidArgumentException
620
+	 * @throws InvalidDataTypeException
621
+	 * @throws InvalidInterfaceException
622
+	 * @throws ReflectionException
623
+	 */
624
+	public function column_ATT_fname(EE_Registration $registration)
625
+	{
626
+		$attendee      = $registration->attendee();
627
+		$edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
628
+			[
629
+				'action'  => 'view_registration',
630
+				'_REG_ID' => $registration->ID(),
631
+			],
632
+			REG_ADMIN_URL
633
+		);
634
+		$attendee_name = $attendee instanceof EE_Attendee
635
+			? $attendee->full_name()
636
+			: '';
637
+
638
+		$status        = esc_attr($registration->status_ID());
639
+		$pretty_status = EEH_Template::pretty_status($status, false, 'sentence');
640
+		$status_dot    = '';
641
+
642
+		$content       = '
643 643
         <div class="ee-layout-row">
644 644
             <span aria-label="' . $pretty_status . '" 
645 645
                   class="ee-status-dot ee-status-dot--' . $status . ' ee-aria-tooltip"
646 646
             ></span>';
647 647
 
648
-        $content .= EE_Registry::instance()->CAP->current_user_can(
649
-            'ee_read_registration',
650
-            'espresso_registrations_view_registration',
651
-            $registration->ID()
652
-        )
653
-            ? '
648
+		$content .= EE_Registry::instance()->CAP->current_user_can(
649
+			'ee_read_registration',
650
+			'espresso_registrations_view_registration',
651
+			$registration->ID()
652
+		)
653
+			? '
654 654
             <a  href="' . $edit_lnk_url . '"  
655 655
                 class="row-title status-' . $status . ' ee-aria-tooltip" 
656 656
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
657 657
             >
658 658
                 ' . $attendee_name . '
659 659
             </a>'
660
-            : $attendee_name;
661
-
662
-        $content .= $registration->count() === 1
663
-            ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
664
-            : '';
665
-
666
-        $transaction = $registration->get_first_related('Transaction');
667
-        $payment_count = $transaction instanceof EE_Transaction
668
-            ? $transaction->count_related('Payment')
669
-            : 0;
670
-
671
-        // append group count to name
672
-        $content .= '<span class="reg-count-group-size">';
673
-        $content .= sprintf(
674
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
675
-            $registration->count(),
676
-            $registration->group_size()
677
-        );
678
-        $content .= '</span>
660
+			: $attendee_name;
661
+
662
+		$content .= $registration->count() === 1
663
+			? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
664
+			: '';
665
+
666
+		$transaction = $registration->get_first_related('Transaction');
667
+		$payment_count = $transaction instanceof EE_Transaction
668
+			? $transaction->count_related('Payment')
669
+			: 0;
670
+
671
+		// append group count to name
672
+		$content .= '<span class="reg-count-group-size">';
673
+		$content .= sprintf(
674
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
675
+			$registration->count(),
676
+			$registration->group_size()
677
+		);
678
+		$content .= '</span>
679 679
         </div>';
680 680
 
681
-        // append reg_code
682
-        $content .=  sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code'));
683
-        // reg status text for accessibility
684
-        // $content   .= '<span class="ee-status-text-small">'
685
-        //            . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence')
686
-        //            . '</span>';
687
-        $action = ['_REG_ID' => $registration->ID()];
688
-        if (isset($this->_req_data['event_id'])) {
689
-            $action['event_id'] = $registration->event_ID();
690
-        }
691
-        // trash/restore/delete actions
692
-        $actions = [];
693
-        if (
694
-            $this->_view !== 'trash'
695
-            && $payment_count === 0
696
-            && EE_Registry::instance()->CAP->current_user_can(
697
-                'ee_delete_registration',
698
-                'espresso_registrations_trash_registrations',
699
-                $registration->ID()
700
-            )
701
-        ) {
702
-            $action['action'] = 'trash_registrations';
703
-            $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
704
-                $action,
705
-                REG_ADMIN_URL
706
-            );
707
-            $actions['trash'] = '<a class="ee-aria-tooltip" href="'
708
-                                . $trash_lnk_url
709
-                                . '" aria-label="'
710
-                                . esc_attr__('Trash Registration', 'event_espresso')
711
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
712
-        } elseif ($this->_view === 'trash') {
713
-            // restore registration link
714
-            if (
715
-                EE_Registry::instance()->CAP->current_user_can(
716
-                    'ee_delete_registration',
717
-                    'espresso_registrations_restore_registrations',
718
-                    $registration->ID()
719
-                )
720
-            ) {
721
-                $action['action']   = 'restore_registrations';
722
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
723
-                    $action,
724
-                    REG_ADMIN_URL
725
-                );
726
-                $actions['restore'] = '<a class="ee-aria-tooltip" href="'
727
-                                      . $restore_lnk_url
728
-                                      . '" aria-label="'
729
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
730
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
731
-            }
732
-            if (
733
-                EE_Registry::instance()->CAP->current_user_can(
734
-                    'ee_delete_registration',
735
-                    'espresso_registrations_ee_delete_registrations',
736
-                    $registration->ID()
737
-                )
738
-            ) {
739
-                $action['action']  = 'delete_registrations';
740
-                $delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
741
-                    $action,
742
-                    REG_ADMIN_URL
743
-                );
744
-                $actions['delete'] = '<a class="ee-aria-tooltip" href="'
745
-                                     . $delete_lnk_url
746
-                                     . '" aria-label="'
747
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
748
-                                     . '">'
749
-                                     . esc_html__('Delete', 'event_espresso')
750
-                                     . '</a>';
751
-            }
752
-        }
753
-        $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
754
-        return $this->columnContent('ATT_fname', $content);
755
-    }
756
-
757
-
758
-    /**
759
-     * @param EE_Registration $registration
760
-     * @return string
761
-     * @throws EE_Error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidDataTypeException
764
-     * @throws InvalidInterfaceException
765
-     * @throws ReflectionException
766
-     */
767
-    public function column_ATT_email(EE_Registration $registration)
768
-    {
769
-        $attendee = $registration->get_first_related('Attendee');
770
-        $content = ! $attendee instanceof EE_Attendee
771
-            ? esc_html__('No attached contact record.', 'event_espresso')
772
-            : $attendee->email();
773
-        return $this->columnContent('ATT_email', $content);
774
-    }
775
-
776
-
777
-    /**
778
-     * @param EE_Registration $registration
779
-     * @return string
780
-     */
781
-    public function column__REG_count(EE_Registration $registration)
782
-    {
783
-        $content = sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
784
-        return $this->columnContent('_REG_count', $content);
785
-    }
786
-
787
-
788
-    /**
789
-     * @param EE_Registration $registration
790
-     * @return string
791
-     * @throws EE_Error
792
-     * @throws ReflectionException
793
-     */
794
-    public function column_PRC_amount(EE_Registration $registration)
795
-    {
796
-        $ticket   = $registration->ticket();
797
-        $req_data = $this->_admin_page->get_request_data();
798
-
799
-        $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
800
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
801
-            : '';
802
-
803
-        $content .= $registration->final_price() > 0
804
-            ? '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>'
805
-            // free event
806
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
807
-
808
-        return $this->columnContent('PRC_amount', $content, 'end');
809
-    }
810
-
811
-
812
-    /**
813
-     * @param EE_Registration $registration
814
-     * @return string
815
-     * @throws EE_Error
816
-     * @throws ReflectionException
817
-     */
818
-    public function column__REG_final_price(EE_Registration $registration)
819
-    {
820
-        $ticket   = $registration->ticket();
821
-        $req_data = $this->_admin_page->get_request_data();
822
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
823
-            ? ''
824
-            : '<span class="TKT_name">' . $ticket->name() . '</span> ';
825
-        $content  .= '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>';
826
-        return $this->columnContent('_REG_final_price', $content, 'end');
827
-    }
828
-
829
-
830
-    /**
831
-     * @param EE_Registration $registration
832
-     * @return string
833
-     * @throws EE_Error
834
-     */
835
-    public function column__REG_paid(EE_Registration $registration)
836
-    {
837
-        $payment_method      = $registration->payment_method();
838
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
839
-            ? $payment_method->admin_name()
840
-            : esc_html__('Unknown', 'event_espresso');
841
-        $content             =
842
-            '<span class="reg-overview-paid-event-spn">' . $registration->pretty_paid() . '</span>';
843
-        if ($registration->paid() > 0) {
844
-            $content .= '<span class="ee-status-text-small">'
845
-                        . sprintf(
846
-                            esc_html__('...via %s', 'event_espresso'),
847
-                            $payment_method_name
848
-                        )
849
-                        . '</span>';
850
-        }
851
-        return $this->columnContent('_REG_paid', $content, 'end');
852
-    }
853
-
854
-
855
-    /**
856
-     * @param EE_Registration $registration
857
-     * @return string
858
-     * @throws EE_Error
859
-     * @throws EntityNotFoundException
860
-     * @throws InvalidArgumentException
861
-     * @throws InvalidDataTypeException
862
-     * @throws InvalidInterfaceException
863
-     * @throws ReflectionException
864
-     */
865
-    public function column_TXN_total(EE_Registration $registration)
866
-    {
867
-        if ($registration->transaction()) {
868
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
869
-                [
870
-                    'action' => 'view_transaction',
871
-                    'TXN_ID' => $registration->transaction_ID(),
872
-                ],
873
-                TXN_ADMIN_URL
874
-            );
875
-            $content = EE_Registry::instance()->CAP->current_user_can(
876
-                'ee_read_transaction',
877
-                'espresso_transactions_view_transaction',
878
-                $registration->transaction_ID()
879
-            )
880
-                ? '
681
+		// append reg_code
682
+		$content .=  sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code'));
683
+		// reg status text for accessibility
684
+		// $content   .= '<span class="ee-status-text-small">'
685
+		//            . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence')
686
+		//            . '</span>';
687
+		$action = ['_REG_ID' => $registration->ID()];
688
+		if (isset($this->_req_data['event_id'])) {
689
+			$action['event_id'] = $registration->event_ID();
690
+		}
691
+		// trash/restore/delete actions
692
+		$actions = [];
693
+		if (
694
+			$this->_view !== 'trash'
695
+			&& $payment_count === 0
696
+			&& EE_Registry::instance()->CAP->current_user_can(
697
+				'ee_delete_registration',
698
+				'espresso_registrations_trash_registrations',
699
+				$registration->ID()
700
+			)
701
+		) {
702
+			$action['action'] = 'trash_registrations';
703
+			$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
704
+				$action,
705
+				REG_ADMIN_URL
706
+			);
707
+			$actions['trash'] = '<a class="ee-aria-tooltip" href="'
708
+								. $trash_lnk_url
709
+								. '" aria-label="'
710
+								. esc_attr__('Trash Registration', 'event_espresso')
711
+								. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
712
+		} elseif ($this->_view === 'trash') {
713
+			// restore registration link
714
+			if (
715
+				EE_Registry::instance()->CAP->current_user_can(
716
+					'ee_delete_registration',
717
+					'espresso_registrations_restore_registrations',
718
+					$registration->ID()
719
+				)
720
+			) {
721
+				$action['action']   = 'restore_registrations';
722
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
723
+					$action,
724
+					REG_ADMIN_URL
725
+				);
726
+				$actions['restore'] = '<a class="ee-aria-tooltip" href="'
727
+									  . $restore_lnk_url
728
+									  . '" aria-label="'
729
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
730
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
731
+			}
732
+			if (
733
+				EE_Registry::instance()->CAP->current_user_can(
734
+					'ee_delete_registration',
735
+					'espresso_registrations_ee_delete_registrations',
736
+					$registration->ID()
737
+				)
738
+			) {
739
+				$action['action']  = 'delete_registrations';
740
+				$delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
741
+					$action,
742
+					REG_ADMIN_URL
743
+				);
744
+				$actions['delete'] = '<a class="ee-aria-tooltip" href="'
745
+									 . $delete_lnk_url
746
+									 . '" aria-label="'
747
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
748
+									 . '">'
749
+									 . esc_html__('Delete', 'event_espresso')
750
+									 . '</a>';
751
+			}
752
+		}
753
+		$content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
754
+		return $this->columnContent('ATT_fname', $content);
755
+	}
756
+
757
+
758
+	/**
759
+	 * @param EE_Registration $registration
760
+	 * @return string
761
+	 * @throws EE_Error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidDataTypeException
764
+	 * @throws InvalidInterfaceException
765
+	 * @throws ReflectionException
766
+	 */
767
+	public function column_ATT_email(EE_Registration $registration)
768
+	{
769
+		$attendee = $registration->get_first_related('Attendee');
770
+		$content = ! $attendee instanceof EE_Attendee
771
+			? esc_html__('No attached contact record.', 'event_espresso')
772
+			: $attendee->email();
773
+		return $this->columnContent('ATT_email', $content);
774
+	}
775
+
776
+
777
+	/**
778
+	 * @param EE_Registration $registration
779
+	 * @return string
780
+	 */
781
+	public function column__REG_count(EE_Registration $registration)
782
+	{
783
+		$content = sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
784
+		return $this->columnContent('_REG_count', $content);
785
+	}
786
+
787
+
788
+	/**
789
+	 * @param EE_Registration $registration
790
+	 * @return string
791
+	 * @throws EE_Error
792
+	 * @throws ReflectionException
793
+	 */
794
+	public function column_PRC_amount(EE_Registration $registration)
795
+	{
796
+		$ticket   = $registration->ticket();
797
+		$req_data = $this->_admin_page->get_request_data();
798
+
799
+		$content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
800
+			? '<div class="TKT_name">' . $ticket->name() . '</div>'
801
+			: '';
802
+
803
+		$content .= $registration->final_price() > 0
804
+			? '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>'
805
+			// free event
806
+			: '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
807
+
808
+		return $this->columnContent('PRC_amount', $content, 'end');
809
+	}
810
+
811
+
812
+	/**
813
+	 * @param EE_Registration $registration
814
+	 * @return string
815
+	 * @throws EE_Error
816
+	 * @throws ReflectionException
817
+	 */
818
+	public function column__REG_final_price(EE_Registration $registration)
819
+	{
820
+		$ticket   = $registration->ticket();
821
+		$req_data = $this->_admin_page->get_request_data();
822
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
823
+			? ''
824
+			: '<span class="TKT_name">' . $ticket->name() . '</span> ';
825
+		$content  .= '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>';
826
+		return $this->columnContent('_REG_final_price', $content, 'end');
827
+	}
828
+
829
+
830
+	/**
831
+	 * @param EE_Registration $registration
832
+	 * @return string
833
+	 * @throws EE_Error
834
+	 */
835
+	public function column__REG_paid(EE_Registration $registration)
836
+	{
837
+		$payment_method      = $registration->payment_method();
838
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
839
+			? $payment_method->admin_name()
840
+			: esc_html__('Unknown', 'event_espresso');
841
+		$content             =
842
+			'<span class="reg-overview-paid-event-spn">' . $registration->pretty_paid() . '</span>';
843
+		if ($registration->paid() > 0) {
844
+			$content .= '<span class="ee-status-text-small">'
845
+						. sprintf(
846
+							esc_html__('...via %s', 'event_espresso'),
847
+							$payment_method_name
848
+						)
849
+						. '</span>';
850
+		}
851
+		return $this->columnContent('_REG_paid', $content, 'end');
852
+	}
853
+
854
+
855
+	/**
856
+	 * @param EE_Registration $registration
857
+	 * @return string
858
+	 * @throws EE_Error
859
+	 * @throws EntityNotFoundException
860
+	 * @throws InvalidArgumentException
861
+	 * @throws InvalidDataTypeException
862
+	 * @throws InvalidInterfaceException
863
+	 * @throws ReflectionException
864
+	 */
865
+	public function column_TXN_total(EE_Registration $registration)
866
+	{
867
+		if ($registration->transaction()) {
868
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
869
+				[
870
+					'action' => 'view_transaction',
871
+					'TXN_ID' => $registration->transaction_ID(),
872
+				],
873
+				TXN_ADMIN_URL
874
+			);
875
+			$content = EE_Registry::instance()->CAP->current_user_can(
876
+				'ee_read_transaction',
877
+				'espresso_transactions_view_transaction',
878
+				$registration->transaction_ID()
879
+			)
880
+				? '
881 881
                     <a class="ee-aria-tooltip status-' . $registration->transaction()->status_ID() . '" 
882 882
                         href="' . $view_txn_lnk_url . '" 
883 883
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
884 884
                     >
885 885
                         ' . $registration->transaction()->pretty_total() . '
886 886
                     </a>'
887
-                : $registration->transaction()->pretty_total();
888
-        } else {
889
-            $content = esc_html__("None", "event_espresso");
890
-        }
891
-        return $this->columnContent('TXN_total', $content, 'end');
892
-    }
893
-
894
-
895
-    /**
896
-     * @param EE_Registration $registration
897
-     * @return string
898
-     * @throws EE_Error
899
-     * @throws EntityNotFoundException
900
-     * @throws InvalidArgumentException
901
-     * @throws InvalidDataTypeException
902
-     * @throws InvalidInterfaceException
903
-     * @throws ReflectionException
904
-     */
905
-    public function column_TXN_paid(EE_Registration $registration)
906
-    {
907
-        $content = '&nbsp;';
908
-        $align = 'end';
909
-        if ($registration->count() === 1) {
910
-            $transaction = $registration->transaction()
911
-                ? $registration->transaction()
912
-                : EE_Transaction::new_instance();
913
-            if ($transaction->paid() >= $transaction->total()) {
914
-                $align = 'center';
915
-                $content = '<span class="dashicons dashicons-yes green-icon"></span>';
916
-            } else {
917
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
918
-                    [
919
-                        'action' => 'view_transaction',
920
-                        'TXN_ID' => $registration->transaction_ID(),
921
-                    ],
922
-                    TXN_ADMIN_URL
923
-                );
924
-                $content = EE_Registry::instance()->CAP->current_user_can(
925
-                    'ee_read_transaction',
926
-                    'espresso_transactions_view_transaction',
927
-                    $registration->transaction_ID()
928
-                )
929
-                    ? '
887
+				: $registration->transaction()->pretty_total();
888
+		} else {
889
+			$content = esc_html__("None", "event_espresso");
890
+		}
891
+		return $this->columnContent('TXN_total', $content, 'end');
892
+	}
893
+
894
+
895
+	/**
896
+	 * @param EE_Registration $registration
897
+	 * @return string
898
+	 * @throws EE_Error
899
+	 * @throws EntityNotFoundException
900
+	 * @throws InvalidArgumentException
901
+	 * @throws InvalidDataTypeException
902
+	 * @throws InvalidInterfaceException
903
+	 * @throws ReflectionException
904
+	 */
905
+	public function column_TXN_paid(EE_Registration $registration)
906
+	{
907
+		$content = '&nbsp;';
908
+		$align = 'end';
909
+		if ($registration->count() === 1) {
910
+			$transaction = $registration->transaction()
911
+				? $registration->transaction()
912
+				: EE_Transaction::new_instance();
913
+			if ($transaction->paid() >= $transaction->total()) {
914
+				$align = 'center';
915
+				$content = '<span class="dashicons dashicons-yes green-icon"></span>';
916
+			} else {
917
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
918
+					[
919
+						'action' => 'view_transaction',
920
+						'TXN_ID' => $registration->transaction_ID(),
921
+					],
922
+					TXN_ADMIN_URL
923
+				);
924
+				$content = EE_Registry::instance()->CAP->current_user_can(
925
+					'ee_read_transaction',
926
+					'espresso_transactions_view_transaction',
927
+					$registration->transaction_ID()
928
+				)
929
+					? '
930 930
                     <a class="ee-aria-tooltip status-' . $transaction->status_ID() . '" 
931 931
                         href="' . $view_txn_lnk_url . '"  
932 932
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
933 933
                     >
934 934
                         ' . $registration->transaction()->pretty_paid() . '
935 935
                     </a>'
936
-                    :  $registration->transaction()->pretty_paid();
937
-            }
938
-        }
939
-        return $this->columnContent('TXN_paid', $content, $align);
940
-    }
941
-
942
-
943
-    /**
944
-     * @param EE_Registration $registration
945
-     * @return string
946
-     * @throws EE_Error
947
-     * @throws InvalidArgumentException
948
-     * @throws InvalidDataTypeException
949
-     * @throws InvalidInterfaceException
950
-     * @throws ReflectionException
951
-     */
952
-    public function column_actions(EE_Registration $registration)
953
-    {
954
-        $actions  = [];
955
-        $attendee = $registration->attendee();
956
-        $this->_set_related_details($registration);
957
-
958
-        // Build row actions
959
-        if (
960
-            EE_Registry::instance()->CAP->current_user_can(
961
-                'ee_read_registration',
962
-                'espresso_registrations_view_registration',
963
-                $registration->ID()
964
-            )
965
-        ) {
966
-            $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
967
-                [
968
-                    'action'  => 'view_registration',
969
-                    '_REG_ID' => $registration->ID(),
970
-                ],
971
-                REG_ADMIN_URL
972
-            );
973
-            $actions['view_lnk'] = '
936
+					:  $registration->transaction()->pretty_paid();
937
+			}
938
+		}
939
+		return $this->columnContent('TXN_paid', $content, $align);
940
+	}
941
+
942
+
943
+	/**
944
+	 * @param EE_Registration $registration
945
+	 * @return string
946
+	 * @throws EE_Error
947
+	 * @throws InvalidArgumentException
948
+	 * @throws InvalidDataTypeException
949
+	 * @throws InvalidInterfaceException
950
+	 * @throws ReflectionException
951
+	 */
952
+	public function column_actions(EE_Registration $registration)
953
+	{
954
+		$actions  = [];
955
+		$attendee = $registration->attendee();
956
+		$this->_set_related_details($registration);
957
+
958
+		// Build row actions
959
+		if (
960
+			EE_Registry::instance()->CAP->current_user_can(
961
+				'ee_read_registration',
962
+				'espresso_registrations_view_registration',
963
+				$registration->ID()
964
+			)
965
+		) {
966
+			$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
967
+				[
968
+					'action'  => 'view_registration',
969
+					'_REG_ID' => $registration->ID(),
970
+				],
971
+				REG_ADMIN_URL
972
+			);
973
+			$actions['view_lnk'] = '
974 974
                 <a href="' . $view_lnk_url . '" aria-label="'
975
-                . esc_attr__('View Registration Details', 'event_espresso')
976
-                . '" class="ee-aria-tooltip button button--small button--icon-only">
975
+				. esc_attr__('View Registration Details', 'event_espresso')
976
+				. '" class="ee-aria-tooltip button button--small button--icon-only">
977 977
 				    <span class="dashicons dashicons-clipboard"></span>
978 978
 			    </a>';
979
-        }
980
-
981
-        if (
982
-            $attendee instanceof EE_Attendee
983
-            && EE_Registry::instance()->CAP->current_user_can(
984
-                'ee_edit_contacts',
985
-                'espresso_registrations_edit_attendee'
986
-            )
987
-        ) {
988
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
989
-                [
990
-                    'action' => 'edit_attendee',
991
-                    'post'   => $registration->attendee_ID(),
992
-                ],
993
-                REG_ADMIN_URL
994
-            );
995
-            $actions['edit_lnk'] = '
979
+		}
980
+
981
+		if (
982
+			$attendee instanceof EE_Attendee
983
+			&& EE_Registry::instance()->CAP->current_user_can(
984
+				'ee_edit_contacts',
985
+				'espresso_registrations_edit_attendee'
986
+			)
987
+		) {
988
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
989
+				[
990
+					'action' => 'edit_attendee',
991
+					'post'   => $registration->attendee_ID(),
992
+				],
993
+				REG_ADMIN_URL
994
+			);
995
+			$actions['edit_lnk'] = '
996 996
                 <a href="' . $edit_lnk_url . '" aria-label="'
997
-                . esc_attr__('Edit Contact Details', 'event_espresso')
998
-                . '" class="ee-aria-tooltip button button--small button--icon-only">
997
+				. esc_attr__('Edit Contact Details', 'event_espresso')
998
+				. '" class="ee-aria-tooltip button button--small button--icon-only">
999 999
                     <span class="dashicons dashicons-groups"></span>
1000 1000
                 </a>';
1001
-        }
1002
-
1003
-        if (
1004
-            $attendee instanceof EE_Attendee
1005
-            && EE_Registry::instance()->CAP->current_user_can(
1006
-                'ee_send_message',
1007
-                'espresso_registrations_resend_registration',
1008
-                $registration->ID()
1009
-            )
1010
-        ) {
1011
-            $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1012
-                [
1013
-                    'action'  => 'resend_registration',
1014
-                    '_REG_ID' => $registration->ID(),
1015
-                ],
1016
-                REG_ADMIN_URL,
1017
-                true
1018
-            );
1019
-            $actions['resend_reg_lnk'] = '
1001
+		}
1002
+
1003
+		if (
1004
+			$attendee instanceof EE_Attendee
1005
+			&& EE_Registry::instance()->CAP->current_user_can(
1006
+				'ee_send_message',
1007
+				'espresso_registrations_resend_registration',
1008
+				$registration->ID()
1009
+			)
1010
+		) {
1011
+			$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1012
+				[
1013
+					'action'  => 'resend_registration',
1014
+					'_REG_ID' => $registration->ID(),
1015
+				],
1016
+				REG_ADMIN_URL,
1017
+				true
1018
+			);
1019
+			$actions['resend_reg_lnk'] = '
1020 1020
 			    <a href="' . $resend_reg_lnk_url . '" aria-label="'
1021
-                . esc_attr__('Resend Registration Details', 'event_espresso')
1022
-                . '" class="ee-aria-tooltip button button--small button--icon-only">
1021
+				. esc_attr__('Resend Registration Details', 'event_espresso')
1022
+				. '" class="ee-aria-tooltip button button--small button--icon-only">
1023 1023
 			        <span class="dashicons dashicons-email-alt"></span>
1024 1024
 			    </a>';
1025
-        }
1026
-
1027
-        if (
1028
-            EE_Registry::instance()->CAP->current_user_can(
1029
-                'ee_read_transaction',
1030
-                'espresso_transactions_view_transaction',
1031
-                $this->_transaction_details['id']
1032
-            )
1033
-        ) {
1034
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1035
-                [
1036
-                    'action' => 'view_transaction',
1037
-                    'TXN_ID' => $this->_transaction_details['id'],
1038
-                ],
1039
-                TXN_ADMIN_URL
1040
-            );
1041
-            $actions['view_txn_lnk'] = '
1025
+		}
1026
+
1027
+		if (
1028
+			EE_Registry::instance()->CAP->current_user_can(
1029
+				'ee_read_transaction',
1030
+				'espresso_transactions_view_transaction',
1031
+				$this->_transaction_details['id']
1032
+			)
1033
+		) {
1034
+			$view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1035
+				[
1036
+					'action' => 'view_transaction',
1037
+					'TXN_ID' => $this->_transaction_details['id'],
1038
+				],
1039
+				TXN_ADMIN_URL
1040
+			);
1041
+			$actions['view_txn_lnk'] = '
1042 1042
                 <a class="ee-aria-tooltip ee-status-color-' . $this->_transaction_details['status']
1043
-                . ' button button--small button--icon-only" href="' . $view_txn_lnk_url
1044
-                . '"  aria-label="' . $this->_transaction_details['title_attr'] . '">
1043
+				. ' button button--small button--icon-only" href="' . $view_txn_lnk_url
1044
+				. '"  aria-label="' . $this->_transaction_details['title_attr'] . '">
1045 1045
                     <span class="dashicons dashicons-cart"></span>
1046 1046
                 </a>';
1047
-        }
1048
-
1049
-        // only show invoice link if message type is active.
1050
-        if (
1051
-            $attendee instanceof EE_Attendee
1052
-            && $registration->is_primary_registrant()
1053
-            && EEH_MSG_Template::is_mt_active('invoice')
1054
-        ) {
1055
-            $actions['dl_invoice_lnk'] = '
1047
+		}
1048
+
1049
+		// only show invoice link if message type is active.
1050
+		if (
1051
+			$attendee instanceof EE_Attendee
1052
+			&& $registration->is_primary_registrant()
1053
+			&& EEH_MSG_Template::is_mt_active('invoice')
1054
+		) {
1055
+			$actions['dl_invoice_lnk'] = '
1056 1056
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1057
-                . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--small button--icon-only">
1057
+				. '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--small button--icon-only">
1058 1058
                     <span class="dashicons dashicons-media-spreadsheet"></span>
1059 1059
                 </a>';
1060
-        }
1060
+		}
1061 1061
 
1062
-        // message list table link (filtered by REG_ID
1063
-        if (
1064
-            EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1065
-        ) {
1066
-            $actions['filtered_messages_link'] = '
1062
+		// message list table link (filtered by REG_ID
1063
+		if (
1064
+			EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1065
+		) {
1066
+			$actions['filtered_messages_link'] = '
1067 1067
                 ' . EEH_MSG_Template::get_message_action_link(
1068
-                'see_notifications_for',
1069
-                null,
1070
-                ['_REG_ID' => $registration->ID()]
1071
-            );
1072
-        }
1073
-
1074
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $registration, $this);
1075
-        $content = $this->_action_string(
1076
-            implode('', $actions),
1077
-            $registration,
1078
-            'div',
1079
-            'reg-overview-actions ee-list-table-actions'
1080
-        );
1081
-        return $this->columnContent('actions', $this->actionsModalMenu($content));
1082
-    }
1068
+				'see_notifications_for',
1069
+				null,
1070
+				['_REG_ID' => $registration->ID()]
1071
+			);
1072
+		}
1073
+
1074
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $registration, $this);
1075
+		$content = $this->_action_string(
1076
+			implode('', $actions),
1077
+			$registration,
1078
+			'div',
1079
+			'reg-overview-actions ee-list-table-actions'
1080
+		);
1081
+		return $this->columnContent('actions', $this->actionsModalMenu($content));
1082
+	}
1083 1083
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
     public function __construct(Registrations_Admin_Page $admin_page)
49 49
     {
50 50
         $req_data = $admin_page->get_request_data();
51
-        if (! empty($req_data['event_id'])) {
51
+        if ( ! empty($req_data['event_id'])) {
52 52
             $extra_query_args = [];
53 53
             foreach ($admin_page->get_views() as $view_details) {
54
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
54
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
55 55
             }
56 56
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57 57
         }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
             'ajax'     => true,
84 84
             'screen'   => $this->_admin_page->get_current_screen()->id,
85 85
         ];
86
-        $req_data            = $this->_admin_page->get_request_data();
86
+        $req_data = $this->_admin_page->get_request_data();
87 87
         if (isset($req_data['event_id'])) {
88
-            $this->_columns        = [
88
+            $this->_columns = [
89 89
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
90 90
                 'id'          => esc_html__('ID', 'event_espresso'),
91 91
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 ],
108 108
             ];
109 109
         } else {
110
-            $this->_columns        = [
110
+            $this->_columns = [
111 111
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
112 112
                 'id'          => esc_html__('ID', 'event_espresso'),
113 113
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 'return_url'  => $return_url,
135 135
             ],
136 136
         ];
137
-        $filters                                  = array_diff_key(
137
+        $filters = array_diff_key(
138 138
             $this->_req_data,
139 139
             array_flip(
140 140
                 [
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
                 ]
145 145
             )
146 146
         );
147
-        if (! empty($filters)) {
147
+        if ( ! empty($filters)) {
148 148
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
149 149
         }
150 150
         $this->_primary_column   = 'id';
151 151
         $this->_sortable_columns = [
152
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
152
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
153 153
             /**
154 154
              * Allows users to change the default sort if they wish.
155 155
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
167 167
             'id'       => ['REG_ID' => false],
168 168
         ];
169
-        $this->_hidden_columns   = [];
169
+        $this->_hidden_columns = [];
170 170
     }
171 171
 
172 172
 
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
         $this_month_r    = date('m', current_time('timestamp'));
354 354
         $days_this_month = date('t', current_time('timestamp'));
355 355
         // setup date query.
356
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
356
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
357 357
             'REG_date',
358
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
358
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
359 359
             'Y-m-d H:i:s'
360 360
         );
361
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
361
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
362 362
             'REG_date',
363
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
363
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
364 364
             'Y-m-d H:i:s'
365 365
         );
366 366
         $_where['REG_date'] = [
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                 $end_string,
371 371
             ],
372 372
         ];
373
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
373
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
374 374
         return EEM_Registration::instance()->count([$_where]);
375 375
     }
376 376
 
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
             [
399 399
                 EEM_Registration::instance()->convert_datetime_for_query(
400 400
                     'REG_date',
401
-                    $current_date . $time_start,
401
+                    $current_date.$time_start,
402 402
                     'Y-m-d H:i:s'
403 403
                 ),
404 404
                 EEM_Registration::instance()->convert_datetime_for_query(
405 405
                     'REG_date',
406
-                    $current_date . $time_end,
406
+                    $current_date.$time_end,
407 407
                     'Y-m-d H:i:s'
408 408
                 ),
409 409
             ],
410 410
         ];
411
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
411
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
412 412
         return EEM_Registration::instance()->count([$_where]);
413 413
     }
414 414
 
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
             'registration_list_table_checkbox_input',
436 436
             $REG_ID
437 437
         )
438
-            ? '<input disabled type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" /><span class="dashicons dashicons-lock"></span>'
439
-            : '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
438
+            ? '<input disabled type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" /><span class="dashicons dashicons-lock"></span>'
439
+            : '<input type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" />';
440 440
 
441 441
         return $this->columnContent('cb', $content, 'center');
442 442
     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         $attendee = $registration->attendee();
458 458
 
459 459
         $content .= '<span class="show-on-mobile-view-only">';
460
-        $content  .= $attendee instanceof EE_Attendee
460
+        $content .= $attendee instanceof EE_Attendee
461 461
             ? $attendee->full_name()
462 462
             : '';
463 463
 
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
             ],
486 486
             TXN_ADMIN_URL
487 487
         );
488
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
488
+        $view_link = EE_Registry::instance()->CAP->current_user_can(
489 489
             'ee_read_transaction',
490 490
             'espresso_transactions_view_transaction'
491 491
         )
492
-            ? '<a class="ee-aria-tooltip ee-status-color-' . $this->_transaction_details['status'] . '" href="'
492
+            ? '<a class="ee-aria-tooltip ee-status-color-'.$this->_transaction_details['status'].'" href="'
493 493
               . $view_lnk_url
494 494
               . '" aria-label="'
495 495
               . esc_attr($this->_transaction_details['title_attr'])
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
               . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
498 498
               . '</a>'
499 499
             : $registration->get_i18n_datetime('REG_date');
500
-        $view_link    .= ' <span class="ee-status-text-small">'
500
+        $view_link .= ' <span class="ee-status-text-small">'
501 501
                          . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
502 502
                          . '</span>';
503 503
 
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
                 ?: esc_html__("No Associated Event", 'event_espresso');
526 526
         $event_name = wp_trim_words($event_name, 30, '...');
527 527
         if ($EVT_ID) {
528
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
528
+            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
529 529
                 ['action' => 'edit', 'post' => $EVT_ID],
530 530
                 EVENTS_ADMIN_URL
531 531
             );
532
-            $edit_event              =
532
+            $edit_event =
533 533
                 EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
534 534
                     ? '<a class="ee-aria-tooltip ee-status-color-'
535 535
                       . $this->_event_details['status']
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
                       . '</a>'
543 543
                     : $event_name;
544 544
             $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
545
-            $actions['event_filter'] = '<a class="ee-aria-tooltip" href="' . $edit_event_url . '" aria-label="';
545
+            $actions['event_filter'] = '<a class="ee-aria-tooltip" href="'.$edit_event_url.'" aria-label="';
546 546
             $actions['event_filter'] .= sprintf(
547 547
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
548 548
                 $event_name
549 549
             );
550
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
550
+            $actions['event_filter'] .= '">'.esc_html__('View Registrations', 'event_espresso').'</a>';
551 551
         } else {
552 552
             $edit_event              = $event_name;
553 553
             $actions['event_filter'] = '';
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
     {
596 596
         $content       = '<div class="ee-registration-event-datetimes-container">';
597 597
         $expand_toggle = count($datetime_strings) > 1
598
-            ? ' <span aria-label="' . esc_attr__('Click to view all dates', 'event_espresso')
598
+            ? ' <span aria-label="'.esc_attr__('Click to view all dates', 'event_espresso')
599 599
               . '" class="ee-aria-tooltip ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
600 600
             : '';
601 601
         // get first item for initial visibility
602
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
602
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
603 603
         $content .= $expand_toggle;
604 604
         if ($datetime_strings) {
605 605
             $content .= '<div style="clear:both"></div>';
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 
642 642
         $content       = '
643 643
         <div class="ee-layout-row">
644
-            <span aria-label="' . $pretty_status . '" 
645
-                  class="ee-status-dot ee-status-dot--' . $status . ' ee-aria-tooltip"
644
+            <span aria-label="' . $pretty_status.'" 
645
+                  class="ee-status-dot ee-status-dot--' . $status.' ee-aria-tooltip"
646 646
             ></span>';
647 647
 
648 648
         $content .= EE_Registry::instance()->CAP->current_user_can(
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
             $registration->ID()
652 652
         )
653 653
             ? '
654
-            <a  href="' . $edit_lnk_url . '"  
655
-                class="row-title status-' . $status . ' ee-aria-tooltip" 
656
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
654
+            <a  href="' . $edit_lnk_url.'"  
655
+                class="row-title status-' . $status.' ee-aria-tooltip" 
656
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
657 657
             >
658
-                ' . $attendee_name . '
658
+                ' . $attendee_name.'
659 659
             </a>'
660 660
             : $attendee_name;
661 661
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
         </div>';
680 680
 
681 681
         // append reg_code
682
-        $content .=  sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code'));
682
+        $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $registration->get('REG_code'));
683 683
         // reg status text for accessibility
684 684
         // $content   .= '<span class="ee-status-text-small">'
685 685
         //            . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence')
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
                                 . $trash_lnk_url
709 709
                                 . '" aria-label="'
710 710
                                 . esc_attr__('Trash Registration', 'event_espresso')
711
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
711
+                                . '">'.esc_html__('Trash', 'event_espresso').'</a>';
712 712
         } elseif ($this->_view === 'trash') {
713 713
             // restore registration link
714 714
             if (
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
                 $actions['restore'] = '<a class="ee-aria-tooltip" href="'
727 727
                                       . $restore_lnk_url
728 728
                                       . '" aria-label="'
729
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
730
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
729
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
730
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
731 731
             }
732 732
             if (
733 733
                 EE_Registry::instance()->CAP->current_user_can(
@@ -797,13 +797,13 @@  discard block
 block discarded – undo
797 797
         $req_data = $this->_admin_page->get_request_data();
798 798
 
799 799
         $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
800
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
800
+            ? '<div class="TKT_name">'.$ticket->name().'</div>'
801 801
             : '';
802 802
 
803 803
         $content .= $registration->final_price() > 0
804
-            ? '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>'
804
+            ? '<span class="reg-overview-paid-event-spn">'.$registration->pretty_final_price().'</span>'
805 805
             // free event
806
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
806
+            : '<span class="reg-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
807 807
 
808 808
         return $this->columnContent('PRC_amount', $content, 'end');
809 809
     }
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
         $req_data = $this->_admin_page->get_request_data();
822 822
         $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
823 823
             ? ''
824
-            : '<span class="TKT_name">' . $ticket->name() . '</span> ';
825
-        $content  .= '<span class="reg-overview-paid-event-spn">' . $registration->pretty_final_price() . '</span>';
824
+            : '<span class="TKT_name">'.$ticket->name().'</span> ';
825
+        $content .= '<span class="reg-overview-paid-event-spn">'.$registration->pretty_final_price().'</span>';
826 826
         return $this->columnContent('_REG_final_price', $content, 'end');
827 827
     }
828 828
 
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
             ? $payment_method->admin_name()
840 840
             : esc_html__('Unknown', 'event_espresso');
841 841
         $content             =
842
-            '<span class="reg-overview-paid-event-spn">' . $registration->pretty_paid() . '</span>';
842
+            '<span class="reg-overview-paid-event-spn">'.$registration->pretty_paid().'</span>';
843 843
         if ($registration->paid() > 0) {
844 844
             $content .= '<span class="ee-status-text-small">'
845 845
                         . sprintf(
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
                 $registration->transaction_ID()
879 879
             )
880 880
                 ? '
881
-                    <a class="ee-aria-tooltip status-' . $registration->transaction()->status_ID() . '" 
882
-                        href="' . $view_txn_lnk_url . '" 
883
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
881
+                    <a class="ee-aria-tooltip status-' . $registration->transaction()->status_ID().'" 
882
+                        href="' . $view_txn_lnk_url.'" 
883
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
884 884
                     >
885
-                        ' . $registration->transaction()->pretty_total() . '
885
+                        ' . $registration->transaction()->pretty_total().'
886 886
                     </a>'
887 887
                 : $registration->transaction()->pretty_total();
888 888
         } else {
@@ -927,11 +927,11 @@  discard block
 block discarded – undo
927 927
                     $registration->transaction_ID()
928 928
                 )
929 929
                     ? '
930
-                    <a class="ee-aria-tooltip status-' . $transaction->status_ID() . '" 
931
-                        href="' . $view_txn_lnk_url . '"  
932
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
930
+                    <a class="ee-aria-tooltip status-' . $transaction->status_ID().'" 
931
+                        href="' . $view_txn_lnk_url.'"  
932
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
933 933
                     >
934
-                        ' . $registration->transaction()->pretty_paid() . '
934
+                        ' . $registration->transaction()->pretty_paid().'
935 935
                     </a>'
936 936
                     :  $registration->transaction()->pretty_paid();
937 937
             }
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
                 REG_ADMIN_URL
972 972
             );
973 973
             $actions['view_lnk'] = '
974
-                <a href="' . $view_lnk_url . '" aria-label="'
974
+                <a href="' . $view_lnk_url.'" aria-label="'
975 975
                 . esc_attr__('View Registration Details', 'event_espresso')
976 976
                 . '" class="ee-aria-tooltip button button--small button--icon-only">
977 977
 				    <span class="dashicons dashicons-clipboard"></span>
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
                 REG_ADMIN_URL
994 994
             );
995 995
             $actions['edit_lnk'] = '
996
-                <a href="' . $edit_lnk_url . '" aria-label="'
996
+                <a href="' . $edit_lnk_url.'" aria-label="'
997 997
                 . esc_attr__('Edit Contact Details', 'event_espresso')
998 998
                 . '" class="ee-aria-tooltip button button--small button--icon-only">
999 999
                     <span class="dashicons dashicons-groups"></span>
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
                 true
1018 1018
             );
1019 1019
             $actions['resend_reg_lnk'] = '
1020
-			    <a href="' . $resend_reg_lnk_url . '" aria-label="'
1020
+			    <a href="' . $resend_reg_lnk_url.'" aria-label="'
1021 1021
                 . esc_attr__('Resend Registration Details', 'event_espresso')
1022 1022
                 . '" class="ee-aria-tooltip button button--small button--icon-only">
1023 1023
 			        <span class="dashicons dashicons-email-alt"></span>
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
                 $this->_transaction_details['id']
1032 1032
             )
1033 1033
         ) {
1034
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1034
+            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1035 1035
                 [
1036 1036
                     'action' => 'view_transaction',
1037 1037
                     'TXN_ID' => $this->_transaction_details['id'],
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
             );
1041 1041
             $actions['view_txn_lnk'] = '
1042 1042
                 <a class="ee-aria-tooltip ee-status-color-' . $this->_transaction_details['status']
1043
-                . ' button button--small button--icon-only" href="' . $view_txn_lnk_url
1044
-                . '"  aria-label="' . $this->_transaction_details['title_attr'] . '">
1043
+                . ' button button--small button--icon-only" href="'.$view_txn_lnk_url
1044
+                . '"  aria-label="'.$this->_transaction_details['title_attr'].'">
1045 1045
                     <span class="dashicons dashicons-cart"></span>
1046 1046
                 </a>';
1047 1047
         }
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
         ) {
1055 1055
             $actions['dl_invoice_lnk'] = '
1056 1056
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1057
-                . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--small button--icon-only">
1057
+                . '" target="_blank" href="'.$registration->invoice_url().'" class="ee-aria-tooltip button button--small button--icon-only">
1058 1058
                     <span class="dashicons dashicons-media-spreadsheet"></span>
1059 1059
                 </a>';
1060 1060
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4161 added lines, -4161 removed lines patch added patch discarded remove patch
@@ -19,4242 +19,4242 @@
 block discarded – undo
19 19
  */
20 20
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
21 21
 {
22
-    /**
23
-     * @var EE_Admin_Config
24
-     */
25
-    protected $admin_config;
22
+	/**
23
+	 * @var EE_Admin_Config
24
+	 */
25
+	protected $admin_config;
26 26
 
27
-    /**
28
-     * @var LoaderInterface
29
-     */
30
-    protected $loader;
27
+	/**
28
+	 * @var LoaderInterface
29
+	 */
30
+	protected $loader;
31 31
 
32
-    /**
33
-     * @var RequestInterface
34
-     */
35
-    protected $request;
32
+	/**
33
+	 * @var RequestInterface
34
+	 */
35
+	protected $request;
36 36
 
37
-    // set in _init_page_props()
38
-    public $page_slug;
37
+	// set in _init_page_props()
38
+	public $page_slug;
39 39
 
40
-    public $page_label;
40
+	public $page_label;
41 41
 
42
-    public $page_folder;
42
+	public $page_folder;
43 43
 
44
-    // set in define_page_props()
45
-    protected $_admin_base_url;
44
+	// set in define_page_props()
45
+	protected $_admin_base_url;
46 46
 
47
-    protected $_admin_base_path;
47
+	protected $_admin_base_path;
48 48
 
49
-    protected $_admin_page_title;
49
+	protected $_admin_page_title;
50 50
 
51
-    protected $_labels;
51
+	protected $_labels;
52 52
 
53 53
 
54
-    // set early within EE_Admin_Init
55
-    protected $_wp_page_slug;
54
+	// set early within EE_Admin_Init
55
+	protected $_wp_page_slug;
56 56
 
57
-    // nav tabs
58
-    protected $_nav_tabs;
57
+	// nav tabs
58
+	protected $_nav_tabs;
59 59
 
60
-    protected $_default_nav_tab_name;
60
+	protected $_default_nav_tab_name;
61 61
 
62
-    /**
63
-     * @var array $_help_tour
64
-     */
65
-    protected $_help_tour = [];
62
+	/**
63
+	 * @var array $_help_tour
64
+	 */
65
+	protected $_help_tour = [];
66 66
 
67 67
 
68
-    // template variables (used by templates)
69
-    protected $_template_path;
68
+	// template variables (used by templates)
69
+	protected $_template_path;
70 70
 
71
-    protected $_column_template_path;
71
+	protected $_column_template_path;
72 72
 
73
-    /**
74
-     * @var array $_template_args
75
-     */
76
-    protected $_template_args = [];
73
+	/**
74
+	 * @var array $_template_args
75
+	 */
76
+	protected $_template_args = [];
77 77
 
78
-    /**
79
-     * this will hold the list table object for a given view.
80
-     *
81
-     * @var EE_Admin_List_Table $_list_table_object
82
-     */
83
-    protected $_list_table_object;
78
+	/**
79
+	 * this will hold the list table object for a given view.
80
+	 *
81
+	 * @var EE_Admin_List_Table $_list_table_object
82
+	 */
83
+	protected $_list_table_object;
84 84
 
85
-    // boolean
86
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
85
+	// boolean
86
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
87 87
 
88
-    protected $_routing;
88
+	protected $_routing;
89 89
 
90
-    // list table args
91
-    protected $_view;
90
+	// list table args
91
+	protected $_view;
92 92
 
93
-    protected $_views;
93
+	protected $_views;
94 94
 
95 95
 
96
-    // action => method pairs used for routing incoming requests
97
-    protected $_page_routes;
96
+	// action => method pairs used for routing incoming requests
97
+	protected $_page_routes;
98 98
 
99
-    /**
100
-     * @var array $_page_config
101
-     */
102
-    protected $_page_config;
99
+	/**
100
+	 * @var array $_page_config
101
+	 */
102
+	protected $_page_config;
103 103
 
104
-    /**
105
-     * the current page route and route config
106
-     *
107
-     * @var string $_route
108
-     */
109
-    protected $_route;
104
+	/**
105
+	 * the current page route and route config
106
+	 *
107
+	 * @var string $_route
108
+	 */
109
+	protected $_route;
110 110
 
111
-    /**
112
-     * @var string $_cpt_route
113
-     */
114
-    protected $_cpt_route;
111
+	/**
112
+	 * @var string $_cpt_route
113
+	 */
114
+	protected $_cpt_route;
115 115
 
116
-    /**
117
-     * @var array $_route_config
118
-     */
119
-    protected $_route_config;
116
+	/**
117
+	 * @var array $_route_config
118
+	 */
119
+	protected $_route_config;
120 120
 
121
-    /**
122
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
123
-     * actions.
124
-     *
125
-     * @since 4.6.x
126
-     * @var array.
127
-     */
128
-    protected $_default_route_query_args;
121
+	/**
122
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
123
+	 * actions.
124
+	 *
125
+	 * @since 4.6.x
126
+	 * @var array.
127
+	 */
128
+	protected $_default_route_query_args;
129 129
 
130
-    // set via request page and action args.
131
-    protected $_current_page;
132
-
133
-    protected $_current_view;
130
+	// set via request page and action args.
131
+	protected $_current_page;
132
+
133
+	protected $_current_view;
134 134
 
135
-    protected $_current_page_view_url;
135
+	protected $_current_page_view_url;
136 136
 
137
-    /**
138
-     * unprocessed value for the 'action' request param (default '')
139
-     *
140
-     * @var string
141
-     */
142
-    protected $raw_req_action = '';
143
-
144
-    /**
145
-     * unprocessed value for the 'page' request param (default '')
146
-     *
147
-     * @var string
148
-     */
149
-    protected $raw_req_page = '';
150
-
151
-    /**
152
-     * sanitized request action (and nonce)
153
-     *
154
-     * @var string
155
-     */
156
-    protected $_req_action = '';
157
-
158
-    /**
159
-     * sanitized request action nonce
160
-     *
161
-     * @var string
162
-     */
163
-    protected $_req_nonce = '';
164
-
165
-    /**
166
-     * @var string
167
-     */
168
-    protected $_search_btn_label = '';
169
-
170
-    /**
171
-     * @var string
172
-     */
173
-    protected $_search_box_callback = '';
174
-
175
-    /**
176
-     * @var WP_Screen
177
-     */
178
-    protected $_current_screen;
179
-
180
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
181
-    protected $_hook_obj;
182
-
183
-    // for holding incoming request data
184
-    protected $_req_data = [];
185
-
186
-    // yes / no array for admin form fields
187
-    protected $_yes_no_values = [];
188
-
189
-    // some default things shared by all child classes
190
-    protected $_default_espresso_metaboxes;
191
-
192
-    /**
193
-     * @var EE_Registry
194
-     */
195
-    protected $EE;
196
-
197
-
198
-    /**
199
-     * This is just a property that flags whether the given route is a caffeinated route or not.
200
-     *
201
-     * @var boolean
202
-     */
203
-    protected $_is_caf = false;
204
-
205
-    /**
206
-     * whether or not initializePage() has run
207
-     *
208
-     * @var boolean
209
-     */
210
-    protected $initialized = false;
211
-
212
-    /**
213
-     * @var FeatureFlags
214
-     */
215
-    protected $feature;
216
-
217
-
218
-    /**
219
-     * @Constructor
220
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
221
-     * @throws InvalidArgumentException
222
-     * @throws InvalidDataTypeException
223
-     * @throws InvalidInterfaceException
224
-     * @throws ReflectionException
225
-     */
226
-    public function __construct($routing = true)
227
-    {
228
-        $this->loader = LoaderFactory::getLoader();
229
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
230
-        $this->feature = $this->loader->getShared(FeatureFlags::class);
231
-        $this->request = $this->loader->getShared(RequestInterface::class);
232
-        // routing enabled?
233
-        $this->_routing = $routing;
234
-
235
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
236
-            $this->_is_caf = true;
237
-        }
238
-        $this->_yes_no_values = [
239
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
240
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
241
-        ];
242
-        // set the _req_data property.
243
-        $this->_req_data = $this->request->requestParams();
244
-    }
245
-
246
-
247
-    /**
248
-     * @return EE_Admin_Config
249
-     */
250
-    public function adminConfig(): EE_Admin_Config
251
-    {
252
-        return $this->admin_config;
253
-    }
254
-
255
-
256
-    /**
257
-     * @return FeatureFlags
258
-     */
259
-    public function feature(): FeatureFlags
260
-    {
261
-        return $this->feature;
262
-    }
263
-
264
-
265
-    /**
266
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
267
-     * for child classes that needed to set properties prior to these methods getting called,
268
-     * but also needed the parent class to have its construction completed as well.
269
-     * Bottom line is that constructors should ONLY be used for setting initial properties
270
-     * and any complex initialization logic should only run after instantiation is complete.
271
-     *
272
-     * This method gets called immediately after construction from within
273
-     *      EE_Admin_Page_Init::_initialize_admin_page()
274
-     *
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     * @throws ReflectionException
280
-     * @since $VID:$
281
-     */
282
-    public function initializePage()
283
-    {
284
-        if ($this->initialized) {
285
-            return;
286
-        }
287
-        // set initial page props (child method)
288
-        $this->_init_page_props();
289
-        // set global defaults
290
-        $this->_set_defaults();
291
-        // set early because incoming requests could be ajax related and we need to register those hooks.
292
-        $this->_global_ajax_hooks();
293
-        $this->_ajax_hooks();
294
-        // other_page_hooks have to be early too.
295
-        $this->_do_other_page_hooks();
296
-        // set up page dependencies
297
-        $this->_before_page_setup();
298
-        $this->_page_setup();
299
-        $this->initialized = true;
300
-    }
301
-
302
-
303
-    /**
304
-     * _init_page_props
305
-     * Child classes use to set at least the following properties:
306
-     * $page_slug.
307
-     * $page_label.
308
-     *
309
-     * @abstract
310
-     * @return void
311
-     */
312
-    abstract protected function _init_page_props();
313
-
314
-
315
-    /**
316
-     * _ajax_hooks
317
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
318
-     * Note: within the ajax callback methods.
319
-     *
320
-     * @abstract
321
-     * @return void
322
-     */
323
-    abstract protected function _ajax_hooks();
324
-
325
-
326
-    /**
327
-     * _define_page_props
328
-     * child classes define page properties in here.  Must include at least:
329
-     * $_admin_base_url = base_url for all admin pages
330
-     * $_admin_page_title = default admin_page_title for admin pages
331
-     * $_labels = array of default labels for various automatically generated elements:
332
-     *    array(
333
-     *        'buttons' => array(
334
-     *            'add' => esc_html__('label for add new button'),
335
-     *            'edit' => esc_html__('label for edit button'),
336
-     *            'delete' => esc_html__('label for delete button')
337
-     *            )
338
-     *        )
339
-     *
340
-     * @abstract
341
-     * @return void
342
-     */
343
-    abstract protected function _define_page_props();
344
-
345
-
346
-    /**
347
-     * _set_page_routes
348
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
349
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
350
-     * have a 'default' route. Here's the format
351
-     * $this->_page_routes = array(
352
-     *        'default' => array(
353
-     *            'func' => '_default_method_handling_route',
354
-     *            'args' => array('array','of','args'),
355
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
356
-     *            ajax request, backend processing)
357
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
358
-     *            headers route after.  The string you enter here should match the defined route reference for a
359
-     *            headers sent route.
360
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
361
-     *            this route.
362
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
363
-     *            checks).
364
-     *        ),
365
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
366
-     *        handling method.
367
-     *        )
368
-     * )
369
-     *
370
-     * @abstract
371
-     * @return void
372
-     */
373
-    abstract protected function _set_page_routes();
374
-
375
-
376
-    /**
377
-     * _set_page_config
378
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
379
-     * array corresponds to the page_route for the loaded page. Format:
380
-     * $this->_page_config = array(
381
-     *        'default' => array(
382
-     *            'labels' => array(
383
-     *                'buttons' => array(
384
-     *                    'add' => esc_html__('label for adding item'),
385
-     *                    'edit' => esc_html__('label for editing item'),
386
-     *                    'delete' => esc_html__('label for deleting item')
387
-     *                ),
388
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
389
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
390
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
391
-     *            _define_page_props() method
392
-     *            'nav' => array(
393
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
394
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
395
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
396
-     *                'order' => 10, //required to indicate tab position.
397
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
398
-     *                displayed then add this parameter.
399
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
400
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
401
-     *            metaboxes set for eventespresso admin pages.
402
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
403
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
404
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
405
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
406
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
407
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
408
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
409
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
410
-     *            want to display.
411
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
412
-     *                'tab_id' => array(
413
-     *                    'title' => 'tab_title',
414
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
415
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
416
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
417
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
418
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
419
-     *                    attempt to use the callback which should match the name of a method in the class
420
-     *                    ),
421
-     *                'tab2_id' => array(
422
-     *                    'title' => 'tab2 title',
423
-     *                    'filename' => 'file_name_2'
424
-     *                    'callback' => 'callback_method_for_content',
425
-     *                 ),
426
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
427
-     *            help tab area on an admin page. @return void
428
-     *
429
-     * @link
430
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
431
-     *                'help_tour' => array(
432
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
433
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
434
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
435
-     *                ),
436
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
437
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
438
-     *                visited just set
439
-     *                'require_nonce' to FALSE
440
-     *                )
441
-     *                )
442
-     *
443
-     * @abstract
444
-     */
445
-    abstract protected function _set_page_config();
446
-
447
-
448
-
449
-
450
-
451
-    /** end sample help_tour methods **/
452
-    /**
453
-     * _add_screen_options
454
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
455
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
456
-     * to a particular view.
457
-     *
458
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
459
-     *         see also WP_Screen object documents...
460
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
461
-     * @abstract
462
-     * @return void
463
-     */
464
-    abstract protected function _add_screen_options();
465
-
466
-
467
-    /**
468
-     * _add_feature_pointers
469
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
470
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
471
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
472
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
473
-     * extended) also see:
474
-     *
475
-     * @link   http://eamann.com/tech/wordpress-portland/
476
-     * @abstract
477
-     * @return void
478
-     */
479
-    abstract protected function _add_feature_pointers();
480
-
481
-
482
-    /**
483
-     * load_scripts_styles
484
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
485
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
486
-     * scripts/styles per view by putting them in a dynamic function in this format
487
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
488
-     *
489
-     * @abstract
490
-     * @return void
491
-     */
492
-    abstract public function load_scripts_styles();
493
-
494
-
495
-    /**
496
-     * admin_init
497
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
498
-     * all pages/views loaded by child class.
499
-     *
500
-     * @abstract
501
-     * @return void
502
-     */
503
-    abstract public function admin_init();
504
-
505
-
506
-    /**
507
-     * admin_notices
508
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
509
-     * all pages/views loaded by child class.
510
-     *
511
-     * @abstract
512
-     * @return void
513
-     */
514
-    abstract public function admin_notices();
515
-
516
-
517
-    /**
518
-     * admin_footer_scripts
519
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
520
-     * will apply to all pages/views loaded by child class.
521
-     *
522
-     * @return void
523
-     */
524
-    abstract public function admin_footer_scripts();
525
-
526
-
527
-    /**
528
-     * admin_footer
529
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
530
-     * apply to all pages/views loaded by child class.
531
-     *
532
-     * @return void
533
-     */
534
-    public function admin_footer()
535
-    {
536
-    }
537
-
538
-
539
-    /**
540
-     * _global_ajax_hooks
541
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
542
-     * Note: within the ajax callback methods.
543
-     *
544
-     * @abstract
545
-     * @return void
546
-     */
547
-    protected function _global_ajax_hooks()
548
-    {
549
-        // for lazy loading of metabox content
550
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
551
-
552
-        add_action(
553
-            'wp_ajax_espresso_hide_status_change_notice',
554
-            [$this, 'hideStatusChangeNotice']
555
-        );
556
-        add_action(
557
-            'wp_ajax_nopriv_espresso_hide_status_change_notice',
558
-            [$this, 'hideStatusChangeNotice']
559
-        );
560
-    }
561
-
562
-
563
-    public function ajax_metabox_content()
564
-    {
565
-        $content_id  = $this->request->getRequestParam('contentid', '');
566
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
567
-        EE_Admin_Page::cached_rss_display($content_id, $content_url);
568
-        wp_die();
569
-    }
570
-
571
-
572
-    public function hideStatusChangeNotice()
573
-    {
574
-        $response = [];
575
-        try {
576
-            /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
577
-            $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
578
-            $response['success'] = $status_change_notice->dismiss() > -1;
579
-        } catch (Exception $exception) {
580
-            $response['errors'] = $exception->getMessage();
581
-        }
582
-        echo wp_json_encode($response);
583
-        exit();
584
-    }
585
-
586
-
587
-    /**
588
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
589
-     *
590
-     * @return void
591
-     */
592
-    protected function _before_page_setup()
593
-    {
594
-        // default is to do nothing
595
-    }
596
-
597
-
598
-    /**
599
-     * Makes sure any things that need to be loaded early get handled.
600
-     * We also escape early here if the page requested doesn't match the object.
601
-     *
602
-     * @final
603
-     * @return void
604
-     * @throws EE_Error
605
-     * @throws InvalidArgumentException
606
-     * @throws ReflectionException
607
-     * @throws InvalidDataTypeException
608
-     * @throws InvalidInterfaceException
609
-     */
610
-    final protected function _page_setup()
611
-    {
612
-        // requires?
613
-        // admin_init stuff - global - we're setting this REALLY early
614
-        // so if EE_Admin pages have to hook into other WP pages they can.
615
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
616
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
617
-        // next verify if we need to load anything...
618
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
619
-        $this->page_folder   = strtolower(
620
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
621
-        );
622
-        global $ee_menu_slugs;
623
-        $ee_menu_slugs = (array) $ee_menu_slugs;
624
-        if (
625
-            ! $this->request->isAjax()
626
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
627
-        ) {
628
-            return;
629
-        }
630
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
631
-        // we need to copy the action from the second to the first
632
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
633
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
634
-        $action     = $action !== '-1' ? $action : $action2;
635
-        $req_action = $action !== '-1' ? $action : 'default';
636
-
637
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
638
-        // then let's use the route as the action.
639
-        // This covers cases where we're coming in from a list table that isn't on the default route.
640
-        $route = $this->request->getRequestParam('route');
641
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
642
-            ? $route
643
-            : $req_action;
644
-
645
-        $this->_current_view = $this->_req_action;
646
-        $this->_req_nonce    = $this->_req_action . '_nonce';
647
-        $this->_define_page_props();
648
-        $this->_current_page_view_url = add_query_arg(
649
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
650
-            $this->_admin_base_url
651
-        );
652
-        // default things
653
-        $this->_default_espresso_metaboxes = [
654
-            '_espresso_news_post_box',
655
-            '_espresso_links_post_box',
656
-            '_espresso_ratings_request',
657
-            '_espresso_sponsors_post_box',
658
-        ];
659
-        // set page configs
660
-        $this->_set_page_routes();
661
-        $this->_set_page_config();
662
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
663
-        if ($this->request->requestParamIsSet('wp_referer')) {
664
-            $wp_referer = $this->request->getRequestParam('wp_referer');
665
-            if ($wp_referer) {
666
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
667
-            }
668
-        }
669
-        // for caffeinated and other extended functionality.
670
-        //  If there is a _extend_page_config method
671
-        // then let's run that to modify the all the various page configuration arrays
672
-        if (method_exists($this, '_extend_page_config')) {
673
-            $this->_extend_page_config();
674
-        }
675
-        // for CPT and other extended functionality.
676
-        // If there is an _extend_page_config_for_cpt
677
-        // then let's run that to modify all the various page configuration arrays.
678
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
679
-            $this->_extend_page_config_for_cpt();
680
-        }
681
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
682
-        $this->_page_routes = apply_filters(
683
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
684
-            $this->_page_routes,
685
-            $this
686
-        );
687
-        $this->_page_config = apply_filters(
688
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
689
-            $this->_page_config,
690
-            $this
691
-        );
692
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
693
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
694
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
695
-            add_action(
696
-                'AHEE__EE_Admin_Page__route_admin_request',
697
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
698
-                10,
699
-                2
700
-            );
701
-        }
702
-        // next route only if routing enabled
703
-        if ($this->_routing && ! $this->request->isAjax()) {
704
-            $this->_verify_routes();
705
-            // next let's just check user_access and kill if no access
706
-            $this->check_user_access();
707
-            if ($this->_is_UI_request) {
708
-                // admin_init stuff - global, all views for this page class, specific view
709
-                add_action('admin_init', [$this, 'admin_init'], 10);
710
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
711
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
712
-                }
713
-            } else {
714
-                // hijack regular WP loading and route admin request immediately
715
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
716
-                $this->route_admin_request();
717
-            }
718
-        }
719
-    }
720
-
721
-
722
-    /**
723
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
724
-     *
725
-     * @return void
726
-     * @throws EE_Error
727
-     */
728
-    private function _do_other_page_hooks()
729
-    {
730
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
731
-        foreach ($registered_pages as $page) {
732
-            // now let's setup the file name and class that should be present
733
-            $classname = str_replace('.class.php', '', $page);
734
-            // autoloaders should take care of loading file
735
-            if (! class_exists($classname)) {
736
-                $error_msg[] = sprintf(
737
-                    esc_html__(
738
-                        'Something went wrong with loading the %s admin hooks page.',
739
-                        'event_espresso'
740
-                    ),
741
-                    $page
742
-                );
743
-                $error_msg[] = $error_msg[0]
744
-                               . "\r\n"
745
-                               . sprintf(
746
-                                   esc_html__(
747
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
748
-                                       'event_espresso'
749
-                                   ),
750
-                                   $page,
751
-                                   '<br />',
752
-                                   '<strong>' . $classname . '</strong>'
753
-                               );
754
-                throw new EE_Error(implode('||', $error_msg));
755
-            }
756
-            // notice we are passing the instance of this class to the hook object.
757
-            $this->loader->getShared($classname, [$this]);
758
-        }
759
-    }
760
-
761
-
762
-    /**
763
-     * @throws ReflectionException
764
-     * @throws EE_Error
765
-     */
766
-    public function load_page_dependencies()
767
-    {
768
-        try {
769
-            $this->_load_page_dependencies();
770
-        } catch (EE_Error $e) {
771
-            $e->get_error();
772
-        }
773
-    }
774
-
775
-
776
-    /**
777
-     * load_page_dependencies
778
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
779
-     *
780
-     * @return void
781
-     * @throws DomainException
782
-     * @throws EE_Error
783
-     * @throws InvalidArgumentException
784
-     * @throws InvalidDataTypeException
785
-     * @throws InvalidInterfaceException
786
-     */
787
-    protected function _load_page_dependencies()
788
-    {
789
-        // let's set the current_screen and screen options to override what WP set
790
-        $this->_current_screen = get_current_screen();
791
-        // load admin_notices - global, page class, and view specific
792
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
793
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
794
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
795
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
796
-        }
797
-        // load network admin_notices - global, page class, and view specific
798
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
799
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
800
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
801
-        }
802
-        // this will save any per_page screen options if they are present
803
-        $this->_set_per_page_screen_options();
804
-        // setup list table properties
805
-        $this->_set_list_table();
806
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
807
-        // However in some cases the metaboxes will need to be added within a route handling callback.
808
-        $this->_add_registered_meta_boxes();
809
-        $this->_add_screen_columns();
810
-        // add screen options - global, page child class, and view specific
811
-        $this->_add_global_screen_options();
812
-        $this->_add_screen_options();
813
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
814
-        if (method_exists($this, $add_screen_options)) {
815
-            $this->{$add_screen_options}();
816
-        }
817
-        // add help tab(s) and tours- set via page_config and qtips.
818
-        // $this->_add_help_tour();
819
-        $this->_add_help_tabs();
820
-        $this->_add_qtips();
821
-        // add feature_pointers - global, page child class, and view specific
822
-        $this->_add_feature_pointers();
823
-        $this->_add_global_feature_pointers();
824
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
825
-        if (method_exists($this, $add_feature_pointer)) {
826
-            $this->{$add_feature_pointer}();
827
-        }
828
-        // enqueue scripts/styles - global, page class, and view specific
829
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
830
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
831
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
832
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
833
-        }
834
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
835
-        // admin_print_footer_scripts - global, page child class, and view specific.
836
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
837
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
838
-        // is a good use case. Notice the late priority we're giving these
839
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
840
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
841
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
842
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
843
-        }
844
-        // admin footer scripts
845
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
846
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
847
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
848
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
849
-        }
850
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
851
-        // targeted hook
852
-        do_action(
853
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
854
-        );
855
-    }
856
-
857
-
858
-    /**
859
-     * _set_defaults
860
-     * This sets some global defaults for class properties.
861
-     */
862
-    private function _set_defaults()
863
-    {
864
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
865
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
866
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
867
-        $this->_page_config          = $this->_default_route_query_args = [];
868
-        $this->_default_nav_tab_name = 'overview';
869
-        // init template args
870
-        $this->_template_args = [
871
-            'admin_page_header'  => '',
872
-            'admin_page_content' => '',
873
-            'post_body_content'  => '',
874
-            'before_list_table'  => '',
875
-            'after_list_table'   => '',
876
-        ];
877
-    }
878
-
879
-
880
-    /**
881
-     * route_admin_request
882
-     *
883
-     * @return void
884
-     * @throws InvalidArgumentException
885
-     * @throws InvalidInterfaceException
886
-     * @throws InvalidDataTypeException
887
-     * @throws EE_Error
888
-     * @throws ReflectionException
889
-     * @see    _route_admin_request()
890
-     */
891
-    public function route_admin_request()
892
-    {
893
-        try {
894
-            $this->_route_admin_request();
895
-        } catch (EE_Error $e) {
896
-            $e->get_error();
897
-        }
898
-    }
899
-
900
-
901
-    public function set_wp_page_slug($wp_page_slug)
902
-    {
903
-        $this->_wp_page_slug = $wp_page_slug;
904
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
905
-        if (is_network_admin()) {
906
-            $this->_wp_page_slug .= '-network';
907
-        }
908
-    }
909
-
910
-
911
-    /**
912
-     * _verify_routes
913
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
914
-     * we know if we need to drop out.
915
-     *
916
-     * @return bool
917
-     * @throws EE_Error
918
-     */
919
-    protected function _verify_routes()
920
-    {
921
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
922
-        if (! $this->_current_page && ! $this->request->isAjax()) {
923
-            return false;
924
-        }
925
-        $this->_route = false;
926
-        // check that the page_routes array is not empty
927
-        if (empty($this->_page_routes)) {
928
-            // user error msg
929
-            $error_msg = sprintf(
930
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
931
-                $this->_admin_page_title
932
-            );
933
-            // developer error msg
934
-            $error_msg .= '||' . $error_msg
935
-                          . esc_html__(
936
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
937
-                              'event_espresso'
938
-                          );
939
-            throw new EE_Error($error_msg);
940
-        }
941
-        // and that the requested page route exists
942
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
943
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
944
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
945
-        } else {
946
-            // user error msg
947
-            $error_msg = sprintf(
948
-                esc_html__(
949
-                    'The requested page route does not exist for the %s admin page.',
950
-                    'event_espresso'
951
-                ),
952
-                $this->_admin_page_title
953
-            );
954
-            // developer error msg
955
-            $error_msg .= '||' . $error_msg
956
-                          . sprintf(
957
-                              esc_html__(
958
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
959
-                                  'event_espresso'
960
-                              ),
961
-                              $this->_req_action
962
-                          );
963
-            throw new EE_Error($error_msg);
964
-        }
965
-        // and that a default route exists
966
-        if (! array_key_exists('default', $this->_page_routes)) {
967
-            // user error msg
968
-            $error_msg = sprintf(
969
-                esc_html__(
970
-                    'A default page route has not been set for the % admin page.',
971
-                    'event_espresso'
972
-                ),
973
-                $this->_admin_page_title
974
-            );
975
-            // developer error msg
976
-            $error_msg .= '||' . $error_msg
977
-                          . esc_html__(
978
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
979
-                              'event_espresso'
980
-                          );
981
-            throw new EE_Error($error_msg);
982
-        }
983
-
984
-        // first lets' catch if the UI request has EVER been set.
985
-        if ($this->_is_UI_request === null) {
986
-            // lets set if this is a UI request or not.
987
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
988
-            // wait a minute... we might have a noheader in the route array
989
-            $this->_is_UI_request = ! (
990
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
991
-            )
992
-                ? $this->_is_UI_request
993
-                : false;
994
-        }
995
-        $this->_set_current_labels();
996
-        return true;
997
-    }
998
-
999
-
1000
-    /**
1001
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1002
-     *
1003
-     * @param string $route the route name we're verifying
1004
-     * @return bool we'll throw an exception if this isn't a valid route.
1005
-     * @throws EE_Error
1006
-     */
1007
-    protected function _verify_route($route)
1008
-    {
1009
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
1010
-            return true;
1011
-        }
1012
-        // user error msg
1013
-        $error_msg = sprintf(
1014
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1015
-            $this->_admin_page_title
1016
-        );
1017
-        // developer error msg
1018
-        $error_msg .= '||' . $error_msg
1019
-                      . sprintf(
1020
-                          esc_html__(
1021
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1022
-                              'event_espresso'
1023
-                          ),
1024
-                          $route
1025
-                      );
1026
-        throw new EE_Error($error_msg);
1027
-    }
1028
-
1029
-
1030
-    /**
1031
-     * perform nonce verification
1032
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1033
-     * using this method (and save retyping!)
1034
-     *
1035
-     * @param string $nonce     The nonce sent
1036
-     * @param string $nonce_ref The nonce reference string (name0)
1037
-     * @return void
1038
-     * @throws EE_Error
1039
-     * @throws InvalidArgumentException
1040
-     * @throws InvalidDataTypeException
1041
-     * @throws InvalidInterfaceException
1042
-     */
1043
-    protected function _verify_nonce($nonce, $nonce_ref)
1044
-    {
1045
-        // verify nonce against expected value
1046
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1047
-            // these are not the droids you are looking for !!!
1048
-            $msg = sprintf(
1049
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
1050
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1051
-                '</a>'
1052
-            );
1053
-            if (WP_DEBUG) {
1054
-                $msg .= "\n  ";
1055
-                $msg .= sprintf(
1056
-                    esc_html__(
1057
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1058
-                        'event_espresso'
1059
-                    ),
1060
-                    __CLASS__
1061
-                );
1062
-            }
1063
-            if (! $this->request->isAjax()) {
1064
-                wp_die($msg);
1065
-            }
1066
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1067
-            $this->_return_json();
1068
-        }
1069
-    }
1070
-
1071
-
1072
-    /**
1073
-     * _route_admin_request()
1074
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1075
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1076
-     * in the page routes and then will try to load the corresponding method.
1077
-     *
1078
-     * @return void
1079
-     * @throws EE_Error
1080
-     * @throws InvalidArgumentException
1081
-     * @throws InvalidDataTypeException
1082
-     * @throws InvalidInterfaceException
1083
-     * @throws ReflectionException
1084
-     */
1085
-    protected function _route_admin_request()
1086
-    {
1087
-        if (! $this->_is_UI_request) {
1088
-            $this->_verify_routes();
1089
-        }
1090
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1091
-        if ($this->_req_action !== 'default' && $nonce_check) {
1092
-            // set nonce from post data
1093
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1094
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1095
-        }
1096
-        // set the nav_tabs array but ONLY if this is  UI_request
1097
-        if ($this->_is_UI_request) {
1098
-            $this->_set_nav_tabs();
1099
-        }
1100
-        // grab callback function
1101
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1102
-        // check if callback has args
1103
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1104
-        $error_msg = '';
1105
-        // action right before calling route
1106
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1107
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1108
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1109
-        }
1110
-        // right before calling the route, let's clean the _wp_http_referer
1111
-        $this->request->setServerParam(
1112
-            'REQUEST_URI',
1113
-            remove_query_arg(
1114
-                '_wp_http_referer',
1115
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1116
-            )
1117
-        );
1118
-        if (! empty($func)) {
1119
-            if (is_array($func)) {
1120
-                [$class, $method] = $func;
1121
-            } elseif (strpos($func, '::') !== false) {
1122
-                [$class, $method] = explode('::', $func);
1123
-            } else {
1124
-                $class  = $this;
1125
-                $method = $func;
1126
-            }
1127
-            if (! (is_object($class) && $class === $this)) {
1128
-                // send along this admin page object for access by addons.
1129
-                $args['admin_page_object'] = $this;
1130
-            }
1131
-            if (
1132
-                // is it a method on a class that doesn't work?
1133
-                (
1134
-                    (
1135
-                        method_exists($class, $method)
1136
-                        && call_user_func_array([$class, $method], $args) === false
1137
-                    )
1138
-                    && (
1139
-                        // is it a standalone function that doesn't work?
1140
-                        function_exists($method)
1141
-                        && call_user_func_array(
1142
-                            $func,
1143
-                            array_merge(['admin_page_object' => $this], $args)
1144
-                        ) === false
1145
-                    )
1146
-                )
1147
-                || (
1148
-                    // is it neither a class method NOR a standalone function?
1149
-                    ! method_exists($class, $method)
1150
-                    && ! function_exists($method)
1151
-                )
1152
-            ) {
1153
-                // user error msg
1154
-                $error_msg = esc_html__(
1155
-                    'An error occurred. The  requested page route could not be found.',
1156
-                    'event_espresso'
1157
-                );
1158
-                // developer error msg
1159
-                $error_msg .= '||';
1160
-                $error_msg .= sprintf(
1161
-                    esc_html__(
1162
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1163
-                        'event_espresso'
1164
-                    ),
1165
-                    $method
1166
-                );
1167
-            }
1168
-            if (! empty($error_msg)) {
1169
-                throw new EE_Error($error_msg);
1170
-            }
1171
-        }
1172
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1173
-        // then we need to reset the routing properties to the new route.
1174
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1175
-        if (
1176
-            $this->_is_UI_request === false
1177
-            && is_array($this->_route)
1178
-            && ! empty($this->_route['headers_sent_route'])
1179
-        ) {
1180
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1181
-        }
1182
-    }
1183
-
1184
-
1185
-    /**
1186
-     * This method just allows the resetting of page properties in the case where a no headers
1187
-     * route redirects to a headers route in its route config.
1188
-     *
1189
-     * @param string $new_route New (non header) route to redirect to.
1190
-     * @return   void
1191
-     * @throws ReflectionException
1192
-     * @throws InvalidArgumentException
1193
-     * @throws InvalidInterfaceException
1194
-     * @throws InvalidDataTypeException
1195
-     * @throws EE_Error
1196
-     * @since   4.3.0
1197
-     */
1198
-    protected function _reset_routing_properties($new_route)
1199
-    {
1200
-        $this->_is_UI_request = true;
1201
-        // now we set the current route to whatever the headers_sent_route is set at
1202
-        $this->request->setRequestParam('action', $new_route);
1203
-        // rerun page setup
1204
-        $this->_page_setup();
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     * _add_query_arg
1210
-     * adds nonce to array of arguments then calls WP add_query_arg function
1211
-     *(internally just uses EEH_URL's function with the same name)
1212
-     *
1213
-     * @param array  $args
1214
-     * @param string $url
1215
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1216
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1217
-     *                                        Example usage: If the current page is:
1218
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1219
-     *                                        &action=default&event_id=20&month_range=March%202015
1220
-     *                                        &_wpnonce=5467821
1221
-     *                                        and you call:
1222
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1223
-     *                                        array(
1224
-     *                                        'action' => 'resend_something',
1225
-     *                                        'page=>espresso_registrations'
1226
-     *                                        ),
1227
-     *                                        $some_url,
1228
-     *                                        true
1229
-     *                                        );
1230
-     *                                        It will produce a url in this structure:
1231
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1232
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1233
-     *                                        month_range]=March%202015
1234
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1235
-     * @return string
1236
-     */
1237
-    public static function add_query_args_and_nonce(
1238
-        $args = [],
1239
-        $url = '',
1240
-        $sticky = false,
1241
-        $exclude_nonce = false
1242
-    ) {
1243
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1244
-        if ($sticky) {
1245
-            /** @var RequestInterface $request */
1246
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1247
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1248
-            foreach ($request->requestParams() as $key => $value) {
1249
-                // do not add nonces
1250
-                if (strpos($key, 'nonce') !== false) {
1251
-                    continue;
1252
-                }
1253
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1254
-            }
1255
-        }
1256
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * This returns a generated link that will load the related help tab.
1262
-     *
1263
-     * @param string $help_tab_id the id for the connected help tab
1264
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1265
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1266
-     * @return string              generated link
1267
-     * @uses EEH_Template::get_help_tab_link()
1268
-     */
1269
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1270
-    {
1271
-        return EEH_Template::get_help_tab_link(
1272
-            $help_tab_id,
1273
-            $this->page_slug,
1274
-            $this->_req_action,
1275
-            $icon_style,
1276
-            $help_text
1277
-        );
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * _add_help_tabs
1283
-     * Note child classes define their help tabs within the page_config array.
1284
-     *
1285
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1286
-     * @return void
1287
-     * @throws DomainException
1288
-     * @throws EE_Error
1289
-     * @throws ReflectionException
1290
-     */
1291
-    protected function _add_help_tabs()
1292
-    {
1293
-        $tour_buttons = '';
1294
-        if (isset($this->_page_config[ $this->_req_action ])) {
1295
-            $config = $this->_page_config[ $this->_req_action ];
1296
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1297
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1298
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1299
-            //     $tb = array();
1300
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1301
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1302
-            //         // if this is the end tour then we don't need to setup a button
1303
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1304
-            //             continue;
1305
-            //         }
1306
-            //         $tb[] = '<button id="trigger-tour-'
1307
-            //                 . $tour->get_slug()
1308
-            //                 . '" class="button--primary trigger-ee-help-tour">'
1309
-            //                 . $tour->get_label()
1310
-            //                 . '</button>';
1311
-            //     }
1312
-            //     $tour_buttons .= implode('<br />', $tb);
1313
-            //     $tour_buttons .= '</div></div>';
1314
-            // }
1315
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1316
-            if (is_array($config) && isset($config['help_sidebar'])) {
1317
-                // check that the callback given is valid
1318
-                if (! method_exists($this, $config['help_sidebar'])) {
1319
-                    throw new EE_Error(
1320
-                        sprintf(
1321
-                            esc_html__(
1322
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1323
-                                'event_espresso'
1324
-                            ),
1325
-                            $config['help_sidebar'],
1326
-                            get_class($this)
1327
-                        )
1328
-                    );
1329
-                }
1330
-                $content = apply_filters(
1331
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1332
-                    $this->{$config['help_sidebar']}()
1333
-                );
1334
-                $content .= $tour_buttons; // add help tour buttons.
1335
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1336
-                $this->_current_screen->set_help_sidebar($content);
1337
-            }
1338
-            // if there ARE tour buttons...
1339
-            if (! empty($tour_buttons)) {
1340
-                // if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1341
-                if (! isset($config['help_sidebar'])) {
1342
-                    $this->_current_screen->set_help_sidebar($tour_buttons);
1343
-                }
1344
-                // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1345
-                if (! isset($config['help_tabs'])) {
1346
-                    $_ht['id'] = $this->page_slug;
1347
-                    $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1348
-                    $_ht['content'] = '<p>'
1349
-                                      . esc_html__(
1350
-                                          'The buttons to the right allow you to start/restart any help tours available for this page',
1351
-                                          'event_espresso'
1352
-                                      ) . '</p>';
1353
-                    $this->_current_screen->add_help_tab($_ht);
1354
-                }
1355
-            }
1356
-            if (! isset($config['help_tabs'])) {
1357
-                return;
1358
-            } //no help tabs for this route
1359
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1360
-                // we're here so there ARE help tabs!
1361
-                // make sure we've got what we need
1362
-                if (! isset($cfg['title'])) {
1363
-                    throw new EE_Error(
1364
-                        esc_html__(
1365
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1366
-                            'event_espresso'
1367
-                        )
1368
-                    );
1369
-                }
1370
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1371
-                    throw new EE_Error(
1372
-                        esc_html__(
1373
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1374
-                            'event_espresso'
1375
-                        )
1376
-                    );
1377
-                }
1378
-                // first priority goes to content.
1379
-                if (! empty($cfg['content'])) {
1380
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1381
-                    // second priority goes to filename
1382
-                } elseif (! empty($cfg['filename'])) {
1383
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1384
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1385
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1386
-                                                             . basename($this->_get_dir())
1387
-                                                             . '/help_tabs/'
1388
-                                                             . $cfg['filename']
1389
-                                                             . '.help_tab.php' : $file_path;
1390
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1391
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1392
-                        EE_Error::add_error(
1393
-                            sprintf(
1394
-                                esc_html__(
1395
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1396
-                                    'event_espresso'
1397
-                                ),
1398
-                                $tab_id,
1399
-                                key($config),
1400
-                                $file_path
1401
-                            ),
1402
-                            __FILE__,
1403
-                            __FUNCTION__,
1404
-                            __LINE__
1405
-                        );
1406
-                        return;
1407
-                    }
1408
-                    $template_args['admin_page_obj'] = $this;
1409
-                    $content                         = EEH_Template::display_template(
1410
-                        $file_path,
1411
-                        $template_args,
1412
-                        true
1413
-                    );
1414
-                } else {
1415
-                    $content = '';
1416
-                }
1417
-                // check if callback is valid
1418
-                if (
1419
-                    empty($content)
1420
-                    && (
1421
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1422
-                    )
1423
-                ) {
1424
-                    EE_Error::add_error(
1425
-                        sprintf(
1426
-                            esc_html__(
1427
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1428
-                                'event_espresso'
1429
-                            ),
1430
-                            $cfg['title']
1431
-                        ),
1432
-                        __FILE__,
1433
-                        __FUNCTION__,
1434
-                        __LINE__
1435
-                    );
1436
-                    return;
1437
-                }
1438
-                // setup config array for help tab method
1439
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1440
-                $_ht = [
1441
-                    'id'       => $id,
1442
-                    'title'    => $cfg['title'],
1443
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1444
-                    'content'  => $content,
1445
-                ];
1446
-                $this->_current_screen->add_help_tab($_ht);
1447
-            }
1448
-        }
1449
-    }
1450
-
1451
-
1452
-    /**
1453
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1454
-     * an array with properties for setting up usage of the joyride plugin
1455
-     *
1456
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1457
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1458
-     *         _set_page_config() comments
1459
-     * @return void
1460
-     * @throws InvalidArgumentException
1461
-     * @throws InvalidDataTypeException
1462
-     * @throws InvalidInterfaceException
1463
-     * @throws ReflectionException
1464
-     */
1465
-    protected function _add_help_tour()
1466
-    {
1467
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1468
-        // $tours = array();
1469
-        // $this->_help_tour = array();
1470
-        // // exit early if help tours are turned off globally
1471
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1472
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1473
-        // ) {
1474
-        //     return;
1475
-        // }
1476
-        // // loop through _page_config to find any help_tour defined
1477
-        // foreach ($this->_page_config as $route => $config) {
1478
-        //     // we're only going to set things up for this route
1479
-        //     if ($route !== $this->_req_action) {
1480
-        //         continue;
1481
-        //     }
1482
-        //     if (isset($config['help_tour'])) {
1483
-        //         foreach ($config['help_tour'] as $tour) {
1484
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1485
-        //             // let's see if we can get that file...
1486
-        //             // if not its possible this is a decaf route not set in caffeinated
1487
-        //             // so lets try and get the caffeinated equivalent
1488
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1489
-        //                                                      . basename($this->_get_dir())
1490
-        //                                                      . '/help_tours/'
1491
-        //                                                      . $tour
1492
-        //                                                      . '.class.php' : $file_path;
1493
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1494
-        //             if (! is_readable($file_path)) {
1495
-        //                 EE_Error::add_error(
1496
-        //                     sprintf(
1497
-        //                         esc_html__(
1498
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1499
-        //                             'event_espresso'
1500
-        //                         ),
1501
-        //                         $file_path,
1502
-        //                         $tour
1503
-        //                     ),
1504
-        //                     __FILE__,
1505
-        //                     __FUNCTION__,
1506
-        //                     __LINE__
1507
-        //                 );
1508
-        //                 return;
1509
-        //             }
1510
-        //             require_once $file_path;
1511
-        //             if (! class_exists($tour)) {
1512
-        //                 $error_msg[] = sprintf(
1513
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1514
-        //                     $tour
1515
-        //                 );
1516
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1517
-        //                                . sprintf(
1518
-        //                                    esc_html__(
1519
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1520
-        //                                        'event_espresso'
1521
-        //                                    ),
1522
-        //                                    $tour,
1523
-        //                                    '<br />',
1524
-        //                                    $tour,
1525
-        //                                    $this->_req_action,
1526
-        //                                    get_class($this)
1527
-        //                                );
1528
-        //                 throw new EE_Error(implode('||', $error_msg));
1529
-        //             }
1530
-        //             $tour_obj = new $tour($this->_is_caf);
1531
-        //             $tours[] = $tour_obj;
1532
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1533
-        //         }
1534
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1535
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1536
-        //         $tours[] = $end_stop_tour;
1537
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1538
-        //     }
1539
-        // }
1540
-        //
1541
-        // if (! empty($tours)) {
1542
-        //     $this->_help_tour['tours'] = $tours;
1543
-        // }
1544
-        // // that's it!  Now that the $_help_tours property is set (or not)
1545
-        // // the scripts and html should be taken care of automatically.
1546
-        //
1547
-        // /**
1548
-        //  * Allow extending the help tours variable.
1549
-        //  *
1550
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1551
-        //  */
1552
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1553
-    }
1554
-
1555
-
1556
-    /**
1557
-     * This simply sets up any qtips that have been defined in the page config
1558
-     *
1559
-     * @return void
1560
-     * @throws ReflectionException
1561
-     * @throws EE_Error
1562
-     */
1563
-    protected function _add_qtips()
1564
-    {
1565
-        if (isset($this->_route_config['qtips'])) {
1566
-            $qtips = (array) $this->_route_config['qtips'];
1567
-            // load qtip loader
1568
-            $path = [
1569
-                $this->_get_dir() . '/qtips/',
1570
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1571
-            ];
1572
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1573
-        }
1574
-    }
1575
-
1576
-
1577
-    /**
1578
-     * _set_nav_tabs
1579
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1580
-     * wish to add additional tabs or modify accordingly.
1581
-     *
1582
-     * @return void
1583
-     * @throws InvalidArgumentException
1584
-     * @throws InvalidInterfaceException
1585
-     * @throws InvalidDataTypeException
1586
-     */
1587
-    protected function _set_nav_tabs()
1588
-    {
1589
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1590
-        $i = 0;
1591
-        foreach ($this->_page_config as $slug => $config) {
1592
-            if (! is_array($config) || empty($config['nav'])) {
1593
-                continue;
1594
-            }
1595
-            // no nav tab for this config
1596
-            // check for persistent flag
1597
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1598
-                // nav tab is only to appear when route requested.
1599
-                continue;
1600
-            }
1601
-            if (! $this->check_user_access($slug, true)) {
1602
-                // no nav tab because current user does not have access.
1603
-                continue;
1604
-            }
1605
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1606
-            $this->_nav_tabs[ $slug ] = [
1607
-                'url'       => isset($config['nav']['url'])
1608
-                    ? $config['nav']['url']
1609
-                    : EE_Admin_Page::add_query_args_and_nonce(
1610
-                        ['action' => $slug],
1611
-                        $this->_admin_base_url
1612
-                    ),
1613
-                'link_text' => isset($config['nav']['label'])
1614
-                    ? $config['nav']['label']
1615
-                    : ucwords(
1616
-                        str_replace('_', ' ', $slug)
1617
-                    ),
1618
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1619
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1620
-            ];
1621
-            $i++;
1622
-        }
1623
-        // if $this->_nav_tabs is empty then lets set the default
1624
-        if (empty($this->_nav_tabs)) {
1625
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1626
-                'url'       => $this->_admin_base_url,
1627
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1628
-                'css_class' => 'nav-tab-active',
1629
-                'order'     => 10,
1630
-            ];
1631
-        }
1632
-        // now let's sort the tabs according to order
1633
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1634
-    }
1635
-
1636
-
1637
-    /**
1638
-     * _set_current_labels
1639
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1640
-     * property array
1641
-     *
1642
-     * @return void
1643
-     */
1644
-    private function _set_current_labels()
1645
-    {
1646
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1647
-            foreach ($this->_route_config['labels'] as $label => $text) {
1648
-                if (is_array($text)) {
1649
-                    foreach ($text as $sublabel => $subtext) {
1650
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1651
-                    }
1652
-                } else {
1653
-                    $this->_labels[ $label ] = $text;
1654
-                }
1655
-            }
1656
-        }
1657
-    }
1658
-
1659
-
1660
-    /**
1661
-     *        verifies user access for this admin page
1662
-     *
1663
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1664
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1665
-     *                               return false if verify fail.
1666
-     * @return bool
1667
-     * @throws InvalidArgumentException
1668
-     * @throws InvalidDataTypeException
1669
-     * @throws InvalidInterfaceException
1670
-     */
1671
-    public function check_user_access($route_to_check = '', $verify_only = false)
1672
-    {
1673
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1674
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1675
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1676
-                          && is_array(
1677
-                              $this->_page_routes[ $route_to_check ]
1678
-                          )
1679
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1680
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1681
-        if (empty($capability) && empty($route_to_check)) {
1682
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1683
-                : $this->_route['capability'];
1684
-        } else {
1685
-            $capability = empty($capability) ? 'manage_options' : $capability;
1686
-        }
1687
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1688
-        if (
1689
-            ! $this->request->isAjax()
1690
-            && (
1691
-                ! function_exists('is_admin')
1692
-                || ! EE_Registry::instance()->CAP->current_user_can(
1693
-                    $capability,
1694
-                    $this->page_slug
1695
-                    . '_'
1696
-                    . $route_to_check,
1697
-                    $id
1698
-                )
1699
-            )
1700
-        ) {
1701
-            if ($verify_only) {
1702
-                return false;
1703
-            }
1704
-            if (is_user_logged_in()) {
1705
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1706
-            } else {
1707
-                return false;
1708
-            }
1709
-        }
1710
-        return true;
1711
-    }
1712
-
1713
-
1714
-    protected function addMetaBox(
1715
-        $box_id,
1716
-        $title,
1717
-        $callback,
1718
-        $screen,
1719
-        $context = 'normal',
1720
-        $priority = 'default',
1721
-        $callback_args = null
1722
-    ) {
1723
-        add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1724
-        add_filter(
1725
-            "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1726
-            function ($classes) {
1727
-                array_push($classes, 'ee-admin-container');
1728
-                return $classes;
1729
-            }
1730
-        );
1731
-    }
1732
-
1733
-
1734
-    /**
1735
-     * admin_init_global
1736
-     * This runs all the code that we want executed within the WP admin_init hook.
1737
-     * This method executes for ALL EE Admin pages.
1738
-     *
1739
-     * @return void
1740
-     */
1741
-    public function admin_init_global()
1742
-    {
1743
-    }
1744
-
1745
-
1746
-    /**
1747
-     * wp_loaded_global
1748
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1749
-     * EE_Admin page and will execute on every EE Admin Page load
1750
-     *
1751
-     * @return void
1752
-     */
1753
-    public function wp_loaded()
1754
-    {
1755
-    }
1756
-
1757
-
1758
-    /**
1759
-     * admin_notices
1760
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1761
-     * ALL EE_Admin pages.
1762
-     *
1763
-     * @return void
1764
-     */
1765
-    public function admin_notices_global()
1766
-    {
1767
-        $this->_display_no_javascript_warning();
1768
-        $this->_display_espresso_notices();
1769
-    }
1770
-
1771
-
1772
-    public function network_admin_notices_global()
1773
-    {
1774
-        $this->_display_no_javascript_warning();
1775
-        $this->_display_espresso_notices();
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     * admin_footer_scripts_global
1781
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1782
-     * will apply on ALL EE_Admin pages.
1783
-     *
1784
-     * @return void
1785
-     */
1786
-    public function admin_footer_scripts_global()
1787
-    {
1788
-        $this->_add_admin_page_ajax_loading_img();
1789
-        $this->_add_admin_page_overlay();
1790
-        // if metaboxes are present we need to add the nonce field
1791
-        if (
1792
-            isset($this->_route_config['metaboxes'])
1793
-            || isset($this->_route_config['list_table'])
1794
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1795
-        ) {
1796
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1797
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1798
-        }
1799
-    }
1800
-
1801
-
1802
-    /**
1803
-     * admin_footer_global
1804
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1805
-     * This particular method will apply on ALL EE_Admin Pages.
1806
-     *
1807
-     * @return void
1808
-     */
1809
-    public function admin_footer_global()
1810
-    {
1811
-        // dialog container for dialog helper
1812
-        echo '
137
+	/**
138
+	 * unprocessed value for the 'action' request param (default '')
139
+	 *
140
+	 * @var string
141
+	 */
142
+	protected $raw_req_action = '';
143
+
144
+	/**
145
+	 * unprocessed value for the 'page' request param (default '')
146
+	 *
147
+	 * @var string
148
+	 */
149
+	protected $raw_req_page = '';
150
+
151
+	/**
152
+	 * sanitized request action (and nonce)
153
+	 *
154
+	 * @var string
155
+	 */
156
+	protected $_req_action = '';
157
+
158
+	/**
159
+	 * sanitized request action nonce
160
+	 *
161
+	 * @var string
162
+	 */
163
+	protected $_req_nonce = '';
164
+
165
+	/**
166
+	 * @var string
167
+	 */
168
+	protected $_search_btn_label = '';
169
+
170
+	/**
171
+	 * @var string
172
+	 */
173
+	protected $_search_box_callback = '';
174
+
175
+	/**
176
+	 * @var WP_Screen
177
+	 */
178
+	protected $_current_screen;
179
+
180
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
181
+	protected $_hook_obj;
182
+
183
+	// for holding incoming request data
184
+	protected $_req_data = [];
185
+
186
+	// yes / no array for admin form fields
187
+	protected $_yes_no_values = [];
188
+
189
+	// some default things shared by all child classes
190
+	protected $_default_espresso_metaboxes;
191
+
192
+	/**
193
+	 * @var EE_Registry
194
+	 */
195
+	protected $EE;
196
+
197
+
198
+	/**
199
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
200
+	 *
201
+	 * @var boolean
202
+	 */
203
+	protected $_is_caf = false;
204
+
205
+	/**
206
+	 * whether or not initializePage() has run
207
+	 *
208
+	 * @var boolean
209
+	 */
210
+	protected $initialized = false;
211
+
212
+	/**
213
+	 * @var FeatureFlags
214
+	 */
215
+	protected $feature;
216
+
217
+
218
+	/**
219
+	 * @Constructor
220
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
221
+	 * @throws InvalidArgumentException
222
+	 * @throws InvalidDataTypeException
223
+	 * @throws InvalidInterfaceException
224
+	 * @throws ReflectionException
225
+	 */
226
+	public function __construct($routing = true)
227
+	{
228
+		$this->loader = LoaderFactory::getLoader();
229
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
230
+		$this->feature = $this->loader->getShared(FeatureFlags::class);
231
+		$this->request = $this->loader->getShared(RequestInterface::class);
232
+		// routing enabled?
233
+		$this->_routing = $routing;
234
+
235
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
236
+			$this->_is_caf = true;
237
+		}
238
+		$this->_yes_no_values = [
239
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
240
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
241
+		];
242
+		// set the _req_data property.
243
+		$this->_req_data = $this->request->requestParams();
244
+	}
245
+
246
+
247
+	/**
248
+	 * @return EE_Admin_Config
249
+	 */
250
+	public function adminConfig(): EE_Admin_Config
251
+	{
252
+		return $this->admin_config;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @return FeatureFlags
258
+	 */
259
+	public function feature(): FeatureFlags
260
+	{
261
+		return $this->feature;
262
+	}
263
+
264
+
265
+	/**
266
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
267
+	 * for child classes that needed to set properties prior to these methods getting called,
268
+	 * but also needed the parent class to have its construction completed as well.
269
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
270
+	 * and any complex initialization logic should only run after instantiation is complete.
271
+	 *
272
+	 * This method gets called immediately after construction from within
273
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
274
+	 *
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 * @throws ReflectionException
280
+	 * @since $VID:$
281
+	 */
282
+	public function initializePage()
283
+	{
284
+		if ($this->initialized) {
285
+			return;
286
+		}
287
+		// set initial page props (child method)
288
+		$this->_init_page_props();
289
+		// set global defaults
290
+		$this->_set_defaults();
291
+		// set early because incoming requests could be ajax related and we need to register those hooks.
292
+		$this->_global_ajax_hooks();
293
+		$this->_ajax_hooks();
294
+		// other_page_hooks have to be early too.
295
+		$this->_do_other_page_hooks();
296
+		// set up page dependencies
297
+		$this->_before_page_setup();
298
+		$this->_page_setup();
299
+		$this->initialized = true;
300
+	}
301
+
302
+
303
+	/**
304
+	 * _init_page_props
305
+	 * Child classes use to set at least the following properties:
306
+	 * $page_slug.
307
+	 * $page_label.
308
+	 *
309
+	 * @abstract
310
+	 * @return void
311
+	 */
312
+	abstract protected function _init_page_props();
313
+
314
+
315
+	/**
316
+	 * _ajax_hooks
317
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
318
+	 * Note: within the ajax callback methods.
319
+	 *
320
+	 * @abstract
321
+	 * @return void
322
+	 */
323
+	abstract protected function _ajax_hooks();
324
+
325
+
326
+	/**
327
+	 * _define_page_props
328
+	 * child classes define page properties in here.  Must include at least:
329
+	 * $_admin_base_url = base_url for all admin pages
330
+	 * $_admin_page_title = default admin_page_title for admin pages
331
+	 * $_labels = array of default labels for various automatically generated elements:
332
+	 *    array(
333
+	 *        'buttons' => array(
334
+	 *            'add' => esc_html__('label for add new button'),
335
+	 *            'edit' => esc_html__('label for edit button'),
336
+	 *            'delete' => esc_html__('label for delete button')
337
+	 *            )
338
+	 *        )
339
+	 *
340
+	 * @abstract
341
+	 * @return void
342
+	 */
343
+	abstract protected function _define_page_props();
344
+
345
+
346
+	/**
347
+	 * _set_page_routes
348
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
349
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
350
+	 * have a 'default' route. Here's the format
351
+	 * $this->_page_routes = array(
352
+	 *        'default' => array(
353
+	 *            'func' => '_default_method_handling_route',
354
+	 *            'args' => array('array','of','args'),
355
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
356
+	 *            ajax request, backend processing)
357
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
358
+	 *            headers route after.  The string you enter here should match the defined route reference for a
359
+	 *            headers sent route.
360
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
361
+	 *            this route.
362
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
363
+	 *            checks).
364
+	 *        ),
365
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
366
+	 *        handling method.
367
+	 *        )
368
+	 * )
369
+	 *
370
+	 * @abstract
371
+	 * @return void
372
+	 */
373
+	abstract protected function _set_page_routes();
374
+
375
+
376
+	/**
377
+	 * _set_page_config
378
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
379
+	 * array corresponds to the page_route for the loaded page. Format:
380
+	 * $this->_page_config = array(
381
+	 *        'default' => array(
382
+	 *            'labels' => array(
383
+	 *                'buttons' => array(
384
+	 *                    'add' => esc_html__('label for adding item'),
385
+	 *                    'edit' => esc_html__('label for editing item'),
386
+	 *                    'delete' => esc_html__('label for deleting item')
387
+	 *                ),
388
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
389
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
390
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
391
+	 *            _define_page_props() method
392
+	 *            'nav' => array(
393
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
394
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
395
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
396
+	 *                'order' => 10, //required to indicate tab position.
397
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
398
+	 *                displayed then add this parameter.
399
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
400
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
401
+	 *            metaboxes set for eventespresso admin pages.
402
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
403
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
404
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
405
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
406
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
407
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
408
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
409
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
410
+	 *            want to display.
411
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
412
+	 *                'tab_id' => array(
413
+	 *                    'title' => 'tab_title',
414
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
415
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
416
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
417
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
418
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
419
+	 *                    attempt to use the callback which should match the name of a method in the class
420
+	 *                    ),
421
+	 *                'tab2_id' => array(
422
+	 *                    'title' => 'tab2 title',
423
+	 *                    'filename' => 'file_name_2'
424
+	 *                    'callback' => 'callback_method_for_content',
425
+	 *                 ),
426
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
427
+	 *            help tab area on an admin page. @return void
428
+	 *
429
+	 * @link
430
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
431
+	 *                'help_tour' => array(
432
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
433
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
434
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
435
+	 *                ),
436
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
437
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
438
+	 *                visited just set
439
+	 *                'require_nonce' to FALSE
440
+	 *                )
441
+	 *                )
442
+	 *
443
+	 * @abstract
444
+	 */
445
+	abstract protected function _set_page_config();
446
+
447
+
448
+
449
+
450
+
451
+	/** end sample help_tour methods **/
452
+	/**
453
+	 * _add_screen_options
454
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
455
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
456
+	 * to a particular view.
457
+	 *
458
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
459
+	 *         see also WP_Screen object documents...
460
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
461
+	 * @abstract
462
+	 * @return void
463
+	 */
464
+	abstract protected function _add_screen_options();
465
+
466
+
467
+	/**
468
+	 * _add_feature_pointers
469
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
470
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
471
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
472
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
473
+	 * extended) also see:
474
+	 *
475
+	 * @link   http://eamann.com/tech/wordpress-portland/
476
+	 * @abstract
477
+	 * @return void
478
+	 */
479
+	abstract protected function _add_feature_pointers();
480
+
481
+
482
+	/**
483
+	 * load_scripts_styles
484
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
485
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
486
+	 * scripts/styles per view by putting them in a dynamic function in this format
487
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
488
+	 *
489
+	 * @abstract
490
+	 * @return void
491
+	 */
492
+	abstract public function load_scripts_styles();
493
+
494
+
495
+	/**
496
+	 * admin_init
497
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
498
+	 * all pages/views loaded by child class.
499
+	 *
500
+	 * @abstract
501
+	 * @return void
502
+	 */
503
+	abstract public function admin_init();
504
+
505
+
506
+	/**
507
+	 * admin_notices
508
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
509
+	 * all pages/views loaded by child class.
510
+	 *
511
+	 * @abstract
512
+	 * @return void
513
+	 */
514
+	abstract public function admin_notices();
515
+
516
+
517
+	/**
518
+	 * admin_footer_scripts
519
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
520
+	 * will apply to all pages/views loaded by child class.
521
+	 *
522
+	 * @return void
523
+	 */
524
+	abstract public function admin_footer_scripts();
525
+
526
+
527
+	/**
528
+	 * admin_footer
529
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
530
+	 * apply to all pages/views loaded by child class.
531
+	 *
532
+	 * @return void
533
+	 */
534
+	public function admin_footer()
535
+	{
536
+	}
537
+
538
+
539
+	/**
540
+	 * _global_ajax_hooks
541
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
542
+	 * Note: within the ajax callback methods.
543
+	 *
544
+	 * @abstract
545
+	 * @return void
546
+	 */
547
+	protected function _global_ajax_hooks()
548
+	{
549
+		// for lazy loading of metabox content
550
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
551
+
552
+		add_action(
553
+			'wp_ajax_espresso_hide_status_change_notice',
554
+			[$this, 'hideStatusChangeNotice']
555
+		);
556
+		add_action(
557
+			'wp_ajax_nopriv_espresso_hide_status_change_notice',
558
+			[$this, 'hideStatusChangeNotice']
559
+		);
560
+	}
561
+
562
+
563
+	public function ajax_metabox_content()
564
+	{
565
+		$content_id  = $this->request->getRequestParam('contentid', '');
566
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
567
+		EE_Admin_Page::cached_rss_display($content_id, $content_url);
568
+		wp_die();
569
+	}
570
+
571
+
572
+	public function hideStatusChangeNotice()
573
+	{
574
+		$response = [];
575
+		try {
576
+			/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
577
+			$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
578
+			$response['success'] = $status_change_notice->dismiss() > -1;
579
+		} catch (Exception $exception) {
580
+			$response['errors'] = $exception->getMessage();
581
+		}
582
+		echo wp_json_encode($response);
583
+		exit();
584
+	}
585
+
586
+
587
+	/**
588
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
589
+	 *
590
+	 * @return void
591
+	 */
592
+	protected function _before_page_setup()
593
+	{
594
+		// default is to do nothing
595
+	}
596
+
597
+
598
+	/**
599
+	 * Makes sure any things that need to be loaded early get handled.
600
+	 * We also escape early here if the page requested doesn't match the object.
601
+	 *
602
+	 * @final
603
+	 * @return void
604
+	 * @throws EE_Error
605
+	 * @throws InvalidArgumentException
606
+	 * @throws ReflectionException
607
+	 * @throws InvalidDataTypeException
608
+	 * @throws InvalidInterfaceException
609
+	 */
610
+	final protected function _page_setup()
611
+	{
612
+		// requires?
613
+		// admin_init stuff - global - we're setting this REALLY early
614
+		// so if EE_Admin pages have to hook into other WP pages they can.
615
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
616
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
617
+		// next verify if we need to load anything...
618
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
619
+		$this->page_folder   = strtolower(
620
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
621
+		);
622
+		global $ee_menu_slugs;
623
+		$ee_menu_slugs = (array) $ee_menu_slugs;
624
+		if (
625
+			! $this->request->isAjax()
626
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
627
+		) {
628
+			return;
629
+		}
630
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
631
+		// we need to copy the action from the second to the first
632
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
633
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
634
+		$action     = $action !== '-1' ? $action : $action2;
635
+		$req_action = $action !== '-1' ? $action : 'default';
636
+
637
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
638
+		// then let's use the route as the action.
639
+		// This covers cases where we're coming in from a list table that isn't on the default route.
640
+		$route = $this->request->getRequestParam('route');
641
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
642
+			? $route
643
+			: $req_action;
644
+
645
+		$this->_current_view = $this->_req_action;
646
+		$this->_req_nonce    = $this->_req_action . '_nonce';
647
+		$this->_define_page_props();
648
+		$this->_current_page_view_url = add_query_arg(
649
+			['page' => $this->_current_page, 'action' => $this->_current_view],
650
+			$this->_admin_base_url
651
+		);
652
+		// default things
653
+		$this->_default_espresso_metaboxes = [
654
+			'_espresso_news_post_box',
655
+			'_espresso_links_post_box',
656
+			'_espresso_ratings_request',
657
+			'_espresso_sponsors_post_box',
658
+		];
659
+		// set page configs
660
+		$this->_set_page_routes();
661
+		$this->_set_page_config();
662
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
663
+		if ($this->request->requestParamIsSet('wp_referer')) {
664
+			$wp_referer = $this->request->getRequestParam('wp_referer');
665
+			if ($wp_referer) {
666
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
667
+			}
668
+		}
669
+		// for caffeinated and other extended functionality.
670
+		//  If there is a _extend_page_config method
671
+		// then let's run that to modify the all the various page configuration arrays
672
+		if (method_exists($this, '_extend_page_config')) {
673
+			$this->_extend_page_config();
674
+		}
675
+		// for CPT and other extended functionality.
676
+		// If there is an _extend_page_config_for_cpt
677
+		// then let's run that to modify all the various page configuration arrays.
678
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
679
+			$this->_extend_page_config_for_cpt();
680
+		}
681
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
682
+		$this->_page_routes = apply_filters(
683
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
684
+			$this->_page_routes,
685
+			$this
686
+		);
687
+		$this->_page_config = apply_filters(
688
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
689
+			$this->_page_config,
690
+			$this
691
+		);
692
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
693
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
694
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
695
+			add_action(
696
+				'AHEE__EE_Admin_Page__route_admin_request',
697
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
698
+				10,
699
+				2
700
+			);
701
+		}
702
+		// next route only if routing enabled
703
+		if ($this->_routing && ! $this->request->isAjax()) {
704
+			$this->_verify_routes();
705
+			// next let's just check user_access and kill if no access
706
+			$this->check_user_access();
707
+			if ($this->_is_UI_request) {
708
+				// admin_init stuff - global, all views for this page class, specific view
709
+				add_action('admin_init', [$this, 'admin_init'], 10);
710
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
711
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
712
+				}
713
+			} else {
714
+				// hijack regular WP loading and route admin request immediately
715
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
716
+				$this->route_admin_request();
717
+			}
718
+		}
719
+	}
720
+
721
+
722
+	/**
723
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
724
+	 *
725
+	 * @return void
726
+	 * @throws EE_Error
727
+	 */
728
+	private function _do_other_page_hooks()
729
+	{
730
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
731
+		foreach ($registered_pages as $page) {
732
+			// now let's setup the file name and class that should be present
733
+			$classname = str_replace('.class.php', '', $page);
734
+			// autoloaders should take care of loading file
735
+			if (! class_exists($classname)) {
736
+				$error_msg[] = sprintf(
737
+					esc_html__(
738
+						'Something went wrong with loading the %s admin hooks page.',
739
+						'event_espresso'
740
+					),
741
+					$page
742
+				);
743
+				$error_msg[] = $error_msg[0]
744
+							   . "\r\n"
745
+							   . sprintf(
746
+								   esc_html__(
747
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
748
+									   'event_espresso'
749
+								   ),
750
+								   $page,
751
+								   '<br />',
752
+								   '<strong>' . $classname . '</strong>'
753
+							   );
754
+				throw new EE_Error(implode('||', $error_msg));
755
+			}
756
+			// notice we are passing the instance of this class to the hook object.
757
+			$this->loader->getShared($classname, [$this]);
758
+		}
759
+	}
760
+
761
+
762
+	/**
763
+	 * @throws ReflectionException
764
+	 * @throws EE_Error
765
+	 */
766
+	public function load_page_dependencies()
767
+	{
768
+		try {
769
+			$this->_load_page_dependencies();
770
+		} catch (EE_Error $e) {
771
+			$e->get_error();
772
+		}
773
+	}
774
+
775
+
776
+	/**
777
+	 * load_page_dependencies
778
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
779
+	 *
780
+	 * @return void
781
+	 * @throws DomainException
782
+	 * @throws EE_Error
783
+	 * @throws InvalidArgumentException
784
+	 * @throws InvalidDataTypeException
785
+	 * @throws InvalidInterfaceException
786
+	 */
787
+	protected function _load_page_dependencies()
788
+	{
789
+		// let's set the current_screen and screen options to override what WP set
790
+		$this->_current_screen = get_current_screen();
791
+		// load admin_notices - global, page class, and view specific
792
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
793
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
794
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
795
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
796
+		}
797
+		// load network admin_notices - global, page class, and view specific
798
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
799
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
800
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
801
+		}
802
+		// this will save any per_page screen options if they are present
803
+		$this->_set_per_page_screen_options();
804
+		// setup list table properties
805
+		$this->_set_list_table();
806
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
807
+		// However in some cases the metaboxes will need to be added within a route handling callback.
808
+		$this->_add_registered_meta_boxes();
809
+		$this->_add_screen_columns();
810
+		// add screen options - global, page child class, and view specific
811
+		$this->_add_global_screen_options();
812
+		$this->_add_screen_options();
813
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
814
+		if (method_exists($this, $add_screen_options)) {
815
+			$this->{$add_screen_options}();
816
+		}
817
+		// add help tab(s) and tours- set via page_config and qtips.
818
+		// $this->_add_help_tour();
819
+		$this->_add_help_tabs();
820
+		$this->_add_qtips();
821
+		// add feature_pointers - global, page child class, and view specific
822
+		$this->_add_feature_pointers();
823
+		$this->_add_global_feature_pointers();
824
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
825
+		if (method_exists($this, $add_feature_pointer)) {
826
+			$this->{$add_feature_pointer}();
827
+		}
828
+		// enqueue scripts/styles - global, page class, and view specific
829
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
830
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
831
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
832
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
833
+		}
834
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
835
+		// admin_print_footer_scripts - global, page child class, and view specific.
836
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
837
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
838
+		// is a good use case. Notice the late priority we're giving these
839
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
840
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
841
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
842
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
843
+		}
844
+		// admin footer scripts
845
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
846
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
847
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
848
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
849
+		}
850
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
851
+		// targeted hook
852
+		do_action(
853
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
854
+		);
855
+	}
856
+
857
+
858
+	/**
859
+	 * _set_defaults
860
+	 * This sets some global defaults for class properties.
861
+	 */
862
+	private function _set_defaults()
863
+	{
864
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
865
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
866
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
867
+		$this->_page_config          = $this->_default_route_query_args = [];
868
+		$this->_default_nav_tab_name = 'overview';
869
+		// init template args
870
+		$this->_template_args = [
871
+			'admin_page_header'  => '',
872
+			'admin_page_content' => '',
873
+			'post_body_content'  => '',
874
+			'before_list_table'  => '',
875
+			'after_list_table'   => '',
876
+		];
877
+	}
878
+
879
+
880
+	/**
881
+	 * route_admin_request
882
+	 *
883
+	 * @return void
884
+	 * @throws InvalidArgumentException
885
+	 * @throws InvalidInterfaceException
886
+	 * @throws InvalidDataTypeException
887
+	 * @throws EE_Error
888
+	 * @throws ReflectionException
889
+	 * @see    _route_admin_request()
890
+	 */
891
+	public function route_admin_request()
892
+	{
893
+		try {
894
+			$this->_route_admin_request();
895
+		} catch (EE_Error $e) {
896
+			$e->get_error();
897
+		}
898
+	}
899
+
900
+
901
+	public function set_wp_page_slug($wp_page_slug)
902
+	{
903
+		$this->_wp_page_slug = $wp_page_slug;
904
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
905
+		if (is_network_admin()) {
906
+			$this->_wp_page_slug .= '-network';
907
+		}
908
+	}
909
+
910
+
911
+	/**
912
+	 * _verify_routes
913
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
914
+	 * we know if we need to drop out.
915
+	 *
916
+	 * @return bool
917
+	 * @throws EE_Error
918
+	 */
919
+	protected function _verify_routes()
920
+	{
921
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
922
+		if (! $this->_current_page && ! $this->request->isAjax()) {
923
+			return false;
924
+		}
925
+		$this->_route = false;
926
+		// check that the page_routes array is not empty
927
+		if (empty($this->_page_routes)) {
928
+			// user error msg
929
+			$error_msg = sprintf(
930
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
931
+				$this->_admin_page_title
932
+			);
933
+			// developer error msg
934
+			$error_msg .= '||' . $error_msg
935
+						  . esc_html__(
936
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
937
+							  'event_espresso'
938
+						  );
939
+			throw new EE_Error($error_msg);
940
+		}
941
+		// and that the requested page route exists
942
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
943
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
944
+			$this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
945
+		} else {
946
+			// user error msg
947
+			$error_msg = sprintf(
948
+				esc_html__(
949
+					'The requested page route does not exist for the %s admin page.',
950
+					'event_espresso'
951
+				),
952
+				$this->_admin_page_title
953
+			);
954
+			// developer error msg
955
+			$error_msg .= '||' . $error_msg
956
+						  . sprintf(
957
+							  esc_html__(
958
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
959
+								  'event_espresso'
960
+							  ),
961
+							  $this->_req_action
962
+						  );
963
+			throw new EE_Error($error_msg);
964
+		}
965
+		// and that a default route exists
966
+		if (! array_key_exists('default', $this->_page_routes)) {
967
+			// user error msg
968
+			$error_msg = sprintf(
969
+				esc_html__(
970
+					'A default page route has not been set for the % admin page.',
971
+					'event_espresso'
972
+				),
973
+				$this->_admin_page_title
974
+			);
975
+			// developer error msg
976
+			$error_msg .= '||' . $error_msg
977
+						  . esc_html__(
978
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
979
+							  'event_espresso'
980
+						  );
981
+			throw new EE_Error($error_msg);
982
+		}
983
+
984
+		// first lets' catch if the UI request has EVER been set.
985
+		if ($this->_is_UI_request === null) {
986
+			// lets set if this is a UI request or not.
987
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
988
+			// wait a minute... we might have a noheader in the route array
989
+			$this->_is_UI_request = ! (
990
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
991
+			)
992
+				? $this->_is_UI_request
993
+				: false;
994
+		}
995
+		$this->_set_current_labels();
996
+		return true;
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1002
+	 *
1003
+	 * @param string $route the route name we're verifying
1004
+	 * @return bool we'll throw an exception if this isn't a valid route.
1005
+	 * @throws EE_Error
1006
+	 */
1007
+	protected function _verify_route($route)
1008
+	{
1009
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
1010
+			return true;
1011
+		}
1012
+		// user error msg
1013
+		$error_msg = sprintf(
1014
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1015
+			$this->_admin_page_title
1016
+		);
1017
+		// developer error msg
1018
+		$error_msg .= '||' . $error_msg
1019
+					  . sprintf(
1020
+						  esc_html__(
1021
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1022
+							  'event_espresso'
1023
+						  ),
1024
+						  $route
1025
+					  );
1026
+		throw new EE_Error($error_msg);
1027
+	}
1028
+
1029
+
1030
+	/**
1031
+	 * perform nonce verification
1032
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1033
+	 * using this method (and save retyping!)
1034
+	 *
1035
+	 * @param string $nonce     The nonce sent
1036
+	 * @param string $nonce_ref The nonce reference string (name0)
1037
+	 * @return void
1038
+	 * @throws EE_Error
1039
+	 * @throws InvalidArgumentException
1040
+	 * @throws InvalidDataTypeException
1041
+	 * @throws InvalidInterfaceException
1042
+	 */
1043
+	protected function _verify_nonce($nonce, $nonce_ref)
1044
+	{
1045
+		// verify nonce against expected value
1046
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
1047
+			// these are not the droids you are looking for !!!
1048
+			$msg = sprintf(
1049
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
1050
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1051
+				'</a>'
1052
+			);
1053
+			if (WP_DEBUG) {
1054
+				$msg .= "\n  ";
1055
+				$msg .= sprintf(
1056
+					esc_html__(
1057
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1058
+						'event_espresso'
1059
+					),
1060
+					__CLASS__
1061
+				);
1062
+			}
1063
+			if (! $this->request->isAjax()) {
1064
+				wp_die($msg);
1065
+			}
1066
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1067
+			$this->_return_json();
1068
+		}
1069
+	}
1070
+
1071
+
1072
+	/**
1073
+	 * _route_admin_request()
1074
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1075
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1076
+	 * in the page routes and then will try to load the corresponding method.
1077
+	 *
1078
+	 * @return void
1079
+	 * @throws EE_Error
1080
+	 * @throws InvalidArgumentException
1081
+	 * @throws InvalidDataTypeException
1082
+	 * @throws InvalidInterfaceException
1083
+	 * @throws ReflectionException
1084
+	 */
1085
+	protected function _route_admin_request()
1086
+	{
1087
+		if (! $this->_is_UI_request) {
1088
+			$this->_verify_routes();
1089
+		}
1090
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1091
+		if ($this->_req_action !== 'default' && $nonce_check) {
1092
+			// set nonce from post data
1093
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1094
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1095
+		}
1096
+		// set the nav_tabs array but ONLY if this is  UI_request
1097
+		if ($this->_is_UI_request) {
1098
+			$this->_set_nav_tabs();
1099
+		}
1100
+		// grab callback function
1101
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1102
+		// check if callback has args
1103
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1104
+		$error_msg = '';
1105
+		// action right before calling route
1106
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1107
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1108
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1109
+		}
1110
+		// right before calling the route, let's clean the _wp_http_referer
1111
+		$this->request->setServerParam(
1112
+			'REQUEST_URI',
1113
+			remove_query_arg(
1114
+				'_wp_http_referer',
1115
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1116
+			)
1117
+		);
1118
+		if (! empty($func)) {
1119
+			if (is_array($func)) {
1120
+				[$class, $method] = $func;
1121
+			} elseif (strpos($func, '::') !== false) {
1122
+				[$class, $method] = explode('::', $func);
1123
+			} else {
1124
+				$class  = $this;
1125
+				$method = $func;
1126
+			}
1127
+			if (! (is_object($class) && $class === $this)) {
1128
+				// send along this admin page object for access by addons.
1129
+				$args['admin_page_object'] = $this;
1130
+			}
1131
+			if (
1132
+				// is it a method on a class that doesn't work?
1133
+				(
1134
+					(
1135
+						method_exists($class, $method)
1136
+						&& call_user_func_array([$class, $method], $args) === false
1137
+					)
1138
+					&& (
1139
+						// is it a standalone function that doesn't work?
1140
+						function_exists($method)
1141
+						&& call_user_func_array(
1142
+							$func,
1143
+							array_merge(['admin_page_object' => $this], $args)
1144
+						) === false
1145
+					)
1146
+				)
1147
+				|| (
1148
+					// is it neither a class method NOR a standalone function?
1149
+					! method_exists($class, $method)
1150
+					&& ! function_exists($method)
1151
+				)
1152
+			) {
1153
+				// user error msg
1154
+				$error_msg = esc_html__(
1155
+					'An error occurred. The  requested page route could not be found.',
1156
+					'event_espresso'
1157
+				);
1158
+				// developer error msg
1159
+				$error_msg .= '||';
1160
+				$error_msg .= sprintf(
1161
+					esc_html__(
1162
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1163
+						'event_espresso'
1164
+					),
1165
+					$method
1166
+				);
1167
+			}
1168
+			if (! empty($error_msg)) {
1169
+				throw new EE_Error($error_msg);
1170
+			}
1171
+		}
1172
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1173
+		// then we need to reset the routing properties to the new route.
1174
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1175
+		if (
1176
+			$this->_is_UI_request === false
1177
+			&& is_array($this->_route)
1178
+			&& ! empty($this->_route['headers_sent_route'])
1179
+		) {
1180
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1181
+		}
1182
+	}
1183
+
1184
+
1185
+	/**
1186
+	 * This method just allows the resetting of page properties in the case where a no headers
1187
+	 * route redirects to a headers route in its route config.
1188
+	 *
1189
+	 * @param string $new_route New (non header) route to redirect to.
1190
+	 * @return   void
1191
+	 * @throws ReflectionException
1192
+	 * @throws InvalidArgumentException
1193
+	 * @throws InvalidInterfaceException
1194
+	 * @throws InvalidDataTypeException
1195
+	 * @throws EE_Error
1196
+	 * @since   4.3.0
1197
+	 */
1198
+	protected function _reset_routing_properties($new_route)
1199
+	{
1200
+		$this->_is_UI_request = true;
1201
+		// now we set the current route to whatever the headers_sent_route is set at
1202
+		$this->request->setRequestParam('action', $new_route);
1203
+		// rerun page setup
1204
+		$this->_page_setup();
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 * _add_query_arg
1210
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1211
+	 *(internally just uses EEH_URL's function with the same name)
1212
+	 *
1213
+	 * @param array  $args
1214
+	 * @param string $url
1215
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1216
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1217
+	 *                                        Example usage: If the current page is:
1218
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1219
+	 *                                        &action=default&event_id=20&month_range=March%202015
1220
+	 *                                        &_wpnonce=5467821
1221
+	 *                                        and you call:
1222
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1223
+	 *                                        array(
1224
+	 *                                        'action' => 'resend_something',
1225
+	 *                                        'page=>espresso_registrations'
1226
+	 *                                        ),
1227
+	 *                                        $some_url,
1228
+	 *                                        true
1229
+	 *                                        );
1230
+	 *                                        It will produce a url in this structure:
1231
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1232
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1233
+	 *                                        month_range]=March%202015
1234
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1235
+	 * @return string
1236
+	 */
1237
+	public static function add_query_args_and_nonce(
1238
+		$args = [],
1239
+		$url = '',
1240
+		$sticky = false,
1241
+		$exclude_nonce = false
1242
+	) {
1243
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1244
+		if ($sticky) {
1245
+			/** @var RequestInterface $request */
1246
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1247
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1248
+			foreach ($request->requestParams() as $key => $value) {
1249
+				// do not add nonces
1250
+				if (strpos($key, 'nonce') !== false) {
1251
+					continue;
1252
+				}
1253
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1254
+			}
1255
+		}
1256
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * This returns a generated link that will load the related help tab.
1262
+	 *
1263
+	 * @param string $help_tab_id the id for the connected help tab
1264
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1265
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1266
+	 * @return string              generated link
1267
+	 * @uses EEH_Template::get_help_tab_link()
1268
+	 */
1269
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1270
+	{
1271
+		return EEH_Template::get_help_tab_link(
1272
+			$help_tab_id,
1273
+			$this->page_slug,
1274
+			$this->_req_action,
1275
+			$icon_style,
1276
+			$help_text
1277
+		);
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * _add_help_tabs
1283
+	 * Note child classes define their help tabs within the page_config array.
1284
+	 *
1285
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1286
+	 * @return void
1287
+	 * @throws DomainException
1288
+	 * @throws EE_Error
1289
+	 * @throws ReflectionException
1290
+	 */
1291
+	protected function _add_help_tabs()
1292
+	{
1293
+		$tour_buttons = '';
1294
+		if (isset($this->_page_config[ $this->_req_action ])) {
1295
+			$config = $this->_page_config[ $this->_req_action ];
1296
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1297
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1298
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1299
+			//     $tb = array();
1300
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1301
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1302
+			//         // if this is the end tour then we don't need to setup a button
1303
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1304
+			//             continue;
1305
+			//         }
1306
+			//         $tb[] = '<button id="trigger-tour-'
1307
+			//                 . $tour->get_slug()
1308
+			//                 . '" class="button--primary trigger-ee-help-tour">'
1309
+			//                 . $tour->get_label()
1310
+			//                 . '</button>';
1311
+			//     }
1312
+			//     $tour_buttons .= implode('<br />', $tb);
1313
+			//     $tour_buttons .= '</div></div>';
1314
+			// }
1315
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1316
+			if (is_array($config) && isset($config['help_sidebar'])) {
1317
+				// check that the callback given is valid
1318
+				if (! method_exists($this, $config['help_sidebar'])) {
1319
+					throw new EE_Error(
1320
+						sprintf(
1321
+							esc_html__(
1322
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1323
+								'event_espresso'
1324
+							),
1325
+							$config['help_sidebar'],
1326
+							get_class($this)
1327
+						)
1328
+					);
1329
+				}
1330
+				$content = apply_filters(
1331
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1332
+					$this->{$config['help_sidebar']}()
1333
+				);
1334
+				$content .= $tour_buttons; // add help tour buttons.
1335
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1336
+				$this->_current_screen->set_help_sidebar($content);
1337
+			}
1338
+			// if there ARE tour buttons...
1339
+			if (! empty($tour_buttons)) {
1340
+				// if we DON'T have config help sidebar then we'll just add the tour buttons to the sidebar.
1341
+				if (! isset($config['help_sidebar'])) {
1342
+					$this->_current_screen->set_help_sidebar($tour_buttons);
1343
+				}
1344
+				// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1345
+				if (! isset($config['help_tabs'])) {
1346
+					$_ht['id'] = $this->page_slug;
1347
+					$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1348
+					$_ht['content'] = '<p>'
1349
+									  . esc_html__(
1350
+										  'The buttons to the right allow you to start/restart any help tours available for this page',
1351
+										  'event_espresso'
1352
+									  ) . '</p>';
1353
+					$this->_current_screen->add_help_tab($_ht);
1354
+				}
1355
+			}
1356
+			if (! isset($config['help_tabs'])) {
1357
+				return;
1358
+			} //no help tabs for this route
1359
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1360
+				// we're here so there ARE help tabs!
1361
+				// make sure we've got what we need
1362
+				if (! isset($cfg['title'])) {
1363
+					throw new EE_Error(
1364
+						esc_html__(
1365
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1366
+							'event_espresso'
1367
+						)
1368
+					);
1369
+				}
1370
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1371
+					throw new EE_Error(
1372
+						esc_html__(
1373
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1374
+							'event_espresso'
1375
+						)
1376
+					);
1377
+				}
1378
+				// first priority goes to content.
1379
+				if (! empty($cfg['content'])) {
1380
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1381
+					// second priority goes to filename
1382
+				} elseif (! empty($cfg['filename'])) {
1383
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1384
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1385
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1386
+															 . basename($this->_get_dir())
1387
+															 . '/help_tabs/'
1388
+															 . $cfg['filename']
1389
+															 . '.help_tab.php' : $file_path;
1390
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1391
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1392
+						EE_Error::add_error(
1393
+							sprintf(
1394
+								esc_html__(
1395
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1396
+									'event_espresso'
1397
+								),
1398
+								$tab_id,
1399
+								key($config),
1400
+								$file_path
1401
+							),
1402
+							__FILE__,
1403
+							__FUNCTION__,
1404
+							__LINE__
1405
+						);
1406
+						return;
1407
+					}
1408
+					$template_args['admin_page_obj'] = $this;
1409
+					$content                         = EEH_Template::display_template(
1410
+						$file_path,
1411
+						$template_args,
1412
+						true
1413
+					);
1414
+				} else {
1415
+					$content = '';
1416
+				}
1417
+				// check if callback is valid
1418
+				if (
1419
+					empty($content)
1420
+					&& (
1421
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1422
+					)
1423
+				) {
1424
+					EE_Error::add_error(
1425
+						sprintf(
1426
+							esc_html__(
1427
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1428
+								'event_espresso'
1429
+							),
1430
+							$cfg['title']
1431
+						),
1432
+						__FILE__,
1433
+						__FUNCTION__,
1434
+						__LINE__
1435
+					);
1436
+					return;
1437
+				}
1438
+				// setup config array for help tab method
1439
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1440
+				$_ht = [
1441
+					'id'       => $id,
1442
+					'title'    => $cfg['title'],
1443
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1444
+					'content'  => $content,
1445
+				];
1446
+				$this->_current_screen->add_help_tab($_ht);
1447
+			}
1448
+		}
1449
+	}
1450
+
1451
+
1452
+	/**
1453
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1454
+	 * an array with properties for setting up usage of the joyride plugin
1455
+	 *
1456
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1457
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1458
+	 *         _set_page_config() comments
1459
+	 * @return void
1460
+	 * @throws InvalidArgumentException
1461
+	 * @throws InvalidDataTypeException
1462
+	 * @throws InvalidInterfaceException
1463
+	 * @throws ReflectionException
1464
+	 */
1465
+	protected function _add_help_tour()
1466
+	{
1467
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1468
+		// $tours = array();
1469
+		// $this->_help_tour = array();
1470
+		// // exit early if help tours are turned off globally
1471
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1472
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1473
+		// ) {
1474
+		//     return;
1475
+		// }
1476
+		// // loop through _page_config to find any help_tour defined
1477
+		// foreach ($this->_page_config as $route => $config) {
1478
+		//     // we're only going to set things up for this route
1479
+		//     if ($route !== $this->_req_action) {
1480
+		//         continue;
1481
+		//     }
1482
+		//     if (isset($config['help_tour'])) {
1483
+		//         foreach ($config['help_tour'] as $tour) {
1484
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1485
+		//             // let's see if we can get that file...
1486
+		//             // if not its possible this is a decaf route not set in caffeinated
1487
+		//             // so lets try and get the caffeinated equivalent
1488
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1489
+		//                                                      . basename($this->_get_dir())
1490
+		//                                                      . '/help_tours/'
1491
+		//                                                      . $tour
1492
+		//                                                      . '.class.php' : $file_path;
1493
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1494
+		//             if (! is_readable($file_path)) {
1495
+		//                 EE_Error::add_error(
1496
+		//                     sprintf(
1497
+		//                         esc_html__(
1498
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1499
+		//                             'event_espresso'
1500
+		//                         ),
1501
+		//                         $file_path,
1502
+		//                         $tour
1503
+		//                     ),
1504
+		//                     __FILE__,
1505
+		//                     __FUNCTION__,
1506
+		//                     __LINE__
1507
+		//                 );
1508
+		//                 return;
1509
+		//             }
1510
+		//             require_once $file_path;
1511
+		//             if (! class_exists($tour)) {
1512
+		//                 $error_msg[] = sprintf(
1513
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1514
+		//                     $tour
1515
+		//                 );
1516
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1517
+		//                                . sprintf(
1518
+		//                                    esc_html__(
1519
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1520
+		//                                        'event_espresso'
1521
+		//                                    ),
1522
+		//                                    $tour,
1523
+		//                                    '<br />',
1524
+		//                                    $tour,
1525
+		//                                    $this->_req_action,
1526
+		//                                    get_class($this)
1527
+		//                                );
1528
+		//                 throw new EE_Error(implode('||', $error_msg));
1529
+		//             }
1530
+		//             $tour_obj = new $tour($this->_is_caf);
1531
+		//             $tours[] = $tour_obj;
1532
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1533
+		//         }
1534
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1535
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1536
+		//         $tours[] = $end_stop_tour;
1537
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1538
+		//     }
1539
+		// }
1540
+		//
1541
+		// if (! empty($tours)) {
1542
+		//     $this->_help_tour['tours'] = $tours;
1543
+		// }
1544
+		// // that's it!  Now that the $_help_tours property is set (or not)
1545
+		// // the scripts and html should be taken care of automatically.
1546
+		//
1547
+		// /**
1548
+		//  * Allow extending the help tours variable.
1549
+		//  *
1550
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1551
+		//  */
1552
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1553
+	}
1554
+
1555
+
1556
+	/**
1557
+	 * This simply sets up any qtips that have been defined in the page config
1558
+	 *
1559
+	 * @return void
1560
+	 * @throws ReflectionException
1561
+	 * @throws EE_Error
1562
+	 */
1563
+	protected function _add_qtips()
1564
+	{
1565
+		if (isset($this->_route_config['qtips'])) {
1566
+			$qtips = (array) $this->_route_config['qtips'];
1567
+			// load qtip loader
1568
+			$path = [
1569
+				$this->_get_dir() . '/qtips/',
1570
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1571
+			];
1572
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1573
+		}
1574
+	}
1575
+
1576
+
1577
+	/**
1578
+	 * _set_nav_tabs
1579
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1580
+	 * wish to add additional tabs or modify accordingly.
1581
+	 *
1582
+	 * @return void
1583
+	 * @throws InvalidArgumentException
1584
+	 * @throws InvalidInterfaceException
1585
+	 * @throws InvalidDataTypeException
1586
+	 */
1587
+	protected function _set_nav_tabs()
1588
+	{
1589
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1590
+		$i = 0;
1591
+		foreach ($this->_page_config as $slug => $config) {
1592
+			if (! is_array($config) || empty($config['nav'])) {
1593
+				continue;
1594
+			}
1595
+			// no nav tab for this config
1596
+			// check for persistent flag
1597
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1598
+				// nav tab is only to appear when route requested.
1599
+				continue;
1600
+			}
1601
+			if (! $this->check_user_access($slug, true)) {
1602
+				// no nav tab because current user does not have access.
1603
+				continue;
1604
+			}
1605
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1606
+			$this->_nav_tabs[ $slug ] = [
1607
+				'url'       => isset($config['nav']['url'])
1608
+					? $config['nav']['url']
1609
+					: EE_Admin_Page::add_query_args_and_nonce(
1610
+						['action' => $slug],
1611
+						$this->_admin_base_url
1612
+					),
1613
+				'link_text' => isset($config['nav']['label'])
1614
+					? $config['nav']['label']
1615
+					: ucwords(
1616
+						str_replace('_', ' ', $slug)
1617
+					),
1618
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1619
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1620
+			];
1621
+			$i++;
1622
+		}
1623
+		// if $this->_nav_tabs is empty then lets set the default
1624
+		if (empty($this->_nav_tabs)) {
1625
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1626
+				'url'       => $this->_admin_base_url,
1627
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1628
+				'css_class' => 'nav-tab-active',
1629
+				'order'     => 10,
1630
+			];
1631
+		}
1632
+		// now let's sort the tabs according to order
1633
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1634
+	}
1635
+
1636
+
1637
+	/**
1638
+	 * _set_current_labels
1639
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1640
+	 * property array
1641
+	 *
1642
+	 * @return void
1643
+	 */
1644
+	private function _set_current_labels()
1645
+	{
1646
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1647
+			foreach ($this->_route_config['labels'] as $label => $text) {
1648
+				if (is_array($text)) {
1649
+					foreach ($text as $sublabel => $subtext) {
1650
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1651
+					}
1652
+				} else {
1653
+					$this->_labels[ $label ] = $text;
1654
+				}
1655
+			}
1656
+		}
1657
+	}
1658
+
1659
+
1660
+	/**
1661
+	 *        verifies user access for this admin page
1662
+	 *
1663
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1664
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1665
+	 *                               return false if verify fail.
1666
+	 * @return bool
1667
+	 * @throws InvalidArgumentException
1668
+	 * @throws InvalidDataTypeException
1669
+	 * @throws InvalidInterfaceException
1670
+	 */
1671
+	public function check_user_access($route_to_check = '', $verify_only = false)
1672
+	{
1673
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1674
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1675
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1676
+						  && is_array(
1677
+							  $this->_page_routes[ $route_to_check ]
1678
+						  )
1679
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1680
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1681
+		if (empty($capability) && empty($route_to_check)) {
1682
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1683
+				: $this->_route['capability'];
1684
+		} else {
1685
+			$capability = empty($capability) ? 'manage_options' : $capability;
1686
+		}
1687
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1688
+		if (
1689
+			! $this->request->isAjax()
1690
+			&& (
1691
+				! function_exists('is_admin')
1692
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1693
+					$capability,
1694
+					$this->page_slug
1695
+					. '_'
1696
+					. $route_to_check,
1697
+					$id
1698
+				)
1699
+			)
1700
+		) {
1701
+			if ($verify_only) {
1702
+				return false;
1703
+			}
1704
+			if (is_user_logged_in()) {
1705
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1706
+			} else {
1707
+				return false;
1708
+			}
1709
+		}
1710
+		return true;
1711
+	}
1712
+
1713
+
1714
+	protected function addMetaBox(
1715
+		$box_id,
1716
+		$title,
1717
+		$callback,
1718
+		$screen,
1719
+		$context = 'normal',
1720
+		$priority = 'default',
1721
+		$callback_args = null
1722
+	) {
1723
+		add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1724
+		add_filter(
1725
+			"postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1726
+			function ($classes) {
1727
+				array_push($classes, 'ee-admin-container');
1728
+				return $classes;
1729
+			}
1730
+		);
1731
+	}
1732
+
1733
+
1734
+	/**
1735
+	 * admin_init_global
1736
+	 * This runs all the code that we want executed within the WP admin_init hook.
1737
+	 * This method executes for ALL EE Admin pages.
1738
+	 *
1739
+	 * @return void
1740
+	 */
1741
+	public function admin_init_global()
1742
+	{
1743
+	}
1744
+
1745
+
1746
+	/**
1747
+	 * wp_loaded_global
1748
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1749
+	 * EE_Admin page and will execute on every EE Admin Page load
1750
+	 *
1751
+	 * @return void
1752
+	 */
1753
+	public function wp_loaded()
1754
+	{
1755
+	}
1756
+
1757
+
1758
+	/**
1759
+	 * admin_notices
1760
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1761
+	 * ALL EE_Admin pages.
1762
+	 *
1763
+	 * @return void
1764
+	 */
1765
+	public function admin_notices_global()
1766
+	{
1767
+		$this->_display_no_javascript_warning();
1768
+		$this->_display_espresso_notices();
1769
+	}
1770
+
1771
+
1772
+	public function network_admin_notices_global()
1773
+	{
1774
+		$this->_display_no_javascript_warning();
1775
+		$this->_display_espresso_notices();
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 * admin_footer_scripts_global
1781
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1782
+	 * will apply on ALL EE_Admin pages.
1783
+	 *
1784
+	 * @return void
1785
+	 */
1786
+	public function admin_footer_scripts_global()
1787
+	{
1788
+		$this->_add_admin_page_ajax_loading_img();
1789
+		$this->_add_admin_page_overlay();
1790
+		// if metaboxes are present we need to add the nonce field
1791
+		if (
1792
+			isset($this->_route_config['metaboxes'])
1793
+			|| isset($this->_route_config['list_table'])
1794
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1795
+		) {
1796
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1797
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1798
+		}
1799
+	}
1800
+
1801
+
1802
+	/**
1803
+	 * admin_footer_global
1804
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1805
+	 * This particular method will apply on ALL EE_Admin Pages.
1806
+	 *
1807
+	 * @return void
1808
+	 */
1809
+	public function admin_footer_global()
1810
+	{
1811
+		// dialog container for dialog helper
1812
+		echo '
1813 1813
         <div class="ee-admin-dialog-container auto-hide hidden">
1814 1814
             <div class="ee-notices"></div>
1815 1815
             <div class="ee-admin-dialog-container-inner-content"></div>
1816 1816
         </div>
1817 1817
         ';
1818 1818
 
1819
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1820
-        // help tour stuff?
1821
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1822
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1823
-        // }
1824
-        // current set timezone for timezone js
1825
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1831
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1832
-     * help popups then in your templates or your content you set "triggers" for the content using the
1833
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1834
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1835
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1836
-     * for the
1837
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1838
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1839
-     *    'help_trigger_id' => array(
1840
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1841
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1842
-     *    )
1843
-     * );
1844
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1845
-     *
1846
-     * @param array $help_array
1847
-     * @param bool  $display
1848
-     * @return string content
1849
-     * @throws DomainException
1850
-     * @throws EE_Error
1851
-     */
1852
-    protected function _set_help_popup_content($help_array = [], $display = false)
1853
-    {
1854
-        $content    = '';
1855
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1856
-        // loop through the array and setup content
1857
-        foreach ($help_array as $trigger => $help) {
1858
-            // make sure the array is setup properly
1859
-            if (! isset($help['title'], $help['content'])) {
1860
-                throw new EE_Error(
1861
-                    esc_html__(
1862
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1863
-                        'event_espresso'
1864
-                    )
1865
-                );
1866
-            }
1867
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1868
-            $template_args = [
1869
-                'help_popup_id'      => $trigger,
1870
-                'help_popup_title'   => $help['title'],
1871
-                'help_popup_content' => $help['content'],
1872
-            ];
1873
-            $content       .= EEH_Template::display_template(
1874
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1875
-                $template_args,
1876
-                true
1877
-            );
1878
-        }
1879
-        if ($display) {
1880
-            echo $content; // already escaped
1881
-            return '';
1882
-        }
1883
-        return $content;
1884
-    }
1885
-
1886
-
1887
-    /**
1888
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1889
-     *
1890
-     * @return array properly formatted array for help popup content
1891
-     * @throws EE_Error
1892
-     */
1893
-    private function _get_help_content()
1894
-    {
1895
-        // what is the method we're looking for?
1896
-        $method_name = '_help_popup_content_' . $this->_req_action;
1897
-        // if method doesn't exist let's get out.
1898
-        if (! method_exists($this, $method_name)) {
1899
-            return [];
1900
-        }
1901
-        // k we're good to go let's retrieve the help array
1902
-        $help_array = $this->{$method_name}();
1903
-        // make sure we've got an array!
1904
-        if (! is_array($help_array)) {
1905
-            throw new EE_Error(
1906
-                esc_html__(
1907
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1908
-                    'event_espresso'
1909
-                )
1910
-            );
1911
-        }
1912
-        return $help_array;
1913
-    }
1914
-
1915
-
1916
-    /**
1917
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1918
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1919
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1920
-     *
1921
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1922
-     * @param boolean $display    if false then we return the trigger string
1923
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1924
-     * @return string
1925
-     * @throws DomainException
1926
-     * @throws EE_Error
1927
-     */
1928
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1929
-    {
1930
-        if ($this->request->isAjax()) {
1931
-            return '';
1932
-        }
1933
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1934
-        $help_array   = $this->_get_help_content();
1935
-        $help_content = '';
1936
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1937
-            $help_array[ $trigger_id ] = [
1938
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1939
-                'content' => esc_html__(
1940
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1941
-                    'event_espresso'
1942
-                ),
1943
-            ];
1944
-            $help_content = $this->_set_help_popup_content($help_array);
1945
-        }
1946
-        // let's setup the trigger
1947
-        $content = '<a class="ee-dialog" href="?height='
1948
-                   . esc_attr($dimensions[0])
1949
-                   . '&width='
1950
-                   . esc_attr($dimensions[1])
1951
-                   . '&inlineId='
1952
-                   . esc_attr($trigger_id)
1953
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1954
-        $content .= $help_content;
1955
-        if ($display) {
1956
-            echo $content; // already escaped
1957
-            return '';
1958
-        }
1959
-        return $content;
1960
-    }
1961
-
1962
-
1963
-    /**
1964
-     * _add_global_screen_options
1965
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1966
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1967
-     *
1968
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1969
-     *         see also WP_Screen object documents...
1970
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1971
-     * @abstract
1972
-     * @return void
1973
-     */
1974
-    private function _add_global_screen_options()
1975
-    {
1976
-    }
1977
-
1978
-
1979
-    /**
1980
-     * _add_global_feature_pointers
1981
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1982
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1983
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1984
-     *
1985
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1986
-     *         extended) also see:
1987
-     * @link   http://eamann.com/tech/wordpress-portland/
1988
-     * @abstract
1989
-     * @return void
1990
-     */
1991
-    private function _add_global_feature_pointers()
1992
-    {
1993
-    }
1994
-
1995
-
1996
-    /**
1997
-     * load_global_scripts_styles
1998
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1999
-     *
2000
-     * @return void
2001
-     */
2002
-    public function load_global_scripts_styles()
2003
-    {
2004
-        // add debugging styles
2005
-        if (WP_DEBUG) {
2006
-            add_action('admin_head', [$this, 'add_xdebug_style']);
2007
-        }
2008
-        // taking care of metaboxes
2009
-        if (
2010
-            empty($this->_cpt_route)
2011
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2012
-        ) {
2013
-            wp_enqueue_script('dashboard');
2014
-        }
2015
-
2016
-        wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
2017
-        // LOCALIZED DATA
2018
-        // localize script for ajax lazy loading
2019
-        wp_localize_script(
2020
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
2021
-            'eeLazyLoadingContainers',
2022
-            apply_filters(
2023
-                'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2024
-                ['espresso_news_post_box_content']
2025
-            )
2026
-        );
2027
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2028
-        // /**
2029
-        //  * help tour stuff
2030
-        //  */
2031
-        // if (! empty($this->_help_tour)) {
2032
-        //     // register the js for kicking things off
2033
-        //     wp_enqueue_script(
2034
-        //         'ee-help-tour',
2035
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2036
-        //         array('jquery-joyride'),
2037
-        //         EVENT_ESPRESSO_VERSION,
2038
-        //         true
2039
-        //     );
2040
-        //     $tours = array();
2041
-        //     // setup tours for the js tour object
2042
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2043
-        //         if ($tour instanceof EE_Help_Tour) {
2044
-        //             $tours[] = array(
2045
-        //                 'id'      => $tour->get_slug(),
2046
-        //                 'options' => $tour->get_options(),
2047
-        //             );
2048
-        //         }
2049
-        //     }
2050
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2051
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2052
-        // }
2053
-
2054
-        add_filter(
2055
-            'admin_body_class',
2056
-            function ($classes) {
2057
-                if (strpos($classes, 'espresso-admin') === false) {
2058
-                    $classes .= ' espresso-admin';
2059
-                }
2060
-                return $classes;
2061
-            }
2062
-        );
2063
-    }
2064
-
2065
-
2066
-    /**
2067
-     *        admin_footer_scripts_eei18n_js_strings
2068
-     *
2069
-     * @return        void
2070
-     */
2071
-    public function admin_footer_scripts_eei18n_js_strings()
2072
-    {
2073
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2074
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2075
-            __(
2076
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2077
-                'event_espresso'
2078
-            )
2079
-        );
2080
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2105
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2106
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2107
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2108
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2109
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2110
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2111
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2112
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2113
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2114
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2115
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2116
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2117
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2118
-    }
2119
-
2120
-
2121
-    /**
2122
-     *        load enhanced xdebug styles for ppl with failing eyesight
2123
-     *
2124
-     * @return        void
2125
-     */
2126
-    public function add_xdebug_style()
2127
-    {
2128
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2129
-    }
2130
-
2131
-
2132
-    /************************/
2133
-    /** LIST TABLE METHODS **/
2134
-    /************************/
2135
-    /**
2136
-     * this sets up the list table if the current view requires it.
2137
-     *
2138
-     * @return void
2139
-     * @throws EE_Error
2140
-     * @throws InvalidArgumentException
2141
-     * @throws InvalidDataTypeException
2142
-     * @throws InvalidInterfaceException
2143
-     */
2144
-    protected function _set_list_table()
2145
-    {
2146
-        // first is this a list_table view?
2147
-        if (! isset($this->_route_config['list_table'])) {
2148
-            return;
2149
-        } //not a list_table view so get out.
2150
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2151
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2152
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2153
-            // user error msg
2154
-            $error_msg = esc_html__(
2155
-                'An error occurred. The requested list table views could not be found.',
2156
-                'event_espresso'
2157
-            );
2158
-            // developer error msg
2159
-            $error_msg .= '||'
2160
-                          . sprintf(
2161
-                              esc_html__(
2162
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2163
-                                  'event_espresso'
2164
-                              ),
2165
-                              $this->_req_action,
2166
-                              $list_table_view
2167
-                          );
2168
-            throw new EE_Error($error_msg);
2169
-        }
2170
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2171
-        $this->_views = apply_filters(
2172
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2173
-            $this->_views
2174
-        );
2175
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2176
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2177
-        $this->_set_list_table_view();
2178
-        $this->_set_list_table_object();
2179
-    }
2180
-
2181
-
2182
-    /**
2183
-     * set current view for List Table
2184
-     *
2185
-     * @return void
2186
-     */
2187
-    protected function _set_list_table_view()
2188
-    {
2189
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2190
-        $status = $this->request->getRequestParam('status', null, 'key');
2191
-        $this->_view = $status && array_key_exists($status, $this->_views)
2192
-            ? $status
2193
-            : $this->_view;
2194
-    }
2195
-
2196
-
2197
-    /**
2198
-     * _set_list_table_object
2199
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2200
-     *
2201
-     * @throws InvalidInterfaceException
2202
-     * @throws InvalidArgumentException
2203
-     * @throws InvalidDataTypeException
2204
-     * @throws EE_Error
2205
-     * @throws InvalidInterfaceException
2206
-     */
2207
-    protected function _set_list_table_object()
2208
-    {
2209
-        if (isset($this->_route_config['list_table'])) {
2210
-            if (! class_exists($this->_route_config['list_table'])) {
2211
-                throw new EE_Error(
2212
-                    sprintf(
2213
-                        esc_html__(
2214
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2215
-                            'event_espresso'
2216
-                        ),
2217
-                        $this->_route_config['list_table'],
2218
-                        get_class($this)
2219
-                    )
2220
-                );
2221
-            }
2222
-            $this->_list_table_object = $this->loader->getShared(
2223
-                $this->_route_config['list_table'],
2224
-                [$this]
2225
-            );
2226
-        }
2227
-    }
2228
-
2229
-
2230
-    /**
2231
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2232
-     *
2233
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2234
-     *                                                    urls.  The array should be indexed by the view it is being
2235
-     *                                                    added to.
2236
-     * @return array
2237
-     */
2238
-    public function get_list_table_view_RLs($extra_query_args = [])
2239
-    {
2240
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2241
-        if (empty($this->_views)) {
2242
-            $this->_views = [];
2243
-        }
2244
-        // cycle thru views
2245
-        foreach ($this->_views as $key => $view) {
2246
-            $query_args = [];
2247
-            // check for current view
2248
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2249
-            $query_args['action']                        = $this->_req_action;
2250
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2251
-            $query_args['status']                        = $view['slug'];
2252
-            // merge any other arguments sent in.
2253
-            if (isset($extra_query_args[ $view['slug'] ])) {
2254
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2255
-                    $query_args[] = $extra_query_arg;
2256
-                }
2257
-            }
2258
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2259
-        }
2260
-        return $this->_views;
2261
-    }
2262
-
2263
-
2264
-    /**
2265
-     * _entries_per_page_dropdown
2266
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2267
-     *
2268
-     * @param int $max_entries total number of rows in the table
2269
-     * @return string
2270
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2271
-     *         WP does it.
2272
-     */
2273
-    protected function _entries_per_page_dropdown($max_entries = 0)
2274
-    {
2275
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2276
-        $values   = [10, 25, 50, 100];
2277
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2278
-        if ($max_entries) {
2279
-            $values[] = $max_entries;
2280
-            sort($values);
2281
-        }
2282
-        $entries_per_page_dropdown = '
1819
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1820
+		// help tour stuff?
1821
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1822
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1823
+		// }
1824
+		// current set timezone for timezone js
1825
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1831
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1832
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1833
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1834
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1835
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1836
+	 * for the
1837
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1838
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1839
+	 *    'help_trigger_id' => array(
1840
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1841
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1842
+	 *    )
1843
+	 * );
1844
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1845
+	 *
1846
+	 * @param array $help_array
1847
+	 * @param bool  $display
1848
+	 * @return string content
1849
+	 * @throws DomainException
1850
+	 * @throws EE_Error
1851
+	 */
1852
+	protected function _set_help_popup_content($help_array = [], $display = false)
1853
+	{
1854
+		$content    = '';
1855
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1856
+		// loop through the array and setup content
1857
+		foreach ($help_array as $trigger => $help) {
1858
+			// make sure the array is setup properly
1859
+			if (! isset($help['title'], $help['content'])) {
1860
+				throw new EE_Error(
1861
+					esc_html__(
1862
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1863
+						'event_espresso'
1864
+					)
1865
+				);
1866
+			}
1867
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1868
+			$template_args = [
1869
+				'help_popup_id'      => $trigger,
1870
+				'help_popup_title'   => $help['title'],
1871
+				'help_popup_content' => $help['content'],
1872
+			];
1873
+			$content       .= EEH_Template::display_template(
1874
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1875
+				$template_args,
1876
+				true
1877
+			);
1878
+		}
1879
+		if ($display) {
1880
+			echo $content; // already escaped
1881
+			return '';
1882
+		}
1883
+		return $content;
1884
+	}
1885
+
1886
+
1887
+	/**
1888
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1889
+	 *
1890
+	 * @return array properly formatted array for help popup content
1891
+	 * @throws EE_Error
1892
+	 */
1893
+	private function _get_help_content()
1894
+	{
1895
+		// what is the method we're looking for?
1896
+		$method_name = '_help_popup_content_' . $this->_req_action;
1897
+		// if method doesn't exist let's get out.
1898
+		if (! method_exists($this, $method_name)) {
1899
+			return [];
1900
+		}
1901
+		// k we're good to go let's retrieve the help array
1902
+		$help_array = $this->{$method_name}();
1903
+		// make sure we've got an array!
1904
+		if (! is_array($help_array)) {
1905
+			throw new EE_Error(
1906
+				esc_html__(
1907
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1908
+					'event_espresso'
1909
+				)
1910
+			);
1911
+		}
1912
+		return $help_array;
1913
+	}
1914
+
1915
+
1916
+	/**
1917
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1918
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1919
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1920
+	 *
1921
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1922
+	 * @param boolean $display    if false then we return the trigger string
1923
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1924
+	 * @return string
1925
+	 * @throws DomainException
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1929
+	{
1930
+		if ($this->request->isAjax()) {
1931
+			return '';
1932
+		}
1933
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1934
+		$help_array   = $this->_get_help_content();
1935
+		$help_content = '';
1936
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1937
+			$help_array[ $trigger_id ] = [
1938
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1939
+				'content' => esc_html__(
1940
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1941
+					'event_espresso'
1942
+				),
1943
+			];
1944
+			$help_content = $this->_set_help_popup_content($help_array);
1945
+		}
1946
+		// let's setup the trigger
1947
+		$content = '<a class="ee-dialog" href="?height='
1948
+				   . esc_attr($dimensions[0])
1949
+				   . '&width='
1950
+				   . esc_attr($dimensions[1])
1951
+				   . '&inlineId='
1952
+				   . esc_attr($trigger_id)
1953
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1954
+		$content .= $help_content;
1955
+		if ($display) {
1956
+			echo $content; // already escaped
1957
+			return '';
1958
+		}
1959
+		return $content;
1960
+	}
1961
+
1962
+
1963
+	/**
1964
+	 * _add_global_screen_options
1965
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1966
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1967
+	 *
1968
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1969
+	 *         see also WP_Screen object documents...
1970
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1971
+	 * @abstract
1972
+	 * @return void
1973
+	 */
1974
+	private function _add_global_screen_options()
1975
+	{
1976
+	}
1977
+
1978
+
1979
+	/**
1980
+	 * _add_global_feature_pointers
1981
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1982
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1983
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1984
+	 *
1985
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1986
+	 *         extended) also see:
1987
+	 * @link   http://eamann.com/tech/wordpress-portland/
1988
+	 * @abstract
1989
+	 * @return void
1990
+	 */
1991
+	private function _add_global_feature_pointers()
1992
+	{
1993
+	}
1994
+
1995
+
1996
+	/**
1997
+	 * load_global_scripts_styles
1998
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1999
+	 *
2000
+	 * @return void
2001
+	 */
2002
+	public function load_global_scripts_styles()
2003
+	{
2004
+		// add debugging styles
2005
+		if (WP_DEBUG) {
2006
+			add_action('admin_head', [$this, 'add_xdebug_style']);
2007
+		}
2008
+		// taking care of metaboxes
2009
+		if (
2010
+			empty($this->_cpt_route)
2011
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2012
+		) {
2013
+			wp_enqueue_script('dashboard');
2014
+		}
2015
+
2016
+		wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
2017
+		// LOCALIZED DATA
2018
+		// localize script for ajax lazy loading
2019
+		wp_localize_script(
2020
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
2021
+			'eeLazyLoadingContainers',
2022
+			apply_filters(
2023
+				'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2024
+				['espresso_news_post_box_content']
2025
+			)
2026
+		);
2027
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2028
+		// /**
2029
+		//  * help tour stuff
2030
+		//  */
2031
+		// if (! empty($this->_help_tour)) {
2032
+		//     // register the js for kicking things off
2033
+		//     wp_enqueue_script(
2034
+		//         'ee-help-tour',
2035
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2036
+		//         array('jquery-joyride'),
2037
+		//         EVENT_ESPRESSO_VERSION,
2038
+		//         true
2039
+		//     );
2040
+		//     $tours = array();
2041
+		//     // setup tours for the js tour object
2042
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2043
+		//         if ($tour instanceof EE_Help_Tour) {
2044
+		//             $tours[] = array(
2045
+		//                 'id'      => $tour->get_slug(),
2046
+		//                 'options' => $tour->get_options(),
2047
+		//             );
2048
+		//         }
2049
+		//     }
2050
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2051
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2052
+		// }
2053
+
2054
+		add_filter(
2055
+			'admin_body_class',
2056
+			function ($classes) {
2057
+				if (strpos($classes, 'espresso-admin') === false) {
2058
+					$classes .= ' espresso-admin';
2059
+				}
2060
+				return $classes;
2061
+			}
2062
+		);
2063
+	}
2064
+
2065
+
2066
+	/**
2067
+	 *        admin_footer_scripts_eei18n_js_strings
2068
+	 *
2069
+	 * @return        void
2070
+	 */
2071
+	public function admin_footer_scripts_eei18n_js_strings()
2072
+	{
2073
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2074
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2075
+			__(
2076
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2077
+				'event_espresso'
2078
+			)
2079
+		);
2080
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2105
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2106
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2107
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2108
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2109
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2110
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2111
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2112
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2113
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2114
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2115
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2116
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2117
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2118
+	}
2119
+
2120
+
2121
+	/**
2122
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2123
+	 *
2124
+	 * @return        void
2125
+	 */
2126
+	public function add_xdebug_style()
2127
+	{
2128
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2129
+	}
2130
+
2131
+
2132
+	/************************/
2133
+	/** LIST TABLE METHODS **/
2134
+	/************************/
2135
+	/**
2136
+	 * this sets up the list table if the current view requires it.
2137
+	 *
2138
+	 * @return void
2139
+	 * @throws EE_Error
2140
+	 * @throws InvalidArgumentException
2141
+	 * @throws InvalidDataTypeException
2142
+	 * @throws InvalidInterfaceException
2143
+	 */
2144
+	protected function _set_list_table()
2145
+	{
2146
+		// first is this a list_table view?
2147
+		if (! isset($this->_route_config['list_table'])) {
2148
+			return;
2149
+		} //not a list_table view so get out.
2150
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2151
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2152
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2153
+			// user error msg
2154
+			$error_msg = esc_html__(
2155
+				'An error occurred. The requested list table views could not be found.',
2156
+				'event_espresso'
2157
+			);
2158
+			// developer error msg
2159
+			$error_msg .= '||'
2160
+						  . sprintf(
2161
+							  esc_html__(
2162
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2163
+								  'event_espresso'
2164
+							  ),
2165
+							  $this->_req_action,
2166
+							  $list_table_view
2167
+						  );
2168
+			throw new EE_Error($error_msg);
2169
+		}
2170
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2171
+		$this->_views = apply_filters(
2172
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2173
+			$this->_views
2174
+		);
2175
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2176
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2177
+		$this->_set_list_table_view();
2178
+		$this->_set_list_table_object();
2179
+	}
2180
+
2181
+
2182
+	/**
2183
+	 * set current view for List Table
2184
+	 *
2185
+	 * @return void
2186
+	 */
2187
+	protected function _set_list_table_view()
2188
+	{
2189
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2190
+		$status = $this->request->getRequestParam('status', null, 'key');
2191
+		$this->_view = $status && array_key_exists($status, $this->_views)
2192
+			? $status
2193
+			: $this->_view;
2194
+	}
2195
+
2196
+
2197
+	/**
2198
+	 * _set_list_table_object
2199
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2200
+	 *
2201
+	 * @throws InvalidInterfaceException
2202
+	 * @throws InvalidArgumentException
2203
+	 * @throws InvalidDataTypeException
2204
+	 * @throws EE_Error
2205
+	 * @throws InvalidInterfaceException
2206
+	 */
2207
+	protected function _set_list_table_object()
2208
+	{
2209
+		if (isset($this->_route_config['list_table'])) {
2210
+			if (! class_exists($this->_route_config['list_table'])) {
2211
+				throw new EE_Error(
2212
+					sprintf(
2213
+						esc_html__(
2214
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2215
+							'event_espresso'
2216
+						),
2217
+						$this->_route_config['list_table'],
2218
+						get_class($this)
2219
+					)
2220
+				);
2221
+			}
2222
+			$this->_list_table_object = $this->loader->getShared(
2223
+				$this->_route_config['list_table'],
2224
+				[$this]
2225
+			);
2226
+		}
2227
+	}
2228
+
2229
+
2230
+	/**
2231
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2232
+	 *
2233
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2234
+	 *                                                    urls.  The array should be indexed by the view it is being
2235
+	 *                                                    added to.
2236
+	 * @return array
2237
+	 */
2238
+	public function get_list_table_view_RLs($extra_query_args = [])
2239
+	{
2240
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2241
+		if (empty($this->_views)) {
2242
+			$this->_views = [];
2243
+		}
2244
+		// cycle thru views
2245
+		foreach ($this->_views as $key => $view) {
2246
+			$query_args = [];
2247
+			// check for current view
2248
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2249
+			$query_args['action']                        = $this->_req_action;
2250
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2251
+			$query_args['status']                        = $view['slug'];
2252
+			// merge any other arguments sent in.
2253
+			if (isset($extra_query_args[ $view['slug'] ])) {
2254
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2255
+					$query_args[] = $extra_query_arg;
2256
+				}
2257
+			}
2258
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2259
+		}
2260
+		return $this->_views;
2261
+	}
2262
+
2263
+
2264
+	/**
2265
+	 * _entries_per_page_dropdown
2266
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2267
+	 *
2268
+	 * @param int $max_entries total number of rows in the table
2269
+	 * @return string
2270
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2271
+	 *         WP does it.
2272
+	 */
2273
+	protected function _entries_per_page_dropdown($max_entries = 0)
2274
+	{
2275
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2276
+		$values   = [10, 25, 50, 100];
2277
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2278
+		if ($max_entries) {
2279
+			$values[] = $max_entries;
2280
+			sort($values);
2281
+		}
2282
+		$entries_per_page_dropdown = '
2283 2283
 			<div id="entries-per-page-dv" class="alignleft actions">
2284 2284
 				<label class="hide-if-no-js">
2285 2285
 					Show
2286 2286
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2287
-        foreach ($values as $value) {
2288
-            if ($value < $max_entries) {
2289
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2290
-                $entries_per_page_dropdown .= '
2287
+		foreach ($values as $value) {
2288
+			if ($value < $max_entries) {
2289
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2290
+				$entries_per_page_dropdown .= '
2291 2291
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2292
-            }
2293
-        }
2294
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2295
-        $entries_per_page_dropdown .= '
2292
+			}
2293
+		}
2294
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2295
+		$entries_per_page_dropdown .= '
2296 2296
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2297
-        $entries_per_page_dropdown .= '
2297
+		$entries_per_page_dropdown .= '
2298 2298
 					</select>
2299 2299
 					entries
2300 2300
 				</label>
2301 2301
 				<input id="entries-per-page-btn" class="button--secondary" type="submit" value="Go" >
2302 2302
 			</div>
2303 2303
 		';
2304
-        return $entries_per_page_dropdown;
2305
-    }
2306
-
2307
-
2308
-    /**
2309
-     *        _set_search_attributes
2310
-     *
2311
-     * @return        void
2312
-     */
2313
-    public function _set_search_attributes()
2314
-    {
2315
-        $this->_template_args['search']['btn_label'] = sprintf(
2316
-            esc_html__('Search %s', 'event_espresso'),
2317
-            empty($this->_search_btn_label) ? $this->page_label
2318
-                : $this->_search_btn_label
2319
-        );
2320
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2321
-    }
2322
-
2323
-
2324
-
2325
-    /*** END LIST TABLE METHODS **/
2326
-
2327
-
2328
-    /**
2329
-     * _add_registered_metaboxes
2330
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2331
-     *
2332
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2333
-     * @return void
2334
-     * @throws EE_Error
2335
-     */
2336
-    private function _add_registered_meta_boxes()
2337
-    {
2338
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2339
-        // we only add meta boxes if the page_route calls for it
2340
-        if (
2341
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2342
-            && is_array(
2343
-                $this->_route_config['metaboxes']
2344
-            )
2345
-        ) {
2346
-            // this simply loops through the callbacks provided
2347
-            // and checks if there is a corresponding callback registered by the child
2348
-            // if there is then we go ahead and process the metabox loader.
2349
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2350
-                // first check for Closures
2351
-                if ($metabox_callback instanceof Closure) {
2352
-                    $result = $metabox_callback();
2353
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2354
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2355
-                } else {
2356
-                    $result = $this->{$metabox_callback}();
2357
-                }
2358
-                if ($result === false) {
2359
-                    // user error msg
2360
-                    $error_msg = esc_html__(
2361
-                        'An error occurred. The  requested metabox could not be found.',
2362
-                        'event_espresso'
2363
-                    );
2364
-                    // developer error msg
2365
-                    $error_msg .= '||'
2366
-                                  . sprintf(
2367
-                                      esc_html__(
2368
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2369
-                                          'event_espresso'
2370
-                                      ),
2371
-                                      $metabox_callback
2372
-                                  );
2373
-                    throw new EE_Error($error_msg);
2374
-                }
2375
-            }
2376
-        }
2377
-    }
2378
-
2379
-
2380
-    /**
2381
-     * _add_screen_columns
2382
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2383
-     * the dynamic column template and we'll setup the column options for the page.
2384
-     *
2385
-     * @return void
2386
-     */
2387
-    private function _add_screen_columns()
2388
-    {
2389
-        if (
2390
-            is_array($this->_route_config)
2391
-            && isset($this->_route_config['columns'])
2392
-            && is_array($this->_route_config['columns'])
2393
-            && count($this->_route_config['columns']) === 2
2394
-        ) {
2395
-            add_screen_option(
2396
-                'layout_columns',
2397
-                [
2398
-                    'max'     => (int) $this->_route_config['columns'][0],
2399
-                    'default' => (int) $this->_route_config['columns'][1],
2400
-                ]
2401
-            );
2402
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2403
-            $screen_id                                           = $this->_current_screen->id;
2404
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2405
-            $total_columns                                       = ! empty($screen_columns)
2406
-                ? $screen_columns
2407
-                : $this->_route_config['columns'][1];
2408
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2409
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2410
-            $this->_template_args['screen']                      = $this->_current_screen;
2411
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2412
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2413
-            // finally if we don't have has_metaboxes set in the route config
2414
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2415
-            $this->_route_config['has_metaboxes'] = true;
2416
-        }
2417
-    }
2418
-
2419
-
2420
-
2421
-    /** GLOBALLY AVAILABLE METABOXES **/
2422
-
2423
-
2424
-    /**
2425
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2426
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2427
-     * these get loaded on.
2428
-     */
2429
-    private function _espresso_news_post_box()
2430
-    {
2431
-        $news_box_title = apply_filters(
2432
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2433
-            esc_html__('New @ Event Espresso', 'event_espresso')
2434
-        );
2435
-        $this->addMetaBox(
2436
-            'espresso_news_post_box',
2437
-            $news_box_title,
2438
-            [
2439
-                $this,
2440
-                'espresso_news_post_box',
2441
-            ],
2442
-            $this->_wp_page_slug,
2443
-            'side'
2444
-        );
2445
-    }
2446
-
2447
-
2448
-    /**
2449
-     * Code for setting up espresso ratings request metabox.
2450
-     */
2451
-    protected function _espresso_ratings_request()
2452
-    {
2453
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2454
-            return;
2455
-        }
2456
-        $ratings_box_title = apply_filters(
2457
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2458
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2459
-        );
2460
-        $this->addMetaBox(
2461
-            'espresso_ratings_request',
2462
-            $ratings_box_title,
2463
-            [
2464
-                $this,
2465
-                'espresso_ratings_request',
2466
-            ],
2467
-            $this->_wp_page_slug,
2468
-            'side'
2469
-        );
2470
-    }
2471
-
2472
-
2473
-    /**
2474
-     * Code for setting up espresso ratings request metabox content.
2475
-     *
2476
-     * @throws DomainException
2477
-     */
2478
-    public function espresso_ratings_request()
2479
-    {
2480
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2481
-    }
2482
-
2483
-
2484
-    public static function cached_rss_display($rss_id, $url)
2485
-    {
2486
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2487
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2488
-                     . '</p><p class="hide-if-js">'
2489
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2490
-                     . '</p>';
2491
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2492
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2493
-        $post      = '</div>' . "\n";
2494
-        $cache_key = 'ee_rss_' . md5($rss_id);
2495
-        $output    = get_transient($cache_key);
2496
-        if ($output !== false) {
2497
-            echo $pre . $output . $post; // already escaped
2498
-            return true;
2499
-        }
2500
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2501
-            echo $pre . $loading . $post; // already escaped
2502
-            return false;
2503
-        }
2504
-        ob_start();
2505
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2506
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2507
-        return true;
2508
-    }
2509
-
2510
-
2511
-    public function espresso_news_post_box()
2512
-    {
2513
-        ?>
2304
+		return $entries_per_page_dropdown;
2305
+	}
2306
+
2307
+
2308
+	/**
2309
+	 *        _set_search_attributes
2310
+	 *
2311
+	 * @return        void
2312
+	 */
2313
+	public function _set_search_attributes()
2314
+	{
2315
+		$this->_template_args['search']['btn_label'] = sprintf(
2316
+			esc_html__('Search %s', 'event_espresso'),
2317
+			empty($this->_search_btn_label) ? $this->page_label
2318
+				: $this->_search_btn_label
2319
+		);
2320
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2321
+	}
2322
+
2323
+
2324
+
2325
+	/*** END LIST TABLE METHODS **/
2326
+
2327
+
2328
+	/**
2329
+	 * _add_registered_metaboxes
2330
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2331
+	 *
2332
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2333
+	 * @return void
2334
+	 * @throws EE_Error
2335
+	 */
2336
+	private function _add_registered_meta_boxes()
2337
+	{
2338
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2339
+		// we only add meta boxes if the page_route calls for it
2340
+		if (
2341
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2342
+			&& is_array(
2343
+				$this->_route_config['metaboxes']
2344
+			)
2345
+		) {
2346
+			// this simply loops through the callbacks provided
2347
+			// and checks if there is a corresponding callback registered by the child
2348
+			// if there is then we go ahead and process the metabox loader.
2349
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2350
+				// first check for Closures
2351
+				if ($metabox_callback instanceof Closure) {
2352
+					$result = $metabox_callback();
2353
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2354
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2355
+				} else {
2356
+					$result = $this->{$metabox_callback}();
2357
+				}
2358
+				if ($result === false) {
2359
+					// user error msg
2360
+					$error_msg = esc_html__(
2361
+						'An error occurred. The  requested metabox could not be found.',
2362
+						'event_espresso'
2363
+					);
2364
+					// developer error msg
2365
+					$error_msg .= '||'
2366
+								  . sprintf(
2367
+									  esc_html__(
2368
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2369
+										  'event_espresso'
2370
+									  ),
2371
+									  $metabox_callback
2372
+								  );
2373
+					throw new EE_Error($error_msg);
2374
+				}
2375
+			}
2376
+		}
2377
+	}
2378
+
2379
+
2380
+	/**
2381
+	 * _add_screen_columns
2382
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2383
+	 * the dynamic column template and we'll setup the column options for the page.
2384
+	 *
2385
+	 * @return void
2386
+	 */
2387
+	private function _add_screen_columns()
2388
+	{
2389
+		if (
2390
+			is_array($this->_route_config)
2391
+			&& isset($this->_route_config['columns'])
2392
+			&& is_array($this->_route_config['columns'])
2393
+			&& count($this->_route_config['columns']) === 2
2394
+		) {
2395
+			add_screen_option(
2396
+				'layout_columns',
2397
+				[
2398
+					'max'     => (int) $this->_route_config['columns'][0],
2399
+					'default' => (int) $this->_route_config['columns'][1],
2400
+				]
2401
+			);
2402
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2403
+			$screen_id                                           = $this->_current_screen->id;
2404
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2405
+			$total_columns                                       = ! empty($screen_columns)
2406
+				? $screen_columns
2407
+				: $this->_route_config['columns'][1];
2408
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2409
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2410
+			$this->_template_args['screen']                      = $this->_current_screen;
2411
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2412
+																   . 'admin_details_metabox_column_wrapper.template.php';
2413
+			// finally if we don't have has_metaboxes set in the route config
2414
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2415
+			$this->_route_config['has_metaboxes'] = true;
2416
+		}
2417
+	}
2418
+
2419
+
2420
+
2421
+	/** GLOBALLY AVAILABLE METABOXES **/
2422
+
2423
+
2424
+	/**
2425
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2426
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2427
+	 * these get loaded on.
2428
+	 */
2429
+	private function _espresso_news_post_box()
2430
+	{
2431
+		$news_box_title = apply_filters(
2432
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2433
+			esc_html__('New @ Event Espresso', 'event_espresso')
2434
+		);
2435
+		$this->addMetaBox(
2436
+			'espresso_news_post_box',
2437
+			$news_box_title,
2438
+			[
2439
+				$this,
2440
+				'espresso_news_post_box',
2441
+			],
2442
+			$this->_wp_page_slug,
2443
+			'side'
2444
+		);
2445
+	}
2446
+
2447
+
2448
+	/**
2449
+	 * Code for setting up espresso ratings request metabox.
2450
+	 */
2451
+	protected function _espresso_ratings_request()
2452
+	{
2453
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2454
+			return;
2455
+		}
2456
+		$ratings_box_title = apply_filters(
2457
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2458
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2459
+		);
2460
+		$this->addMetaBox(
2461
+			'espresso_ratings_request',
2462
+			$ratings_box_title,
2463
+			[
2464
+				$this,
2465
+				'espresso_ratings_request',
2466
+			],
2467
+			$this->_wp_page_slug,
2468
+			'side'
2469
+		);
2470
+	}
2471
+
2472
+
2473
+	/**
2474
+	 * Code for setting up espresso ratings request metabox content.
2475
+	 *
2476
+	 * @throws DomainException
2477
+	 */
2478
+	public function espresso_ratings_request()
2479
+	{
2480
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2481
+	}
2482
+
2483
+
2484
+	public static function cached_rss_display($rss_id, $url)
2485
+	{
2486
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2487
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2488
+					 . '</p><p class="hide-if-js">'
2489
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2490
+					 . '</p>';
2491
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2492
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2493
+		$post      = '</div>' . "\n";
2494
+		$cache_key = 'ee_rss_' . md5($rss_id);
2495
+		$output    = get_transient($cache_key);
2496
+		if ($output !== false) {
2497
+			echo $pre . $output . $post; // already escaped
2498
+			return true;
2499
+		}
2500
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2501
+			echo $pre . $loading . $post; // already escaped
2502
+			return false;
2503
+		}
2504
+		ob_start();
2505
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2506
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2507
+		return true;
2508
+	}
2509
+
2510
+
2511
+	public function espresso_news_post_box()
2512
+	{
2513
+		?>
2514 2514
         <div class="padding">
2515 2515
             <div id="espresso_news_post_box_content" class="infolinks">
2516 2516
                 <?php
2517
-                // Get RSS Feed(s)
2518
-                EE_Admin_Page::cached_rss_display(
2519
-                    'espresso_news_post_box_content',
2520
-                    esc_url_raw(
2521
-                        apply_filters(
2522
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2523
-                            'https://eventespresso.com/feed/'
2524
-                        )
2525
-                    )
2526
-                );
2527
-                ?>
2517
+				// Get RSS Feed(s)
2518
+				EE_Admin_Page::cached_rss_display(
2519
+					'espresso_news_post_box_content',
2520
+					esc_url_raw(
2521
+						apply_filters(
2522
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2523
+							'https://eventespresso.com/feed/'
2524
+						)
2525
+					)
2526
+				);
2527
+				?>
2528 2528
             </div>
2529 2529
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2530 2530
         </div>
2531 2531
         <?php
2532
-    }
2533
-
2534
-
2535
-    private function _espresso_links_post_box()
2536
-    {
2537
-        // Hiding until we actually have content to put in here...
2538
-        // $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2539
-    }
2540
-
2541
-
2542
-    public function espresso_links_post_box()
2543
-    {
2544
-        // Hiding until we actually have content to put in here...
2545
-        // EEH_Template::display_template(
2546
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2547
-        // );
2548
-    }
2549
-
2550
-
2551
-    protected function _espresso_sponsors_post_box()
2552
-    {
2553
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2554
-            $this->addMetaBox(
2555
-                'espresso_sponsors_post_box',
2556
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2557
-                [$this, 'espresso_sponsors_post_box'],
2558
-                $this->_wp_page_slug,
2559
-                'side'
2560
-            );
2561
-        }
2562
-    }
2563
-
2564
-
2565
-    public function espresso_sponsors_post_box()
2566
-    {
2567
-        EEH_Template::display_template(
2568
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2569
-        );
2570
-    }
2571
-
2572
-
2573
-    private function _publish_post_box()
2574
-    {
2575
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2576
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2577
-        // then we'll use that for the metabox label.
2578
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2579
-        if (! empty($this->_labels['publishbox'])) {
2580
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2581
-                : $this->_labels['publishbox'];
2582
-        } else {
2583
-            $box_label = esc_html__('Publish', 'event_espresso');
2584
-        }
2585
-        $box_label = apply_filters(
2586
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2587
-            $box_label,
2588
-            $this->_req_action,
2589
-            $this
2590
-        );
2591
-        $this->addMetaBox(
2592
-            $meta_box_ref,
2593
-            $box_label,
2594
-            [$this, 'editor_overview'],
2595
-            $this->_current_screen->id,
2596
-            'side',
2597
-            'high'
2598
-        );
2599
-    }
2600
-
2601
-
2602
-    public function editor_overview()
2603
-    {
2604
-        // if we have extra content set let's add it in if not make sure its empty
2605
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2606
-            ? $this->_template_args['publish_box_extra_content']
2607
-            : '';
2608
-        echo EEH_Template::display_template(
2609
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2610
-            $this->_template_args,
2611
-            true
2612
-        );
2613
-    }
2614
-
2615
-
2616
-    /** end of globally available metaboxes section **/
2617
-
2618
-
2619
-    /**
2620
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2621
-     * protected method.
2622
-     *
2623
-     * @param string $name
2624
-     * @param int    $id
2625
-     * @param bool   $delete
2626
-     * @param string $save_close_redirect_URL
2627
-     * @param bool   $both_btns
2628
-     * @throws EE_Error
2629
-     * @throws InvalidArgumentException
2630
-     * @throws InvalidDataTypeException
2631
-     * @throws InvalidInterfaceException
2632
-     * @see   $this->_set_publish_post_box_vars for param details
2633
-     * @since 4.6.0
2634
-     */
2635
-    public function set_publish_post_box_vars(
2636
-        $name = '',
2637
-        $id = 0,
2638
-        $delete = false,
2639
-        $save_close_redirect_URL = '',
2640
-        $both_btns = true
2641
-    ) {
2642
-        $this->_set_publish_post_box_vars(
2643
-            $name,
2644
-            $id,
2645
-            $delete,
2646
-            $save_close_redirect_URL,
2647
-            $both_btns
2648
-        );
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2654
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2655
-     * save, and save and close buttons to work properly, then you will want to include a
2656
-     * values for the name and id arguments.
2657
-     *
2658
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2659
-     * @param int     $id                         id attached to the item published
2660
-     * @param string  $delete                     page route callback for the delete action
2661
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2662
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2663
-     *                                            the Save button
2664
-     * @throws EE_Error
2665
-     * @throws InvalidArgumentException
2666
-     * @throws InvalidDataTypeException
2667
-     * @throws InvalidInterfaceException
2668
-     * @todo  Add in validation for name/id arguments.
2669
-     */
2670
-    protected function _set_publish_post_box_vars(
2671
-        $name = '',
2672
-        $id = 0,
2673
-        $delete = '',
2674
-        $save_close_redirect_URL = '',
2675
-        $both_btns = true
2676
-    ) {
2677
-        // if Save & Close, use a custom redirect URL or default to the main page?
2678
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2679
-            ? $save_close_redirect_URL
2680
-            : $this->_admin_base_url;
2681
-        // create the Save & Close and Save buttons
2682
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2683
-        // if we have extra content set let's add it in if not make sure its empty
2684
-        $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2685
-        if ($delete && ! empty($id)) {
2686
-            // make sure we have a default if just true is sent.
2687
-            $delete           = ! empty($delete) ? $delete : 'delete';
2688
-            $delete_link_args = [$name => $id];
2689
-            $delete           = $this->get_action_link_or_button(
2690
-                $delete,
2691
-                $delete,
2692
-                $delete_link_args,
2693
-                'submitdelete deletion button button--small button--caution'
2694
-            );
2695
-        }
2696
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2697
-        if (! empty($name) && ! empty($id)) {
2698
-            $hidden_field_arr[ $name ] = [
2699
-                'type'  => 'hidden',
2700
-                'value' => $id,
2701
-            ];
2702
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2703
-        } else {
2704
-            $hf = '';
2705
-        }
2706
-        // add hidden field
2707
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2708
-            ? $hf[ $name ]['field']
2709
-            : $hf;
2710
-    }
2711
-
2712
-
2713
-    /**
2714
-     * displays an error message to ppl who have javascript disabled
2715
-     *
2716
-     * @return void
2717
-     */
2718
-    private function _display_no_javascript_warning()
2719
-    {
2720
-        ?>
2532
+	}
2533
+
2534
+
2535
+	private function _espresso_links_post_box()
2536
+	{
2537
+		// Hiding until we actually have content to put in here...
2538
+		// $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2539
+	}
2540
+
2541
+
2542
+	public function espresso_links_post_box()
2543
+	{
2544
+		// Hiding until we actually have content to put in here...
2545
+		// EEH_Template::display_template(
2546
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2547
+		// );
2548
+	}
2549
+
2550
+
2551
+	protected function _espresso_sponsors_post_box()
2552
+	{
2553
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2554
+			$this->addMetaBox(
2555
+				'espresso_sponsors_post_box',
2556
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2557
+				[$this, 'espresso_sponsors_post_box'],
2558
+				$this->_wp_page_slug,
2559
+				'side'
2560
+			);
2561
+		}
2562
+	}
2563
+
2564
+
2565
+	public function espresso_sponsors_post_box()
2566
+	{
2567
+		EEH_Template::display_template(
2568
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2569
+		);
2570
+	}
2571
+
2572
+
2573
+	private function _publish_post_box()
2574
+	{
2575
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2576
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2577
+		// then we'll use that for the metabox label.
2578
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2579
+		if (! empty($this->_labels['publishbox'])) {
2580
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2581
+				: $this->_labels['publishbox'];
2582
+		} else {
2583
+			$box_label = esc_html__('Publish', 'event_espresso');
2584
+		}
2585
+		$box_label = apply_filters(
2586
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2587
+			$box_label,
2588
+			$this->_req_action,
2589
+			$this
2590
+		);
2591
+		$this->addMetaBox(
2592
+			$meta_box_ref,
2593
+			$box_label,
2594
+			[$this, 'editor_overview'],
2595
+			$this->_current_screen->id,
2596
+			'side',
2597
+			'high'
2598
+		);
2599
+	}
2600
+
2601
+
2602
+	public function editor_overview()
2603
+	{
2604
+		// if we have extra content set let's add it in if not make sure its empty
2605
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2606
+			? $this->_template_args['publish_box_extra_content']
2607
+			: '';
2608
+		echo EEH_Template::display_template(
2609
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2610
+			$this->_template_args,
2611
+			true
2612
+		);
2613
+	}
2614
+
2615
+
2616
+	/** end of globally available metaboxes section **/
2617
+
2618
+
2619
+	/**
2620
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2621
+	 * protected method.
2622
+	 *
2623
+	 * @param string $name
2624
+	 * @param int    $id
2625
+	 * @param bool   $delete
2626
+	 * @param string $save_close_redirect_URL
2627
+	 * @param bool   $both_btns
2628
+	 * @throws EE_Error
2629
+	 * @throws InvalidArgumentException
2630
+	 * @throws InvalidDataTypeException
2631
+	 * @throws InvalidInterfaceException
2632
+	 * @see   $this->_set_publish_post_box_vars for param details
2633
+	 * @since 4.6.0
2634
+	 */
2635
+	public function set_publish_post_box_vars(
2636
+		$name = '',
2637
+		$id = 0,
2638
+		$delete = false,
2639
+		$save_close_redirect_URL = '',
2640
+		$both_btns = true
2641
+	) {
2642
+		$this->_set_publish_post_box_vars(
2643
+			$name,
2644
+			$id,
2645
+			$delete,
2646
+			$save_close_redirect_URL,
2647
+			$both_btns
2648
+		);
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2654
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2655
+	 * save, and save and close buttons to work properly, then you will want to include a
2656
+	 * values for the name and id arguments.
2657
+	 *
2658
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2659
+	 * @param int     $id                         id attached to the item published
2660
+	 * @param string  $delete                     page route callback for the delete action
2661
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2662
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2663
+	 *                                            the Save button
2664
+	 * @throws EE_Error
2665
+	 * @throws InvalidArgumentException
2666
+	 * @throws InvalidDataTypeException
2667
+	 * @throws InvalidInterfaceException
2668
+	 * @todo  Add in validation for name/id arguments.
2669
+	 */
2670
+	protected function _set_publish_post_box_vars(
2671
+		$name = '',
2672
+		$id = 0,
2673
+		$delete = '',
2674
+		$save_close_redirect_URL = '',
2675
+		$both_btns = true
2676
+	) {
2677
+		// if Save & Close, use a custom redirect URL or default to the main page?
2678
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2679
+			? $save_close_redirect_URL
2680
+			: $this->_admin_base_url;
2681
+		// create the Save & Close and Save buttons
2682
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2683
+		// if we have extra content set let's add it in if not make sure its empty
2684
+		$this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2685
+		if ($delete && ! empty($id)) {
2686
+			// make sure we have a default if just true is sent.
2687
+			$delete           = ! empty($delete) ? $delete : 'delete';
2688
+			$delete_link_args = [$name => $id];
2689
+			$delete           = $this->get_action_link_or_button(
2690
+				$delete,
2691
+				$delete,
2692
+				$delete_link_args,
2693
+				'submitdelete deletion button button--small button--caution'
2694
+			);
2695
+		}
2696
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2697
+		if (! empty($name) && ! empty($id)) {
2698
+			$hidden_field_arr[ $name ] = [
2699
+				'type'  => 'hidden',
2700
+				'value' => $id,
2701
+			];
2702
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2703
+		} else {
2704
+			$hf = '';
2705
+		}
2706
+		// add hidden field
2707
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2708
+			? $hf[ $name ]['field']
2709
+			: $hf;
2710
+	}
2711
+
2712
+
2713
+	/**
2714
+	 * displays an error message to ppl who have javascript disabled
2715
+	 *
2716
+	 * @return void
2717
+	 */
2718
+	private function _display_no_javascript_warning()
2719
+	{
2720
+		?>
2721 2721
         <noscript>
2722 2722
             <div id="no-js-message" class="error">
2723 2723
                 <p style="font-size:1.3em;">
2724 2724
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2725 2725
                     <?php esc_html_e(
2726
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2727
-                        'event_espresso'
2728
-                    ); ?>
2726
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2727
+						'event_espresso'
2728
+					); ?>
2729 2729
                 </p>
2730 2730
             </div>
2731 2731
         </noscript>
2732 2732
         <?php
2733
-    }
2734
-
2735
-
2736
-    /**
2737
-     * displays espresso success and/or error notices
2738
-     *
2739
-     * @return void
2740
-     */
2741
-    protected function _display_espresso_notices()
2742
-    {
2743
-        $notices = $this->_get_transient(true);
2744
-        echo stripslashes($notices);
2745
-    }
2746
-
2747
-
2748
-    /**
2749
-     * spinny things pacify the masses
2750
-     *
2751
-     * @return void
2752
-     */
2753
-    protected function _add_admin_page_ajax_loading_img()
2754
-    {
2755
-        ?>
2733
+	}
2734
+
2735
+
2736
+	/**
2737
+	 * displays espresso success and/or error notices
2738
+	 *
2739
+	 * @return void
2740
+	 */
2741
+	protected function _display_espresso_notices()
2742
+	{
2743
+		$notices = $this->_get_transient(true);
2744
+		echo stripslashes($notices);
2745
+	}
2746
+
2747
+
2748
+	/**
2749
+	 * spinny things pacify the masses
2750
+	 *
2751
+	 * @return void
2752
+	 */
2753
+	protected function _add_admin_page_ajax_loading_img()
2754
+	{
2755
+		?>
2756 2756
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2757 2757
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2758
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2758
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2759 2759
         </div>
2760 2760
         <?php
2761
-    }
2761
+	}
2762 2762
 
2763 2763
 
2764
-    /**
2765
-     * add admin page overlay for modal boxes
2766
-     *
2767
-     * @return void
2768
-     */
2769
-    protected function _add_admin_page_overlay()
2770
-    {
2771
-        ?>
2764
+	/**
2765
+	 * add admin page overlay for modal boxes
2766
+	 *
2767
+	 * @return void
2768
+	 */
2769
+	protected function _add_admin_page_overlay()
2770
+	{
2771
+		?>
2772 2772
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2773 2773
         <?php
2774
-    }
2775
-
2776
-
2777
-    /**
2778
-     * facade for $this->addMetaBox()
2779
-     *
2780
-     * @param string  $action        where the metabox get's displayed
2781
-     * @param string  $title         Title of Metabox (output in metabox header)
2782
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2783
-     *                               instead of the one created in here.
2784
-     * @param array   $callback_args an array of args supplied for the metabox
2785
-     * @param string  $column        what metabox column
2786
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2787
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2788
-     *                               created but just set our own callback for wp's add_meta_box.
2789
-     * @throws DomainException
2790
-     */
2791
-    public function _add_admin_page_meta_box(
2792
-        $action,
2793
-        $title,
2794
-        $callback,
2795
-        $callback_args,
2796
-        $column = 'normal',
2797
-        $priority = 'high',
2798
-        $create_func = true
2799
-    ) {
2800
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2801
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2802
-        if (empty($callback_args) && $create_func) {
2803
-            $callback_args = [
2804
-                'template_path' => $this->_template_path,
2805
-                'template_args' => $this->_template_args,
2806
-            ];
2807
-        }
2808
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2809
-        $call_back_func = $create_func
2810
-            ? static function ($post, $metabox) {
2811
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2812
-                echo EEH_Template::display_template(
2813
-                    $metabox['args']['template_path'],
2814
-                    $metabox['args']['template_args'],
2815
-                    true
2816
-                );
2817
-            }
2818
-            : $callback;
2819
-        $this->addMetaBox(
2820
-            str_replace('_', '-', $action) . '-mbox',
2821
-            $title,
2822
-            $call_back_func,
2823
-            $this->_wp_page_slug,
2824
-            $column,
2825
-            $priority,
2826
-            $callback_args
2827
-        );
2828
-    }
2829
-
2830
-
2831
-    /**
2832
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2833
-     *
2834
-     * @throws DomainException
2835
-     * @throws EE_Error
2836
-     * @throws InvalidArgumentException
2837
-     * @throws InvalidDataTypeException
2838
-     * @throws InvalidInterfaceException
2839
-     */
2840
-    public function display_admin_page_with_metabox_columns()
2841
-    {
2842
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2843
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2844
-            $this->_column_template_path,
2845
-            $this->_template_args,
2846
-            true
2847
-        );
2848
-        // the final wrapper
2849
-        $this->admin_page_wrapper();
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * generates  HTML wrapper for an admin details page
2855
-     *
2856
-     * @return void
2857
-     * @throws DomainException
2858
-     * @throws EE_Error
2859
-     * @throws InvalidArgumentException
2860
-     * @throws InvalidDataTypeException
2861
-     * @throws InvalidInterfaceException
2862
-     */
2863
-    public function display_admin_page_with_sidebar()
2864
-    {
2865
-        $this->_display_admin_page(true);
2866
-    }
2867
-
2868
-
2869
-    /**
2870
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2871
-     *
2872
-     * @return void
2873
-     * @throws DomainException
2874
-     * @throws EE_Error
2875
-     * @throws InvalidArgumentException
2876
-     * @throws InvalidDataTypeException
2877
-     * @throws InvalidInterfaceException
2878
-     */
2879
-    public function display_admin_page_with_no_sidebar()
2880
-    {
2881
-        $this->_display_admin_page();
2882
-    }
2883
-
2884
-
2885
-    /**
2886
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2887
-     *
2888
-     * @return void
2889
-     * @throws DomainException
2890
-     * @throws EE_Error
2891
-     * @throws InvalidArgumentException
2892
-     * @throws InvalidDataTypeException
2893
-     * @throws InvalidInterfaceException
2894
-     */
2895
-    public function display_about_admin_page()
2896
-    {
2897
-        $this->_display_admin_page(false, true);
2898
-    }
2899
-
2900
-
2901
-    /**
2902
-     * display_admin_page
2903
-     * contains the code for actually displaying an admin page
2904
-     *
2905
-     * @param boolean $sidebar true with sidebar, false without
2906
-     * @param boolean $about   use the about admin wrapper instead of the default.
2907
-     * @return void
2908
-     * @throws DomainException
2909
-     * @throws EE_Error
2910
-     * @throws InvalidArgumentException
2911
-     * @throws InvalidDataTypeException
2912
-     * @throws InvalidInterfaceException
2913
-     */
2914
-    private function _display_admin_page($sidebar = false, $about = false)
2915
-    {
2916
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2917
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2918
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2919
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2920
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2921
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2922
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2923
-            ? 'poststuff'
2924
-            : 'espresso-default-admin';
2925
-
2926
-        $template_path = $sidebar
2927
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2928
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2929
-        if ($this->request->isAjax()) {
2930
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2931
-        }
2932
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2933
-
2934
-        $this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2935
-        $this->_template_args['before_admin_page_content'] = $this->_template_args['before_admin_page_content'] ?? '';
2936
-        $this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2937
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2938
-            $template_path,
2939
-            $this->_template_args,
2940
-            true
2941
-        );
2942
-        // the final template wrapper
2943
-        $this->admin_page_wrapper($about);
2944
-    }
2945
-
2946
-
2947
-    /**
2948
-     * This is used to display caf preview pages.
2949
-     *
2950
-     * @param string $utm_campaign_source what is the key used for google analytics link
2951
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2952
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2953
-     * @return void
2954
-     * @throws DomainException
2955
-     * @throws EE_Error
2956
-     * @throws InvalidArgumentException
2957
-     * @throws InvalidDataTypeException
2958
-     * @throws InvalidInterfaceException
2959
-     * @since 4.3.2
2960
-     */
2961
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2962
-    {
2963
-        // let's generate a default preview action button if there isn't one already present.
2964
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2965
-            'Upgrade to Event Espresso 4 Right Now',
2966
-            'event_espresso'
2967
-        );
2968
-        $buy_now_url                                   = add_query_arg(
2969
-            [
2970
-                'ee_ver'       => 'ee4',
2971
-                'utm_source'   => 'ee4_plugin_admin',
2972
-                'utm_medium'   => 'link',
2973
-                'utm_campaign' => $utm_campaign_source,
2974
-                'utm_content'  => 'buy_now_button',
2975
-            ],
2976
-            'https://eventespresso.com/pricing/'
2977
-        );
2978
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2979
-            ? $this->get_action_link_or_button(
2980
-                '',
2981
-                'buy_now',
2982
-                [],
2983
-                'button--primary button--big',
2984
-                esc_url_raw($buy_now_url),
2985
-                true
2986
-            )
2987
-            : $this->_template_args['preview_action_button'];
2988
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2989
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2990
-            $this->_template_args,
2991
-            true
2992
-        );
2993
-        $this->_display_admin_page($display_sidebar);
2994
-    }
2995
-
2996
-
2997
-    /**
2998
-     * display_admin_list_table_page_with_sidebar
2999
-     * generates HTML wrapper for an admin_page with list_table
3000
-     *
3001
-     * @return void
3002
-     * @throws DomainException
3003
-     * @throws EE_Error
3004
-     * @throws InvalidArgumentException
3005
-     * @throws InvalidDataTypeException
3006
-     * @throws InvalidInterfaceException
3007
-     */
3008
-    public function display_admin_list_table_page_with_sidebar()
3009
-    {
3010
-        $this->_display_admin_list_table_page(true);
3011
-    }
3012
-
3013
-
3014
-    /**
3015
-     * display_admin_list_table_page_with_no_sidebar
3016
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
3017
-     *
3018
-     * @return void
3019
-     * @throws DomainException
3020
-     * @throws EE_Error
3021
-     * @throws InvalidArgumentException
3022
-     * @throws InvalidDataTypeException
3023
-     * @throws InvalidInterfaceException
3024
-     */
3025
-    public function display_admin_list_table_page_with_no_sidebar()
3026
-    {
3027
-        $this->_display_admin_list_table_page();
3028
-    }
3029
-
3030
-
3031
-    /**
3032
-     * generates html wrapper for an admin_list_table page
3033
-     *
3034
-     * @param boolean $sidebar whether to display with sidebar or not.
3035
-     * @return void
3036
-     * @throws DomainException
3037
-     * @throws EE_Error
3038
-     * @throws InvalidArgumentException
3039
-     * @throws InvalidDataTypeException
3040
-     * @throws InvalidInterfaceException
3041
-     */
3042
-    private function _display_admin_list_table_page($sidebar = false)
3043
-    {
3044
-        // setup search attributes
3045
-        $this->_set_search_attributes();
3046
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3047
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3048
-        $this->_template_args['table_url']        = $this->request->isAjax()
3049
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3050
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3051
-        $this->_template_args['list_table']       = $this->_list_table_object;
3052
-        $this->_template_args['current_route']    = $this->_req_action;
3053
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3054
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3055
-        if (! empty($ajax_sorting_callback)) {
3056
-            $sortable_list_table_form_fields = wp_nonce_field(
3057
-                $ajax_sorting_callback . '_nonce',
3058
-                $ajax_sorting_callback . '_nonce',
3059
-                false,
3060
-                false
3061
-            );
3062
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3063
-                                                . $this->page_slug
3064
-                                                . '" />';
3065
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3066
-                                                . $ajax_sorting_callback
3067
-                                                . '" />';
3068
-        } else {
3069
-            $sortable_list_table_form_fields = '';
3070
-        }
3071
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3072
-        $hidden_form_fields                                      =
3073
-            isset($this->_template_args['list_table_hidden_fields'])
3074
-                ? $this->_template_args['list_table_hidden_fields']
3075
-                : '';
3076
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3077
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3078
-                                                                    . $nonce_ref
3079
-                                                                    . '" value="'
3080
-                                                                    . wp_create_nonce($nonce_ref)
3081
-                                                                    . '">';
3082
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3083
-        // display message about search results?
3084
-        $search = $this->request->getRequestParam('s');
3085
-        $this->_template_args['before_list_table'] .= ! empty($search)
3086
-            ? '<p class="ee-search-results">' . sprintf(
3087
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3088
-                trim($search, '%')
3089
-            ) . '</p>'
3090
-            : '';
3091
-        // filter before_list_table template arg
3092
-        $this->_template_args['before_list_table'] = apply_filters(
3093
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3094
-            $this->_template_args['before_list_table'],
3095
-            $this->page_slug,
3096
-            $this->request->requestParams(),
3097
-            $this->_req_action
3098
-        );
3099
-        // convert to array and filter again
3100
-        // arrays are easier to inject new items in a specific location,
3101
-        // but would not be backwards compatible, so we have to add a new filter
3102
-        $this->_template_args['before_list_table'] = implode(
3103
-            " \n",
3104
-            (array) apply_filters(
3105
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3106
-                (array) $this->_template_args['before_list_table'],
3107
-                $this->page_slug,
3108
-                $this->request->requestParams(),
3109
-                $this->_req_action
3110
-            )
3111
-        );
3112
-        // filter after_list_table template arg
3113
-        $this->_template_args['after_list_table'] = apply_filters(
3114
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3115
-            $this->_template_args['after_list_table'],
3116
-            $this->page_slug,
3117
-            $this->request->requestParams(),
3118
-            $this->_req_action
3119
-        );
3120
-        // convert to array and filter again
3121
-        // arrays are easier to inject new items in a specific location,
3122
-        // but would not be backwards compatible, so we have to add a new filter
3123
-        $this->_template_args['after_list_table']   = implode(
3124
-            " \n",
3125
-            (array) apply_filters(
3126
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3127
-                (array) $this->_template_args['after_list_table'],
3128
-                $this->page_slug,
3129
-                $this->request->requestParams(),
3130
-                $this->_req_action
3131
-            )
3132
-        );
3133
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3134
-            $template_path,
3135
-            $this->_template_args,
3136
-            true
3137
-        );
3138
-        // the final template wrapper
3139
-        if ($sidebar) {
3140
-            $this->display_admin_page_with_sidebar();
3141
-        } else {
3142
-            $this->display_admin_page_with_no_sidebar();
3143
-        }
3144
-    }
3145
-
3146
-
3147
-    /**
3148
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3149
-     * html string for the legend.
3150
-     * $items are expected in an array in the following format:
3151
-     * $legend_items = array(
3152
-     *        'item_id' => array(
3153
-     *            'icon' => 'http://url_to_icon_being_described.png',
3154
-     *            'desc' => esc_html__('localized description of item');
3155
-     *        )
3156
-     * );
3157
-     *
3158
-     * @param array $items see above for format of array
3159
-     * @return string html string of legend
3160
-     * @throws DomainException
3161
-     */
3162
-    protected function _display_legend($items)
3163
-    {
3164
-        $this->_template_args['items'] = apply_filters(
3165
-            'FHEE__EE_Admin_Page___display_legend__items',
3166
-            (array) $items,
3167
-            $this
3168
-        );
3169
-        /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
3170
-        $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
3171
-        if (! $status_change_notice->isDismissed()) {
3172
-            $this->_template_args['status_change_notice'] = EEH_Template::display_template(
3173
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
3174
-                [ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
3175
-                true
3176
-            );
3177
-        }
3178
-        return EEH_Template::display_template(
3179
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3180
-            $this->_template_args,
3181
-            true
3182
-        );
3183
-    }
3184
-
3185
-
3186
-    /**
3187
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3188
-     * The returned json object is created from an array in the following format:
3189
-     * array(
3190
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3191
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3192
-     *  'notices' => '', // - contains any EE_Error formatted notices
3193
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3194
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3195
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3196
-     *  that might be included in here)
3197
-     * )
3198
-     * The json object is populated by whatever is set in the $_template_args property.
3199
-     *
3200
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3201
-     *                                 instead of displayed.
3202
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3203
-     * @return void
3204
-     * @throws EE_Error
3205
-     * @throws InvalidArgumentException
3206
-     * @throws InvalidDataTypeException
3207
-     * @throws InvalidInterfaceException
3208
-     */
3209
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3210
-    {
3211
-        // make sure any EE_Error notices have been handled.
3212
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3213
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3214
-        unset($this->_template_args['data']);
3215
-        $json = [
3216
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3217
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3218
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3219
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3220
-            'notices'   => EE_Error::get_notices(),
3221
-            'content'   => isset($this->_template_args['admin_page_content'])
3222
-                ? $this->_template_args['admin_page_content'] : '',
3223
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3224
-            'isEEajax'  => true
3225
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3226
-        ];
3227
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3228
-        if (null === error_get_last() || ! headers_sent()) {
3229
-            header('Content-Type: application/json; charset=UTF-8');
3230
-        }
3231
-        echo wp_json_encode($json);
3232
-        exit();
3233
-    }
3234
-
3235
-
3236
-    /**
3237
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3238
-     *
3239
-     * @return void
3240
-     * @throws EE_Error
3241
-     * @throws InvalidArgumentException
3242
-     * @throws InvalidDataTypeException
3243
-     * @throws InvalidInterfaceException
3244
-     */
3245
-    public function return_json()
3246
-    {
3247
-        if ($this->request->isAjax()) {
3248
-            $this->_return_json();
3249
-        } else {
3250
-            throw new EE_Error(
3251
-                sprintf(
3252
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3253
-                    __FUNCTION__
3254
-                )
3255
-            );
3256
-        }
3257
-    }
3258
-
3259
-
3260
-    /**
3261
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3262
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3263
-     *
3264
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3265
-     */
3266
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3267
-    {
3268
-        $this->_hook_obj = $hook_obj;
3269
-    }
3270
-
3271
-
3272
-    /**
3273
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3274
-     *
3275
-     * @param boolean $about whether to use the special about page wrapper or default.
3276
-     * @return void
3277
-     * @throws DomainException
3278
-     * @throws EE_Error
3279
-     * @throws InvalidArgumentException
3280
-     * @throws InvalidDataTypeException
3281
-     * @throws InvalidInterfaceException
3282
-     */
3283
-    public function admin_page_wrapper($about = false)
3284
-    {
3285
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3286
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3287
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3288
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3289
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3290
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3291
-            isset($this->_template_args['before_admin_page_content'])
3292
-                ? $this->_template_args['before_admin_page_content']
3293
-                : ''
3294
-        );
3295
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3296
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3297
-            isset($this->_template_args['after_admin_page_content'])
3298
-                ? $this->_template_args['after_admin_page_content']
3299
-                : ''
3300
-        );
3301
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3302
-        // load settings page wrapper template
3303
-        $template_path = ! $this->request->isAjax()
3304
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3305
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3306
-        // about page?
3307
-        $template_path = $about
3308
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3309
-            : $template_path;
3310
-        if ($this->request->isAjax()) {
3311
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3312
-                $template_path,
3313
-                $this->_template_args,
3314
-                true
3315
-            );
3316
-            $this->_return_json();
3317
-        } else {
3318
-            EEH_Template::display_template($template_path, $this->_template_args);
3319
-        }
3320
-    }
3321
-
3322
-
3323
-    /**
3324
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3325
-     *
3326
-     * @return string html
3327
-     * @throws EE_Error
3328
-     */
3329
-    protected function _get_main_nav_tabs()
3330
-    {
3331
-        // let's generate the html using the EEH_Tabbed_Content helper.
3332
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3333
-        // (rather than setting in the page_routes array)
3334
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3335
-    }
3336
-
3337
-
3338
-    /**
3339
-     *        sort nav tabs
3340
-     *
3341
-     * @param $a
3342
-     * @param $b
3343
-     * @return int
3344
-     */
3345
-    private function _sort_nav_tabs($a, $b)
3346
-    {
3347
-        if ($a['order'] === $b['order']) {
3348
-            return 0;
3349
-        }
3350
-        return ($a['order'] < $b['order']) ? -1 : 1;
3351
-    }
3352
-
3353
-
3354
-    /**
3355
-     * generates HTML for the forms used on admin pages
3356
-     *
3357
-     * @param array  $input_vars - array of input field details
3358
-     * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3359
-     * @param bool   $id
3360
-     * @return array|string
3361
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3362
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3363
-     */
3364
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3365
-    {
3366
-        return $generator === 'string'
3367
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3368
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3369
-    }
3370
-
3371
-
3372
-    /**
3373
-     * generates the "Save" and "Save & Close" buttons for edit forms
3374
-     *
3375
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3376
-     *                                   Close" button.
3377
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3378
-     *                                   'Save', [1] => 'save & close')
3379
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3380
-     *                                   via the "name" value in the button).  We can also use this to just dump
3381
-     *                                   default actions by submitting some other value.
3382
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3383
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3384
-     *                                   close (normal form handling).
3385
-     */
3386
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3387
-    {
3388
-        // make sure $text and $actions are in an array
3389
-        $text          = (array) $text;
3390
-        $actions       = (array) $actions;
3391
-        $referrer_url  = empty($referrer)
3392
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3393
-              . $this->request->getServerParam('REQUEST_URI')
3394
-              . '" />'
3395
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3396
-              . $referrer
3397
-              . '" />';
3398
-        $button_text   = ! empty($text)
3399
-            ? $text
3400
-            : [
3401
-                esc_html__('Save', 'event_espresso'),
3402
-                esc_html__('Save and Close', 'event_espresso'),
3403
-            ];
3404
-        $default_names = ['save', 'save_and_close'];
3405
-        // add in a hidden index for the current page (so save and close redirects properly)
3406
-        $this->_template_args['save_buttons'] = $referrer_url;
3407
-        foreach ($button_text as $key => $button) {
3408
-            $ref                                  = $default_names[ $key ];
3409
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button--primary '
3410
-                                                     . $ref
3411
-                                                     . '" value="'
3412
-                                                     . $button
3413
-                                                     . '" name="'
3414
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3415
-                                                     . '" id="'
3416
-                                                     . $this->_current_view . '_' . $ref
3417
-                                                     . '" />';
3418
-            if (! $both) {
3419
-                break;
3420
-            }
3421
-        }
3422
-    }
3423
-
3424
-
3425
-    /**
3426
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3427
-     *
3428
-     * @param string $route
3429
-     * @param array  $additional_hidden_fields
3430
-     * @see   $this->_set_add_edit_form_tags() for details on params
3431
-     * @since 4.6.0
3432
-     */
3433
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3434
-    {
3435
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3436
-    }
3437
-
3438
-
3439
-    /**
3440
-     * set form open and close tags on add/edit pages.
3441
-     *
3442
-     * @param string $route                    the route you want the form to direct to
3443
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3444
-     * @return void
3445
-     */
3446
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3447
-    {
3448
-        if (empty($route)) {
3449
-            $user_msg = esc_html__(
3450
-                'An error occurred. No action was set for this page\'s form.',
3451
-                'event_espresso'
3452
-            );
3453
-            $dev_msg  = $user_msg . "\n"
3454
-                        . sprintf(
3455
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3456
-                            __FUNCTION__,
3457
-                            __CLASS__
3458
-                        );
3459
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3460
-        }
3461
-        // open form
3462
-        $action = $this->_admin_base_url;
3463
-        $this->_template_args['before_admin_page_content'] = "
2774
+	}
2775
+
2776
+
2777
+	/**
2778
+	 * facade for $this->addMetaBox()
2779
+	 *
2780
+	 * @param string  $action        where the metabox get's displayed
2781
+	 * @param string  $title         Title of Metabox (output in metabox header)
2782
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2783
+	 *                               instead of the one created in here.
2784
+	 * @param array   $callback_args an array of args supplied for the metabox
2785
+	 * @param string  $column        what metabox column
2786
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2787
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2788
+	 *                               created but just set our own callback for wp's add_meta_box.
2789
+	 * @throws DomainException
2790
+	 */
2791
+	public function _add_admin_page_meta_box(
2792
+		$action,
2793
+		$title,
2794
+		$callback,
2795
+		$callback_args,
2796
+		$column = 'normal',
2797
+		$priority = 'high',
2798
+		$create_func = true
2799
+	) {
2800
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2801
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2802
+		if (empty($callback_args) && $create_func) {
2803
+			$callback_args = [
2804
+				'template_path' => $this->_template_path,
2805
+				'template_args' => $this->_template_args,
2806
+			];
2807
+		}
2808
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2809
+		$call_back_func = $create_func
2810
+			? static function ($post, $metabox) {
2811
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2812
+				echo EEH_Template::display_template(
2813
+					$metabox['args']['template_path'],
2814
+					$metabox['args']['template_args'],
2815
+					true
2816
+				);
2817
+			}
2818
+			: $callback;
2819
+		$this->addMetaBox(
2820
+			str_replace('_', '-', $action) . '-mbox',
2821
+			$title,
2822
+			$call_back_func,
2823
+			$this->_wp_page_slug,
2824
+			$column,
2825
+			$priority,
2826
+			$callback_args
2827
+		);
2828
+	}
2829
+
2830
+
2831
+	/**
2832
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2833
+	 *
2834
+	 * @throws DomainException
2835
+	 * @throws EE_Error
2836
+	 * @throws InvalidArgumentException
2837
+	 * @throws InvalidDataTypeException
2838
+	 * @throws InvalidInterfaceException
2839
+	 */
2840
+	public function display_admin_page_with_metabox_columns()
2841
+	{
2842
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2843
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2844
+			$this->_column_template_path,
2845
+			$this->_template_args,
2846
+			true
2847
+		);
2848
+		// the final wrapper
2849
+		$this->admin_page_wrapper();
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * generates  HTML wrapper for an admin details page
2855
+	 *
2856
+	 * @return void
2857
+	 * @throws DomainException
2858
+	 * @throws EE_Error
2859
+	 * @throws InvalidArgumentException
2860
+	 * @throws InvalidDataTypeException
2861
+	 * @throws InvalidInterfaceException
2862
+	 */
2863
+	public function display_admin_page_with_sidebar()
2864
+	{
2865
+		$this->_display_admin_page(true);
2866
+	}
2867
+
2868
+
2869
+	/**
2870
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2871
+	 *
2872
+	 * @return void
2873
+	 * @throws DomainException
2874
+	 * @throws EE_Error
2875
+	 * @throws InvalidArgumentException
2876
+	 * @throws InvalidDataTypeException
2877
+	 * @throws InvalidInterfaceException
2878
+	 */
2879
+	public function display_admin_page_with_no_sidebar()
2880
+	{
2881
+		$this->_display_admin_page();
2882
+	}
2883
+
2884
+
2885
+	/**
2886
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2887
+	 *
2888
+	 * @return void
2889
+	 * @throws DomainException
2890
+	 * @throws EE_Error
2891
+	 * @throws InvalidArgumentException
2892
+	 * @throws InvalidDataTypeException
2893
+	 * @throws InvalidInterfaceException
2894
+	 */
2895
+	public function display_about_admin_page()
2896
+	{
2897
+		$this->_display_admin_page(false, true);
2898
+	}
2899
+
2900
+
2901
+	/**
2902
+	 * display_admin_page
2903
+	 * contains the code for actually displaying an admin page
2904
+	 *
2905
+	 * @param boolean $sidebar true with sidebar, false without
2906
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2907
+	 * @return void
2908
+	 * @throws DomainException
2909
+	 * @throws EE_Error
2910
+	 * @throws InvalidArgumentException
2911
+	 * @throws InvalidDataTypeException
2912
+	 * @throws InvalidInterfaceException
2913
+	 */
2914
+	private function _display_admin_page($sidebar = false, $about = false)
2915
+	{
2916
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2917
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2918
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2919
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2920
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2921
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2922
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2923
+			? 'poststuff'
2924
+			: 'espresso-default-admin';
2925
+
2926
+		$template_path = $sidebar
2927
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2928
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2929
+		if ($this->request->isAjax()) {
2930
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2931
+		}
2932
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2933
+
2934
+		$this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2935
+		$this->_template_args['before_admin_page_content'] = $this->_template_args['before_admin_page_content'] ?? '';
2936
+		$this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2937
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2938
+			$template_path,
2939
+			$this->_template_args,
2940
+			true
2941
+		);
2942
+		// the final template wrapper
2943
+		$this->admin_page_wrapper($about);
2944
+	}
2945
+
2946
+
2947
+	/**
2948
+	 * This is used to display caf preview pages.
2949
+	 *
2950
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2951
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2952
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2953
+	 * @return void
2954
+	 * @throws DomainException
2955
+	 * @throws EE_Error
2956
+	 * @throws InvalidArgumentException
2957
+	 * @throws InvalidDataTypeException
2958
+	 * @throws InvalidInterfaceException
2959
+	 * @since 4.3.2
2960
+	 */
2961
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2962
+	{
2963
+		// let's generate a default preview action button if there isn't one already present.
2964
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2965
+			'Upgrade to Event Espresso 4 Right Now',
2966
+			'event_espresso'
2967
+		);
2968
+		$buy_now_url                                   = add_query_arg(
2969
+			[
2970
+				'ee_ver'       => 'ee4',
2971
+				'utm_source'   => 'ee4_plugin_admin',
2972
+				'utm_medium'   => 'link',
2973
+				'utm_campaign' => $utm_campaign_source,
2974
+				'utm_content'  => 'buy_now_button',
2975
+			],
2976
+			'https://eventespresso.com/pricing/'
2977
+		);
2978
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2979
+			? $this->get_action_link_or_button(
2980
+				'',
2981
+				'buy_now',
2982
+				[],
2983
+				'button--primary button--big',
2984
+				esc_url_raw($buy_now_url),
2985
+				true
2986
+			)
2987
+			: $this->_template_args['preview_action_button'];
2988
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2989
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2990
+			$this->_template_args,
2991
+			true
2992
+		);
2993
+		$this->_display_admin_page($display_sidebar);
2994
+	}
2995
+
2996
+
2997
+	/**
2998
+	 * display_admin_list_table_page_with_sidebar
2999
+	 * generates HTML wrapper for an admin_page with list_table
3000
+	 *
3001
+	 * @return void
3002
+	 * @throws DomainException
3003
+	 * @throws EE_Error
3004
+	 * @throws InvalidArgumentException
3005
+	 * @throws InvalidDataTypeException
3006
+	 * @throws InvalidInterfaceException
3007
+	 */
3008
+	public function display_admin_list_table_page_with_sidebar()
3009
+	{
3010
+		$this->_display_admin_list_table_page(true);
3011
+	}
3012
+
3013
+
3014
+	/**
3015
+	 * display_admin_list_table_page_with_no_sidebar
3016
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
3017
+	 *
3018
+	 * @return void
3019
+	 * @throws DomainException
3020
+	 * @throws EE_Error
3021
+	 * @throws InvalidArgumentException
3022
+	 * @throws InvalidDataTypeException
3023
+	 * @throws InvalidInterfaceException
3024
+	 */
3025
+	public function display_admin_list_table_page_with_no_sidebar()
3026
+	{
3027
+		$this->_display_admin_list_table_page();
3028
+	}
3029
+
3030
+
3031
+	/**
3032
+	 * generates html wrapper for an admin_list_table page
3033
+	 *
3034
+	 * @param boolean $sidebar whether to display with sidebar or not.
3035
+	 * @return void
3036
+	 * @throws DomainException
3037
+	 * @throws EE_Error
3038
+	 * @throws InvalidArgumentException
3039
+	 * @throws InvalidDataTypeException
3040
+	 * @throws InvalidInterfaceException
3041
+	 */
3042
+	private function _display_admin_list_table_page($sidebar = false)
3043
+	{
3044
+		// setup search attributes
3045
+		$this->_set_search_attributes();
3046
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3047
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3048
+		$this->_template_args['table_url']        = $this->request->isAjax()
3049
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3050
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3051
+		$this->_template_args['list_table']       = $this->_list_table_object;
3052
+		$this->_template_args['current_route']    = $this->_req_action;
3053
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3054
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3055
+		if (! empty($ajax_sorting_callback)) {
3056
+			$sortable_list_table_form_fields = wp_nonce_field(
3057
+				$ajax_sorting_callback . '_nonce',
3058
+				$ajax_sorting_callback . '_nonce',
3059
+				false,
3060
+				false
3061
+			);
3062
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3063
+												. $this->page_slug
3064
+												. '" />';
3065
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3066
+												. $ajax_sorting_callback
3067
+												. '" />';
3068
+		} else {
3069
+			$sortable_list_table_form_fields = '';
3070
+		}
3071
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3072
+		$hidden_form_fields                                      =
3073
+			isset($this->_template_args['list_table_hidden_fields'])
3074
+				? $this->_template_args['list_table_hidden_fields']
3075
+				: '';
3076
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3077
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3078
+																	. $nonce_ref
3079
+																	. '" value="'
3080
+																	. wp_create_nonce($nonce_ref)
3081
+																	. '">';
3082
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3083
+		// display message about search results?
3084
+		$search = $this->request->getRequestParam('s');
3085
+		$this->_template_args['before_list_table'] .= ! empty($search)
3086
+			? '<p class="ee-search-results">' . sprintf(
3087
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3088
+				trim($search, '%')
3089
+			) . '</p>'
3090
+			: '';
3091
+		// filter before_list_table template arg
3092
+		$this->_template_args['before_list_table'] = apply_filters(
3093
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3094
+			$this->_template_args['before_list_table'],
3095
+			$this->page_slug,
3096
+			$this->request->requestParams(),
3097
+			$this->_req_action
3098
+		);
3099
+		// convert to array and filter again
3100
+		// arrays are easier to inject new items in a specific location,
3101
+		// but would not be backwards compatible, so we have to add a new filter
3102
+		$this->_template_args['before_list_table'] = implode(
3103
+			" \n",
3104
+			(array) apply_filters(
3105
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3106
+				(array) $this->_template_args['before_list_table'],
3107
+				$this->page_slug,
3108
+				$this->request->requestParams(),
3109
+				$this->_req_action
3110
+			)
3111
+		);
3112
+		// filter after_list_table template arg
3113
+		$this->_template_args['after_list_table'] = apply_filters(
3114
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3115
+			$this->_template_args['after_list_table'],
3116
+			$this->page_slug,
3117
+			$this->request->requestParams(),
3118
+			$this->_req_action
3119
+		);
3120
+		// convert to array and filter again
3121
+		// arrays are easier to inject new items in a specific location,
3122
+		// but would not be backwards compatible, so we have to add a new filter
3123
+		$this->_template_args['after_list_table']   = implode(
3124
+			" \n",
3125
+			(array) apply_filters(
3126
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3127
+				(array) $this->_template_args['after_list_table'],
3128
+				$this->page_slug,
3129
+				$this->request->requestParams(),
3130
+				$this->_req_action
3131
+			)
3132
+		);
3133
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3134
+			$template_path,
3135
+			$this->_template_args,
3136
+			true
3137
+		);
3138
+		// the final template wrapper
3139
+		if ($sidebar) {
3140
+			$this->display_admin_page_with_sidebar();
3141
+		} else {
3142
+			$this->display_admin_page_with_no_sidebar();
3143
+		}
3144
+	}
3145
+
3146
+
3147
+	/**
3148
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3149
+	 * html string for the legend.
3150
+	 * $items are expected in an array in the following format:
3151
+	 * $legend_items = array(
3152
+	 *        'item_id' => array(
3153
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3154
+	 *            'desc' => esc_html__('localized description of item');
3155
+	 *        )
3156
+	 * );
3157
+	 *
3158
+	 * @param array $items see above for format of array
3159
+	 * @return string html string of legend
3160
+	 * @throws DomainException
3161
+	 */
3162
+	protected function _display_legend($items)
3163
+	{
3164
+		$this->_template_args['items'] = apply_filters(
3165
+			'FHEE__EE_Admin_Page___display_legend__items',
3166
+			(array) $items,
3167
+			$this
3168
+		);
3169
+		/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
3170
+		$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
3171
+		if (! $status_change_notice->isDismissed()) {
3172
+			$this->_template_args['status_change_notice'] = EEH_Template::display_template(
3173
+				EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
3174
+				[ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
3175
+				true
3176
+			);
3177
+		}
3178
+		return EEH_Template::display_template(
3179
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3180
+			$this->_template_args,
3181
+			true
3182
+		);
3183
+	}
3184
+
3185
+
3186
+	/**
3187
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3188
+	 * The returned json object is created from an array in the following format:
3189
+	 * array(
3190
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3191
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3192
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3193
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3194
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3195
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3196
+	 *  that might be included in here)
3197
+	 * )
3198
+	 * The json object is populated by whatever is set in the $_template_args property.
3199
+	 *
3200
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3201
+	 *                                 instead of displayed.
3202
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3203
+	 * @return void
3204
+	 * @throws EE_Error
3205
+	 * @throws InvalidArgumentException
3206
+	 * @throws InvalidDataTypeException
3207
+	 * @throws InvalidInterfaceException
3208
+	 */
3209
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3210
+	{
3211
+		// make sure any EE_Error notices have been handled.
3212
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3213
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3214
+		unset($this->_template_args['data']);
3215
+		$json = [
3216
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3217
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3218
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3219
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3220
+			'notices'   => EE_Error::get_notices(),
3221
+			'content'   => isset($this->_template_args['admin_page_content'])
3222
+				? $this->_template_args['admin_page_content'] : '',
3223
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3224
+			'isEEajax'  => true
3225
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3226
+		];
3227
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3228
+		if (null === error_get_last() || ! headers_sent()) {
3229
+			header('Content-Type: application/json; charset=UTF-8');
3230
+		}
3231
+		echo wp_json_encode($json);
3232
+		exit();
3233
+	}
3234
+
3235
+
3236
+	/**
3237
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3238
+	 *
3239
+	 * @return void
3240
+	 * @throws EE_Error
3241
+	 * @throws InvalidArgumentException
3242
+	 * @throws InvalidDataTypeException
3243
+	 * @throws InvalidInterfaceException
3244
+	 */
3245
+	public function return_json()
3246
+	{
3247
+		if ($this->request->isAjax()) {
3248
+			$this->_return_json();
3249
+		} else {
3250
+			throw new EE_Error(
3251
+				sprintf(
3252
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3253
+					__FUNCTION__
3254
+				)
3255
+			);
3256
+		}
3257
+	}
3258
+
3259
+
3260
+	/**
3261
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3262
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3263
+	 *
3264
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3265
+	 */
3266
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3267
+	{
3268
+		$this->_hook_obj = $hook_obj;
3269
+	}
3270
+
3271
+
3272
+	/**
3273
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3274
+	 *
3275
+	 * @param boolean $about whether to use the special about page wrapper or default.
3276
+	 * @return void
3277
+	 * @throws DomainException
3278
+	 * @throws EE_Error
3279
+	 * @throws InvalidArgumentException
3280
+	 * @throws InvalidDataTypeException
3281
+	 * @throws InvalidInterfaceException
3282
+	 */
3283
+	public function admin_page_wrapper($about = false)
3284
+	{
3285
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3286
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3287
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3288
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3289
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3290
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3291
+			isset($this->_template_args['before_admin_page_content'])
3292
+				? $this->_template_args['before_admin_page_content']
3293
+				: ''
3294
+		);
3295
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3296
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3297
+			isset($this->_template_args['after_admin_page_content'])
3298
+				? $this->_template_args['after_admin_page_content']
3299
+				: ''
3300
+		);
3301
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3302
+		// load settings page wrapper template
3303
+		$template_path = ! $this->request->isAjax()
3304
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3305
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3306
+		// about page?
3307
+		$template_path = $about
3308
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3309
+			: $template_path;
3310
+		if ($this->request->isAjax()) {
3311
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3312
+				$template_path,
3313
+				$this->_template_args,
3314
+				true
3315
+			);
3316
+			$this->_return_json();
3317
+		} else {
3318
+			EEH_Template::display_template($template_path, $this->_template_args);
3319
+		}
3320
+	}
3321
+
3322
+
3323
+	/**
3324
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3325
+	 *
3326
+	 * @return string html
3327
+	 * @throws EE_Error
3328
+	 */
3329
+	protected function _get_main_nav_tabs()
3330
+	{
3331
+		// let's generate the html using the EEH_Tabbed_Content helper.
3332
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3333
+		// (rather than setting in the page_routes array)
3334
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3335
+	}
3336
+
3337
+
3338
+	/**
3339
+	 *        sort nav tabs
3340
+	 *
3341
+	 * @param $a
3342
+	 * @param $b
3343
+	 * @return int
3344
+	 */
3345
+	private function _sort_nav_tabs($a, $b)
3346
+	{
3347
+		if ($a['order'] === $b['order']) {
3348
+			return 0;
3349
+		}
3350
+		return ($a['order'] < $b['order']) ? -1 : 1;
3351
+	}
3352
+
3353
+
3354
+	/**
3355
+	 * generates HTML for the forms used on admin pages
3356
+	 *
3357
+	 * @param array  $input_vars - array of input field details
3358
+	 * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3359
+	 * @param bool   $id
3360
+	 * @return array|string
3361
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3362
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3363
+	 */
3364
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3365
+	{
3366
+		return $generator === 'string'
3367
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3368
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3369
+	}
3370
+
3371
+
3372
+	/**
3373
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3374
+	 *
3375
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3376
+	 *                                   Close" button.
3377
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3378
+	 *                                   'Save', [1] => 'save & close')
3379
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3380
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3381
+	 *                                   default actions by submitting some other value.
3382
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3383
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3384
+	 *                                   close (normal form handling).
3385
+	 */
3386
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3387
+	{
3388
+		// make sure $text and $actions are in an array
3389
+		$text          = (array) $text;
3390
+		$actions       = (array) $actions;
3391
+		$referrer_url  = empty($referrer)
3392
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3393
+			  . $this->request->getServerParam('REQUEST_URI')
3394
+			  . '" />'
3395
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3396
+			  . $referrer
3397
+			  . '" />';
3398
+		$button_text   = ! empty($text)
3399
+			? $text
3400
+			: [
3401
+				esc_html__('Save', 'event_espresso'),
3402
+				esc_html__('Save and Close', 'event_espresso'),
3403
+			];
3404
+		$default_names = ['save', 'save_and_close'];
3405
+		// add in a hidden index for the current page (so save and close redirects properly)
3406
+		$this->_template_args['save_buttons'] = $referrer_url;
3407
+		foreach ($button_text as $key => $button) {
3408
+			$ref                                  = $default_names[ $key ];
3409
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button--primary '
3410
+													 . $ref
3411
+													 . '" value="'
3412
+													 . $button
3413
+													 . '" name="'
3414
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3415
+													 . '" id="'
3416
+													 . $this->_current_view . '_' . $ref
3417
+													 . '" />';
3418
+			if (! $both) {
3419
+				break;
3420
+			}
3421
+		}
3422
+	}
3423
+
3424
+
3425
+	/**
3426
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3427
+	 *
3428
+	 * @param string $route
3429
+	 * @param array  $additional_hidden_fields
3430
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3431
+	 * @since 4.6.0
3432
+	 */
3433
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3434
+	{
3435
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3436
+	}
3437
+
3438
+
3439
+	/**
3440
+	 * set form open and close tags on add/edit pages.
3441
+	 *
3442
+	 * @param string $route                    the route you want the form to direct to
3443
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3444
+	 * @return void
3445
+	 */
3446
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3447
+	{
3448
+		if (empty($route)) {
3449
+			$user_msg = esc_html__(
3450
+				'An error occurred. No action was set for this page\'s form.',
3451
+				'event_espresso'
3452
+			);
3453
+			$dev_msg  = $user_msg . "\n"
3454
+						. sprintf(
3455
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3456
+							__FUNCTION__,
3457
+							__CLASS__
3458
+						);
3459
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3460
+		}
3461
+		// open form
3462
+		$action = $this->_admin_base_url;
3463
+		$this->_template_args['before_admin_page_content'] = "
3464 3464
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3465 3465
             ";
3466
-        // add nonce
3467
-        $nonce                                             =
3468
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3469
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3470
-        // add REQUIRED form action
3471
-        $hidden_fields = [
3472
-            'action' => ['type' => 'hidden', 'value' => $route],
3473
-        ];
3474
-        // merge arrays
3475
-        $hidden_fields = is_array($additional_hidden_fields)
3476
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3477
-            : $hidden_fields;
3478
-        // generate form fields
3479
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3480
-        // add fields to form
3481
-        foreach ((array) $form_fields as $field_name => $form_field) {
3482
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3483
-        }
3484
-        // close form
3485
-        $this->_template_args['after_admin_page_content'] = '</form>';
3486
-    }
3487
-
3488
-
3489
-    /**
3490
-     * Public Wrapper for _redirect_after_action() method since its
3491
-     * discovered it would be useful for external code to have access.
3492
-     *
3493
-     * @param bool   $success
3494
-     * @param string $what
3495
-     * @param string $action_desc
3496
-     * @param array  $query_args
3497
-     * @param bool   $override_overwrite
3498
-     * @throws EE_Error
3499
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3500
-     * @since 4.5.0
3501
-     */
3502
-    public function redirect_after_action(
3503
-        $success = false,
3504
-        $what = 'item',
3505
-        $action_desc = 'processed',
3506
-        $query_args = [],
3507
-        $override_overwrite = false
3508
-    ) {
3509
-        $this->_redirect_after_action(
3510
-            $success,
3511
-            $what,
3512
-            $action_desc,
3513
-            $query_args,
3514
-            $override_overwrite
3515
-        );
3516
-    }
3517
-
3518
-
3519
-    /**
3520
-     * Helper method for merging existing request data with the returned redirect url.
3521
-     *
3522
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3523
-     * filters are still applied.
3524
-     *
3525
-     * @param array $new_route_data
3526
-     * @return array
3527
-     */
3528
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3529
-    {
3530
-        foreach ($this->request->requestParams() as $ref => $value) {
3531
-            // unset nonces
3532
-            if (strpos($ref, 'nonce') !== false) {
3533
-                $this->request->unSetRequestParam($ref);
3534
-                continue;
3535
-            }
3536
-            // urlencode values.
3537
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3538
-            $this->request->setRequestParam($ref, $value);
3539
-        }
3540
-        return array_merge($this->request->requestParams(), $new_route_data);
3541
-    }
3542
-
3543
-
3544
-    /**
3545
-     *    _redirect_after_action
3546
-     *
3547
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3548
-     * @param string $what               - what the action was performed on
3549
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3550
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3551
-     *                                   action is completed
3552
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3553
-     *                                   override this so that they show.
3554
-     * @return void
3555
-     * @throws EE_Error
3556
-     * @throws InvalidArgumentException
3557
-     * @throws InvalidDataTypeException
3558
-     * @throws InvalidInterfaceException
3559
-     */
3560
-    protected function _redirect_after_action(
3561
-        $success = 0,
3562
-        $what = 'item',
3563
-        $action_desc = 'processed',
3564
-        $query_args = [],
3565
-        $override_overwrite = false
3566
-    ) {
3567
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3568
-        // class name for actions/filters.
3569
-        $classname = get_class($this);
3570
-        // set redirect url.
3571
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3572
-        // otherwise we go with whatever is set as the _admin_base_url
3573
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3574
-        $notices      = EE_Error::get_notices(false);
3575
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3576
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3577
-            EE_Error::overwrite_success();
3578
-        }
3579
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3580
-            // how many records affected ? more than one record ? or just one ?
3581
-            if ($success > 1) {
3582
-                // set plural msg
3583
-                EE_Error::add_success(
3584
-                    sprintf(
3585
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3586
-                        $what,
3587
-                        $action_desc
3588
-                    ),
3589
-                    __FILE__,
3590
-                    __FUNCTION__,
3591
-                    __LINE__
3592
-                );
3593
-            } elseif ($success === 1) {
3594
-                // set singular msg
3595
-                EE_Error::add_success(
3596
-                    sprintf(
3597
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3598
-                        $what,
3599
-                        $action_desc
3600
-                    ),
3601
-                    __FILE__,
3602
-                    __FUNCTION__,
3603
-                    __LINE__
3604
-                );
3605
-            }
3606
-        }
3607
-        // check that $query_args isn't something crazy
3608
-        if (! is_array($query_args)) {
3609
-            $query_args = [];
3610
-        }
3611
-        /**
3612
-         * Allow injecting actions before the query_args are modified for possible different
3613
-         * redirections on save and close actions
3614
-         *
3615
-         * @param array $query_args       The original query_args array coming into the
3616
-         *                                method.
3617
-         * @since 4.2.0
3618
-         */
3619
-        do_action(
3620
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3621
-            $query_args
3622
-        );
3623
-        // calculate where we're going (if we have a "save and close" button pushed)
3624
-
3625
-        if (
3626
-            $this->request->requestParamIsSet('save_and_close')
3627
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3628
-        ) {
3629
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3630
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3631
-            // regenerate query args array from referrer URL
3632
-            parse_str($parsed_url['query'], $query_args);
3633
-            // correct page and action will be in the query args now
3634
-            $redirect_url = admin_url('admin.php');
3635
-        }
3636
-        // merge any default query_args set in _default_route_query_args property
3637
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3638
-            $args_to_merge = [];
3639
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3640
-                // is there a wp_referer array in our _default_route_query_args property?
3641
-                if ($query_param === 'wp_referer') {
3642
-                    $query_value = (array) $query_value;
3643
-                    foreach ($query_value as $reference => $value) {
3644
-                        if (strpos($reference, 'nonce') !== false) {
3645
-                            continue;
3646
-                        }
3647
-                        // finally we will override any arguments in the referer with
3648
-                        // what might be set on the _default_route_query_args array.
3649
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3650
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3651
-                        } else {
3652
-                            $args_to_merge[ $reference ] = urlencode($value);
3653
-                        }
3654
-                    }
3655
-                    continue;
3656
-                }
3657
-                $args_to_merge[ $query_param ] = $query_value;
3658
-            }
3659
-            // now let's merge these arguments but override with what was specifically sent in to the
3660
-            // redirect.
3661
-            $query_args = array_merge($args_to_merge, $query_args);
3662
-        }
3663
-        $this->_process_notices($query_args);
3664
-        // generate redirect url
3665
-        // if redirecting to anything other than the main page, add a nonce
3666
-        if (isset($query_args['action'])) {
3667
-            // manually generate wp_nonce and merge that with the query vars
3668
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3669
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3670
-        }
3671
-        // we're adding some hooks and filters in here for processing any things just before redirects
3672
-        // (example: an admin page has done an insert or update and we want to run something after that).
3673
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3674
-        $redirect_url = apply_filters(
3675
-            'FHEE_redirect_' . $classname . $this->_req_action,
3676
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3677
-            $query_args
3678
-        );
3679
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3680
-        if ($this->request->isAjax()) {
3681
-            $default_data                    = [
3682
-                'close'        => true,
3683
-                'redirect_url' => $redirect_url,
3684
-                'where'        => 'main',
3685
-                'what'         => 'append',
3686
-            ];
3687
-            $this->_template_args['success'] = $success;
3688
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3689
-                $default_data,
3690
-                $this->_template_args['data']
3691
-            ) : $default_data;
3692
-            $this->_return_json();
3693
-        }
3694
-        wp_safe_redirect($redirect_url);
3695
-        exit();
3696
-    }
3697
-
3698
-
3699
-    /**
3700
-     * process any notices before redirecting (or returning ajax request)
3701
-     * This method sets the $this->_template_args['notices'] attribute;
3702
-     *
3703
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3704
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3705
-     *                                  page_routes haven't been defined yet.
3706
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3707
-     *                                  still save a transient for the notice.
3708
-     * @return void
3709
-     * @throws EE_Error
3710
-     * @throws InvalidArgumentException
3711
-     * @throws InvalidDataTypeException
3712
-     * @throws InvalidInterfaceException
3713
-     */
3714
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3715
-    {
3716
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3717
-        if ($this->request->isAjax()) {
3718
-            $notices = EE_Error::get_notices(false);
3719
-            if (empty($this->_template_args['success'])) {
3720
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3721
-            }
3722
-            if (empty($this->_template_args['errors'])) {
3723
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3724
-            }
3725
-            if (empty($this->_template_args['attention'])) {
3726
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3727
-            }
3728
-        }
3729
-        $this->_template_args['notices'] = EE_Error::get_notices();
3730
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3731
-        if (! $this->request->isAjax() || $sticky_notices) {
3732
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3733
-            $this->_add_transient(
3734
-                $route,
3735
-                $this->_template_args['notices'],
3736
-                true,
3737
-                $skip_route_verify
3738
-            );
3739
-        }
3740
-    }
3741
-
3742
-
3743
-    /**
3744
-     * get_action_link_or_button
3745
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3746
-     *
3747
-     * @param string $action        use this to indicate which action the url is generated with.
3748
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3749
-     *                              property.
3750
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3751
-     * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3752
-     * @param string $base_url      If this is not provided
3753
-     *                              the _admin_base_url will be used as the default for the button base_url.
3754
-     *                              Otherwise this value will be used.
3755
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3756
-     * @return string
3757
-     * @throws InvalidArgumentException
3758
-     * @throws InvalidInterfaceException
3759
-     * @throws InvalidDataTypeException
3760
-     * @throws EE_Error
3761
-     */
3762
-    public function get_action_link_or_button(
3763
-        $action,
3764
-        $type = 'add',
3765
-        $extra_request = [],
3766
-        $class = 'button--primary',
3767
-        $base_url = '',
3768
-        $exclude_nonce = false
3769
-    ) {
3770
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3771
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3772
-            throw new EE_Error(
3773
-                sprintf(
3774
-                    esc_html__(
3775
-                        'There is no page route for given action for the button.  This action was given: %s',
3776
-                        'event_espresso'
3777
-                    ),
3778
-                    $action
3779
-                )
3780
-            );
3781
-        }
3782
-        if (! isset($this->_labels['buttons'][ $type ])) {
3783
-            throw new EE_Error(
3784
-                sprintf(
3785
-                    esc_html__(
3786
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3787
-                        'event_espresso'
3788
-                    ),
3789
-                    $type
3790
-                )
3791
-            );
3792
-        }
3793
-        // finally check user access for this button.
3794
-        $has_access = $this->check_user_access($action, true);
3795
-        if (! $has_access) {
3796
-            return '';
3797
-        }
3798
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3799
-        $query_args = [
3800
-            'action' => $action,
3801
-        ];
3802
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3803
-        if (! empty($extra_request)) {
3804
-            $query_args = array_merge($extra_request, $query_args);
3805
-        }
3806
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3807
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3808
-    }
3809
-
3810
-
3811
-    /**
3812
-     * _per_page_screen_option
3813
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3814
-     *
3815
-     * @return void
3816
-     * @throws InvalidArgumentException
3817
-     * @throws InvalidInterfaceException
3818
-     * @throws InvalidDataTypeException
3819
-     */
3820
-    protected function _per_page_screen_option()
3821
-    {
3822
-        $option = 'per_page';
3823
-        $args   = [
3824
-            'label'   => apply_filters(
3825
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3826
-                $this->_admin_page_title,
3827
-                $this
3828
-            ),
3829
-            'default' => (int) apply_filters(
3830
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3831
-                20
3832
-            ),
3833
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3834
-        ];
3835
-        // ONLY add the screen option if the user has access to it.
3836
-        if ($this->check_user_access($this->_current_view, true)) {
3837
-            add_screen_option($option, $args);
3838
-        }
3839
-    }
3840
-
3841
-
3842
-    /**
3843
-     * set_per_page_screen_option
3844
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3845
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3846
-     * admin_menu.
3847
-     *
3848
-     * @return void
3849
-     */
3850
-    private function _set_per_page_screen_options()
3851
-    {
3852
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3853
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3854
-            if (! $user = wp_get_current_user()) {
3855
-                return;
3856
-            }
3857
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3858
-            if (! $option) {
3859
-                return;
3860
-            }
3861
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3862
-            $map_option = $option;
3863
-            $option     = str_replace('-', '_', $option);
3864
-            switch ($map_option) {
3865
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3866
-                    $max_value = apply_filters(
3867
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3868
-                        999,
3869
-                        $this->_current_page,
3870
-                        $this->_current_view
3871
-                    );
3872
-                    if ($value < 1) {
3873
-                        return;
3874
-                    }
3875
-                    $value = min($value, $max_value);
3876
-                    break;
3877
-                default:
3878
-                    $value = apply_filters(
3879
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3880
-                        false,
3881
-                        $option,
3882
-                        $value
3883
-                    );
3884
-                    if (false === $value) {
3885
-                        return;
3886
-                    }
3887
-                    break;
3888
-            }
3889
-            update_user_meta($user->ID, $option, $value);
3890
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3891
-            exit;
3892
-        }
3893
-    }
3894
-
3895
-
3896
-    /**
3897
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3898
-     *
3899
-     * @param array $data array that will be assigned to template args.
3900
-     */
3901
-    public function set_template_args($data)
3902
-    {
3903
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3904
-    }
3905
-
3906
-
3907
-    /**
3908
-     * This makes available the WP transient system for temporarily moving data between routes
3909
-     *
3910
-     * @param string $route             the route that should receive the transient
3911
-     * @param array  $data              the data that gets sent
3912
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3913
-     *                                  normal route transient.
3914
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3915
-     *                                  when we are adding a transient before page_routes have been defined.
3916
-     * @return void
3917
-     * @throws EE_Error
3918
-     */
3919
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3920
-    {
3921
-        $user_id = get_current_user_id();
3922
-        if (! $skip_route_verify) {
3923
-            $this->_verify_route($route);
3924
-        }
3925
-        // now let's set the string for what kind of transient we're setting
3926
-        $transient = $notices
3927
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3928
-            : 'rte_tx_' . $route . '_' . $user_id;
3929
-        $data      = $notices ? ['notices' => $data] : $data;
3930
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3931
-        $existing = is_multisite() && is_network_admin()
3932
-            ? get_site_transient($transient)
3933
-            : get_transient($transient);
3934
-        if ($existing) {
3935
-            $data = array_merge((array) $data, (array) $existing);
3936
-        }
3937
-        if (is_multisite() && is_network_admin()) {
3938
-            set_site_transient($transient, $data, 8);
3939
-        } else {
3940
-            set_transient($transient, $data, 8);
3941
-        }
3942
-    }
3943
-
3944
-
3945
-    /**
3946
-     * this retrieves the temporary transient that has been set for moving data between routes.
3947
-     *
3948
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3949
-     * @param string $route
3950
-     * @return mixed data
3951
-     */
3952
-    protected function _get_transient($notices = false, $route = '')
3953
-    {
3954
-        $user_id   = get_current_user_id();
3955
-        $route     = ! $route ? $this->_req_action : $route;
3956
-        $transient = $notices
3957
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3958
-            : 'rte_tx_' . $route . '_' . $user_id;
3959
-        $data      = is_multisite() && is_network_admin()
3960
-            ? get_site_transient($transient)
3961
-            : get_transient($transient);
3962
-        // delete transient after retrieval (just in case it hasn't expired);
3963
-        if (is_multisite() && is_network_admin()) {
3964
-            delete_site_transient($transient);
3965
-        } else {
3966
-            delete_transient($transient);
3967
-        }
3968
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3969
-    }
3970
-
3971
-
3972
-    /**
3973
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3974
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3975
-     * default route callback on the EE_Admin page you want it run.)
3976
-     *
3977
-     * @return void
3978
-     */
3979
-    protected function _transient_garbage_collection()
3980
-    {
3981
-        global $wpdb;
3982
-        // retrieve all existing transients
3983
-        $query =
3984
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3985
-        if ($results = $wpdb->get_results($query)) {
3986
-            foreach ($results as $result) {
3987
-                $transient = str_replace('_transient_', '', $result->option_name);
3988
-                get_transient($transient);
3989
-                if (is_multisite() && is_network_admin()) {
3990
-                    get_site_transient($transient);
3991
-                }
3992
-            }
3993
-        }
3994
-    }
3995
-
3996
-
3997
-    /**
3998
-     * get_view
3999
-     *
4000
-     * @return string content of _view property
4001
-     */
4002
-    public function get_view()
4003
-    {
4004
-        return $this->_view;
4005
-    }
4006
-
4007
-
4008
-    /**
4009
-     * getter for the protected $_views property
4010
-     *
4011
-     * @return array
4012
-     */
4013
-    public function get_views()
4014
-    {
4015
-        return $this->_views;
4016
-    }
4017
-
4018
-
4019
-    /**
4020
-     * get_current_page
4021
-     *
4022
-     * @return string _current_page property value
4023
-     */
4024
-    public function get_current_page()
4025
-    {
4026
-        return $this->_current_page;
4027
-    }
4028
-
4029
-
4030
-    /**
4031
-     * get_current_view
4032
-     *
4033
-     * @return string _current_view property value
4034
-     */
4035
-    public function get_current_view()
4036
-    {
4037
-        return $this->_current_view;
4038
-    }
4039
-
4040
-
4041
-    /**
4042
-     * get_current_screen
4043
-     *
4044
-     * @return object The current WP_Screen object
4045
-     */
4046
-    public function get_current_screen()
4047
-    {
4048
-        return $this->_current_screen;
4049
-    }
4050
-
4051
-
4052
-    /**
4053
-     * get_current_page_view_url
4054
-     *
4055
-     * @return string This returns the url for the current_page_view.
4056
-     */
4057
-    public function get_current_page_view_url()
4058
-    {
4059
-        return $this->_current_page_view_url;
4060
-    }
4061
-
4062
-
4063
-    /**
4064
-     * just returns the Request
4065
-     *
4066
-     * @return RequestInterface
4067
-     */
4068
-    public function get_request()
4069
-    {
4070
-        return $this->request;
4071
-    }
4072
-
4073
-
4074
-    /**
4075
-     * just returns the _req_data property
4076
-     *
4077
-     * @return array
4078
-     */
4079
-    public function get_request_data()
4080
-    {
4081
-        return $this->request->requestParams();
4082
-    }
4083
-
4084
-
4085
-    /**
4086
-     * returns the _req_data protected property
4087
-     *
4088
-     * @return string
4089
-     */
4090
-    public function get_req_action()
4091
-    {
4092
-        return $this->_req_action;
4093
-    }
4094
-
4095
-
4096
-    /**
4097
-     * @return bool  value of $_is_caf property
4098
-     */
4099
-    public function is_caf()
4100
-    {
4101
-        return $this->_is_caf;
4102
-    }
4103
-
4104
-
4105
-    /**
4106
-     * @return mixed
4107
-     */
4108
-    public function default_espresso_metaboxes()
4109
-    {
4110
-        return $this->_default_espresso_metaboxes;
4111
-    }
4112
-
4113
-
4114
-    /**
4115
-     * @return mixed
4116
-     */
4117
-    public function admin_base_url()
4118
-    {
4119
-        return $this->_admin_base_url;
4120
-    }
4121
-
4122
-
4123
-    /**
4124
-     * @return mixed
4125
-     */
4126
-    public function wp_page_slug()
4127
-    {
4128
-        return $this->_wp_page_slug;
4129
-    }
4130
-
4131
-
4132
-    /**
4133
-     * updates  espresso configuration settings
4134
-     *
4135
-     * @param string                   $tab
4136
-     * @param EE_Config_Base|EE_Config $config
4137
-     * @param string                   $file file where error occurred
4138
-     * @param string                   $func function  where error occurred
4139
-     * @param string                   $line line no where error occurred
4140
-     * @return boolean
4141
-     */
4142
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4143
-    {
4144
-        // remove any options that are NOT going to be saved with the config settings.
4145
-        if (isset($config->core->ee_ueip_optin)) {
4146
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4147
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4148
-            update_option('ee_ueip_has_notified', true);
4149
-        }
4150
-        // and save it (note we're also doing the network save here)
4151
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4152
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4153
-        if ($config_saved && $net_saved) {
4154
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4155
-            return true;
4156
-        }
4157
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4158
-        return false;
4159
-    }
4160
-
4161
-
4162
-    /**
4163
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4164
-     *
4165
-     * @return array
4166
-     */
4167
-    public function get_yes_no_values()
4168
-    {
4169
-        return $this->_yes_no_values;
4170
-    }
4171
-
4172
-
4173
-    /**
4174
-     * @return string
4175
-     * @throws ReflectionException
4176
-     * @since $VID:$
4177
-     */
4178
-    protected function _get_dir()
4179
-    {
4180
-        $reflector = new ReflectionClass(get_class($this));
4181
-        return dirname($reflector->getFileName());
4182
-    }
4183
-
4184
-
4185
-    /**
4186
-     * A helper for getting a "next link".
4187
-     *
4188
-     * @param string $url   The url to link to
4189
-     * @param string $class The class to use.
4190
-     * @return string
4191
-     */
4192
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4193
-    {
4194
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4195
-    }
4196
-
4197
-
4198
-    /**
4199
-     * A helper for getting a "previous link".
4200
-     *
4201
-     * @param string $url   The url to link to
4202
-     * @param string $class The class to use.
4203
-     * @return string
4204
-     */
4205
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4206
-    {
4207
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4208
-    }
4209
-
4210
-
4211
-
4212
-
4213
-
4214
-
4215
-
4216
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4217
-
4218
-
4219
-    /**
4220
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4221
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4222
-     * _req_data array.
4223
-     *
4224
-     * @return bool success/fail
4225
-     * @throws EE_Error
4226
-     * @throws InvalidArgumentException
4227
-     * @throws ReflectionException
4228
-     * @throws InvalidDataTypeException
4229
-     * @throws InvalidInterfaceException
4230
-     */
4231
-    protected function _process_resend_registration()
4232
-    {
4233
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4234
-        do_action(
4235
-            'AHEE__EE_Admin_Page___process_resend_registration',
4236
-            $this->_template_args['success'],
4237
-            $this->request->requestParams()
4238
-        );
4239
-        return $this->_template_args['success'];
4240
-    }
4241
-
4242
-
4243
-    /**
4244
-     * This automatically processes any payment message notifications when manual payment has been applied.
4245
-     *
4246
-     * @param EE_Payment $payment
4247
-     * @return bool success/fail
4248
-     */
4249
-    protected function _process_payment_notification(EE_Payment $payment)
4250
-    {
4251
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4252
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4253
-        $this->_template_args['success'] = apply_filters(
4254
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4255
-            false,
4256
-            $payment
4257
-        );
4258
-        return $this->_template_args['success'];
4259
-    }
3466
+		// add nonce
3467
+		$nonce                                             =
3468
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3469
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3470
+		// add REQUIRED form action
3471
+		$hidden_fields = [
3472
+			'action' => ['type' => 'hidden', 'value' => $route],
3473
+		];
3474
+		// merge arrays
3475
+		$hidden_fields = is_array($additional_hidden_fields)
3476
+			? array_merge($hidden_fields, $additional_hidden_fields)
3477
+			: $hidden_fields;
3478
+		// generate form fields
3479
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3480
+		// add fields to form
3481
+		foreach ((array) $form_fields as $field_name => $form_field) {
3482
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3483
+		}
3484
+		// close form
3485
+		$this->_template_args['after_admin_page_content'] = '</form>';
3486
+	}
3487
+
3488
+
3489
+	/**
3490
+	 * Public Wrapper for _redirect_after_action() method since its
3491
+	 * discovered it would be useful for external code to have access.
3492
+	 *
3493
+	 * @param bool   $success
3494
+	 * @param string $what
3495
+	 * @param string $action_desc
3496
+	 * @param array  $query_args
3497
+	 * @param bool   $override_overwrite
3498
+	 * @throws EE_Error
3499
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3500
+	 * @since 4.5.0
3501
+	 */
3502
+	public function redirect_after_action(
3503
+		$success = false,
3504
+		$what = 'item',
3505
+		$action_desc = 'processed',
3506
+		$query_args = [],
3507
+		$override_overwrite = false
3508
+	) {
3509
+		$this->_redirect_after_action(
3510
+			$success,
3511
+			$what,
3512
+			$action_desc,
3513
+			$query_args,
3514
+			$override_overwrite
3515
+		);
3516
+	}
3517
+
3518
+
3519
+	/**
3520
+	 * Helper method for merging existing request data with the returned redirect url.
3521
+	 *
3522
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3523
+	 * filters are still applied.
3524
+	 *
3525
+	 * @param array $new_route_data
3526
+	 * @return array
3527
+	 */
3528
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3529
+	{
3530
+		foreach ($this->request->requestParams() as $ref => $value) {
3531
+			// unset nonces
3532
+			if (strpos($ref, 'nonce') !== false) {
3533
+				$this->request->unSetRequestParam($ref);
3534
+				continue;
3535
+			}
3536
+			// urlencode values.
3537
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3538
+			$this->request->setRequestParam($ref, $value);
3539
+		}
3540
+		return array_merge($this->request->requestParams(), $new_route_data);
3541
+	}
3542
+
3543
+
3544
+	/**
3545
+	 *    _redirect_after_action
3546
+	 *
3547
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3548
+	 * @param string $what               - what the action was performed on
3549
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3550
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3551
+	 *                                   action is completed
3552
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3553
+	 *                                   override this so that they show.
3554
+	 * @return void
3555
+	 * @throws EE_Error
3556
+	 * @throws InvalidArgumentException
3557
+	 * @throws InvalidDataTypeException
3558
+	 * @throws InvalidInterfaceException
3559
+	 */
3560
+	protected function _redirect_after_action(
3561
+		$success = 0,
3562
+		$what = 'item',
3563
+		$action_desc = 'processed',
3564
+		$query_args = [],
3565
+		$override_overwrite = false
3566
+	) {
3567
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3568
+		// class name for actions/filters.
3569
+		$classname = get_class($this);
3570
+		// set redirect url.
3571
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3572
+		// otherwise we go with whatever is set as the _admin_base_url
3573
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3574
+		$notices      = EE_Error::get_notices(false);
3575
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3576
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3577
+			EE_Error::overwrite_success();
3578
+		}
3579
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3580
+			// how many records affected ? more than one record ? or just one ?
3581
+			if ($success > 1) {
3582
+				// set plural msg
3583
+				EE_Error::add_success(
3584
+					sprintf(
3585
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3586
+						$what,
3587
+						$action_desc
3588
+					),
3589
+					__FILE__,
3590
+					__FUNCTION__,
3591
+					__LINE__
3592
+				);
3593
+			} elseif ($success === 1) {
3594
+				// set singular msg
3595
+				EE_Error::add_success(
3596
+					sprintf(
3597
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3598
+						$what,
3599
+						$action_desc
3600
+					),
3601
+					__FILE__,
3602
+					__FUNCTION__,
3603
+					__LINE__
3604
+				);
3605
+			}
3606
+		}
3607
+		// check that $query_args isn't something crazy
3608
+		if (! is_array($query_args)) {
3609
+			$query_args = [];
3610
+		}
3611
+		/**
3612
+		 * Allow injecting actions before the query_args are modified for possible different
3613
+		 * redirections on save and close actions
3614
+		 *
3615
+		 * @param array $query_args       The original query_args array coming into the
3616
+		 *                                method.
3617
+		 * @since 4.2.0
3618
+		 */
3619
+		do_action(
3620
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3621
+			$query_args
3622
+		);
3623
+		// calculate where we're going (if we have a "save and close" button pushed)
3624
+
3625
+		if (
3626
+			$this->request->requestParamIsSet('save_and_close')
3627
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3628
+		) {
3629
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3630
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3631
+			// regenerate query args array from referrer URL
3632
+			parse_str($parsed_url['query'], $query_args);
3633
+			// correct page and action will be in the query args now
3634
+			$redirect_url = admin_url('admin.php');
3635
+		}
3636
+		// merge any default query_args set in _default_route_query_args property
3637
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3638
+			$args_to_merge = [];
3639
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3640
+				// is there a wp_referer array in our _default_route_query_args property?
3641
+				if ($query_param === 'wp_referer') {
3642
+					$query_value = (array) $query_value;
3643
+					foreach ($query_value as $reference => $value) {
3644
+						if (strpos($reference, 'nonce') !== false) {
3645
+							continue;
3646
+						}
3647
+						// finally we will override any arguments in the referer with
3648
+						// what might be set on the _default_route_query_args array.
3649
+						if (isset($this->_default_route_query_args[ $reference ])) {
3650
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3651
+						} else {
3652
+							$args_to_merge[ $reference ] = urlencode($value);
3653
+						}
3654
+					}
3655
+					continue;
3656
+				}
3657
+				$args_to_merge[ $query_param ] = $query_value;
3658
+			}
3659
+			// now let's merge these arguments but override with what was specifically sent in to the
3660
+			// redirect.
3661
+			$query_args = array_merge($args_to_merge, $query_args);
3662
+		}
3663
+		$this->_process_notices($query_args);
3664
+		// generate redirect url
3665
+		// if redirecting to anything other than the main page, add a nonce
3666
+		if (isset($query_args['action'])) {
3667
+			// manually generate wp_nonce and merge that with the query vars
3668
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3669
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3670
+		}
3671
+		// we're adding some hooks and filters in here for processing any things just before redirects
3672
+		// (example: an admin page has done an insert or update and we want to run something after that).
3673
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3674
+		$redirect_url = apply_filters(
3675
+			'FHEE_redirect_' . $classname . $this->_req_action,
3676
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3677
+			$query_args
3678
+		);
3679
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3680
+		if ($this->request->isAjax()) {
3681
+			$default_data                    = [
3682
+				'close'        => true,
3683
+				'redirect_url' => $redirect_url,
3684
+				'where'        => 'main',
3685
+				'what'         => 'append',
3686
+			];
3687
+			$this->_template_args['success'] = $success;
3688
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3689
+				$default_data,
3690
+				$this->_template_args['data']
3691
+			) : $default_data;
3692
+			$this->_return_json();
3693
+		}
3694
+		wp_safe_redirect($redirect_url);
3695
+		exit();
3696
+	}
3697
+
3698
+
3699
+	/**
3700
+	 * process any notices before redirecting (or returning ajax request)
3701
+	 * This method sets the $this->_template_args['notices'] attribute;
3702
+	 *
3703
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3704
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3705
+	 *                                  page_routes haven't been defined yet.
3706
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3707
+	 *                                  still save a transient for the notice.
3708
+	 * @return void
3709
+	 * @throws EE_Error
3710
+	 * @throws InvalidArgumentException
3711
+	 * @throws InvalidDataTypeException
3712
+	 * @throws InvalidInterfaceException
3713
+	 */
3714
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3715
+	{
3716
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3717
+		if ($this->request->isAjax()) {
3718
+			$notices = EE_Error::get_notices(false);
3719
+			if (empty($this->_template_args['success'])) {
3720
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3721
+			}
3722
+			if (empty($this->_template_args['errors'])) {
3723
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3724
+			}
3725
+			if (empty($this->_template_args['attention'])) {
3726
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3727
+			}
3728
+		}
3729
+		$this->_template_args['notices'] = EE_Error::get_notices();
3730
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3731
+		if (! $this->request->isAjax() || $sticky_notices) {
3732
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3733
+			$this->_add_transient(
3734
+				$route,
3735
+				$this->_template_args['notices'],
3736
+				true,
3737
+				$skip_route_verify
3738
+			);
3739
+		}
3740
+	}
3741
+
3742
+
3743
+	/**
3744
+	 * get_action_link_or_button
3745
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3746
+	 *
3747
+	 * @param string $action        use this to indicate which action the url is generated with.
3748
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3749
+	 *                              property.
3750
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3751
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3752
+	 * @param string $base_url      If this is not provided
3753
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3754
+	 *                              Otherwise this value will be used.
3755
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3756
+	 * @return string
3757
+	 * @throws InvalidArgumentException
3758
+	 * @throws InvalidInterfaceException
3759
+	 * @throws InvalidDataTypeException
3760
+	 * @throws EE_Error
3761
+	 */
3762
+	public function get_action_link_or_button(
3763
+		$action,
3764
+		$type = 'add',
3765
+		$extra_request = [],
3766
+		$class = 'button--primary',
3767
+		$base_url = '',
3768
+		$exclude_nonce = false
3769
+	) {
3770
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3771
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3772
+			throw new EE_Error(
3773
+				sprintf(
3774
+					esc_html__(
3775
+						'There is no page route for given action for the button.  This action was given: %s',
3776
+						'event_espresso'
3777
+					),
3778
+					$action
3779
+				)
3780
+			);
3781
+		}
3782
+		if (! isset($this->_labels['buttons'][ $type ])) {
3783
+			throw new EE_Error(
3784
+				sprintf(
3785
+					esc_html__(
3786
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3787
+						'event_espresso'
3788
+					),
3789
+					$type
3790
+				)
3791
+			);
3792
+		}
3793
+		// finally check user access for this button.
3794
+		$has_access = $this->check_user_access($action, true);
3795
+		if (! $has_access) {
3796
+			return '';
3797
+		}
3798
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3799
+		$query_args = [
3800
+			'action' => $action,
3801
+		];
3802
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3803
+		if (! empty($extra_request)) {
3804
+			$query_args = array_merge($extra_request, $query_args);
3805
+		}
3806
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3807
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3808
+	}
3809
+
3810
+
3811
+	/**
3812
+	 * _per_page_screen_option
3813
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3814
+	 *
3815
+	 * @return void
3816
+	 * @throws InvalidArgumentException
3817
+	 * @throws InvalidInterfaceException
3818
+	 * @throws InvalidDataTypeException
3819
+	 */
3820
+	protected function _per_page_screen_option()
3821
+	{
3822
+		$option = 'per_page';
3823
+		$args   = [
3824
+			'label'   => apply_filters(
3825
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3826
+				$this->_admin_page_title,
3827
+				$this
3828
+			),
3829
+			'default' => (int) apply_filters(
3830
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3831
+				20
3832
+			),
3833
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3834
+		];
3835
+		// ONLY add the screen option if the user has access to it.
3836
+		if ($this->check_user_access($this->_current_view, true)) {
3837
+			add_screen_option($option, $args);
3838
+		}
3839
+	}
3840
+
3841
+
3842
+	/**
3843
+	 * set_per_page_screen_option
3844
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3845
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3846
+	 * admin_menu.
3847
+	 *
3848
+	 * @return void
3849
+	 */
3850
+	private function _set_per_page_screen_options()
3851
+	{
3852
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3853
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3854
+			if (! $user = wp_get_current_user()) {
3855
+				return;
3856
+			}
3857
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3858
+			if (! $option) {
3859
+				return;
3860
+			}
3861
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3862
+			$map_option = $option;
3863
+			$option     = str_replace('-', '_', $option);
3864
+			switch ($map_option) {
3865
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3866
+					$max_value = apply_filters(
3867
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3868
+						999,
3869
+						$this->_current_page,
3870
+						$this->_current_view
3871
+					);
3872
+					if ($value < 1) {
3873
+						return;
3874
+					}
3875
+					$value = min($value, $max_value);
3876
+					break;
3877
+				default:
3878
+					$value = apply_filters(
3879
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3880
+						false,
3881
+						$option,
3882
+						$value
3883
+					);
3884
+					if (false === $value) {
3885
+						return;
3886
+					}
3887
+					break;
3888
+			}
3889
+			update_user_meta($user->ID, $option, $value);
3890
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3891
+			exit;
3892
+		}
3893
+	}
3894
+
3895
+
3896
+	/**
3897
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3898
+	 *
3899
+	 * @param array $data array that will be assigned to template args.
3900
+	 */
3901
+	public function set_template_args($data)
3902
+	{
3903
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3904
+	}
3905
+
3906
+
3907
+	/**
3908
+	 * This makes available the WP transient system for temporarily moving data between routes
3909
+	 *
3910
+	 * @param string $route             the route that should receive the transient
3911
+	 * @param array  $data              the data that gets sent
3912
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3913
+	 *                                  normal route transient.
3914
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3915
+	 *                                  when we are adding a transient before page_routes have been defined.
3916
+	 * @return void
3917
+	 * @throws EE_Error
3918
+	 */
3919
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3920
+	{
3921
+		$user_id = get_current_user_id();
3922
+		if (! $skip_route_verify) {
3923
+			$this->_verify_route($route);
3924
+		}
3925
+		// now let's set the string for what kind of transient we're setting
3926
+		$transient = $notices
3927
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3928
+			: 'rte_tx_' . $route . '_' . $user_id;
3929
+		$data      = $notices ? ['notices' => $data] : $data;
3930
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3931
+		$existing = is_multisite() && is_network_admin()
3932
+			? get_site_transient($transient)
3933
+			: get_transient($transient);
3934
+		if ($existing) {
3935
+			$data = array_merge((array) $data, (array) $existing);
3936
+		}
3937
+		if (is_multisite() && is_network_admin()) {
3938
+			set_site_transient($transient, $data, 8);
3939
+		} else {
3940
+			set_transient($transient, $data, 8);
3941
+		}
3942
+	}
3943
+
3944
+
3945
+	/**
3946
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3947
+	 *
3948
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3949
+	 * @param string $route
3950
+	 * @return mixed data
3951
+	 */
3952
+	protected function _get_transient($notices = false, $route = '')
3953
+	{
3954
+		$user_id   = get_current_user_id();
3955
+		$route     = ! $route ? $this->_req_action : $route;
3956
+		$transient = $notices
3957
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3958
+			: 'rte_tx_' . $route . '_' . $user_id;
3959
+		$data      = is_multisite() && is_network_admin()
3960
+			? get_site_transient($transient)
3961
+			: get_transient($transient);
3962
+		// delete transient after retrieval (just in case it hasn't expired);
3963
+		if (is_multisite() && is_network_admin()) {
3964
+			delete_site_transient($transient);
3965
+		} else {
3966
+			delete_transient($transient);
3967
+		}
3968
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3969
+	}
3970
+
3971
+
3972
+	/**
3973
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3974
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3975
+	 * default route callback on the EE_Admin page you want it run.)
3976
+	 *
3977
+	 * @return void
3978
+	 */
3979
+	protected function _transient_garbage_collection()
3980
+	{
3981
+		global $wpdb;
3982
+		// retrieve all existing transients
3983
+		$query =
3984
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3985
+		if ($results = $wpdb->get_results($query)) {
3986
+			foreach ($results as $result) {
3987
+				$transient = str_replace('_transient_', '', $result->option_name);
3988
+				get_transient($transient);
3989
+				if (is_multisite() && is_network_admin()) {
3990
+					get_site_transient($transient);
3991
+				}
3992
+			}
3993
+		}
3994
+	}
3995
+
3996
+
3997
+	/**
3998
+	 * get_view
3999
+	 *
4000
+	 * @return string content of _view property
4001
+	 */
4002
+	public function get_view()
4003
+	{
4004
+		return $this->_view;
4005
+	}
4006
+
4007
+
4008
+	/**
4009
+	 * getter for the protected $_views property
4010
+	 *
4011
+	 * @return array
4012
+	 */
4013
+	public function get_views()
4014
+	{
4015
+		return $this->_views;
4016
+	}
4017
+
4018
+
4019
+	/**
4020
+	 * get_current_page
4021
+	 *
4022
+	 * @return string _current_page property value
4023
+	 */
4024
+	public function get_current_page()
4025
+	{
4026
+		return $this->_current_page;
4027
+	}
4028
+
4029
+
4030
+	/**
4031
+	 * get_current_view
4032
+	 *
4033
+	 * @return string _current_view property value
4034
+	 */
4035
+	public function get_current_view()
4036
+	{
4037
+		return $this->_current_view;
4038
+	}
4039
+
4040
+
4041
+	/**
4042
+	 * get_current_screen
4043
+	 *
4044
+	 * @return object The current WP_Screen object
4045
+	 */
4046
+	public function get_current_screen()
4047
+	{
4048
+		return $this->_current_screen;
4049
+	}
4050
+
4051
+
4052
+	/**
4053
+	 * get_current_page_view_url
4054
+	 *
4055
+	 * @return string This returns the url for the current_page_view.
4056
+	 */
4057
+	public function get_current_page_view_url()
4058
+	{
4059
+		return $this->_current_page_view_url;
4060
+	}
4061
+
4062
+
4063
+	/**
4064
+	 * just returns the Request
4065
+	 *
4066
+	 * @return RequestInterface
4067
+	 */
4068
+	public function get_request()
4069
+	{
4070
+		return $this->request;
4071
+	}
4072
+
4073
+
4074
+	/**
4075
+	 * just returns the _req_data property
4076
+	 *
4077
+	 * @return array
4078
+	 */
4079
+	public function get_request_data()
4080
+	{
4081
+		return $this->request->requestParams();
4082
+	}
4083
+
4084
+
4085
+	/**
4086
+	 * returns the _req_data protected property
4087
+	 *
4088
+	 * @return string
4089
+	 */
4090
+	public function get_req_action()
4091
+	{
4092
+		return $this->_req_action;
4093
+	}
4094
+
4095
+
4096
+	/**
4097
+	 * @return bool  value of $_is_caf property
4098
+	 */
4099
+	public function is_caf()
4100
+	{
4101
+		return $this->_is_caf;
4102
+	}
4103
+
4104
+
4105
+	/**
4106
+	 * @return mixed
4107
+	 */
4108
+	public function default_espresso_metaboxes()
4109
+	{
4110
+		return $this->_default_espresso_metaboxes;
4111
+	}
4112
+
4113
+
4114
+	/**
4115
+	 * @return mixed
4116
+	 */
4117
+	public function admin_base_url()
4118
+	{
4119
+		return $this->_admin_base_url;
4120
+	}
4121
+
4122
+
4123
+	/**
4124
+	 * @return mixed
4125
+	 */
4126
+	public function wp_page_slug()
4127
+	{
4128
+		return $this->_wp_page_slug;
4129
+	}
4130
+
4131
+
4132
+	/**
4133
+	 * updates  espresso configuration settings
4134
+	 *
4135
+	 * @param string                   $tab
4136
+	 * @param EE_Config_Base|EE_Config $config
4137
+	 * @param string                   $file file where error occurred
4138
+	 * @param string                   $func function  where error occurred
4139
+	 * @param string                   $line line no where error occurred
4140
+	 * @return boolean
4141
+	 */
4142
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4143
+	{
4144
+		// remove any options that are NOT going to be saved with the config settings.
4145
+		if (isset($config->core->ee_ueip_optin)) {
4146
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4147
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4148
+			update_option('ee_ueip_has_notified', true);
4149
+		}
4150
+		// and save it (note we're also doing the network save here)
4151
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4152
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4153
+		if ($config_saved && $net_saved) {
4154
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4155
+			return true;
4156
+		}
4157
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4158
+		return false;
4159
+	}
4160
+
4161
+
4162
+	/**
4163
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4164
+	 *
4165
+	 * @return array
4166
+	 */
4167
+	public function get_yes_no_values()
4168
+	{
4169
+		return $this->_yes_no_values;
4170
+	}
4171
+
4172
+
4173
+	/**
4174
+	 * @return string
4175
+	 * @throws ReflectionException
4176
+	 * @since $VID:$
4177
+	 */
4178
+	protected function _get_dir()
4179
+	{
4180
+		$reflector = new ReflectionClass(get_class($this));
4181
+		return dirname($reflector->getFileName());
4182
+	}
4183
+
4184
+
4185
+	/**
4186
+	 * A helper for getting a "next link".
4187
+	 *
4188
+	 * @param string $url   The url to link to
4189
+	 * @param string $class The class to use.
4190
+	 * @return string
4191
+	 */
4192
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4193
+	{
4194
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4195
+	}
4196
+
4197
+
4198
+	/**
4199
+	 * A helper for getting a "previous link".
4200
+	 *
4201
+	 * @param string $url   The url to link to
4202
+	 * @param string $class The class to use.
4203
+	 * @return string
4204
+	 */
4205
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4206
+	{
4207
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4208
+	}
4209
+
4210
+
4211
+
4212
+
4213
+
4214
+
4215
+
4216
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4217
+
4218
+
4219
+	/**
4220
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4221
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4222
+	 * _req_data array.
4223
+	 *
4224
+	 * @return bool success/fail
4225
+	 * @throws EE_Error
4226
+	 * @throws InvalidArgumentException
4227
+	 * @throws ReflectionException
4228
+	 * @throws InvalidDataTypeException
4229
+	 * @throws InvalidInterfaceException
4230
+	 */
4231
+	protected function _process_resend_registration()
4232
+	{
4233
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4234
+		do_action(
4235
+			'AHEE__EE_Admin_Page___process_resend_registration',
4236
+			$this->_template_args['success'],
4237
+			$this->request->requestParams()
4238
+		);
4239
+		return $this->_template_args['success'];
4240
+	}
4241
+
4242
+
4243
+	/**
4244
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4245
+	 *
4246
+	 * @param EE_Payment $payment
4247
+	 * @return bool success/fail
4248
+	 */
4249
+	protected function _process_payment_notification(EE_Payment $payment)
4250
+	{
4251
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4252
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4253
+		$this->_template_args['success'] = apply_filters(
4254
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4255
+			false,
4256
+			$payment
4257
+		);
4258
+		return $this->_template_args['success'];
4259
+	}
4260 4260
 }
Please login to merge, or discard this patch.