Completed
Branch CAFEREL (7412f0)
by
unknown
07:13 queued 04:01
created
core/db_classes/EE_Venue.class.php 1 patch
Indentation   +670 added lines, -670 removed lines patch added patch discarded remove patch
@@ -13,674 +13,674 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Venue extends EE_CPT_Base implements AddressInterface
15 15
 {
16
-    /**
17
-     * @param array  $props_n_values          incoming values
18
-     * @param string|null $timezone           incoming timezone (if not set the timezone set for the website
19
-     *                                        will be
20
-     *                                        used.)
21
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
22
-     *                                        date_format and the second value is the time format
23
-     * @return EE_Venue
24
-     * @throws EE_Error
25
-     * @throws ReflectionException
26
-     */
27
-    public static function new_instance(
28
-        array $props_n_values = [],
29
-        ?string $timezone = '',
30
-        array $date_formats = []
31
-    ): EE_Venue {
32
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
33
-        return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
34
-    }
35
-
36
-
37
-    /**
38
-     * @param array  $props_n_values  incoming values from the database
39
-     * @param string|null $timezone   incoming timezone as set by the model.
40
-     *                                If not set the timezone for the website will be used.
41
-     * @return EE_Venue
42
-     * @throws EE_Error
43
-     * @throws ReflectionException
44
-     */
45
-    public static function new_instance_from_db(array $props_n_values = [], ?string $timezone = ''): EE_Venue
46
-    {
47
-        return new self($props_n_values, true, $timezone);
48
-    }
49
-
50
-
51
-    /**
52
-     * Gets name
53
-     *
54
-     * @return string
55
-     * @throws EE_Error
56
-     * @throws ReflectionException
57
-     */
58
-    public function name(): string
59
-    {
60
-        return (string) $this->get('VNU_name');
61
-    }
62
-
63
-
64
-    /**
65
-     * Gets phone
66
-     *
67
-     * @return string
68
-     * @throws EE_Error
69
-     * @throws ReflectionException
70
-     */
71
-    public function phone(): string
72
-    {
73
-        return (string) $this->get('VNU_phone');
74
-    }
75
-
76
-
77
-    /**
78
-     * venue_url
79
-     *
80
-     * @return string
81
-     * @throws EE_Error
82
-     * @throws ReflectionException
83
-     */
84
-    public function venue_url(): string
85
-    {
86
-        return (string) $this->get('VNU_url');
87
-    }
88
-
89
-
90
-    /**
91
-     * Gets desc
92
-     *
93
-     * @return string
94
-     * @throws EE_Error
95
-     * @throws ReflectionException
96
-     */
97
-    public function description(): string
98
-    {
99
-        return (string) $this->get('VNU_desc');
100
-    }
101
-
102
-
103
-    /**
104
-     * Gets short description (AKA: the excerpt)
105
-     *
106
-     * @return string
107
-     * @throws EE_Error
108
-     * @throws ReflectionException
109
-     */
110
-    public function excerpt(): string
111
-    {
112
-        return (string) $this->get('VNU_short_desc');
113
-    }
114
-
115
-
116
-    /**
117
-     * Gets identifier
118
-     *
119
-     * @return string
120
-     * @throws EE_Error
121
-     * @throws ReflectionException
122
-     */
123
-    public function identifier(): string
124
-    {
125
-        return (string) $this->get('VNU_identifier');
126
-    }
127
-
128
-
129
-    /**
130
-     * Gets address
131
-     *
132
-     * @return string
133
-     * @throws EE_Error
134
-     * @throws ReflectionException
135
-     */
136
-    public function address(): string
137
-    {
138
-        return (string) $this->get('VNU_address');
139
-    }
140
-
141
-
142
-    /**
143
-     * Gets address2
144
-     *
145
-     * @return string
146
-     * @throws EE_Error
147
-     * @throws ReflectionException
148
-     */
149
-    public function address2(): string
150
-    {
151
-        return (string) $this->get('VNU_address2');
152
-    }
153
-
154
-
155
-    /**
156
-     * Gets city
157
-     *
158
-     * @return string
159
-     * @throws EE_Error
160
-     * @throws ReflectionException
161
-     */
162
-    public function city(): string
163
-    {
164
-        return (string) $this->get('VNU_city');
165
-    }
166
-
167
-
168
-    /**
169
-     * Gets state
170
-     *
171
-     * @return int
172
-     * @throws EE_Error
173
-     * @throws ReflectionException
174
-     */
175
-    public function state_ID(): int
176
-    {
177
-        return (int) $this->get('STA_ID');
178
-    }
179
-
180
-
181
-    /**
182
-     * @return string
183
-     * @throws EE_Error
184
-     * @throws ReflectionException
185
-     */
186
-    public function state_abbrev(): string
187
-    {
188
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
189
-    }
190
-
191
-
192
-    /**
193
-     * @return string
194
-     * @throws EE_Error
195
-     * @throws ReflectionException
196
-     */
197
-    public function state_name(): string
198
-    {
199
-        return $this->state_obj() instanceof EE_State
200
-            ? (string) $this->state_obj()->name()
201
-            : '';
202
-    }
203
-
204
-
205
-    /**
206
-     * Gets the state for this venue
207
-     *
208
-     * @return EE_State|null
209
-     * @throws EE_Error
210
-     * @throws ReflectionException
211
-     */
212
-    public function state_obj(): ?EE_State
213
-    {
214
-        return $this->get_first_related('State');
215
-    }
216
-
217
-
218
-    /**
219
-     * either displays the state abbreviation or the state name, as determined
220
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
221
-     * defaults to abbreviation
222
-     *
223
-     * @return string
224
-     * @throws EE_Error
225
-     * @throws ReflectionException
226
-     */
227
-    public function state(): string
228
-    {
229
-        return apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())
230
-            ? $this->state_abbrev()
231
-            : $this->state_name();
232
-    }
233
-
234
-
235
-    /**
236
-     * country_ID
237
-     *
238
-     * @return string
239
-     * @throws EE_Error
240
-     * @throws ReflectionException
241
-     */
242
-    public function country_ID(): string
243
-    {
244
-        return (string) $this->get('CNT_ISO');
245
-    }
246
-
247
-
248
-    /**
249
-     * @return string
250
-     * @throws EE_Error
251
-     * @throws ReflectionException
252
-     */
253
-    public function country_name(): string
254
-    {
255
-        return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
256
-    }
257
-
258
-
259
-    /**
260
-     * Gets the country of this venue
261
-     *
262
-     * @return EE_Country|null
263
-     * @throws EE_Error
264
-     * @throws ReflectionException
265
-     */
266
-    public function country_obj(): ?EE_Country
267
-    {
268
-        return $this->get_first_related('Country');
269
-    }
270
-
271
-
272
-    /**
273
-     * either displays the country ISO2 code or the country name, as determined
274
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
275
-     * defaults to abbreviation
276
-     *
277
-     * @return string
278
-     * @throws EE_Error
279
-     * @throws ReflectionException
280
-     */
281
-    public function country(): string
282
-    {
283
-        return apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())
284
-            ? $this->country_ID()
285
-            : $this->country_name();
286
-    }
287
-
288
-
289
-    /**
290
-     * Gets zip
291
-     *
292
-     * @return string
293
-     * @throws EE_Error
294
-     * @throws ReflectionException
295
-     */
296
-    public function zip(): string
297
-    {
298
-        return $this->get('VNU_zip');
299
-    }
300
-
301
-
302
-    /**
303
-     * Gets capacity
304
-     *
305
-     * @return int|string
306
-     * @throws EE_Error
307
-     * @throws ReflectionException
308
-     */
309
-    public function capacity()
310
-    {
311
-        return $this->get_pretty('VNU_capacity', 'symbol');
312
-    }
313
-
314
-
315
-    /**
316
-     * Gets created
317
-     *
318
-     * @return string
319
-     * @throws EE_Error
320
-     * @throws ReflectionException
321
-     */
322
-    public function created(): string
323
-    {
324
-        return (string) $this->get('VNU_created');
325
-    }
326
-
327
-
328
-    /**
329
-     * Gets modified
330
-     *
331
-     * @return string
332
-     * @throws EE_Error
333
-     * @throws ReflectionException
334
-     */
335
-    public function modified(): string
336
-    {
337
-        return (string) $this->get('VNU_modified');
338
-    }
339
-
340
-
341
-    /**
342
-     * Gets order
343
-     *
344
-     * @return int
345
-     * @throws EE_Error
346
-     * @throws ReflectionException
347
-     */
348
-    public function order(): int
349
-    {
350
-        return (int) $this->get('VNU_order');
351
-    }
352
-
353
-
354
-    /**
355
-     * Gets wp_user
356
-     *
357
-     * @return int
358
-     * @throws EE_Error
359
-     * @throws ReflectionException
360
-     */
361
-    public function wp_user(): int
362
-    {
363
-        return (int) $this->get('VNU_wp_user');
364
-    }
365
-
366
-
367
-    /**
368
-     * @return string
369
-     * @throws EE_Error
370
-     * @throws ReflectionException
371
-     */
372
-    public function virtual_phone(): string
373
-    {
374
-        return (string) $this->get('VNU_virtual_phone');
375
-    }
376
-
377
-
378
-    /**
379
-     * @return string
380
-     * @throws EE_Error
381
-     * @throws ReflectionException
382
-     */
383
-    public function virtual_url(): string
384
-    {
385
-        return (string) $this->get('VNU_virtual_url');
386
-    }
387
-
388
-
389
-    /**
390
-     * @return bool
391
-     * @throws EE_Error
392
-     * @throws ReflectionException
393
-     */
394
-    public function enable_for_gmap(): bool
395
-    {
396
-        return (bool) $this->get('VNU_enable_for_gmap');
397
-    }
398
-
399
-
400
-    /**
401
-     * @return string
402
-     * @throws EE_Error
403
-     * @throws ReflectionException
404
-     */
405
-    public function google_map_link(): string
406
-    {
407
-        return (string) $this->get('VNU_google_map_link');
408
-    }
409
-
410
-
411
-    /**
412
-     * Gets all events happening at this venue. Query parameters can be added to
413
-     * fetch a subset of those events.
414
-     *
415
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
416
-     * @param bool  $upcoming
417
-     * @return EE_Event[]
418
-     * @throws EE_Error
419
-     * @throws ReflectionException
420
-     */
421
-    public function events(array $query_params = array(), bool $upcoming = false): array
422
-    {
423
-        if ($upcoming) {
424
-            $query_params = array(
425
-                array(
426
-                    'status'                 => 'publish',
427
-                    'Datetime.DTT_EVT_start' => array(
428
-                        '>',
429
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
430
-                    ),
431
-                ),
432
-            );
433
-        }
434
-        return $this->get_many_related('Event', $query_params);
435
-    }
436
-
437
-
438
-    /**
439
-     * Sets address
440
-     *
441
-     * @param string $address
442
-     * @throws EE_Error
443
-     * @throws ReflectionException
444
-     */
445
-    public function set_address(string $address = '')
446
-    {
447
-        $this->set('VNU_address', $address);
448
-    }
449
-
450
-
451
-    /**
452
-     * @param string $address2
453
-     * @throws EE_Error
454
-     * @throws ReflectionException
455
-     */
456
-    public function set_address2(string $address2 = '')
457
-    {
458
-        $this->set('VNU_address2', $address2);
459
-    }
460
-
461
-
462
-    /**
463
-     * @param string $city
464
-     * @throws EE_Error
465
-     * @throws ReflectionException
466
-     */
467
-    public function set_city(string $city = '')
468
-    {
469
-        $this->set('VNU_city', $city);
470
-    }
471
-
472
-
473
-    /**
474
-     * @param int $state
475
-     * @throws EE_Error
476
-     * @throws ReflectionException
477
-     */
478
-    public function set_state_ID(int $state = 0)
479
-    {
480
-        $this->set('STA_ID', $state);
481
-    }
482
-
483
-
484
-    /**
485
-     * Sets the state, given either a state id or state object
486
-     *
487
-     * @param EE_State|int $state_id_or_obj
488
-     * @return EE_State
489
-     * @throws EE_Error
490
-     * @throws ReflectionException
491
-     */
492
-    public function set_state_obj($state_id_or_obj): EE_State
493
-    {
494
-        return $this->_add_relation_to($state_id_or_obj, 'State');
495
-    }
496
-
497
-
498
-    /**
499
-     * @param string $country_ID
500
-     * @throws EE_Error
501
-     * @throws ReflectionException
502
-     */
503
-    public function set_country_ID(string $country_ID = '')
504
-    {
505
-        $this->set('CNT_ISO', $country_ID);
506
-    }
507
-
508
-
509
-    /**
510
-     * Sets the country on the venue
511
-     *
512
-     * @param EE_Country|string $country_id_or_obj
513
-     * @return EE_Country
514
-     * @throws EE_Error
515
-     * @throws ReflectionException
516
-     */
517
-    public function set_country_obj($country_id_or_obj): EE_Country
518
-    {
519
-        return $this->_add_relation_to($country_id_or_obj, 'Country');
520
-    }
521
-
522
-
523
-    /**
524
-     * @param string $zip
525
-     * @throws EE_Error
526
-     * @throws ReflectionException
527
-     */
528
-    public function set_zip(string $zip = '')
529
-    {
530
-        $this->set('VNU_zip', $zip);
531
-    }
532
-
533
-
534
-    /**
535
-     * @param int $capacity
536
-     * @throws EE_Error
537
-     * @throws ReflectionException
538
-     */
539
-    public function set_capacity(int $capacity = 0)
540
-    {
541
-        $this->set('VNU_capacity', $capacity);
542
-    }
543
-
544
-
545
-    /**
546
-     * @param string $created
547
-     * @throws EE_Error
548
-     * @throws ReflectionException
549
-     */
550
-    public function set_created(string $created = '')
551
-    {
552
-        $this->set('VNU_created', $created);
553
-    }
554
-
555
-
556
-    /**
557
-     * @param string $desc
558
-     * @throws EE_Error
559
-     * @throws ReflectionException
560
-     */
561
-    public function set_description(string $desc = '')
562
-    {
563
-        $this->set('VNU_desc', $desc);
564
-    }
565
-
566
-
567
-    /**
568
-     * @param string $identifier
569
-     * @throws EE_Error
570
-     * @throws ReflectionException
571
-     */
572
-    public function set_identifier(string $identifier = '')
573
-    {
574
-        $this->set('VNU_identifier', $identifier);
575
-    }
576
-
577
-
578
-    /**
579
-     * @param string $modified
580
-     * @throws EE_Error
581
-     * @throws ReflectionException
582
-     */
583
-    public function set_modified(string $modified = '')
584
-    {
585
-        $this->set('VNU_modified', $modified);
586
-    }
587
-
588
-
589
-    /**
590
-     * @param string $name
591
-     * @throws EE_Error
592
-     * @throws ReflectionException
593
-     */
594
-    public function set_name(string $name = '')
595
-    {
596
-        $this->set('VNU_name', $name);
597
-    }
598
-
599
-
600
-    /**
601
-     * @param int $order
602
-     * @throws EE_Error
603
-     * @throws ReflectionException
604
-     */
605
-    public function set_order(int $order = 0)
606
-    {
607
-        $this->set('VNU_order', $order);
608
-    }
609
-
610
-
611
-    /**
612
-     * @param string $phone
613
-     * @throws EE_Error
614
-     * @throws ReflectionException
615
-     */
616
-    public function set_phone(string $phone = '')
617
-    {
618
-        $this->set('VNU_phone', $phone);
619
-    }
620
-
621
-
622
-    /**
623
-     * @param int $wp_user
624
-     * @throws EE_Error
625
-     * @throws ReflectionException
626
-     */
627
-    public function set_wp_user(int $wp_user = 1)
628
-    {
629
-        $this->set('VNU_wp_user', $wp_user);
630
-    }
631
-
632
-
633
-    /**
634
-     * @param string $url
635
-     * @throws EE_Error
636
-     * @throws ReflectionException
637
-     */
638
-    public function set_venue_url(string $url = '')
639
-    {
640
-        $this->set('VNU_url', $url);
641
-    }
642
-
643
-
644
-    /**
645
-     * @param string $phone
646
-     * @throws EE_Error
647
-     * @throws ReflectionException
648
-     */
649
-    public function set_virtual_phone(string $phone = '')
650
-    {
651
-        $this->set('VNU_virtual_phone', $phone);
652
-    }
653
-
654
-
655
-    /**
656
-     * @param string $url
657
-     * @throws EE_Error
658
-     * @throws ReflectionException
659
-     */
660
-    public function set_virtual_url(string $url = '')
661
-    {
662
-        $this->set('VNU_virtual_url', $url);
663
-    }
664
-
665
-
666
-    /**
667
-     * @param bool|int|string $enable
668
-     * @throws EE_Error
669
-     * @throws ReflectionException
670
-     */
671
-    public function set_enable_for_gmap($enable = false)
672
-    {
673
-        $this->set('VNU_enable_for_gmap', $enable);
674
-    }
675
-
676
-
677
-    /**
678
-     * @param string $google_map_link
679
-     * @throws EE_Error
680
-     * @throws ReflectionException
681
-     */
682
-    public function set_google_map_link(string $google_map_link = '')
683
-    {
684
-        $this->set('VNU_google_map_link', $google_map_link);
685
-    }
16
+	/**
17
+	 * @param array  $props_n_values          incoming values
18
+	 * @param string|null $timezone           incoming timezone (if not set the timezone set for the website
19
+	 *                                        will be
20
+	 *                                        used.)
21
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
22
+	 *                                        date_format and the second value is the time format
23
+	 * @return EE_Venue
24
+	 * @throws EE_Error
25
+	 * @throws ReflectionException
26
+	 */
27
+	public static function new_instance(
28
+		array $props_n_values = [],
29
+		?string $timezone = '',
30
+		array $date_formats = []
31
+	): EE_Venue {
32
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
33
+		return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
34
+	}
35
+
36
+
37
+	/**
38
+	 * @param array  $props_n_values  incoming values from the database
39
+	 * @param string|null $timezone   incoming timezone as set by the model.
40
+	 *                                If not set the timezone for the website will be used.
41
+	 * @return EE_Venue
42
+	 * @throws EE_Error
43
+	 * @throws ReflectionException
44
+	 */
45
+	public static function new_instance_from_db(array $props_n_values = [], ?string $timezone = ''): EE_Venue
46
+	{
47
+		return new self($props_n_values, true, $timezone);
48
+	}
49
+
50
+
51
+	/**
52
+	 * Gets name
53
+	 *
54
+	 * @return string
55
+	 * @throws EE_Error
56
+	 * @throws ReflectionException
57
+	 */
58
+	public function name(): string
59
+	{
60
+		return (string) $this->get('VNU_name');
61
+	}
62
+
63
+
64
+	/**
65
+	 * Gets phone
66
+	 *
67
+	 * @return string
68
+	 * @throws EE_Error
69
+	 * @throws ReflectionException
70
+	 */
71
+	public function phone(): string
72
+	{
73
+		return (string) $this->get('VNU_phone');
74
+	}
75
+
76
+
77
+	/**
78
+	 * venue_url
79
+	 *
80
+	 * @return string
81
+	 * @throws EE_Error
82
+	 * @throws ReflectionException
83
+	 */
84
+	public function venue_url(): string
85
+	{
86
+		return (string) $this->get('VNU_url');
87
+	}
88
+
89
+
90
+	/**
91
+	 * Gets desc
92
+	 *
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 * @throws ReflectionException
96
+	 */
97
+	public function description(): string
98
+	{
99
+		return (string) $this->get('VNU_desc');
100
+	}
101
+
102
+
103
+	/**
104
+	 * Gets short description (AKA: the excerpt)
105
+	 *
106
+	 * @return string
107
+	 * @throws EE_Error
108
+	 * @throws ReflectionException
109
+	 */
110
+	public function excerpt(): string
111
+	{
112
+		return (string) $this->get('VNU_short_desc');
113
+	}
114
+
115
+
116
+	/**
117
+	 * Gets identifier
118
+	 *
119
+	 * @return string
120
+	 * @throws EE_Error
121
+	 * @throws ReflectionException
122
+	 */
123
+	public function identifier(): string
124
+	{
125
+		return (string) $this->get('VNU_identifier');
126
+	}
127
+
128
+
129
+	/**
130
+	 * Gets address
131
+	 *
132
+	 * @return string
133
+	 * @throws EE_Error
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function address(): string
137
+	{
138
+		return (string) $this->get('VNU_address');
139
+	}
140
+
141
+
142
+	/**
143
+	 * Gets address2
144
+	 *
145
+	 * @return string
146
+	 * @throws EE_Error
147
+	 * @throws ReflectionException
148
+	 */
149
+	public function address2(): string
150
+	{
151
+		return (string) $this->get('VNU_address2');
152
+	}
153
+
154
+
155
+	/**
156
+	 * Gets city
157
+	 *
158
+	 * @return string
159
+	 * @throws EE_Error
160
+	 * @throws ReflectionException
161
+	 */
162
+	public function city(): string
163
+	{
164
+		return (string) $this->get('VNU_city');
165
+	}
166
+
167
+
168
+	/**
169
+	 * Gets state
170
+	 *
171
+	 * @return int
172
+	 * @throws EE_Error
173
+	 * @throws ReflectionException
174
+	 */
175
+	public function state_ID(): int
176
+	{
177
+		return (int) $this->get('STA_ID');
178
+	}
179
+
180
+
181
+	/**
182
+	 * @return string
183
+	 * @throws EE_Error
184
+	 * @throws ReflectionException
185
+	 */
186
+	public function state_abbrev(): string
187
+	{
188
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return string
194
+	 * @throws EE_Error
195
+	 * @throws ReflectionException
196
+	 */
197
+	public function state_name(): string
198
+	{
199
+		return $this->state_obj() instanceof EE_State
200
+			? (string) $this->state_obj()->name()
201
+			: '';
202
+	}
203
+
204
+
205
+	/**
206
+	 * Gets the state for this venue
207
+	 *
208
+	 * @return EE_State|null
209
+	 * @throws EE_Error
210
+	 * @throws ReflectionException
211
+	 */
212
+	public function state_obj(): ?EE_State
213
+	{
214
+		return $this->get_first_related('State');
215
+	}
216
+
217
+
218
+	/**
219
+	 * either displays the state abbreviation or the state name, as determined
220
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
221
+	 * defaults to abbreviation
222
+	 *
223
+	 * @return string
224
+	 * @throws EE_Error
225
+	 * @throws ReflectionException
226
+	 */
227
+	public function state(): string
228
+	{
229
+		return apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())
230
+			? $this->state_abbrev()
231
+			: $this->state_name();
232
+	}
233
+
234
+
235
+	/**
236
+	 * country_ID
237
+	 *
238
+	 * @return string
239
+	 * @throws EE_Error
240
+	 * @throws ReflectionException
241
+	 */
242
+	public function country_ID(): string
243
+	{
244
+		return (string) $this->get('CNT_ISO');
245
+	}
246
+
247
+
248
+	/**
249
+	 * @return string
250
+	 * @throws EE_Error
251
+	 * @throws ReflectionException
252
+	 */
253
+	public function country_name(): string
254
+	{
255
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
256
+	}
257
+
258
+
259
+	/**
260
+	 * Gets the country of this venue
261
+	 *
262
+	 * @return EE_Country|null
263
+	 * @throws EE_Error
264
+	 * @throws ReflectionException
265
+	 */
266
+	public function country_obj(): ?EE_Country
267
+	{
268
+		return $this->get_first_related('Country');
269
+	}
270
+
271
+
272
+	/**
273
+	 * either displays the country ISO2 code or the country name, as determined
274
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
275
+	 * defaults to abbreviation
276
+	 *
277
+	 * @return string
278
+	 * @throws EE_Error
279
+	 * @throws ReflectionException
280
+	 */
281
+	public function country(): string
282
+	{
283
+		return apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())
284
+			? $this->country_ID()
285
+			: $this->country_name();
286
+	}
287
+
288
+
289
+	/**
290
+	 * Gets zip
291
+	 *
292
+	 * @return string
293
+	 * @throws EE_Error
294
+	 * @throws ReflectionException
295
+	 */
296
+	public function zip(): string
297
+	{
298
+		return $this->get('VNU_zip');
299
+	}
300
+
301
+
302
+	/**
303
+	 * Gets capacity
304
+	 *
305
+	 * @return int|string
306
+	 * @throws EE_Error
307
+	 * @throws ReflectionException
308
+	 */
309
+	public function capacity()
310
+	{
311
+		return $this->get_pretty('VNU_capacity', 'symbol');
312
+	}
313
+
314
+
315
+	/**
316
+	 * Gets created
317
+	 *
318
+	 * @return string
319
+	 * @throws EE_Error
320
+	 * @throws ReflectionException
321
+	 */
322
+	public function created(): string
323
+	{
324
+		return (string) $this->get('VNU_created');
325
+	}
326
+
327
+
328
+	/**
329
+	 * Gets modified
330
+	 *
331
+	 * @return string
332
+	 * @throws EE_Error
333
+	 * @throws ReflectionException
334
+	 */
335
+	public function modified(): string
336
+	{
337
+		return (string) $this->get('VNU_modified');
338
+	}
339
+
340
+
341
+	/**
342
+	 * Gets order
343
+	 *
344
+	 * @return int
345
+	 * @throws EE_Error
346
+	 * @throws ReflectionException
347
+	 */
348
+	public function order(): int
349
+	{
350
+		return (int) $this->get('VNU_order');
351
+	}
352
+
353
+
354
+	/**
355
+	 * Gets wp_user
356
+	 *
357
+	 * @return int
358
+	 * @throws EE_Error
359
+	 * @throws ReflectionException
360
+	 */
361
+	public function wp_user(): int
362
+	{
363
+		return (int) $this->get('VNU_wp_user');
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return string
369
+	 * @throws EE_Error
370
+	 * @throws ReflectionException
371
+	 */
372
+	public function virtual_phone(): string
373
+	{
374
+		return (string) $this->get('VNU_virtual_phone');
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 * @throws ReflectionException
382
+	 */
383
+	public function virtual_url(): string
384
+	{
385
+		return (string) $this->get('VNU_virtual_url');
386
+	}
387
+
388
+
389
+	/**
390
+	 * @return bool
391
+	 * @throws EE_Error
392
+	 * @throws ReflectionException
393
+	 */
394
+	public function enable_for_gmap(): bool
395
+	{
396
+		return (bool) $this->get('VNU_enable_for_gmap');
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return string
402
+	 * @throws EE_Error
403
+	 * @throws ReflectionException
404
+	 */
405
+	public function google_map_link(): string
406
+	{
407
+		return (string) $this->get('VNU_google_map_link');
408
+	}
409
+
410
+
411
+	/**
412
+	 * Gets all events happening at this venue. Query parameters can be added to
413
+	 * fetch a subset of those events.
414
+	 *
415
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
416
+	 * @param bool  $upcoming
417
+	 * @return EE_Event[]
418
+	 * @throws EE_Error
419
+	 * @throws ReflectionException
420
+	 */
421
+	public function events(array $query_params = array(), bool $upcoming = false): array
422
+	{
423
+		if ($upcoming) {
424
+			$query_params = array(
425
+				array(
426
+					'status'                 => 'publish',
427
+					'Datetime.DTT_EVT_start' => array(
428
+						'>',
429
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
430
+					),
431
+				),
432
+			);
433
+		}
434
+		return $this->get_many_related('Event', $query_params);
435
+	}
436
+
437
+
438
+	/**
439
+	 * Sets address
440
+	 *
441
+	 * @param string $address
442
+	 * @throws EE_Error
443
+	 * @throws ReflectionException
444
+	 */
445
+	public function set_address(string $address = '')
446
+	{
447
+		$this->set('VNU_address', $address);
448
+	}
449
+
450
+
451
+	/**
452
+	 * @param string $address2
453
+	 * @throws EE_Error
454
+	 * @throws ReflectionException
455
+	 */
456
+	public function set_address2(string $address2 = '')
457
+	{
458
+		$this->set('VNU_address2', $address2);
459
+	}
460
+
461
+
462
+	/**
463
+	 * @param string $city
464
+	 * @throws EE_Error
465
+	 * @throws ReflectionException
466
+	 */
467
+	public function set_city(string $city = '')
468
+	{
469
+		$this->set('VNU_city', $city);
470
+	}
471
+
472
+
473
+	/**
474
+	 * @param int $state
475
+	 * @throws EE_Error
476
+	 * @throws ReflectionException
477
+	 */
478
+	public function set_state_ID(int $state = 0)
479
+	{
480
+		$this->set('STA_ID', $state);
481
+	}
482
+
483
+
484
+	/**
485
+	 * Sets the state, given either a state id or state object
486
+	 *
487
+	 * @param EE_State|int $state_id_or_obj
488
+	 * @return EE_State
489
+	 * @throws EE_Error
490
+	 * @throws ReflectionException
491
+	 */
492
+	public function set_state_obj($state_id_or_obj): EE_State
493
+	{
494
+		return $this->_add_relation_to($state_id_or_obj, 'State');
495
+	}
496
+
497
+
498
+	/**
499
+	 * @param string $country_ID
500
+	 * @throws EE_Error
501
+	 * @throws ReflectionException
502
+	 */
503
+	public function set_country_ID(string $country_ID = '')
504
+	{
505
+		$this->set('CNT_ISO', $country_ID);
506
+	}
507
+
508
+
509
+	/**
510
+	 * Sets the country on the venue
511
+	 *
512
+	 * @param EE_Country|string $country_id_or_obj
513
+	 * @return EE_Country
514
+	 * @throws EE_Error
515
+	 * @throws ReflectionException
516
+	 */
517
+	public function set_country_obj($country_id_or_obj): EE_Country
518
+	{
519
+		return $this->_add_relation_to($country_id_or_obj, 'Country');
520
+	}
521
+
522
+
523
+	/**
524
+	 * @param string $zip
525
+	 * @throws EE_Error
526
+	 * @throws ReflectionException
527
+	 */
528
+	public function set_zip(string $zip = '')
529
+	{
530
+		$this->set('VNU_zip', $zip);
531
+	}
532
+
533
+
534
+	/**
535
+	 * @param int $capacity
536
+	 * @throws EE_Error
537
+	 * @throws ReflectionException
538
+	 */
539
+	public function set_capacity(int $capacity = 0)
540
+	{
541
+		$this->set('VNU_capacity', $capacity);
542
+	}
543
+
544
+
545
+	/**
546
+	 * @param string $created
547
+	 * @throws EE_Error
548
+	 * @throws ReflectionException
549
+	 */
550
+	public function set_created(string $created = '')
551
+	{
552
+		$this->set('VNU_created', $created);
553
+	}
554
+
555
+
556
+	/**
557
+	 * @param string $desc
558
+	 * @throws EE_Error
559
+	 * @throws ReflectionException
560
+	 */
561
+	public function set_description(string $desc = '')
562
+	{
563
+		$this->set('VNU_desc', $desc);
564
+	}
565
+
566
+
567
+	/**
568
+	 * @param string $identifier
569
+	 * @throws EE_Error
570
+	 * @throws ReflectionException
571
+	 */
572
+	public function set_identifier(string $identifier = '')
573
+	{
574
+		$this->set('VNU_identifier', $identifier);
575
+	}
576
+
577
+
578
+	/**
579
+	 * @param string $modified
580
+	 * @throws EE_Error
581
+	 * @throws ReflectionException
582
+	 */
583
+	public function set_modified(string $modified = '')
584
+	{
585
+		$this->set('VNU_modified', $modified);
586
+	}
587
+
588
+
589
+	/**
590
+	 * @param string $name
591
+	 * @throws EE_Error
592
+	 * @throws ReflectionException
593
+	 */
594
+	public function set_name(string $name = '')
595
+	{
596
+		$this->set('VNU_name', $name);
597
+	}
598
+
599
+
600
+	/**
601
+	 * @param int $order
602
+	 * @throws EE_Error
603
+	 * @throws ReflectionException
604
+	 */
605
+	public function set_order(int $order = 0)
606
+	{
607
+		$this->set('VNU_order', $order);
608
+	}
609
+
610
+
611
+	/**
612
+	 * @param string $phone
613
+	 * @throws EE_Error
614
+	 * @throws ReflectionException
615
+	 */
616
+	public function set_phone(string $phone = '')
617
+	{
618
+		$this->set('VNU_phone', $phone);
619
+	}
620
+
621
+
622
+	/**
623
+	 * @param int $wp_user
624
+	 * @throws EE_Error
625
+	 * @throws ReflectionException
626
+	 */
627
+	public function set_wp_user(int $wp_user = 1)
628
+	{
629
+		$this->set('VNU_wp_user', $wp_user);
630
+	}
631
+
632
+
633
+	/**
634
+	 * @param string $url
635
+	 * @throws EE_Error
636
+	 * @throws ReflectionException
637
+	 */
638
+	public function set_venue_url(string $url = '')
639
+	{
640
+		$this->set('VNU_url', $url);
641
+	}
642
+
643
+
644
+	/**
645
+	 * @param string $phone
646
+	 * @throws EE_Error
647
+	 * @throws ReflectionException
648
+	 */
649
+	public function set_virtual_phone(string $phone = '')
650
+	{
651
+		$this->set('VNU_virtual_phone', $phone);
652
+	}
653
+
654
+
655
+	/**
656
+	 * @param string $url
657
+	 * @throws EE_Error
658
+	 * @throws ReflectionException
659
+	 */
660
+	public function set_virtual_url(string $url = '')
661
+	{
662
+		$this->set('VNU_virtual_url', $url);
663
+	}
664
+
665
+
666
+	/**
667
+	 * @param bool|int|string $enable
668
+	 * @throws EE_Error
669
+	 * @throws ReflectionException
670
+	 */
671
+	public function set_enable_for_gmap($enable = false)
672
+	{
673
+		$this->set('VNU_enable_for_gmap', $enable);
674
+	}
675
+
676
+
677
+	/**
678
+	 * @param string $google_map_link
679
+	 * @throws EE_Error
680
+	 * @throws ReflectionException
681
+	 */
682
+	public function set_google_map_link(string $google_map_link = '')
683
+	{
684
+		$this->set('VNU_google_map_link', $google_map_link);
685
+	}
686 686
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -37,120 +37,120 @@
 block discarded – undo
37 37
  * @since           4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time.
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time.
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
             <div class="error">
49 49
                 <p>
50 50
                     <?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
                 </p>
56 56
             </div>
57 57
             <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
             <div class="error">
74 74
                 <p>
75 75
                     <?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
85
-                    );
86
-                    ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
85
+					);
86
+					?>
87 87
                 </p>
88 88
             </div>
89 89
             <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96 96
 
97
-        require_once __DIR__ . '/vendor/autoload.php';
98
-        require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
97
+		require_once __DIR__ . '/vendor/autoload.php';
98
+		require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
99 99
 
100
-        /**
101
-         * espresso_version
102
-         * Returns the plugin version
103
-         *
104
-         * @return string
105
-         */
106
-        function espresso_version()
107
-        {
108
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.0.rc.009');
109
-        }
100
+		/**
101
+		 * espresso_version
102
+		 * Returns the plugin version
103
+		 *
104
+		 * @return string
105
+		 */
106
+		function espresso_version()
107
+		{
108
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.0.rc.009');
109
+		}
110 110
 
111
-        /**
112
-         * espresso_plugin_activation
113
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
114
-         */
115
-        function espresso_plugin_activation()
116
-        {
117
-            update_option('ee_espresso_activation', true);
118
-            // Run WP GraphQL activation callback
119
-            graphql_activation_callback();
120
-        }
111
+		/**
112
+		 * espresso_plugin_activation
113
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
114
+		 */
115
+		function espresso_plugin_activation()
116
+		{
117
+			update_option('ee_espresso_activation', true);
118
+			// Run WP GraphQL activation callback
119
+			graphql_activation_callback();
120
+		}
121 121
 
122
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
122
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
123 123
 
124
-        /**
125
-         * espresso_plugin_deactivation
126
-         */
127
-        function espresso_plugin_deactivation()
128
-        {
129
-            // Run WP GraphQL deactivation callback
130
-            graphql_deactivation_callback();
131
-        }
132
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
124
+		/**
125
+		 * espresso_plugin_deactivation
126
+		 */
127
+		function espresso_plugin_deactivation()
128
+		{
129
+			// Run WP GraphQL deactivation callback
130
+			graphql_deactivation_callback();
131
+		}
132
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
133 133
 
134
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
135
-        bootstrap_espresso();
136
-    }
134
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
135
+		bootstrap_espresso();
136
+	}
137 137
 }
138 138
 
139 139
 if (! function_exists('espresso_deactivate_plugin')) {
140
-    /**
141
-     *    deactivate_plugin
142
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
143
-     *
144
-     * @access public
145
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
146
-     * @return    void
147
-     */
148
-    function espresso_deactivate_plugin($plugin_basename = '')
149
-    {
150
-        if (! function_exists('deactivate_plugins')) {
151
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
152
-        }
153
-        unset($_GET['activate'], $_REQUEST['activate']);
154
-        deactivate_plugins($plugin_basename);
155
-    }
140
+	/**
141
+	 *    deactivate_plugin
142
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
143
+	 *
144
+	 * @access public
145
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
146
+	 * @return    void
147
+	 */
148
+	function espresso_deactivate_plugin($plugin_basename = '')
149
+	{
150
+		if (! function_exists('deactivate_plugins')) {
151
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
152
+		}
153
+		unset($_GET['activate'], $_REQUEST['activate']);
154
+		deactivate_plugins($plugin_basename);
155
+	}
156 156
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4260 added lines, -4260 removed lines patch added patch discarded remove patch
@@ -23,4348 +23,4348 @@
 block discarded – undo
23 23
  */
24 24
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
25 25
 {
26
-    /**
27
-     * @var EE_Admin_Config
28
-     */
29
-    protected $admin_config;
26
+	/**
27
+	 * @var EE_Admin_Config
28
+	 */
29
+	protected $admin_config;
30 30
 
31
-    /**
32
-     * @var LoaderInterface
33
-     */
34
-    protected $loader;
31
+	/**
32
+	 * @var LoaderInterface
33
+	 */
34
+	protected $loader;
35 35
 
36
-    /**
37
-     * @var RequestInterface
38
-     */
39
-    protected $request;
36
+	/**
37
+	 * @var RequestInterface
38
+	 */
39
+	protected $request;
40 40
 
41
-    // set in _init_page_props()
42
-    public $page_slug;
41
+	// set in _init_page_props()
42
+	public $page_slug;
43 43
 
44
-    public $page_label;
44
+	public $page_label;
45 45
 
46
-    public $page_folder;
46
+	public $page_folder;
47 47
 
48
-    // set in define_page_props()
49
-    protected $_admin_base_url;
48
+	// set in define_page_props()
49
+	protected $_admin_base_url;
50 50
 
51
-    protected $_admin_base_path;
51
+	protected $_admin_base_path;
52 52
 
53
-    protected $_admin_page_title;
53
+	protected $_admin_page_title;
54 54
 
55
-    protected $_labels;
55
+	protected $_labels;
56 56
 
57 57
 
58
-    // set early within EE_Admin_Init
59
-    protected $_wp_page_slug;
58
+	// set early within EE_Admin_Init
59
+	protected $_wp_page_slug;
60 60
 
61
-    // nav tabs
62
-    protected $_nav_tabs;
61
+	// nav tabs
62
+	protected $_nav_tabs;
63 63
 
64
-    protected $_default_nav_tab_name;
64
+	protected $_default_nav_tab_name;
65 65
 
66 66
 
67
-    // template variables (used by templates)
68
-    protected $_template_path;
67
+	// template variables (used by templates)
68
+	protected $_template_path;
69 69
 
70
-    protected $_column_template_path;
70
+	protected $_column_template_path;
71 71
 
72
-    /**
73
-     * @var array $_template_args
74
-     */
75
-    protected $_template_args = [];
72
+	/**
73
+	 * @var array $_template_args
74
+	 */
75
+	protected $_template_args = [];
76 76
 
77
-    /**
78
-     * this will hold the list table object for a given view.
79
-     *
80
-     * @var EE_Admin_List_Table $_list_table_object
81
-     */
82
-    protected $_list_table_object;
77
+	/**
78
+	 * this will hold the list table object for a given view.
79
+	 *
80
+	 * @var EE_Admin_List_Table $_list_table_object
81
+	 */
82
+	protected $_list_table_object;
83 83
 
84
-    // boolean
85
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
84
+	// boolean
85
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
86 86
 
87
-    protected $_routing;
87
+	protected $_routing;
88 88
 
89
-    // list table args
90
-    protected $_view;
89
+	// list table args
90
+	protected $_view;
91 91
 
92
-    protected $_views;
92
+	protected $_views;
93 93
 
94 94
 
95
-    // action => method pairs used for routing incoming requests
96
-    protected $_page_routes;
95
+	// action => method pairs used for routing incoming requests
96
+	protected $_page_routes;
97 97
 
98
-    /**
99
-     * @var array $_page_config
100
-     */
101
-    protected $_page_config;
98
+	/**
99
+	 * @var array $_page_config
100
+	 */
101
+	protected $_page_config;
102 102
 
103
-    /**
104
-     * the current page route and route config
105
-     *
106
-     * @var array|string|null $_route
107
-     */
108
-    protected $_route;
103
+	/**
104
+	 * the current page route and route config
105
+	 *
106
+	 * @var array|string|null $_route
107
+	 */
108
+	protected $_route;
109 109
 
110
-    /**
111
-     * @var string $_cpt_route
112
-     */
113
-    protected $_cpt_route;
110
+	/**
111
+	 * @var string $_cpt_route
112
+	 */
113
+	protected $_cpt_route;
114 114
 
115
-    /**
116
-     * @var array $_route_config
117
-     */
118
-    protected $_route_config;
115
+	/**
116
+	 * @var array $_route_config
117
+	 */
118
+	protected $_route_config;
119 119
 
120
-    /**
121
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
122
-     * actions.
123
-     *
124
-     * @since 4.6.x
125
-     * @var array.
126
-     */
127
-    protected $_default_route_query_args;
120
+	/**
121
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
122
+	 * actions.
123
+	 *
124
+	 * @since 4.6.x
125
+	 * @var array.
126
+	 */
127
+	protected $_default_route_query_args;
128 128
 
129
-    // set via request page and action args.
130
-    protected $_current_page;
129
+	// set via request page and action args.
130
+	protected $_current_page;
131 131
 
132
-    protected $_current_view;
132
+	protected $_current_view;
133 133
 
134
-    protected $_current_page_view_url;
134
+	protected $_current_page_view_url;
135 135
 
136
-    /**
137
-     * unprocessed value for the 'action' request param (default '')
138
-     *
139
-     * @var string
140
-     */
141
-    protected $raw_req_action = '';
136
+	/**
137
+	 * unprocessed value for the 'action' request param (default '')
138
+	 *
139
+	 * @var string
140
+	 */
141
+	protected $raw_req_action = '';
142 142
 
143
-    /**
144
-     * unprocessed value for the 'page' request param (default '')
145
-     *
146
-     * @var string
147
-     */
148
-    protected $raw_req_page = '';
149
-
150
-    /**
151
-     * sanitized request action (and nonce)
152
-     *
153
-     * @var string
154
-     */
155
-    protected $_req_action = '';
156
-
157
-    /**
158
-     * sanitized request action nonce
159
-     *
160
-     * @var string
161
-     */
162
-    protected $_req_nonce = '';
163
-
164
-    /**
165
-     * @var string
166
-     */
167
-    protected $_search_btn_label = '';
168
-
169
-    /**
170
-     * @var string
171
-     */
172
-    protected $_search_box_callback = '';
173
-
174
-    /**
175
-     * @var WP_Screen
176
-     */
177
-    protected $_current_screen;
178
-
179
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
180
-    protected $_hook_obj;
181
-
182
-    // for holding incoming request data
183
-    protected $_req_data = [];
184
-
185
-    // yes / no array for admin form fields
186
-    protected $_yes_no_values = [];
187
-
188
-    // some default things shared by all child classes
189
-    protected $_default_espresso_metaboxes = [
190
-        '_espresso_news_post_box',
191
-        '_espresso_links_post_box',
192
-        '_espresso_ratings_request',
193
-        '_espresso_sponsors_post_box',
194
-    ];
195
-
196
-    /**
197
-     * @var EE_Registry
198
-     */
199
-    protected $EE;
200
-
201
-
202
-    /**
203
-     * This is just a property that flags whether the given route is a caffeinated route or not.
204
-     *
205
-     * @var boolean
206
-     */
207
-    protected $_is_caf = false;
208
-
209
-    /**
210
-     * whether or not initializePage() has run
211
-     *
212
-     * @var boolean
213
-     */
214
-    protected $initialized = false;
215
-
216
-    /**
217
-     * @var FeatureFlags
218
-     */
219
-    protected $feature;
220
-
221
-
222
-    /**
223
-     * @var string
224
-     */
225
-    protected $class_name;
226
-
227
-    /**
228
-     * if the current class is an admin page extension, like: Extend_Events_Admin_Page,
229
-     * then this would be the parent classname: Events_Admin_Page
230
-     *
231
-     * @var string
232
-     */
233
-    protected $base_class_name;
234
-
235
-    /**
236
-     * @var array
237
-     * @since $VID:$
238
-     */
239
-    private $publish_post_meta_box_hidden_fields = [];
240
-
241
-
242
-    /**
243
-     * @Constructor
244
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
245
-     * @throws InvalidArgumentException
246
-     * @throws InvalidDataTypeException
247
-     * @throws InvalidInterfaceException
248
-     * @throws ReflectionException
249
-     */
250
-    public function __construct($routing = true)
251
-    {
252
-        $this->loader       = LoaderFactory::getLoader();
253
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
254
-        $this->feature      = $this->loader->getShared(FeatureFlags::class);
255
-        $this->request      = $this->loader->getShared(RequestInterface::class);
256
-        // routing enabled?
257
-        $this->_routing = $routing;
258
-
259
-        $this->class_name      = get_class($this);
260
-        $this->base_class_name = strpos($this->class_name, 'Extend_') === 0
261
-            ? str_replace('Extend_', '', $this->class_name)
262
-            : '';
263
-
264
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
265
-            $this->_is_caf = true;
266
-        }
267
-        $this->_yes_no_values = [
268
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
269
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
270
-        ];
271
-        // set the _req_data property.
272
-        $this->_req_data = $this->request->requestParams();
273
-    }
274
-
275
-
276
-    /**
277
-     * @return EE_Admin_Config
278
-     */
279
-    public function adminConfig(): EE_Admin_Config
280
-    {
281
-        return $this->admin_config;
282
-    }
283
-
284
-
285
-    /**
286
-     * @return FeatureFlags
287
-     */
288
-    public function feature(): FeatureFlags
289
-    {
290
-        return $this->feature;
291
-    }
292
-
293
-
294
-    /**
295
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
296
-     * for child classes that needed to set properties prior to these methods getting called,
297
-     * but also needed the parent class to have its construction completed as well.
298
-     * Bottom line is that constructors should ONLY be used for setting initial properties
299
-     * and any complex initialization logic should only run after instantiation is complete.
300
-     *
301
-     * This method gets called immediately after construction from within
302
-     *      EE_Admin_Page_Init::_initialize_admin_page()
303
-     *
304
-     * @throws EE_Error
305
-     * @throws InvalidArgumentException
306
-     * @throws InvalidDataTypeException
307
-     * @throws InvalidInterfaceException
308
-     * @throws ReflectionException
309
-     * @since $VID:$
310
-     */
311
-    public function initializePage()
312
-    {
313
-        if ($this->initialized) {
314
-            return;
315
-        }
316
-        // set initial page props (child method)
317
-        $this->_init_page_props();
318
-        // set global defaults
319
-        $this->_set_defaults();
320
-        // set early because incoming requests could be ajax related and we need to register those hooks.
321
-        $this->_global_ajax_hooks();
322
-        $this->_ajax_hooks();
323
-        // other_page_hooks have to be early too.
324
-        $this->_do_other_page_hooks();
325
-        // set up page dependencies
326
-        $this->_before_page_setup();
327
-        $this->_page_setup();
328
-        $this->initialized = true;
329
-    }
330
-
331
-
332
-    /**
333
-     * _init_page_props
334
-     * Child classes use to set at least the following properties:
335
-     * $page_slug.
336
-     * $page_label.
337
-     *
338
-     * @abstract
339
-     * @return void
340
-     */
341
-    abstract protected function _init_page_props();
342
-
343
-
344
-    /**
345
-     * _ajax_hooks
346
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
347
-     * Note: within the ajax callback methods.
348
-     *
349
-     * @abstract
350
-     * @return void
351
-     */
352
-    abstract protected function _ajax_hooks();
353
-
354
-
355
-    /**
356
-     * _define_page_props
357
-     * child classes define page properties in here.  Must include at least:
358
-     * $_admin_base_url = base_url for all admin pages
359
-     * $_admin_page_title = default admin_page_title for admin pages
360
-     * $_labels = array of default labels for various automatically generated elements:
361
-     *    array(
362
-     *        'buttons' => array(
363
-     *            'add' => esc_html__('label for add new button'),
364
-     *            'edit' => esc_html__('label for edit button'),
365
-     *            'delete' => esc_html__('label for delete button')
366
-     *            )
367
-     *        )
368
-     *
369
-     * @abstract
370
-     * @return void
371
-     */
372
-    abstract protected function _define_page_props();
373
-
374
-
375
-    /**
376
-     * _set_page_routes
377
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
378
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
379
-     * have a 'default' route. Here's the format
380
-     * $this->_page_routes = array(
381
-     *        'default' => array(
382
-     *            'func' => '_default_method_handling_route',
383
-     *            'args' => array('array','of','args'),
384
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
385
-     *            ajax request, backend processing)
386
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
387
-     *            headers route after.  The string you enter here should match the defined route reference for a
388
-     *            headers sent route.
389
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
390
-     *            this route.
391
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
392
-     *            checks).
393
-     *        ),
394
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
395
-     *        handling method.
396
-     *        )
397
-     * )
398
-     *
399
-     * @abstract
400
-     * @return void
401
-     */
402
-    abstract protected function _set_page_routes();
403
-
404
-
405
-    /**
406
-     * _set_page_config
407
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
408
-     * array corresponds to the page_route for the loaded page. Format:
409
-     * $this->_page_config = array(
410
-     *        'default' => array(
411
-     *            'labels' => array(
412
-     *                'buttons' => array(
413
-     *                    'add' => esc_html__('label for adding item'),
414
-     *                    'edit' => esc_html__('label for editing item'),
415
-     *                    'delete' => esc_html__('label for deleting item')
416
-     *                ),
417
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
418
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
419
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
420
-     *            _define_page_props() method
421
-     *            'nav' => array(
422
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
423
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
424
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
425
-     *                'order' => 10, //required to indicate tab position.
426
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
427
-     *                displayed then add this parameter.
428
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
429
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
430
-     *            metaboxes set for eventespresso admin pages.
431
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
432
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
433
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
434
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
435
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
436
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
437
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
438
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
439
-     *            want to display.
440
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
441
-     *                'tab_id' => array(
442
-     *                    'title' => 'tab_title',
443
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
444
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
445
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
446
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
447
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
448
-     *                    attempt to use the callback which should match the name of a method in the class
449
-     *                    ),
450
-     *                'tab2_id' => array(
451
-     *                    'title' => 'tab2 title',
452
-     *                    'filename' => 'file_name_2'
453
-     *                    'callback' => 'callback_method_for_content',
454
-     *                 ),
455
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
456
-     *            help tab area on an admin page. @return void
457
-     *
458
-     * @abstract
459
-     */
460
-    abstract protected function _set_page_config();
461
-
462
-
463
-    /**
464
-     * _add_screen_options
465
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
466
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
467
-     * to a particular view.
468
-     *
469
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
470
-     *         see also WP_Screen object documents...
471
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
472
-     * @abstract
473
-     * @return void
474
-     */
475
-    abstract protected function _add_screen_options();
476
-
477
-
478
-    /**
479
-     * _add_feature_pointers
480
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
481
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
482
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
483
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
484
-     * extended) also see:
485
-     *
486
-     * @link   http://eamann.com/tech/wordpress-portland/
487
-     * @abstract
488
-     * @return void
489
-     */
490
-    abstract protected function _add_feature_pointers();
491
-
492
-
493
-    /**
494
-     * load_scripts_styles
495
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
496
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
497
-     * scripts/styles per view by putting them in a dynamic function in this format
498
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
499
-     *
500
-     * @abstract
501
-     * @return void
502
-     */
503
-    abstract public function load_scripts_styles();
504
-
505
-
506
-    /**
507
-     * admin_init
508
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
509
-     * all pages/views loaded by child class.
510
-     *
511
-     * @abstract
512
-     * @return void
513
-     */
514
-    abstract public function admin_init();
515
-
516
-
517
-    /**
518
-     * admin_notices
519
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
520
-     * all pages/views loaded by child class.
521
-     *
522
-     * @abstract
523
-     * @return void
524
-     */
525
-    abstract public function admin_notices();
526
-
527
-
528
-    /**
529
-     * admin_footer_scripts
530
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
531
-     * will apply to all pages/views loaded by child class.
532
-     *
533
-     * @return void
534
-     */
535
-    abstract public function admin_footer_scripts();
536
-
537
-
538
-    /**
539
-     * admin_footer
540
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
541
-     * apply to all pages/views loaded by child class.
542
-     *
543
-     * @return void
544
-     */
545
-    public function admin_footer()
546
-    {
547
-    }
548
-
549
-
550
-    /**
551
-     * _global_ajax_hooks
552
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
553
-     * Note: within the ajax callback methods.
554
-     *
555
-     * @abstract
556
-     * @return void
557
-     */
558
-    protected function _global_ajax_hooks()
559
-    {
560
-        // for lazy loading of metabox content
561
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
562
-
563
-        add_action(
564
-            'wp_ajax_espresso_hide_status_change_notice',
565
-            [$this, 'hideStatusChangeNotice']
566
-        );
567
-        add_action(
568
-            'wp_ajax_nopriv_espresso_hide_status_change_notice',
569
-            [$this, 'hideStatusChangeNotice']
570
-        );
571
-    }
572
-
573
-
574
-    public function ajax_metabox_content()
575
-    {
576
-        $content_id  = $this->request->getRequestParam('contentid', '');
577
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
578
-        EE_Admin_Page::cached_rss_display($content_id, $content_url);
579
-        wp_die();
580
-    }
581
-
582
-
583
-    public function hideStatusChangeNotice()
584
-    {
585
-        $response = [];
586
-        try {
587
-            /** @var StatusChangeNotice $status_change_notice */
588
-            $status_change_notice = $this->loader->getShared(
589
-                'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
590
-            );
591
-            $response['success']  = $status_change_notice->dismiss() > -1;
592
-        } catch (Exception $exception) {
593
-            $response['errors'] = $exception->getMessage();
594
-        }
595
-        echo wp_json_encode($response);
596
-        exit();
597
-    }
598
-
599
-
600
-    /**
601
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
602
-     *
603
-     * @return void
604
-     */
605
-    protected function _before_page_setup()
606
-    {
607
-        // default is to do nothing
608
-    }
609
-
610
-
611
-    /**
612
-     * Makes sure any things that need to be loaded early get handled.
613
-     * We also escape early here if the page requested doesn't match the object.
614
-     *
615
-     * @final
616
-     * @return void
617
-     * @throws EE_Error
618
-     * @throws InvalidArgumentException
619
-     * @throws ReflectionException
620
-     * @throws InvalidDataTypeException
621
-     * @throws InvalidInterfaceException
622
-     */
623
-    final protected function _page_setup()
624
-    {
625
-        // requires?
626
-        // admin_init stuff - global - we're setting this REALLY early
627
-        // so if EE_Admin pages have to hook into other WP pages they can.
628
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
629
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
630
-        // next verify if we need to load anything...
631
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
632
-        $this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
633
-        $this->page_folder   = strtolower(
634
-            str_replace(['_Admin_Page', 'Extend_'], '', $this->class_name)
635
-        );
636
-        global $ee_menu_slugs;
637
-        $ee_menu_slugs = (array) $ee_menu_slugs;
638
-        if (
639
-            ! $this->request->isAjax()
640
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
641
-        ) {
642
-            return;
643
-        }
644
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
645
-        // we need to copy the action from the second to the first
646
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
647
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
648
-        $action     = $action !== '-1' ? $action : $action2;
649
-        $req_action = $action !== '-1' ? $action : 'default';
650
-
651
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
652
-        // then let's use the route as the action.
653
-        // This covers cases where we're coming in from a list table that isn't on the default route.
654
-        $route             = $this->request->getRequestParam('route');
655
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
656
-            ? $route
657
-            : $req_action;
658
-
659
-        $this->_current_view = $this->_req_action;
660
-        $this->_req_nonce    = $this->_req_action . '_nonce';
661
-        $this->_define_page_props();
662
-        $this->_current_page_view_url = add_query_arg(
663
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
664
-            $this->_admin_base_url
665
-        );
666
-        // set page configs
667
-        $this->_set_page_routes();
668
-        $this->_set_page_config();
669
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
670
-        if ($this->request->requestParamIsSet('wp_referer')) {
671
-            $wp_referer = $this->request->getRequestParam('wp_referer');
672
-            if ($wp_referer) {
673
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
674
-            }
675
-        }
676
-        // for CPT and other extended functionality.
677
-        // If there is an _extend_page_config_for_cpt
678
-        // then let's run that to modify all the various page configuration arrays.
679
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
680
-            $this->_extend_page_config_for_cpt();
681
-        }
682
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
683
-        $this->_page_routes = apply_filters(
684
-            'FHEE__' . $this->class_name . '__page_setup__page_routes',
685
-            $this->_page_routes,
686
-            $this
687
-        );
688
-        $this->_page_config = apply_filters(
689
-            'FHEE__' . $this->class_name . '__page_setup__page_config',
690
-            $this->_page_config,
691
-            $this
692
-        );
693
-        if ($this->base_class_name !== '') {
694
-            $this->_page_routes = apply_filters(
695
-                'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
696
-                $this->_page_routes,
697
-                $this
698
-            );
699
-            $this->_page_config = apply_filters(
700
-                'FHEE__' . $this->base_class_name . '__page_setup__page_config',
701
-                $this->_page_config,
702
-                $this
703
-            );
704
-        }
705
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
706
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
707
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
708
-            add_action(
709
-                'AHEE__EE_Admin_Page__route_admin_request',
710
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
711
-                10,
712
-                2
713
-            );
714
-        }
715
-        // next route only if routing enabled
716
-        if ($this->_routing && ! $this->request->isAjax()) {
717
-            $this->_verify_routes();
718
-            // next let's just check user_access and kill if no access
719
-            $this->check_user_access();
720
-            if ($this->_is_UI_request) {
721
-                // admin_init stuff - global, all views for this page class, specific view
722
-                add_action('admin_init', [$this, 'admin_init'], 10);
723
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
724
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
725
-                }
726
-            } else {
727
-                // hijack regular WP loading and route admin request immediately
728
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
729
-                $this->route_admin_request();
730
-            }
731
-        }
732
-    }
733
-
734
-
735
-    /**
736
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
737
-     *
738
-     * @return void
739
-     * @throws EE_Error
740
-     */
741
-    private function _do_other_page_hooks()
742
-    {
743
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
744
-        foreach ($registered_pages as $page) {
745
-            // now let's setup the file name and class that should be present
746
-            $classname = str_replace('.class.php', '', $page);
747
-            // autoloaders should take care of loading file
748
-            if (! class_exists($classname)) {
749
-                $error_msg[] = sprintf(
750
-                    esc_html__(
751
-                        'Something went wrong with loading the %s admin hooks page.',
752
-                        'event_espresso'
753
-                    ),
754
-                    $page
755
-                );
756
-                $error_msg[] = $error_msg[0]
757
-                               . "\r\n"
758
-                               . sprintf(
759
-                                   esc_html__(
760
-                                       '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',
761
-                                       'event_espresso'
762
-                                   ),
763
-                                   $page,
764
-                                   '<br />',
765
-                                   '<strong>' . $classname . '</strong>'
766
-                               );
767
-                throw new EE_Error(implode('||', $error_msg));
768
-            }
769
-            // notice we are passing the instance of this class to the hook object.
770
-            $this->loader->getShared($classname, [$this]);
771
-        }
772
-    }
773
-
774
-
775
-    /**
776
-     * @throws ReflectionException
777
-     * @throws EE_Error
778
-     */
779
-    public function load_page_dependencies()
780
-    {
781
-        try {
782
-            $this->_load_page_dependencies();
783
-        } catch (EE_Error $e) {
784
-            $e->get_error();
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     * load_page_dependencies
791
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
792
-     *
793
-     * @return void
794
-     * @throws DomainException
795
-     * @throws EE_Error
796
-     * @throws InvalidArgumentException
797
-     * @throws InvalidDataTypeException
798
-     * @throws InvalidInterfaceException
799
-     */
800
-    protected function _load_page_dependencies()
801
-    {
802
-        // let's set the current_screen and screen options to override what WP set
803
-        $this->_current_screen = get_current_screen();
804
-        // load admin_notices - global, page class, and view specific
805
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
806
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
807
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
808
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
809
-        }
810
-        // load network admin_notices - global, page class, and view specific
811
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
812
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
813
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
814
-        }
815
-        // this will save any per_page screen options if they are present
816
-        $this->_set_per_page_screen_options();
817
-        // setup list table properties
818
-        $this->_set_list_table();
819
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
820
-        // However in some cases the metaboxes will need to be added within a route handling callback.
821
-        if ($this->class_name === 'Promotions_Admin_Page') {
822
-            // hack because promos admin was loading the edited promotion object in the metaboxes callback
823
-            $this->addRegisteredMetaBoxes();
824
-        } else {
825
-            add_action('add_meta_boxes', [$this, 'addRegisteredMetaBoxes'], 99);
826
-        }
827
-        $this->_add_screen_columns();
828
-        // add screen options - global, page child class, and view specific
829
-        $this->_add_global_screen_options();
830
-        $this->_add_screen_options();
831
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
832
-        if (method_exists($this, $add_screen_options)) {
833
-            $this->{$add_screen_options}();
834
-        }
835
-        // add help tab(s) - set via page_config and qtips.
836
-        $this->_add_help_tabs();
837
-        $this->_add_qtips();
838
-        // add feature_pointers - global, page child class, and view specific
839
-        $this->_add_feature_pointers();
840
-        $this->_add_global_feature_pointers();
841
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
842
-        if (method_exists($this, $add_feature_pointer)) {
843
-            $this->{$add_feature_pointer}();
844
-        }
845
-        // enqueue scripts/styles - global, page class, and view specific
846
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
847
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
848
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
849
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
850
-        }
851
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
852
-        // admin_print_footer_scripts - global, page child class, and view specific.
853
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
854
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
855
-        // is a good use case. Notice the late priority we're giving these
856
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
857
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
858
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
859
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
860
-        }
861
-        // admin footer scripts
862
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
863
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
864
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
865
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
866
-        }
867
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
868
-        // targeted hook
869
-        do_action(
870
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
871
-        );
872
-    }
873
-
874
-
875
-    /**
876
-     * _set_defaults
877
-     * This sets some global defaults for class properties.
878
-     */
879
-    private function _set_defaults()
880
-    {
881
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
882
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
883
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
884
-        $this->_page_config          = $this->_default_route_query_args = [];
885
-        $this->_default_nav_tab_name = 'overview';
886
-        // init template args
887
-        $this->set_template_args(
888
-            [
889
-                'admin_page_header'  => '',
890
-                'admin_page_content' => '',
891
-                'post_body_content'  => '',
892
-                'before_list_table'  => '',
893
-                'after_list_table'   => '',
894
-            ]
895
-        );
896
-    }
897
-
898
-
899
-    /**
900
-     * route_admin_request
901
-     *
902
-     * @return void
903
-     * @throws InvalidArgumentException
904
-     * @throws InvalidInterfaceException
905
-     * @throws InvalidDataTypeException
906
-     * @throws EE_Error
907
-     * @throws ReflectionException
908
-     * @see    _route_admin_request()
909
-     */
910
-    public function route_admin_request()
911
-    {
912
-        try {
913
-            $this->_route_admin_request();
914
-        } catch (EE_Error $e) {
915
-            $e->get_error();
916
-        }
917
-    }
918
-
919
-
920
-    public function set_wp_page_slug($wp_page_slug)
921
-    {
922
-        $this->_wp_page_slug = $wp_page_slug;
923
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
924
-        if (is_network_admin()) {
925
-            $this->_wp_page_slug .= '-network';
926
-        }
927
-    }
928
-
929
-
930
-    /**
931
-     * _verify_routes
932
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
933
-     * we know if we need to drop out.
934
-     *
935
-     * @return bool
936
-     * @throws EE_Error
937
-     */
938
-    protected function _verify_routes()
939
-    {
940
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
941
-        if (! $this->_current_page && ! $this->request->isAjax()) {
942
-            return false;
943
-        }
944
-        $this->_route = false;
945
-        // check that the page_routes array is not empty
946
-        if (empty($this->_page_routes)) {
947
-            // user error msg
948
-            $error_msg = sprintf(
949
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
950
-                $this->_admin_page_title
951
-            );
952
-            // developer error msg
953
-            $error_msg .= '||' . $error_msg
954
-                          . esc_html__(
955
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
956
-                              'event_espresso'
957
-                          );
958
-            throw new EE_Error($error_msg);
959
-        }
960
-        // and that the requested page route exists
961
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
962
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
963
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
964
-        } else {
965
-            // user error msg
966
-            $error_msg = sprintf(
967
-                esc_html__(
968
-                    'The requested page route does not exist for the %s admin page.',
969
-                    'event_espresso'
970
-                ),
971
-                $this->_admin_page_title
972
-            );
973
-            // developer error msg
974
-            $error_msg .= '||' . $error_msg
975
-                          . sprintf(
976
-                              esc_html__(
977
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
978
-                                  'event_espresso'
979
-                              ),
980
-                              $this->_req_action
981
-                          );
982
-            throw new EE_Error($error_msg);
983
-        }
984
-        // and that a default route exists
985
-        if (! array_key_exists('default', $this->_page_routes)) {
986
-            // user error msg
987
-            $error_msg = sprintf(
988
-                esc_html__(
989
-                    'A default page route has not been set for the % admin page.',
990
-                    'event_espresso'
991
-                ),
992
-                $this->_admin_page_title
993
-            );
994
-            // developer error msg
995
-            $error_msg .= '||' . $error_msg
996
-                          . esc_html__(
997
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
998
-                              'event_espresso'
999
-                          );
1000
-            throw new EE_Error($error_msg);
1001
-        }
1002
-
1003
-        // first lets' catch if the UI request has EVER been set.
1004
-        if ($this->_is_UI_request === null) {
1005
-            // lets set if this is a UI request or not.
1006
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
1007
-            // wait a minute... we might have a noheader in the route array
1008
-            $this->_is_UI_request = ! (
1009
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
1010
-            )
1011
-                ? $this->_is_UI_request
1012
-                : false;
1013
-        }
1014
-        $this->_set_current_labels();
1015
-        return true;
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1021
-     *
1022
-     * @param string $route the route name we're verifying
1023
-     * @return bool we'll throw an exception if this isn't a valid route.
1024
-     * @throws EE_Error
1025
-     */
1026
-    protected function _verify_route($route)
1027
-    {
1028
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
1029
-            return true;
1030
-        }
1031
-        // user error msg
1032
-        $error_msg = sprintf(
1033
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1034
-            $this->_admin_page_title
1035
-        );
1036
-        // developer error msg
1037
-        $error_msg .= '||' . $error_msg
1038
-                      . sprintf(
1039
-                          esc_html__(
1040
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1041
-                              'event_espresso'
1042
-                          ),
1043
-                          $route
1044
-                      );
1045
-        throw new EE_Error($error_msg);
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     * perform nonce verification
1051
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1052
-     * using this method (and save retyping!)
1053
-     *
1054
-     * @param string $nonce     The nonce sent
1055
-     * @param string $nonce_ref The nonce reference string (name0)
1056
-     * @return void
1057
-     * @throws EE_Error
1058
-     * @throws InvalidArgumentException
1059
-     * @throws InvalidDataTypeException
1060
-     * @throws InvalidInterfaceException
1061
-     */
1062
-    protected function _verify_nonce($nonce, $nonce_ref)
1063
-    {
1064
-        // verify nonce against expected value
1065
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1066
-            // these are not the droids you are looking for !!!
1067
-            $msg = sprintf(
1068
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
1069
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1070
-                '</a>'
1071
-            );
1072
-            if (WP_DEBUG) {
1073
-                $msg .= "\n  ";
1074
-                $msg .= sprintf(
1075
-                    esc_html__(
1076
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1077
-                        'event_espresso'
1078
-                    ),
1079
-                    __CLASS__
1080
-                );
1081
-            }
1082
-            if (! $this->request->isAjax()) {
1083
-                wp_die($msg);
1084
-            }
1085
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1086
-            $this->_return_json();
1087
-        }
1088
-    }
1089
-
1090
-
1091
-    /**
1092
-     * _route_admin_request()
1093
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1094
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1095
-     * in the page routes and then will try to load the corresponding method.
1096
-     *
1097
-     * @return void
1098
-     * @throws EE_Error
1099
-     * @throws InvalidArgumentException
1100
-     * @throws InvalidDataTypeException
1101
-     * @throws InvalidInterfaceException
1102
-     * @throws ReflectionException
1103
-     */
1104
-    protected function _route_admin_request()
1105
-    {
1106
-        if (! $this->_is_UI_request) {
1107
-            $this->_verify_routes();
1108
-        }
1109
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1110
-        if ($this->_req_action !== 'default' && $nonce_check) {
1111
-            // set nonce from post data
1112
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1113
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1114
-        }
1115
-        // set the nav_tabs array but ONLY if this is  UI_request
1116
-        if ($this->_is_UI_request) {
1117
-            $this->_set_nav_tabs();
1118
-        }
1119
-        // grab callback function
1120
-        $func = is_array($this->_route) && isset($this->_route['func'])
1121
-            ? $this->_route['func']
1122
-            : $this->_route;
1123
-        // check if callback has args
1124
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1125
-        // action right before calling route
1126
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1127
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1128
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1129
-        }
1130
-        // strip _wp_http_referer from the server REQUEST_URI
1131
-        // else it grows in length on every submission due to recursion,
1132
-        // ultimately causing a "Request-URI Too Large" error
1133
-        $this->request->unSetRequestParam('_wp_http_referer');
1134
-        $this->request->unSetServerParam('_wp_http_referer');
1135
-        $cleaner_request_uri = remove_query_arg(
1136
-            '_wp_http_referer',
1137
-            wp_unslash($this->request->getServerParam('REQUEST_URI'))
1138
-        );
1139
-        $this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri, true);
1140
-        $this->request->setServerParam('REQUEST_URI', $cleaner_request_uri, true);
1141
-        $route_callback = [];
1142
-        if (! empty($func)) {
1143
-            if (is_array($func)) {
1144
-                $route_callback = $func;
1145
-            } elseif (is_string($func)) {
1146
-                if (strpos($func, '::') !== false) {
1147
-                    $route_callback = explode('::', $func);
1148
-                } elseif (method_exists($this, $func)) {
1149
-                    $route_callback = [$this, $func];
1150
-                } else {
1151
-                    $route_callback = $func;
1152
-                }
1153
-            }
1154
-            [$class, $method] = $route_callback;
1155
-            // is it neither a class method NOR a standalone function?
1156
-            if (! is_callable($route_callback)) {
1157
-                // user error msg
1158
-                $error_msg = esc_html__(
1159
-                    'An error occurred. The  requested page route could not be found.',
1160
-                    'event_espresso'
1161
-                );
1162
-                // developer error msg
1163
-                $error_msg .= '||';
1164
-                $error_msg .= sprintf(
1165
-                    esc_html__(
1166
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1167
-                        'event_espresso'
1168
-                    ),
1169
-                    $method
1170
-                );
1171
-                throw new DomainException($error_msg);
1172
-            }
1173
-            if ($class !== $this && ! in_array($this, $args)) {
1174
-                // send along this admin page object for access by addons.
1175
-                $args['admin_page'] = $this;
1176
-            }
1177
-            try {
1178
-                call_user_func_array($route_callback, $args);
1179
-            } catch (Throwable $throwable) {
1180
-                $arg_keys = array_keys($args);
1181
-                $nice_args = [];
1182
-                foreach ($args as $key => $arg) {
1183
-                    $nice_args[ $key ] = is_object($arg) ? get_class($arg) : $arg_keys[ $key ];
1184
-                }
1185
-                new ExceptionStackTraceDisplay(
1186
-                        new RuntimeException(
1187
-                            sprintf(
1188
-                                esc_html__(
1189
-                                    'Page route "%1$s" with the supplied arguments (%2$s) threw the following exception: %3$s',
1190
-                                    'event_espresso'
1191
-                                ),
1192
-                                $method,
1193
-                                implode(', ', $nice_args),
1194
-                                $throwable->getMessage()
1195
-                            ),
1196
-                            $throwable->getCode(),
1197
-                            $throwable
1198
-                        )
1199
-                );
1200
-            }
1201
-        }
1202
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1203
-        // then we need to reset the routing properties to the new route.
1204
-        // 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.
1205
-        if (
1206
-            $this->_is_UI_request === false
1207
-            && is_array($this->_route)
1208
-            && ! empty($this->_route['headers_sent_route'])
1209
-        ) {
1210
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1211
-        }
1212
-    }
1213
-
1214
-
1215
-    /**
1216
-     * This method just allows the resetting of page properties in the case where a no headers
1217
-     * route redirects to a headers route in its route config.
1218
-     *
1219
-     * @param string $new_route New (non header) route to redirect to.
1220
-     * @return   void
1221
-     * @throws ReflectionException
1222
-     * @throws InvalidArgumentException
1223
-     * @throws InvalidInterfaceException
1224
-     * @throws InvalidDataTypeException
1225
-     * @throws EE_Error
1226
-     * @since   4.3.0
1227
-     */
1228
-    protected function _reset_routing_properties($new_route)
1229
-    {
1230
-        $this->_is_UI_request = true;
1231
-        // now we set the current route to whatever the headers_sent_route is set at
1232
-        $this->request->setRequestParam('action', $new_route);
1233
-        // rerun page setup
1234
-        $this->_page_setup();
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     * _add_query_arg
1240
-     * adds nonce to array of arguments then calls WP add_query_arg function
1241
-     *(internally just uses EEH_URL's function with the same name)
1242
-     *
1243
-     * @param array  $args
1244
-     * @param string $url
1245
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1246
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1247
-     *                                        Example usage: If the current page is:
1248
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1249
-     *                                        &action=default&event_id=20&month_range=March%202015
1250
-     *                                        &_wpnonce=5467821
1251
-     *                                        and you call:
1252
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1253
-     *                                        array(
1254
-     *                                        'action' => 'resend_something',
1255
-     *                                        'page=>espresso_registrations'
1256
-     *                                        ),
1257
-     *                                        $some_url,
1258
-     *                                        true
1259
-     *                                        );
1260
-     *                                        It will produce a url in this structure:
1261
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1262
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1263
-     *                                        month_range]=March%202015
1264
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1265
-     * @param int    $context
1266
-     * @return string
1267
-     */
1268
-    public static function add_query_args_and_nonce(
1269
-        $args = [],
1270
-        $url = '',
1271
-        $sticky = false,
1272
-        $exclude_nonce = false,
1273
-        int $context = EEH_URL::CONTEXT_NONE
1274
-    ) {
1275
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1276
-        if ($sticky) {
1277
-            /** @var RequestInterface $request */
1278
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1279
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1280
-            $request->unSetServerParam('_wp_http_referer', true);
1281
-            foreach ($request->requestParams() as $key => $value) {
1282
-                // do not add nonces
1283
-                if (strpos($key, 'nonce') !== false) {
1284
-                    continue;
1285
-                }
1286
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1287
-            }
1288
-        }
1289
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce, $context);
1290
-    }
1291
-
1292
-
1293
-    /**
1294
-     * This returns a generated link that will load the related help tab.
1295
-     *
1296
-     * @param string $help_tab_id the id for the connected help tab
1297
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1298
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1299
-     * @return string              generated link
1300
-     * @uses EEH_Template::get_help_tab_link()
1301
-     */
1302
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1303
-    {
1304
-        return EEH_Template::get_help_tab_link(
1305
-            $help_tab_id,
1306
-            $this->page_slug,
1307
-            $this->_req_action,
1308
-            $icon_style,
1309
-            $help_text
1310
-        );
1311
-    }
1312
-
1313
-
1314
-    /**
1315
-     * _add_help_tabs
1316
-     * Note child classes define their help tabs within the page_config array.
1317
-     *
1318
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1319
-     * @return void
1320
-     * @throws DomainException
1321
-     * @throws EE_Error
1322
-     * @throws ReflectionException
1323
-     */
1324
-    protected function _add_help_tabs()
1325
-    {
1326
-        if (isset($this->_page_config[ $this->_req_action ])) {
1327
-            $config = $this->_page_config[ $this->_req_action ];
1328
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1329
-            if (is_array($config) && isset($config['help_sidebar'])) {
1330
-                // check that the callback given is valid
1331
-                if (! method_exists($this, $config['help_sidebar'])) {
1332
-                    throw new EE_Error(
1333
-                        sprintf(
1334
-                            esc_html__(
1335
-                                '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',
1336
-                                'event_espresso'
1337
-                            ),
1338
-                            $config['help_sidebar'],
1339
-                            $this->class_name
1340
-                        )
1341
-                    );
1342
-                }
1343
-                $content = apply_filters(
1344
-                    'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1345
-                    $this->{$config['help_sidebar']}()
1346
-                );
1347
-                $this->_current_screen->set_help_sidebar($content);
1348
-            }
1349
-            if (! isset($config['help_tabs'])) {
1350
-                return;
1351
-            } //no help tabs for this route
1352
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1353
-                // we're here so there ARE help tabs!
1354
-                // make sure we've got what we need
1355
-                if (! isset($cfg['title'])) {
1356
-                    throw new EE_Error(
1357
-                        esc_html__(
1358
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1359
-                            'event_espresso'
1360
-                        )
1361
-                    );
1362
-                }
1363
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1364
-                    throw new EE_Error(
1365
-                        esc_html__(
1366
-                            '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',
1367
-                            'event_espresso'
1368
-                        )
1369
-                    );
1370
-                }
1371
-                // first priority goes to content.
1372
-                if (! empty($cfg['content'])) {
1373
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1374
-                    // second priority goes to filename
1375
-                } elseif (! empty($cfg['filename'])) {
1376
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1377
-                    // 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)
1378
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1379
-                                                             . basename($this->_get_dir())
1380
-                                                             . '/help_tabs/'
1381
-                                                             . $cfg['filename']
1382
-                                                             . '.help_tab.php' : $file_path;
1383
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1384
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1385
-                        EE_Error::add_error(
1386
-                            sprintf(
1387
-                                esc_html__(
1388
-                                    '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',
1389
-                                    'event_espresso'
1390
-                                ),
1391
-                                $tab_id,
1392
-                                key($config),
1393
-                                $file_path
1394
-                            ),
1395
-                            __FILE__,
1396
-                            __FUNCTION__,
1397
-                            __LINE__
1398
-                        );
1399
-                        return;
1400
-                    }
1401
-                    $template_args['admin_page_obj'] = $this;
1402
-                    $content                         = EEH_Template::display_template(
1403
-                        $file_path,
1404
-                        $template_args,
1405
-                        true
1406
-                    );
1407
-                } else {
1408
-                    $content = '';
1409
-                }
1410
-                // check if callback is valid
1411
-                if (
1412
-                    empty($content)
1413
-                    && (
1414
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1415
-                    )
1416
-                ) {
1417
-                    EE_Error::add_error(
1418
-                        sprintf(
1419
-                            esc_html__(
1420
-                                '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.',
1421
-                                'event_espresso'
1422
-                            ),
1423
-                            $cfg['title']
1424
-                        ),
1425
-                        __FILE__,
1426
-                        __FUNCTION__,
1427
-                        __LINE__
1428
-                    );
1429
-                    return;
1430
-                }
1431
-                // setup config array for help tab method
1432
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1433
-                $_ht = [
1434
-                    'id'       => $id,
1435
-                    'title'    => $cfg['title'],
1436
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1437
-                    'content'  => $content,
1438
-                ];
1439
-                $this->_current_screen->add_help_tab($_ht);
1440
-            }
1441
-        }
1442
-    }
1443
-
1444
-
1445
-    /**
1446
-     * This simply sets up any qtips that have been defined in the page config
1447
-     *
1448
-     * @return void
1449
-     * @throws ReflectionException
1450
-     * @throws EE_Error
1451
-     */
1452
-    protected function _add_qtips()
1453
-    {
1454
-        if (isset($this->_route_config['qtips'])) {
1455
-            $qtips = (array) $this->_route_config['qtips'];
1456
-            // load qtip loader
1457
-            $path = [
1458
-                $this->_get_dir() . '/qtips/',
1459
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1460
-            ];
1461
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1462
-        }
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * _set_nav_tabs
1468
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1469
-     * wish to add additional tabs or modify accordingly.
1470
-     *
1471
-     * @return void
1472
-     * @throws InvalidArgumentException
1473
-     * @throws InvalidInterfaceException
1474
-     * @throws InvalidDataTypeException
1475
-     */
1476
-    protected function _set_nav_tabs()
1477
-    {
1478
-        $i        = 0;
1479
-        $only_tab = count($this->_page_config) < 2;
1480
-        foreach ($this->_page_config as $slug => $config) {
1481
-            if (! is_array($config) || empty($config['nav'])) {
1482
-                continue;
1483
-            }
1484
-            // no nav tab for this config
1485
-            // check for persistent flag
1486
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1487
-                // nav tab is only to appear when route requested.
1488
-                continue;
1489
-            }
1490
-            if (! $this->check_user_access($slug, true)) {
1491
-                // no nav tab because current user does not have access.
1492
-                continue;
1493
-            }
1494
-            $css_class = $config['css_class'] ?? '';
1495
-            $css_class .= $only_tab ? ' ee-only-tab' : '';
1496
-            $css_class .= " ee-nav-tab__$slug";
1497
-
1498
-            $this->_nav_tabs[ $slug ] = [
1499
-                'url'       => $config['nav']['url'] ?? EE_Admin_Page::add_query_args_and_nonce(
1500
-                        ['action' => $slug],
1501
-                        $this->_admin_base_url
1502
-                    ),
1503
-                'link_text' => $this->navTabLabel($config['nav'], $slug),
1504
-                'css_class' => $this->_req_action === $slug ? $css_class . ' nav-tab-active' : $css_class,
1505
-                'order'     => $config['nav']['order'] ?? $i,
1506
-            ];
1507
-            $i++;
1508
-        }
1509
-        // if $this->_nav_tabs is empty then lets set the default
1510
-        if (empty($this->_nav_tabs)) {
1511
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1512
-                'url'       => $this->_admin_base_url,
1513
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1514
-                'css_class' => 'nav-tab-active',
1515
-                'order'     => 10,
1516
-            ];
1517
-        }
1518
-        // now let's sort the tabs according to order
1519
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1520
-    }
1521
-
1522
-
1523
-    private function navTabLabel(array $nav_tab, string $slug): string
1524
-    {
1525
-        $label = $nav_tab['label'] ?? ucwords(str_replace('_', ' ', $slug));
1526
-        $icon  = $nav_tab['icon'] ?? null;
1527
-        $icon  = $icon ? '<span class="dashicons ' . $icon . '"></span>' : '';
1528
-        return '
143
+	/**
144
+	 * unprocessed value for the 'page' request param (default '')
145
+	 *
146
+	 * @var string
147
+	 */
148
+	protected $raw_req_page = '';
149
+
150
+	/**
151
+	 * sanitized request action (and nonce)
152
+	 *
153
+	 * @var string
154
+	 */
155
+	protected $_req_action = '';
156
+
157
+	/**
158
+	 * sanitized request action nonce
159
+	 *
160
+	 * @var string
161
+	 */
162
+	protected $_req_nonce = '';
163
+
164
+	/**
165
+	 * @var string
166
+	 */
167
+	protected $_search_btn_label = '';
168
+
169
+	/**
170
+	 * @var string
171
+	 */
172
+	protected $_search_box_callback = '';
173
+
174
+	/**
175
+	 * @var WP_Screen
176
+	 */
177
+	protected $_current_screen;
178
+
179
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
180
+	protected $_hook_obj;
181
+
182
+	// for holding incoming request data
183
+	protected $_req_data = [];
184
+
185
+	// yes / no array for admin form fields
186
+	protected $_yes_no_values = [];
187
+
188
+	// some default things shared by all child classes
189
+	protected $_default_espresso_metaboxes = [
190
+		'_espresso_news_post_box',
191
+		'_espresso_links_post_box',
192
+		'_espresso_ratings_request',
193
+		'_espresso_sponsors_post_box',
194
+	];
195
+
196
+	/**
197
+	 * @var EE_Registry
198
+	 */
199
+	protected $EE;
200
+
201
+
202
+	/**
203
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
204
+	 *
205
+	 * @var boolean
206
+	 */
207
+	protected $_is_caf = false;
208
+
209
+	/**
210
+	 * whether or not initializePage() has run
211
+	 *
212
+	 * @var boolean
213
+	 */
214
+	protected $initialized = false;
215
+
216
+	/**
217
+	 * @var FeatureFlags
218
+	 */
219
+	protected $feature;
220
+
221
+
222
+	/**
223
+	 * @var string
224
+	 */
225
+	protected $class_name;
226
+
227
+	/**
228
+	 * if the current class is an admin page extension, like: Extend_Events_Admin_Page,
229
+	 * then this would be the parent classname: Events_Admin_Page
230
+	 *
231
+	 * @var string
232
+	 */
233
+	protected $base_class_name;
234
+
235
+	/**
236
+	 * @var array
237
+	 * @since $VID:$
238
+	 */
239
+	private $publish_post_meta_box_hidden_fields = [];
240
+
241
+
242
+	/**
243
+	 * @Constructor
244
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
245
+	 * @throws InvalidArgumentException
246
+	 * @throws InvalidDataTypeException
247
+	 * @throws InvalidInterfaceException
248
+	 * @throws ReflectionException
249
+	 */
250
+	public function __construct($routing = true)
251
+	{
252
+		$this->loader       = LoaderFactory::getLoader();
253
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
254
+		$this->feature      = $this->loader->getShared(FeatureFlags::class);
255
+		$this->request      = $this->loader->getShared(RequestInterface::class);
256
+		// routing enabled?
257
+		$this->_routing = $routing;
258
+
259
+		$this->class_name      = get_class($this);
260
+		$this->base_class_name = strpos($this->class_name, 'Extend_') === 0
261
+			? str_replace('Extend_', '', $this->class_name)
262
+			: '';
263
+
264
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
265
+			$this->_is_caf = true;
266
+		}
267
+		$this->_yes_no_values = [
268
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
269
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
270
+		];
271
+		// set the _req_data property.
272
+		$this->_req_data = $this->request->requestParams();
273
+	}
274
+
275
+
276
+	/**
277
+	 * @return EE_Admin_Config
278
+	 */
279
+	public function adminConfig(): EE_Admin_Config
280
+	{
281
+		return $this->admin_config;
282
+	}
283
+
284
+
285
+	/**
286
+	 * @return FeatureFlags
287
+	 */
288
+	public function feature(): FeatureFlags
289
+	{
290
+		return $this->feature;
291
+	}
292
+
293
+
294
+	/**
295
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
296
+	 * for child classes that needed to set properties prior to these methods getting called,
297
+	 * but also needed the parent class to have its construction completed as well.
298
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
299
+	 * and any complex initialization logic should only run after instantiation is complete.
300
+	 *
301
+	 * This method gets called immediately after construction from within
302
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
303
+	 *
304
+	 * @throws EE_Error
305
+	 * @throws InvalidArgumentException
306
+	 * @throws InvalidDataTypeException
307
+	 * @throws InvalidInterfaceException
308
+	 * @throws ReflectionException
309
+	 * @since $VID:$
310
+	 */
311
+	public function initializePage()
312
+	{
313
+		if ($this->initialized) {
314
+			return;
315
+		}
316
+		// set initial page props (child method)
317
+		$this->_init_page_props();
318
+		// set global defaults
319
+		$this->_set_defaults();
320
+		// set early because incoming requests could be ajax related and we need to register those hooks.
321
+		$this->_global_ajax_hooks();
322
+		$this->_ajax_hooks();
323
+		// other_page_hooks have to be early too.
324
+		$this->_do_other_page_hooks();
325
+		// set up page dependencies
326
+		$this->_before_page_setup();
327
+		$this->_page_setup();
328
+		$this->initialized = true;
329
+	}
330
+
331
+
332
+	/**
333
+	 * _init_page_props
334
+	 * Child classes use to set at least the following properties:
335
+	 * $page_slug.
336
+	 * $page_label.
337
+	 *
338
+	 * @abstract
339
+	 * @return void
340
+	 */
341
+	abstract protected function _init_page_props();
342
+
343
+
344
+	/**
345
+	 * _ajax_hooks
346
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
347
+	 * Note: within the ajax callback methods.
348
+	 *
349
+	 * @abstract
350
+	 * @return void
351
+	 */
352
+	abstract protected function _ajax_hooks();
353
+
354
+
355
+	/**
356
+	 * _define_page_props
357
+	 * child classes define page properties in here.  Must include at least:
358
+	 * $_admin_base_url = base_url for all admin pages
359
+	 * $_admin_page_title = default admin_page_title for admin pages
360
+	 * $_labels = array of default labels for various automatically generated elements:
361
+	 *    array(
362
+	 *        'buttons' => array(
363
+	 *            'add' => esc_html__('label for add new button'),
364
+	 *            'edit' => esc_html__('label for edit button'),
365
+	 *            'delete' => esc_html__('label for delete button')
366
+	 *            )
367
+	 *        )
368
+	 *
369
+	 * @abstract
370
+	 * @return void
371
+	 */
372
+	abstract protected function _define_page_props();
373
+
374
+
375
+	/**
376
+	 * _set_page_routes
377
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
378
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
379
+	 * have a 'default' route. Here's the format
380
+	 * $this->_page_routes = array(
381
+	 *        'default' => array(
382
+	 *            'func' => '_default_method_handling_route',
383
+	 *            'args' => array('array','of','args'),
384
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
385
+	 *            ajax request, backend processing)
386
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
387
+	 *            headers route after.  The string you enter here should match the defined route reference for a
388
+	 *            headers sent route.
389
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
390
+	 *            this route.
391
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
392
+	 *            checks).
393
+	 *        ),
394
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
395
+	 *        handling method.
396
+	 *        )
397
+	 * )
398
+	 *
399
+	 * @abstract
400
+	 * @return void
401
+	 */
402
+	abstract protected function _set_page_routes();
403
+
404
+
405
+	/**
406
+	 * _set_page_config
407
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
408
+	 * array corresponds to the page_route for the loaded page. Format:
409
+	 * $this->_page_config = array(
410
+	 *        'default' => array(
411
+	 *            'labels' => array(
412
+	 *                'buttons' => array(
413
+	 *                    'add' => esc_html__('label for adding item'),
414
+	 *                    'edit' => esc_html__('label for editing item'),
415
+	 *                    'delete' => esc_html__('label for deleting item')
416
+	 *                ),
417
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
418
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
419
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
420
+	 *            _define_page_props() method
421
+	 *            'nav' => array(
422
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
423
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
424
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
425
+	 *                'order' => 10, //required to indicate tab position.
426
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
427
+	 *                displayed then add this parameter.
428
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
429
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
430
+	 *            metaboxes set for eventespresso admin pages.
431
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
432
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
433
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
434
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
435
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
436
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
437
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
438
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
439
+	 *            want to display.
440
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
441
+	 *                'tab_id' => array(
442
+	 *                    'title' => 'tab_title',
443
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
444
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
445
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
446
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
447
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
448
+	 *                    attempt to use the callback which should match the name of a method in the class
449
+	 *                    ),
450
+	 *                'tab2_id' => array(
451
+	 *                    'title' => 'tab2 title',
452
+	 *                    'filename' => 'file_name_2'
453
+	 *                    'callback' => 'callback_method_for_content',
454
+	 *                 ),
455
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
456
+	 *            help tab area on an admin page. @return void
457
+	 *
458
+	 * @abstract
459
+	 */
460
+	abstract protected function _set_page_config();
461
+
462
+
463
+	/**
464
+	 * _add_screen_options
465
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
466
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
467
+	 * to a particular view.
468
+	 *
469
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
470
+	 *         see also WP_Screen object documents...
471
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
472
+	 * @abstract
473
+	 * @return void
474
+	 */
475
+	abstract protected function _add_screen_options();
476
+
477
+
478
+	/**
479
+	 * _add_feature_pointers
480
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
481
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
482
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
483
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
484
+	 * extended) also see:
485
+	 *
486
+	 * @link   http://eamann.com/tech/wordpress-portland/
487
+	 * @abstract
488
+	 * @return void
489
+	 */
490
+	abstract protected function _add_feature_pointers();
491
+
492
+
493
+	/**
494
+	 * load_scripts_styles
495
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
496
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
497
+	 * scripts/styles per view by putting them in a dynamic function in this format
498
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
499
+	 *
500
+	 * @abstract
501
+	 * @return void
502
+	 */
503
+	abstract public function load_scripts_styles();
504
+
505
+
506
+	/**
507
+	 * admin_init
508
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
509
+	 * all pages/views loaded by child class.
510
+	 *
511
+	 * @abstract
512
+	 * @return void
513
+	 */
514
+	abstract public function admin_init();
515
+
516
+
517
+	/**
518
+	 * admin_notices
519
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
520
+	 * all pages/views loaded by child class.
521
+	 *
522
+	 * @abstract
523
+	 * @return void
524
+	 */
525
+	abstract public function admin_notices();
526
+
527
+
528
+	/**
529
+	 * admin_footer_scripts
530
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
531
+	 * will apply to all pages/views loaded by child class.
532
+	 *
533
+	 * @return void
534
+	 */
535
+	abstract public function admin_footer_scripts();
536
+
537
+
538
+	/**
539
+	 * admin_footer
540
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
541
+	 * apply to all pages/views loaded by child class.
542
+	 *
543
+	 * @return void
544
+	 */
545
+	public function admin_footer()
546
+	{
547
+	}
548
+
549
+
550
+	/**
551
+	 * _global_ajax_hooks
552
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
553
+	 * Note: within the ajax callback methods.
554
+	 *
555
+	 * @abstract
556
+	 * @return void
557
+	 */
558
+	protected function _global_ajax_hooks()
559
+	{
560
+		// for lazy loading of metabox content
561
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
562
+
563
+		add_action(
564
+			'wp_ajax_espresso_hide_status_change_notice',
565
+			[$this, 'hideStatusChangeNotice']
566
+		);
567
+		add_action(
568
+			'wp_ajax_nopriv_espresso_hide_status_change_notice',
569
+			[$this, 'hideStatusChangeNotice']
570
+		);
571
+	}
572
+
573
+
574
+	public function ajax_metabox_content()
575
+	{
576
+		$content_id  = $this->request->getRequestParam('contentid', '');
577
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
578
+		EE_Admin_Page::cached_rss_display($content_id, $content_url);
579
+		wp_die();
580
+	}
581
+
582
+
583
+	public function hideStatusChangeNotice()
584
+	{
585
+		$response = [];
586
+		try {
587
+			/** @var StatusChangeNotice $status_change_notice */
588
+			$status_change_notice = $this->loader->getShared(
589
+				'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
590
+			);
591
+			$response['success']  = $status_change_notice->dismiss() > -1;
592
+		} catch (Exception $exception) {
593
+			$response['errors'] = $exception->getMessage();
594
+		}
595
+		echo wp_json_encode($response);
596
+		exit();
597
+	}
598
+
599
+
600
+	/**
601
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
602
+	 *
603
+	 * @return void
604
+	 */
605
+	protected function _before_page_setup()
606
+	{
607
+		// default is to do nothing
608
+	}
609
+
610
+
611
+	/**
612
+	 * Makes sure any things that need to be loaded early get handled.
613
+	 * We also escape early here if the page requested doesn't match the object.
614
+	 *
615
+	 * @final
616
+	 * @return void
617
+	 * @throws EE_Error
618
+	 * @throws InvalidArgumentException
619
+	 * @throws ReflectionException
620
+	 * @throws InvalidDataTypeException
621
+	 * @throws InvalidInterfaceException
622
+	 */
623
+	final protected function _page_setup()
624
+	{
625
+		// requires?
626
+		// admin_init stuff - global - we're setting this REALLY early
627
+		// so if EE_Admin pages have to hook into other WP pages they can.
628
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
629
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
630
+		// next verify if we need to load anything...
631
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
632
+		$this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
633
+		$this->page_folder   = strtolower(
634
+			str_replace(['_Admin_Page', 'Extend_'], '', $this->class_name)
635
+		);
636
+		global $ee_menu_slugs;
637
+		$ee_menu_slugs = (array) $ee_menu_slugs;
638
+		if (
639
+			! $this->request->isAjax()
640
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
641
+		) {
642
+			return;
643
+		}
644
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
645
+		// we need to copy the action from the second to the first
646
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
647
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
648
+		$action     = $action !== '-1' ? $action : $action2;
649
+		$req_action = $action !== '-1' ? $action : 'default';
650
+
651
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
652
+		// then let's use the route as the action.
653
+		// This covers cases where we're coming in from a list table that isn't on the default route.
654
+		$route             = $this->request->getRequestParam('route');
655
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
656
+			? $route
657
+			: $req_action;
658
+
659
+		$this->_current_view = $this->_req_action;
660
+		$this->_req_nonce    = $this->_req_action . '_nonce';
661
+		$this->_define_page_props();
662
+		$this->_current_page_view_url = add_query_arg(
663
+			['page' => $this->_current_page, 'action' => $this->_current_view],
664
+			$this->_admin_base_url
665
+		);
666
+		// set page configs
667
+		$this->_set_page_routes();
668
+		$this->_set_page_config();
669
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
670
+		if ($this->request->requestParamIsSet('wp_referer')) {
671
+			$wp_referer = $this->request->getRequestParam('wp_referer');
672
+			if ($wp_referer) {
673
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
674
+			}
675
+		}
676
+		// for CPT and other extended functionality.
677
+		// If there is an _extend_page_config_for_cpt
678
+		// then let's run that to modify all the various page configuration arrays.
679
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
680
+			$this->_extend_page_config_for_cpt();
681
+		}
682
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
683
+		$this->_page_routes = apply_filters(
684
+			'FHEE__' . $this->class_name . '__page_setup__page_routes',
685
+			$this->_page_routes,
686
+			$this
687
+		);
688
+		$this->_page_config = apply_filters(
689
+			'FHEE__' . $this->class_name . '__page_setup__page_config',
690
+			$this->_page_config,
691
+			$this
692
+		);
693
+		if ($this->base_class_name !== '') {
694
+			$this->_page_routes = apply_filters(
695
+				'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
696
+				$this->_page_routes,
697
+				$this
698
+			);
699
+			$this->_page_config = apply_filters(
700
+				'FHEE__' . $this->base_class_name . '__page_setup__page_config',
701
+				$this->_page_config,
702
+				$this
703
+			);
704
+		}
705
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
706
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
707
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
708
+			add_action(
709
+				'AHEE__EE_Admin_Page__route_admin_request',
710
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
711
+				10,
712
+				2
713
+			);
714
+		}
715
+		// next route only if routing enabled
716
+		if ($this->_routing && ! $this->request->isAjax()) {
717
+			$this->_verify_routes();
718
+			// next let's just check user_access and kill if no access
719
+			$this->check_user_access();
720
+			if ($this->_is_UI_request) {
721
+				// admin_init stuff - global, all views for this page class, specific view
722
+				add_action('admin_init', [$this, 'admin_init'], 10);
723
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
724
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
725
+				}
726
+			} else {
727
+				// hijack regular WP loading and route admin request immediately
728
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
729
+				$this->route_admin_request();
730
+			}
731
+		}
732
+	}
733
+
734
+
735
+	/**
736
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
737
+	 *
738
+	 * @return void
739
+	 * @throws EE_Error
740
+	 */
741
+	private function _do_other_page_hooks()
742
+	{
743
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
744
+		foreach ($registered_pages as $page) {
745
+			// now let's setup the file name and class that should be present
746
+			$classname = str_replace('.class.php', '', $page);
747
+			// autoloaders should take care of loading file
748
+			if (! class_exists($classname)) {
749
+				$error_msg[] = sprintf(
750
+					esc_html__(
751
+						'Something went wrong with loading the %s admin hooks page.',
752
+						'event_espresso'
753
+					),
754
+					$page
755
+				);
756
+				$error_msg[] = $error_msg[0]
757
+							   . "\r\n"
758
+							   . sprintf(
759
+								   esc_html__(
760
+									   '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',
761
+									   'event_espresso'
762
+								   ),
763
+								   $page,
764
+								   '<br />',
765
+								   '<strong>' . $classname . '</strong>'
766
+							   );
767
+				throw new EE_Error(implode('||', $error_msg));
768
+			}
769
+			// notice we are passing the instance of this class to the hook object.
770
+			$this->loader->getShared($classname, [$this]);
771
+		}
772
+	}
773
+
774
+
775
+	/**
776
+	 * @throws ReflectionException
777
+	 * @throws EE_Error
778
+	 */
779
+	public function load_page_dependencies()
780
+	{
781
+		try {
782
+			$this->_load_page_dependencies();
783
+		} catch (EE_Error $e) {
784
+			$e->get_error();
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 * load_page_dependencies
791
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
792
+	 *
793
+	 * @return void
794
+	 * @throws DomainException
795
+	 * @throws EE_Error
796
+	 * @throws InvalidArgumentException
797
+	 * @throws InvalidDataTypeException
798
+	 * @throws InvalidInterfaceException
799
+	 */
800
+	protected function _load_page_dependencies()
801
+	{
802
+		// let's set the current_screen and screen options to override what WP set
803
+		$this->_current_screen = get_current_screen();
804
+		// load admin_notices - global, page class, and view specific
805
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
806
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
807
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
808
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
809
+		}
810
+		// load network admin_notices - global, page class, and view specific
811
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
812
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
813
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
814
+		}
815
+		// this will save any per_page screen options if they are present
816
+		$this->_set_per_page_screen_options();
817
+		// setup list table properties
818
+		$this->_set_list_table();
819
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
820
+		// However in some cases the metaboxes will need to be added within a route handling callback.
821
+		if ($this->class_name === 'Promotions_Admin_Page') {
822
+			// hack because promos admin was loading the edited promotion object in the metaboxes callback
823
+			$this->addRegisteredMetaBoxes();
824
+		} else {
825
+			add_action('add_meta_boxes', [$this, 'addRegisteredMetaBoxes'], 99);
826
+		}
827
+		$this->_add_screen_columns();
828
+		// add screen options - global, page child class, and view specific
829
+		$this->_add_global_screen_options();
830
+		$this->_add_screen_options();
831
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
832
+		if (method_exists($this, $add_screen_options)) {
833
+			$this->{$add_screen_options}();
834
+		}
835
+		// add help tab(s) - set via page_config and qtips.
836
+		$this->_add_help_tabs();
837
+		$this->_add_qtips();
838
+		// add feature_pointers - global, page child class, and view specific
839
+		$this->_add_feature_pointers();
840
+		$this->_add_global_feature_pointers();
841
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
842
+		if (method_exists($this, $add_feature_pointer)) {
843
+			$this->{$add_feature_pointer}();
844
+		}
845
+		// enqueue scripts/styles - global, page class, and view specific
846
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
847
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
848
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
849
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
850
+		}
851
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
852
+		// admin_print_footer_scripts - global, page child class, and view specific.
853
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
854
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
855
+		// is a good use case. Notice the late priority we're giving these
856
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
857
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
858
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
859
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
860
+		}
861
+		// admin footer scripts
862
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
863
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
864
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
865
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
866
+		}
867
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
868
+		// targeted hook
869
+		do_action(
870
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
871
+		);
872
+	}
873
+
874
+
875
+	/**
876
+	 * _set_defaults
877
+	 * This sets some global defaults for class properties.
878
+	 */
879
+	private function _set_defaults()
880
+	{
881
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
882
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
883
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
884
+		$this->_page_config          = $this->_default_route_query_args = [];
885
+		$this->_default_nav_tab_name = 'overview';
886
+		// init template args
887
+		$this->set_template_args(
888
+			[
889
+				'admin_page_header'  => '',
890
+				'admin_page_content' => '',
891
+				'post_body_content'  => '',
892
+				'before_list_table'  => '',
893
+				'after_list_table'   => '',
894
+			]
895
+		);
896
+	}
897
+
898
+
899
+	/**
900
+	 * route_admin_request
901
+	 *
902
+	 * @return void
903
+	 * @throws InvalidArgumentException
904
+	 * @throws InvalidInterfaceException
905
+	 * @throws InvalidDataTypeException
906
+	 * @throws EE_Error
907
+	 * @throws ReflectionException
908
+	 * @see    _route_admin_request()
909
+	 */
910
+	public function route_admin_request()
911
+	{
912
+		try {
913
+			$this->_route_admin_request();
914
+		} catch (EE_Error $e) {
915
+			$e->get_error();
916
+		}
917
+	}
918
+
919
+
920
+	public function set_wp_page_slug($wp_page_slug)
921
+	{
922
+		$this->_wp_page_slug = $wp_page_slug;
923
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
924
+		if (is_network_admin()) {
925
+			$this->_wp_page_slug .= '-network';
926
+		}
927
+	}
928
+
929
+
930
+	/**
931
+	 * _verify_routes
932
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
933
+	 * we know if we need to drop out.
934
+	 *
935
+	 * @return bool
936
+	 * @throws EE_Error
937
+	 */
938
+	protected function _verify_routes()
939
+	{
940
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
941
+		if (! $this->_current_page && ! $this->request->isAjax()) {
942
+			return false;
943
+		}
944
+		$this->_route = false;
945
+		// check that the page_routes array is not empty
946
+		if (empty($this->_page_routes)) {
947
+			// user error msg
948
+			$error_msg = sprintf(
949
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
950
+				$this->_admin_page_title
951
+			);
952
+			// developer error msg
953
+			$error_msg .= '||' . $error_msg
954
+						  . esc_html__(
955
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
956
+							  'event_espresso'
957
+						  );
958
+			throw new EE_Error($error_msg);
959
+		}
960
+		// and that the requested page route exists
961
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
962
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
963
+			$this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
964
+		} else {
965
+			// user error msg
966
+			$error_msg = sprintf(
967
+				esc_html__(
968
+					'The requested page route does not exist for the %s admin page.',
969
+					'event_espresso'
970
+				),
971
+				$this->_admin_page_title
972
+			);
973
+			// developer error msg
974
+			$error_msg .= '||' . $error_msg
975
+						  . sprintf(
976
+							  esc_html__(
977
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
978
+								  'event_espresso'
979
+							  ),
980
+							  $this->_req_action
981
+						  );
982
+			throw new EE_Error($error_msg);
983
+		}
984
+		// and that a default route exists
985
+		if (! array_key_exists('default', $this->_page_routes)) {
986
+			// user error msg
987
+			$error_msg = sprintf(
988
+				esc_html__(
989
+					'A default page route has not been set for the % admin page.',
990
+					'event_espresso'
991
+				),
992
+				$this->_admin_page_title
993
+			);
994
+			// developer error msg
995
+			$error_msg .= '||' . $error_msg
996
+						  . esc_html__(
997
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
998
+							  'event_espresso'
999
+						  );
1000
+			throw new EE_Error($error_msg);
1001
+		}
1002
+
1003
+		// first lets' catch if the UI request has EVER been set.
1004
+		if ($this->_is_UI_request === null) {
1005
+			// lets set if this is a UI request or not.
1006
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
1007
+			// wait a minute... we might have a noheader in the route array
1008
+			$this->_is_UI_request = ! (
1009
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
1010
+			)
1011
+				? $this->_is_UI_request
1012
+				: false;
1013
+		}
1014
+		$this->_set_current_labels();
1015
+		return true;
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
1021
+	 *
1022
+	 * @param string $route the route name we're verifying
1023
+	 * @return bool we'll throw an exception if this isn't a valid route.
1024
+	 * @throws EE_Error
1025
+	 */
1026
+	protected function _verify_route($route)
1027
+	{
1028
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
1029
+			return true;
1030
+		}
1031
+		// user error msg
1032
+		$error_msg = sprintf(
1033
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
1034
+			$this->_admin_page_title
1035
+		);
1036
+		// developer error msg
1037
+		$error_msg .= '||' . $error_msg
1038
+					  . sprintf(
1039
+						  esc_html__(
1040
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
1041
+							  'event_espresso'
1042
+						  ),
1043
+						  $route
1044
+					  );
1045
+		throw new EE_Error($error_msg);
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 * perform nonce verification
1051
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1052
+	 * using this method (and save retyping!)
1053
+	 *
1054
+	 * @param string $nonce     The nonce sent
1055
+	 * @param string $nonce_ref The nonce reference string (name0)
1056
+	 * @return void
1057
+	 * @throws EE_Error
1058
+	 * @throws InvalidArgumentException
1059
+	 * @throws InvalidDataTypeException
1060
+	 * @throws InvalidInterfaceException
1061
+	 */
1062
+	protected function _verify_nonce($nonce, $nonce_ref)
1063
+	{
1064
+		// verify nonce against expected value
1065
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
1066
+			// these are not the droids you are looking for !!!
1067
+			$msg = sprintf(
1068
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
1069
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1070
+				'</a>'
1071
+			);
1072
+			if (WP_DEBUG) {
1073
+				$msg .= "\n  ";
1074
+				$msg .= sprintf(
1075
+					esc_html__(
1076
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1077
+						'event_espresso'
1078
+					),
1079
+					__CLASS__
1080
+				);
1081
+			}
1082
+			if (! $this->request->isAjax()) {
1083
+				wp_die($msg);
1084
+			}
1085
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1086
+			$this->_return_json();
1087
+		}
1088
+	}
1089
+
1090
+
1091
+	/**
1092
+	 * _route_admin_request()
1093
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1094
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1095
+	 * in the page routes and then will try to load the corresponding method.
1096
+	 *
1097
+	 * @return void
1098
+	 * @throws EE_Error
1099
+	 * @throws InvalidArgumentException
1100
+	 * @throws InvalidDataTypeException
1101
+	 * @throws InvalidInterfaceException
1102
+	 * @throws ReflectionException
1103
+	 */
1104
+	protected function _route_admin_request()
1105
+	{
1106
+		if (! $this->_is_UI_request) {
1107
+			$this->_verify_routes();
1108
+		}
1109
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1110
+		if ($this->_req_action !== 'default' && $nonce_check) {
1111
+			// set nonce from post data
1112
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1113
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1114
+		}
1115
+		// set the nav_tabs array but ONLY if this is  UI_request
1116
+		if ($this->_is_UI_request) {
1117
+			$this->_set_nav_tabs();
1118
+		}
1119
+		// grab callback function
1120
+		$func = is_array($this->_route) && isset($this->_route['func'])
1121
+			? $this->_route['func']
1122
+			: $this->_route;
1123
+		// check if callback has args
1124
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1125
+		// action right before calling route
1126
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1127
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1128
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1129
+		}
1130
+		// strip _wp_http_referer from the server REQUEST_URI
1131
+		// else it grows in length on every submission due to recursion,
1132
+		// ultimately causing a "Request-URI Too Large" error
1133
+		$this->request->unSetRequestParam('_wp_http_referer');
1134
+		$this->request->unSetServerParam('_wp_http_referer');
1135
+		$cleaner_request_uri = remove_query_arg(
1136
+			'_wp_http_referer',
1137
+			wp_unslash($this->request->getServerParam('REQUEST_URI'))
1138
+		);
1139
+		$this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri, true);
1140
+		$this->request->setServerParam('REQUEST_URI', $cleaner_request_uri, true);
1141
+		$route_callback = [];
1142
+		if (! empty($func)) {
1143
+			if (is_array($func)) {
1144
+				$route_callback = $func;
1145
+			} elseif (is_string($func)) {
1146
+				if (strpos($func, '::') !== false) {
1147
+					$route_callback = explode('::', $func);
1148
+				} elseif (method_exists($this, $func)) {
1149
+					$route_callback = [$this, $func];
1150
+				} else {
1151
+					$route_callback = $func;
1152
+				}
1153
+			}
1154
+			[$class, $method] = $route_callback;
1155
+			// is it neither a class method NOR a standalone function?
1156
+			if (! is_callable($route_callback)) {
1157
+				// user error msg
1158
+				$error_msg = esc_html__(
1159
+					'An error occurred. The  requested page route could not be found.',
1160
+					'event_espresso'
1161
+				);
1162
+				// developer error msg
1163
+				$error_msg .= '||';
1164
+				$error_msg .= sprintf(
1165
+					esc_html__(
1166
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1167
+						'event_espresso'
1168
+					),
1169
+					$method
1170
+				);
1171
+				throw new DomainException($error_msg);
1172
+			}
1173
+			if ($class !== $this && ! in_array($this, $args)) {
1174
+				// send along this admin page object for access by addons.
1175
+				$args['admin_page'] = $this;
1176
+			}
1177
+			try {
1178
+				call_user_func_array($route_callback, $args);
1179
+			} catch (Throwable $throwable) {
1180
+				$arg_keys = array_keys($args);
1181
+				$nice_args = [];
1182
+				foreach ($args as $key => $arg) {
1183
+					$nice_args[ $key ] = is_object($arg) ? get_class($arg) : $arg_keys[ $key ];
1184
+				}
1185
+				new ExceptionStackTraceDisplay(
1186
+						new RuntimeException(
1187
+							sprintf(
1188
+								esc_html__(
1189
+									'Page route "%1$s" with the supplied arguments (%2$s) threw the following exception: %3$s',
1190
+									'event_espresso'
1191
+								),
1192
+								$method,
1193
+								implode(', ', $nice_args),
1194
+								$throwable->getMessage()
1195
+							),
1196
+							$throwable->getCode(),
1197
+							$throwable
1198
+						)
1199
+				);
1200
+			}
1201
+		}
1202
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1203
+		// then we need to reset the routing properties to the new route.
1204
+		// 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.
1205
+		if (
1206
+			$this->_is_UI_request === false
1207
+			&& is_array($this->_route)
1208
+			&& ! empty($this->_route['headers_sent_route'])
1209
+		) {
1210
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1211
+		}
1212
+	}
1213
+
1214
+
1215
+	/**
1216
+	 * This method just allows the resetting of page properties in the case where a no headers
1217
+	 * route redirects to a headers route in its route config.
1218
+	 *
1219
+	 * @param string $new_route New (non header) route to redirect to.
1220
+	 * @return   void
1221
+	 * @throws ReflectionException
1222
+	 * @throws InvalidArgumentException
1223
+	 * @throws InvalidInterfaceException
1224
+	 * @throws InvalidDataTypeException
1225
+	 * @throws EE_Error
1226
+	 * @since   4.3.0
1227
+	 */
1228
+	protected function _reset_routing_properties($new_route)
1229
+	{
1230
+		$this->_is_UI_request = true;
1231
+		// now we set the current route to whatever the headers_sent_route is set at
1232
+		$this->request->setRequestParam('action', $new_route);
1233
+		// rerun page setup
1234
+		$this->_page_setup();
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 * _add_query_arg
1240
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1241
+	 *(internally just uses EEH_URL's function with the same name)
1242
+	 *
1243
+	 * @param array  $args
1244
+	 * @param string $url
1245
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1246
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1247
+	 *                                        Example usage: If the current page is:
1248
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1249
+	 *                                        &action=default&event_id=20&month_range=March%202015
1250
+	 *                                        &_wpnonce=5467821
1251
+	 *                                        and you call:
1252
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1253
+	 *                                        array(
1254
+	 *                                        'action' => 'resend_something',
1255
+	 *                                        'page=>espresso_registrations'
1256
+	 *                                        ),
1257
+	 *                                        $some_url,
1258
+	 *                                        true
1259
+	 *                                        );
1260
+	 *                                        It will produce a url in this structure:
1261
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1262
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1263
+	 *                                        month_range]=March%202015
1264
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1265
+	 * @param int    $context
1266
+	 * @return string
1267
+	 */
1268
+	public static function add_query_args_and_nonce(
1269
+		$args = [],
1270
+		$url = '',
1271
+		$sticky = false,
1272
+		$exclude_nonce = false,
1273
+		int $context = EEH_URL::CONTEXT_NONE
1274
+	) {
1275
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1276
+		if ($sticky) {
1277
+			/** @var RequestInterface $request */
1278
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1279
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1280
+			$request->unSetServerParam('_wp_http_referer', true);
1281
+			foreach ($request->requestParams() as $key => $value) {
1282
+				// do not add nonces
1283
+				if (strpos($key, 'nonce') !== false) {
1284
+					continue;
1285
+				}
1286
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1287
+			}
1288
+		}
1289
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce, $context);
1290
+	}
1291
+
1292
+
1293
+	/**
1294
+	 * This returns a generated link that will load the related help tab.
1295
+	 *
1296
+	 * @param string $help_tab_id the id for the connected help tab
1297
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1298
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1299
+	 * @return string              generated link
1300
+	 * @uses EEH_Template::get_help_tab_link()
1301
+	 */
1302
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1303
+	{
1304
+		return EEH_Template::get_help_tab_link(
1305
+			$help_tab_id,
1306
+			$this->page_slug,
1307
+			$this->_req_action,
1308
+			$icon_style,
1309
+			$help_text
1310
+		);
1311
+	}
1312
+
1313
+
1314
+	/**
1315
+	 * _add_help_tabs
1316
+	 * Note child classes define their help tabs within the page_config array.
1317
+	 *
1318
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1319
+	 * @return void
1320
+	 * @throws DomainException
1321
+	 * @throws EE_Error
1322
+	 * @throws ReflectionException
1323
+	 */
1324
+	protected function _add_help_tabs()
1325
+	{
1326
+		if (isset($this->_page_config[ $this->_req_action ])) {
1327
+			$config = $this->_page_config[ $this->_req_action ];
1328
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1329
+			if (is_array($config) && isset($config['help_sidebar'])) {
1330
+				// check that the callback given is valid
1331
+				if (! method_exists($this, $config['help_sidebar'])) {
1332
+					throw new EE_Error(
1333
+						sprintf(
1334
+							esc_html__(
1335
+								'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',
1336
+								'event_espresso'
1337
+							),
1338
+							$config['help_sidebar'],
1339
+							$this->class_name
1340
+						)
1341
+					);
1342
+				}
1343
+				$content = apply_filters(
1344
+					'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1345
+					$this->{$config['help_sidebar']}()
1346
+				);
1347
+				$this->_current_screen->set_help_sidebar($content);
1348
+			}
1349
+			if (! isset($config['help_tabs'])) {
1350
+				return;
1351
+			} //no help tabs for this route
1352
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1353
+				// we're here so there ARE help tabs!
1354
+				// make sure we've got what we need
1355
+				if (! isset($cfg['title'])) {
1356
+					throw new EE_Error(
1357
+						esc_html__(
1358
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1359
+							'event_espresso'
1360
+						)
1361
+					);
1362
+				}
1363
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1364
+					throw new EE_Error(
1365
+						esc_html__(
1366
+							'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',
1367
+							'event_espresso'
1368
+						)
1369
+					);
1370
+				}
1371
+				// first priority goes to content.
1372
+				if (! empty($cfg['content'])) {
1373
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1374
+					// second priority goes to filename
1375
+				} elseif (! empty($cfg['filename'])) {
1376
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1377
+					// 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)
1378
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1379
+															 . basename($this->_get_dir())
1380
+															 . '/help_tabs/'
1381
+															 . $cfg['filename']
1382
+															 . '.help_tab.php' : $file_path;
1383
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1384
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1385
+						EE_Error::add_error(
1386
+							sprintf(
1387
+								esc_html__(
1388
+									'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',
1389
+									'event_espresso'
1390
+								),
1391
+								$tab_id,
1392
+								key($config),
1393
+								$file_path
1394
+							),
1395
+							__FILE__,
1396
+							__FUNCTION__,
1397
+							__LINE__
1398
+						);
1399
+						return;
1400
+					}
1401
+					$template_args['admin_page_obj'] = $this;
1402
+					$content                         = EEH_Template::display_template(
1403
+						$file_path,
1404
+						$template_args,
1405
+						true
1406
+					);
1407
+				} else {
1408
+					$content = '';
1409
+				}
1410
+				// check if callback is valid
1411
+				if (
1412
+					empty($content)
1413
+					&& (
1414
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1415
+					)
1416
+				) {
1417
+					EE_Error::add_error(
1418
+						sprintf(
1419
+							esc_html__(
1420
+								'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.',
1421
+								'event_espresso'
1422
+							),
1423
+							$cfg['title']
1424
+						),
1425
+						__FILE__,
1426
+						__FUNCTION__,
1427
+						__LINE__
1428
+					);
1429
+					return;
1430
+				}
1431
+				// setup config array for help tab method
1432
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1433
+				$_ht = [
1434
+					'id'       => $id,
1435
+					'title'    => $cfg['title'],
1436
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1437
+					'content'  => $content,
1438
+				];
1439
+				$this->_current_screen->add_help_tab($_ht);
1440
+			}
1441
+		}
1442
+	}
1443
+
1444
+
1445
+	/**
1446
+	 * This simply sets up any qtips that have been defined in the page config
1447
+	 *
1448
+	 * @return void
1449
+	 * @throws ReflectionException
1450
+	 * @throws EE_Error
1451
+	 */
1452
+	protected function _add_qtips()
1453
+	{
1454
+		if (isset($this->_route_config['qtips'])) {
1455
+			$qtips = (array) $this->_route_config['qtips'];
1456
+			// load qtip loader
1457
+			$path = [
1458
+				$this->_get_dir() . '/qtips/',
1459
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1460
+			];
1461
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1462
+		}
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * _set_nav_tabs
1468
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1469
+	 * wish to add additional tabs or modify accordingly.
1470
+	 *
1471
+	 * @return void
1472
+	 * @throws InvalidArgumentException
1473
+	 * @throws InvalidInterfaceException
1474
+	 * @throws InvalidDataTypeException
1475
+	 */
1476
+	protected function _set_nav_tabs()
1477
+	{
1478
+		$i        = 0;
1479
+		$only_tab = count($this->_page_config) < 2;
1480
+		foreach ($this->_page_config as $slug => $config) {
1481
+			if (! is_array($config) || empty($config['nav'])) {
1482
+				continue;
1483
+			}
1484
+			// no nav tab for this config
1485
+			// check for persistent flag
1486
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1487
+				// nav tab is only to appear when route requested.
1488
+				continue;
1489
+			}
1490
+			if (! $this->check_user_access($slug, true)) {
1491
+				// no nav tab because current user does not have access.
1492
+				continue;
1493
+			}
1494
+			$css_class = $config['css_class'] ?? '';
1495
+			$css_class .= $only_tab ? ' ee-only-tab' : '';
1496
+			$css_class .= " ee-nav-tab__$slug";
1497
+
1498
+			$this->_nav_tabs[ $slug ] = [
1499
+				'url'       => $config['nav']['url'] ?? EE_Admin_Page::add_query_args_and_nonce(
1500
+						['action' => $slug],
1501
+						$this->_admin_base_url
1502
+					),
1503
+				'link_text' => $this->navTabLabel($config['nav'], $slug),
1504
+				'css_class' => $this->_req_action === $slug ? $css_class . ' nav-tab-active' : $css_class,
1505
+				'order'     => $config['nav']['order'] ?? $i,
1506
+			];
1507
+			$i++;
1508
+		}
1509
+		// if $this->_nav_tabs is empty then lets set the default
1510
+		if (empty($this->_nav_tabs)) {
1511
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1512
+				'url'       => $this->_admin_base_url,
1513
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1514
+				'css_class' => 'nav-tab-active',
1515
+				'order'     => 10,
1516
+			];
1517
+		}
1518
+		// now let's sort the tabs according to order
1519
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1520
+	}
1521
+
1522
+
1523
+	private function navTabLabel(array $nav_tab, string $slug): string
1524
+	{
1525
+		$label = $nav_tab['label'] ?? ucwords(str_replace('_', ' ', $slug));
1526
+		$icon  = $nav_tab['icon'] ?? null;
1527
+		$icon  = $icon ? '<span class="dashicons ' . $icon . '"></span>' : '';
1528
+		return '
1529 1529
             <span class="ee-admin-screen-tab__label">
1530 1530
                 ' . $icon . '
1531 1531
                 <span class="ee-nav-label__text">' . $label . '</span>
1532 1532
             </span>';
1533
-    }
1534
-
1535
-
1536
-    /**
1537
-     * _set_current_labels
1538
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1539
-     * property array
1540
-     *
1541
-     * @return void
1542
-     */
1543
-    private function _set_current_labels()
1544
-    {
1545
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1546
-            foreach ($this->_route_config['labels'] as $label => $text) {
1547
-                if (is_array($text)) {
1548
-                    foreach ($text as $sublabel => $subtext) {
1549
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1550
-                    }
1551
-                } else {
1552
-                    $this->_labels[ $label ] = $text;
1553
-                }
1554
-            }
1555
-        }
1556
-    }
1557
-
1558
-
1559
-    /**
1560
-     *        verifies user access for this admin page
1561
-     *
1562
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1563
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1564
-     *                               return false if verify fail.
1565
-     * @return bool
1566
-     * @throws InvalidArgumentException
1567
-     * @throws InvalidDataTypeException
1568
-     * @throws InvalidInterfaceException
1569
-     */
1570
-    public function check_user_access($route_to_check = '', $verify_only = false)
1571
-    {
1572
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1573
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1574
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1575
-                          && is_array($this->_page_routes[ $route_to_check ])
1576
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1577
-            ? $this->_page_routes[ $route_to_check ]['capability']
1578
-            : null;
1579
-
1580
-        if (empty($capability) && empty($route_to_check)) {
1581
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1582
-                : $this->_route['capability'];
1583
-        } else {
1584
-            $capability = empty($capability) ? 'manage_options' : $capability;
1585
-        }
1586
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1587
-        if (
1588
-            ! $this->request->isAjax()
1589
-            && (
1590
-                ! function_exists('is_admin')
1591
-                || ! EE_Registry::instance()->CAP->current_user_can(
1592
-                    $capability,
1593
-                    $this->page_slug
1594
-                    . '_'
1595
-                    . $route_to_check,
1596
-                    $id
1597
-                )
1598
-            )
1599
-        ) {
1600
-            if ($verify_only) {
1601
-                return false;
1602
-            }
1603
-            if (is_user_logged_in()) {
1604
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1605
-            } else {
1606
-                return false;
1607
-            }
1608
-        }
1609
-        return true;
1610
-    }
1611
-
1612
-
1613
-    /**
1614
-     * @param string                 $box_id
1615
-     * @param string                 $title
1616
-     * @param callable|string|null   $callback
1617
-     * @param string|array|WP_Screen $screen
1618
-     * @param string                 $context
1619
-     * @param string                 $priority
1620
-     * @param array|null             $callback_args
1621
-     */
1622
-    protected function addMetaBox(
1623
-        string $box_id,
1624
-        string $title,
1625
-        $callback,
1626
-        $screen,
1627
-        string $context = 'normal',
1628
-        string $priority = 'default',
1629
-        ?array $callback_args = null
1630
-    ) {
1631
-        if (! (is_callable($callback) || ! function_exists($callback))) {
1632
-            return;
1633
-        }
1634
-
1635
-        add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1636
-        add_filter(
1637
-            "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1638
-            function ($classes) {
1639
-                $classes[] = 'ee-admin-container';
1640
-                return $classes;
1641
-            }
1642
-        );
1643
-    }
1644
-
1645
-
1646
-    /**
1647
-     * admin_init_global
1648
-     * This runs all the code that we want executed within the WP admin_init hook.
1649
-     * This method executes for ALL EE Admin pages.
1650
-     *
1651
-     * @return void
1652
-     */
1653
-    public function admin_init_global()
1654
-    {
1655
-    }
1656
-
1657
-
1658
-    /**
1659
-     * wp_loaded_global
1660
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1661
-     * EE_Admin page and will execute on every EE Admin Page load
1662
-     *
1663
-     * @return void
1664
-     */
1665
-    public function wp_loaded()
1666
-    {
1667
-    }
1668
-
1669
-
1670
-    /**
1671
-     * admin_notices
1672
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1673
-     * ALL EE_Admin pages.
1674
-     *
1675
-     * @return void
1676
-     */
1677
-    public function admin_notices_global()
1678
-    {
1679
-        $this->_display_no_javascript_warning();
1680
-        $this->_display_espresso_notices();
1681
-    }
1682
-
1683
-
1684
-    public function network_admin_notices_global()
1685
-    {
1686
-        $this->_display_no_javascript_warning();
1687
-        $this->_display_espresso_notices();
1688
-    }
1689
-
1690
-
1691
-    /**
1692
-     * admin_footer_scripts_global
1693
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1694
-     * will apply on ALL EE_Admin pages.
1695
-     *
1696
-     * @return void
1697
-     */
1698
-    public function admin_footer_scripts_global()
1699
-    {
1700
-        $this->_add_admin_page_ajax_loading_img();
1701
-        $this->_add_admin_page_overlay();
1702
-        // if metaboxes are present we need to add the nonce field
1703
-        if (
1704
-            isset($this->_route_config['metaboxes'])
1705
-            || isset($this->_route_config['list_table'])
1706
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1707
-        ) {
1708
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1709
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1710
-        }
1711
-    }
1712
-
1713
-
1714
-    /**
1715
-     * admin_footer_global
1716
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1717
-     * This particular method will apply on ALL EE_Admin Pages.
1718
-     *
1719
-     * @return void
1720
-     */
1721
-    public function admin_footer_global()
1722
-    {
1723
-        // dialog container for dialog helper
1724
-        echo '
1533
+	}
1534
+
1535
+
1536
+	/**
1537
+	 * _set_current_labels
1538
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1539
+	 * property array
1540
+	 *
1541
+	 * @return void
1542
+	 */
1543
+	private function _set_current_labels()
1544
+	{
1545
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1546
+			foreach ($this->_route_config['labels'] as $label => $text) {
1547
+				if (is_array($text)) {
1548
+					foreach ($text as $sublabel => $subtext) {
1549
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1550
+					}
1551
+				} else {
1552
+					$this->_labels[ $label ] = $text;
1553
+				}
1554
+			}
1555
+		}
1556
+	}
1557
+
1558
+
1559
+	/**
1560
+	 *        verifies user access for this admin page
1561
+	 *
1562
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1563
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1564
+	 *                               return false if verify fail.
1565
+	 * @return bool
1566
+	 * @throws InvalidArgumentException
1567
+	 * @throws InvalidDataTypeException
1568
+	 * @throws InvalidInterfaceException
1569
+	 */
1570
+	public function check_user_access($route_to_check = '', $verify_only = false)
1571
+	{
1572
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1573
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1574
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1575
+						  && is_array($this->_page_routes[ $route_to_check ])
1576
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1577
+			? $this->_page_routes[ $route_to_check ]['capability']
1578
+			: null;
1579
+
1580
+		if (empty($capability) && empty($route_to_check)) {
1581
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1582
+				: $this->_route['capability'];
1583
+		} else {
1584
+			$capability = empty($capability) ? 'manage_options' : $capability;
1585
+		}
1586
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1587
+		if (
1588
+			! $this->request->isAjax()
1589
+			&& (
1590
+				! function_exists('is_admin')
1591
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1592
+					$capability,
1593
+					$this->page_slug
1594
+					. '_'
1595
+					. $route_to_check,
1596
+					$id
1597
+				)
1598
+			)
1599
+		) {
1600
+			if ($verify_only) {
1601
+				return false;
1602
+			}
1603
+			if (is_user_logged_in()) {
1604
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1605
+			} else {
1606
+				return false;
1607
+			}
1608
+		}
1609
+		return true;
1610
+	}
1611
+
1612
+
1613
+	/**
1614
+	 * @param string                 $box_id
1615
+	 * @param string                 $title
1616
+	 * @param callable|string|null   $callback
1617
+	 * @param string|array|WP_Screen $screen
1618
+	 * @param string                 $context
1619
+	 * @param string                 $priority
1620
+	 * @param array|null             $callback_args
1621
+	 */
1622
+	protected function addMetaBox(
1623
+		string $box_id,
1624
+		string $title,
1625
+		$callback,
1626
+		$screen,
1627
+		string $context = 'normal',
1628
+		string $priority = 'default',
1629
+		?array $callback_args = null
1630
+	) {
1631
+		if (! (is_callable($callback) || ! function_exists($callback))) {
1632
+			return;
1633
+		}
1634
+
1635
+		add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1636
+		add_filter(
1637
+			"postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1638
+			function ($classes) {
1639
+				$classes[] = 'ee-admin-container';
1640
+				return $classes;
1641
+			}
1642
+		);
1643
+	}
1644
+
1645
+
1646
+	/**
1647
+	 * admin_init_global
1648
+	 * This runs all the code that we want executed within the WP admin_init hook.
1649
+	 * This method executes for ALL EE Admin pages.
1650
+	 *
1651
+	 * @return void
1652
+	 */
1653
+	public function admin_init_global()
1654
+	{
1655
+	}
1656
+
1657
+
1658
+	/**
1659
+	 * wp_loaded_global
1660
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1661
+	 * EE_Admin page and will execute on every EE Admin Page load
1662
+	 *
1663
+	 * @return void
1664
+	 */
1665
+	public function wp_loaded()
1666
+	{
1667
+	}
1668
+
1669
+
1670
+	/**
1671
+	 * admin_notices
1672
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1673
+	 * ALL EE_Admin pages.
1674
+	 *
1675
+	 * @return void
1676
+	 */
1677
+	public function admin_notices_global()
1678
+	{
1679
+		$this->_display_no_javascript_warning();
1680
+		$this->_display_espresso_notices();
1681
+	}
1682
+
1683
+
1684
+	public function network_admin_notices_global()
1685
+	{
1686
+		$this->_display_no_javascript_warning();
1687
+		$this->_display_espresso_notices();
1688
+	}
1689
+
1690
+
1691
+	/**
1692
+	 * admin_footer_scripts_global
1693
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1694
+	 * will apply on ALL EE_Admin pages.
1695
+	 *
1696
+	 * @return void
1697
+	 */
1698
+	public function admin_footer_scripts_global()
1699
+	{
1700
+		$this->_add_admin_page_ajax_loading_img();
1701
+		$this->_add_admin_page_overlay();
1702
+		// if metaboxes are present we need to add the nonce field
1703
+		if (
1704
+			isset($this->_route_config['metaboxes'])
1705
+			|| isset($this->_route_config['list_table'])
1706
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1707
+		) {
1708
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1709
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1710
+		}
1711
+	}
1712
+
1713
+
1714
+	/**
1715
+	 * admin_footer_global
1716
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1717
+	 * This particular method will apply on ALL EE_Admin Pages.
1718
+	 *
1719
+	 * @return void
1720
+	 */
1721
+	public function admin_footer_global()
1722
+	{
1723
+		// dialog container for dialog helper
1724
+		echo '
1725 1725
         <div class="ee-admin-dialog-container auto-hide hidden">
1726 1726
             <div class="ee-notices"></div>
1727 1727
             <div class="ee-admin-dialog-container-inner-content"></div>
1728 1728
         </div>
1729 1729
         ';
1730 1730
 
1731
-        // current set timezone for timezone js
1732
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1733
-    }
1734
-
1735
-
1736
-    /**
1737
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1738
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1739
-     * help popups then in your templates or your content you set "triggers" for the content using the
1740
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1741
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1742
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1743
-     * for the
1744
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1745
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1746
-     *    'help_trigger_id' => array(
1747
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1748
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1749
-     *    )
1750
-     * );
1751
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1752
-     *
1753
-     * @param array $help_array
1754
-     * @param bool  $display
1755
-     * @return string content
1756
-     * @throws DomainException
1757
-     * @throws EE_Error
1758
-     */
1759
-    protected function _set_help_popup_content($help_array = [], $display = false)
1760
-    {
1761
-        $content    = '';
1762
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1763
-        // loop through the array and setup content
1764
-        foreach ($help_array as $trigger => $help) {
1765
-            // make sure the array is setup properly
1766
-            if (! isset($help['title'], $help['content'])) {
1767
-                throw new EE_Error(
1768
-                    esc_html__(
1769
-                        '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',
1770
-                        'event_espresso'
1771
-                    )
1772
-                );
1773
-            }
1774
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1775
-            $template_args = [
1776
-                'help_popup_id'      => $trigger,
1777
-                'help_popup_title'   => $help['title'],
1778
-                'help_popup_content' => $help['content'],
1779
-            ];
1780
-            $content       .= EEH_Template::display_template(
1781
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1782
-                $template_args,
1783
-                true
1784
-            );
1785
-        }
1786
-        if ($display) {
1787
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1788
-            return '';
1789
-        }
1790
-        return $content;
1791
-    }
1792
-
1793
-
1794
-    /**
1795
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1796
-     *
1797
-     * @return array properly formatted array for help popup content
1798
-     * @throws EE_Error
1799
-     */
1800
-    private function _get_help_content()
1801
-    {
1802
-        // what is the method we're looking for?
1803
-        $method_name = '_help_popup_content_' . $this->_req_action;
1804
-        // if method doesn't exist let's get out.
1805
-        if (! method_exists($this, $method_name)) {
1806
-            return [];
1807
-        }
1808
-        // k we're good to go let's retrieve the help array
1809
-        $help_array = $this->{$method_name}();
1810
-        // make sure we've got an array!
1811
-        if (! is_array($help_array)) {
1812
-            throw new EE_Error(
1813
-                esc_html__(
1814
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1815
-                    'event_espresso'
1816
-                )
1817
-            );
1818
-        }
1819
-        return $help_array;
1820
-    }
1821
-
1822
-
1823
-    /**
1824
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1825
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1826
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1827
-     *
1828
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1829
-     * @param boolean $display    if false then we return the trigger string
1830
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1831
-     * @return string
1832
-     * @throws DomainException
1833
-     * @throws EE_Error
1834
-     */
1835
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1836
-    {
1837
-        if ($this->request->isAjax()) {
1838
-            return '';
1839
-        }
1840
-        // 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
1841
-        $help_array   = $this->_get_help_content();
1842
-        $help_content = '';
1843
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1844
-            $help_array[ $trigger_id ] = [
1845
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1846
-                'content' => esc_html__(
1847
-                    '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.)',
1848
-                    'event_espresso'
1849
-                ),
1850
-            ];
1851
-            $help_content              = $this->_set_help_popup_content($help_array);
1852
-        }
1853
-        // let's setup the trigger
1854
-        $content = '<a class="ee-dialog" href="?height='
1855
-                   . esc_attr($dimensions[0])
1856
-                   . '&width='
1857
-                   . esc_attr($dimensions[1])
1858
-                   . '&inlineId='
1859
-                   . esc_attr($trigger_id)
1860
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1861
-        $content .= $help_content;
1862
-        if ($display) {
1863
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1864
-            return '';
1865
-        }
1866
-        return $content;
1867
-    }
1868
-
1869
-
1870
-    /**
1871
-     * _add_global_screen_options
1872
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1873
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1874
-     *
1875
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1876
-     *         see also WP_Screen object documents...
1877
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1878
-     * @abstract
1879
-     * @return void
1880
-     */
1881
-    private function _add_global_screen_options()
1882
-    {
1883
-    }
1884
-
1885
-
1886
-    /**
1887
-     * _add_global_feature_pointers
1888
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1889
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1890
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1891
-     *
1892
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1893
-     *         extended) also see:
1894
-     * @link   http://eamann.com/tech/wordpress-portland/
1895
-     * @abstract
1896
-     * @return void
1897
-     */
1898
-    private function _add_global_feature_pointers()
1899
-    {
1900
-    }
1901
-
1902
-
1903
-    /**
1904
-     * load_global_scripts_styles
1905
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1906
-     *
1907
-     * @return void
1908
-     */
1909
-    public function load_global_scripts_styles()
1910
-    {
1911
-        // add debugging styles
1912
-        if (WP_DEBUG) {
1913
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1914
-        }
1915
-        // taking care of metaboxes
1916
-        if (
1917
-            empty($this->_cpt_route)
1918
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1919
-        ) {
1920
-            wp_enqueue_script('dashboard');
1921
-        }
1922
-
1923
-        wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1924
-        wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1925
-        // LOCALIZED DATA
1926
-        // localize script for ajax lazy loading
1927
-        wp_localize_script(
1928
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1929
-            'eeLazyLoadingContainers',
1930
-            apply_filters(
1931
-                'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1932
-                ['espresso_news_post_box_content']
1933
-            )
1934
-        );
1935
-        StatusChangeNotice::loadAssets();
1936
-
1937
-        add_filter(
1938
-            'admin_body_class',
1939
-            function ($classes) {
1940
-                if (strpos($classes, 'espresso-admin') === false) {
1941
-                    $classes .= ' espresso-admin';
1942
-                }
1943
-                return $classes;
1944
-            }
1945
-        );
1946
-    }
1947
-
1948
-
1949
-    /**
1950
-     *        admin_footer_scripts_eei18n_js_strings
1951
-     *
1952
-     * @return        void
1953
-     */
1954
-    public function admin_footer_scripts_eei18n_js_strings()
1955
-    {
1956
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1957
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1958
-            __(
1959
-                '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!!!',
1960
-                'event_espresso'
1961
-            )
1962
-        );
1963
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1964
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1965
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1966
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1967
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1968
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1969
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1970
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1971
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1972
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1973
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1974
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1975
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1976
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1977
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1978
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1979
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1980
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1981
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1982
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1983
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1984
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1985
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1986
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1987
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1988
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1989
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1990
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1991
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1992
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1993
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1994
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1995
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1996
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1997
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1998
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1999
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2000
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2001
-    }
2002
-
2003
-
2004
-    /**
2005
-     *        load enhanced xdebug styles for ppl with failing eyesight
2006
-     *
2007
-     * @return        void
2008
-     */
2009
-    public function add_xdebug_style()
2010
-    {
2011
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2012
-    }
2013
-
2014
-
2015
-    /************************/
2016
-    /** LIST TABLE METHODS **/
2017
-    /************************/
2018
-    /**
2019
-     * this sets up the list table if the current view requires it.
2020
-     *
2021
-     * @return void
2022
-     * @throws EE_Error
2023
-     * @throws InvalidArgumentException
2024
-     * @throws InvalidDataTypeException
2025
-     * @throws InvalidInterfaceException
2026
-     */
2027
-    protected function _set_list_table()
2028
-    {
2029
-        // first is this a list_table view?
2030
-        if (! isset($this->_route_config['list_table'])) {
2031
-            return;
2032
-        } //not a list_table view so get out.
2033
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2034
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2035
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2036
-            // user error msg
2037
-            $error_msg = esc_html__(
2038
-                'An error occurred. The requested list table views could not be found.',
2039
-                'event_espresso'
2040
-            );
2041
-            // developer error msg
2042
-            $error_msg .= '||'
2043
-                          . sprintf(
2044
-                              esc_html__(
2045
-                                  '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.',
2046
-                                  'event_espresso'
2047
-                              ),
2048
-                              $this->_req_action,
2049
-                              $list_table_view
2050
-                          );
2051
-            throw new EE_Error($error_msg);
2052
-        }
2053
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2054
-        $this->_views = apply_filters(
2055
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2056
-            $this->_views
2057
-        );
2058
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2059
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2060
-        $this->_set_list_table_view();
2061
-        $this->_set_list_table_object();
2062
-    }
2063
-
2064
-
2065
-    /**
2066
-     * set current view for List Table
2067
-     *
2068
-     * @return void
2069
-     */
2070
-    protected function _set_list_table_view()
2071
-    {
2072
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2073
-        $status      = $this->request->getRequestParam('status', null, 'key');
2074
-        $this->_view = $status && array_key_exists($status, $this->_views)
2075
-            ? $status
2076
-            : $this->_view;
2077
-    }
2078
-
2079
-
2080
-    /**
2081
-     * _set_list_table_object
2082
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2083
-     *
2084
-     * @throws InvalidInterfaceException
2085
-     * @throws InvalidArgumentException
2086
-     * @throws InvalidDataTypeException
2087
-     * @throws EE_Error
2088
-     * @throws InvalidInterfaceException
2089
-     */
2090
-    protected function _set_list_table_object()
2091
-    {
2092
-        if (isset($this->_route_config['list_table'])) {
2093
-            if (! class_exists($this->_route_config['list_table'])) {
2094
-                throw new EE_Error(
2095
-                    sprintf(
2096
-                        esc_html__(
2097
-                            '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.',
2098
-                            'event_espresso'
2099
-                        ),
2100
-                        $this->_route_config['list_table'],
2101
-                        $this->class_name
2102
-                    )
2103
-                );
2104
-            }
2105
-            $this->_list_table_object = $this->loader->getShared(
2106
-                $this->_route_config['list_table'],
2107
-                [$this]
2108
-            );
2109
-        }
2110
-    }
2111
-
2112
-
2113
-    /**
2114
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2115
-     *
2116
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2117
-     *                                                    urls.  The array should be indexed by the view it is being
2118
-     *                                                    added to.
2119
-     * @return array
2120
-     */
2121
-    public function get_list_table_view_RLs($extra_query_args = [])
2122
-    {
2123
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
-        if (empty($this->_views)) {
2125
-            $this->_views = [];
2126
-        }
2127
-        // cycle thru views
2128
-        foreach ($this->_views as $key => $view) {
2129
-            $query_args = [];
2130
-            // check for current view
2131
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2132
-            $query_args['action']                        = $this->_req_action;
2133
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2134
-            $query_args['status']                        = $view['slug'];
2135
-            // merge any other arguments sent in.
2136
-            if (isset($extra_query_args[ $view['slug'] ])) {
2137
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2138
-                    $query_args[] = $extra_query_arg;
2139
-                }
2140
-            }
2141
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2142
-        }
2143
-        return $this->_views;
2144
-    }
2145
-
2146
-
2147
-    /**
2148
-     * _entries_per_page_dropdown
2149
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2150
-     *
2151
-     * @param int $max_entries total number of rows in the table
2152
-     * @return string
2153
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2154
-     *                         WP does it.
2155
-     */
2156
-    protected function _entries_per_page_dropdown($max_entries = 0)
2157
-    {
2158
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2159
-        $values   = [10, 25, 50, 100];
2160
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2161
-        if ($max_entries) {
2162
-            $values[] = $max_entries;
2163
-            sort($values);
2164
-        }
2165
-        $entries_per_page_dropdown = '
1731
+		// current set timezone for timezone js
1732
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1733
+	}
1734
+
1735
+
1736
+	/**
1737
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1738
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1739
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1740
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1741
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1742
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1743
+	 * for the
1744
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1745
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1746
+	 *    'help_trigger_id' => array(
1747
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1748
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1749
+	 *    )
1750
+	 * );
1751
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1752
+	 *
1753
+	 * @param array $help_array
1754
+	 * @param bool  $display
1755
+	 * @return string content
1756
+	 * @throws DomainException
1757
+	 * @throws EE_Error
1758
+	 */
1759
+	protected function _set_help_popup_content($help_array = [], $display = false)
1760
+	{
1761
+		$content    = '';
1762
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1763
+		// loop through the array and setup content
1764
+		foreach ($help_array as $trigger => $help) {
1765
+			// make sure the array is setup properly
1766
+			if (! isset($help['title'], $help['content'])) {
1767
+				throw new EE_Error(
1768
+					esc_html__(
1769
+						'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',
1770
+						'event_espresso'
1771
+					)
1772
+				);
1773
+			}
1774
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1775
+			$template_args = [
1776
+				'help_popup_id'      => $trigger,
1777
+				'help_popup_title'   => $help['title'],
1778
+				'help_popup_content' => $help['content'],
1779
+			];
1780
+			$content       .= EEH_Template::display_template(
1781
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1782
+				$template_args,
1783
+				true
1784
+			);
1785
+		}
1786
+		if ($display) {
1787
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1788
+			return '';
1789
+		}
1790
+		return $content;
1791
+	}
1792
+
1793
+
1794
+	/**
1795
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1796
+	 *
1797
+	 * @return array properly formatted array for help popup content
1798
+	 * @throws EE_Error
1799
+	 */
1800
+	private function _get_help_content()
1801
+	{
1802
+		// what is the method we're looking for?
1803
+		$method_name = '_help_popup_content_' . $this->_req_action;
1804
+		// if method doesn't exist let's get out.
1805
+		if (! method_exists($this, $method_name)) {
1806
+			return [];
1807
+		}
1808
+		// k we're good to go let's retrieve the help array
1809
+		$help_array = $this->{$method_name}();
1810
+		// make sure we've got an array!
1811
+		if (! is_array($help_array)) {
1812
+			throw new EE_Error(
1813
+				esc_html__(
1814
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1815
+					'event_espresso'
1816
+				)
1817
+			);
1818
+		}
1819
+		return $help_array;
1820
+	}
1821
+
1822
+
1823
+	/**
1824
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1825
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1826
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1827
+	 *
1828
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1829
+	 * @param boolean $display    if false then we return the trigger string
1830
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1831
+	 * @return string
1832
+	 * @throws DomainException
1833
+	 * @throws EE_Error
1834
+	 */
1835
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1836
+	{
1837
+		if ($this->request->isAjax()) {
1838
+			return '';
1839
+		}
1840
+		// 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
1841
+		$help_array   = $this->_get_help_content();
1842
+		$help_content = '';
1843
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1844
+			$help_array[ $trigger_id ] = [
1845
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1846
+				'content' => esc_html__(
1847
+					'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.)',
1848
+					'event_espresso'
1849
+				),
1850
+			];
1851
+			$help_content              = $this->_set_help_popup_content($help_array);
1852
+		}
1853
+		// let's setup the trigger
1854
+		$content = '<a class="ee-dialog" href="?height='
1855
+				   . esc_attr($dimensions[0])
1856
+				   . '&width='
1857
+				   . esc_attr($dimensions[1])
1858
+				   . '&inlineId='
1859
+				   . esc_attr($trigger_id)
1860
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1861
+		$content .= $help_content;
1862
+		if ($display) {
1863
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1864
+			return '';
1865
+		}
1866
+		return $content;
1867
+	}
1868
+
1869
+
1870
+	/**
1871
+	 * _add_global_screen_options
1872
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1873
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1874
+	 *
1875
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1876
+	 *         see also WP_Screen object documents...
1877
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1878
+	 * @abstract
1879
+	 * @return void
1880
+	 */
1881
+	private function _add_global_screen_options()
1882
+	{
1883
+	}
1884
+
1885
+
1886
+	/**
1887
+	 * _add_global_feature_pointers
1888
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1889
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1890
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1891
+	 *
1892
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1893
+	 *         extended) also see:
1894
+	 * @link   http://eamann.com/tech/wordpress-portland/
1895
+	 * @abstract
1896
+	 * @return void
1897
+	 */
1898
+	private function _add_global_feature_pointers()
1899
+	{
1900
+	}
1901
+
1902
+
1903
+	/**
1904
+	 * load_global_scripts_styles
1905
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1906
+	 *
1907
+	 * @return void
1908
+	 */
1909
+	public function load_global_scripts_styles()
1910
+	{
1911
+		// add debugging styles
1912
+		if (WP_DEBUG) {
1913
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1914
+		}
1915
+		// taking care of metaboxes
1916
+		if (
1917
+			empty($this->_cpt_route)
1918
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1919
+		) {
1920
+			wp_enqueue_script('dashboard');
1921
+		}
1922
+
1923
+		wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1924
+		wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1925
+		// LOCALIZED DATA
1926
+		// localize script for ajax lazy loading
1927
+		wp_localize_script(
1928
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1929
+			'eeLazyLoadingContainers',
1930
+			apply_filters(
1931
+				'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1932
+				['espresso_news_post_box_content']
1933
+			)
1934
+		);
1935
+		StatusChangeNotice::loadAssets();
1936
+
1937
+		add_filter(
1938
+			'admin_body_class',
1939
+			function ($classes) {
1940
+				if (strpos($classes, 'espresso-admin') === false) {
1941
+					$classes .= ' espresso-admin';
1942
+				}
1943
+				return $classes;
1944
+			}
1945
+		);
1946
+	}
1947
+
1948
+
1949
+	/**
1950
+	 *        admin_footer_scripts_eei18n_js_strings
1951
+	 *
1952
+	 * @return        void
1953
+	 */
1954
+	public function admin_footer_scripts_eei18n_js_strings()
1955
+	{
1956
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1957
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1958
+			__(
1959
+				'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!!!',
1960
+				'event_espresso'
1961
+			)
1962
+		);
1963
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1964
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1965
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1966
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1967
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1968
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1969
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1970
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1971
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1972
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1973
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1974
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1975
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1976
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1977
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1978
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1979
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1980
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1981
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1982
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1983
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1984
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1985
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1986
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1987
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1988
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1989
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1990
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1991
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1992
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1993
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1994
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1995
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1996
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1997
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1998
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1999
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2000
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2001
+	}
2002
+
2003
+
2004
+	/**
2005
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2006
+	 *
2007
+	 * @return        void
2008
+	 */
2009
+	public function add_xdebug_style()
2010
+	{
2011
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2012
+	}
2013
+
2014
+
2015
+	/************************/
2016
+	/** LIST TABLE METHODS **/
2017
+	/************************/
2018
+	/**
2019
+	 * this sets up the list table if the current view requires it.
2020
+	 *
2021
+	 * @return void
2022
+	 * @throws EE_Error
2023
+	 * @throws InvalidArgumentException
2024
+	 * @throws InvalidDataTypeException
2025
+	 * @throws InvalidInterfaceException
2026
+	 */
2027
+	protected function _set_list_table()
2028
+	{
2029
+		// first is this a list_table view?
2030
+		if (! isset($this->_route_config['list_table'])) {
2031
+			return;
2032
+		} //not a list_table view so get out.
2033
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2034
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2035
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2036
+			// user error msg
2037
+			$error_msg = esc_html__(
2038
+				'An error occurred. The requested list table views could not be found.',
2039
+				'event_espresso'
2040
+			);
2041
+			// developer error msg
2042
+			$error_msg .= '||'
2043
+						  . sprintf(
2044
+							  esc_html__(
2045
+								  '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.',
2046
+								  'event_espresso'
2047
+							  ),
2048
+							  $this->_req_action,
2049
+							  $list_table_view
2050
+						  );
2051
+			throw new EE_Error($error_msg);
2052
+		}
2053
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2054
+		$this->_views = apply_filters(
2055
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2056
+			$this->_views
2057
+		);
2058
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2059
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2060
+		$this->_set_list_table_view();
2061
+		$this->_set_list_table_object();
2062
+	}
2063
+
2064
+
2065
+	/**
2066
+	 * set current view for List Table
2067
+	 *
2068
+	 * @return void
2069
+	 */
2070
+	protected function _set_list_table_view()
2071
+	{
2072
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2073
+		$status      = $this->request->getRequestParam('status', null, 'key');
2074
+		$this->_view = $status && array_key_exists($status, $this->_views)
2075
+			? $status
2076
+			: $this->_view;
2077
+	}
2078
+
2079
+
2080
+	/**
2081
+	 * _set_list_table_object
2082
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2083
+	 *
2084
+	 * @throws InvalidInterfaceException
2085
+	 * @throws InvalidArgumentException
2086
+	 * @throws InvalidDataTypeException
2087
+	 * @throws EE_Error
2088
+	 * @throws InvalidInterfaceException
2089
+	 */
2090
+	protected function _set_list_table_object()
2091
+	{
2092
+		if (isset($this->_route_config['list_table'])) {
2093
+			if (! class_exists($this->_route_config['list_table'])) {
2094
+				throw new EE_Error(
2095
+					sprintf(
2096
+						esc_html__(
2097
+							'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.',
2098
+							'event_espresso'
2099
+						),
2100
+						$this->_route_config['list_table'],
2101
+						$this->class_name
2102
+					)
2103
+				);
2104
+			}
2105
+			$this->_list_table_object = $this->loader->getShared(
2106
+				$this->_route_config['list_table'],
2107
+				[$this]
2108
+			);
2109
+		}
2110
+	}
2111
+
2112
+
2113
+	/**
2114
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2115
+	 *
2116
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2117
+	 *                                                    urls.  The array should be indexed by the view it is being
2118
+	 *                                                    added to.
2119
+	 * @return array
2120
+	 */
2121
+	public function get_list_table_view_RLs($extra_query_args = [])
2122
+	{
2123
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
+		if (empty($this->_views)) {
2125
+			$this->_views = [];
2126
+		}
2127
+		// cycle thru views
2128
+		foreach ($this->_views as $key => $view) {
2129
+			$query_args = [];
2130
+			// check for current view
2131
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2132
+			$query_args['action']                        = $this->_req_action;
2133
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2134
+			$query_args['status']                        = $view['slug'];
2135
+			// merge any other arguments sent in.
2136
+			if (isset($extra_query_args[ $view['slug'] ])) {
2137
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2138
+					$query_args[] = $extra_query_arg;
2139
+				}
2140
+			}
2141
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2142
+		}
2143
+		return $this->_views;
2144
+	}
2145
+
2146
+
2147
+	/**
2148
+	 * _entries_per_page_dropdown
2149
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2150
+	 *
2151
+	 * @param int $max_entries total number of rows in the table
2152
+	 * @return string
2153
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2154
+	 *                         WP does it.
2155
+	 */
2156
+	protected function _entries_per_page_dropdown($max_entries = 0)
2157
+	{
2158
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2159
+		$values   = [10, 25, 50, 100];
2160
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2161
+		if ($max_entries) {
2162
+			$values[] = $max_entries;
2163
+			sort($values);
2164
+		}
2165
+		$entries_per_page_dropdown = '
2166 2166
 			<div id="entries-per-page-dv" class="alignleft actions">
2167 2167
 				<label class="hide-if-no-js">
2168 2168
 					Show
2169 2169
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2170
-        foreach ($values as $value) {
2171
-            if ($value < $max_entries) {
2172
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2173
-                $entries_per_page_dropdown .= '
2170
+		foreach ($values as $value) {
2171
+			if ($value < $max_entries) {
2172
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2173
+				$entries_per_page_dropdown .= '
2174 2174
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2175
-            }
2176
-        }
2177
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2178
-        $entries_per_page_dropdown .= '
2175
+			}
2176
+		}
2177
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2178
+		$entries_per_page_dropdown .= '
2179 2179
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2180
-        $entries_per_page_dropdown .= '
2180
+		$entries_per_page_dropdown .= '
2181 2181
 					</select>
2182 2182
 					entries
2183 2183
 				</label>
2184 2184
 				<input id="entries-per-page-btn" class="button button--secondary" type="submit" value="Go" >
2185 2185
 			</div>
2186 2186
 		';
2187
-        return $entries_per_page_dropdown;
2188
-    }
2189
-
2190
-
2191
-    /**
2192
-     *        _set_search_attributes
2193
-     *
2194
-     * @return        void
2195
-     */
2196
-    public function _set_search_attributes()
2197
-    {
2198
-        $this->_template_args['search']['btn_label'] = sprintf(
2199
-            esc_html__('Search %s', 'event_espresso'),
2200
-            empty($this->_search_btn_label) ? $this->page_label
2201
-                : $this->_search_btn_label
2202
-        );
2203
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2204
-    }
2205
-
2206
-
2207
-
2208
-    /*** END LIST TABLE METHODS **/
2209
-
2210
-    /**
2211
-     * @return void
2212
-     * @throws EE_Error
2213
-     */
2214
-    public function addRegisteredMetaBoxes()
2215
-    {
2216
-        remove_action('add_meta_boxes', [$this, 'addRegisteredMetaBoxes'], 99);
2217
-        $this->_add_registered_meta_boxes();
2218
-    }
2219
-
2220
-
2221
-    /**
2222
-     * _add_registered_metaboxes
2223
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2224
-     *
2225
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2226
-     * @return void
2227
-     * @throws EE_Error
2228
-     */
2229
-    private function _add_registered_meta_boxes()
2230
-    {
2231
-        // we only add meta boxes if the page_route calls for it
2232
-        if (
2233
-            is_array($this->_route_config)
2234
-            && isset($this->_route_config['metaboxes'])
2235
-            && is_array($this->_route_config['metaboxes'])
2236
-        ) {
2237
-            // this simply loops through the callbacks provided
2238
-            // and checks if there is a corresponding callback registered by the child
2239
-            // if there is then we go ahead and process the metabox loader.
2240
-            foreach ($this->_route_config['metaboxes'] as $key => $metabox_callback) {
2241
-                // first check for Closures
2242
-                if ($metabox_callback instanceof Closure) {
2243
-                    $result = $metabox_callback();
2244
-                } elseif (is_callable($metabox_callback)) {
2245
-                    $result = call_user_func($metabox_callback);
2246
-                } elseif (method_exists($this, $metabox_callback)) {
2247
-                    $result = $this->{$metabox_callback}();
2248
-                } else {
2249
-                    $result = false;
2250
-                }
2251
-                if ($result === false) {
2252
-                    // user error msg
2253
-                    $error_msg = esc_html__(
2254
-                        'An error occurred. The  requested metabox could not be found.',
2255
-                        'event_espresso'
2256
-                    );
2257
-                    // developer error msg
2258
-                    $error_msg .= '||'
2259
-                                  . sprintf(
2260
-                                      esc_html__(
2261
-                                          '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.',
2262
-                                          'event_espresso'
2263
-                                      ),
2264
-                                      $metabox_callback
2265
-                                  );
2266
-                    throw new EE_Error($error_msg);
2267
-                }
2268
-                unset($this->_route_config['metaboxes'][ $key ]);
2269
-            }
2270
-        }
2271
-    }
2272
-
2273
-
2274
-    /**
2275
-     * _add_screen_columns
2276
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2277
-     * the dynamic column template and we'll setup the column options for the page.
2278
-     *
2279
-     * @return void
2280
-     */
2281
-    private function _add_screen_columns()
2282
-    {
2283
-        if (
2284
-            is_array($this->_route_config)
2285
-            && isset($this->_route_config['columns'])
2286
-            && is_array($this->_route_config['columns'])
2287
-            && count($this->_route_config['columns']) === 2
2288
-        ) {
2289
-            add_screen_option(
2290
-                'layout_columns',
2291
-                [
2292
-                    'max'     => (int) $this->_route_config['columns'][0],
2293
-                    'default' => (int) $this->_route_config['columns'][1],
2294
-                ]
2295
-            );
2296
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2297
-            $screen_id                                           = $this->_current_screen->id;
2298
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2299
-            $total_columns                                       = ! empty($screen_columns)
2300
-                ? $screen_columns
2301
-                : $this->_route_config['columns'][1];
2302
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2303
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2304
-            $this->_template_args['screen']                      = $this->_current_screen;
2305
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2306
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2307
-            // finally if we don't have has_metaboxes set in the route config
2308
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2309
-            $this->_route_config['has_metaboxes'] = true;
2310
-        }
2311
-    }
2312
-
2313
-
2314
-
2315
-    /** GLOBALLY AVAILABLE METABOXES **/
2316
-
2317
-
2318
-    /**
2319
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2320
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2321
-     * these get loaded on.
2322
-     */
2323
-    private function _espresso_news_post_box()
2324
-    {
2325
-        $news_box_title = apply_filters(
2326
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2327
-            esc_html__('New @ Event Espresso', 'event_espresso')
2328
-        );
2329
-        $this->addMetaBox(
2330
-            'espresso_news_post_box',
2331
-            $news_box_title,
2332
-            [
2333
-                $this,
2334
-                'espresso_news_post_box',
2335
-            ],
2336
-            $this->_wp_page_slug,
2337
-            'side',
2338
-            'low'
2339
-        );
2340
-    }
2341
-
2342
-
2343
-    /**
2344
-     * Code for setting up espresso ratings request metabox.
2345
-     */
2346
-    protected function _espresso_ratings_request()
2347
-    {
2348
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2349
-            return;
2350
-        }
2351
-        $ratings_box_title = apply_filters(
2352
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2353
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2354
-        );
2355
-        $this->addMetaBox(
2356
-            'espresso_ratings_request',
2357
-            $ratings_box_title,
2358
-            [
2359
-                $this,
2360
-                'espresso_ratings_request',
2361
-            ],
2362
-            $this->_wp_page_slug,
2363
-            'side'
2364
-        );
2365
-    }
2366
-
2367
-
2368
-    /**
2369
-     * Code for setting up espresso ratings request metabox content.
2370
-     *
2371
-     * @throws DomainException
2372
-     */
2373
-    public function espresso_ratings_request()
2374
-    {
2375
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2376
-    }
2377
-
2378
-
2379
-    public static function cached_rss_display($rss_id, $url)
2380
-    {
2381
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2382
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2383
-                     . '</p><p class="hide-if-js">'
2384
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2385
-                     . '</p>';
2386
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2387
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2388
-        $post      = '</div>' . "\n";
2389
-        $cache_key = 'ee_rss_' . md5($rss_id);
2390
-        $output    = get_transient($cache_key);
2391
-        if ($output !== false) {
2392
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2393
-            return true;
2394
-        }
2395
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2396
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2397
-            return false;
2398
-        }
2399
-        ob_start();
2400
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2401
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2402
-        return true;
2403
-    }
2404
-
2405
-
2406
-    public function espresso_news_post_box()
2407
-    {
2408
-        ?>
2187
+		return $entries_per_page_dropdown;
2188
+	}
2189
+
2190
+
2191
+	/**
2192
+	 *        _set_search_attributes
2193
+	 *
2194
+	 * @return        void
2195
+	 */
2196
+	public function _set_search_attributes()
2197
+	{
2198
+		$this->_template_args['search']['btn_label'] = sprintf(
2199
+			esc_html__('Search %s', 'event_espresso'),
2200
+			empty($this->_search_btn_label) ? $this->page_label
2201
+				: $this->_search_btn_label
2202
+		);
2203
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2204
+	}
2205
+
2206
+
2207
+
2208
+	/*** END LIST TABLE METHODS **/
2209
+
2210
+	/**
2211
+	 * @return void
2212
+	 * @throws EE_Error
2213
+	 */
2214
+	public function addRegisteredMetaBoxes()
2215
+	{
2216
+		remove_action('add_meta_boxes', [$this, 'addRegisteredMetaBoxes'], 99);
2217
+		$this->_add_registered_meta_boxes();
2218
+	}
2219
+
2220
+
2221
+	/**
2222
+	 * _add_registered_metaboxes
2223
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2224
+	 *
2225
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2226
+	 * @return void
2227
+	 * @throws EE_Error
2228
+	 */
2229
+	private function _add_registered_meta_boxes()
2230
+	{
2231
+		// we only add meta boxes if the page_route calls for it
2232
+		if (
2233
+			is_array($this->_route_config)
2234
+			&& isset($this->_route_config['metaboxes'])
2235
+			&& is_array($this->_route_config['metaboxes'])
2236
+		) {
2237
+			// this simply loops through the callbacks provided
2238
+			// and checks if there is a corresponding callback registered by the child
2239
+			// if there is then we go ahead and process the metabox loader.
2240
+			foreach ($this->_route_config['metaboxes'] as $key => $metabox_callback) {
2241
+				// first check for Closures
2242
+				if ($metabox_callback instanceof Closure) {
2243
+					$result = $metabox_callback();
2244
+				} elseif (is_callable($metabox_callback)) {
2245
+					$result = call_user_func($metabox_callback);
2246
+				} elseif (method_exists($this, $metabox_callback)) {
2247
+					$result = $this->{$metabox_callback}();
2248
+				} else {
2249
+					$result = false;
2250
+				}
2251
+				if ($result === false) {
2252
+					// user error msg
2253
+					$error_msg = esc_html__(
2254
+						'An error occurred. The  requested metabox could not be found.',
2255
+						'event_espresso'
2256
+					);
2257
+					// developer error msg
2258
+					$error_msg .= '||'
2259
+								  . sprintf(
2260
+									  esc_html__(
2261
+										  '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.',
2262
+										  'event_espresso'
2263
+									  ),
2264
+									  $metabox_callback
2265
+								  );
2266
+					throw new EE_Error($error_msg);
2267
+				}
2268
+				unset($this->_route_config['metaboxes'][ $key ]);
2269
+			}
2270
+		}
2271
+	}
2272
+
2273
+
2274
+	/**
2275
+	 * _add_screen_columns
2276
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2277
+	 * the dynamic column template and we'll setup the column options for the page.
2278
+	 *
2279
+	 * @return void
2280
+	 */
2281
+	private function _add_screen_columns()
2282
+	{
2283
+		if (
2284
+			is_array($this->_route_config)
2285
+			&& isset($this->_route_config['columns'])
2286
+			&& is_array($this->_route_config['columns'])
2287
+			&& count($this->_route_config['columns']) === 2
2288
+		) {
2289
+			add_screen_option(
2290
+				'layout_columns',
2291
+				[
2292
+					'max'     => (int) $this->_route_config['columns'][0],
2293
+					'default' => (int) $this->_route_config['columns'][1],
2294
+				]
2295
+			);
2296
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2297
+			$screen_id                                           = $this->_current_screen->id;
2298
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2299
+			$total_columns                                       = ! empty($screen_columns)
2300
+				? $screen_columns
2301
+				: $this->_route_config['columns'][1];
2302
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2303
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2304
+			$this->_template_args['screen']                      = $this->_current_screen;
2305
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2306
+																   . 'admin_details_metabox_column_wrapper.template.php';
2307
+			// finally if we don't have has_metaboxes set in the route config
2308
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2309
+			$this->_route_config['has_metaboxes'] = true;
2310
+		}
2311
+	}
2312
+
2313
+
2314
+
2315
+	/** GLOBALLY AVAILABLE METABOXES **/
2316
+
2317
+
2318
+	/**
2319
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2320
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2321
+	 * these get loaded on.
2322
+	 */
2323
+	private function _espresso_news_post_box()
2324
+	{
2325
+		$news_box_title = apply_filters(
2326
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2327
+			esc_html__('New @ Event Espresso', 'event_espresso')
2328
+		);
2329
+		$this->addMetaBox(
2330
+			'espresso_news_post_box',
2331
+			$news_box_title,
2332
+			[
2333
+				$this,
2334
+				'espresso_news_post_box',
2335
+			],
2336
+			$this->_wp_page_slug,
2337
+			'side',
2338
+			'low'
2339
+		);
2340
+	}
2341
+
2342
+
2343
+	/**
2344
+	 * Code for setting up espresso ratings request metabox.
2345
+	 */
2346
+	protected function _espresso_ratings_request()
2347
+	{
2348
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2349
+			return;
2350
+		}
2351
+		$ratings_box_title = apply_filters(
2352
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2353
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2354
+		);
2355
+		$this->addMetaBox(
2356
+			'espresso_ratings_request',
2357
+			$ratings_box_title,
2358
+			[
2359
+				$this,
2360
+				'espresso_ratings_request',
2361
+			],
2362
+			$this->_wp_page_slug,
2363
+			'side'
2364
+		);
2365
+	}
2366
+
2367
+
2368
+	/**
2369
+	 * Code for setting up espresso ratings request metabox content.
2370
+	 *
2371
+	 * @throws DomainException
2372
+	 */
2373
+	public function espresso_ratings_request()
2374
+	{
2375
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2376
+	}
2377
+
2378
+
2379
+	public static function cached_rss_display($rss_id, $url)
2380
+	{
2381
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2382
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2383
+					 . '</p><p class="hide-if-js">'
2384
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2385
+					 . '</p>';
2386
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2387
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2388
+		$post      = '</div>' . "\n";
2389
+		$cache_key = 'ee_rss_' . md5($rss_id);
2390
+		$output    = get_transient($cache_key);
2391
+		if ($output !== false) {
2392
+			echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2393
+			return true;
2394
+		}
2395
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2396
+			echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2397
+			return false;
2398
+		}
2399
+		ob_start();
2400
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2401
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2402
+		return true;
2403
+	}
2404
+
2405
+
2406
+	public function espresso_news_post_box()
2407
+	{
2408
+		?>
2409 2409
         <div class="padding">
2410 2410
             <div id="espresso_news_post_box_content" class="infolinks">
2411 2411
                 <?php
2412
-                // Get RSS Feed(s)
2413
-                EE_Admin_Page::cached_rss_display(
2414
-                    'espresso_news_post_box_content',
2415
-                    esc_url_raw(
2416
-                        apply_filters(
2417
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2418
-                            'https://eventespresso.com/feed/'
2419
-                        )
2420
-                    )
2421
-                );
2422
-                ?>
2412
+				// Get RSS Feed(s)
2413
+				EE_Admin_Page::cached_rss_display(
2414
+					'espresso_news_post_box_content',
2415
+					esc_url_raw(
2416
+						apply_filters(
2417
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2418
+							'https://eventespresso.com/feed/'
2419
+						)
2420
+					)
2421
+				);
2422
+				?>
2423 2423
             </div>
2424 2424
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2425 2425
         </div>
2426 2426
         <?php
2427
-    }
2428
-
2429
-
2430
-    private function _espresso_links_post_box()
2431
-    {
2432
-        // Hiding until we actually have content to put in here...
2433
-        // $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2434
-    }
2435
-
2436
-
2437
-    public function espresso_links_post_box()
2438
-    {
2439
-        // Hiding until we actually have content to put in here...
2440
-        // EEH_Template::display_template(
2441
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2442
-        // );
2443
-    }
2444
-
2445
-
2446
-    protected function _espresso_sponsors_post_box()
2447
-    {
2448
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2449
-            $this->addMetaBox(
2450
-                'espresso_sponsors_post_box',
2451
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2452
-                [$this, 'espresso_sponsors_post_box'],
2453
-                $this->_wp_page_slug,
2454
-                'side'
2455
-            );
2456
-        }
2457
-    }
2458
-
2459
-
2460
-    public function espresso_sponsors_post_box()
2461
-    {
2462
-        EEH_Template::display_template(
2463
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2464
-        );
2465
-    }
2466
-
2467
-
2468
-    /**
2469
-     * if there is [ 'label' => [ 'publishbox' => 'some title' ]]
2470
-     * present in the _page_config array, then we'll use that for the metabox label.
2471
-     * Otherwise we'll just use publish
2472
-     * (publishbox itself could be an array of labels indexed by routes)
2473
-     *
2474
-     * @return string
2475
-     * @since   $VID:$
2476
-     */
2477
-    protected function getPublishBoxTitle(): string
2478
-    {
2479
-        $publish_box_title = esc_html__('Publish', 'event_espresso');
2480
-        if (! empty($this->_labels['publishbox'])) {
2481
-            if (is_array($this->_labels['publishbox'])) {
2482
-                $publish_box_title = $this->_labels['publishbox'][ $this->_req_action ] ?? $publish_box_title;
2483
-            } else {
2484
-                $publish_box_title = $this->_labels['publishbox'];
2485
-            }
2486
-        }
2487
-        return apply_filters(
2488
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2489
-            $publish_box_title,
2490
-            $this->_req_action,
2491
-            $this
2492
-        );
2493
-    }
2494
-
2495
-
2496
-    /**
2497
-     * @throws EE_Error
2498
-     */
2499
-    private function _publish_post_box()
2500
-    {
2501
-        $title = $this->getPublishBoxTitle();
2502
-        if (empty($this->_template_args['save_buttons'])) {
2503
-            $this->_set_publish_post_box_vars(
2504
-                sanitize_key($title),
2505
-                "espresso_{$this->page_slug}_editor_overview",
2506
-                '',
2507
-                '',
2508
-                true
2509
-            );
2510
-        } else {
2511
-            $this->addPublishPostMetaBoxHiddenFields(
2512
-                sanitize_key($title),
2513
-                ['type' => 'hidden', 'value' => "espresso_{$this->page_slug}_editor_overview"]
2514
-            );
2515
-        }
2516
-        $this->addMetaBox(
2517
-            "espresso_{$this->page_slug}_editor_overview",
2518
-            $title,
2519
-            [$this, 'editor_overview'],
2520
-            $this->_current_screen->id,
2521
-            'side',
2522
-            'high'
2523
-        );
2524
-    }
2525
-
2526
-
2527
-    public function editor_overview()
2528
-    {
2529
-        /**
2530
-         * @var string $publish_box_extra_content
2531
-         * @var string $publish_hidden_fields
2532
-         * @var string $publish_delete_link
2533
-         * @var string $save_buttons
2534
-         */
2535
-        // if we have extra content set let's add it in if not make sure its empty
2536
-        $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2537
-        echo EEH_Template::display_template(
2538
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2539
-            $this->_template_args,
2540
-            true
2541
-        );
2542
-    }
2543
-
2544
-
2545
-    /** end of globally available metaboxes section **/
2546
-
2547
-
2548
-    /**
2549
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2550
-     * Note: currently there is no validation for this.  However, if you want the delete button, the
2551
-     * save, and save and close buttons to work properly, then you will want to include a
2552
-     * values for the name and id arguments.
2553
-     *
2554
-     * @param string|null $name                     key used for the action ID (i.e. event_id)
2555
-     * @param int|string  $id                       id attached to the item published
2556
-     * @param string|null $delete                   page route callback for the delete action
2557
-     * @param string|null $save_close_redirect_URL  custom URL to redirect to after Save & Close has been completed
2558
-     * @param boolean     $both_btns                whether to display BOTH the "Save & Close" and "Save" buttons
2559
-     *                                              or just the "Save" button
2560
-     * @throws EE_Error
2561
-     * @throws InvalidArgumentException
2562
-     * @throws InvalidDataTypeException
2563
-     * @throws InvalidInterfaceException
2564
-     * @todo  Add in validation for name/id arguments.
2565
-     */
2566
-    protected function _set_publish_post_box_vars(
2567
-        ?string $name = '',
2568
-        $id = 0,
2569
-        ?string $delete = '',
2570
-        ?string $save_close_redirect_URL = '',
2571
-        bool $both_btns = true
2572
-    ) {
2573
-        static $already_set = false;
2574
-        if ($already_set) {
2575
-            return;
2576
-        }
2577
-        $already_set = true;
2578
-        // if Save & Close, use a custom redirect URL or default to the main page?
2579
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2580
-            ? $save_close_redirect_URL
2581
-            : $this->_admin_base_url;
2582
-        // create the Save & Close and Save buttons
2583
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2584
-        // if we have extra content set let's add it in if not make sure its empty
2585
-        $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2586
-        $delete_link                                       = '';
2587
-        if ($delete && ! empty($id)) {
2588
-            // make sure we have a default if just true is sent.
2589
-            $delete      = ! empty($delete) ? $delete : 'delete';
2590
-            $delete_link = $this->get_action_link_or_button(
2591
-                $delete,
2592
-                $delete,
2593
-                [$name => $id],
2594
-                'submitdelete deletion button button--outline button--caution'
2595
-            );
2596
-        }
2597
-        $this->_template_args['publish_delete_link'] = $delete_link;
2598
-        if (! empty($name) && ! empty($id)) {
2599
-            $this->addPublishPostMetaBoxHiddenFields($name, ['type' => 'hidden', 'value' => $id]);
2600
-        }
2601
-        $hidden_fields = $this->_generate_admin_form_fields($this->publish_post_meta_box_hidden_fields, 'array');
2602
-        // add hidden fields
2603
-        $this->_template_args['publish_hidden_fields'] = $this->_template_args['publish_hidden_fields'] ?? '';
2604
-        foreach ($hidden_fields as $hidden_field) {
2605
-            $this->_template_args['publish_hidden_fields'] .= $hidden_field['field'] ?? '';
2606
-        }
2607
-    }
2608
-
2609
-
2610
-    /**
2611
-     * @param string|null $name
2612
-     * @param int|string  $id
2613
-     * @param string|null $delete
2614
-     * @param string|null $save_close_redirect_URL
2615
-     * @param bool        $both_btns
2616
-     * @throws EE_Error
2617
-     */
2618
-    public function set_publish_post_box_vars(
2619
-        ?string $name = '',
2620
-        $id = 0,
2621
-        ?string $delete = '',
2622
-        ?string $save_close_redirect_URL = '',
2623
-        bool $both_btns = false
2624
-    ) {
2625
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2626
-    }
2627
-
2628
-
2629
-    protected function addPublishPostMetaBoxHiddenFields(string $field_name, array $field_attributes)
2630
-    {
2631
-        $this->publish_post_meta_box_hidden_fields[ $field_name ] = $field_attributes;
2632
-    }
2633
-
2634
-
2635
-    /**
2636
-     * displays an error message to ppl who have javascript disabled
2637
-     *
2638
-     * @return void
2639
-     */
2640
-    private function _display_no_javascript_warning()
2641
-    {
2642
-        ?>
2427
+	}
2428
+
2429
+
2430
+	private function _espresso_links_post_box()
2431
+	{
2432
+		// Hiding until we actually have content to put in here...
2433
+		// $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2434
+	}
2435
+
2436
+
2437
+	public function espresso_links_post_box()
2438
+	{
2439
+		// Hiding until we actually have content to put in here...
2440
+		// EEH_Template::display_template(
2441
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2442
+		// );
2443
+	}
2444
+
2445
+
2446
+	protected function _espresso_sponsors_post_box()
2447
+	{
2448
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2449
+			$this->addMetaBox(
2450
+				'espresso_sponsors_post_box',
2451
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2452
+				[$this, 'espresso_sponsors_post_box'],
2453
+				$this->_wp_page_slug,
2454
+				'side'
2455
+			);
2456
+		}
2457
+	}
2458
+
2459
+
2460
+	public function espresso_sponsors_post_box()
2461
+	{
2462
+		EEH_Template::display_template(
2463
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2464
+		);
2465
+	}
2466
+
2467
+
2468
+	/**
2469
+	 * if there is [ 'label' => [ 'publishbox' => 'some title' ]]
2470
+	 * present in the _page_config array, then we'll use that for the metabox label.
2471
+	 * Otherwise we'll just use publish
2472
+	 * (publishbox itself could be an array of labels indexed by routes)
2473
+	 *
2474
+	 * @return string
2475
+	 * @since   $VID:$
2476
+	 */
2477
+	protected function getPublishBoxTitle(): string
2478
+	{
2479
+		$publish_box_title = esc_html__('Publish', 'event_espresso');
2480
+		if (! empty($this->_labels['publishbox'])) {
2481
+			if (is_array($this->_labels['publishbox'])) {
2482
+				$publish_box_title = $this->_labels['publishbox'][ $this->_req_action ] ?? $publish_box_title;
2483
+			} else {
2484
+				$publish_box_title = $this->_labels['publishbox'];
2485
+			}
2486
+		}
2487
+		return apply_filters(
2488
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2489
+			$publish_box_title,
2490
+			$this->_req_action,
2491
+			$this
2492
+		);
2493
+	}
2494
+
2495
+
2496
+	/**
2497
+	 * @throws EE_Error
2498
+	 */
2499
+	private function _publish_post_box()
2500
+	{
2501
+		$title = $this->getPublishBoxTitle();
2502
+		if (empty($this->_template_args['save_buttons'])) {
2503
+			$this->_set_publish_post_box_vars(
2504
+				sanitize_key($title),
2505
+				"espresso_{$this->page_slug}_editor_overview",
2506
+				'',
2507
+				'',
2508
+				true
2509
+			);
2510
+		} else {
2511
+			$this->addPublishPostMetaBoxHiddenFields(
2512
+				sanitize_key($title),
2513
+				['type' => 'hidden', 'value' => "espresso_{$this->page_slug}_editor_overview"]
2514
+			);
2515
+		}
2516
+		$this->addMetaBox(
2517
+			"espresso_{$this->page_slug}_editor_overview",
2518
+			$title,
2519
+			[$this, 'editor_overview'],
2520
+			$this->_current_screen->id,
2521
+			'side',
2522
+			'high'
2523
+		);
2524
+	}
2525
+
2526
+
2527
+	public function editor_overview()
2528
+	{
2529
+		/**
2530
+		 * @var string $publish_box_extra_content
2531
+		 * @var string $publish_hidden_fields
2532
+		 * @var string $publish_delete_link
2533
+		 * @var string $save_buttons
2534
+		 */
2535
+		// if we have extra content set let's add it in if not make sure its empty
2536
+		$this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2537
+		echo EEH_Template::display_template(
2538
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2539
+			$this->_template_args,
2540
+			true
2541
+		);
2542
+	}
2543
+
2544
+
2545
+	/** end of globally available metaboxes section **/
2546
+
2547
+
2548
+	/**
2549
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2550
+	 * Note: currently there is no validation for this.  However, if you want the delete button, the
2551
+	 * save, and save and close buttons to work properly, then you will want to include a
2552
+	 * values for the name and id arguments.
2553
+	 *
2554
+	 * @param string|null $name                     key used for the action ID (i.e. event_id)
2555
+	 * @param int|string  $id                       id attached to the item published
2556
+	 * @param string|null $delete                   page route callback for the delete action
2557
+	 * @param string|null $save_close_redirect_URL  custom URL to redirect to after Save & Close has been completed
2558
+	 * @param boolean     $both_btns                whether to display BOTH the "Save & Close" and "Save" buttons
2559
+	 *                                              or just the "Save" button
2560
+	 * @throws EE_Error
2561
+	 * @throws InvalidArgumentException
2562
+	 * @throws InvalidDataTypeException
2563
+	 * @throws InvalidInterfaceException
2564
+	 * @todo  Add in validation for name/id arguments.
2565
+	 */
2566
+	protected function _set_publish_post_box_vars(
2567
+		?string $name = '',
2568
+		$id = 0,
2569
+		?string $delete = '',
2570
+		?string $save_close_redirect_URL = '',
2571
+		bool $both_btns = true
2572
+	) {
2573
+		static $already_set = false;
2574
+		if ($already_set) {
2575
+			return;
2576
+		}
2577
+		$already_set = true;
2578
+		// if Save & Close, use a custom redirect URL or default to the main page?
2579
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2580
+			? $save_close_redirect_URL
2581
+			: $this->_admin_base_url;
2582
+		// create the Save & Close and Save buttons
2583
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2584
+		// if we have extra content set let's add it in if not make sure its empty
2585
+		$this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2586
+		$delete_link                                       = '';
2587
+		if ($delete && ! empty($id)) {
2588
+			// make sure we have a default if just true is sent.
2589
+			$delete      = ! empty($delete) ? $delete : 'delete';
2590
+			$delete_link = $this->get_action_link_or_button(
2591
+				$delete,
2592
+				$delete,
2593
+				[$name => $id],
2594
+				'submitdelete deletion button button--outline button--caution'
2595
+			);
2596
+		}
2597
+		$this->_template_args['publish_delete_link'] = $delete_link;
2598
+		if (! empty($name) && ! empty($id)) {
2599
+			$this->addPublishPostMetaBoxHiddenFields($name, ['type' => 'hidden', 'value' => $id]);
2600
+		}
2601
+		$hidden_fields = $this->_generate_admin_form_fields($this->publish_post_meta_box_hidden_fields, 'array');
2602
+		// add hidden fields
2603
+		$this->_template_args['publish_hidden_fields'] = $this->_template_args['publish_hidden_fields'] ?? '';
2604
+		foreach ($hidden_fields as $hidden_field) {
2605
+			$this->_template_args['publish_hidden_fields'] .= $hidden_field['field'] ?? '';
2606
+		}
2607
+	}
2608
+
2609
+
2610
+	/**
2611
+	 * @param string|null $name
2612
+	 * @param int|string  $id
2613
+	 * @param string|null $delete
2614
+	 * @param string|null $save_close_redirect_URL
2615
+	 * @param bool        $both_btns
2616
+	 * @throws EE_Error
2617
+	 */
2618
+	public function set_publish_post_box_vars(
2619
+		?string $name = '',
2620
+		$id = 0,
2621
+		?string $delete = '',
2622
+		?string $save_close_redirect_URL = '',
2623
+		bool $both_btns = false
2624
+	) {
2625
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2626
+	}
2627
+
2628
+
2629
+	protected function addPublishPostMetaBoxHiddenFields(string $field_name, array $field_attributes)
2630
+	{
2631
+		$this->publish_post_meta_box_hidden_fields[ $field_name ] = $field_attributes;
2632
+	}
2633
+
2634
+
2635
+	/**
2636
+	 * displays an error message to ppl who have javascript disabled
2637
+	 *
2638
+	 * @return void
2639
+	 */
2640
+	private function _display_no_javascript_warning()
2641
+	{
2642
+		?>
2643 2643
         <noscript>
2644 2644
             <div id="no-js-message" class="error">
2645 2645
                 <p style="font-size:1.3em;">
2646 2646
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2647 2647
                     <?php esc_html_e(
2648
-                        '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.',
2649
-                        'event_espresso'
2650
-                    ); ?>
2648
+						'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.',
2649
+						'event_espresso'
2650
+					); ?>
2651 2651
                 </p>
2652 2652
             </div>
2653 2653
         </noscript>
2654 2654
         <?php
2655
-    }
2656
-
2657
-
2658
-    /**
2659
-     * displays espresso success and/or error notices
2660
-     *
2661
-     * @return void
2662
-     */
2663
-    protected function _display_espresso_notices()
2664
-    {
2665
-        $notices = $this->_get_transient(true);
2666
-        echo stripslashes($notices);
2667
-    }
2668
-
2669
-
2670
-    /**
2671
-     * spinny things pacify the masses
2672
-     *
2673
-     * @return void
2674
-     */
2675
-    protected function _add_admin_page_ajax_loading_img()
2676
-    {
2677
-        ?>
2655
+	}
2656
+
2657
+
2658
+	/**
2659
+	 * displays espresso success and/or error notices
2660
+	 *
2661
+	 * @return void
2662
+	 */
2663
+	protected function _display_espresso_notices()
2664
+	{
2665
+		$notices = $this->_get_transient(true);
2666
+		echo stripslashes($notices);
2667
+	}
2668
+
2669
+
2670
+	/**
2671
+	 * spinny things pacify the masses
2672
+	 *
2673
+	 * @return void
2674
+	 */
2675
+	protected function _add_admin_page_ajax_loading_img()
2676
+	{
2677
+		?>
2678 2678
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2679 2679
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2680
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2680
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2681 2681
         </div>
2682 2682
         <?php
2683
-    }
2683
+	}
2684 2684
 
2685 2685
 
2686
-    /**
2687
-     * add admin page overlay for modal boxes
2688
-     *
2689
-     * @return void
2690
-     */
2691
-    protected function _add_admin_page_overlay()
2692
-    {
2693
-        ?>
2686
+	/**
2687
+	 * add admin page overlay for modal boxes
2688
+	 *
2689
+	 * @return void
2690
+	 */
2691
+	protected function _add_admin_page_overlay()
2692
+	{
2693
+		?>
2694 2694
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2695 2695
         <?php
2696
-    }
2697
-
2698
-
2699
-    /**
2700
-     * facade for $this->addMetaBox()
2701
-     *
2702
-     * @param string  $action        where the metabox gets displayed
2703
-     * @param string  $title         Title of Metabox (output in metabox header)
2704
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2705
-     *                               instead of the one created in here.
2706
-     * @param array   $callback_args an array of args supplied for the metabox
2707
-     * @param string  $column        what metabox column
2708
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2709
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2710
-     *                               created but just set our own callback for wp's add_meta_box.
2711
-     * @throws DomainException
2712
-     */
2713
-    public function _add_admin_page_meta_box(
2714
-        $action,
2715
-        $title,
2716
-        $callback,
2717
-        $callback_args,
2718
-        $column = 'normal',
2719
-        $priority = 'high',
2720
-        $create_func = true
2721
-    ) {
2722
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2723
-        // 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.
2724
-        if (empty($callback_args) && $create_func) {
2725
-            $callback_args = [
2726
-                'template_path' => $this->_template_path,
2727
-                'template_args' => $this->_template_args,
2728
-            ];
2729
-        }
2730
-        // 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)
2731
-        $call_back_func = $create_func
2732
-            ? static function ($post, $metabox) {
2733
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2734
-                echo EEH_Template::display_template(
2735
-                    $metabox['args']['template_path'],
2736
-                    $metabox['args']['template_args'],
2737
-                    true
2738
-                );
2739
-            }
2740
-            : $callback;
2741
-        $this->addMetaBox(
2742
-            str_replace('_', '-', $action) . '-mbox',
2743
-            $title,
2744
-            $call_back_func,
2745
-            $this->_wp_page_slug,
2746
-            $column,
2747
-            $priority,
2748
-            $callback_args
2749
-        );
2750
-    }
2751
-
2752
-
2753
-    /**
2754
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2755
-     *
2756
-     * @throws DomainException
2757
-     * @throws EE_Error
2758
-     * @throws InvalidArgumentException
2759
-     * @throws InvalidDataTypeException
2760
-     * @throws InvalidInterfaceException
2761
-     */
2762
-    public function display_admin_page_with_metabox_columns()
2763
-    {
2764
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2765
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2766
-            $this->_column_template_path,
2767
-            $this->_template_args,
2768
-            true
2769
-        );
2770
-        // the final wrapper
2771
-        $this->admin_page_wrapper();
2772
-    }
2773
-
2774
-
2775
-    /**
2776
-     * generates  HTML wrapper for an admin details page
2777
-     *
2778
-     * @return void
2779
-     * @throws DomainException
2780
-     * @throws EE_Error
2781
-     * @throws InvalidArgumentException
2782
-     * @throws InvalidDataTypeException
2783
-     * @throws InvalidInterfaceException
2784
-     */
2785
-    public function display_admin_page_with_sidebar()
2786
-    {
2787
-        $this->_display_admin_page(true);
2788
-    }
2789
-
2790
-
2791
-    /**
2792
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2793
-     *
2794
-     * @return void
2795
-     * @throws DomainException
2796
-     * @throws EE_Error
2797
-     * @throws InvalidArgumentException
2798
-     * @throws InvalidDataTypeException
2799
-     * @throws InvalidInterfaceException
2800
-     */
2801
-    public function display_admin_page_with_no_sidebar()
2802
-    {
2803
-        $this->_display_admin_page();
2804
-    }
2805
-
2806
-
2807
-    /**
2808
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2809
-     *
2810
-     * @return void
2811
-     * @throws DomainException
2812
-     * @throws EE_Error
2813
-     * @throws InvalidArgumentException
2814
-     * @throws InvalidDataTypeException
2815
-     * @throws InvalidInterfaceException
2816
-     */
2817
-    public function display_about_admin_page()
2818
-    {
2819
-        $this->_display_admin_page(false, true);
2820
-    }
2821
-
2822
-
2823
-    /**
2824
-     * display_admin_page
2825
-     * contains the code for actually displaying an admin page
2826
-     *
2827
-     * @param boolean $sidebar true with sidebar, false without
2828
-     * @param boolean $about   use the about admin wrapper instead of the default.
2829
-     * @return void
2830
-     * @throws DomainException
2831
-     * @throws EE_Error
2832
-     * @throws InvalidArgumentException
2833
-     * @throws InvalidDataTypeException
2834
-     * @throws InvalidInterfaceException
2835
-     */
2836
-    private function _display_admin_page($sidebar = false, $about = false)
2837
-    {
2838
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2839
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2840
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2841
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2842
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2843
-
2844
-        $post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2845
-
2846
-        $this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2847
-                                                  && $this->_req_action !== 'data_reset'
2848
-                                                  && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2849
-                                                  && strpos($post_body_content, 'wp-list-table') === false;
2850
-
2851
-        $this->_template_args['current_page']                 = $this->_wp_page_slug;
2852
-        $this->_template_args['admin_page_wrapper_div_id']    = $this->_cpt_route
2853
-            ? 'poststuff'
2854
-            : 'espresso-default-admin';
2855
-        $this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2856
-                                                                    'event-espresso_page_espresso_',
2857
-                                                                    '',
2858
-                                                                    $this->_wp_page_slug
2859
-                                                                ) . ' ' . $this->_req_action . '-route';
2860
-
2861
-        $template_path = $sidebar
2862
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2863
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2864
-        if ($this->request->isAjax()) {
2865
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2866
-        }
2867
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2868
-
2869
-        $this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2870
-        $this->_template_args['before_admin_page_content'] = $post_body_content;
2871
-        $this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2872
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2873
-            $template_path,
2874
-            $this->_template_args,
2875
-            true
2876
-        );
2877
-        // the final template wrapper
2878
-        $this->admin_page_wrapper($about);
2879
-    }
2880
-
2881
-
2882
-    /**
2883
-     * This is used to display caf preview pages.
2884
-     *
2885
-     * @param string $utm_campaign_source what is the key used for google analytics link
2886
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2887
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2888
-     * @return void
2889
-     * @throws DomainException
2890
-     * @throws EE_Error
2891
-     * @throws InvalidArgumentException
2892
-     * @throws InvalidDataTypeException
2893
-     * @throws InvalidInterfaceException
2894
-     * @since 4.3.2
2895
-     */
2896
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2897
-    {
2898
-        // let's generate a default preview action button if there isn't one already present.
2899
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2900
-            'Upgrade to Event Espresso 4 Right Now',
2901
-            'event_espresso'
2902
-        );
2903
-        $buy_now_url                                   = add_query_arg(
2904
-            [
2905
-                'ee_ver'       => 'ee4',
2906
-                'utm_source'   => 'ee4_plugin_admin',
2907
-                'utm_medium'   => 'link',
2908
-                'utm_campaign' => $utm_campaign_source,
2909
-                'utm_content'  => 'buy_now_button',
2910
-            ],
2911
-            'https://eventespresso.com/pricing/'
2912
-        );
2913
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2914
-            ? $this->get_action_link_or_button(
2915
-                '',
2916
-                'buy_now',
2917
-                [],
2918
-                'button button--primary button--big',
2919
-                esc_url_raw($buy_now_url),
2920
-                true
2921
-            )
2922
-            : $this->_template_args['preview_action_button'];
2923
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2924
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2925
-            $this->_template_args,
2926
-            true
2927
-        );
2928
-        $this->_display_admin_page($display_sidebar);
2929
-    }
2930
-
2931
-
2932
-    /**
2933
-     * display_admin_list_table_page_with_sidebar
2934
-     * generates HTML wrapper for an admin_page with list_table
2935
-     *
2936
-     * @return void
2937
-     * @throws DomainException
2938
-     * @throws EE_Error
2939
-     * @throws InvalidArgumentException
2940
-     * @throws InvalidDataTypeException
2941
-     * @throws InvalidInterfaceException
2942
-     */
2943
-    public function display_admin_list_table_page_with_sidebar()
2944
-    {
2945
-        $this->_display_admin_list_table_page(true);
2946
-    }
2947
-
2948
-
2949
-    /**
2950
-     * display_admin_list_table_page_with_no_sidebar
2951
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2952
-     *
2953
-     * @return void
2954
-     * @throws DomainException
2955
-     * @throws EE_Error
2956
-     * @throws InvalidArgumentException
2957
-     * @throws InvalidDataTypeException
2958
-     * @throws InvalidInterfaceException
2959
-     */
2960
-    public function display_admin_list_table_page_with_no_sidebar()
2961
-    {
2962
-        $this->_display_admin_list_table_page();
2963
-    }
2964
-
2965
-
2966
-    /**
2967
-     * generates html wrapper for an admin_list_table page
2968
-     *
2969
-     * @param boolean $sidebar whether to display with sidebar or not.
2970
-     * @return void
2971
-     * @throws DomainException
2972
-     * @throws EE_Error
2973
-     * @throws InvalidArgumentException
2974
-     * @throws InvalidDataTypeException
2975
-     * @throws InvalidInterfaceException
2976
-     */
2977
-    private function _display_admin_list_table_page($sidebar = false)
2978
-    {
2979
-        // setup search attributes
2980
-        $this->_set_search_attributes();
2981
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2982
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2983
-        $this->_template_args['table_url']        = $this->request->isAjax()
2984
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2985
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2986
-        $this->_template_args['list_table']       = $this->_list_table_object;
2987
-        $this->_template_args['current_route']    = $this->_req_action;
2988
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2989
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2990
-        if (! empty($ajax_sorting_callback)) {
2991
-            $sortable_list_table_form_fields = wp_nonce_field(
2992
-                $ajax_sorting_callback . '_nonce',
2993
-                $ajax_sorting_callback . '_nonce',
2994
-                false,
2995
-                false
2996
-            );
2997
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2998
-                                                . $this->page_slug
2999
-                                                . '" />';
3000
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3001
-                                                . $ajax_sorting_callback
3002
-                                                . '" />';
3003
-        } else {
3004
-            $sortable_list_table_form_fields = '';
3005
-        }
3006
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3007
-
3008
-        $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
3009
-
3010
-        $nonce_ref          = $this->_req_action . '_nonce';
3011
-        $hidden_form_fields .= '
2696
+	}
2697
+
2698
+
2699
+	/**
2700
+	 * facade for $this->addMetaBox()
2701
+	 *
2702
+	 * @param string  $action        where the metabox gets displayed
2703
+	 * @param string  $title         Title of Metabox (output in metabox header)
2704
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2705
+	 *                               instead of the one created in here.
2706
+	 * @param array   $callback_args an array of args supplied for the metabox
2707
+	 * @param string  $column        what metabox column
2708
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2709
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2710
+	 *                               created but just set our own callback for wp's add_meta_box.
2711
+	 * @throws DomainException
2712
+	 */
2713
+	public function _add_admin_page_meta_box(
2714
+		$action,
2715
+		$title,
2716
+		$callback,
2717
+		$callback_args,
2718
+		$column = 'normal',
2719
+		$priority = 'high',
2720
+		$create_func = true
2721
+	) {
2722
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2723
+		// 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.
2724
+		if (empty($callback_args) && $create_func) {
2725
+			$callback_args = [
2726
+				'template_path' => $this->_template_path,
2727
+				'template_args' => $this->_template_args,
2728
+			];
2729
+		}
2730
+		// 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)
2731
+		$call_back_func = $create_func
2732
+			? static function ($post, $metabox) {
2733
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2734
+				echo EEH_Template::display_template(
2735
+					$metabox['args']['template_path'],
2736
+					$metabox['args']['template_args'],
2737
+					true
2738
+				);
2739
+			}
2740
+			: $callback;
2741
+		$this->addMetaBox(
2742
+			str_replace('_', '-', $action) . '-mbox',
2743
+			$title,
2744
+			$call_back_func,
2745
+			$this->_wp_page_slug,
2746
+			$column,
2747
+			$priority,
2748
+			$callback_args
2749
+		);
2750
+	}
2751
+
2752
+
2753
+	/**
2754
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2755
+	 *
2756
+	 * @throws DomainException
2757
+	 * @throws EE_Error
2758
+	 * @throws InvalidArgumentException
2759
+	 * @throws InvalidDataTypeException
2760
+	 * @throws InvalidInterfaceException
2761
+	 */
2762
+	public function display_admin_page_with_metabox_columns()
2763
+	{
2764
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2765
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2766
+			$this->_column_template_path,
2767
+			$this->_template_args,
2768
+			true
2769
+		);
2770
+		// the final wrapper
2771
+		$this->admin_page_wrapper();
2772
+	}
2773
+
2774
+
2775
+	/**
2776
+	 * generates  HTML wrapper for an admin details page
2777
+	 *
2778
+	 * @return void
2779
+	 * @throws DomainException
2780
+	 * @throws EE_Error
2781
+	 * @throws InvalidArgumentException
2782
+	 * @throws InvalidDataTypeException
2783
+	 * @throws InvalidInterfaceException
2784
+	 */
2785
+	public function display_admin_page_with_sidebar()
2786
+	{
2787
+		$this->_display_admin_page(true);
2788
+	}
2789
+
2790
+
2791
+	/**
2792
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2793
+	 *
2794
+	 * @return void
2795
+	 * @throws DomainException
2796
+	 * @throws EE_Error
2797
+	 * @throws InvalidArgumentException
2798
+	 * @throws InvalidDataTypeException
2799
+	 * @throws InvalidInterfaceException
2800
+	 */
2801
+	public function display_admin_page_with_no_sidebar()
2802
+	{
2803
+		$this->_display_admin_page();
2804
+	}
2805
+
2806
+
2807
+	/**
2808
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2809
+	 *
2810
+	 * @return void
2811
+	 * @throws DomainException
2812
+	 * @throws EE_Error
2813
+	 * @throws InvalidArgumentException
2814
+	 * @throws InvalidDataTypeException
2815
+	 * @throws InvalidInterfaceException
2816
+	 */
2817
+	public function display_about_admin_page()
2818
+	{
2819
+		$this->_display_admin_page(false, true);
2820
+	}
2821
+
2822
+
2823
+	/**
2824
+	 * display_admin_page
2825
+	 * contains the code for actually displaying an admin page
2826
+	 *
2827
+	 * @param boolean $sidebar true with sidebar, false without
2828
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2829
+	 * @return void
2830
+	 * @throws DomainException
2831
+	 * @throws EE_Error
2832
+	 * @throws InvalidArgumentException
2833
+	 * @throws InvalidDataTypeException
2834
+	 * @throws InvalidInterfaceException
2835
+	 */
2836
+	private function _display_admin_page($sidebar = false, $about = false)
2837
+	{
2838
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2839
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2840
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2841
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2842
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2843
+
2844
+		$post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2845
+
2846
+		$this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2847
+												  && $this->_req_action !== 'data_reset'
2848
+												  && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2849
+												  && strpos($post_body_content, 'wp-list-table') === false;
2850
+
2851
+		$this->_template_args['current_page']                 = $this->_wp_page_slug;
2852
+		$this->_template_args['admin_page_wrapper_div_id']    = $this->_cpt_route
2853
+			? 'poststuff'
2854
+			: 'espresso-default-admin';
2855
+		$this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2856
+																	'event-espresso_page_espresso_',
2857
+																	'',
2858
+																	$this->_wp_page_slug
2859
+																) . ' ' . $this->_req_action . '-route';
2860
+
2861
+		$template_path = $sidebar
2862
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2863
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2864
+		if ($this->request->isAjax()) {
2865
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2866
+		}
2867
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2868
+
2869
+		$this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2870
+		$this->_template_args['before_admin_page_content'] = $post_body_content;
2871
+		$this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2872
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2873
+			$template_path,
2874
+			$this->_template_args,
2875
+			true
2876
+		);
2877
+		// the final template wrapper
2878
+		$this->admin_page_wrapper($about);
2879
+	}
2880
+
2881
+
2882
+	/**
2883
+	 * This is used to display caf preview pages.
2884
+	 *
2885
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2886
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2887
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2888
+	 * @return void
2889
+	 * @throws DomainException
2890
+	 * @throws EE_Error
2891
+	 * @throws InvalidArgumentException
2892
+	 * @throws InvalidDataTypeException
2893
+	 * @throws InvalidInterfaceException
2894
+	 * @since 4.3.2
2895
+	 */
2896
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2897
+	{
2898
+		// let's generate a default preview action button if there isn't one already present.
2899
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2900
+			'Upgrade to Event Espresso 4 Right Now',
2901
+			'event_espresso'
2902
+		);
2903
+		$buy_now_url                                   = add_query_arg(
2904
+			[
2905
+				'ee_ver'       => 'ee4',
2906
+				'utm_source'   => 'ee4_plugin_admin',
2907
+				'utm_medium'   => 'link',
2908
+				'utm_campaign' => $utm_campaign_source,
2909
+				'utm_content'  => 'buy_now_button',
2910
+			],
2911
+			'https://eventespresso.com/pricing/'
2912
+		);
2913
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2914
+			? $this->get_action_link_or_button(
2915
+				'',
2916
+				'buy_now',
2917
+				[],
2918
+				'button button--primary button--big',
2919
+				esc_url_raw($buy_now_url),
2920
+				true
2921
+			)
2922
+			: $this->_template_args['preview_action_button'];
2923
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2924
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2925
+			$this->_template_args,
2926
+			true
2927
+		);
2928
+		$this->_display_admin_page($display_sidebar);
2929
+	}
2930
+
2931
+
2932
+	/**
2933
+	 * display_admin_list_table_page_with_sidebar
2934
+	 * generates HTML wrapper for an admin_page with list_table
2935
+	 *
2936
+	 * @return void
2937
+	 * @throws DomainException
2938
+	 * @throws EE_Error
2939
+	 * @throws InvalidArgumentException
2940
+	 * @throws InvalidDataTypeException
2941
+	 * @throws InvalidInterfaceException
2942
+	 */
2943
+	public function display_admin_list_table_page_with_sidebar()
2944
+	{
2945
+		$this->_display_admin_list_table_page(true);
2946
+	}
2947
+
2948
+
2949
+	/**
2950
+	 * display_admin_list_table_page_with_no_sidebar
2951
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2952
+	 *
2953
+	 * @return void
2954
+	 * @throws DomainException
2955
+	 * @throws EE_Error
2956
+	 * @throws InvalidArgumentException
2957
+	 * @throws InvalidDataTypeException
2958
+	 * @throws InvalidInterfaceException
2959
+	 */
2960
+	public function display_admin_list_table_page_with_no_sidebar()
2961
+	{
2962
+		$this->_display_admin_list_table_page();
2963
+	}
2964
+
2965
+
2966
+	/**
2967
+	 * generates html wrapper for an admin_list_table page
2968
+	 *
2969
+	 * @param boolean $sidebar whether to display with sidebar or not.
2970
+	 * @return void
2971
+	 * @throws DomainException
2972
+	 * @throws EE_Error
2973
+	 * @throws InvalidArgumentException
2974
+	 * @throws InvalidDataTypeException
2975
+	 * @throws InvalidInterfaceException
2976
+	 */
2977
+	private function _display_admin_list_table_page($sidebar = false)
2978
+	{
2979
+		// setup search attributes
2980
+		$this->_set_search_attributes();
2981
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2982
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2983
+		$this->_template_args['table_url']        = $this->request->isAjax()
2984
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2985
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2986
+		$this->_template_args['list_table']       = $this->_list_table_object;
2987
+		$this->_template_args['current_route']    = $this->_req_action;
2988
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2989
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2990
+		if (! empty($ajax_sorting_callback)) {
2991
+			$sortable_list_table_form_fields = wp_nonce_field(
2992
+				$ajax_sorting_callback . '_nonce',
2993
+				$ajax_sorting_callback . '_nonce',
2994
+				false,
2995
+				false
2996
+			);
2997
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2998
+												. $this->page_slug
2999
+												. '" />';
3000
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3001
+												. $ajax_sorting_callback
3002
+												. '" />';
3003
+		} else {
3004
+			$sortable_list_table_form_fields = '';
3005
+		}
3006
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3007
+
3008
+		$hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
3009
+
3010
+		$nonce_ref          = $this->_req_action . '_nonce';
3011
+		$hidden_form_fields .= '
3012 3012
             <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
3013 3013
 
3014
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3015
-        // display message about search results?
3016
-        $search                                    = $this->request->getRequestParam('s');
3017
-        $this->_template_args['before_list_table'] .= ! empty($search)
3018
-            ? '<p class="ee-search-results">' . sprintf(
3019
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3020
-                trim($search, '%')
3021
-            ) . '</p>'
3022
-            : '';
3023
-        // filter before_list_table template arg
3024
-        $this->_template_args['before_list_table'] = apply_filters(
3025
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3026
-            $this->_template_args['before_list_table'],
3027
-            $this->page_slug,
3028
-            $this->request->requestParams(),
3029
-            $this->_req_action
3030
-        );
3031
-        // convert to array and filter again
3032
-        // arrays are easier to inject new items in a specific location,
3033
-        // but would not be backwards compatible, so we have to add a new filter
3034
-        $this->_template_args['before_list_table'] = implode(
3035
-            " \n",
3036
-            (array) apply_filters(
3037
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3038
-                (array) $this->_template_args['before_list_table'],
3039
-                $this->page_slug,
3040
-                $this->request->requestParams(),
3041
-                $this->_req_action
3042
-            )
3043
-        );
3044
-        // filter after_list_table template arg
3045
-        $this->_template_args['after_list_table'] = apply_filters(
3046
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3047
-            $this->_template_args['after_list_table'],
3048
-            $this->page_slug,
3049
-            $this->request->requestParams(),
3050
-            $this->_req_action
3051
-        );
3052
-        // convert to array and filter again
3053
-        // arrays are easier to inject new items in a specific location,
3054
-        // but would not be backwards compatible, so we have to add a new filter
3055
-        $this->_template_args['after_list_table']   = implode(
3056
-            " \n",
3057
-            (array) apply_filters(
3058
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3059
-                (array) $this->_template_args['after_list_table'],
3060
-                $this->page_slug,
3061
-                $this->request->requestParams(),
3062
-                $this->_req_action
3063
-            )
3064
-        );
3065
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3066
-            $template_path,
3067
-            $this->_template_args,
3068
-            true
3069
-        );
3070
-        // the final template wrapper
3071
-        if ($sidebar) {
3072
-            $this->display_admin_page_with_sidebar();
3073
-        } else {
3074
-            $this->display_admin_page_with_no_sidebar();
3075
-        }
3076
-    }
3077
-
3078
-
3079
-    /**
3080
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3081
-     * html string for the legend.
3082
-     * $items are expected in an array in the following format:
3083
-     * $legend_items = array(
3084
-     *        'item_id' => array(
3085
-     *            'icon' => 'http://url_to_icon_being_described.png',
3086
-     *            'desc' => esc_html__('localized description of item');
3087
-     *        )
3088
-     * );
3089
-     *
3090
-     * @param array $items see above for format of array
3091
-     * @return string html string of legend
3092
-     * @throws DomainException
3093
-     */
3094
-    protected function _display_legend($items)
3095
-    {
3096
-        $this->_template_args['items'] = apply_filters(
3097
-            'FHEE__EE_Admin_Page___display_legend__items',
3098
-            (array) $items,
3099
-            $this
3100
-        );
3101
-        /** @var StatusChangeNotice $status_change_notice */
3102
-        $status_change_notice                         = $this->loader->getShared(
3103
-            'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
3104
-        );
3105
-        $this->_template_args['status_change_notice'] = $status_change_notice->display(
3106
-            '__admin-legend',
3107
-            $this->page_slug
3108
-        );
3109
-        return EEH_Template::display_template(
3110
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3111
-            $this->_template_args,
3112
-            true
3113
-        );
3114
-    }
3115
-
3116
-
3117
-    /**
3118
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3119
-     * The returned json object is created from an array in the following format:
3120
-     * array(
3121
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3122
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3123
-     *  'notices' => '', // - contains any EE_Error formatted notices
3124
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3125
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3126
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3127
-     *  that might be included in here)
3128
-     * )
3129
-     * The json object is populated by whatever is set in the $_template_args property.
3130
-     *
3131
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3132
-     *                                 instead of displayed.
3133
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3134
-     * @return void
3135
-     * @throws EE_Error
3136
-     * @throws InvalidArgumentException
3137
-     * @throws InvalidDataTypeException
3138
-     * @throws InvalidInterfaceException
3139
-     */
3140
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3141
-    {
3142
-        // make sure any EE_Error notices have been handled.
3143
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3144
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3145
-        unset($this->_template_args['data']);
3146
-        $json = [
3147
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3148
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3149
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3150
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3151
-            'notices'   => EE_Error::get_notices(),
3152
-            'content'   => isset($this->_template_args['admin_page_content'])
3153
-                ? $this->_template_args['admin_page_content'] : '',
3154
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3155
-            'isEEajax'  => true
3156
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3157
-        ];
3158
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3159
-        if (null === error_get_last() || ! headers_sent()) {
3160
-            header('Content-Type: application/json; charset=UTF-8');
3161
-        }
3162
-        echo wp_json_encode($json);
3163
-        exit();
3164
-    }
3165
-
3166
-
3167
-    /**
3168
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3169
-     *
3170
-     * @return void
3171
-     * @throws EE_Error
3172
-     * @throws InvalidArgumentException
3173
-     * @throws InvalidDataTypeException
3174
-     * @throws InvalidInterfaceException
3175
-     */
3176
-    public function return_json()
3177
-    {
3178
-        if ($this->request->isAjax()) {
3179
-            $this->_return_json();
3180
-        } else {
3181
-            throw new EE_Error(
3182
-                sprintf(
3183
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3184
-                    __FUNCTION__
3185
-                )
3186
-            );
3187
-        }
3188
-    }
3189
-
3190
-
3191
-    /**
3192
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3193
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3194
-     *
3195
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3196
-     */
3197
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3198
-    {
3199
-        $this->_hook_obj = $hook_obj;
3200
-    }
3201
-
3202
-
3203
-    /**
3204
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3205
-     *
3206
-     * @param boolean $about whether to use the special about page wrapper or default.
3207
-     * @return void
3208
-     * @throws DomainException
3209
-     * @throws EE_Error
3210
-     * @throws InvalidArgumentException
3211
-     * @throws InvalidDataTypeException
3212
-     * @throws InvalidInterfaceException
3213
-     */
3214
-    public function admin_page_wrapper($about = false)
3215
-    {
3216
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3217
-        $this->_nav_tabs                          = $this->_get_main_nav_tabs();
3218
-        $this->_template_args['nav_tabs']         = $this->_nav_tabs;
3219
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3220
-
3221
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3222
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3223
-            $this->_template_args['before_admin_page_content'] ?? ''
3224
-        );
3225
-
3226
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3227
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3228
-            $this->_template_args['after_admin_page_content'] ?? ''
3229
-        );
3230
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3231
-
3232
-        if ($this->request->isAjax()) {
3233
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3234
-            // $template_path,
3235
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3236
-                $this->_template_args,
3237
-                true
3238
-            );
3239
-            $this->_return_json();
3240
-        }
3241
-        // load settings page wrapper template
3242
-        $template_path = $about
3243
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3244
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3245
-
3246
-        EEH_Template::display_template($template_path, $this->_template_args);
3247
-    }
3248
-
3249
-
3250
-    /**
3251
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3252
-     *
3253
-     * @return string html
3254
-     * @throws EE_Error
3255
-     */
3256
-    protected function _get_main_nav_tabs()
3257
-    {
3258
-        // let's generate the html using the EEH_Tabbed_Content helper.
3259
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3260
-        // (rather than setting in the page_routes array)
3261
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs, $this->page_slug);
3262
-    }
3263
-
3264
-
3265
-    /**
3266
-     *        sort nav tabs
3267
-     *
3268
-     * @param $a
3269
-     * @param $b
3270
-     * @return int
3271
-     */
3272
-    private function _sort_nav_tabs($a, $b)
3273
-    {
3274
-        if ($a['order'] === $b['order']) {
3275
-            return 0;
3276
-        }
3277
-        return ($a['order'] < $b['order']) ? -1 : 1;
3278
-    }
3279
-
3280
-
3281
-    /**
3282
-     * generates HTML for the forms used on admin pages
3283
-     *
3284
-     * @param array  $input_vars - array of input field details
3285
-     * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3286
-     * @param bool   $id
3287
-     * @return array|string
3288
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3289
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3290
-     */
3291
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3292
-    {
3293
-        return $generator === 'string'
3294
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3295
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3296
-    }
3297
-
3298
-
3299
-    /**
3300
-     * generates the "Save" and "Save & Close" buttons for edit forms
3301
-     *
3302
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3303
-     *                                   Close" button.
3304
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3305
-     *                                   'Save', [1] => 'save & close')
3306
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3307
-     *                                   via the "name" value in the button).  We can also use this to just dump
3308
-     *                                   default actions by submitting some other value.
3309
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3310
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3311
-     *                                   close (normal form handling).
3312
-     */
3313
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3314
-    {
3315
-        // make sure $text and $actions are in an array
3316
-        $text          = (array) $text;
3317
-        $actions       = (array) $actions;
3318
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3319
-        $button_text   = ! empty($text)
3320
-            ? $text
3321
-            : [
3322
-                esc_html__('Save', 'event_espresso'),
3323
-                esc_html__('Save and Close', 'event_espresso'),
3324
-            ];
3325
-        $default_names = ['save', 'save_and_close'];
3326
-        $buttons       = '';
3327
-        foreach ($button_text as $key => $button) {
3328
-            $ref     = $default_names[ $key ];
3329
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3330
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3331
-                        . 'value="' . $button . '" name="' . $name . '" '
3332
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3333
-            if (! $both) {
3334
-                break;
3335
-            }
3336
-        }
3337
-        // add in a hidden index for the current page (so save and close redirects properly)
3338
-        $buttons                              .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3339
-                                                 . $referrer_url
3340
-                                                 . '" />';
3341
-        $this->_template_args['save_buttons'] = $buttons;
3342
-    }
3343
-
3344
-
3345
-    /**
3346
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3347
-     *
3348
-     * @param string $route
3349
-     * @param array  $additional_hidden_fields
3350
-     * @see   $this->_set_add_edit_form_tags() for details on params
3351
-     * @since 4.6.0
3352
-     */
3353
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3354
-    {
3355
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3356
-    }
3357
-
3358
-
3359
-    /**
3360
-     * set form open and close tags on add/edit pages.
3361
-     *
3362
-     * @param string $route                    the route you want the form to direct to
3363
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3364
-     * @return void
3365
-     */
3366
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3367
-    {
3368
-        if (empty($route)) {
3369
-            $user_msg = esc_html__(
3370
-                'An error occurred. No action was set for this page\'s form.',
3371
-                'event_espresso'
3372
-            );
3373
-            $dev_msg  = $user_msg . "\n"
3374
-                        . sprintf(
3375
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3376
-                            __FUNCTION__,
3377
-                            __CLASS__
3378
-                        );
3379
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3380
-        }
3381
-        // open form
3382
-        $action                                            = $this->_admin_base_url;
3383
-        $this->_template_args['before_admin_page_content'] = "
3014
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3015
+		// display message about search results?
3016
+		$search                                    = $this->request->getRequestParam('s');
3017
+		$this->_template_args['before_list_table'] .= ! empty($search)
3018
+			? '<p class="ee-search-results">' . sprintf(
3019
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3020
+				trim($search, '%')
3021
+			) . '</p>'
3022
+			: '';
3023
+		// filter before_list_table template arg
3024
+		$this->_template_args['before_list_table'] = apply_filters(
3025
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3026
+			$this->_template_args['before_list_table'],
3027
+			$this->page_slug,
3028
+			$this->request->requestParams(),
3029
+			$this->_req_action
3030
+		);
3031
+		// convert to array and filter again
3032
+		// arrays are easier to inject new items in a specific location,
3033
+		// but would not be backwards compatible, so we have to add a new filter
3034
+		$this->_template_args['before_list_table'] = implode(
3035
+			" \n",
3036
+			(array) apply_filters(
3037
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3038
+				(array) $this->_template_args['before_list_table'],
3039
+				$this->page_slug,
3040
+				$this->request->requestParams(),
3041
+				$this->_req_action
3042
+			)
3043
+		);
3044
+		// filter after_list_table template arg
3045
+		$this->_template_args['after_list_table'] = apply_filters(
3046
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3047
+			$this->_template_args['after_list_table'],
3048
+			$this->page_slug,
3049
+			$this->request->requestParams(),
3050
+			$this->_req_action
3051
+		);
3052
+		// convert to array and filter again
3053
+		// arrays are easier to inject new items in a specific location,
3054
+		// but would not be backwards compatible, so we have to add a new filter
3055
+		$this->_template_args['after_list_table']   = implode(
3056
+			" \n",
3057
+			(array) apply_filters(
3058
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3059
+				(array) $this->_template_args['after_list_table'],
3060
+				$this->page_slug,
3061
+				$this->request->requestParams(),
3062
+				$this->_req_action
3063
+			)
3064
+		);
3065
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3066
+			$template_path,
3067
+			$this->_template_args,
3068
+			true
3069
+		);
3070
+		// the final template wrapper
3071
+		if ($sidebar) {
3072
+			$this->display_admin_page_with_sidebar();
3073
+		} else {
3074
+			$this->display_admin_page_with_no_sidebar();
3075
+		}
3076
+	}
3077
+
3078
+
3079
+	/**
3080
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3081
+	 * html string for the legend.
3082
+	 * $items are expected in an array in the following format:
3083
+	 * $legend_items = array(
3084
+	 *        'item_id' => array(
3085
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3086
+	 *            'desc' => esc_html__('localized description of item');
3087
+	 *        )
3088
+	 * );
3089
+	 *
3090
+	 * @param array $items see above for format of array
3091
+	 * @return string html string of legend
3092
+	 * @throws DomainException
3093
+	 */
3094
+	protected function _display_legend($items)
3095
+	{
3096
+		$this->_template_args['items'] = apply_filters(
3097
+			'FHEE__EE_Admin_Page___display_legend__items',
3098
+			(array) $items,
3099
+			$this
3100
+		);
3101
+		/** @var StatusChangeNotice $status_change_notice */
3102
+		$status_change_notice                         = $this->loader->getShared(
3103
+			'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
3104
+		);
3105
+		$this->_template_args['status_change_notice'] = $status_change_notice->display(
3106
+			'__admin-legend',
3107
+			$this->page_slug
3108
+		);
3109
+		return EEH_Template::display_template(
3110
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3111
+			$this->_template_args,
3112
+			true
3113
+		);
3114
+	}
3115
+
3116
+
3117
+	/**
3118
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3119
+	 * The returned json object is created from an array in the following format:
3120
+	 * array(
3121
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3122
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3123
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3124
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3125
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3126
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3127
+	 *  that might be included in here)
3128
+	 * )
3129
+	 * The json object is populated by whatever is set in the $_template_args property.
3130
+	 *
3131
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3132
+	 *                                 instead of displayed.
3133
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3134
+	 * @return void
3135
+	 * @throws EE_Error
3136
+	 * @throws InvalidArgumentException
3137
+	 * @throws InvalidDataTypeException
3138
+	 * @throws InvalidInterfaceException
3139
+	 */
3140
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3141
+	{
3142
+		// make sure any EE_Error notices have been handled.
3143
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3144
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3145
+		unset($this->_template_args['data']);
3146
+		$json = [
3147
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3148
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3149
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3150
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3151
+			'notices'   => EE_Error::get_notices(),
3152
+			'content'   => isset($this->_template_args['admin_page_content'])
3153
+				? $this->_template_args['admin_page_content'] : '',
3154
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3155
+			'isEEajax'  => true
3156
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3157
+		];
3158
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3159
+		if (null === error_get_last() || ! headers_sent()) {
3160
+			header('Content-Type: application/json; charset=UTF-8');
3161
+		}
3162
+		echo wp_json_encode($json);
3163
+		exit();
3164
+	}
3165
+
3166
+
3167
+	/**
3168
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3169
+	 *
3170
+	 * @return void
3171
+	 * @throws EE_Error
3172
+	 * @throws InvalidArgumentException
3173
+	 * @throws InvalidDataTypeException
3174
+	 * @throws InvalidInterfaceException
3175
+	 */
3176
+	public function return_json()
3177
+	{
3178
+		if ($this->request->isAjax()) {
3179
+			$this->_return_json();
3180
+		} else {
3181
+			throw new EE_Error(
3182
+				sprintf(
3183
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3184
+					__FUNCTION__
3185
+				)
3186
+			);
3187
+		}
3188
+	}
3189
+
3190
+
3191
+	/**
3192
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3193
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3194
+	 *
3195
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3196
+	 */
3197
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3198
+	{
3199
+		$this->_hook_obj = $hook_obj;
3200
+	}
3201
+
3202
+
3203
+	/**
3204
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3205
+	 *
3206
+	 * @param boolean $about whether to use the special about page wrapper or default.
3207
+	 * @return void
3208
+	 * @throws DomainException
3209
+	 * @throws EE_Error
3210
+	 * @throws InvalidArgumentException
3211
+	 * @throws InvalidDataTypeException
3212
+	 * @throws InvalidInterfaceException
3213
+	 */
3214
+	public function admin_page_wrapper($about = false)
3215
+	{
3216
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3217
+		$this->_nav_tabs                          = $this->_get_main_nav_tabs();
3218
+		$this->_template_args['nav_tabs']         = $this->_nav_tabs;
3219
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3220
+
3221
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3222
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3223
+			$this->_template_args['before_admin_page_content'] ?? ''
3224
+		);
3225
+
3226
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3227
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3228
+			$this->_template_args['after_admin_page_content'] ?? ''
3229
+		);
3230
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3231
+
3232
+		if ($this->request->isAjax()) {
3233
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3234
+			// $template_path,
3235
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3236
+				$this->_template_args,
3237
+				true
3238
+			);
3239
+			$this->_return_json();
3240
+		}
3241
+		// load settings page wrapper template
3242
+		$template_path = $about
3243
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3244
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3245
+
3246
+		EEH_Template::display_template($template_path, $this->_template_args);
3247
+	}
3248
+
3249
+
3250
+	/**
3251
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3252
+	 *
3253
+	 * @return string html
3254
+	 * @throws EE_Error
3255
+	 */
3256
+	protected function _get_main_nav_tabs()
3257
+	{
3258
+		// let's generate the html using the EEH_Tabbed_Content helper.
3259
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3260
+		// (rather than setting in the page_routes array)
3261
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs, $this->page_slug);
3262
+	}
3263
+
3264
+
3265
+	/**
3266
+	 *        sort nav tabs
3267
+	 *
3268
+	 * @param $a
3269
+	 * @param $b
3270
+	 * @return int
3271
+	 */
3272
+	private function _sort_nav_tabs($a, $b)
3273
+	{
3274
+		if ($a['order'] === $b['order']) {
3275
+			return 0;
3276
+		}
3277
+		return ($a['order'] < $b['order']) ? -1 : 1;
3278
+	}
3279
+
3280
+
3281
+	/**
3282
+	 * generates HTML for the forms used on admin pages
3283
+	 *
3284
+	 * @param array  $input_vars - array of input field details
3285
+	 * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3286
+	 * @param bool   $id
3287
+	 * @return array|string
3288
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3289
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3290
+	 */
3291
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3292
+	{
3293
+		return $generator === 'string'
3294
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3295
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3296
+	}
3297
+
3298
+
3299
+	/**
3300
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3301
+	 *
3302
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3303
+	 *                                   Close" button.
3304
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3305
+	 *                                   'Save', [1] => 'save & close')
3306
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3307
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3308
+	 *                                   default actions by submitting some other value.
3309
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3310
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3311
+	 *                                   close (normal form handling).
3312
+	 */
3313
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3314
+	{
3315
+		// make sure $text and $actions are in an array
3316
+		$text          = (array) $text;
3317
+		$actions       = (array) $actions;
3318
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3319
+		$button_text   = ! empty($text)
3320
+			? $text
3321
+			: [
3322
+				esc_html__('Save', 'event_espresso'),
3323
+				esc_html__('Save and Close', 'event_espresso'),
3324
+			];
3325
+		$default_names = ['save', 'save_and_close'];
3326
+		$buttons       = '';
3327
+		foreach ($button_text as $key => $button) {
3328
+			$ref     = $default_names[ $key ];
3329
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3330
+			$buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3331
+						. 'value="' . $button . '" name="' . $name . '" '
3332
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3333
+			if (! $both) {
3334
+				break;
3335
+			}
3336
+		}
3337
+		// add in a hidden index for the current page (so save and close redirects properly)
3338
+		$buttons                              .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3339
+												 . $referrer_url
3340
+												 . '" />';
3341
+		$this->_template_args['save_buttons'] = $buttons;
3342
+	}
3343
+
3344
+
3345
+	/**
3346
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3347
+	 *
3348
+	 * @param string $route
3349
+	 * @param array  $additional_hidden_fields
3350
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3351
+	 * @since 4.6.0
3352
+	 */
3353
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3354
+	{
3355
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3356
+	}
3357
+
3358
+
3359
+	/**
3360
+	 * set form open and close tags on add/edit pages.
3361
+	 *
3362
+	 * @param string $route                    the route you want the form to direct to
3363
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3364
+	 * @return void
3365
+	 */
3366
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3367
+	{
3368
+		if (empty($route)) {
3369
+			$user_msg = esc_html__(
3370
+				'An error occurred. No action was set for this page\'s form.',
3371
+				'event_espresso'
3372
+			);
3373
+			$dev_msg  = $user_msg . "\n"
3374
+						. sprintf(
3375
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3376
+							__FUNCTION__,
3377
+							__CLASS__
3378
+						);
3379
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3380
+		}
3381
+		// open form
3382
+		$action                                            = $this->_admin_base_url;
3383
+		$this->_template_args['before_admin_page_content'] = "
3384 3384
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3385 3385
             ";
3386
-        // add nonce
3387
-        $nonce                                             =
3388
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3389
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3390
-        // add REQUIRED form action
3391
-        $hidden_fields = [
3392
-            'action' => ['type' => 'hidden', 'value' => $route],
3393
-        ];
3394
-        // merge arrays
3395
-        $hidden_fields = is_array($additional_hidden_fields)
3396
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3397
-            : $hidden_fields;
3398
-        // generate form fields
3399
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3400
-        // add fields to form
3401
-        foreach ((array) $form_fields as $form_field) {
3402
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3403
-        }
3404
-        // close form
3405
-        $this->_template_args['after_admin_page_content'] = '</form>';
3406
-    }
3407
-
3408
-
3409
-    /**
3410
-     * Public Wrapper for _redirect_after_action() method since its
3411
-     * discovered it would be useful for external code to have access.
3412
-     *
3413
-     * @param bool   $success
3414
-     * @param string $what
3415
-     * @param string $action_desc
3416
-     * @param array  $query_args
3417
-     * @param bool   $override_overwrite
3418
-     * @throws EE_Error
3419
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3420
-     * @since 4.5.0
3421
-     */
3422
-    public function redirect_after_action(
3423
-        $success = false,
3424
-        $what = 'item',
3425
-        $action_desc = 'processed',
3426
-        $query_args = [],
3427
-        $override_overwrite = false
3428
-    ) {
3429
-        $this->_redirect_after_action(
3430
-            $success,
3431
-            $what,
3432
-            $action_desc,
3433
-            $query_args,
3434
-            $override_overwrite
3435
-        );
3436
-    }
3437
-
3438
-
3439
-    /**
3440
-     * Helper method for merging existing request data with the returned redirect url.
3441
-     *
3442
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3443
-     * filters are still applied.
3444
-     *
3445
-     * @param array $new_route_data
3446
-     * @return array
3447
-     */
3448
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3449
-    {
3450
-        foreach ($this->request->requestParams() as $ref => $value) {
3451
-            // unset nonces
3452
-            if (strpos($ref, 'nonce') !== false) {
3453
-                $this->request->unSetRequestParam($ref);
3454
-                continue;
3455
-            }
3456
-            // urlencode values.
3457
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3458
-            $this->request->setRequestParam($ref, $value);
3459
-        }
3460
-        return array_merge($this->request->requestParams(), $new_route_data);
3461
-    }
3462
-
3463
-
3464
-    /**
3465
-     * @param int|float|string $success            - whether success was for two or more records, or just one, or none
3466
-     * @param string           $what               - what the action was performed on
3467
-     * @param string           $action_desc        - what was done ie: updated, deleted, etc
3468
-     * @param array            $query_args         - an array of query_args to be added to the URL to redirect to
3469
-     * @param BOOL             $override_overwrite - by default all EE_Error::success messages are overwritten,
3470
-     *                                             this allows you to override this so that they show.
3471
-     * @return void
3472
-     * @throws EE_Error
3473
-     * @throws InvalidArgumentException
3474
-     * @throws InvalidDataTypeException
3475
-     * @throws InvalidInterfaceException
3476
-     */
3477
-    protected function _redirect_after_action(
3478
-        $success = 0,
3479
-        string $what = 'item',
3480
-        string $action_desc = 'processed',
3481
-        array $query_args = [],
3482
-        bool $override_overwrite = false
3483
-    ) {
3484
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3485
-        $notices = EE_Error::get_notices(false);
3486
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3487
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3488
-            EE_Error::overwrite_success();
3489
-        }
3490
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3491
-            // how many records affected ? more than one record ? or just one ?
3492
-            EE_Error::add_success(
3493
-                sprintf(
3494
-                    esc_html(
3495
-                        _n(
3496
-                            'The "%1$s" has been successfully %2$s.',
3497
-                            'The "%1$s" have been successfully %2$s.',
3498
-                            $success,
3499
-                            'event_espresso'
3500
-                        )
3501
-                    ),
3502
-                    $what,
3503
-                    $action_desc
3504
-                ),
3505
-                __FILE__,
3506
-                __FUNCTION__,
3507
-                __LINE__
3508
-            );
3509
-        }
3510
-        // check that $query_args isn't something crazy
3511
-        if (! is_array($query_args)) {
3512
-            $query_args = [];
3513
-        }
3514
-        /**
3515
-         * Allow injecting actions before the query_args are modified for possible different
3516
-         * redirections on save and close actions
3517
-         *
3518
-         * @param array $query_args       The original query_args array coming into the
3519
-         *                                method.
3520
-         * @since 4.2.0
3521
-         */
3522
-        do_action(
3523
-            "AHEE__{$this->class_name}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3524
-            $query_args
3525
-        );
3526
-        // set redirect url.
3527
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3528
-        // otherwise we go with whatever is set as the _admin_base_url
3529
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3530
-        // calculate where we're going (if we have a "save and close" button pushed)
3531
-        if (
3532
-            $this->request->requestParamIsSet('save_and_close')
3533
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3534
-        ) {
3535
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3536
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3537
-            // regenerate query args array from referrer URL
3538
-            parse_str($parsed_url['query'], $query_args);
3539
-            // correct page and action will be in the query args now
3540
-            $redirect_url = admin_url('admin.php');
3541
-        }
3542
-        // merge any default query_args set in _default_route_query_args property
3543
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3544
-            $args_to_merge = [];
3545
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3546
-                // is there a wp_referer array in our _default_route_query_args property?
3547
-                if ($query_param === 'wp_referer') {
3548
-                    $query_value = (array) $query_value;
3549
-                    foreach ($query_value as $reference => $value) {
3550
-                        if (strpos($reference, 'nonce') !== false) {
3551
-                            continue;
3552
-                        }
3553
-                        // finally we will override any arguments in the referer with
3554
-                        // what might be set on the _default_route_query_args array.
3555
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3556
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3557
-                        } else {
3558
-                            $args_to_merge[ $reference ] = urlencode($value);
3559
-                        }
3560
-                    }
3561
-                    continue;
3562
-                }
3563
-                $args_to_merge[ $query_param ] = $query_value;
3564
-            }
3565
-            // now let's merge these arguments but override with what was specifically sent in to the
3566
-            // redirect.
3567
-            $query_args = array_merge($args_to_merge, $query_args);
3568
-        }
3569
-        $this->_process_notices($query_args);
3570
-        // generate redirect url
3571
-        // if redirecting to anything other than the main page, add a nonce
3572
-        if (isset($query_args['action'])) {
3573
-            // manually generate wp_nonce and merge that with the query vars
3574
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3575
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3576
-        }
3577
-        // we're adding some hooks and filters in here for processing any things just before redirects
3578
-        // (example: an admin page has done an insert or update and we want to run something after that).
3579
-        do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3580
-        $redirect_url = apply_filters(
3581
-            'FHEE_redirect_' . $this->class_name . $this->_req_action,
3582
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3583
-            $query_args
3584
-        );
3585
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3586
-        if ($this->request->isAjax()) {
3587
-            $default_data                    = [
3588
-                'close'        => true,
3589
-                'redirect_url' => $redirect_url,
3590
-                'where'        => 'main',
3591
-                'what'         => 'append',
3592
-            ];
3593
-            $this->_template_args['success'] = $success;
3594
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3595
-                $default_data,
3596
-                $this->_template_args['data']
3597
-            ) : $default_data;
3598
-            $this->_return_json();
3599
-        }
3600
-        wp_safe_redirect($redirect_url);
3601
-        exit();
3602
-    }
3603
-
3604
-
3605
-    /**
3606
-     * process any notices before redirecting (or returning ajax request)
3607
-     * This method sets the $this->_template_args['notices'] attribute;
3608
-     *
3609
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3610
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3611
-     *                                  page_routes haven't been defined yet.
3612
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3613
-     *                                  still save a transient for the notice.
3614
-     * @return void
3615
-     * @throws EE_Error
3616
-     * @throws InvalidArgumentException
3617
-     * @throws InvalidDataTypeException
3618
-     * @throws InvalidInterfaceException
3619
-     */
3620
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3621
-    {
3622
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3623
-        if ($this->request->isAjax()) {
3624
-            $notices = EE_Error::get_notices(false);
3625
-            if (empty($this->_template_args['success'])) {
3626
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3627
-            }
3628
-            if (empty($this->_template_args['errors'])) {
3629
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3630
-            }
3631
-            if (empty($this->_template_args['attention'])) {
3632
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3633
-            }
3634
-        }
3635
-        $this->_template_args['notices'] = EE_Error::get_notices();
3636
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3637
-        if (! $this->request->isAjax() || $sticky_notices) {
3638
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3639
-            $this->_add_transient(
3640
-                $route,
3641
-                $this->_template_args['notices'],
3642
-                true,
3643
-                $skip_route_verify
3644
-            );
3645
-        }
3646
-    }
3647
-
3648
-
3649
-    /**
3650
-     * get_action_link_or_button
3651
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3652
-     *
3653
-     * @param string $action        use this to indicate which action the url is generated with.
3654
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3655
-     *                              property.
3656
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3657
-     * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3658
-     * @param string $base_url      If this is not provided
3659
-     *                              the _admin_base_url will be used as the default for the button base_url.
3660
-     *                              Otherwise this value will be used.
3661
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3662
-     * @return string
3663
-     * @throws InvalidArgumentException
3664
-     * @throws InvalidInterfaceException
3665
-     * @throws InvalidDataTypeException
3666
-     * @throws EE_Error
3667
-     */
3668
-    public function get_action_link_or_button(
3669
-        $action,
3670
-        $type = 'add',
3671
-        $extra_request = [],
3672
-        $class = 'button button--primary',
3673
-        $base_url = '',
3674
-        $exclude_nonce = false
3675
-    ) {
3676
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3677
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3678
-            throw new EE_Error(
3679
-                sprintf(
3680
-                    esc_html__(
3681
-                        'There is no page route for given action for the button.  This action was given: %s',
3682
-                        'event_espresso'
3683
-                    ),
3684
-                    $action
3685
-                )
3686
-            );
3687
-        }
3688
-        if (! isset($this->_labels['buttons'][ $type ])) {
3689
-            throw new EE_Error(
3690
-                sprintf(
3691
-                    esc_html__(
3692
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3693
-                        'event_espresso'
3694
-                    ),
3695
-                    $type
3696
-                )
3697
-            );
3698
-        }
3699
-        // finally check user access for this button.
3700
-        $has_access = $this->check_user_access($action, true);
3701
-        if (! $has_access) {
3702
-            return '';
3703
-        }
3704
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3705
-        $query_args = [
3706
-            'action' => $action,
3707
-        ];
3708
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3709
-        if (! empty($extra_request)) {
3710
-            $query_args = array_merge($extra_request, $query_args);
3711
-        }
3712
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3713
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3714
-    }
3715
-
3716
-
3717
-    /**
3718
-     * _per_page_screen_option
3719
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3720
-     *
3721
-     * @return void
3722
-     * @throws InvalidArgumentException
3723
-     * @throws InvalidInterfaceException
3724
-     * @throws InvalidDataTypeException
3725
-     */
3726
-    protected function _per_page_screen_option()
3727
-    {
3728
-        $option = 'per_page';
3729
-        $args   = [
3730
-            'label'   => apply_filters(
3731
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3732
-                $this->_admin_page_title,
3733
-                $this
3734
-            ),
3735
-            'default' => (int) apply_filters(
3736
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3737
-                20
3738
-            ),
3739
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3740
-        ];
3741
-        // ONLY add the screen option if the user has access to it.
3742
-        if ($this->check_user_access($this->_current_view, true)) {
3743
-            add_screen_option($option, $args);
3744
-        }
3745
-    }
3746
-
3747
-
3748
-    /**
3749
-     * set_per_page_screen_option
3750
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3751
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3752
-     * admin_menu.
3753
-     *
3754
-     * @return void
3755
-     */
3756
-    private function _set_per_page_screen_options()
3757
-    {
3758
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3759
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3760
-            if (! $user = wp_get_current_user()) {
3761
-                return;
3762
-            }
3763
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3764
-            if (! $option) {
3765
-                return;
3766
-            }
3767
-            $value      = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3768
-            $map_option = $option;
3769
-            $option     = str_replace('-', '_', $option);
3770
-            switch ($map_option) {
3771
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3772
-                    $max_value = apply_filters(
3773
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3774
-                        999,
3775
-                        $this->_current_page,
3776
-                        $this->_current_view
3777
-                    );
3778
-                    if ($value < 1) {
3779
-                        return;
3780
-                    }
3781
-                    $value = min($value, $max_value);
3782
-                    break;
3783
-                default:
3784
-                    $value = apply_filters(
3785
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3786
-                        false,
3787
-                        $option,
3788
-                        $value
3789
-                    );
3790
-                    if (false === $value) {
3791
-                        return;
3792
-                    }
3793
-                    break;
3794
-            }
3795
-            update_user_meta($user->ID, $option, $value);
3796
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3797
-            exit;
3798
-        }
3799
-    }
3800
-
3801
-
3802
-    /**
3803
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3804
-     *
3805
-     * @param array $data array that will be assigned to template args.
3806
-     */
3807
-    public function set_template_args($data)
3808
-    {
3809
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3810
-    }
3811
-
3812
-
3813
-    /**
3814
-     * This makes available the WP transient system for temporarily moving data between routes
3815
-     *
3816
-     * @param string $route             the route that should receive the transient
3817
-     * @param array  $data              the data that gets sent
3818
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3819
-     *                                  normal route transient.
3820
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3821
-     *                                  when we are adding a transient before page_routes have been defined.
3822
-     * @return void
3823
-     * @throws EE_Error
3824
-     */
3825
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826
-    {
3827
-        $user_id = get_current_user_id();
3828
-        if (! $skip_route_verify) {
3829
-            $this->_verify_route($route);
3830
-        }
3831
-        // now let's set the string for what kind of transient we're setting
3832
-        $transient = $notices
3833
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
-            : 'rte_tx_' . $route . '_' . $user_id;
3835
-        $data      = $notices ? ['notices' => $data] : $data;
3836
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3837
-        $existing = is_multisite() && is_network_admin()
3838
-            ? get_site_transient($transient)
3839
-            : get_transient($transient);
3840
-        if ($existing) {
3841
-            $data = array_merge((array) $data, (array) $existing);
3842
-        }
3843
-        if (is_multisite() && is_network_admin()) {
3844
-            set_site_transient($transient, $data, 8);
3845
-        } else {
3846
-            set_transient($transient, $data, 8);
3847
-        }
3848
-    }
3849
-
3850
-
3851
-    /**
3852
-     * this retrieves the temporary transient that has been set for moving data between routes.
3853
-     *
3854
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3855
-     * @param string $route
3856
-     * @return mixed data
3857
-     */
3858
-    protected function _get_transient($notices = false, $route = '')
3859
-    {
3860
-        $user_id   = get_current_user_id();
3861
-        $route     = ! $route ? $this->_req_action : $route;
3862
-        $transient = $notices
3863
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
-            : 'rte_tx_' . $route . '_' . $user_id;
3865
-        $data      = is_multisite() && is_network_admin()
3866
-            ? get_site_transient($transient)
3867
-            : get_transient($transient);
3868
-        // delete transient after retrieval (just in case it hasn't expired);
3869
-        if (is_multisite() && is_network_admin()) {
3870
-            delete_site_transient($transient);
3871
-        } else {
3872
-            delete_transient($transient);
3873
-        }
3874
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3875
-    }
3876
-
3877
-
3878
-    /**
3879
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3880
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3881
-     * default route callback on the EE_Admin page you want it run.)
3882
-     *
3883
-     * @return void
3884
-     */
3885
-    protected function _transient_garbage_collection()
3886
-    {
3887
-        global $wpdb;
3888
-        // retrieve all existing transients
3889
-        $query =
3890
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3891
-        if ($results = $wpdb->get_results($query)) {
3892
-            foreach ($results as $result) {
3893
-                $transient = str_replace('_transient_', '', $result->option_name);
3894
-                get_transient($transient);
3895
-                if (is_multisite() && is_network_admin()) {
3896
-                    get_site_transient($transient);
3897
-                }
3898
-            }
3899
-        }
3900
-    }
3901
-
3902
-
3903
-    /**
3904
-     * get_view
3905
-     *
3906
-     * @return string content of _view property
3907
-     */
3908
-    public function get_view()
3909
-    {
3910
-        return $this->_view;
3911
-    }
3912
-
3913
-
3914
-    /**
3915
-     * getter for the protected $_views property
3916
-     *
3917
-     * @return array
3918
-     */
3919
-    public function get_views()
3920
-    {
3921
-        return $this->_views;
3922
-    }
3923
-
3924
-
3925
-    /**
3926
-     * get_current_page
3927
-     *
3928
-     * @return string _current_page property value
3929
-     */
3930
-    public function get_current_page()
3931
-    {
3932
-        return $this->_current_page;
3933
-    }
3934
-
3935
-
3936
-    /**
3937
-     * get_current_view
3938
-     *
3939
-     * @return string _current_view property value
3940
-     */
3941
-    public function get_current_view()
3942
-    {
3943
-        return $this->_current_view;
3944
-    }
3945
-
3946
-
3947
-    /**
3948
-     * get_current_screen
3949
-     *
3950
-     * @return object The current WP_Screen object
3951
-     */
3952
-    public function get_current_screen()
3953
-    {
3954
-        return $this->_current_screen;
3955
-    }
3956
-
3957
-
3958
-    /**
3959
-     * get_current_page_view_url
3960
-     *
3961
-     * @return string This returns the url for the current_page_view.
3962
-     */
3963
-    public function get_current_page_view_url()
3964
-    {
3965
-        return $this->_current_page_view_url;
3966
-    }
3967
-
3968
-
3969
-    /**
3970
-     * just returns the Request
3971
-     *
3972
-     * @return RequestInterface
3973
-     */
3974
-    public function get_request()
3975
-    {
3976
-        return $this->request;
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * just returns the _req_data property
3982
-     *
3983
-     * @return array
3984
-     */
3985
-    public function get_request_data()
3986
-    {
3987
-        return $this->request->requestParams();
3988
-    }
3989
-
3990
-
3991
-    /**
3992
-     * returns the _req_data protected property
3993
-     *
3994
-     * @return string
3995
-     */
3996
-    public function get_req_action()
3997
-    {
3998
-        return $this->_req_action;
3999
-    }
4000
-
4001
-
4002
-    /**
4003
-     * @return bool  value of $_is_caf property
4004
-     */
4005
-    public function is_caf()
4006
-    {
4007
-        return $this->_is_caf;
4008
-    }
4009
-
4010
-
4011
-    /**
4012
-     * @return mixed
4013
-     */
4014
-    public function default_espresso_metaboxes()
4015
-    {
4016
-        return $this->_default_espresso_metaboxes;
4017
-    }
4018
-
4019
-
4020
-    /**
4021
-     * @return mixed
4022
-     */
4023
-    public function admin_base_url()
4024
-    {
4025
-        return $this->_admin_base_url;
4026
-    }
4027
-
4028
-
4029
-    /**
4030
-     * @return mixed
4031
-     */
4032
-    public function wp_page_slug()
4033
-    {
4034
-        return $this->_wp_page_slug;
4035
-    }
4036
-
4037
-
4038
-    /**
4039
-     * updates  espresso configuration settings
4040
-     *
4041
-     * @param string                   $tab
4042
-     * @param EE_Config_Base|EE_Config $config
4043
-     * @param string                   $file file where error occurred
4044
-     * @param string                   $func function  where error occurred
4045
-     * @param string                   $line line no where error occurred
4046
-     * @return boolean
4047
-     */
4048
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4049
-    {
4050
-        // remove any options that are NOT going to be saved with the config settings.
4051
-        if (isset($config->core->ee_ueip_optin)) {
4052
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4053
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4054
-            update_option('ee_ueip_has_notified', true);
4055
-        }
4056
-        // and save it (note we're also doing the network save here)
4057
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
4058
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4059
-        if ($config_saved && $net_saved) {
4060
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4061
-            return true;
4062
-        }
4063
-        EE_Error::add_error(
4064
-            sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab),
4065
-            $file,
4066
-            $func,
4067
-            $line
4068
-        );
4069
-        return false;
4070
-    }
4071
-
4072
-
4073
-    /**
4074
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4075
-     *
4076
-     * @return array
4077
-     */
4078
-    public function get_yes_no_values()
4079
-    {
4080
-        return $this->_yes_no_values;
4081
-    }
4082
-
4083
-
4084
-    /**
4085
-     * @return string
4086
-     * @throws ReflectionException
4087
-     * @since $VID:$
4088
-     */
4089
-    protected function _get_dir()
4090
-    {
4091
-        $reflector = new ReflectionClass($this->class_name);
4092
-        return dirname($reflector->getFileName());
4093
-    }
4094
-
4095
-
4096
-    /**
4097
-     * A helper for getting a "next link".
4098
-     *
4099
-     * @param string $url   The url to link to
4100
-     * @param string $class The class to use.
4101
-     * @return string
4102
-     */
4103
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4104
-    {
4105
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4106
-    }
4107
-
4108
-
4109
-    /**
4110
-     * A helper for getting a "previous link".
4111
-     *
4112
-     * @param string $url   The url to link to
4113
-     * @param string $class The class to use.
4114
-     * @return string
4115
-     */
4116
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4117
-    {
4118
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4119
-    }
4120
-
4121
-
4122
-
4123
-
4124
-
4125
-
4126
-
4127
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4128
-
4129
-
4130
-    /**
4131
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4132
-     * 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
4133
-     * _req_data array.
4134
-     *
4135
-     * @return bool success/fail
4136
-     * @throws EE_Error
4137
-     * @throws InvalidArgumentException
4138
-     * @throws ReflectionException
4139
-     * @throws InvalidDataTypeException
4140
-     * @throws InvalidInterfaceException
4141
-     */
4142
-    protected function _process_resend_registration()
4143
-    {
4144
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4145
-        do_action(
4146
-            'AHEE__EE_Admin_Page___process_resend_registration',
4147
-            $this->_template_args['success'],
4148
-            $this->request->requestParams()
4149
-        );
4150
-        return $this->_template_args['success'];
4151
-    }
4152
-
4153
-
4154
-    /**
4155
-     * This automatically processes any payment message notifications when manual payment has been applied.
4156
-     *
4157
-     * @param EE_Payment $payment
4158
-     * @return bool success/fail
4159
-     */
4160
-    protected function _process_payment_notification(EE_Payment $payment)
4161
-    {
4162
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4163
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4164
-        $this->_template_args['success'] = apply_filters(
4165
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4166
-            false,
4167
-            $payment
4168
-        );
4169
-        return $this->_template_args['success'];
4170
-    }
4171
-
4172
-
4173
-    /**
4174
-     * @param EEM_Base      $entity_model
4175
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4176
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4177
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4178
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4179
-     * @return int|float
4180
-     * @throws EE_Error
4181
-     */
4182
-    protected function trashRestoreDeleteEntities(
4183
-        EEM_Base $entity_model,
4184
-        $entity_PK_name,
4185
-        $action = EE_Admin_List_Table::ACTION_DELETE,
4186
-        $delete_column = '',
4187
-        callable $callback = null
4188
-    ) {
4189
-        $entity_PK      = $entity_model->get_primary_key_field();
4190
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4191
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4192
-        // grab ID if deleting a single entity
4193
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4194
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4195
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4196
-        }
4197
-        // or grab checkbox array if bulk deleting
4198
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4199
-        if (empty($checkboxes)) {
4200
-            return 0;
4201
-        }
4202
-        $success = 0;
4203
-        $IDs     = array_keys($checkboxes);
4204
-        // cycle thru bulk action checkboxes
4205
-        foreach ($IDs as $ID) {
4206
-            // increment $success
4207
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4208
-                $success++;
4209
-            }
4210
-        }
4211
-        $count = (int) count($checkboxes);
4212
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4213
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4214
-        return $success === $count ? $count : $success / $count;
4215
-    }
4216
-
4217
-
4218
-    /**
4219
-     * @param EE_Primary_Key_Field_Base $entity_PK
4220
-     * @return string
4221
-     * @throws EE_Error
4222
-     * @since   4.10.30.p
4223
-     */
4224
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4225
-    {
4226
-        $entity_PK_type = $entity_PK->getSchemaType();
4227
-        switch ($entity_PK_type) {
4228
-            case 'boolean':
4229
-                return 'bool';
4230
-            case 'integer':
4231
-                return 'int';
4232
-            case 'number':
4233
-                return 'float';
4234
-            case 'string':
4235
-                return 'string';
4236
-        }
4237
-        throw new RuntimeException(
4238
-            sprintf(
4239
-                esc_html__(
4240
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4241
-                    'event_espresso'
4242
-                ),
4243
-                $entity_PK_type,
4244
-                $entity_PK->get_name()
4245
-            )
4246
-        );
4247
-    }
4248
-
4249
-
4250
-    /**
4251
-     * @param EEM_Base      $entity_model
4252
-     * @param int|string    $entity_ID
4253
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4254
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4255
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4256
-     * @return bool
4257
-     */
4258
-    protected function trashRestoreDeleteEntity(
4259
-        EEM_Base $entity_model,
4260
-        $entity_ID,
4261
-        string $action,
4262
-        string $delete_column,
4263
-        ?callable $callback = null
4264
-    ): bool {
4265
-        $entity_ID = absint($entity_ID);
4266
-        if (! $entity_ID) {
4267
-            $this->trashRestoreDeleteError($action, $entity_model);
4268
-        }
4269
-        $result = 0;
4270
-        try {
4271
-            $entity = $entity_model->get_one_by_ID($entity_ID);
4272
-            if (! $entity instanceof EE_Base_Class) {
4273
-                throw new DomainException(
4274
-                    sprintf(
4275
-                        esc_html__(
4276
-                            'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4277
-                            'event_espresso'
4278
-                        ),
4279
-                        str_replace('EEM_', '', $entity_model->get_this_model_name()),
4280
-                        $entity_ID
4281
-                    )
4282
-                );
4283
-            }
4284
-            switch ($action) {
4285
-                case EE_Admin_List_Table::ACTION_DELETE:
4286
-                    $result = (bool) $entity->delete_permanently();
4287
-                    break;
4288
-                case EE_Admin_List_Table::ACTION_RESTORE:
4289
-                    $result = $entity->delete_or_restore(false);
4290
-                    break;
4291
-                case EE_Admin_List_Table::ACTION_TRASH:
4292
-                    $result = $entity->delete_or_restore();
4293
-                    break;
4294
-            }
4295
-        } catch (Exception $exception) {
4296
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4297
-        }
4298
-        if (is_callable($callback)) {
4299
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4300
-        }
4301
-        return $result;
4302
-    }
4303
-
4304
-
4305
-    /**
4306
-     * @param EEM_Base $entity_model
4307
-     * @param string   $delete_column
4308
-     * @since 4.10.30.p
4309
-     */
4310
-    private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4311
-    {
4312
-        if (empty($delete_column)) {
4313
-            throw new DomainException(
4314
-                sprintf(
4315
-                    esc_html__(
4316
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4317
-                        'event_espresso'
4318
-                    ),
4319
-                    $entity_model->get_this_model_name()
4320
-                )
4321
-            );
4322
-        }
4323
-        if (! $entity_model->has_field($delete_column)) {
4324
-            throw new DomainException(
4325
-                sprintf(
4326
-                    esc_html__(
4327
-                        'The %1$s field does not exist on the %2$s model.',
4328
-                        'event_espresso'
4329
-                    ),
4330
-                    $delete_column,
4331
-                    $entity_model->get_this_model_name()
4332
-                )
4333
-            );
4334
-        }
4335
-    }
4336
-
4337
-
4338
-    /**
4339
-     * @param EEM_Base       $entity_model
4340
-     * @param Exception|null $exception
4341
-     * @param string         $action
4342
-     * @since 4.10.30.p
4343
-     */
4344
-    private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4345
-    {
4346
-        if ($exception instanceof Exception) {
4347
-            throw new RuntimeException(
4348
-                sprintf(
4349
-                    esc_html__(
4350
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4351
-                        'event_espresso'
4352
-                    ),
4353
-                    $action,
4354
-                    $entity_model->get_this_model_name(),
4355
-                    $exception->getMessage()
4356
-                )
4357
-            );
4358
-        }
4359
-        throw new RuntimeException(
4360
-            sprintf(
4361
-                esc_html__(
4362
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4363
-                    'event_espresso'
4364
-                ),
4365
-                $action,
4366
-                $entity_model->get_this_model_name()
4367
-            )
4368
-        );
4369
-    }
3386
+		// add nonce
3387
+		$nonce                                             =
3388
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3389
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3390
+		// add REQUIRED form action
3391
+		$hidden_fields = [
3392
+			'action' => ['type' => 'hidden', 'value' => $route],
3393
+		];
3394
+		// merge arrays
3395
+		$hidden_fields = is_array($additional_hidden_fields)
3396
+			? array_merge($hidden_fields, $additional_hidden_fields)
3397
+			: $hidden_fields;
3398
+		// generate form fields
3399
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3400
+		// add fields to form
3401
+		foreach ((array) $form_fields as $form_field) {
3402
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3403
+		}
3404
+		// close form
3405
+		$this->_template_args['after_admin_page_content'] = '</form>';
3406
+	}
3407
+
3408
+
3409
+	/**
3410
+	 * Public Wrapper for _redirect_after_action() method since its
3411
+	 * discovered it would be useful for external code to have access.
3412
+	 *
3413
+	 * @param bool   $success
3414
+	 * @param string $what
3415
+	 * @param string $action_desc
3416
+	 * @param array  $query_args
3417
+	 * @param bool   $override_overwrite
3418
+	 * @throws EE_Error
3419
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3420
+	 * @since 4.5.0
3421
+	 */
3422
+	public function redirect_after_action(
3423
+		$success = false,
3424
+		$what = 'item',
3425
+		$action_desc = 'processed',
3426
+		$query_args = [],
3427
+		$override_overwrite = false
3428
+	) {
3429
+		$this->_redirect_after_action(
3430
+			$success,
3431
+			$what,
3432
+			$action_desc,
3433
+			$query_args,
3434
+			$override_overwrite
3435
+		);
3436
+	}
3437
+
3438
+
3439
+	/**
3440
+	 * Helper method for merging existing request data with the returned redirect url.
3441
+	 *
3442
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3443
+	 * filters are still applied.
3444
+	 *
3445
+	 * @param array $new_route_data
3446
+	 * @return array
3447
+	 */
3448
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3449
+	{
3450
+		foreach ($this->request->requestParams() as $ref => $value) {
3451
+			// unset nonces
3452
+			if (strpos($ref, 'nonce') !== false) {
3453
+				$this->request->unSetRequestParam($ref);
3454
+				continue;
3455
+			}
3456
+			// urlencode values.
3457
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3458
+			$this->request->setRequestParam($ref, $value);
3459
+		}
3460
+		return array_merge($this->request->requestParams(), $new_route_data);
3461
+	}
3462
+
3463
+
3464
+	/**
3465
+	 * @param int|float|string $success            - whether success was for two or more records, or just one, or none
3466
+	 * @param string           $what               - what the action was performed on
3467
+	 * @param string           $action_desc        - what was done ie: updated, deleted, etc
3468
+	 * @param array            $query_args         - an array of query_args to be added to the URL to redirect to
3469
+	 * @param BOOL             $override_overwrite - by default all EE_Error::success messages are overwritten,
3470
+	 *                                             this allows you to override this so that they show.
3471
+	 * @return void
3472
+	 * @throws EE_Error
3473
+	 * @throws InvalidArgumentException
3474
+	 * @throws InvalidDataTypeException
3475
+	 * @throws InvalidInterfaceException
3476
+	 */
3477
+	protected function _redirect_after_action(
3478
+		$success = 0,
3479
+		string $what = 'item',
3480
+		string $action_desc = 'processed',
3481
+		array $query_args = [],
3482
+		bool $override_overwrite = false
3483
+	) {
3484
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3485
+		$notices = EE_Error::get_notices(false);
3486
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3487
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3488
+			EE_Error::overwrite_success();
3489
+		}
3490
+		if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3491
+			// how many records affected ? more than one record ? or just one ?
3492
+			EE_Error::add_success(
3493
+				sprintf(
3494
+					esc_html(
3495
+						_n(
3496
+							'The "%1$s" has been successfully %2$s.',
3497
+							'The "%1$s" have been successfully %2$s.',
3498
+							$success,
3499
+							'event_espresso'
3500
+						)
3501
+					),
3502
+					$what,
3503
+					$action_desc
3504
+				),
3505
+				__FILE__,
3506
+				__FUNCTION__,
3507
+				__LINE__
3508
+			);
3509
+		}
3510
+		// check that $query_args isn't something crazy
3511
+		if (! is_array($query_args)) {
3512
+			$query_args = [];
3513
+		}
3514
+		/**
3515
+		 * Allow injecting actions before the query_args are modified for possible different
3516
+		 * redirections on save and close actions
3517
+		 *
3518
+		 * @param array $query_args       The original query_args array coming into the
3519
+		 *                                method.
3520
+		 * @since 4.2.0
3521
+		 */
3522
+		do_action(
3523
+			"AHEE__{$this->class_name}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3524
+			$query_args
3525
+		);
3526
+		// set redirect url.
3527
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3528
+		// otherwise we go with whatever is set as the _admin_base_url
3529
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3530
+		// calculate where we're going (if we have a "save and close" button pushed)
3531
+		if (
3532
+			$this->request->requestParamIsSet('save_and_close')
3533
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3534
+		) {
3535
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3536
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3537
+			// regenerate query args array from referrer URL
3538
+			parse_str($parsed_url['query'], $query_args);
3539
+			// correct page and action will be in the query args now
3540
+			$redirect_url = admin_url('admin.php');
3541
+		}
3542
+		// merge any default query_args set in _default_route_query_args property
3543
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3544
+			$args_to_merge = [];
3545
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3546
+				// is there a wp_referer array in our _default_route_query_args property?
3547
+				if ($query_param === 'wp_referer') {
3548
+					$query_value = (array) $query_value;
3549
+					foreach ($query_value as $reference => $value) {
3550
+						if (strpos($reference, 'nonce') !== false) {
3551
+							continue;
3552
+						}
3553
+						// finally we will override any arguments in the referer with
3554
+						// what might be set on the _default_route_query_args array.
3555
+						if (isset($this->_default_route_query_args[ $reference ])) {
3556
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3557
+						} else {
3558
+							$args_to_merge[ $reference ] = urlencode($value);
3559
+						}
3560
+					}
3561
+					continue;
3562
+				}
3563
+				$args_to_merge[ $query_param ] = $query_value;
3564
+			}
3565
+			// now let's merge these arguments but override with what was specifically sent in to the
3566
+			// redirect.
3567
+			$query_args = array_merge($args_to_merge, $query_args);
3568
+		}
3569
+		$this->_process_notices($query_args);
3570
+		// generate redirect url
3571
+		// if redirecting to anything other than the main page, add a nonce
3572
+		if (isset($query_args['action'])) {
3573
+			// manually generate wp_nonce and merge that with the query vars
3574
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3575
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3576
+		}
3577
+		// we're adding some hooks and filters in here for processing any things just before redirects
3578
+		// (example: an admin page has done an insert or update and we want to run something after that).
3579
+		do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3580
+		$redirect_url = apply_filters(
3581
+			'FHEE_redirect_' . $this->class_name . $this->_req_action,
3582
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3583
+			$query_args
3584
+		);
3585
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3586
+		if ($this->request->isAjax()) {
3587
+			$default_data                    = [
3588
+				'close'        => true,
3589
+				'redirect_url' => $redirect_url,
3590
+				'where'        => 'main',
3591
+				'what'         => 'append',
3592
+			];
3593
+			$this->_template_args['success'] = $success;
3594
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3595
+				$default_data,
3596
+				$this->_template_args['data']
3597
+			) : $default_data;
3598
+			$this->_return_json();
3599
+		}
3600
+		wp_safe_redirect($redirect_url);
3601
+		exit();
3602
+	}
3603
+
3604
+
3605
+	/**
3606
+	 * process any notices before redirecting (or returning ajax request)
3607
+	 * This method sets the $this->_template_args['notices'] attribute;
3608
+	 *
3609
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3610
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3611
+	 *                                  page_routes haven't been defined yet.
3612
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3613
+	 *                                  still save a transient for the notice.
3614
+	 * @return void
3615
+	 * @throws EE_Error
3616
+	 * @throws InvalidArgumentException
3617
+	 * @throws InvalidDataTypeException
3618
+	 * @throws InvalidInterfaceException
3619
+	 */
3620
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3621
+	{
3622
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3623
+		if ($this->request->isAjax()) {
3624
+			$notices = EE_Error::get_notices(false);
3625
+			if (empty($this->_template_args['success'])) {
3626
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3627
+			}
3628
+			if (empty($this->_template_args['errors'])) {
3629
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3630
+			}
3631
+			if (empty($this->_template_args['attention'])) {
3632
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3633
+			}
3634
+		}
3635
+		$this->_template_args['notices'] = EE_Error::get_notices();
3636
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3637
+		if (! $this->request->isAjax() || $sticky_notices) {
3638
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3639
+			$this->_add_transient(
3640
+				$route,
3641
+				$this->_template_args['notices'],
3642
+				true,
3643
+				$skip_route_verify
3644
+			);
3645
+		}
3646
+	}
3647
+
3648
+
3649
+	/**
3650
+	 * get_action_link_or_button
3651
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3652
+	 *
3653
+	 * @param string $action        use this to indicate which action the url is generated with.
3654
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3655
+	 *                              property.
3656
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3657
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3658
+	 * @param string $base_url      If this is not provided
3659
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3660
+	 *                              Otherwise this value will be used.
3661
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3662
+	 * @return string
3663
+	 * @throws InvalidArgumentException
3664
+	 * @throws InvalidInterfaceException
3665
+	 * @throws InvalidDataTypeException
3666
+	 * @throws EE_Error
3667
+	 */
3668
+	public function get_action_link_or_button(
3669
+		$action,
3670
+		$type = 'add',
3671
+		$extra_request = [],
3672
+		$class = 'button button--primary',
3673
+		$base_url = '',
3674
+		$exclude_nonce = false
3675
+	) {
3676
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3677
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3678
+			throw new EE_Error(
3679
+				sprintf(
3680
+					esc_html__(
3681
+						'There is no page route for given action for the button.  This action was given: %s',
3682
+						'event_espresso'
3683
+					),
3684
+					$action
3685
+				)
3686
+			);
3687
+		}
3688
+		if (! isset($this->_labels['buttons'][ $type ])) {
3689
+			throw new EE_Error(
3690
+				sprintf(
3691
+					esc_html__(
3692
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3693
+						'event_espresso'
3694
+					),
3695
+					$type
3696
+				)
3697
+			);
3698
+		}
3699
+		// finally check user access for this button.
3700
+		$has_access = $this->check_user_access($action, true);
3701
+		if (! $has_access) {
3702
+			return '';
3703
+		}
3704
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3705
+		$query_args = [
3706
+			'action' => $action,
3707
+		];
3708
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3709
+		if (! empty($extra_request)) {
3710
+			$query_args = array_merge($extra_request, $query_args);
3711
+		}
3712
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3713
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3714
+	}
3715
+
3716
+
3717
+	/**
3718
+	 * _per_page_screen_option
3719
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3720
+	 *
3721
+	 * @return void
3722
+	 * @throws InvalidArgumentException
3723
+	 * @throws InvalidInterfaceException
3724
+	 * @throws InvalidDataTypeException
3725
+	 */
3726
+	protected function _per_page_screen_option()
3727
+	{
3728
+		$option = 'per_page';
3729
+		$args   = [
3730
+			'label'   => apply_filters(
3731
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3732
+				$this->_admin_page_title,
3733
+				$this
3734
+			),
3735
+			'default' => (int) apply_filters(
3736
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3737
+				20
3738
+			),
3739
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3740
+		];
3741
+		// ONLY add the screen option if the user has access to it.
3742
+		if ($this->check_user_access($this->_current_view, true)) {
3743
+			add_screen_option($option, $args);
3744
+		}
3745
+	}
3746
+
3747
+
3748
+	/**
3749
+	 * set_per_page_screen_option
3750
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3751
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3752
+	 * admin_menu.
3753
+	 *
3754
+	 * @return void
3755
+	 */
3756
+	private function _set_per_page_screen_options()
3757
+	{
3758
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3759
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3760
+			if (! $user = wp_get_current_user()) {
3761
+				return;
3762
+			}
3763
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3764
+			if (! $option) {
3765
+				return;
3766
+			}
3767
+			$value      = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3768
+			$map_option = $option;
3769
+			$option     = str_replace('-', '_', $option);
3770
+			switch ($map_option) {
3771
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3772
+					$max_value = apply_filters(
3773
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3774
+						999,
3775
+						$this->_current_page,
3776
+						$this->_current_view
3777
+					);
3778
+					if ($value < 1) {
3779
+						return;
3780
+					}
3781
+					$value = min($value, $max_value);
3782
+					break;
3783
+				default:
3784
+					$value = apply_filters(
3785
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3786
+						false,
3787
+						$option,
3788
+						$value
3789
+					);
3790
+					if (false === $value) {
3791
+						return;
3792
+					}
3793
+					break;
3794
+			}
3795
+			update_user_meta($user->ID, $option, $value);
3796
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3797
+			exit;
3798
+		}
3799
+	}
3800
+
3801
+
3802
+	/**
3803
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3804
+	 *
3805
+	 * @param array $data array that will be assigned to template args.
3806
+	 */
3807
+	public function set_template_args($data)
3808
+	{
3809
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3810
+	}
3811
+
3812
+
3813
+	/**
3814
+	 * This makes available the WP transient system for temporarily moving data between routes
3815
+	 *
3816
+	 * @param string $route             the route that should receive the transient
3817
+	 * @param array  $data              the data that gets sent
3818
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3819
+	 *                                  normal route transient.
3820
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3821
+	 *                                  when we are adding a transient before page_routes have been defined.
3822
+	 * @return void
3823
+	 * @throws EE_Error
3824
+	 */
3825
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826
+	{
3827
+		$user_id = get_current_user_id();
3828
+		if (! $skip_route_verify) {
3829
+			$this->_verify_route($route);
3830
+		}
3831
+		// now let's set the string for what kind of transient we're setting
3832
+		$transient = $notices
3833
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
+			: 'rte_tx_' . $route . '_' . $user_id;
3835
+		$data      = $notices ? ['notices' => $data] : $data;
3836
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3837
+		$existing = is_multisite() && is_network_admin()
3838
+			? get_site_transient($transient)
3839
+			: get_transient($transient);
3840
+		if ($existing) {
3841
+			$data = array_merge((array) $data, (array) $existing);
3842
+		}
3843
+		if (is_multisite() && is_network_admin()) {
3844
+			set_site_transient($transient, $data, 8);
3845
+		} else {
3846
+			set_transient($transient, $data, 8);
3847
+		}
3848
+	}
3849
+
3850
+
3851
+	/**
3852
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3853
+	 *
3854
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3855
+	 * @param string $route
3856
+	 * @return mixed data
3857
+	 */
3858
+	protected function _get_transient($notices = false, $route = '')
3859
+	{
3860
+		$user_id   = get_current_user_id();
3861
+		$route     = ! $route ? $this->_req_action : $route;
3862
+		$transient = $notices
3863
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
+			: 'rte_tx_' . $route . '_' . $user_id;
3865
+		$data      = is_multisite() && is_network_admin()
3866
+			? get_site_transient($transient)
3867
+			: get_transient($transient);
3868
+		// delete transient after retrieval (just in case it hasn't expired);
3869
+		if (is_multisite() && is_network_admin()) {
3870
+			delete_site_transient($transient);
3871
+		} else {
3872
+			delete_transient($transient);
3873
+		}
3874
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3875
+	}
3876
+
3877
+
3878
+	/**
3879
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3880
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3881
+	 * default route callback on the EE_Admin page you want it run.)
3882
+	 *
3883
+	 * @return void
3884
+	 */
3885
+	protected function _transient_garbage_collection()
3886
+	{
3887
+		global $wpdb;
3888
+		// retrieve all existing transients
3889
+		$query =
3890
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3891
+		if ($results = $wpdb->get_results($query)) {
3892
+			foreach ($results as $result) {
3893
+				$transient = str_replace('_transient_', '', $result->option_name);
3894
+				get_transient($transient);
3895
+				if (is_multisite() && is_network_admin()) {
3896
+					get_site_transient($transient);
3897
+				}
3898
+			}
3899
+		}
3900
+	}
3901
+
3902
+
3903
+	/**
3904
+	 * get_view
3905
+	 *
3906
+	 * @return string content of _view property
3907
+	 */
3908
+	public function get_view()
3909
+	{
3910
+		return $this->_view;
3911
+	}
3912
+
3913
+
3914
+	/**
3915
+	 * getter for the protected $_views property
3916
+	 *
3917
+	 * @return array
3918
+	 */
3919
+	public function get_views()
3920
+	{
3921
+		return $this->_views;
3922
+	}
3923
+
3924
+
3925
+	/**
3926
+	 * get_current_page
3927
+	 *
3928
+	 * @return string _current_page property value
3929
+	 */
3930
+	public function get_current_page()
3931
+	{
3932
+		return $this->_current_page;
3933
+	}
3934
+
3935
+
3936
+	/**
3937
+	 * get_current_view
3938
+	 *
3939
+	 * @return string _current_view property value
3940
+	 */
3941
+	public function get_current_view()
3942
+	{
3943
+		return $this->_current_view;
3944
+	}
3945
+
3946
+
3947
+	/**
3948
+	 * get_current_screen
3949
+	 *
3950
+	 * @return object The current WP_Screen object
3951
+	 */
3952
+	public function get_current_screen()
3953
+	{
3954
+		return $this->_current_screen;
3955
+	}
3956
+
3957
+
3958
+	/**
3959
+	 * get_current_page_view_url
3960
+	 *
3961
+	 * @return string This returns the url for the current_page_view.
3962
+	 */
3963
+	public function get_current_page_view_url()
3964
+	{
3965
+		return $this->_current_page_view_url;
3966
+	}
3967
+
3968
+
3969
+	/**
3970
+	 * just returns the Request
3971
+	 *
3972
+	 * @return RequestInterface
3973
+	 */
3974
+	public function get_request()
3975
+	{
3976
+		return $this->request;
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * just returns the _req_data property
3982
+	 *
3983
+	 * @return array
3984
+	 */
3985
+	public function get_request_data()
3986
+	{
3987
+		return $this->request->requestParams();
3988
+	}
3989
+
3990
+
3991
+	/**
3992
+	 * returns the _req_data protected property
3993
+	 *
3994
+	 * @return string
3995
+	 */
3996
+	public function get_req_action()
3997
+	{
3998
+		return $this->_req_action;
3999
+	}
4000
+
4001
+
4002
+	/**
4003
+	 * @return bool  value of $_is_caf property
4004
+	 */
4005
+	public function is_caf()
4006
+	{
4007
+		return $this->_is_caf;
4008
+	}
4009
+
4010
+
4011
+	/**
4012
+	 * @return mixed
4013
+	 */
4014
+	public function default_espresso_metaboxes()
4015
+	{
4016
+		return $this->_default_espresso_metaboxes;
4017
+	}
4018
+
4019
+
4020
+	/**
4021
+	 * @return mixed
4022
+	 */
4023
+	public function admin_base_url()
4024
+	{
4025
+		return $this->_admin_base_url;
4026
+	}
4027
+
4028
+
4029
+	/**
4030
+	 * @return mixed
4031
+	 */
4032
+	public function wp_page_slug()
4033
+	{
4034
+		return $this->_wp_page_slug;
4035
+	}
4036
+
4037
+
4038
+	/**
4039
+	 * updates  espresso configuration settings
4040
+	 *
4041
+	 * @param string                   $tab
4042
+	 * @param EE_Config_Base|EE_Config $config
4043
+	 * @param string                   $file file where error occurred
4044
+	 * @param string                   $func function  where error occurred
4045
+	 * @param string                   $line line no where error occurred
4046
+	 * @return boolean
4047
+	 */
4048
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4049
+	{
4050
+		// remove any options that are NOT going to be saved with the config settings.
4051
+		if (isset($config->core->ee_ueip_optin)) {
4052
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4053
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4054
+			update_option('ee_ueip_has_notified', true);
4055
+		}
4056
+		// and save it (note we're also doing the network save here)
4057
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
4058
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4059
+		if ($config_saved && $net_saved) {
4060
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4061
+			return true;
4062
+		}
4063
+		EE_Error::add_error(
4064
+			sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab),
4065
+			$file,
4066
+			$func,
4067
+			$line
4068
+		);
4069
+		return false;
4070
+	}
4071
+
4072
+
4073
+	/**
4074
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4075
+	 *
4076
+	 * @return array
4077
+	 */
4078
+	public function get_yes_no_values()
4079
+	{
4080
+		return $this->_yes_no_values;
4081
+	}
4082
+
4083
+
4084
+	/**
4085
+	 * @return string
4086
+	 * @throws ReflectionException
4087
+	 * @since $VID:$
4088
+	 */
4089
+	protected function _get_dir()
4090
+	{
4091
+		$reflector = new ReflectionClass($this->class_name);
4092
+		return dirname($reflector->getFileName());
4093
+	}
4094
+
4095
+
4096
+	/**
4097
+	 * A helper for getting a "next link".
4098
+	 *
4099
+	 * @param string $url   The url to link to
4100
+	 * @param string $class The class to use.
4101
+	 * @return string
4102
+	 */
4103
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4104
+	{
4105
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4106
+	}
4107
+
4108
+
4109
+	/**
4110
+	 * A helper for getting a "previous link".
4111
+	 *
4112
+	 * @param string $url   The url to link to
4113
+	 * @param string $class The class to use.
4114
+	 * @return string
4115
+	 */
4116
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4117
+	{
4118
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4119
+	}
4120
+
4121
+
4122
+
4123
+
4124
+
4125
+
4126
+
4127
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4128
+
4129
+
4130
+	/**
4131
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4132
+	 * 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
4133
+	 * _req_data array.
4134
+	 *
4135
+	 * @return bool success/fail
4136
+	 * @throws EE_Error
4137
+	 * @throws InvalidArgumentException
4138
+	 * @throws ReflectionException
4139
+	 * @throws InvalidDataTypeException
4140
+	 * @throws InvalidInterfaceException
4141
+	 */
4142
+	protected function _process_resend_registration()
4143
+	{
4144
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4145
+		do_action(
4146
+			'AHEE__EE_Admin_Page___process_resend_registration',
4147
+			$this->_template_args['success'],
4148
+			$this->request->requestParams()
4149
+		);
4150
+		return $this->_template_args['success'];
4151
+	}
4152
+
4153
+
4154
+	/**
4155
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4156
+	 *
4157
+	 * @param EE_Payment $payment
4158
+	 * @return bool success/fail
4159
+	 */
4160
+	protected function _process_payment_notification(EE_Payment $payment)
4161
+	{
4162
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4163
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4164
+		$this->_template_args['success'] = apply_filters(
4165
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4166
+			false,
4167
+			$payment
4168
+		);
4169
+		return $this->_template_args['success'];
4170
+	}
4171
+
4172
+
4173
+	/**
4174
+	 * @param EEM_Base      $entity_model
4175
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4176
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4177
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4178
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4179
+	 * @return int|float
4180
+	 * @throws EE_Error
4181
+	 */
4182
+	protected function trashRestoreDeleteEntities(
4183
+		EEM_Base $entity_model,
4184
+		$entity_PK_name,
4185
+		$action = EE_Admin_List_Table::ACTION_DELETE,
4186
+		$delete_column = '',
4187
+		callable $callback = null
4188
+	) {
4189
+		$entity_PK      = $entity_model->get_primary_key_field();
4190
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4191
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4192
+		// grab ID if deleting a single entity
4193
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4194
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4195
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4196
+		}
4197
+		// or grab checkbox array if bulk deleting
4198
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4199
+		if (empty($checkboxes)) {
4200
+			return 0;
4201
+		}
4202
+		$success = 0;
4203
+		$IDs     = array_keys($checkboxes);
4204
+		// cycle thru bulk action checkboxes
4205
+		foreach ($IDs as $ID) {
4206
+			// increment $success
4207
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4208
+				$success++;
4209
+			}
4210
+		}
4211
+		$count = (int) count($checkboxes);
4212
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4213
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4214
+		return $success === $count ? $count : $success / $count;
4215
+	}
4216
+
4217
+
4218
+	/**
4219
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4220
+	 * @return string
4221
+	 * @throws EE_Error
4222
+	 * @since   4.10.30.p
4223
+	 */
4224
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4225
+	{
4226
+		$entity_PK_type = $entity_PK->getSchemaType();
4227
+		switch ($entity_PK_type) {
4228
+			case 'boolean':
4229
+				return 'bool';
4230
+			case 'integer':
4231
+				return 'int';
4232
+			case 'number':
4233
+				return 'float';
4234
+			case 'string':
4235
+				return 'string';
4236
+		}
4237
+		throw new RuntimeException(
4238
+			sprintf(
4239
+				esc_html__(
4240
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4241
+					'event_espresso'
4242
+				),
4243
+				$entity_PK_type,
4244
+				$entity_PK->get_name()
4245
+			)
4246
+		);
4247
+	}
4248
+
4249
+
4250
+	/**
4251
+	 * @param EEM_Base      $entity_model
4252
+	 * @param int|string    $entity_ID
4253
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4254
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4255
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4256
+	 * @return bool
4257
+	 */
4258
+	protected function trashRestoreDeleteEntity(
4259
+		EEM_Base $entity_model,
4260
+		$entity_ID,
4261
+		string $action,
4262
+		string $delete_column,
4263
+		?callable $callback = null
4264
+	): bool {
4265
+		$entity_ID = absint($entity_ID);
4266
+		if (! $entity_ID) {
4267
+			$this->trashRestoreDeleteError($action, $entity_model);
4268
+		}
4269
+		$result = 0;
4270
+		try {
4271
+			$entity = $entity_model->get_one_by_ID($entity_ID);
4272
+			if (! $entity instanceof EE_Base_Class) {
4273
+				throw new DomainException(
4274
+					sprintf(
4275
+						esc_html__(
4276
+							'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4277
+							'event_espresso'
4278
+						),
4279
+						str_replace('EEM_', '', $entity_model->get_this_model_name()),
4280
+						$entity_ID
4281
+					)
4282
+				);
4283
+			}
4284
+			switch ($action) {
4285
+				case EE_Admin_List_Table::ACTION_DELETE:
4286
+					$result = (bool) $entity->delete_permanently();
4287
+					break;
4288
+				case EE_Admin_List_Table::ACTION_RESTORE:
4289
+					$result = $entity->delete_or_restore(false);
4290
+					break;
4291
+				case EE_Admin_List_Table::ACTION_TRASH:
4292
+					$result = $entity->delete_or_restore();
4293
+					break;
4294
+			}
4295
+		} catch (Exception $exception) {
4296
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4297
+		}
4298
+		if (is_callable($callback)) {
4299
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4300
+		}
4301
+		return $result;
4302
+	}
4303
+
4304
+
4305
+	/**
4306
+	 * @param EEM_Base $entity_model
4307
+	 * @param string   $delete_column
4308
+	 * @since 4.10.30.p
4309
+	 */
4310
+	private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4311
+	{
4312
+		if (empty($delete_column)) {
4313
+			throw new DomainException(
4314
+				sprintf(
4315
+					esc_html__(
4316
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4317
+						'event_espresso'
4318
+					),
4319
+					$entity_model->get_this_model_name()
4320
+				)
4321
+			);
4322
+		}
4323
+		if (! $entity_model->has_field($delete_column)) {
4324
+			throw new DomainException(
4325
+				sprintf(
4326
+					esc_html__(
4327
+						'The %1$s field does not exist on the %2$s model.',
4328
+						'event_espresso'
4329
+					),
4330
+					$delete_column,
4331
+					$entity_model->get_this_model_name()
4332
+				)
4333
+			);
4334
+		}
4335
+	}
4336
+
4337
+
4338
+	/**
4339
+	 * @param EEM_Base       $entity_model
4340
+	 * @param Exception|null $exception
4341
+	 * @param string         $action
4342
+	 * @since 4.10.30.p
4343
+	 */
4344
+	private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4345
+	{
4346
+		if ($exception instanceof Exception) {
4347
+			throw new RuntimeException(
4348
+				sprintf(
4349
+					esc_html__(
4350
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4351
+						'event_espresso'
4352
+					),
4353
+					$action,
4354
+					$entity_model->get_this_model_name(),
4355
+					$exception->getMessage()
4356
+				)
4357
+			);
4358
+		}
4359
+		throw new RuntimeException(
4360
+			sprintf(
4361
+				esc_html__(
4362
+					'Could not %1$s the %2$s because an invalid ID was received.',
4363
+					'event_espresso'
4364
+				),
4365
+				$action,
4366
+				$entity_model->get_this_model_name()
4367
+			)
4368
+		);
4369
+	}
4370 4370
 }
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         $ee_menu_slugs = (array) $ee_menu_slugs;
638 638
         if (
639 639
             ! $this->request->isAjax()
640
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
640
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
641 641
         ) {
642 642
             return;
643 643
         }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
             : $req_action;
658 658
 
659 659
         $this->_current_view = $this->_req_action;
660
-        $this->_req_nonce    = $this->_req_action . '_nonce';
660
+        $this->_req_nonce    = $this->_req_action.'_nonce';
661 661
         $this->_define_page_props();
662 662
         $this->_current_page_view_url = add_query_arg(
663 663
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -681,33 +681,33 @@  discard block
 block discarded – undo
681 681
         }
682 682
         // filter routes and page_config so addons can add their stuff. Filtering done per class
683 683
         $this->_page_routes = apply_filters(
684
-            'FHEE__' . $this->class_name . '__page_setup__page_routes',
684
+            'FHEE__'.$this->class_name.'__page_setup__page_routes',
685 685
             $this->_page_routes,
686 686
             $this
687 687
         );
688 688
         $this->_page_config = apply_filters(
689
-            'FHEE__' . $this->class_name . '__page_setup__page_config',
689
+            'FHEE__'.$this->class_name.'__page_setup__page_config',
690 690
             $this->_page_config,
691 691
             $this
692 692
         );
693 693
         if ($this->base_class_name !== '') {
694 694
             $this->_page_routes = apply_filters(
695
-                'FHEE__' . $this->base_class_name . '__page_setup__page_routes',
695
+                'FHEE__'.$this->base_class_name.'__page_setup__page_routes',
696 696
                 $this->_page_routes,
697 697
                 $this
698 698
             );
699 699
             $this->_page_config = apply_filters(
700
-                'FHEE__' . $this->base_class_name . '__page_setup__page_config',
700
+                'FHEE__'.$this->base_class_name.'__page_setup__page_config',
701 701
                 $this->_page_config,
702 702
                 $this
703 703
             );
704 704
         }
705 705
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
706 706
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
707
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
707
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
708 708
             add_action(
709 709
                 'AHEE__EE_Admin_Page__route_admin_request',
710
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
710
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
711 711
                 10,
712 712
                 2
713 713
             );
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
             if ($this->_is_UI_request) {
721 721
                 // admin_init stuff - global, all views for this page class, specific view
722 722
                 add_action('admin_init', [$this, 'admin_init'], 10);
723
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
724
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
723
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
724
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
725 725
                 }
726 726
             } else {
727 727
                 // hijack regular WP loading and route admin request immediately
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
      */
741 741
     private function _do_other_page_hooks()
742 742
     {
743
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
743
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
744 744
         foreach ($registered_pages as $page) {
745 745
             // now let's setup the file name and class that should be present
746 746
             $classname = str_replace('.class.php', '', $page);
747 747
             // autoloaders should take care of loading file
748
-            if (! class_exists($classname)) {
748
+            if ( ! class_exists($classname)) {
749 749
                 $error_msg[] = sprintf(
750 750
                     esc_html__(
751 751
                         'Something went wrong with loading the %s admin hooks page.',
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
                                    ),
763 763
                                    $page,
764 764
                                    '<br />',
765
-                                   '<strong>' . $classname . '</strong>'
765
+                                   '<strong>'.$classname.'</strong>'
766 766
                                );
767 767
                 throw new EE_Error(implode('||', $error_msg));
768 768
             }
@@ -804,13 +804,13 @@  discard block
 block discarded – undo
804 804
         // load admin_notices - global, page class, and view specific
805 805
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
806 806
         add_action('admin_notices', [$this, 'admin_notices'], 10);
807
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
808
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
807
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
808
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
809 809
         }
810 810
         // load network admin_notices - global, page class, and view specific
811 811
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
812
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
813
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
812
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
813
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
814 814
         }
815 815
         // this will save any per_page screen options if they are present
816 816
         $this->_set_per_page_screen_options();
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
     protected function _verify_routes()
939 939
     {
940 940
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
941
-        if (! $this->_current_page && ! $this->request->isAjax()) {
941
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
942 942
             return false;
943 943
         }
944 944
         $this->_route = false;
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
                 $this->_admin_page_title
951 951
             );
952 952
             // developer error msg
953
-            $error_msg .= '||' . $error_msg
953
+            $error_msg .= '||'.$error_msg
954 954
                           . esc_html__(
955 955
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
956 956
                               'event_espresso'
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
         }
960 960
         // and that the requested page route exists
961 961
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
962
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
963
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
962
+            $this->_route        = $this->_page_routes[$this->_req_action];
963
+            $this->_route_config = $this->_page_config[$this->_req_action] ?? [];
964 964
         } else {
965 965
             // user error msg
966 966
             $error_msg = sprintf(
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
                 $this->_admin_page_title
972 972
             );
973 973
             // developer error msg
974
-            $error_msg .= '||' . $error_msg
974
+            $error_msg .= '||'.$error_msg
975 975
                           . sprintf(
976 976
                               esc_html__(
977 977
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
             throw new EE_Error($error_msg);
983 983
         }
984 984
         // and that a default route exists
985
-        if (! array_key_exists('default', $this->_page_routes)) {
985
+        if ( ! array_key_exists('default', $this->_page_routes)) {
986 986
             // user error msg
987 987
             $error_msg = sprintf(
988 988
                 esc_html__(
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
                 $this->_admin_page_title
993 993
             );
994 994
             // developer error msg
995
-            $error_msg .= '||' . $error_msg
995
+            $error_msg .= '||'.$error_msg
996 996
                           . esc_html__(
997 997
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
998 998
                               'event_espresso'
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
             $this->_admin_page_title
1035 1035
         );
1036 1036
         // developer error msg
1037
-        $error_msg .= '||' . $error_msg
1037
+        $error_msg .= '||'.$error_msg
1038 1038
                       . sprintf(
1039 1039
                           esc_html__(
1040 1040
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
     protected function _verify_nonce($nonce, $nonce_ref)
1063 1063
     {
1064 1064
         // verify nonce against expected value
1065
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1065
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
1066 1066
             // these are not the droids you are looking for !!!
1067 1067
             $msg = sprintf(
1068 1068
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
                     __CLASS__
1080 1080
                 );
1081 1081
             }
1082
-            if (! $this->request->isAjax()) {
1082
+            if ( ! $this->request->isAjax()) {
1083 1083
                 wp_die($msg);
1084 1084
             }
1085 1085
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
      */
1104 1104
     protected function _route_admin_request()
1105 1105
     {
1106
-        if (! $this->_is_UI_request) {
1106
+        if ( ! $this->_is_UI_request) {
1107 1107
             $this->_verify_routes();
1108 1108
         }
1109 1109
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
         $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1125 1125
         // action right before calling route
1126 1126
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1127
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1127
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1128 1128
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1129 1129
         }
1130 1130
         // strip _wp_http_referer from the server REQUEST_URI
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
         $this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri, true);
1140 1140
         $this->request->setServerParam('REQUEST_URI', $cleaner_request_uri, true);
1141 1141
         $route_callback = [];
1142
-        if (! empty($func)) {
1142
+        if ( ! empty($func)) {
1143 1143
             if (is_array($func)) {
1144 1144
                 $route_callback = $func;
1145 1145
             } elseif (is_string($func)) {
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             }
1154 1154
             [$class, $method] = $route_callback;
1155 1155
             // is it neither a class method NOR a standalone function?
1156
-            if (! is_callable($route_callback)) {
1156
+            if ( ! is_callable($route_callback)) {
1157 1157
                 // user error msg
1158 1158
                 $error_msg = esc_html__(
1159 1159
                     'An error occurred. The  requested page route could not be found.',
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
                 $arg_keys = array_keys($args);
1181 1181
                 $nice_args = [];
1182 1182
                 foreach ($args as $key => $arg) {
1183
-                    $nice_args[ $key ] = is_object($arg) ? get_class($arg) : $arg_keys[ $key ];
1183
+                    $nice_args[$key] = is_object($arg) ? get_class($arg) : $arg_keys[$key];
1184 1184
                 }
1185 1185
                 new ExceptionStackTraceDisplay(
1186 1186
                         new RuntimeException(
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
                 if (strpos($key, 'nonce') !== false) {
1284 1284
                     continue;
1285 1285
                 }
1286
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1286
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1287 1287
             }
1288 1288
         }
1289 1289
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce, $context);
@@ -1323,12 +1323,12 @@  discard block
 block discarded – undo
1323 1323
      */
1324 1324
     protected function _add_help_tabs()
1325 1325
     {
1326
-        if (isset($this->_page_config[ $this->_req_action ])) {
1327
-            $config = $this->_page_config[ $this->_req_action ];
1326
+        if (isset($this->_page_config[$this->_req_action])) {
1327
+            $config = $this->_page_config[$this->_req_action];
1328 1328
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1329 1329
             if (is_array($config) && isset($config['help_sidebar'])) {
1330 1330
                 // check that the callback given is valid
1331
-                if (! method_exists($this, $config['help_sidebar'])) {
1331
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1332 1332
                     throw new EE_Error(
1333 1333
                         sprintf(
1334 1334
                             esc_html__(
@@ -1341,18 +1341,18 @@  discard block
 block discarded – undo
1341 1341
                     );
1342 1342
                 }
1343 1343
                 $content = apply_filters(
1344
-                    'FHEE__' . $this->class_name . '__add_help_tabs__help_sidebar',
1344
+                    'FHEE__'.$this->class_name.'__add_help_tabs__help_sidebar',
1345 1345
                     $this->{$config['help_sidebar']}()
1346 1346
                 );
1347 1347
                 $this->_current_screen->set_help_sidebar($content);
1348 1348
             }
1349
-            if (! isset($config['help_tabs'])) {
1349
+            if ( ! isset($config['help_tabs'])) {
1350 1350
                 return;
1351 1351
             } //no help tabs for this route
1352 1352
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1353 1353
                 // we're here so there ARE help tabs!
1354 1354
                 // make sure we've got what we need
1355
-                if (! isset($cfg['title'])) {
1355
+                if ( ! isset($cfg['title'])) {
1356 1356
                     throw new EE_Error(
1357 1357
                         esc_html__(
1358 1358
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
                         )
1361 1361
                     );
1362 1362
                 }
1363
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1363
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1364 1364
                     throw new EE_Error(
1365 1365
                         esc_html__(
1366 1366
                             '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',
@@ -1369,11 +1369,11 @@  discard block
 block discarded – undo
1369 1369
                     );
1370 1370
                 }
1371 1371
                 // first priority goes to content.
1372
-                if (! empty($cfg['content'])) {
1372
+                if ( ! empty($cfg['content'])) {
1373 1373
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1374 1374
                     // second priority goes to filename
1375
-                } elseif (! empty($cfg['filename'])) {
1376
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1375
+                } elseif ( ! empty($cfg['filename'])) {
1376
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1377 1377
                     // 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)
1378 1378
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1379 1379
                                                              . basename($this->_get_dir())
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
                                                              . $cfg['filename']
1382 1382
                                                              . '.help_tab.php' : $file_path;
1383 1383
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1384
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1384
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1385 1385
                         EE_Error::add_error(
1386 1386
                             sprintf(
1387 1387
                                 esc_html__(
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
                     return;
1430 1430
                 }
1431 1431
                 // setup config array for help tab method
1432
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1432
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1433 1433
                 $_ht = [
1434 1434
                     'id'       => $id,
1435 1435
                     'title'    => $cfg['title'],
@@ -1455,8 +1455,8 @@  discard block
 block discarded – undo
1455 1455
             $qtips = (array) $this->_route_config['qtips'];
1456 1456
             // load qtip loader
1457 1457
             $path = [
1458
-                $this->_get_dir() . '/qtips/',
1459
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1458
+                $this->_get_dir().'/qtips/',
1459
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1460 1460
             ];
1461 1461
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1462 1462
         }
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
         $i        = 0;
1479 1479
         $only_tab = count($this->_page_config) < 2;
1480 1480
         foreach ($this->_page_config as $slug => $config) {
1481
-            if (! is_array($config) || empty($config['nav'])) {
1481
+            if ( ! is_array($config) || empty($config['nav'])) {
1482 1482
                 continue;
1483 1483
             }
1484 1484
             // no nav tab for this config
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
                 // nav tab is only to appear when route requested.
1488 1488
                 continue;
1489 1489
             }
1490
-            if (! $this->check_user_access($slug, true)) {
1490
+            if ( ! $this->check_user_access($slug, true)) {
1491 1491
                 // no nav tab because current user does not have access.
1492 1492
                 continue;
1493 1493
             }
@@ -1495,20 +1495,20 @@  discard block
 block discarded – undo
1495 1495
             $css_class .= $only_tab ? ' ee-only-tab' : '';
1496 1496
             $css_class .= " ee-nav-tab__$slug";
1497 1497
 
1498
-            $this->_nav_tabs[ $slug ] = [
1498
+            $this->_nav_tabs[$slug] = [
1499 1499
                 'url'       => $config['nav']['url'] ?? EE_Admin_Page::add_query_args_and_nonce(
1500 1500
                         ['action' => $slug],
1501 1501
                         $this->_admin_base_url
1502 1502
                     ),
1503 1503
                 'link_text' => $this->navTabLabel($config['nav'], $slug),
1504
-                'css_class' => $this->_req_action === $slug ? $css_class . ' nav-tab-active' : $css_class,
1504
+                'css_class' => $this->_req_action === $slug ? $css_class.' nav-tab-active' : $css_class,
1505 1505
                 'order'     => $config['nav']['order'] ?? $i,
1506 1506
             ];
1507 1507
             $i++;
1508 1508
         }
1509 1509
         // if $this->_nav_tabs is empty then lets set the default
1510 1510
         if (empty($this->_nav_tabs)) {
1511
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1511
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1512 1512
                 'url'       => $this->_admin_base_url,
1513 1513
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1514 1514
                 'css_class' => 'nav-tab-active',
@@ -1524,11 +1524,11 @@  discard block
 block discarded – undo
1524 1524
     {
1525 1525
         $label = $nav_tab['label'] ?? ucwords(str_replace('_', ' ', $slug));
1526 1526
         $icon  = $nav_tab['icon'] ?? null;
1527
-        $icon  = $icon ? '<span class="dashicons ' . $icon . '"></span>' : '';
1527
+        $icon  = $icon ? '<span class="dashicons '.$icon.'"></span>' : '';
1528 1528
         return '
1529 1529
             <span class="ee-admin-screen-tab__label">
1530
-                ' . $icon . '
1531
-                <span class="ee-nav-label__text">' . $label . '</span>
1530
+                ' . $icon.'
1531
+                <span class="ee-nav-label__text">' . $label.'</span>
1532 1532
             </span>';
1533 1533
     }
1534 1534
 
@@ -1546,10 +1546,10 @@  discard block
 block discarded – undo
1546 1546
             foreach ($this->_route_config['labels'] as $label => $text) {
1547 1547
                 if (is_array($text)) {
1548 1548
                     foreach ($text as $sublabel => $subtext) {
1549
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1549
+                        $this->_labels[$label][$sublabel] = $subtext;
1550 1550
                     }
1551 1551
                 } else {
1552
-                    $this->_labels[ $label ] = $text;
1552
+                    $this->_labels[$label] = $text;
1553 1553
                 }
1554 1554
             }
1555 1555
         }
@@ -1571,10 +1571,10 @@  discard block
 block discarded – undo
1571 1571
     {
1572 1572
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1573 1573
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1574
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1575
-                          && is_array($this->_page_routes[ $route_to_check ])
1576
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1577
-            ? $this->_page_routes[ $route_to_check ]['capability']
1574
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1575
+                          && is_array($this->_page_routes[$route_to_check])
1576
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1577
+            ? $this->_page_routes[$route_to_check]['capability']
1578 1578
             : null;
1579 1579
 
1580 1580
         if (empty($capability) && empty($route_to_check)) {
@@ -1628,14 +1628,14 @@  discard block
 block discarded – undo
1628 1628
         string $priority = 'default',
1629 1629
         ?array $callback_args = null
1630 1630
     ) {
1631
-        if (! (is_callable($callback) || ! function_exists($callback))) {
1631
+        if ( ! (is_callable($callback) || ! function_exists($callback))) {
1632 1632
             return;
1633 1633
         }
1634 1634
 
1635 1635
         add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1636 1636
         add_filter(
1637 1637
             "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1638
-            function ($classes) {
1638
+            function($classes) {
1639 1639
                 $classes[] = 'ee-admin-container';
1640 1640
                 return $classes;
1641 1641
             }
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
         ';
1730 1730
 
1731 1731
         // current set timezone for timezone js
1732
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1732
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1733 1733
     }
1734 1734
 
1735 1735
 
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
         // loop through the array and setup content
1764 1764
         foreach ($help_array as $trigger => $help) {
1765 1765
             // make sure the array is setup properly
1766
-            if (! isset($help['title'], $help['content'])) {
1766
+            if ( ! isset($help['title'], $help['content'])) {
1767 1767
                 throw new EE_Error(
1768 1768
                     esc_html__(
1769 1769
                         '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',
@@ -1777,8 +1777,8 @@  discard block
 block discarded – undo
1777 1777
                 'help_popup_title'   => $help['title'],
1778 1778
                 'help_popup_content' => $help['content'],
1779 1779
             ];
1780
-            $content       .= EEH_Template::display_template(
1781
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1780
+            $content .= EEH_Template::display_template(
1781
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1782 1782
                 $template_args,
1783 1783
                 true
1784 1784
             );
@@ -1800,15 +1800,15 @@  discard block
 block discarded – undo
1800 1800
     private function _get_help_content()
1801 1801
     {
1802 1802
         // what is the method we're looking for?
1803
-        $method_name = '_help_popup_content_' . $this->_req_action;
1803
+        $method_name = '_help_popup_content_'.$this->_req_action;
1804 1804
         // if method doesn't exist let's get out.
1805
-        if (! method_exists($this, $method_name)) {
1805
+        if ( ! method_exists($this, $method_name)) {
1806 1806
             return [];
1807 1807
         }
1808 1808
         // k we're good to go let's retrieve the help array
1809 1809
         $help_array = $this->{$method_name}();
1810 1810
         // make sure we've got an array!
1811
-        if (! is_array($help_array)) {
1811
+        if ( ! is_array($help_array)) {
1812 1812
             throw new EE_Error(
1813 1813
                 esc_html__(
1814 1814
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1840,15 +1840,15 @@  discard block
 block discarded – undo
1840 1840
         // 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
1841 1841
         $help_array   = $this->_get_help_content();
1842 1842
         $help_content = '';
1843
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1844
-            $help_array[ $trigger_id ] = [
1843
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1844
+            $help_array[$trigger_id] = [
1845 1845
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1846 1846
                 'content' => esc_html__(
1847 1847
                     '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.)',
1848 1848
                     'event_espresso'
1849 1849
                 ),
1850 1850
             ];
1851
-            $help_content              = $this->_set_help_popup_content($help_array);
1851
+            $help_content = $this->_set_help_popup_content($help_array);
1852 1852
         }
1853 1853
         // let's setup the trigger
1854 1854
         $content = '<a class="ee-dialog" href="?height='
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
 
1937 1937
         add_filter(
1938 1938
             'admin_body_class',
1939
-            function ($classes) {
1939
+            function($classes) {
1940 1940
                 if (strpos($classes, 'espresso-admin') === false) {
1941 1941
                     $classes .= ' espresso-admin';
1942 1942
                 }
@@ -2027,12 +2027,12 @@  discard block
 block discarded – undo
2027 2027
     protected function _set_list_table()
2028 2028
     {
2029 2029
         // first is this a list_table view?
2030
-        if (! isset($this->_route_config['list_table'])) {
2030
+        if ( ! isset($this->_route_config['list_table'])) {
2031 2031
             return;
2032 2032
         } //not a list_table view so get out.
2033 2033
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2034
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2035
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2034
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2035
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2036 2036
             // user error msg
2037 2037
             $error_msg = esc_html__(
2038 2038
                 'An error occurred. The requested list table views could not be found.',
@@ -2052,10 +2052,10 @@  discard block
 block discarded – undo
2052 2052
         }
2053 2053
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2054 2054
         $this->_views = apply_filters(
2055
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2055
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2056 2056
             $this->_views
2057 2057
         );
2058
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2058
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2059 2059
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2060 2060
         $this->_set_list_table_view();
2061 2061
         $this->_set_list_table_object();
@@ -2090,7 +2090,7 @@  discard block
 block discarded – undo
2090 2090
     protected function _set_list_table_object()
2091 2091
     {
2092 2092
         if (isset($this->_route_config['list_table'])) {
2093
-            if (! class_exists($this->_route_config['list_table'])) {
2093
+            if ( ! class_exists($this->_route_config['list_table'])) {
2094 2094
                 throw new EE_Error(
2095 2095
                     sprintf(
2096 2096
                         esc_html__(
@@ -2128,17 +2128,17 @@  discard block
 block discarded – undo
2128 2128
         foreach ($this->_views as $key => $view) {
2129 2129
             $query_args = [];
2130 2130
             // check for current view
2131
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2131
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2132 2132
             $query_args['action']                        = $this->_req_action;
2133
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2133
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2134 2134
             $query_args['status']                        = $view['slug'];
2135 2135
             // merge any other arguments sent in.
2136
-            if (isset($extra_query_args[ $view['slug'] ])) {
2137
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2136
+            if (isset($extra_query_args[$view['slug']])) {
2137
+                foreach ($extra_query_args[$view['slug']] as $extra_query_arg) {
2138 2138
                     $query_args[] = $extra_query_arg;
2139 2139
                 }
2140 2140
             }
2141
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2141
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2142 2142
         }
2143 2143
         return $this->_views;
2144 2144
     }
@@ -2169,14 +2169,14 @@  discard block
 block discarded – undo
2169 2169
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2170 2170
         foreach ($values as $value) {
2171 2171
             if ($value < $max_entries) {
2172
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2172
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2173 2173
                 $entries_per_page_dropdown .= '
2174
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2174
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2175 2175
             }
2176 2176
         }
2177
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2177
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2178 2178
         $entries_per_page_dropdown .= '
2179
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2179
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2180 2180
         $entries_per_page_dropdown .= '
2181 2181
 					</select>
2182 2182
 					entries
@@ -2200,7 +2200,7 @@  discard block
 block discarded – undo
2200 2200
             empty($this->_search_btn_label) ? $this->page_label
2201 2201
                 : $this->_search_btn_label
2202 2202
         );
2203
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2203
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2204 2204
     }
2205 2205
 
2206 2206
 
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
                                   );
2266 2266
                     throw new EE_Error($error_msg);
2267 2267
                 }
2268
-                unset($this->_route_config['metaboxes'][ $key ]);
2268
+                unset($this->_route_config['metaboxes'][$key]);
2269 2269
             }
2270 2270
         }
2271 2271
     }
@@ -2299,7 +2299,7 @@  discard block
 block discarded – undo
2299 2299
             $total_columns                                       = ! empty($screen_columns)
2300 2300
                 ? $screen_columns
2301 2301
                 : $this->_route_config['columns'][1];
2302
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2302
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2303 2303
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2304 2304
             $this->_template_args['screen']                      = $this->_current_screen;
2305 2305
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
      */
2346 2346
     protected function _espresso_ratings_request()
2347 2347
     {
2348
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2348
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2349 2349
             return;
2350 2350
         }
2351 2351
         $ratings_box_title = apply_filters(
@@ -2372,28 +2372,28 @@  discard block
 block discarded – undo
2372 2372
      */
2373 2373
     public function espresso_ratings_request()
2374 2374
     {
2375
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2375
+        EEH_Template::display_template(EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php');
2376 2376
     }
2377 2377
 
2378 2378
 
2379 2379
     public static function cached_rss_display($rss_id, $url)
2380 2380
     {
2381
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2381
+        $loading = '<p class="widget-loading hide-if-no-js">'
2382 2382
                      . esc_html__('Loading&#8230;', 'event_espresso')
2383 2383
                      . '</p><p class="hide-if-js">'
2384 2384
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2385 2385
                      . '</p>';
2386
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2387
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2388
-        $post      = '</div>' . "\n";
2389
-        $cache_key = 'ee_rss_' . md5($rss_id);
2386
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2387
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2388
+        $post      = '</div>'."\n";
2389
+        $cache_key = 'ee_rss_'.md5($rss_id);
2390 2390
         $output    = get_transient($cache_key);
2391 2391
         if ($output !== false) {
2392
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2392
+            echo wp_kses($pre.$output.$post, AllowedTags::getWithFormTags());
2393 2393
             return true;
2394 2394
         }
2395
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2396
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2395
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2396
+            echo wp_kses($pre.$loading.$post, AllowedTags::getWithFormTags());
2397 2397
             return false;
2398 2398
         }
2399 2399
         ob_start();
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
     public function espresso_sponsors_post_box()
2461 2461
     {
2462 2462
         EEH_Template::display_template(
2463
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2463
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2464 2464
         );
2465 2465
     }
2466 2466
 
@@ -2477,9 +2477,9 @@  discard block
 block discarded – undo
2477 2477
     protected function getPublishBoxTitle(): string
2478 2478
     {
2479 2479
         $publish_box_title = esc_html__('Publish', 'event_espresso');
2480
-        if (! empty($this->_labels['publishbox'])) {
2480
+        if ( ! empty($this->_labels['publishbox'])) {
2481 2481
             if (is_array($this->_labels['publishbox'])) {
2482
-                $publish_box_title = $this->_labels['publishbox'][ $this->_req_action ] ?? $publish_box_title;
2482
+                $publish_box_title = $this->_labels['publishbox'][$this->_req_action] ?? $publish_box_title;
2483 2483
             } else {
2484 2484
                 $publish_box_title = $this->_labels['publishbox'];
2485 2485
             }
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
         // if we have extra content set let's add it in if not make sure its empty
2536 2536
         $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2537 2537
         echo EEH_Template::display_template(
2538
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2538
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2539 2539
             $this->_template_args,
2540 2540
             true
2541 2541
         );
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
             );
2596 2596
         }
2597 2597
         $this->_template_args['publish_delete_link'] = $delete_link;
2598
-        if (! empty($name) && ! empty($id)) {
2598
+        if ( ! empty($name) && ! empty($id)) {
2599 2599
             $this->addPublishPostMetaBoxHiddenFields($name, ['type' => 'hidden', 'value' => $id]);
2600 2600
         }
2601 2601
         $hidden_fields = $this->_generate_admin_form_fields($this->publish_post_meta_box_hidden_fields, 'array');
@@ -2628,7 +2628,7 @@  discard block
 block discarded – undo
2628 2628
 
2629 2629
     protected function addPublishPostMetaBoxHiddenFields(string $field_name, array $field_attributes)
2630 2630
     {
2631
-        $this->publish_post_meta_box_hidden_fields[ $field_name ] = $field_attributes;
2631
+        $this->publish_post_meta_box_hidden_fields[$field_name] = $field_attributes;
2632 2632
     }
2633 2633
 
2634 2634
 
@@ -2729,7 +2729,7 @@  discard block
 block discarded – undo
2729 2729
         }
2730 2730
         // 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)
2731 2731
         $call_back_func = $create_func
2732
-            ? static function ($post, $metabox) {
2732
+            ? static function($post, $metabox) {
2733 2733
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2734 2734
                 echo EEH_Template::display_template(
2735 2735
                     $metabox['args']['template_path'],
@@ -2739,7 +2739,7 @@  discard block
 block discarded – undo
2739 2739
             }
2740 2740
             : $callback;
2741 2741
         $this->addMetaBox(
2742
-            str_replace('_', '-', $action) . '-mbox',
2742
+            str_replace('_', '-', $action).'-mbox',
2743 2743
             $title,
2744 2744
             $call_back_func,
2745 2745
             $this->_wp_page_slug,
@@ -2856,13 +2856,13 @@  discard block
 block discarded – undo
2856 2856
                                                                     'event-espresso_page_espresso_',
2857 2857
                                                                     '',
2858 2858
                                                                     $this->_wp_page_slug
2859
-                                                                ) . ' ' . $this->_req_action . '-route';
2859
+                                                                ).' '.$this->_req_action.'-route';
2860 2860
 
2861 2861
         $template_path = $sidebar
2862 2862
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2863
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2863
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2864 2864
         if ($this->request->isAjax()) {
2865
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2865
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2866 2866
         }
2867 2867
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2868 2868
 
@@ -2896,11 +2896,11 @@  discard block
 block discarded – undo
2896 2896
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2897 2897
     {
2898 2898
         // let's generate a default preview action button if there isn't one already present.
2899
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2899
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2900 2900
             'Upgrade to Event Espresso 4 Right Now',
2901 2901
             'event_espresso'
2902 2902
         );
2903
-        $buy_now_url                                   = add_query_arg(
2903
+        $buy_now_url = add_query_arg(
2904 2904
             [
2905 2905
                 'ee_ver'       => 'ee4',
2906 2906
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2920,8 +2920,8 @@  discard block
 block discarded – undo
2920 2920
                 true
2921 2921
             )
2922 2922
             : $this->_template_args['preview_action_button'];
2923
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2924
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2923
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2924
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2925 2925
             $this->_template_args,
2926 2926
             true
2927 2927
         );
@@ -2979,7 +2979,7 @@  discard block
 block discarded – undo
2979 2979
         // setup search attributes
2980 2980
         $this->_set_search_attributes();
2981 2981
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2982
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2982
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2983 2983
         $this->_template_args['table_url']        = $this->request->isAjax()
2984 2984
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2985 2985
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2987,10 +2987,10 @@  discard block
 block discarded – undo
2987 2987
         $this->_template_args['current_route']    = $this->_req_action;
2988 2988
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2989 2989
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2990
-        if (! empty($ajax_sorting_callback)) {
2990
+        if ( ! empty($ajax_sorting_callback)) {
2991 2991
             $sortable_list_table_form_fields = wp_nonce_field(
2992
-                $ajax_sorting_callback . '_nonce',
2993
-                $ajax_sorting_callback . '_nonce',
2992
+                $ajax_sorting_callback.'_nonce',
2993
+                $ajax_sorting_callback.'_nonce',
2994 2994
                 false,
2995 2995
                 false
2996 2996
             );
@@ -3007,18 +3007,18 @@  discard block
 block discarded – undo
3007 3007
 
3008 3008
         $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
3009 3009
 
3010
-        $nonce_ref          = $this->_req_action . '_nonce';
3010
+        $nonce_ref          = $this->_req_action.'_nonce';
3011 3011
         $hidden_form_fields .= '
3012
-            <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
3012
+            <input type="hidden" name="' . $nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
3013 3013
 
3014 3014
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3015 3015
         // display message about search results?
3016
-        $search                                    = $this->request->getRequestParam('s');
3016
+        $search = $this->request->getRequestParam('s');
3017 3017
         $this->_template_args['before_list_table'] .= ! empty($search)
3018
-            ? '<p class="ee-search-results">' . sprintf(
3018
+            ? '<p class="ee-search-results">'.sprintf(
3019 3019
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3020 3020
                 trim($search, '%')
3021
-            ) . '</p>'
3021
+            ).'</p>'
3022 3022
             : '';
3023 3023
         // filter before_list_table template arg
3024 3024
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3052,7 +3052,7 @@  discard block
 block discarded – undo
3052 3052
         // convert to array and filter again
3053 3053
         // arrays are easier to inject new items in a specific location,
3054 3054
         // but would not be backwards compatible, so we have to add a new filter
3055
-        $this->_template_args['after_list_table']   = implode(
3055
+        $this->_template_args['after_list_table'] = implode(
3056 3056
             " \n",
3057 3057
             (array) apply_filters(
3058 3058
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3107,7 +3107,7 @@  discard block
 block discarded – undo
3107 3107
             $this->page_slug
3108 3108
         );
3109 3109
         return EEH_Template::display_template(
3110
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3110
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3111 3111
             $this->_template_args,
3112 3112
             true
3113 3113
         );
@@ -3232,7 +3232,7 @@  discard block
 block discarded – undo
3232 3232
         if ($this->request->isAjax()) {
3233 3233
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3234 3234
             // $template_path,
3235
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3235
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3236 3236
                 $this->_template_args,
3237 3237
                 true
3238 3238
             );
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
         // load settings page wrapper template
3242 3242
         $template_path = $about
3243 3243
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3244
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3244
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3245 3245
 
3246 3246
         EEH_Template::display_template($template_path, $this->_template_args);
3247 3247
     }
@@ -3325,17 +3325,17 @@  discard block
 block discarded – undo
3325 3325
         $default_names = ['save', 'save_and_close'];
3326 3326
         $buttons       = '';
3327 3327
         foreach ($button_text as $key => $button) {
3328
-            $ref     = $default_names[ $key ];
3329
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3330
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3331
-                        . 'value="' . $button . '" name="' . $name . '" '
3332
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3333
-            if (! $both) {
3328
+            $ref     = $default_names[$key];
3329
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3330
+            $buttons .= '<input type="submit" class="button button--primary '.$ref.'" '
3331
+                        . 'value="'.$button.'" name="'.$name.'" '
3332
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3333
+            if ( ! $both) {
3334 3334
                 break;
3335 3335
             }
3336 3336
         }
3337 3337
         // add in a hidden index for the current page (so save and close redirects properly)
3338
-        $buttons                              .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3338
+        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3339 3339
                                                  . $referrer_url
3340 3340
                                                  . '" />';
3341 3341
         $this->_template_args['save_buttons'] = $buttons;
@@ -3370,13 +3370,13 @@  discard block
 block discarded – undo
3370 3370
                 'An error occurred. No action was set for this page\'s form.',
3371 3371
                 'event_espresso'
3372 3372
             );
3373
-            $dev_msg  = $user_msg . "\n"
3373
+            $dev_msg = $user_msg."\n"
3374 3374
                         . sprintf(
3375 3375
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3376 3376
                             __FUNCTION__,
3377 3377
                             __CLASS__
3378 3378
                         );
3379
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3379
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3380 3380
         }
3381 3381
         // open form
3382 3382
         $action                                            = $this->_admin_base_url;
@@ -3384,9 +3384,9 @@  discard block
 block discarded – undo
3384 3384
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3385 3385
             ";
3386 3386
         // add nonce
3387
-        $nonce                                             =
3388
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3389
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3387
+        $nonce =
3388
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3389
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3390 3390
         // add REQUIRED form action
3391 3391
         $hidden_fields = [
3392 3392
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3399,7 +3399,7 @@  discard block
 block discarded – undo
3399 3399
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3400 3400
         // add fields to form
3401 3401
         foreach ((array) $form_fields as $form_field) {
3402
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3402
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3403 3403
         }
3404 3404
         // close form
3405 3405
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3484,10 +3484,10 @@  discard block
 block discarded – undo
3484 3484
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3485 3485
         $notices = EE_Error::get_notices(false);
3486 3486
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3487
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3487
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3488 3488
             EE_Error::overwrite_success();
3489 3489
         }
3490
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3490
+        if ( ! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3491 3491
             // how many records affected ? more than one record ? or just one ?
3492 3492
             EE_Error::add_success(
3493 3493
                 sprintf(
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
             );
3509 3509
         }
3510 3510
         // check that $query_args isn't something crazy
3511
-        if (! is_array($query_args)) {
3511
+        if ( ! is_array($query_args)) {
3512 3512
             $query_args = [];
3513 3513
         }
3514 3514
         /**
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
             $redirect_url = admin_url('admin.php');
3541 3541
         }
3542 3542
         // merge any default query_args set in _default_route_query_args property
3543
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3543
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3544 3544
             $args_to_merge = [];
3545 3545
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3546 3546
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3552,15 +3552,15 @@  discard block
 block discarded – undo
3552 3552
                         }
3553 3553
                         // finally we will override any arguments in the referer with
3554 3554
                         // what might be set on the _default_route_query_args array.
3555
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3556
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3555
+                        if (isset($this->_default_route_query_args[$reference])) {
3556
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3557 3557
                         } else {
3558
-                            $args_to_merge[ $reference ] = urlencode($value);
3558
+                            $args_to_merge[$reference] = urlencode($value);
3559 3559
                         }
3560 3560
                     }
3561 3561
                     continue;
3562 3562
                 }
3563
-                $args_to_merge[ $query_param ] = $query_value;
3563
+                $args_to_merge[$query_param] = $query_value;
3564 3564
             }
3565 3565
             // now let's merge these arguments but override with what was specifically sent in to the
3566 3566
             // redirect.
@@ -3572,19 +3572,19 @@  discard block
 block discarded – undo
3572 3572
         if (isset($query_args['action'])) {
3573 3573
             // manually generate wp_nonce and merge that with the query vars
3574 3574
             // becuz the wp_nonce_url function wrecks havoc on some vars
3575
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3575
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3576 3576
         }
3577 3577
         // we're adding some hooks and filters in here for processing any things just before redirects
3578 3578
         // (example: an admin page has done an insert or update and we want to run something after that).
3579
-        do_action('AHEE_redirect_' . $this->class_name . $this->_req_action, $query_args);
3579
+        do_action('AHEE_redirect_'.$this->class_name.$this->_req_action, $query_args);
3580 3580
         $redirect_url = apply_filters(
3581
-            'FHEE_redirect_' . $this->class_name . $this->_req_action,
3581
+            'FHEE_redirect_'.$this->class_name.$this->_req_action,
3582 3582
             EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3583 3583
             $query_args
3584 3584
         );
3585 3585
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3586 3586
         if ($this->request->isAjax()) {
3587
-            $default_data                    = [
3587
+            $default_data = [
3588 3588
                 'close'        => true,
3589 3589
                 'redirect_url' => $redirect_url,
3590 3590
                 'where'        => 'main',
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
         }
3635 3635
         $this->_template_args['notices'] = EE_Error::get_notices();
3636 3636
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3637
-        if (! $this->request->isAjax() || $sticky_notices) {
3637
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3638 3638
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3639 3639
             $this->_add_transient(
3640 3640
                 $route,
@@ -3674,7 +3674,7 @@  discard block
 block discarded – undo
3674 3674
         $exclude_nonce = false
3675 3675
     ) {
3676 3676
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3677
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3677
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3678 3678
             throw new EE_Error(
3679 3679
                 sprintf(
3680 3680
                     esc_html__(
@@ -3685,7 +3685,7 @@  discard block
 block discarded – undo
3685 3685
                 )
3686 3686
             );
3687 3687
         }
3688
-        if (! isset($this->_labels['buttons'][ $type ])) {
3688
+        if ( ! isset($this->_labels['buttons'][$type])) {
3689 3689
             throw new EE_Error(
3690 3690
                 sprintf(
3691 3691
                     esc_html__(
@@ -3698,7 +3698,7 @@  discard block
 block discarded – undo
3698 3698
         }
3699 3699
         // finally check user access for this button.
3700 3700
         $has_access = $this->check_user_access($action, true);
3701
-        if (! $has_access) {
3701
+        if ( ! $has_access) {
3702 3702
             return '';
3703 3703
         }
3704 3704
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3706,11 +3706,11 @@  discard block
 block discarded – undo
3706 3706
             'action' => $action,
3707 3707
         ];
3708 3708
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3709
-        if (! empty($extra_request)) {
3709
+        if ( ! empty($extra_request)) {
3710 3710
             $query_args = array_merge($extra_request, $query_args);
3711 3711
         }
3712 3712
         $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3713
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3713
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3714 3714
     }
3715 3715
 
3716 3716
 
@@ -3736,7 +3736,7 @@  discard block
 block discarded – undo
3736 3736
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3737 3737
                 20
3738 3738
             ),
3739
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3739
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3740 3740
         ];
3741 3741
         // ONLY add the screen option if the user has access to it.
3742 3742
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3757,18 +3757,18 @@  discard block
 block discarded – undo
3757 3757
     {
3758 3758
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3759 3759
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3760
-            if (! $user = wp_get_current_user()) {
3760
+            if ( ! $user = wp_get_current_user()) {
3761 3761
                 return;
3762 3762
             }
3763 3763
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3764
-            if (! $option) {
3764
+            if ( ! $option) {
3765 3765
                 return;
3766 3766
             }
3767 3767
             $value      = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3768 3768
             $map_option = $option;
3769 3769
             $option     = str_replace('-', '_', $option);
3770 3770
             switch ($map_option) {
3771
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3771
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3772 3772
                     $max_value = apply_filters(
3773 3773
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3774 3774
                         999,
@@ -3825,13 +3825,13 @@  discard block
 block discarded – undo
3825 3825
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3826 3826
     {
3827 3827
         $user_id = get_current_user_id();
3828
-        if (! $skip_route_verify) {
3828
+        if ( ! $skip_route_verify) {
3829 3829
             $this->_verify_route($route);
3830 3830
         }
3831 3831
         // now let's set the string for what kind of transient we're setting
3832 3832
         $transient = $notices
3833
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3834
-            : 'rte_tx_' . $route . '_' . $user_id;
3833
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3834
+            : 'rte_tx_'.$route.'_'.$user_id;
3835 3835
         $data      = $notices ? ['notices' => $data] : $data;
3836 3836
         // is there already a transient for this route?  If there is then let's ADD to that transient
3837 3837
         $existing = is_multisite() && is_network_admin()
@@ -3860,8 +3860,8 @@  discard block
 block discarded – undo
3860 3860
         $user_id   = get_current_user_id();
3861 3861
         $route     = ! $route ? $this->_req_action : $route;
3862 3862
         $transient = $notices
3863
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3864
-            : 'rte_tx_' . $route . '_' . $user_id;
3863
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3864
+            : 'rte_tx_'.$route.'_'.$user_id;
3865 3865
         $data      = is_multisite() && is_network_admin()
3866 3866
             ? get_site_transient($transient)
3867 3867
             : get_transient($transient);
@@ -4102,7 +4102,7 @@  discard block
 block discarded – undo
4102 4102
      */
4103 4103
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4104 4104
     {
4105
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4105
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4106 4106
     }
4107 4107
 
4108 4108
 
@@ -4115,7 +4115,7 @@  discard block
 block discarded – undo
4115 4115
      */
4116 4116
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4117 4117
     {
4118
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4118
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4119 4119
     }
4120 4120
 
4121 4121
 
@@ -4263,13 +4263,13 @@  discard block
 block discarded – undo
4263 4263
         ?callable $callback = null
4264 4264
     ): bool {
4265 4265
         $entity_ID = absint($entity_ID);
4266
-        if (! $entity_ID) {
4266
+        if ( ! $entity_ID) {
4267 4267
             $this->trashRestoreDeleteError($action, $entity_model);
4268 4268
         }
4269 4269
         $result = 0;
4270 4270
         try {
4271 4271
             $entity = $entity_model->get_one_by_ID($entity_ID);
4272
-            if (! $entity instanceof EE_Base_Class) {
4272
+            if ( ! $entity instanceof EE_Base_Class) {
4273 4273
                 throw new DomainException(
4274 4274
                     sprintf(
4275 4275
                         esc_html__(
@@ -4320,7 +4320,7 @@  discard block
 block discarded – undo
4320 4320
                 )
4321 4321
             );
4322 4322
         }
4323
-        if (! $entity_model->has_field($delete_column)) {
4323
+        if ( ! $entity_model->has_field($delete_column)) {
4324 4324
             throw new DomainException(
4325 4325
                 sprintf(
4326 4326
                     esc_html__(
Please login to merge, or discard this patch.
core/services/address/AddressInterface.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,41 +11,41 @@
 block discarded – undo
11 11
  */
12 12
 interface AddressInterface extends EEI_Address
13 13
 {
14
-    public function address(): string;
14
+	public function address(): string;
15 15
 
16 16
 
17
-    public function address2(): string;
17
+	public function address2(): string;
18 18
 
19 19
 
20
-    public function city(): string;
20
+	public function city(): string;
21 21
 
22 22
 
23
-    public function state_obj(): ?EE_State;
23
+	public function state_obj(): ?EE_State;
24 24
 
25 25
 
26
-    public function state_ID(): int;
26
+	public function state_ID(): int;
27 27
 
28 28
 
29
-    public function state_name(): string;
29
+	public function state_name(): string;
30 30
 
31 31
 
32
-    public function state_abbrev(): string;
32
+	public function state_abbrev(): string;
33 33
 
34 34
 
35
-    public function state(): string;
35
+	public function state(): string;
36 36
 
37 37
 
38
-    public function country_obj(): ?EE_Country;
38
+	public function country_obj(): ?EE_Country;
39 39
 
40 40
 
41
-    public function country_ID(): string;
41
+	public function country_ID(): string;
42 42
 
43 43
 
44
-    public function country_name(): string;
44
+	public function country_name(): string;
45 45
 
46 46
 
47
-    public function country(): string;
47
+	public function country(): string;
48 48
 
49 49
 
50
-    public function zip(): string;
50
+	public function zip(): string;
51 51
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Address.helper.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -17,124 +17,124 @@
 block discarded – undo
17 17
  */
18 18
 class EEH_Address
19 19
 {
20
-    /**
21
-     *    format - output formatted EE object address information
22
-     *
23
-     * @param AddressInterface|null $obj_with_address
24
-     * @param string                $type       how the address is formatted. for example: 'multiline' or 'inline'
25
-     * @param bool                  $use_schema whether to apply schema.org formatting to the address
26
-     * @param bool                  $add_wrapper
27
-     * @return string
28
-     */
29
-    public static function format(
30
-        ?AddressInterface $obj_with_address = null,
31
-        string $type = 'multiline',
32
-        bool $use_schema = true,
33
-        bool $add_wrapper = true
34
-    ): string {
35
-        // check that incoming object implements the AddressInterface interface
36
-        if (! $obj_with_address instanceof AddressInterface && ! $obj_with_address instanceof EEI_Address) {
37
-            $msg     = esc_html__('The address could not be formatted.', 'event_espresso');
38
-            $dev_msg = esc_html__(
39
-                'The Address Formatter requires passed objects to implement the AddressInterface interface.',
40
-                'event_espresso'
41
-            );
42
-            EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
43
-            return '';
44
-        }
45
-        // obtain an address formatter
46
-        $formatter = EEH_Address::_get_formatter($type);
47
-        // apply schema.org formatting ?
48
-        $use_schema        = ! is_admin()
49
-            ? $use_schema
50
-            : false;
51
-        $formatted_address = $use_schema
52
-            ? EEH_Address::_schema_formatting($formatter, $obj_with_address)
53
-            : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
54
-        // return the formatted address
55
-        return $add_wrapper && ! $use_schema
56
-            ? "<div class='espresso-address-dv'>$formatted_address</div>"
57
-            : $formatted_address;
58
-    }
20
+	/**
21
+	 *    format - output formatted EE object address information
22
+	 *
23
+	 * @param AddressInterface|null $obj_with_address
24
+	 * @param string                $type       how the address is formatted. for example: 'multiline' or 'inline'
25
+	 * @param bool                  $use_schema whether to apply schema.org formatting to the address
26
+	 * @param bool                  $add_wrapper
27
+	 * @return string
28
+	 */
29
+	public static function format(
30
+		?AddressInterface $obj_with_address = null,
31
+		string $type = 'multiline',
32
+		bool $use_schema = true,
33
+		bool $add_wrapper = true
34
+	): string {
35
+		// check that incoming object implements the AddressInterface interface
36
+		if (! $obj_with_address instanceof AddressInterface && ! $obj_with_address instanceof EEI_Address) {
37
+			$msg     = esc_html__('The address could not be formatted.', 'event_espresso');
38
+			$dev_msg = esc_html__(
39
+				'The Address Formatter requires passed objects to implement the AddressInterface interface.',
40
+				'event_espresso'
41
+			);
42
+			EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
43
+			return '';
44
+		}
45
+		// obtain an address formatter
46
+		$formatter = EEH_Address::_get_formatter($type);
47
+		// apply schema.org formatting ?
48
+		$use_schema        = ! is_admin()
49
+			? $use_schema
50
+			: false;
51
+		$formatted_address = $use_schema
52
+			? EEH_Address::_schema_formatting($formatter, $obj_with_address)
53
+			: EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
54
+		// return the formatted address
55
+		return $add_wrapper && ! $use_schema
56
+			? "<div class='espresso-address-dv'>$formatted_address</div>"
57
+			: $formatted_address;
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * _get_formatter - obtain the requester formatter class
63
-     *
64
-     * @param string $type how the address is formatted. for example: 'multiline' or 'inline'
65
-     * @return AddressFormatterInterface
66
-     */
67
-    private static function _get_formatter(string $type)
68
-    {
69
-        switch ($type) {
70
-            case 'multiline':
71
-                return new MultiLineAddressFormatter();
72
-            case 'inline':
73
-                return new InlineAddressFormatter();
74
-            default:
75
-                return new NullAddressFormatter();
76
-        }
77
-    }
61
+	/**
62
+	 * _get_formatter - obtain the requester formatter class
63
+	 *
64
+	 * @param string $type how the address is formatted. for example: 'multiline' or 'inline'
65
+	 * @return AddressFormatterInterface
66
+	 */
67
+	private static function _get_formatter(string $type)
68
+	{
69
+		switch ($type) {
70
+			case 'multiline':
71
+				return new MultiLineAddressFormatter();
72
+			case 'inline':
73
+				return new InlineAddressFormatter();
74
+			default:
75
+				return new NullAddressFormatter();
76
+		}
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     *    _regular_formatting
82
-     *    adds formatting to an address
83
-     *
84
-     * @param AddressFormatterInterface $formatter
85
-     * @param AddressInterface          $obj_with_address
86
-     * @param bool                      $add_wrapper
87
-     * @return string
88
-     */
89
-    private static function _regular_formatting(
90
-        AddressFormatterInterface $formatter,
91
-        AddressInterface $obj_with_address,
92
-        bool $add_wrapper = true
93
-    ): string {
94
-        $formatted_address = $add_wrapper
95
-            ? '<div>'
96
-            : '';
97
-        $formatted_address .= $formatter->format(
98
-            $obj_with_address->address(),
99
-            $obj_with_address->address2(),
100
-            $obj_with_address->city(),
101
-            $obj_with_address->state_name(),
102
-            $obj_with_address->zip(),
103
-            $obj_with_address->country_name(),
104
-            $obj_with_address->country_ID()
105
-        );
106
-        $formatted_address .= $add_wrapper
107
-            ? '</div>'
108
-            : '';
109
-        // return the formatted address
110
-        return $formatted_address;
111
-    }
80
+	/**
81
+	 *    _regular_formatting
82
+	 *    adds formatting to an address
83
+	 *
84
+	 * @param AddressFormatterInterface $formatter
85
+	 * @param AddressInterface          $obj_with_address
86
+	 * @param bool                      $add_wrapper
87
+	 * @return string
88
+	 */
89
+	private static function _regular_formatting(
90
+		AddressFormatterInterface $formatter,
91
+		AddressInterface $obj_with_address,
92
+		bool $add_wrapper = true
93
+	): string {
94
+		$formatted_address = $add_wrapper
95
+			? '<div>'
96
+			: '';
97
+		$formatted_address .= $formatter->format(
98
+			$obj_with_address->address(),
99
+			$obj_with_address->address2(),
100
+			$obj_with_address->city(),
101
+			$obj_with_address->state_name(),
102
+			$obj_with_address->zip(),
103
+			$obj_with_address->country_name(),
104
+			$obj_with_address->country_ID()
105
+		);
106
+		$formatted_address .= $add_wrapper
107
+			? '</div>'
108
+			: '';
109
+		// return the formatted address
110
+		return $formatted_address;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     *    _schema_formatting
116
-     *    adds schema.org formatting to an address
117
-     *
118
-     * @param AddressFormatterInterface $formatter
119
-     * @param AddressInterface          $obj_with_address
120
-     * @return string
121
-     */
122
-    private static function _schema_formatting(
123
-        AddressFormatterInterface $formatter,
124
-        AddressInterface $obj_with_address
125
-    ): string {
126
-        $formatted_address = '<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">';
127
-        $formatted_address .= $formatter->format(
128
-            EEH_Schema::streetAddress($obj_with_address),
129
-            EEH_Schema::postOfficeBoxNumber($obj_with_address),
130
-            EEH_Schema::addressLocality($obj_with_address),
131
-            EEH_Schema::addressRegion($obj_with_address),
132
-            EEH_Schema::postalCode($obj_with_address),
133
-            EEH_Schema::addressCountry($obj_with_address),
134
-            $obj_with_address->country_ID()
135
-        );
136
-        $formatted_address .= '</div>';
137
-        // return the formatted address
138
-        return $formatted_address;
139
-    }
114
+	/**
115
+	 *    _schema_formatting
116
+	 *    adds schema.org formatting to an address
117
+	 *
118
+	 * @param AddressFormatterInterface $formatter
119
+	 * @param AddressInterface          $obj_with_address
120
+	 * @return string
121
+	 */
122
+	private static function _schema_formatting(
123
+		AddressFormatterInterface $formatter,
124
+		AddressInterface $obj_with_address
125
+	): string {
126
+		$formatted_address = '<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">';
127
+		$formatted_address .= $formatter->format(
128
+			EEH_Schema::streetAddress($obj_with_address),
129
+			EEH_Schema::postOfficeBoxNumber($obj_with_address),
130
+			EEH_Schema::addressLocality($obj_with_address),
131
+			EEH_Schema::addressRegion($obj_with_address),
132
+			EEH_Schema::postalCode($obj_with_address),
133
+			EEH_Schema::addressCountry($obj_with_address),
134
+			$obj_with_address->country_ID()
135
+		);
136
+		$formatted_address .= '</div>';
137
+		// return the formatted address
138
+		return $formatted_address;
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@
 block discarded – undo
33 33
         bool $add_wrapper = true
34 34
     ): string {
35 35
         // check that incoming object implements the AddressInterface interface
36
-        if (! $obj_with_address instanceof AddressInterface && ! $obj_with_address instanceof EEI_Address) {
36
+        if ( ! $obj_with_address instanceof AddressInterface && ! $obj_with_address instanceof EEI_Address) {
37 37
             $msg     = esc_html__('The address could not be formatted.', 'event_espresso');
38 38
             $dev_msg = esc_html__(
39 39
                 'The Address Formatter requires passed objects to implement the AddressInterface interface.',
40 40
                 'event_espresso'
41 41
             );
42
-            EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
42
+            EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
43 43
             return '';
44 44
         }
45 45
         // obtain an address formatter
Please login to merge, or discard this patch.