Completed
Branch ADMIN-REFRESH (ff800a)
by
unknown
03:18 queued 26s
created
core/admin/templates/admin_details_legend.template.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@  discard block
 block discarded – undo
16 16
 <div class="ee-list-table-legend-container">
17 17
     <h3><?php esc_html_e('Legend', 'event_espresso'); ?></h3>
18 18
     <?php
19
-    if (isset($status_change_notice)) {
20
-        echo $status_change_notice;
21
-    }
22
-    ?>
19
+	if (isset($status_change_notice)) {
20
+		echo $status_change_notice;
21
+	}
22
+	?>
23 23
     <div class="ee-list-table-legend-wrap">
24 24
         <dl class="ee-list-table-legend">
25 25
             <?php foreach ($items as $item => $details) :
26
-                if ($per_col < $count) : ?>
26
+				if ($per_col < $count) : ?>
27 27
         </dl>
28 28
         <dl class="ee-list-table-legend">
29 29
                     <?php $count = 1;
30
-                endif; ?>
30
+				endif; ?>
31 31
             <dt id="ee-legend-item-<?php echo esc_attr($item); ?>">
32 32
                 <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?>
33 33
                 <span class="ee-legend-item-wrap">
34 34
                 <?php
35
-                if (strpos($details['class'], '<span') !== false) {
36
-                    echo $class; // already escaped
37
-                } else { ?>
35
+				if (strpos($details['class'], '<span') !== false) {
36
+					echo $class; // already escaped
37
+				} else { ?>
38 38
                 <span class="<?php echo esc_attr($class); ?>">
39 39
                     <?php if (! empty($details['icon'])) : ?>
40 40
                         <img alt="<?php echo esc_attr($details['desc']); ?>"
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
                     <?php endif; ?>
45 45
                 </span>
46 46
                     <?php
47
-                } ?>
47
+				} ?>
48 48
                 </span>
49 49
                 <span class="ee-legend-description"><?php echo esc_html($details['desc']); ?></span>
50 50
             </dt>
51 51
                 <?php $count++;
52
-            endforeach; ?>
52
+			endforeach; ?>
53 53
         </dl>
54 54
     </div>
55 55
     <div style="clear:both"></div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
                     echo $class; // already escaped
37 37
                 } else { ?>
38 38
                 <span class="<?php echo esc_attr($class); ?>">
39
-                    <?php if (! empty($details['icon'])) : ?>
39
+                    <?php if ( ! empty($details['icon'])) : ?>
40 40
                         <img alt="<?php echo esc_attr($details['desc']); ?>"
41 41
                              class="ee-legend-icon"
42 42
                              src="<?php echo esc_url_raw($details['icon']); ?>"
Please login to merge, or discard this patch.
core/db_classes/EE_Event.class.php 2 patches
Indentation   +1528 added lines, -1528 removed lines patch added patch discarded remove patch
@@ -16,1532 +16,1532 @@
 block discarded – undo
16 16
 class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event
17 17
 {
18 18
 
19
-    /**
20
-     * cached value for the the logical active status for the event
21
-     *
22
-     * @see get_active_status()
23
-     * @var string
24
-     */
25
-    protected $_active_status = '';
26
-
27
-    /**
28
-     * This is just used for caching the Primary Datetime for the Event on initial retrieval
29
-     *
30
-     * @var EE_Datetime
31
-     */
32
-    protected $_Primary_Datetime;
33
-
34
-    /**
35
-     * @var EventSpacesCalculator $available_spaces_calculator
36
-     */
37
-    protected $available_spaces_calculator;
38
-
39
-
40
-    /**
41
-     * @param array  $props_n_values          incoming values
42
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
43
-     *                                        used.)
44
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
45
-     *                                        date_format and the second value is the time format
46
-     * @return EE_Event
47
-     * @throws EE_Error
48
-     * @throws ReflectionException
49
-     */
50
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
51
-    {
52
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
53
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
54
-    }
55
-
56
-
57
-    /**
58
-     * @param array  $props_n_values  incoming values from the database
59
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
60
-     *                                the website will be used.
61
-     * @return EE_Event
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
66
-    {
67
-        return new self($props_n_values, true, $timezone);
68
-    }
69
-
70
-
71
-    /**
72
-     * @return EventSpacesCalculator
73
-     * @throws \EE_Error
74
-     */
75
-    public function getAvailableSpacesCalculator()
76
-    {
77
-        if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
78
-            $this->available_spaces_calculator = new EventSpacesCalculator($this);
79
-        }
80
-        return $this->available_spaces_calculator;
81
-    }
82
-
83
-
84
-    /**
85
-     * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods
86
-     *
87
-     * @param string $field_name
88
-     * @param mixed  $field_value
89
-     * @param bool   $use_default
90
-     * @throws EE_Error
91
-     * @throws ReflectionException
92
-     */
93
-    public function set($field_name, $field_value, $use_default = false)
94
-    {
95
-        switch ($field_name) {
96
-            case 'status':
97
-                $this->set_status($field_value, $use_default);
98
-                break;
99
-            default:
100
-                parent::set($field_name, $field_value, $use_default);
101
-        }
102
-    }
103
-
104
-
105
-    /**
106
-     *    set_status
107
-     * Checks if event status is being changed to SOLD OUT
108
-     * and updates event meta data with previous event status
109
-     * so that we can revert things if/when the event is no longer sold out
110
-     *
111
-     * @access public
112
-     * @param string $new_status
113
-     * @param bool   $use_default
114
-     * @return void
115
-     * @throws EE_Error
116
-     * @throws ReflectionException
117
-     */
118
-    public function set_status($new_status = null, $use_default = false)
119
-    {
120
-        // if nothing is set, and we aren't explicitly wanting to reset the status, then just leave
121
-        if (empty($new_status) && ! $use_default) {
122
-            return;
123
-        }
124
-        // get current Event status
125
-        $old_status = $this->status();
126
-        // if status has changed
127
-        if ($old_status !== $new_status) {
128
-            // TO sold_out
129
-            if ($new_status === EEM_Event::sold_out) {
130
-                // save the previous event status so that we can revert if the event is no longer sold out
131
-                $this->add_post_meta('_previous_event_status', $old_status);
132
-                do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status);
133
-            // OR FROM  sold_out
134
-            } elseif ($old_status === EEM_Event::sold_out) {
135
-                $this->delete_post_meta('_previous_event_status');
136
-                do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status);
137
-            }
138
-            // clear out the active status so that it gets reset the next time it is requested
139
-            $this->_active_status = null;
140
-            // update status
141
-            parent::set('status', $new_status, $use_default);
142
-            do_action('AHEE__EE_Event__set_status__after_update', $this);
143
-            return;
144
-        }
145
-        // even though the old value matches the new value, it's still good to
146
-        // allow the parent set method to have a say
147
-        parent::set('status', $new_status, $use_default);
148
-    }
149
-
150
-
151
-    /**
152
-     * Gets all the datetimes for this event
153
-     *
154
-     * @param array $query_params @see
155
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
156
-     * @return EE_Base_Class[]|EE_Datetime[]
157
-     * @throws EE_Error
158
-     * @throws ReflectionException
159
-     */
160
-    public function datetimes($query_params = array())
161
-    {
162
-        return $this->get_many_related('Datetime', $query_params);
163
-    }
164
-
165
-
166
-    /**
167
-     * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order
168
-     *
169
-     * @return EE_Base_Class[]|EE_Datetime[]
170
-     * @throws EE_Error
171
-     * @throws ReflectionException
172
-     */
173
-    public function datetimes_in_chronological_order()
174
-    {
175
-        return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
176
-    }
177
-
178
-
179
-    /**
180
-     * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
181
-     * @darren, we should probably UNSET timezone on the EEM_Datetime model
182
-     * after running our query, so that this timezone isn't set for EVERY query
183
-     * on EEM_Datetime for the rest of the request, no?
184
-     *
185
-     * @param boolean $show_expired whether or not to include expired events
186
-     * @param boolean $show_deleted whether or not to include deleted events
187
-     * @param null    $limit
188
-     * @return EE_Datetime[]
189
-     * @throws EE_Error
190
-     * @throws ReflectionException
191
-     */
192
-    public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null)
193
-    {
194
-        return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order(
195
-            $this->ID(),
196
-            $show_expired,
197
-            $show_deleted,
198
-            $limit
199
-        );
200
-    }
201
-
202
-
203
-    /**
204
-     * Returns one related datetime. Mostly only used by some legacy code.
205
-     *
206
-     * @return EE_Base_Class|EE_Datetime
207
-     * @throws EE_Error
208
-     * @throws ReflectionException
209
-     */
210
-    public function first_datetime()
211
-    {
212
-        return $this->get_first_related('Datetime');
213
-    }
214
-
215
-
216
-    /**
217
-     * Returns the 'primary' datetime for the event
218
-     *
219
-     * @param bool $try_to_exclude_expired
220
-     * @param bool $try_to_exclude_deleted
221
-     * @return EE_Datetime
222
-     * @throws EE_Error
223
-     * @throws ReflectionException
224
-     */
225
-    public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
226
-    {
227
-        if (! empty($this->_Primary_Datetime)) {
228
-            return $this->_Primary_Datetime;
229
-        }
230
-        $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
231
-            $this->ID(),
232
-            $try_to_exclude_expired,
233
-            $try_to_exclude_deleted
234
-        );
235
-        return $this->_Primary_Datetime;
236
-    }
237
-
238
-
239
-    /**
240
-     * Gets all the tickets available for purchase of this event
241
-     *
242
-     * @param array $query_params @see
243
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
244
-     * @return EE_Base_Class[]|EE_Ticket[]
245
-     * @throws EE_Error
246
-     * @throws ReflectionException
247
-     */
248
-    public function tickets($query_params = array())
249
-    {
250
-        // first get all datetimes
251
-        $datetimes = $this->datetimes_ordered();
252
-        if (! $datetimes) {
253
-            return array();
254
-        }
255
-        $datetime_ids = array();
256
-        foreach ($datetimes as $datetime) {
257
-            $datetime_ids[] = $datetime->ID();
258
-        }
259
-        $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
260
-        // if incoming $query_params has where conditions let's merge but not override existing.
261
-        if (is_array($query_params) && isset($query_params[0])) {
262
-            $where_params = array_merge($query_params[0], $where_params);
263
-            unset($query_params[0]);
264
-        }
265
-        // now add $where_params to $query_params
266
-        $query_params[0] = $where_params;
267
-        return EEM_Ticket::instance()->get_all($query_params);
268
-    }
269
-
270
-
271
-    /**
272
-     * get all unexpired untrashed tickets
273
-     *
274
-     * @return EE_Ticket[]
275
-     * @throws EE_Error
276
-     */
277
-    public function active_tickets()
278
-    {
279
-        return $this->tickets(
280
-            array(
281
-                array(
282
-                    'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
283
-                    'TKT_deleted'  => false,
284
-                ),
285
-            )
286
-        );
287
-    }
288
-
289
-
290
-    /**
291
-     * @return bool
292
-     * @throws EE_Error
293
-     * @throws ReflectionException
294
-     */
295
-    public function additional_limit()
296
-    {
297
-        return $this->get('EVT_additional_limit');
298
-    }
299
-
300
-
301
-    /**
302
-     * @return bool
303
-     * @throws EE_Error
304
-     * @throws ReflectionException
305
-     */
306
-    public function allow_overflow()
307
-    {
308
-        return $this->get('EVT_allow_overflow');
309
-    }
310
-
311
-
312
-    /**
313
-     * @return bool
314
-     * @throws EE_Error
315
-     * @throws ReflectionException
316
-     */
317
-    public function created()
318
-    {
319
-        return $this->get('EVT_created');
320
-    }
321
-
322
-
323
-    /**
324
-     * @return bool
325
-     * @throws EE_Error
326
-     * @throws ReflectionException
327
-     */
328
-    public function description()
329
-    {
330
-        return $this->get('EVT_desc');
331
-    }
332
-
333
-
334
-    /**
335
-     * Runs do_shortcode and wpautop on the description
336
-     *
337
-     * @return string of html
338
-     * @throws EE_Error
339
-     * @throws ReflectionException
340
-     */
341
-    public function description_filtered()
342
-    {
343
-        return $this->get_pretty('EVT_desc');
344
-    }
345
-
346
-
347
-    /**
348
-     * @return bool
349
-     * @throws EE_Error
350
-     * @throws ReflectionException
351
-     */
352
-    public function display_description()
353
-    {
354
-        return $this->get('EVT_display_desc');
355
-    }
356
-
357
-
358
-    /**
359
-     * @return bool
360
-     * @throws EE_Error
361
-     * @throws ReflectionException
362
-     */
363
-    public function display_ticket_selector()
364
-    {
365
-        return (bool) $this->get('EVT_display_ticket_selector');
366
-    }
367
-
368
-
369
-    /**
370
-     * @return string
371
-     * @throws EE_Error
372
-     * @throws ReflectionException
373
-     */
374
-    public function external_url()
375
-    {
376
-        return $this->get('EVT_external_URL');
377
-    }
378
-
379
-
380
-    /**
381
-     * @return bool
382
-     * @throws EE_Error
383
-     * @throws ReflectionException
384
-     */
385
-    public function member_only()
386
-    {
387
-        return $this->get('EVT_member_only');
388
-    }
389
-
390
-
391
-    /**
392
-     * @return bool
393
-     * @throws EE_Error
394
-     * @throws ReflectionException
395
-     */
396
-    public function phone()
397
-    {
398
-        return $this->get('EVT_phone');
399
-    }
400
-
401
-
402
-    /**
403
-     * @return bool
404
-     * @throws EE_Error
405
-     * @throws ReflectionException
406
-     */
407
-    public function modified()
408
-    {
409
-        return $this->get('EVT_modified');
410
-    }
411
-
412
-
413
-    /**
414
-     * @return bool
415
-     * @throws EE_Error
416
-     * @throws ReflectionException
417
-     */
418
-    public function name()
419
-    {
420
-        return $this->get('EVT_name');
421
-    }
422
-
423
-
424
-    /**
425
-     * @return bool
426
-     * @throws EE_Error
427
-     * @throws ReflectionException
428
-     */
429
-    public function order()
430
-    {
431
-        return $this->get('EVT_order');
432
-    }
433
-
434
-
435
-    /**
436
-     * @return bool|string
437
-     * @throws EE_Error
438
-     * @throws ReflectionException
439
-     */
440
-    public function default_registration_status()
441
-    {
442
-        $event_default_registration_status = $this->get('EVT_default_registration_status');
443
-        return ! empty($event_default_registration_status)
444
-            ? $event_default_registration_status
445
-            : EE_Registry::instance()->CFG->registration->default_STS_ID;
446
-    }
447
-
448
-
449
-    /**
450
-     * @param int  $num_words
451
-     * @param null $more
452
-     * @param bool $not_full_desc
453
-     * @return bool|string
454
-     * @throws EE_Error
455
-     * @throws ReflectionException
456
-     */
457
-    public function short_description($num_words = 55, $more = null, $not_full_desc = false)
458
-    {
459
-        $short_desc = $this->get('EVT_short_desc');
460
-        if (! empty($short_desc) || $not_full_desc) {
461
-            return $short_desc;
462
-        }
463
-        $full_desc = $this->get('EVT_desc');
464
-        return wp_trim_words($full_desc, $num_words, $more);
465
-    }
466
-
467
-
468
-    /**
469
-     * @return bool
470
-     * @throws EE_Error
471
-     * @throws ReflectionException
472
-     */
473
-    public function slug()
474
-    {
475
-        return $this->get('EVT_slug');
476
-    }
477
-
478
-
479
-    /**
480
-     * @return bool
481
-     * @throws EE_Error
482
-     * @throws ReflectionException
483
-     */
484
-    public function timezone_string()
485
-    {
486
-        return $this->get('EVT_timezone_string');
487
-    }
488
-
489
-
490
-    /**
491
-     * @return bool
492
-     * @throws EE_Error
493
-     * @throws ReflectionException
494
-     */
495
-    public function visible_on()
496
-    {
497
-        return $this->get('EVT_visible_on');
498
-    }
499
-
500
-
501
-    /**
502
-     * @return int
503
-     * @throws EE_Error
504
-     * @throws ReflectionException
505
-     */
506
-    public function wp_user()
507
-    {
508
-        return $this->get('EVT_wp_user');
509
-    }
510
-
511
-
512
-    /**
513
-     * @return bool
514
-     * @throws EE_Error
515
-     * @throws ReflectionException
516
-     */
517
-    public function donations()
518
-    {
519
-        return $this->get('EVT_donations');
520
-    }
521
-
522
-
523
-    /**
524
-     * @param $limit
525
-     * @throws EE_Error
526
-     */
527
-    public function set_additional_limit($limit)
528
-    {
529
-        $this->set('EVT_additional_limit', $limit);
530
-    }
531
-
532
-
533
-    /**
534
-     * @param $created
535
-     * @throws EE_Error
536
-     */
537
-    public function set_created($created)
538
-    {
539
-        $this->set('EVT_created', $created);
540
-    }
541
-
542
-
543
-    /**
544
-     * @param $desc
545
-     * @throws EE_Error
546
-     */
547
-    public function set_description($desc)
548
-    {
549
-        $this->set('EVT_desc', $desc);
550
-    }
551
-
552
-
553
-    /**
554
-     * @param $display_desc
555
-     * @throws EE_Error
556
-     */
557
-    public function set_display_description($display_desc)
558
-    {
559
-        $this->set('EVT_display_desc', $display_desc);
560
-    }
561
-
562
-
563
-    /**
564
-     * @param $display_ticket_selector
565
-     * @throws EE_Error
566
-     */
567
-    public function set_display_ticket_selector($display_ticket_selector)
568
-    {
569
-        $this->set('EVT_display_ticket_selector', $display_ticket_selector);
570
-    }
571
-
572
-
573
-    /**
574
-     * @param $external_url
575
-     * @throws EE_Error
576
-     */
577
-    public function set_external_url($external_url)
578
-    {
579
-        $this->set('EVT_external_URL', $external_url);
580
-    }
581
-
582
-
583
-    /**
584
-     * @param $member_only
585
-     * @throws EE_Error
586
-     */
587
-    public function set_member_only($member_only)
588
-    {
589
-        $this->set('EVT_member_only', $member_only);
590
-    }
591
-
592
-
593
-    /**
594
-     * @param $event_phone
595
-     * @throws EE_Error
596
-     */
597
-    public function set_event_phone($event_phone)
598
-    {
599
-        $this->set('EVT_phone', $event_phone);
600
-    }
601
-
602
-
603
-    /**
604
-     * @param $modified
605
-     * @throws EE_Error
606
-     */
607
-    public function set_modified($modified)
608
-    {
609
-        $this->set('EVT_modified', $modified);
610
-    }
611
-
612
-
613
-    /**
614
-     * @param $name
615
-     * @throws EE_Error
616
-     */
617
-    public function set_name($name)
618
-    {
619
-        $this->set('EVT_name', $name);
620
-    }
621
-
622
-
623
-    /**
624
-     * @param $order
625
-     * @throws EE_Error
626
-     */
627
-    public function set_order($order)
628
-    {
629
-        $this->set('EVT_order', $order);
630
-    }
631
-
632
-
633
-    /**
634
-     * @param $short_desc
635
-     * @throws EE_Error
636
-     */
637
-    public function set_short_description($short_desc)
638
-    {
639
-        $this->set('EVT_short_desc', $short_desc);
640
-    }
641
-
642
-
643
-    /**
644
-     * @param $slug
645
-     * @throws EE_Error
646
-     */
647
-    public function set_slug($slug)
648
-    {
649
-        $this->set('EVT_slug', $slug);
650
-    }
651
-
652
-
653
-    /**
654
-     * @param $timezone_string
655
-     * @throws EE_Error
656
-     */
657
-    public function set_timezone_string($timezone_string)
658
-    {
659
-        $this->set('EVT_timezone_string', $timezone_string);
660
-    }
661
-
662
-
663
-    /**
664
-     * @param $visible_on
665
-     * @throws EE_Error
666
-     */
667
-    public function set_visible_on($visible_on)
668
-    {
669
-        $this->set('EVT_visible_on', $visible_on);
670
-    }
671
-
672
-
673
-    /**
674
-     * @param $wp_user
675
-     * @throws EE_Error
676
-     */
677
-    public function set_wp_user($wp_user)
678
-    {
679
-        $this->set('EVT_wp_user', $wp_user);
680
-    }
681
-
682
-
683
-    /**
684
-     * @param $default_registration_status
685
-     * @throws EE_Error
686
-     */
687
-    public function set_default_registration_status($default_registration_status)
688
-    {
689
-        $this->set('EVT_default_registration_status', $default_registration_status);
690
-    }
691
-
692
-
693
-    /**
694
-     * @param $donations
695
-     * @throws EE_Error
696
-     */
697
-    public function set_donations($donations)
698
-    {
699
-        $this->set('EVT_donations', $donations);
700
-    }
701
-
702
-
703
-    /**
704
-     * Adds a venue to this event
705
-     *
706
-     * @param int|EE_Venue /int $venue_id_or_obj
707
-     * @return EE_Base_Class|EE_Venue
708
-     * @throws EE_Error
709
-     * @throws ReflectionException
710
-     */
711
-    public function add_venue($venue_id_or_obj): EE_Venue
712
-    {
713
-        return $this->_add_relation_to($venue_id_or_obj, 'Venue');
714
-    }
715
-
716
-
717
-    /**
718
-     * Removes a venue from the event
719
-     *
720
-     * @param EE_Venue /int $venue_id_or_obj
721
-     * @return EE_Base_Class|EE_Venue
722
-     * @throws EE_Error
723
-     * @throws ReflectionException
724
-     */
725
-    public function remove_venue($venue_id_or_obj): EE_Venue
726
-    {
727
-        $venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue();
728
-        return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
729
-    }
730
-
731
-
732
-    /**
733
-     * Gets the venue related to the event. May provide additional $query_params if desired
734
-     *
735
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
736
-     * @return int
737
-     * @throws EE_Error
738
-     * @throws ReflectionException
739
-     */
740
-    public function venue_ID(array $query_params = array()): int
741
-    {
742
-        $venue = $this->get_first_related('Venue', $query_params);
743
-        return $venue instanceof EE_Venue ? $venue->ID() : 0;
744
-    }
745
-
746
-
747
-    /**
748
-     * Gets the venue related to the event. May provide additional $query_params if desired
749
-     *
750
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
751
-     * @return EE_Base_Class|EE_Venue
752
-     * @throws EE_Error
753
-     * @throws ReflectionException
754
-     */
755
-    public function venue(array $query_params = array())
756
-    {
757
-        return $this->get_first_related('Venue', $query_params);
758
-    }
759
-
760
-
761
-    /**
762
-     * @param array $query_params
763
-     * @return EE_Base_Class[]|EE_Venue[]
764
-     * @throws EE_Error
765
-     * @throws ReflectionException
766
-     * @deprecated $VID:$
767
-     */
768
-    public function venues(array $query_params = array()): array
769
-    {
770
-        return [$this->venue($query_params)];
771
-    }
772
-
773
-
774
-    /**
775
-     * check if event id is present and if event is published
776
-     *
777
-     * @access public
778
-     * @return boolean true yes, false no
779
-     * @throws EE_Error
780
-     * @throws ReflectionException
781
-     */
782
-    private function _has_ID_and_is_published()
783
-    {
784
-        // first check if event id is present and not NULL,
785
-        // then check if this event is published (or any of the equivalent "published" statuses)
786
-        return
787
-            $this->ID() && $this->ID() !== null
788
-            && (
789
-                $this->status() === 'publish'
790
-                || $this->status() === EEM_Event::sold_out
791
-                || $this->status() === EEM_Event::postponed
792
-                || $this->status() === EEM_Event::cancelled
793
-            );
794
-    }
795
-
796
-
797
-    /**
798
-     * This simply compares the internal dates with NOW and determines if the event is upcoming or not.
799
-     *
800
-     * @access public
801
-     * @return boolean true yes, false no
802
-     * @throws EE_Error
803
-     * @throws ReflectionException
804
-     */
805
-    public function is_upcoming()
806
-    {
807
-        // check if event id is present and if this event is published
808
-        if ($this->is_inactive()) {
809
-            return false;
810
-        }
811
-        // set initial value
812
-        $upcoming = false;
813
-        // next let's get all datetimes and loop through them
814
-        $datetimes = $this->datetimes_in_chronological_order();
815
-        foreach ($datetimes as $datetime) {
816
-            if ($datetime instanceof EE_Datetime) {
817
-                // if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
818
-                if ($datetime->is_expired()) {
819
-                    continue;
820
-                }
821
-                // if this dtt is active then we return false.
822
-                if ($datetime->is_active()) {
823
-                    return false;
824
-                }
825
-                // otherwise let's check upcoming status
826
-                $upcoming = $datetime->is_upcoming();
827
-            }
828
-        }
829
-        return $upcoming;
830
-    }
831
-
832
-
833
-    /**
834
-     * @return bool
835
-     * @throws EE_Error
836
-     * @throws ReflectionException
837
-     */
838
-    public function is_active()
839
-    {
840
-        // check if event id is present and if this event is published
841
-        if ($this->is_inactive()) {
842
-            return false;
843
-        }
844
-        // set initial value
845
-        $active = false;
846
-        // next let's get all datetimes and loop through them
847
-        $datetimes = $this->datetimes_in_chronological_order();
848
-        foreach ($datetimes as $datetime) {
849
-            if ($datetime instanceof EE_Datetime) {
850
-                // if this dtt is expired then we continue cause one of the other datetimes might be active.
851
-                if ($datetime->is_expired()) {
852
-                    continue;
853
-                }
854
-                // if this dtt is upcoming then we return false.
855
-                if ($datetime->is_upcoming()) {
856
-                    return false;
857
-                }
858
-                // otherwise let's check active status
859
-                $active = $datetime->is_active();
860
-            }
861
-        }
862
-        return $active;
863
-    }
864
-
865
-
866
-    /**
867
-     * @return bool
868
-     * @throws EE_Error
869
-     * @throws ReflectionException
870
-     */
871
-    public function is_expired()
872
-    {
873
-        // check if event id is present and if this event is published
874
-        if ($this->is_inactive()) {
875
-            return false;
876
-        }
877
-        // set initial value
878
-        $expired = false;
879
-        // first let's get all datetimes and loop through them
880
-        $datetimes = $this->datetimes_in_chronological_order();
881
-        foreach ($datetimes as $datetime) {
882
-            if ($datetime instanceof EE_Datetime) {
883
-                // if this dtt is upcoming or active then we return false.
884
-                if ($datetime->is_upcoming() || $datetime->is_active()) {
885
-                    return false;
886
-                }
887
-                // otherwise let's check active status
888
-                $expired = $datetime->is_expired();
889
-            }
890
-        }
891
-        return $expired;
892
-    }
893
-
894
-
895
-    /**
896
-     * @return bool
897
-     * @throws EE_Error
898
-     */
899
-    public function is_inactive()
900
-    {
901
-        // check if event id is present and if this event is published
902
-        if ($this->_has_ID_and_is_published()) {
903
-            return false;
904
-        }
905
-        return true;
906
-    }
907
-
908
-
909
-    /**
910
-     * calculate spaces remaining based on "saleable" tickets
911
-     *
912
-     * @param array $tickets
913
-     * @param bool  $filtered
914
-     * @return int|float
915
-     * @throws EE_Error
916
-     * @throws DomainException
917
-     * @throws UnexpectedEntityException
918
-     */
919
-    public function spaces_remaining($tickets = array(), $filtered = true)
920
-    {
921
-        $this->getAvailableSpacesCalculator()->setActiveTickets($tickets);
922
-        $spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining();
923
-        return $filtered
924
-            ? apply_filters(
925
-                'FHEE_EE_Event__spaces_remaining',
926
-                $spaces_remaining,
927
-                $this,
928
-                $tickets
929
-            )
930
-            : $spaces_remaining;
931
-    }
932
-
933
-
934
-    /**
935
-     *    perform_sold_out_status_check
936
-     *    checks all of this events's datetime  reg_limit - sold values to determine if ANY datetimes have spaces
937
-     *    available... if NOT, then the event status will get toggled to 'sold_out'
938
-     *
939
-     * @return bool    return the ACTUAL sold out state.
940
-     * @throws EE_Error
941
-     * @throws DomainException
942
-     * @throws UnexpectedEntityException
943
-     * @throws ReflectionException
944
-     */
945
-    public function perform_sold_out_status_check()
946
-    {
947
-        // get all tickets
948
-        $tickets = $this->tickets(
949
-            array(
950
-                'default_where_conditions' => 'none',
951
-                'order_by' => array('TKT_qty' => 'ASC'),
952
-            )
953
-        );
954
-        $all_expired = true;
955
-        foreach ($tickets as $ticket) {
956
-            if (! $ticket->is_expired()) {
957
-                $all_expired = false;
958
-                break;
959
-            }
960
-        }
961
-        // if all the tickets are just expired, then don't update the event status to sold out
962
-        if ($all_expired) {
963
-            return true;
964
-        }
965
-        $spaces_remaining = $this->spaces_remaining($tickets);
966
-        if ($spaces_remaining < 1) {
967
-            if ($this->status() !== EEM_Event::post_status_private) {
968
-                $this->set_status(EEM_Event::sold_out);
969
-                $this->save();
970
-            }
971
-            $sold_out = true;
972
-        } else {
973
-            $sold_out = false;
974
-            // was event previously marked as sold out ?
975
-            if ($this->status() === EEM_Event::sold_out) {
976
-                // revert status to previous value, if it was set
977
-                $previous_event_status = $this->get_post_meta('_previous_event_status', true);
978
-                if ($previous_event_status) {
979
-                    $this->set_status($previous_event_status);
980
-                    $this->save();
981
-                }
982
-            }
983
-        }
984
-        do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets);
985
-        return $sold_out;
986
-    }
987
-
988
-
989
-    /**
990
-     * This returns the total remaining spaces for sale on this event.
991
-     *
992
-     * @uses EE_Event::total_available_spaces()
993
-     * @return float|int
994
-     * @throws EE_Error
995
-     * @throws DomainException
996
-     * @throws UnexpectedEntityException
997
-     */
998
-    public function spaces_remaining_for_sale()
999
-    {
1000
-        return $this->total_available_spaces(true);
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * This returns the total spaces available for an event
1006
-     * while considering all the qtys on the tickets and the reg limits
1007
-     * on the datetimes attached to this event.
1008
-     *
1009
-     * @param   bool $consider_sold Whether to consider any tickets that have already sold in our calculation.
1010
-     *                              If this is false, then we return the most tickets that could ever be sold
1011
-     *                              for this event with the datetime and tickets setup on the event under optimal
1012
-     *                              selling conditions.  Otherwise we return a live calculation of spaces available
1013
-     *                              based on tickets sold.  Depending on setup and stage of sales, this
1014
-     *                              may appear to equal remaining tickets.  However, the more tickets are
1015
-     *                              sold out, the more accurate the "live" total is.
1016
-     * @return float|int
1017
-     * @throws EE_Error
1018
-     * @throws DomainException
1019
-     * @throws UnexpectedEntityException
1020
-     */
1021
-    public function total_available_spaces($consider_sold = false)
1022
-    {
1023
-        $spaces_available = $consider_sold
1024
-            ? $this->getAvailableSpacesCalculator()->spacesRemaining()
1025
-            : $this->getAvailableSpacesCalculator()->totalSpacesAvailable();
1026
-        return apply_filters(
1027
-            'FHEE_EE_Event__total_available_spaces__spaces_available',
1028
-            $spaces_available,
1029
-            $this,
1030
-            $this->getAvailableSpacesCalculator()->getDatetimes(),
1031
-            $this->getAvailableSpacesCalculator()->getActiveTickets()
1032
-        );
1033
-    }
1034
-
1035
-
1036
-    /**
1037
-     * Checks if the event is set to sold out
1038
-     *
1039
-     * @param  bool $actual whether or not to perform calculations to not only figure the
1040
-     *                      actual status but also to flip the status if necessary to sold
1041
-     *                      out If false, we just check the existing status of the event
1042
-     * @return boolean
1043
-     * @throws EE_Error
1044
-     */
1045
-    public function is_sold_out($actual = false)
1046
-    {
1047
-        if (! $actual) {
1048
-            return $this->status() === EEM_Event::sold_out;
1049
-        }
1050
-        return $this->perform_sold_out_status_check();
1051
-    }
1052
-
1053
-
1054
-    /**
1055
-     * Checks if the event is marked as postponed
1056
-     *
1057
-     * @return boolean
1058
-     */
1059
-    public function is_postponed()
1060
-    {
1061
-        return $this->status() === EEM_Event::postponed;
1062
-    }
1063
-
1064
-
1065
-    /**
1066
-     * Checks if the event is marked as cancelled
1067
-     *
1068
-     * @return boolean
1069
-     */
1070
-    public function is_cancelled()
1071
-    {
1072
-        return $this->status() === EEM_Event::cancelled;
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * Get the logical active status in a hierarchical order for all the datetimes.  Note
1078
-     * Basically, we order the datetimes by EVT_start_date.  Then first test on whether the event is published.  If its
1079
-     * NOT published then we test for whether its expired or not.  IF it IS published then we test first on whether an
1080
-     * event has any active dates.  If no active dates then we check for any upcoming dates.  If no upcoming dates then
1081
-     * the event is considered expired.
1082
-     * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published.  Sold Out is a
1083
-     * status set on the EVENT when it is not published and thus is done
1084
-     *
1085
-     * @param bool $reset
1086
-     * @return bool | string - based on EE_Datetime active constants or FALSE if error.
1087
-     * @throws EE_Error
1088
-     * @throws ReflectionException
1089
-     */
1090
-    public function get_active_status($reset = false)
1091
-    {
1092
-        // if the active status has already been set, then just use that value (unless we are resetting it)
1093
-        if (! empty($this->_active_status) && ! $reset) {
1094
-            return $this->_active_status;
1095
-        }
1096
-        // first check if event id is present on this object
1097
-        if (! $this->ID()) {
1098
-            return false;
1099
-        }
1100
-        $where_params_for_event = array(array('EVT_ID' => $this->ID()));
1101
-        // if event is published:
1102
-        if ($this->status() === EEM_Event::post_status_publish || $this->status() === EEM_Event::post_status_private) {
1103
-            // active?
1104
-            if (
1105
-                EEM_Datetime::instance()->get_datetime_count_for_status(
1106
-                    EE_Datetime::active,
1107
-                    $where_params_for_event
1108
-                ) > 0
1109
-            ) {
1110
-                $this->_active_status = EE_Datetime::active;
1111
-            } else {
1112
-                // upcoming?
1113
-                if (
1114
-                    EEM_Datetime::instance()->get_datetime_count_for_status(
1115
-                        EE_Datetime::upcoming,
1116
-                        $where_params_for_event
1117
-                    ) > 0
1118
-                ) {
1119
-                    $this->_active_status = EE_Datetime::upcoming;
1120
-                } else {
1121
-                    // expired?
1122
-                    if (
1123
-                        EEM_Datetime::instance()->get_datetime_count_for_status(
1124
-                            EE_Datetime::expired,
1125
-                            $where_params_for_event
1126
-                        ) > 0
1127
-                    ) {
1128
-                        $this->_active_status = EE_Datetime::expired;
1129
-                    } else {
1130
-                        // it would be odd if things make it this far because it basically means there are no datetime's
1131
-                        // attached to the event.  So in this case it will just be considered inactive.
1132
-                        $this->_active_status = EE_Datetime::inactive;
1133
-                    }
1134
-                }
1135
-            }
1136
-        } else {
1137
-            // the event is not published, so let's just set it's active status according to its' post status
1138
-            switch ($this->status()) {
1139
-                case EEM_Event::sold_out:
1140
-                    $this->_active_status = EE_Datetime::sold_out;
1141
-                    break;
1142
-                case EEM_Event::cancelled:
1143
-                    $this->_active_status = EE_Datetime::cancelled;
1144
-                    break;
1145
-                case EEM_Event::postponed:
1146
-                    $this->_active_status = EE_Datetime::postponed;
1147
-                    break;
1148
-                default:
1149
-                    $this->_active_status = EE_Datetime::inactive;
1150
-            }
1151
-        }
1152
-        return $this->_active_status;
1153
-    }
1154
-
1155
-
1156
-    /**
1157
-     *    pretty_active_status
1158
-     *
1159
-     * @access public
1160
-     * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE)
1161
-     * @return mixed void|string
1162
-     * @throws EE_Error
1163
-     * @throws ReflectionException
1164
-     */
1165
-    public function pretty_active_status($echo = true)
1166
-    {
1167
-        $active_status = $this->get_active_status();
1168
-        $status = '<span class="ee-status event-active-status--' . esc_attr($active_status) . '">'
1169
-                  . EEH_Template::pretty_status($active_status, false, 'sentence')
1170
-                  . '</span>';
1171
-        if ($echo) {
1172
-            echo $status; // already escaped
1173
-            return '';
1174
-        }
1175
-        return $status; // already escaped
1176
-    }
1177
-
1178
-
1179
-    /**
1180
-     * @return bool|int
1181
-     * @throws EE_Error
1182
-     * @throws ReflectionException
1183
-     */
1184
-    public function get_number_of_tickets_sold()
1185
-    {
1186
-        $tkt_sold = 0;
1187
-        if (! $this->ID()) {
1188
-            return 0;
1189
-        }
1190
-        $datetimes = $this->datetimes();
1191
-        foreach ($datetimes as $datetime) {
1192
-            if ($datetime instanceof EE_Datetime) {
1193
-                $tkt_sold += $datetime->sold();
1194
-            }
1195
-        }
1196
-        return $tkt_sold;
1197
-    }
1198
-
1199
-
1200
-    /**
1201
-     * This just returns a count of all the registrations for this event
1202
-     *
1203
-     * @access  public
1204
-     * @return int
1205
-     * @throws EE_Error
1206
-     */
1207
-    public function get_count_of_all_registrations()
1208
-    {
1209
-        return EEM_Event::instance()->count_related($this, 'Registration');
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     * This returns the ticket with the earliest start time that is
1215
-     * available for this event (across all datetimes attached to the event)
1216
-     *
1217
-     * @return EE_Base_Class|EE_Ticket|null
1218
-     * @throws EE_Error
1219
-     * @throws ReflectionException
1220
-     */
1221
-    public function get_ticket_with_earliest_start_time()
1222
-    {
1223
-        $where['Datetime.EVT_ID'] = $this->ID();
1224
-        $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1225
-        return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * This returns the ticket with the latest end time that is available
1231
-     * for this event (across all datetimes attached to the event)
1232
-     *
1233
-     * @return EE_Base_Class|EE_Ticket|null
1234
-     * @throws EE_Error
1235
-     * @throws ReflectionException
1236
-     */
1237
-    public function get_ticket_with_latest_end_time()
1238
-    {
1239
-        $where['Datetime.EVT_ID'] = $this->ID();
1240
-        $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1241
-        return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * This returns the number of different ticket types currently on sale for this event.
1247
-     *
1248
-     * @return int
1249
-     * @throws EE_Error
1250
-     * @throws ReflectionException
1251
-     */
1252
-    public function countTicketsOnSale()
1253
-    {
1254
-        $where = array(
1255
-            'Datetime.EVT_ID' => $this->ID(),
1256
-            'TKT_start_date'  => array('<', time()),
1257
-            'TKT_end_date'    => array('>', time()),
1258
-        );
1259
-        return EEM_Ticket::instance()->count(array($where));
1260
-    }
1261
-
1262
-
1263
-    /**
1264
-     * This returns whether there are any tickets on sale for this event.
1265
-     *
1266
-     * @return bool true = YES tickets on sale.
1267
-     * @throws EE_Error
1268
-     */
1269
-    public function tickets_on_sale()
1270
-    {
1271
-        return $this->countTicketsOnSale() > 0;
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * Gets the URL for viewing this event on the front-end. Overrides parent
1277
-     * to check for an external URL first
1278
-     *
1279
-     * @return string
1280
-     * @throws EE_Error
1281
-     */
1282
-    public function get_permalink()
1283
-    {
1284
-        if ($this->external_url()) {
1285
-            return $this->external_url();
1286
-        }
1287
-        return parent::get_permalink();
1288
-    }
1289
-
1290
-
1291
-    /**
1292
-     * Gets the first term for 'espresso_event_categories' we can find
1293
-     *
1294
-     * @param array $query_params @see
1295
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1296
-     * @return EE_Base_Class|EE_Term|null
1297
-     * @throws EE_Error
1298
-     * @throws ReflectionException
1299
-     */
1300
-    public function first_event_category($query_params = array())
1301
-    {
1302
-        $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1303
-        $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1304
-        return EEM_Term::instance()->get_one($query_params);
1305
-    }
1306
-
1307
-
1308
-    /**
1309
-     * Gets all terms for 'espresso_event_categories' we can find
1310
-     *
1311
-     * @param array $query_params
1312
-     * @return EE_Base_Class[]|EE_Term[]
1313
-     * @throws EE_Error
1314
-     * @throws ReflectionException
1315
-     */
1316
-    public function get_all_event_categories($query_params = array())
1317
-    {
1318
-        $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1319
-        $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1320
-        return EEM_Term::instance()->get_all($query_params);
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * Adds a question group to this event
1326
-     *
1327
-     * @param EE_Question_Group|int $question_group_id_or_obj
1328
-     * @param bool $for_primary if true, the question group will be added for the primary
1329
-     *                                           registrant, if false will be added for others. default: false
1330
-     * @return EE_Base_Class|EE_Question_Group
1331
-     * @throws EE_Error
1332
-     * @throws InvalidArgumentException
1333
-     * @throws InvalidDataTypeException
1334
-     * @throws InvalidInterfaceException
1335
-     * @throws ReflectionException
1336
-     */
1337
-    public function add_question_group($question_group_id_or_obj, $for_primary = false)
1338
-    {
1339
-        // If the row already exists, it will be updated. If it doesn't, it will be inserted.
1340
-        // That's in EE_HABTM_Relation::add_relation_to().
1341
-        return $this->_add_relation_to(
1342
-            $question_group_id_or_obj,
1343
-            'Question_Group',
1344
-            [
1345
-                EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary) => true
1346
-            ]
1347
-        );
1348
-    }
1349
-
1350
-
1351
-    /**
1352
-     * Removes a question group from the event
1353
-     *
1354
-     * @param EE_Question_Group|int $question_group_id_or_obj
1355
-     * @param bool $for_primary if true, the question group will be removed from the primary
1356
-     *                                           registrant, if false will be removed from others. default: false
1357
-     * @return EE_Base_Class|EE_Question_Group
1358
-     * @throws EE_Error
1359
-     * @throws InvalidArgumentException
1360
-     * @throws ReflectionException
1361
-     * @throws InvalidDataTypeException
1362
-     * @throws InvalidInterfaceException
1363
-     */
1364
-    public function remove_question_group($question_group_id_or_obj, $for_primary = false)
1365
-    {
1366
-        // If the question group is used for the other type (primary or additional)
1367
-        // then just update it. If not, delete it outright.
1368
-        $existing_relation = $this->get_first_related(
1369
-            'Event_Question_Group',
1370
-            [
1371
-                [
1372
-                    'QSG_ID' => EEM_Question_Group::instance()->ensure_is_ID($question_group_id_or_obj)
1373
-                ]
1374
-            ]
1375
-        );
1376
-        $field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary);
1377
-        $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary);
1378
-        if ($existing_relation->get($other_field) === false) {
1379
-            // Delete it. It's now no longer for primary or additional question groups.
1380
-            return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group');
1381
-        }
1382
-        // Just update it. They'll still use this question group for the other category
1383
-        $existing_relation->save(
1384
-            [
1385
-                $field_to_update => false
1386
-            ]
1387
-        );
1388
-    }
1389
-
1390
-
1391
-    /**
1392
-     * Gets all the question groups, ordering them by QSG_order ascending
1393
-     *
1394
-     * @param array $query_params @see
1395
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1396
-     * @return EE_Base_Class[]|EE_Question_Group[]
1397
-     * @throws EE_Error
1398
-     * @throws ReflectionException
1399
-     */
1400
-    public function question_groups($query_params = array())
1401
-    {
1402
-        $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1403
-        return $this->get_many_related('Question_Group', $query_params);
1404
-    }
1405
-
1406
-
1407
-    /**
1408
-     * Implementation for EEI_Has_Icon interface method.
1409
-     *
1410
-     * @see EEI_Visual_Representation for comments
1411
-     * @return string
1412
-     */
1413
-    public function get_icon()
1414
-    {
1415
-        return '<span class="dashicons dashicons-flag"></span>';
1416
-    }
1417
-
1418
-
1419
-    /**
1420
-     * Implementation for EEI_Admin_Links interface method.
1421
-     *
1422
-     * @see EEI_Admin_Links for comments
1423
-     * @return string
1424
-     * @throws EE_Error
1425
-     */
1426
-    public function get_admin_details_link()
1427
-    {
1428
-        return $this->get_admin_edit_link();
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * Implementation for EEI_Admin_Links interface method.
1434
-     *
1435
-     * @return string
1436
-     * @throws EE_Error*@throws ReflectionException
1437
-     * @see EEI_Admin_Links for comments
1438
-     */
1439
-    public function get_admin_edit_link()
1440
-    {
1441
-        return EEH_URL::add_query_args_and_nonce(
1442
-            array(
1443
-                'page'   => 'espresso_events',
1444
-                'action' => 'edit',
1445
-                'post'   => $this->ID(),
1446
-            ),
1447
-            admin_url('admin.php')
1448
-        );
1449
-    }
1450
-
1451
-
1452
-    /**
1453
-     * Implementation for EEI_Admin_Links interface method.
1454
-     *
1455
-     * @see EEI_Admin_Links for comments
1456
-     * @return string
1457
-     */
1458
-    public function get_admin_settings_link()
1459
-    {
1460
-        return EEH_URL::add_query_args_and_nonce(
1461
-            array(
1462
-                'page'   => 'espresso_events',
1463
-                'action' => 'default_event_settings',
1464
-            ),
1465
-            admin_url('admin.php')
1466
-        );
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * Implementation for EEI_Admin_Links interface method.
1472
-     *
1473
-     * @see EEI_Admin_Links for comments
1474
-     * @return string
1475
-     */
1476
-    public function get_admin_overview_link()
1477
-    {
1478
-        return EEH_URL::add_query_args_and_nonce(
1479
-            array(
1480
-                'page'   => 'espresso_events',
1481
-                'action' => 'default',
1482
-            ),
1483
-            admin_url('admin.php')
1484
-        );
1485
-    }
1486
-
1487
-
1488
-    /**
1489
-     * @return string|null
1490
-     * @throws EE_Error
1491
-     * @throws ReflectionException
1492
-     */
1493
-    public function registrationFormUuid(): ?string
1494
-    {
1495
-        return $this->get('FSC_UUID');
1496
-    }
1497
-
1498
-
1499
-    /**
1500
-     * Gets all the form sections for this event
1501
-     *
1502
-     * @return EE_Base_Class[]|EE_Form_Section[]
1503
-     * @throws EE_Error
1504
-     * @throws ReflectionException
1505
-     */
1506
-    public function registrationForm()
1507
-    {
1508
-        $FSC_UUID = $this->registrationFormUuid();
1509
-
1510
-        if (empty($FSC_UUID)) {
1511
-            return [];
1512
-        }
1513
-
1514
-        return EEM_Form_Section::instance()->get_all([
1515
-            [
1516
-                'OR' => [
1517
-                    'FSC_UUID'      => $FSC_UUID, // top level form
1518
-                    'FSC_belongsTo' => $FSC_UUID, // child form sections
1519
-                ]
1520
-                ],
1521
-            'order_by' => ['FSC_order' => 'ASC'],
1522
-        ]);
1523
-    }
1524
-
1525
-
1526
-    /**
1527
-     * @param string $UUID
1528
-     * @throws EE_Error
1529
-     */
1530
-    public function setRegistrationFormUuid(string $UUID): void
1531
-    {
1532
-        if (! Cuid::isCuid($UUID)) {
1533
-            throw new InvalidArgumentException(
1534
-                sprintf(
1535
-                /* translators: 1: UUID value, 2: UUID generator function. */
1536
-                    esc_html__(
1537
-                        'The supplied UUID "%1$s" is invalid or missing. Please use %2$s to generate a valid one.',
1538
-                        'event_espresso'
1539
-                    ),
1540
-                    $UUID,
1541
-                    '`Cuid::cuid()`'
1542
-                )
1543
-            );
1544
-        }
1545
-        $this->set('FSC_UUID', $UUID);
1546
-    }
19
+	/**
20
+	 * cached value for the the logical active status for the event
21
+	 *
22
+	 * @see get_active_status()
23
+	 * @var string
24
+	 */
25
+	protected $_active_status = '';
26
+
27
+	/**
28
+	 * This is just used for caching the Primary Datetime for the Event on initial retrieval
29
+	 *
30
+	 * @var EE_Datetime
31
+	 */
32
+	protected $_Primary_Datetime;
33
+
34
+	/**
35
+	 * @var EventSpacesCalculator $available_spaces_calculator
36
+	 */
37
+	protected $available_spaces_calculator;
38
+
39
+
40
+	/**
41
+	 * @param array  $props_n_values          incoming values
42
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
43
+	 *                                        used.)
44
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
45
+	 *                                        date_format and the second value is the time format
46
+	 * @return EE_Event
47
+	 * @throws EE_Error
48
+	 * @throws ReflectionException
49
+	 */
50
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
51
+	{
52
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
53
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
54
+	}
55
+
56
+
57
+	/**
58
+	 * @param array  $props_n_values  incoming values from the database
59
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
60
+	 *                                the website will be used.
61
+	 * @return EE_Event
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
66
+	{
67
+		return new self($props_n_values, true, $timezone);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return EventSpacesCalculator
73
+	 * @throws \EE_Error
74
+	 */
75
+	public function getAvailableSpacesCalculator()
76
+	{
77
+		if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
78
+			$this->available_spaces_calculator = new EventSpacesCalculator($this);
79
+		}
80
+		return $this->available_spaces_calculator;
81
+	}
82
+
83
+
84
+	/**
85
+	 * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods
86
+	 *
87
+	 * @param string $field_name
88
+	 * @param mixed  $field_value
89
+	 * @param bool   $use_default
90
+	 * @throws EE_Error
91
+	 * @throws ReflectionException
92
+	 */
93
+	public function set($field_name, $field_value, $use_default = false)
94
+	{
95
+		switch ($field_name) {
96
+			case 'status':
97
+				$this->set_status($field_value, $use_default);
98
+				break;
99
+			default:
100
+				parent::set($field_name, $field_value, $use_default);
101
+		}
102
+	}
103
+
104
+
105
+	/**
106
+	 *    set_status
107
+	 * Checks if event status is being changed to SOLD OUT
108
+	 * and updates event meta data with previous event status
109
+	 * so that we can revert things if/when the event is no longer sold out
110
+	 *
111
+	 * @access public
112
+	 * @param string $new_status
113
+	 * @param bool   $use_default
114
+	 * @return void
115
+	 * @throws EE_Error
116
+	 * @throws ReflectionException
117
+	 */
118
+	public function set_status($new_status = null, $use_default = false)
119
+	{
120
+		// if nothing is set, and we aren't explicitly wanting to reset the status, then just leave
121
+		if (empty($new_status) && ! $use_default) {
122
+			return;
123
+		}
124
+		// get current Event status
125
+		$old_status = $this->status();
126
+		// if status has changed
127
+		if ($old_status !== $new_status) {
128
+			// TO sold_out
129
+			if ($new_status === EEM_Event::sold_out) {
130
+				// save the previous event status so that we can revert if the event is no longer sold out
131
+				$this->add_post_meta('_previous_event_status', $old_status);
132
+				do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status);
133
+			// OR FROM  sold_out
134
+			} elseif ($old_status === EEM_Event::sold_out) {
135
+				$this->delete_post_meta('_previous_event_status');
136
+				do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status);
137
+			}
138
+			// clear out the active status so that it gets reset the next time it is requested
139
+			$this->_active_status = null;
140
+			// update status
141
+			parent::set('status', $new_status, $use_default);
142
+			do_action('AHEE__EE_Event__set_status__after_update', $this);
143
+			return;
144
+		}
145
+		// even though the old value matches the new value, it's still good to
146
+		// allow the parent set method to have a say
147
+		parent::set('status', $new_status, $use_default);
148
+	}
149
+
150
+
151
+	/**
152
+	 * Gets all the datetimes for this event
153
+	 *
154
+	 * @param array $query_params @see
155
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
156
+	 * @return EE_Base_Class[]|EE_Datetime[]
157
+	 * @throws EE_Error
158
+	 * @throws ReflectionException
159
+	 */
160
+	public function datetimes($query_params = array())
161
+	{
162
+		return $this->get_many_related('Datetime', $query_params);
163
+	}
164
+
165
+
166
+	/**
167
+	 * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order
168
+	 *
169
+	 * @return EE_Base_Class[]|EE_Datetime[]
170
+	 * @throws EE_Error
171
+	 * @throws ReflectionException
172
+	 */
173
+	public function datetimes_in_chronological_order()
174
+	{
175
+		return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
176
+	}
177
+
178
+
179
+	/**
180
+	 * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
181
+	 * @darren, we should probably UNSET timezone on the EEM_Datetime model
182
+	 * after running our query, so that this timezone isn't set for EVERY query
183
+	 * on EEM_Datetime for the rest of the request, no?
184
+	 *
185
+	 * @param boolean $show_expired whether or not to include expired events
186
+	 * @param boolean $show_deleted whether or not to include deleted events
187
+	 * @param null    $limit
188
+	 * @return EE_Datetime[]
189
+	 * @throws EE_Error
190
+	 * @throws ReflectionException
191
+	 */
192
+	public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null)
193
+	{
194
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order(
195
+			$this->ID(),
196
+			$show_expired,
197
+			$show_deleted,
198
+			$limit
199
+		);
200
+	}
201
+
202
+
203
+	/**
204
+	 * Returns one related datetime. Mostly only used by some legacy code.
205
+	 *
206
+	 * @return EE_Base_Class|EE_Datetime
207
+	 * @throws EE_Error
208
+	 * @throws ReflectionException
209
+	 */
210
+	public function first_datetime()
211
+	{
212
+		return $this->get_first_related('Datetime');
213
+	}
214
+
215
+
216
+	/**
217
+	 * Returns the 'primary' datetime for the event
218
+	 *
219
+	 * @param bool $try_to_exclude_expired
220
+	 * @param bool $try_to_exclude_deleted
221
+	 * @return EE_Datetime
222
+	 * @throws EE_Error
223
+	 * @throws ReflectionException
224
+	 */
225
+	public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
226
+	{
227
+		if (! empty($this->_Primary_Datetime)) {
228
+			return $this->_Primary_Datetime;
229
+		}
230
+		$this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
231
+			$this->ID(),
232
+			$try_to_exclude_expired,
233
+			$try_to_exclude_deleted
234
+		);
235
+		return $this->_Primary_Datetime;
236
+	}
237
+
238
+
239
+	/**
240
+	 * Gets all the tickets available for purchase of this event
241
+	 *
242
+	 * @param array $query_params @see
243
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
244
+	 * @return EE_Base_Class[]|EE_Ticket[]
245
+	 * @throws EE_Error
246
+	 * @throws ReflectionException
247
+	 */
248
+	public function tickets($query_params = array())
249
+	{
250
+		// first get all datetimes
251
+		$datetimes = $this->datetimes_ordered();
252
+		if (! $datetimes) {
253
+			return array();
254
+		}
255
+		$datetime_ids = array();
256
+		foreach ($datetimes as $datetime) {
257
+			$datetime_ids[] = $datetime->ID();
258
+		}
259
+		$where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
260
+		// if incoming $query_params has where conditions let's merge but not override existing.
261
+		if (is_array($query_params) && isset($query_params[0])) {
262
+			$where_params = array_merge($query_params[0], $where_params);
263
+			unset($query_params[0]);
264
+		}
265
+		// now add $where_params to $query_params
266
+		$query_params[0] = $where_params;
267
+		return EEM_Ticket::instance()->get_all($query_params);
268
+	}
269
+
270
+
271
+	/**
272
+	 * get all unexpired untrashed tickets
273
+	 *
274
+	 * @return EE_Ticket[]
275
+	 * @throws EE_Error
276
+	 */
277
+	public function active_tickets()
278
+	{
279
+		return $this->tickets(
280
+			array(
281
+				array(
282
+					'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
283
+					'TKT_deleted'  => false,
284
+				),
285
+			)
286
+		);
287
+	}
288
+
289
+
290
+	/**
291
+	 * @return bool
292
+	 * @throws EE_Error
293
+	 * @throws ReflectionException
294
+	 */
295
+	public function additional_limit()
296
+	{
297
+		return $this->get('EVT_additional_limit');
298
+	}
299
+
300
+
301
+	/**
302
+	 * @return bool
303
+	 * @throws EE_Error
304
+	 * @throws ReflectionException
305
+	 */
306
+	public function allow_overflow()
307
+	{
308
+		return $this->get('EVT_allow_overflow');
309
+	}
310
+
311
+
312
+	/**
313
+	 * @return bool
314
+	 * @throws EE_Error
315
+	 * @throws ReflectionException
316
+	 */
317
+	public function created()
318
+	{
319
+		return $this->get('EVT_created');
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return bool
325
+	 * @throws EE_Error
326
+	 * @throws ReflectionException
327
+	 */
328
+	public function description()
329
+	{
330
+		return $this->get('EVT_desc');
331
+	}
332
+
333
+
334
+	/**
335
+	 * Runs do_shortcode and wpautop on the description
336
+	 *
337
+	 * @return string of html
338
+	 * @throws EE_Error
339
+	 * @throws ReflectionException
340
+	 */
341
+	public function description_filtered()
342
+	{
343
+		return $this->get_pretty('EVT_desc');
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return bool
349
+	 * @throws EE_Error
350
+	 * @throws ReflectionException
351
+	 */
352
+	public function display_description()
353
+	{
354
+		return $this->get('EVT_display_desc');
355
+	}
356
+
357
+
358
+	/**
359
+	 * @return bool
360
+	 * @throws EE_Error
361
+	 * @throws ReflectionException
362
+	 */
363
+	public function display_ticket_selector()
364
+	{
365
+		return (bool) $this->get('EVT_display_ticket_selector');
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return string
371
+	 * @throws EE_Error
372
+	 * @throws ReflectionException
373
+	 */
374
+	public function external_url()
375
+	{
376
+		return $this->get('EVT_external_URL');
377
+	}
378
+
379
+
380
+	/**
381
+	 * @return bool
382
+	 * @throws EE_Error
383
+	 * @throws ReflectionException
384
+	 */
385
+	public function member_only()
386
+	{
387
+		return $this->get('EVT_member_only');
388
+	}
389
+
390
+
391
+	/**
392
+	 * @return bool
393
+	 * @throws EE_Error
394
+	 * @throws ReflectionException
395
+	 */
396
+	public function phone()
397
+	{
398
+		return $this->get('EVT_phone');
399
+	}
400
+
401
+
402
+	/**
403
+	 * @return bool
404
+	 * @throws EE_Error
405
+	 * @throws ReflectionException
406
+	 */
407
+	public function modified()
408
+	{
409
+		return $this->get('EVT_modified');
410
+	}
411
+
412
+
413
+	/**
414
+	 * @return bool
415
+	 * @throws EE_Error
416
+	 * @throws ReflectionException
417
+	 */
418
+	public function name()
419
+	{
420
+		return $this->get('EVT_name');
421
+	}
422
+
423
+
424
+	/**
425
+	 * @return bool
426
+	 * @throws EE_Error
427
+	 * @throws ReflectionException
428
+	 */
429
+	public function order()
430
+	{
431
+		return $this->get('EVT_order');
432
+	}
433
+
434
+
435
+	/**
436
+	 * @return bool|string
437
+	 * @throws EE_Error
438
+	 * @throws ReflectionException
439
+	 */
440
+	public function default_registration_status()
441
+	{
442
+		$event_default_registration_status = $this->get('EVT_default_registration_status');
443
+		return ! empty($event_default_registration_status)
444
+			? $event_default_registration_status
445
+			: EE_Registry::instance()->CFG->registration->default_STS_ID;
446
+	}
447
+
448
+
449
+	/**
450
+	 * @param int  $num_words
451
+	 * @param null $more
452
+	 * @param bool $not_full_desc
453
+	 * @return bool|string
454
+	 * @throws EE_Error
455
+	 * @throws ReflectionException
456
+	 */
457
+	public function short_description($num_words = 55, $more = null, $not_full_desc = false)
458
+	{
459
+		$short_desc = $this->get('EVT_short_desc');
460
+		if (! empty($short_desc) || $not_full_desc) {
461
+			return $short_desc;
462
+		}
463
+		$full_desc = $this->get('EVT_desc');
464
+		return wp_trim_words($full_desc, $num_words, $more);
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return bool
470
+	 * @throws EE_Error
471
+	 * @throws ReflectionException
472
+	 */
473
+	public function slug()
474
+	{
475
+		return $this->get('EVT_slug');
476
+	}
477
+
478
+
479
+	/**
480
+	 * @return bool
481
+	 * @throws EE_Error
482
+	 * @throws ReflectionException
483
+	 */
484
+	public function timezone_string()
485
+	{
486
+		return $this->get('EVT_timezone_string');
487
+	}
488
+
489
+
490
+	/**
491
+	 * @return bool
492
+	 * @throws EE_Error
493
+	 * @throws ReflectionException
494
+	 */
495
+	public function visible_on()
496
+	{
497
+		return $this->get('EVT_visible_on');
498
+	}
499
+
500
+
501
+	/**
502
+	 * @return int
503
+	 * @throws EE_Error
504
+	 * @throws ReflectionException
505
+	 */
506
+	public function wp_user()
507
+	{
508
+		return $this->get('EVT_wp_user');
509
+	}
510
+
511
+
512
+	/**
513
+	 * @return bool
514
+	 * @throws EE_Error
515
+	 * @throws ReflectionException
516
+	 */
517
+	public function donations()
518
+	{
519
+		return $this->get('EVT_donations');
520
+	}
521
+
522
+
523
+	/**
524
+	 * @param $limit
525
+	 * @throws EE_Error
526
+	 */
527
+	public function set_additional_limit($limit)
528
+	{
529
+		$this->set('EVT_additional_limit', $limit);
530
+	}
531
+
532
+
533
+	/**
534
+	 * @param $created
535
+	 * @throws EE_Error
536
+	 */
537
+	public function set_created($created)
538
+	{
539
+		$this->set('EVT_created', $created);
540
+	}
541
+
542
+
543
+	/**
544
+	 * @param $desc
545
+	 * @throws EE_Error
546
+	 */
547
+	public function set_description($desc)
548
+	{
549
+		$this->set('EVT_desc', $desc);
550
+	}
551
+
552
+
553
+	/**
554
+	 * @param $display_desc
555
+	 * @throws EE_Error
556
+	 */
557
+	public function set_display_description($display_desc)
558
+	{
559
+		$this->set('EVT_display_desc', $display_desc);
560
+	}
561
+
562
+
563
+	/**
564
+	 * @param $display_ticket_selector
565
+	 * @throws EE_Error
566
+	 */
567
+	public function set_display_ticket_selector($display_ticket_selector)
568
+	{
569
+		$this->set('EVT_display_ticket_selector', $display_ticket_selector);
570
+	}
571
+
572
+
573
+	/**
574
+	 * @param $external_url
575
+	 * @throws EE_Error
576
+	 */
577
+	public function set_external_url($external_url)
578
+	{
579
+		$this->set('EVT_external_URL', $external_url);
580
+	}
581
+
582
+
583
+	/**
584
+	 * @param $member_only
585
+	 * @throws EE_Error
586
+	 */
587
+	public function set_member_only($member_only)
588
+	{
589
+		$this->set('EVT_member_only', $member_only);
590
+	}
591
+
592
+
593
+	/**
594
+	 * @param $event_phone
595
+	 * @throws EE_Error
596
+	 */
597
+	public function set_event_phone($event_phone)
598
+	{
599
+		$this->set('EVT_phone', $event_phone);
600
+	}
601
+
602
+
603
+	/**
604
+	 * @param $modified
605
+	 * @throws EE_Error
606
+	 */
607
+	public function set_modified($modified)
608
+	{
609
+		$this->set('EVT_modified', $modified);
610
+	}
611
+
612
+
613
+	/**
614
+	 * @param $name
615
+	 * @throws EE_Error
616
+	 */
617
+	public function set_name($name)
618
+	{
619
+		$this->set('EVT_name', $name);
620
+	}
621
+
622
+
623
+	/**
624
+	 * @param $order
625
+	 * @throws EE_Error
626
+	 */
627
+	public function set_order($order)
628
+	{
629
+		$this->set('EVT_order', $order);
630
+	}
631
+
632
+
633
+	/**
634
+	 * @param $short_desc
635
+	 * @throws EE_Error
636
+	 */
637
+	public function set_short_description($short_desc)
638
+	{
639
+		$this->set('EVT_short_desc', $short_desc);
640
+	}
641
+
642
+
643
+	/**
644
+	 * @param $slug
645
+	 * @throws EE_Error
646
+	 */
647
+	public function set_slug($slug)
648
+	{
649
+		$this->set('EVT_slug', $slug);
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param $timezone_string
655
+	 * @throws EE_Error
656
+	 */
657
+	public function set_timezone_string($timezone_string)
658
+	{
659
+		$this->set('EVT_timezone_string', $timezone_string);
660
+	}
661
+
662
+
663
+	/**
664
+	 * @param $visible_on
665
+	 * @throws EE_Error
666
+	 */
667
+	public function set_visible_on($visible_on)
668
+	{
669
+		$this->set('EVT_visible_on', $visible_on);
670
+	}
671
+
672
+
673
+	/**
674
+	 * @param $wp_user
675
+	 * @throws EE_Error
676
+	 */
677
+	public function set_wp_user($wp_user)
678
+	{
679
+		$this->set('EVT_wp_user', $wp_user);
680
+	}
681
+
682
+
683
+	/**
684
+	 * @param $default_registration_status
685
+	 * @throws EE_Error
686
+	 */
687
+	public function set_default_registration_status($default_registration_status)
688
+	{
689
+		$this->set('EVT_default_registration_status', $default_registration_status);
690
+	}
691
+
692
+
693
+	/**
694
+	 * @param $donations
695
+	 * @throws EE_Error
696
+	 */
697
+	public function set_donations($donations)
698
+	{
699
+		$this->set('EVT_donations', $donations);
700
+	}
701
+
702
+
703
+	/**
704
+	 * Adds a venue to this event
705
+	 *
706
+	 * @param int|EE_Venue /int $venue_id_or_obj
707
+	 * @return EE_Base_Class|EE_Venue
708
+	 * @throws EE_Error
709
+	 * @throws ReflectionException
710
+	 */
711
+	public function add_venue($venue_id_or_obj): EE_Venue
712
+	{
713
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
714
+	}
715
+
716
+
717
+	/**
718
+	 * Removes a venue from the event
719
+	 *
720
+	 * @param EE_Venue /int $venue_id_or_obj
721
+	 * @return EE_Base_Class|EE_Venue
722
+	 * @throws EE_Error
723
+	 * @throws ReflectionException
724
+	 */
725
+	public function remove_venue($venue_id_or_obj): EE_Venue
726
+	{
727
+		$venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue();
728
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
729
+	}
730
+
731
+
732
+	/**
733
+	 * Gets the venue related to the event. May provide additional $query_params if desired
734
+	 *
735
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
736
+	 * @return int
737
+	 * @throws EE_Error
738
+	 * @throws ReflectionException
739
+	 */
740
+	public function venue_ID(array $query_params = array()): int
741
+	{
742
+		$venue = $this->get_first_related('Venue', $query_params);
743
+		return $venue instanceof EE_Venue ? $venue->ID() : 0;
744
+	}
745
+
746
+
747
+	/**
748
+	 * Gets the venue related to the event. May provide additional $query_params if desired
749
+	 *
750
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
751
+	 * @return EE_Base_Class|EE_Venue
752
+	 * @throws EE_Error
753
+	 * @throws ReflectionException
754
+	 */
755
+	public function venue(array $query_params = array())
756
+	{
757
+		return $this->get_first_related('Venue', $query_params);
758
+	}
759
+
760
+
761
+	/**
762
+	 * @param array $query_params
763
+	 * @return EE_Base_Class[]|EE_Venue[]
764
+	 * @throws EE_Error
765
+	 * @throws ReflectionException
766
+	 * @deprecated $VID:$
767
+	 */
768
+	public function venues(array $query_params = array()): array
769
+	{
770
+		return [$this->venue($query_params)];
771
+	}
772
+
773
+
774
+	/**
775
+	 * check if event id is present and if event is published
776
+	 *
777
+	 * @access public
778
+	 * @return boolean true yes, false no
779
+	 * @throws EE_Error
780
+	 * @throws ReflectionException
781
+	 */
782
+	private function _has_ID_and_is_published()
783
+	{
784
+		// first check if event id is present and not NULL,
785
+		// then check if this event is published (or any of the equivalent "published" statuses)
786
+		return
787
+			$this->ID() && $this->ID() !== null
788
+			&& (
789
+				$this->status() === 'publish'
790
+				|| $this->status() === EEM_Event::sold_out
791
+				|| $this->status() === EEM_Event::postponed
792
+				|| $this->status() === EEM_Event::cancelled
793
+			);
794
+	}
795
+
796
+
797
+	/**
798
+	 * This simply compares the internal dates with NOW and determines if the event is upcoming or not.
799
+	 *
800
+	 * @access public
801
+	 * @return boolean true yes, false no
802
+	 * @throws EE_Error
803
+	 * @throws ReflectionException
804
+	 */
805
+	public function is_upcoming()
806
+	{
807
+		// check if event id is present and if this event is published
808
+		if ($this->is_inactive()) {
809
+			return false;
810
+		}
811
+		// set initial value
812
+		$upcoming = false;
813
+		// next let's get all datetimes and loop through them
814
+		$datetimes = $this->datetimes_in_chronological_order();
815
+		foreach ($datetimes as $datetime) {
816
+			if ($datetime instanceof EE_Datetime) {
817
+				// if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
818
+				if ($datetime->is_expired()) {
819
+					continue;
820
+				}
821
+				// if this dtt is active then we return false.
822
+				if ($datetime->is_active()) {
823
+					return false;
824
+				}
825
+				// otherwise let's check upcoming status
826
+				$upcoming = $datetime->is_upcoming();
827
+			}
828
+		}
829
+		return $upcoming;
830
+	}
831
+
832
+
833
+	/**
834
+	 * @return bool
835
+	 * @throws EE_Error
836
+	 * @throws ReflectionException
837
+	 */
838
+	public function is_active()
839
+	{
840
+		// check if event id is present and if this event is published
841
+		if ($this->is_inactive()) {
842
+			return false;
843
+		}
844
+		// set initial value
845
+		$active = false;
846
+		// next let's get all datetimes and loop through them
847
+		$datetimes = $this->datetimes_in_chronological_order();
848
+		foreach ($datetimes as $datetime) {
849
+			if ($datetime instanceof EE_Datetime) {
850
+				// if this dtt is expired then we continue cause one of the other datetimes might be active.
851
+				if ($datetime->is_expired()) {
852
+					continue;
853
+				}
854
+				// if this dtt is upcoming then we return false.
855
+				if ($datetime->is_upcoming()) {
856
+					return false;
857
+				}
858
+				// otherwise let's check active status
859
+				$active = $datetime->is_active();
860
+			}
861
+		}
862
+		return $active;
863
+	}
864
+
865
+
866
+	/**
867
+	 * @return bool
868
+	 * @throws EE_Error
869
+	 * @throws ReflectionException
870
+	 */
871
+	public function is_expired()
872
+	{
873
+		// check if event id is present and if this event is published
874
+		if ($this->is_inactive()) {
875
+			return false;
876
+		}
877
+		// set initial value
878
+		$expired = false;
879
+		// first let's get all datetimes and loop through them
880
+		$datetimes = $this->datetimes_in_chronological_order();
881
+		foreach ($datetimes as $datetime) {
882
+			if ($datetime instanceof EE_Datetime) {
883
+				// if this dtt is upcoming or active then we return false.
884
+				if ($datetime->is_upcoming() || $datetime->is_active()) {
885
+					return false;
886
+				}
887
+				// otherwise let's check active status
888
+				$expired = $datetime->is_expired();
889
+			}
890
+		}
891
+		return $expired;
892
+	}
893
+
894
+
895
+	/**
896
+	 * @return bool
897
+	 * @throws EE_Error
898
+	 */
899
+	public function is_inactive()
900
+	{
901
+		// check if event id is present and if this event is published
902
+		if ($this->_has_ID_and_is_published()) {
903
+			return false;
904
+		}
905
+		return true;
906
+	}
907
+
908
+
909
+	/**
910
+	 * calculate spaces remaining based on "saleable" tickets
911
+	 *
912
+	 * @param array $tickets
913
+	 * @param bool  $filtered
914
+	 * @return int|float
915
+	 * @throws EE_Error
916
+	 * @throws DomainException
917
+	 * @throws UnexpectedEntityException
918
+	 */
919
+	public function spaces_remaining($tickets = array(), $filtered = true)
920
+	{
921
+		$this->getAvailableSpacesCalculator()->setActiveTickets($tickets);
922
+		$spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining();
923
+		return $filtered
924
+			? apply_filters(
925
+				'FHEE_EE_Event__spaces_remaining',
926
+				$spaces_remaining,
927
+				$this,
928
+				$tickets
929
+			)
930
+			: $spaces_remaining;
931
+	}
932
+
933
+
934
+	/**
935
+	 *    perform_sold_out_status_check
936
+	 *    checks all of this events's datetime  reg_limit - sold values to determine if ANY datetimes have spaces
937
+	 *    available... if NOT, then the event status will get toggled to 'sold_out'
938
+	 *
939
+	 * @return bool    return the ACTUAL sold out state.
940
+	 * @throws EE_Error
941
+	 * @throws DomainException
942
+	 * @throws UnexpectedEntityException
943
+	 * @throws ReflectionException
944
+	 */
945
+	public function perform_sold_out_status_check()
946
+	{
947
+		// get all tickets
948
+		$tickets = $this->tickets(
949
+			array(
950
+				'default_where_conditions' => 'none',
951
+				'order_by' => array('TKT_qty' => 'ASC'),
952
+			)
953
+		);
954
+		$all_expired = true;
955
+		foreach ($tickets as $ticket) {
956
+			if (! $ticket->is_expired()) {
957
+				$all_expired = false;
958
+				break;
959
+			}
960
+		}
961
+		// if all the tickets are just expired, then don't update the event status to sold out
962
+		if ($all_expired) {
963
+			return true;
964
+		}
965
+		$spaces_remaining = $this->spaces_remaining($tickets);
966
+		if ($spaces_remaining < 1) {
967
+			if ($this->status() !== EEM_Event::post_status_private) {
968
+				$this->set_status(EEM_Event::sold_out);
969
+				$this->save();
970
+			}
971
+			$sold_out = true;
972
+		} else {
973
+			$sold_out = false;
974
+			// was event previously marked as sold out ?
975
+			if ($this->status() === EEM_Event::sold_out) {
976
+				// revert status to previous value, if it was set
977
+				$previous_event_status = $this->get_post_meta('_previous_event_status', true);
978
+				if ($previous_event_status) {
979
+					$this->set_status($previous_event_status);
980
+					$this->save();
981
+				}
982
+			}
983
+		}
984
+		do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets);
985
+		return $sold_out;
986
+	}
987
+
988
+
989
+	/**
990
+	 * This returns the total remaining spaces for sale on this event.
991
+	 *
992
+	 * @uses EE_Event::total_available_spaces()
993
+	 * @return float|int
994
+	 * @throws EE_Error
995
+	 * @throws DomainException
996
+	 * @throws UnexpectedEntityException
997
+	 */
998
+	public function spaces_remaining_for_sale()
999
+	{
1000
+		return $this->total_available_spaces(true);
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * This returns the total spaces available for an event
1006
+	 * while considering all the qtys on the tickets and the reg limits
1007
+	 * on the datetimes attached to this event.
1008
+	 *
1009
+	 * @param   bool $consider_sold Whether to consider any tickets that have already sold in our calculation.
1010
+	 *                              If this is false, then we return the most tickets that could ever be sold
1011
+	 *                              for this event with the datetime and tickets setup on the event under optimal
1012
+	 *                              selling conditions.  Otherwise we return a live calculation of spaces available
1013
+	 *                              based on tickets sold.  Depending on setup and stage of sales, this
1014
+	 *                              may appear to equal remaining tickets.  However, the more tickets are
1015
+	 *                              sold out, the more accurate the "live" total is.
1016
+	 * @return float|int
1017
+	 * @throws EE_Error
1018
+	 * @throws DomainException
1019
+	 * @throws UnexpectedEntityException
1020
+	 */
1021
+	public function total_available_spaces($consider_sold = false)
1022
+	{
1023
+		$spaces_available = $consider_sold
1024
+			? $this->getAvailableSpacesCalculator()->spacesRemaining()
1025
+			: $this->getAvailableSpacesCalculator()->totalSpacesAvailable();
1026
+		return apply_filters(
1027
+			'FHEE_EE_Event__total_available_spaces__spaces_available',
1028
+			$spaces_available,
1029
+			$this,
1030
+			$this->getAvailableSpacesCalculator()->getDatetimes(),
1031
+			$this->getAvailableSpacesCalculator()->getActiveTickets()
1032
+		);
1033
+	}
1034
+
1035
+
1036
+	/**
1037
+	 * Checks if the event is set to sold out
1038
+	 *
1039
+	 * @param  bool $actual whether or not to perform calculations to not only figure the
1040
+	 *                      actual status but also to flip the status if necessary to sold
1041
+	 *                      out If false, we just check the existing status of the event
1042
+	 * @return boolean
1043
+	 * @throws EE_Error
1044
+	 */
1045
+	public function is_sold_out($actual = false)
1046
+	{
1047
+		if (! $actual) {
1048
+			return $this->status() === EEM_Event::sold_out;
1049
+		}
1050
+		return $this->perform_sold_out_status_check();
1051
+	}
1052
+
1053
+
1054
+	/**
1055
+	 * Checks if the event is marked as postponed
1056
+	 *
1057
+	 * @return boolean
1058
+	 */
1059
+	public function is_postponed()
1060
+	{
1061
+		return $this->status() === EEM_Event::postponed;
1062
+	}
1063
+
1064
+
1065
+	/**
1066
+	 * Checks if the event is marked as cancelled
1067
+	 *
1068
+	 * @return boolean
1069
+	 */
1070
+	public function is_cancelled()
1071
+	{
1072
+		return $this->status() === EEM_Event::cancelled;
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * Get the logical active status in a hierarchical order for all the datetimes.  Note
1078
+	 * Basically, we order the datetimes by EVT_start_date.  Then first test on whether the event is published.  If its
1079
+	 * NOT published then we test for whether its expired or not.  IF it IS published then we test first on whether an
1080
+	 * event has any active dates.  If no active dates then we check for any upcoming dates.  If no upcoming dates then
1081
+	 * the event is considered expired.
1082
+	 * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published.  Sold Out is a
1083
+	 * status set on the EVENT when it is not published and thus is done
1084
+	 *
1085
+	 * @param bool $reset
1086
+	 * @return bool | string - based on EE_Datetime active constants or FALSE if error.
1087
+	 * @throws EE_Error
1088
+	 * @throws ReflectionException
1089
+	 */
1090
+	public function get_active_status($reset = false)
1091
+	{
1092
+		// if the active status has already been set, then just use that value (unless we are resetting it)
1093
+		if (! empty($this->_active_status) && ! $reset) {
1094
+			return $this->_active_status;
1095
+		}
1096
+		// first check if event id is present on this object
1097
+		if (! $this->ID()) {
1098
+			return false;
1099
+		}
1100
+		$where_params_for_event = array(array('EVT_ID' => $this->ID()));
1101
+		// if event is published:
1102
+		if ($this->status() === EEM_Event::post_status_publish || $this->status() === EEM_Event::post_status_private) {
1103
+			// active?
1104
+			if (
1105
+				EEM_Datetime::instance()->get_datetime_count_for_status(
1106
+					EE_Datetime::active,
1107
+					$where_params_for_event
1108
+				) > 0
1109
+			) {
1110
+				$this->_active_status = EE_Datetime::active;
1111
+			} else {
1112
+				// upcoming?
1113
+				if (
1114
+					EEM_Datetime::instance()->get_datetime_count_for_status(
1115
+						EE_Datetime::upcoming,
1116
+						$where_params_for_event
1117
+					) > 0
1118
+				) {
1119
+					$this->_active_status = EE_Datetime::upcoming;
1120
+				} else {
1121
+					// expired?
1122
+					if (
1123
+						EEM_Datetime::instance()->get_datetime_count_for_status(
1124
+							EE_Datetime::expired,
1125
+							$where_params_for_event
1126
+						) > 0
1127
+					) {
1128
+						$this->_active_status = EE_Datetime::expired;
1129
+					} else {
1130
+						// it would be odd if things make it this far because it basically means there are no datetime's
1131
+						// attached to the event.  So in this case it will just be considered inactive.
1132
+						$this->_active_status = EE_Datetime::inactive;
1133
+					}
1134
+				}
1135
+			}
1136
+		} else {
1137
+			// the event is not published, so let's just set it's active status according to its' post status
1138
+			switch ($this->status()) {
1139
+				case EEM_Event::sold_out:
1140
+					$this->_active_status = EE_Datetime::sold_out;
1141
+					break;
1142
+				case EEM_Event::cancelled:
1143
+					$this->_active_status = EE_Datetime::cancelled;
1144
+					break;
1145
+				case EEM_Event::postponed:
1146
+					$this->_active_status = EE_Datetime::postponed;
1147
+					break;
1148
+				default:
1149
+					$this->_active_status = EE_Datetime::inactive;
1150
+			}
1151
+		}
1152
+		return $this->_active_status;
1153
+	}
1154
+
1155
+
1156
+	/**
1157
+	 *    pretty_active_status
1158
+	 *
1159
+	 * @access public
1160
+	 * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE)
1161
+	 * @return mixed void|string
1162
+	 * @throws EE_Error
1163
+	 * @throws ReflectionException
1164
+	 */
1165
+	public function pretty_active_status($echo = true)
1166
+	{
1167
+		$active_status = $this->get_active_status();
1168
+		$status = '<span class="ee-status event-active-status--' . esc_attr($active_status) . '">'
1169
+				  . EEH_Template::pretty_status($active_status, false, 'sentence')
1170
+				  . '</span>';
1171
+		if ($echo) {
1172
+			echo $status; // already escaped
1173
+			return '';
1174
+		}
1175
+		return $status; // already escaped
1176
+	}
1177
+
1178
+
1179
+	/**
1180
+	 * @return bool|int
1181
+	 * @throws EE_Error
1182
+	 * @throws ReflectionException
1183
+	 */
1184
+	public function get_number_of_tickets_sold()
1185
+	{
1186
+		$tkt_sold = 0;
1187
+		if (! $this->ID()) {
1188
+			return 0;
1189
+		}
1190
+		$datetimes = $this->datetimes();
1191
+		foreach ($datetimes as $datetime) {
1192
+			if ($datetime instanceof EE_Datetime) {
1193
+				$tkt_sold += $datetime->sold();
1194
+			}
1195
+		}
1196
+		return $tkt_sold;
1197
+	}
1198
+
1199
+
1200
+	/**
1201
+	 * This just returns a count of all the registrations for this event
1202
+	 *
1203
+	 * @access  public
1204
+	 * @return int
1205
+	 * @throws EE_Error
1206
+	 */
1207
+	public function get_count_of_all_registrations()
1208
+	{
1209
+		return EEM_Event::instance()->count_related($this, 'Registration');
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 * This returns the ticket with the earliest start time that is
1215
+	 * available for this event (across all datetimes attached to the event)
1216
+	 *
1217
+	 * @return EE_Base_Class|EE_Ticket|null
1218
+	 * @throws EE_Error
1219
+	 * @throws ReflectionException
1220
+	 */
1221
+	public function get_ticket_with_earliest_start_time()
1222
+	{
1223
+		$where['Datetime.EVT_ID'] = $this->ID();
1224
+		$query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1225
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * This returns the ticket with the latest end time that is available
1231
+	 * for this event (across all datetimes attached to the event)
1232
+	 *
1233
+	 * @return EE_Base_Class|EE_Ticket|null
1234
+	 * @throws EE_Error
1235
+	 * @throws ReflectionException
1236
+	 */
1237
+	public function get_ticket_with_latest_end_time()
1238
+	{
1239
+		$where['Datetime.EVT_ID'] = $this->ID();
1240
+		$query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1241
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * This returns the number of different ticket types currently on sale for this event.
1247
+	 *
1248
+	 * @return int
1249
+	 * @throws EE_Error
1250
+	 * @throws ReflectionException
1251
+	 */
1252
+	public function countTicketsOnSale()
1253
+	{
1254
+		$where = array(
1255
+			'Datetime.EVT_ID' => $this->ID(),
1256
+			'TKT_start_date'  => array('<', time()),
1257
+			'TKT_end_date'    => array('>', time()),
1258
+		);
1259
+		return EEM_Ticket::instance()->count(array($where));
1260
+	}
1261
+
1262
+
1263
+	/**
1264
+	 * This returns whether there are any tickets on sale for this event.
1265
+	 *
1266
+	 * @return bool true = YES tickets on sale.
1267
+	 * @throws EE_Error
1268
+	 */
1269
+	public function tickets_on_sale()
1270
+	{
1271
+		return $this->countTicketsOnSale() > 0;
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * Gets the URL for viewing this event on the front-end. Overrides parent
1277
+	 * to check for an external URL first
1278
+	 *
1279
+	 * @return string
1280
+	 * @throws EE_Error
1281
+	 */
1282
+	public function get_permalink()
1283
+	{
1284
+		if ($this->external_url()) {
1285
+			return $this->external_url();
1286
+		}
1287
+		return parent::get_permalink();
1288
+	}
1289
+
1290
+
1291
+	/**
1292
+	 * Gets the first term for 'espresso_event_categories' we can find
1293
+	 *
1294
+	 * @param array $query_params @see
1295
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1296
+	 * @return EE_Base_Class|EE_Term|null
1297
+	 * @throws EE_Error
1298
+	 * @throws ReflectionException
1299
+	 */
1300
+	public function first_event_category($query_params = array())
1301
+	{
1302
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1303
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1304
+		return EEM_Term::instance()->get_one($query_params);
1305
+	}
1306
+
1307
+
1308
+	/**
1309
+	 * Gets all terms for 'espresso_event_categories' we can find
1310
+	 *
1311
+	 * @param array $query_params
1312
+	 * @return EE_Base_Class[]|EE_Term[]
1313
+	 * @throws EE_Error
1314
+	 * @throws ReflectionException
1315
+	 */
1316
+	public function get_all_event_categories($query_params = array())
1317
+	{
1318
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1319
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1320
+		return EEM_Term::instance()->get_all($query_params);
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * Adds a question group to this event
1326
+	 *
1327
+	 * @param EE_Question_Group|int $question_group_id_or_obj
1328
+	 * @param bool $for_primary if true, the question group will be added for the primary
1329
+	 *                                           registrant, if false will be added for others. default: false
1330
+	 * @return EE_Base_Class|EE_Question_Group
1331
+	 * @throws EE_Error
1332
+	 * @throws InvalidArgumentException
1333
+	 * @throws InvalidDataTypeException
1334
+	 * @throws InvalidInterfaceException
1335
+	 * @throws ReflectionException
1336
+	 */
1337
+	public function add_question_group($question_group_id_or_obj, $for_primary = false)
1338
+	{
1339
+		// If the row already exists, it will be updated. If it doesn't, it will be inserted.
1340
+		// That's in EE_HABTM_Relation::add_relation_to().
1341
+		return $this->_add_relation_to(
1342
+			$question_group_id_or_obj,
1343
+			'Question_Group',
1344
+			[
1345
+				EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary) => true
1346
+			]
1347
+		);
1348
+	}
1349
+
1350
+
1351
+	/**
1352
+	 * Removes a question group from the event
1353
+	 *
1354
+	 * @param EE_Question_Group|int $question_group_id_or_obj
1355
+	 * @param bool $for_primary if true, the question group will be removed from the primary
1356
+	 *                                           registrant, if false will be removed from others. default: false
1357
+	 * @return EE_Base_Class|EE_Question_Group
1358
+	 * @throws EE_Error
1359
+	 * @throws InvalidArgumentException
1360
+	 * @throws ReflectionException
1361
+	 * @throws InvalidDataTypeException
1362
+	 * @throws InvalidInterfaceException
1363
+	 */
1364
+	public function remove_question_group($question_group_id_or_obj, $for_primary = false)
1365
+	{
1366
+		// If the question group is used for the other type (primary or additional)
1367
+		// then just update it. If not, delete it outright.
1368
+		$existing_relation = $this->get_first_related(
1369
+			'Event_Question_Group',
1370
+			[
1371
+				[
1372
+					'QSG_ID' => EEM_Question_Group::instance()->ensure_is_ID($question_group_id_or_obj)
1373
+				]
1374
+			]
1375
+		);
1376
+		$field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary);
1377
+		$other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary);
1378
+		if ($existing_relation->get($other_field) === false) {
1379
+			// Delete it. It's now no longer for primary or additional question groups.
1380
+			return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group');
1381
+		}
1382
+		// Just update it. They'll still use this question group for the other category
1383
+		$existing_relation->save(
1384
+			[
1385
+				$field_to_update => false
1386
+			]
1387
+		);
1388
+	}
1389
+
1390
+
1391
+	/**
1392
+	 * Gets all the question groups, ordering them by QSG_order ascending
1393
+	 *
1394
+	 * @param array $query_params @see
1395
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1396
+	 * @return EE_Base_Class[]|EE_Question_Group[]
1397
+	 * @throws EE_Error
1398
+	 * @throws ReflectionException
1399
+	 */
1400
+	public function question_groups($query_params = array())
1401
+	{
1402
+		$query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1403
+		return $this->get_many_related('Question_Group', $query_params);
1404
+	}
1405
+
1406
+
1407
+	/**
1408
+	 * Implementation for EEI_Has_Icon interface method.
1409
+	 *
1410
+	 * @see EEI_Visual_Representation for comments
1411
+	 * @return string
1412
+	 */
1413
+	public function get_icon()
1414
+	{
1415
+		return '<span class="dashicons dashicons-flag"></span>';
1416
+	}
1417
+
1418
+
1419
+	/**
1420
+	 * Implementation for EEI_Admin_Links interface method.
1421
+	 *
1422
+	 * @see EEI_Admin_Links for comments
1423
+	 * @return string
1424
+	 * @throws EE_Error
1425
+	 */
1426
+	public function get_admin_details_link()
1427
+	{
1428
+		return $this->get_admin_edit_link();
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * Implementation for EEI_Admin_Links interface method.
1434
+	 *
1435
+	 * @return string
1436
+	 * @throws EE_Error*@throws ReflectionException
1437
+	 * @see EEI_Admin_Links for comments
1438
+	 */
1439
+	public function get_admin_edit_link()
1440
+	{
1441
+		return EEH_URL::add_query_args_and_nonce(
1442
+			array(
1443
+				'page'   => 'espresso_events',
1444
+				'action' => 'edit',
1445
+				'post'   => $this->ID(),
1446
+			),
1447
+			admin_url('admin.php')
1448
+		);
1449
+	}
1450
+
1451
+
1452
+	/**
1453
+	 * Implementation for EEI_Admin_Links interface method.
1454
+	 *
1455
+	 * @see EEI_Admin_Links for comments
1456
+	 * @return string
1457
+	 */
1458
+	public function get_admin_settings_link()
1459
+	{
1460
+		return EEH_URL::add_query_args_and_nonce(
1461
+			array(
1462
+				'page'   => 'espresso_events',
1463
+				'action' => 'default_event_settings',
1464
+			),
1465
+			admin_url('admin.php')
1466
+		);
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * Implementation for EEI_Admin_Links interface method.
1472
+	 *
1473
+	 * @see EEI_Admin_Links for comments
1474
+	 * @return string
1475
+	 */
1476
+	public function get_admin_overview_link()
1477
+	{
1478
+		return EEH_URL::add_query_args_and_nonce(
1479
+			array(
1480
+				'page'   => 'espresso_events',
1481
+				'action' => 'default',
1482
+			),
1483
+			admin_url('admin.php')
1484
+		);
1485
+	}
1486
+
1487
+
1488
+	/**
1489
+	 * @return string|null
1490
+	 * @throws EE_Error
1491
+	 * @throws ReflectionException
1492
+	 */
1493
+	public function registrationFormUuid(): ?string
1494
+	{
1495
+		return $this->get('FSC_UUID');
1496
+	}
1497
+
1498
+
1499
+	/**
1500
+	 * Gets all the form sections for this event
1501
+	 *
1502
+	 * @return EE_Base_Class[]|EE_Form_Section[]
1503
+	 * @throws EE_Error
1504
+	 * @throws ReflectionException
1505
+	 */
1506
+	public function registrationForm()
1507
+	{
1508
+		$FSC_UUID = $this->registrationFormUuid();
1509
+
1510
+		if (empty($FSC_UUID)) {
1511
+			return [];
1512
+		}
1513
+
1514
+		return EEM_Form_Section::instance()->get_all([
1515
+			[
1516
+				'OR' => [
1517
+					'FSC_UUID'      => $FSC_UUID, // top level form
1518
+					'FSC_belongsTo' => $FSC_UUID, // child form sections
1519
+				]
1520
+				],
1521
+			'order_by' => ['FSC_order' => 'ASC'],
1522
+		]);
1523
+	}
1524
+
1525
+
1526
+	/**
1527
+	 * @param string $UUID
1528
+	 * @throws EE_Error
1529
+	 */
1530
+	public function setRegistrationFormUuid(string $UUID): void
1531
+	{
1532
+		if (! Cuid::isCuid($UUID)) {
1533
+			throw new InvalidArgumentException(
1534
+				sprintf(
1535
+				/* translators: 1: UUID value, 2: UUID generator function. */
1536
+					esc_html__(
1537
+						'The supplied UUID "%1$s" is invalid or missing. Please use %2$s to generate a valid one.',
1538
+						'event_espresso'
1539
+					),
1540
+					$UUID,
1541
+					'`Cuid::cuid()`'
1542
+				)
1543
+			);
1544
+		}
1545
+		$this->set('FSC_UUID', $UUID);
1546
+	}
1547 1547
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getAvailableSpacesCalculator()
76 76
     {
77
-        if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
77
+        if ( ! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
78 78
             $this->available_spaces_calculator = new EventSpacesCalculator($this);
79 79
         }
80 80
         return $this->available_spaces_calculator;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
226 226
     {
227
-        if (! empty($this->_Primary_Datetime)) {
227
+        if ( ! empty($this->_Primary_Datetime)) {
228 228
             return $this->_Primary_Datetime;
229 229
         }
230 230
         $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     {
250 250
         // first get all datetimes
251 251
         $datetimes = $this->datetimes_ordered();
252
-        if (! $datetimes) {
252
+        if ( ! $datetimes) {
253 253
             return array();
254 254
         }
255 255
         $datetime_ids = array();
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
     public function short_description($num_words = 55, $more = null, $not_full_desc = false)
458 458
     {
459 459
         $short_desc = $this->get('EVT_short_desc');
460
-        if (! empty($short_desc) || $not_full_desc) {
460
+        if ( ! empty($short_desc) || $not_full_desc) {
461 461
             return $short_desc;
462 462
         }
463 463
         $full_desc = $this->get('EVT_desc');
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
         );
954 954
         $all_expired = true;
955 955
         foreach ($tickets as $ticket) {
956
-            if (! $ticket->is_expired()) {
956
+            if ( ! $ticket->is_expired()) {
957 957
                 $all_expired = false;
958 958
                 break;
959 959
             }
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      */
1045 1045
     public function is_sold_out($actual = false)
1046 1046
     {
1047
-        if (! $actual) {
1047
+        if ( ! $actual) {
1048 1048
             return $this->status() === EEM_Event::sold_out;
1049 1049
         }
1050 1050
         return $this->perform_sold_out_status_check();
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
     public function get_active_status($reset = false)
1091 1091
     {
1092 1092
         // if the active status has already been set, then just use that value (unless we are resetting it)
1093
-        if (! empty($this->_active_status) && ! $reset) {
1093
+        if ( ! empty($this->_active_status) && ! $reset) {
1094 1094
             return $this->_active_status;
1095 1095
         }
1096 1096
         // first check if event id is present on this object
1097
-        if (! $this->ID()) {
1097
+        if ( ! $this->ID()) {
1098 1098
             return false;
1099 1099
         }
1100 1100
         $where_params_for_event = array(array('EVT_ID' => $this->ID()));
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
     public function pretty_active_status($echo = true)
1166 1166
     {
1167 1167
         $active_status = $this->get_active_status();
1168
-        $status = '<span class="ee-status event-active-status--' . esc_attr($active_status) . '">'
1168
+        $status = '<span class="ee-status event-active-status--'.esc_attr($active_status).'">'
1169 1169
                   . EEH_Template::pretty_status($active_status, false, 'sentence')
1170 1170
                   . '</span>';
1171 1171
         if ($echo) {
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
     public function get_number_of_tickets_sold()
1185 1185
     {
1186 1186
         $tkt_sold = 0;
1187
-        if (! $this->ID()) {
1187
+        if ( ! $this->ID()) {
1188 1188
             return 0;
1189 1189
         }
1190 1190
         $datetimes = $this->datetimes();
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
             ]
1375 1375
         );
1376 1376
         $field_to_update = EEM_Event_Question_Group::instance()->fieldNameForContext($for_primary);
1377
-        $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext(! $for_primary);
1377
+        $other_field = EEM_Event_Question_Group::instance()->fieldNameForContext( ! $for_primary);
1378 1378
         if ($existing_relation->get($other_field) === false) {
1379 1379
             // Delete it. It's now no longer for primary or additional question groups.
1380 1380
             return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group');
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
      */
1530 1530
     public function setRegistrationFormUuid(string $UUID): void
1531 1531
     {
1532
-        if (! Cuid::isCuid($UUID)) {
1532
+        if ( ! Cuid::isCuid($UUID)) {
1533 1533
             throw new InvalidArgumentException(
1534 1534
                 sprintf(
1535 1535
                 /* translators: 1: UUID value, 2: UUID generator function. */
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +994 added lines, -994 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8 8
 if (! function_exists('espresso_get_template_part')) {
9
-    /**
10
-     * espresso_get_template_part
11
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
-     *
14
-     * @param string $slug The slug name for the generic template.
15
-     * @param string $name The name of the specialised template.
16
-     */
17
-    function espresso_get_template_part($slug = null, $name = null)
18
-    {
19
-        EEH_Template::get_template_part($slug, $name);
20
-    }
9
+	/**
10
+	 * espresso_get_template_part
11
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
+	 *
14
+	 * @param string $slug The slug name for the generic template.
15
+	 * @param string $name The name of the specialised template.
16
+	 */
17
+	function espresso_get_template_part($slug = null, $name = null)
18
+	{
19
+		EEH_Template::get_template_part($slug, $name);
20
+	}
21 21
 }
22 22
 
23 23
 
24 24
 if (! function_exists('espresso_get_object_css_class')) {
25
-    /**
26
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
-     *
28
-     * @param EE_Base_Class $object the EE object the css class is being generated for
29
-     * @param string        $prefix added to the beginning of the generated class
30
-     * @param string        $suffix added to the end of the generated class
31
-     * @return string
32
-     * @throws EE_Error
33
-     * @throws ReflectionException
34
-     */
35
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
-    {
37
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
-    }
25
+	/**
26
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
+	 *
28
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
29
+	 * @param string        $prefix added to the beginning of the generated class
30
+	 * @param string        $suffix added to the end of the generated class
31
+	 * @return string
32
+	 * @throws EE_Error
33
+	 * @throws ReflectionException
34
+	 */
35
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
+	{
37
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -50,708 +50,708 @@  discard block
 block discarded – undo
50 50
 class EEH_Template
51 51
 {
52 52
 
53
-    private static $_espresso_themes = [];
54
-
55
-
56
-    /**
57
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
-     *
59
-     * @return boolean
60
-     */
61
-    public static function is_espresso_theme()
62
-    {
63
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
-    }
65
-
66
-
67
-    /**
68
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
-     *    load its functions.php file ( if not already loaded )
70
-     *
71
-     * @return void
72
-     */
73
-    public static function load_espresso_theme_functions()
74
-    {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
-            }
79
-        }
80
-    }
81
-
82
-
83
-    /**
84
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
-     *
86
-     * @return array
87
-     */
88
-    public static function get_espresso_themes()
89
-    {
90
-        if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
-            if (empty($espresso_themes)) {
93
-                return [];
94
-            }
95
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
97
-            }
98
-            EEH_Template::$_espresso_themes = [];
99
-            foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
-            }
102
-        }
103
-        return EEH_Template::$_espresso_themes;
104
-    }
105
-
106
-
107
-    /**
108
-     * EEH_Template::get_template_part
109
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
-     * filtering based off of the entire template part name
112
-     *
113
-     * @param string $slug The slug name for the generic template.
114
-     * @param string $name The name of the specialised template.
115
-     * @param array  $template_args
116
-     * @param bool   $return_string
117
-     * @return string        the html output for the formatted money value
118
-     */
119
-    public static function get_template_part(
120
-        $slug = null,
121
-        $name = null,
122
-        $template_args = [],
123
-        $return_string = false
124
-    ) {
125
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
-        $templates = [];
127
-        $name      = (string) $name;
128
-        if ($name != '') {
129
-            $templates[] = "{$slug}-{$name}.php";
130
-        }
131
-        // allow template parts to be turned off via something like:
132
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
-        }
136
-        return '';
137
-    }
138
-
139
-
140
-    /**
141
-     *    locate_template
142
-     *    locate a template file by looking in the following places, in the following order:
143
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
-     *        <assumed full absolute server path>
145
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/
147
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
151
-     *        Example:
152
-     *          You are using the WordPress Twenty Sixteen theme,
153
-     *        and you want to customize the "some-event.template.php" template,
154
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
-     *        /relative/path/to/some-event.template.php
159
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
-     *          Had you passed an absolute path to your template that was in some other location,
165
-     *        ie: "/absolute/path/to/some-event.template.php"
166
-     *          then the search would have been :
167
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
-     *        /absolute/path/to/some-event.template.php
169
-     *          and stopped there upon finding it in the second location
170
-     *
171
-     * @param array|string $templates       array of template file names including extension (or just a single string)
172
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
173
-     * @param boolean      $load            whether to pass the located template path on to the
174
-     *                                      EEH_Template::display_template() method or simply return it
175
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
-     *                                      string
177
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
-     *                                      generate a custom template or not. Used in places where you don't actually
179
-     *                                      load the template, you just want to know if there's a custom version of it.
180
-     * @return mixed
181
-     * @throws DomainException
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public static function locate_template(
187
-        $templates = [],
188
-        $template_args = [],
189
-        $load = true,
190
-        $return_string = true,
191
-        $check_if_custom = false
192
-    ) {
193
-        // first use WP locate_template to check for template in the current theme folder
194
-        $template_path = locate_template($templates);
195
-
196
-        if ($check_if_custom && ! empty($template_path)) {
197
-            return true;
198
-        }
199
-
200
-        // not in the theme
201
-        if (empty($template_path)) {
202
-            // not even a template to look for ?
203
-            if (empty($templates)) {
204
-                $loader = LoaderFactory::getLoader();
205
-                /** @var RequestInterface $request */
206
-                $request = $loader->getShared(RequestInterface::class);
207
-                // get post_type
208
-                $post_type = $request->getRequestParam('post_type');
209
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
-                $custom_post_types = $loader->getShared(
211
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
-                );
213
-                // get array of EE Custom Post Types
214
-                $EE_CPTs = $custom_post_types->getDefinitions();
215
-                // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
217
-                    $archive_or_single = is_archive() ? 'archive' : '';
218
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
-                }
221
-            }
222
-            // currently active EE template theme
223
-            $current_theme = EE_Config::get_current_theme();
224
-
225
-            // array of paths to folders that may contain templates
226
-            $template_folder_paths = [
227
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
230
-                EVENT_ESPRESSO_TEMPLATE_DIR,
231
-            ];
232
-
233
-            // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
236
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
238
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
240
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
-                    EE_PLUGIN_DIR_PATH,
242
-                ];
243
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
-            }
245
-
246
-            // now filter that array
247
-            $template_folder_paths = apply_filters(
248
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
249
-                $template_folder_paths
250
-            );
251
-            $templates             = is_array($templates) ? $templates : [$templates];
252
-            $template_folder_paths =
253
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
-            // array to hold all possible template paths
255
-            $full_template_paths = [];
256
-            $file_name           = '';
257
-
258
-            // loop through $templates
259
-            foreach ($templates as $template) {
260
-                // normalize directory separators
261
-                $template                      = EEH_File::standardise_directory_separators($template);
262
-                $file_name                     = basename($template);
263
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
-                // while looping through all template folder paths
265
-                foreach ($template_folder_paths as $template_folder_path) {
266
-                    // normalize directory separators
267
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
-                    // determine if any common base path exists between the two paths
269
-                    $common_base_path = EEH_Template::_find_common_base_path(
270
-                        [$template_folder_path, $template_path_minus_file_name]
271
-                    );
272
-                    if ($common_base_path !== '') {
273
-                        // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
-                    } else {
276
-                        // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
-                    }
279
-                    // build up our template locations array by adding our resolved paths
280
-                    $full_template_paths[] = $resolved_path;
281
-                }
282
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
-                array_unshift($full_template_paths, $template);
284
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
-            }
287
-            // filter final array of full template paths
288
-            $full_template_paths = apply_filters(
289
-                'FHEE__EEH_Template__locate_template__full_template_paths',
290
-                $full_template_paths,
291
-                $file_name
292
-            );
293
-            // now loop through our final array of template location paths and check each location
294
-            foreach ((array) $full_template_paths as $full_template_path) {
295
-                if (is_readable($full_template_path)) {
296
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
-                    break;
298
-                }
299
-            }
300
-        }
301
-
302
-        // hook that can be used to display the full template path that will be used
303
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
-
305
-        // if we got it and you want to see it...
306
-        if ($template_path && $load && ! $check_if_custom) {
307
-            if ($return_string) {
308
-                return EEH_Template::display_template($template_path, $template_args, true);
309
-            }
310
-            EEH_Template::display_template($template_path, $template_args);
311
-        }
312
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
-    }
314
-
315
-
316
-    /**
317
-     * _find_common_base_path
318
-     * given two paths, this determines if there is a common base path between the two
319
-     *
320
-     * @param array $paths
321
-     * @return string
322
-     */
323
-    protected static function _find_common_base_path($paths)
324
-    {
325
-        $last_offset      = 0;
326
-        $common_base_path = '';
327
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
-            $dir_length = $index - $last_offset + 1;
329
-            $directory  = substr($paths[0], $last_offset, $dir_length);
330
-            foreach ($paths as $path) {
331
-                if (substr($path, $last_offset, $dir_length) != $directory) {
332
-                    return $common_base_path;
333
-                }
334
-            }
335
-            $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
337
-        }
338
-        return substr($common_base_path, 0, -1);
339
-    }
340
-
341
-
342
-    /**
343
-     * load and display a template
344
-     *
345
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
347
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
-     *                                      string
349
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
-     *                                      not found or is not readable
351
-     * @return string
352
-     * @throws DomainException
353
-     */
354
-    public static function display_template(
355
-        $template_path = false,
356
-        $template_args = [],
357
-        $return_string = false,
358
-        $throw_exceptions = false
359
-    ) {
360
-
361
-        /**
362
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
-         * the display_template method are templates we DON'T want modified (usually because of js
365
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
-         * using this.
367
-         *
368
-         * @since 4.6.0
369
-         */
370
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
-
373
-        // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
375
-            // ignore whether template is accessible ?
376
-            if ($throw_exceptions) {
377
-                throw new DomainException(
378
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
-                );
380
-            }
381
-            return '';
382
-        }
383
-        // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
-            $template_args = [$template_args];
386
-        }
387
-        extract($template_args, EXTR_SKIP);
388
-
389
-        if ($return_string) {
390
-            // because we want to return a string, we are going to capture the output
391
-            ob_start();
392
-            include($template_path);
393
-            return ob_get_clean();
394
-        }
395
-        include($template_path);
396
-        return '';
397
-    }
398
-
399
-
400
-    /**
401
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
-     *
403
-     * @param EE_Base_Class $object the EE object the css class is being generated for
404
-     * @param string        $prefix added to the beginning of the generated class
405
-     * @param string        $suffix added to the end of the generated class
406
-     * @return string
407
-     * @throws EE_Error
408
-     * @throws ReflectionException
409
-     */
410
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
-    {
412
-        // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
-        // da muddle
415
-        $class = '';
416
-        // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
-        // is the passed object an EE object ?
419
-        if ($object instanceof EE_Base_Class) {
420
-            // grab the exact type of object
421
-            $obj_class = get_class($object);
422
-            // depending on the type of object...
423
-            switch ($obj_class) {
424
-                // no specifics just yet...
425
-                default:
426
-                    $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
-            }
429
-        }
430
-        return $prefix . $class . $suffix;
431
-    }
432
-
433
-
434
-    /**
435
-     * EEH_Template::format_currency
436
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
-     * the country currency settings from the supplied country ISO code
438
-     *
439
-     * @param float   $amount       raw money value
440
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
-     * @param string  $CNT_ISO      2 letter ISO code for a country
443
-     * @param string  $cur_code_span_class
444
-     * @return string        the html output for the formatted money value
445
-     */
446
-    public static function format_currency(
447
-        $amount = null,
448
-        $return_raw = false,
449
-        $display_code = true,
450
-        $CNT_ISO = '',
451
-        $cur_code_span_class = 'currency-code'
452
-    ) {
453
-        // ensure amount was received
454
-        if ($amount === null) {
455
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
-            return '';
458
-        }
459
-        // ensure amount is float
460
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
463
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
-        // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
466
-            return esc_html($amount_formatted);
467
-        }
468
-        try {
469
-            // was a country ISO code passed ? if so generate currency config object for that country
470
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
-        } catch (Exception $e) {
472
-            // eat exception
473
-            $mny = null;
474
-        }
475
-        // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
477
-            // set default config country currency settings
478
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
-                ? EE_Registry::instance()->CFG->currency
480
-                : new EE_Currency_Config();
481
-        }
482
-        // format float
483
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
-        // add formatting ?
485
-        if (! $return_raw) {
486
-            // add currency sign
487
-            if ($mny->sign_b4) {
488
-                if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
-                } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
-                }
493
-            } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
495
-            }
496
-
497
-            // filter to allow global setting of display_code
498
-            $display_code = (bool) apply_filters(
499
-                'FHEE__EEH_Template__format_currency__display_code',
500
-                $display_code
501
-            );
502
-
503
-            // add currency code ?
504
-            $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
-                : $amount_formatted;
507
-        }
508
-        // filter results
509
-        $amount_formatted = apply_filters(
510
-            'FHEE__EEH_Template__format_currency__amount_formatted',
511
-            $amount_formatted,
512
-            $mny,
513
-            $return_raw
514
-        );
515
-        // clean up vars
516
-        unset($mny);
517
-        // return formatted currency amount
518
-        return $amount_formatted;
519
-    }
520
-
521
-
522
-    /**
523
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
524
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
-     * related status model or model object (i.e. in documentation etc.)
526
-     *
527
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
-     *                            match, then 'Unknown' will be returned.
529
-     * @param boolean $plural     Whether to return plural or not
530
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
-     * @return string             The localized label for the status id.
532
-     * @throws EE_Error
533
-     */
534
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
-    {
536
-        $status = EEM_Status::instance()->localized_status(
537
-            [$status_id => esc_html__('unknown', 'event_espresso')],
538
-            $plural,
539
-            $schema
540
-        );
541
-        return $status[ $status_id ];
542
-    }
543
-
544
-
545
-    /**
546
-     * This helper just returns a button or link for the given parameters
547
-     *
548
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
549
-     * @param string $label What is the label you want displayed for the button
550
-     * @param string $class what class is used for the button (defaults to 'button--primary')
551
-     * @param string $icon
552
-     * @param string $title
553
-     * @return string the html output for the button
554
-     */
555
-    public static function get_button_or_link($url, $label, $class = 'button--primary', $icon = '', $title = '')
556
-    {
557
-        $icon_html = '';
558
-        if (! empty($icon)) {
559
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
-            $dashicons = array_filter($dashicons);
561
-            $count     = count($dashicons);
562
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
-            foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
-            }
567
-            $icon_html .= $count > 1 ? '</span>' : '';
568
-        }
569
-        // sanitize & escape
570
-        $id    = sanitize_title_with_dashes($label);
571
-        $url   = esc_url_raw($url);
572
-        $class = esc_attr($class);
573
-        $title = esc_attr($title);
574
-        $label = esc_html($label);
575
-        return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
-    }
577
-
578
-
579
-    /**
580
-     * This returns a generated link that will load the related help tab on admin pages.
581
-     *
582
-     * @param string      $help_tab_id the id for the connected help tab
583
-     * @param bool|string $page        The page identifier for the page the help tab is on
584
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
-     * @return string              generated link
588
-     */
589
-    public static function get_help_tab_link(
590
-        $help_tab_id,
591
-        $page = false,
592
-        $action = false,
593
-        $icon_style = false,
594
-        $help_text = false
595
-    ) {
596
-        global $allowedtags;
597
-        /** @var RequestInterface $request */
598
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
600
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
-
602
-
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
-        $help_text    = ! $help_text ? '' : $help_text;
606
-        return '<a id="'
607
-               . esc_attr($help_tab_lnk)
608
-               . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
-               . esc_attr($icon)
610
-               . '" title="'
611
-               . esc_attr__(
612
-                   'Click to open the \'Help\' tab for more information about this feature.',
613
-                   'event_espresso'
614
-               )
615
-               . '" > '
616
-               . wp_kses($help_text, $allowedtags)
617
-               . ' </a>';
618
-    }
619
-
620
-
621
-    /**
622
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
623
-     *
624
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
625
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
626
-     * @param EE_Help_Tour
627
-     * @return string         html
628
-     * @throws EE_Error
629
-     */
630
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
631
-    {
632
-        global $allowedtags;
633
-        $id    = $tour->get_slug();
634
-        $stops = $tour->get_stops();
635
-
636
-        $content = '<ol style="display:none" id="' . esc_attr($id) . '">';
637
-
638
-        foreach ($stops as $stop) {
639
-            $data_id    = ! empty($stop['id'])
640
-                ? ' data-id="' . esc_attr($stop['id']) . '"'
641
-                : '';
642
-
643
-            $data_class = empty($data_id) && ! empty($stop['class'])
644
-                ? ' data-class="' . esc_attr($stop['class']) . '"'
645
-                : '';
646
-
647
-            // if container is set to modal then let's make sure we set the options accordingly
648
-            if (empty($data_id) && empty($data_class)) {
649
-                $stop['options']['modal']  = true;
650
-                $stop['options']['expose'] = true;
651
-            }
652
-
653
-            $custom_class  = ! empty($stop['custom_class'])
654
-                ? ' class="' . esc_attr($stop['custom_class']) . '"'
655
-                : '';
656
-            $button_text   = ! empty($stop['button_text'])
657
-                ? ' data-button="' . esc_html($stop['button_text']) . '"'
658
-                : '';
659
-            $inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660
-
661
-            // options
662
-            if (isset($stop['options']) && is_array($stop['options'])) {
663
-                $options = ' data-options="';
664
-                foreach ($stop['options'] as $option => $value) {
665
-                    $options .= esc_attr($option) . ':' . esc_attr($value) . ';';
666
-                }
667
-                $options .= '"';
668
-            } else {
669
-                $options = '';
670
-            }
671
-
672
-            // let's put all together
673
-            $content .= '<li'
674
-                        . $data_id
675
-                        . $data_class
676
-                        . $custom_class
677
-                        . $button_text
678
-                        . $options
679
-                        . '>'
680
-                        . $inner_content
681
-                        . '</li>';
682
-        }
683
-
684
-        $content .= '</ol>';
685
-        return $content;
686
-    }
687
-
688
-
689
-    /**
690
-     * This is a helper method to generate a status legend for a given status array.
691
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
692
-     * status_array.
693
-     *
694
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
695
-     *                               array(
696
-     *                               'status_item' => 'status_name'
697
-     *                               )
698
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
699
-     *                               the legend.
700
-     * @return string               html structure for status.
701
-     * @throws EE_Error
702
-     */
703
-    public static function status_legend($status_array, $active_status = '')
704
-    {
705
-        if (! is_array($status_array)) {
706
-            throw new EE_Error(
707
-                esc_html__(
708
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
709
-                    'event_espresso'
710
-                )
711
-            );
712
-        }
713
-
714
-        $content = '
53
+	private static $_espresso_themes = [];
54
+
55
+
56
+	/**
57
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
+	 *
59
+	 * @return boolean
60
+	 */
61
+	public static function is_espresso_theme()
62
+	{
63
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
+	}
65
+
66
+
67
+	/**
68
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
+	 *    load its functions.php file ( if not already loaded )
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function load_espresso_theme_functions()
74
+	{
75
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
+			}
79
+		}
80
+	}
81
+
82
+
83
+	/**
84
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
+	 *
86
+	 * @return array
87
+	 */
88
+	public static function get_espresso_themes()
89
+	{
90
+		if (empty(EEH_Template::$_espresso_themes)) {
91
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+			if (empty($espresso_themes)) {
93
+				return [];
94
+			}
95
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
+				unset($espresso_themes[ $key ]);
97
+			}
98
+			EEH_Template::$_espresso_themes = [];
99
+			foreach ($espresso_themes as $espresso_theme) {
100
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+			}
102
+		}
103
+		return EEH_Template::$_espresso_themes;
104
+	}
105
+
106
+
107
+	/**
108
+	 * EEH_Template::get_template_part
109
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
+	 * filtering based off of the entire template part name
112
+	 *
113
+	 * @param string $slug The slug name for the generic template.
114
+	 * @param string $name The name of the specialised template.
115
+	 * @param array  $template_args
116
+	 * @param bool   $return_string
117
+	 * @return string        the html output for the formatted money value
118
+	 */
119
+	public static function get_template_part(
120
+		$slug = null,
121
+		$name = null,
122
+		$template_args = [],
123
+		$return_string = false
124
+	) {
125
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
+		$templates = [];
127
+		$name      = (string) $name;
128
+		if ($name != '') {
129
+			$templates[] = "{$slug}-{$name}.php";
130
+		}
131
+		// allow template parts to be turned off via something like:
132
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
+		}
136
+		return '';
137
+	}
138
+
139
+
140
+	/**
141
+	 *    locate_template
142
+	 *    locate a template file by looking in the following places, in the following order:
143
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
+	 *        <assumed full absolute server path>
145
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
147
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
151
+	 *        Example:
152
+	 *          You are using the WordPress Twenty Sixteen theme,
153
+	 *        and you want to customize the "some-event.template.php" template,
154
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
+	 *        /relative/path/to/some-event.template.php
159
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
+	 *          Had you passed an absolute path to your template that was in some other location,
165
+	 *        ie: "/absolute/path/to/some-event.template.php"
166
+	 *          then the search would have been :
167
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
+	 *        /absolute/path/to/some-event.template.php
169
+	 *          and stopped there upon finding it in the second location
170
+	 *
171
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
172
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
173
+	 * @param boolean      $load            whether to pass the located template path on to the
174
+	 *                                      EEH_Template::display_template() method or simply return it
175
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
+	 *                                      string
177
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
+	 *                                      generate a custom template or not. Used in places where you don't actually
179
+	 *                                      load the template, you just want to know if there's a custom version of it.
180
+	 * @return mixed
181
+	 * @throws DomainException
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public static function locate_template(
187
+		$templates = [],
188
+		$template_args = [],
189
+		$load = true,
190
+		$return_string = true,
191
+		$check_if_custom = false
192
+	) {
193
+		// first use WP locate_template to check for template in the current theme folder
194
+		$template_path = locate_template($templates);
195
+
196
+		if ($check_if_custom && ! empty($template_path)) {
197
+			return true;
198
+		}
199
+
200
+		// not in the theme
201
+		if (empty($template_path)) {
202
+			// not even a template to look for ?
203
+			if (empty($templates)) {
204
+				$loader = LoaderFactory::getLoader();
205
+				/** @var RequestInterface $request */
206
+				$request = $loader->getShared(RequestInterface::class);
207
+				// get post_type
208
+				$post_type = $request->getRequestParam('post_type');
209
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
+				$custom_post_types = $loader->getShared(
211
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
+				);
213
+				// get array of EE Custom Post Types
214
+				$EE_CPTs = $custom_post_types->getDefinitions();
215
+				// build template name based on request
216
+				if (isset($EE_CPTs[ $post_type ])) {
217
+					$archive_or_single = is_archive() ? 'archive' : '';
218
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
219
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
220
+				}
221
+			}
222
+			// currently active EE template theme
223
+			$current_theme = EE_Config::get_current_theme();
224
+
225
+			// array of paths to folders that may contain templates
226
+			$template_folder_paths = [
227
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
230
+				EVENT_ESPRESSO_TEMPLATE_DIR,
231
+			];
232
+
233
+			// add core plugin folders for checking only if we're not $check_if_custom
234
+			if (! $check_if_custom) {
235
+				$core_paths            = [
236
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
+					EE_PUBLIC . $current_theme,
238
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
+					EE_TEMPLATES . $current_theme,
240
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
+					EE_PLUGIN_DIR_PATH,
242
+				];
243
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
+			}
245
+
246
+			// now filter that array
247
+			$template_folder_paths = apply_filters(
248
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
249
+				$template_folder_paths
250
+			);
251
+			$templates             = is_array($templates) ? $templates : [$templates];
252
+			$template_folder_paths =
253
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
+			// array to hold all possible template paths
255
+			$full_template_paths = [];
256
+			$file_name           = '';
257
+
258
+			// loop through $templates
259
+			foreach ($templates as $template) {
260
+				// normalize directory separators
261
+				$template                      = EEH_File::standardise_directory_separators($template);
262
+				$file_name                     = basename($template);
263
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
+				// while looping through all template folder paths
265
+				foreach ($template_folder_paths as $template_folder_path) {
266
+					// normalize directory separators
267
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
+					// determine if any common base path exists between the two paths
269
+					$common_base_path = EEH_Template::_find_common_base_path(
270
+						[$template_folder_path, $template_path_minus_file_name]
271
+					);
272
+					if ($common_base_path !== '') {
273
+						// both paths have a common base, so just tack the filename onto our search path
274
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+					} else {
276
+						// no common base path, so let's just concatenate
277
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+					}
279
+					// build up our template locations array by adding our resolved paths
280
+					$full_template_paths[] = $resolved_path;
281
+				}
282
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
+				array_unshift($full_template_paths, $template);
284
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+			}
287
+			// filter final array of full template paths
288
+			$full_template_paths = apply_filters(
289
+				'FHEE__EEH_Template__locate_template__full_template_paths',
290
+				$full_template_paths,
291
+				$file_name
292
+			);
293
+			// now loop through our final array of template location paths and check each location
294
+			foreach ((array) $full_template_paths as $full_template_path) {
295
+				if (is_readable($full_template_path)) {
296
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
+					break;
298
+				}
299
+			}
300
+		}
301
+
302
+		// hook that can be used to display the full template path that will be used
303
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
+
305
+		// if we got it and you want to see it...
306
+		if ($template_path && $load && ! $check_if_custom) {
307
+			if ($return_string) {
308
+				return EEH_Template::display_template($template_path, $template_args, true);
309
+			}
310
+			EEH_Template::display_template($template_path, $template_args);
311
+		}
312
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
+	}
314
+
315
+
316
+	/**
317
+	 * _find_common_base_path
318
+	 * given two paths, this determines if there is a common base path between the two
319
+	 *
320
+	 * @param array $paths
321
+	 * @return string
322
+	 */
323
+	protected static function _find_common_base_path($paths)
324
+	{
325
+		$last_offset      = 0;
326
+		$common_base_path = '';
327
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
+			$dir_length = $index - $last_offset + 1;
329
+			$directory  = substr($paths[0], $last_offset, $dir_length);
330
+			foreach ($paths as $path) {
331
+				if (substr($path, $last_offset, $dir_length) != $directory) {
332
+					return $common_base_path;
333
+				}
334
+			}
335
+			$common_base_path .= $directory;
336
+			$last_offset      = $index + 1;
337
+		}
338
+		return substr($common_base_path, 0, -1);
339
+	}
340
+
341
+
342
+	/**
343
+	 * load and display a template
344
+	 *
345
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
347
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
+	 *                                      string
349
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
+	 *                                      not found or is not readable
351
+	 * @return string
352
+	 * @throws DomainException
353
+	 */
354
+	public static function display_template(
355
+		$template_path = false,
356
+		$template_args = [],
357
+		$return_string = false,
358
+		$throw_exceptions = false
359
+	) {
360
+
361
+		/**
362
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
+		 * the display_template method are templates we DON'T want modified (usually because of js
365
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
+		 * using this.
367
+		 *
368
+		 * @since 4.6.0
369
+		 */
370
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
+
373
+		// you gimme nuttin - YOU GET NUTTIN !!
374
+		if (! $template_path || ! is_readable($template_path)) {
375
+			// ignore whether template is accessible ?
376
+			if ($throw_exceptions) {
377
+				throw new DomainException(
378
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
+				);
380
+			}
381
+			return '';
382
+		}
383
+		// if $template_args are not in an array, then make it so
384
+		if (! is_array($template_args) && ! is_object($template_args)) {
385
+			$template_args = [$template_args];
386
+		}
387
+		extract($template_args, EXTR_SKIP);
388
+
389
+		if ($return_string) {
390
+			// because we want to return a string, we are going to capture the output
391
+			ob_start();
392
+			include($template_path);
393
+			return ob_get_clean();
394
+		}
395
+		include($template_path);
396
+		return '';
397
+	}
398
+
399
+
400
+	/**
401
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
+	 *
403
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
404
+	 * @param string        $prefix added to the beginning of the generated class
405
+	 * @param string        $suffix added to the end of the generated class
406
+	 * @return string
407
+	 * @throws EE_Error
408
+	 * @throws ReflectionException
409
+	 */
410
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
+	{
412
+		// in the beginning...
413
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+		// da muddle
415
+		$class = '';
416
+		// the end
417
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+		// is the passed object an EE object ?
419
+		if ($object instanceof EE_Base_Class) {
420
+			// grab the exact type of object
421
+			$obj_class = get_class($object);
422
+			// depending on the type of object...
423
+			switch ($obj_class) {
424
+				// no specifics just yet...
425
+				default:
426
+					$class = strtolower(str_replace('_', '-', $obj_class));
427
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+			}
429
+		}
430
+		return $prefix . $class . $suffix;
431
+	}
432
+
433
+
434
+	/**
435
+	 * EEH_Template::format_currency
436
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
+	 * the country currency settings from the supplied country ISO code
438
+	 *
439
+	 * @param float   $amount       raw money value
440
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
443
+	 * @param string  $cur_code_span_class
444
+	 * @return string        the html output for the formatted money value
445
+	 */
446
+	public static function format_currency(
447
+		$amount = null,
448
+		$return_raw = false,
449
+		$display_code = true,
450
+		$CNT_ISO = '',
451
+		$cur_code_span_class = 'currency-code'
452
+	) {
453
+		// ensure amount was received
454
+		if ($amount === null) {
455
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
+			return '';
458
+		}
459
+		// ensure amount is float
460
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
463
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
+		// still a number, or was amount converted to a string like "free" ?
465
+		if (! is_float($amount_formatted)) {
466
+			return esc_html($amount_formatted);
467
+		}
468
+		try {
469
+			// was a country ISO code passed ? if so generate currency config object for that country
470
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
+		} catch (Exception $e) {
472
+			// eat exception
473
+			$mny = null;
474
+		}
475
+		// verify results
476
+		if (! $mny instanceof EE_Currency_Config) {
477
+			// set default config country currency settings
478
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
+				? EE_Registry::instance()->CFG->currency
480
+				: new EE_Currency_Config();
481
+		}
482
+		// format float
483
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
+		// add formatting ?
485
+		if (! $return_raw) {
486
+			// add currency sign
487
+			if ($mny->sign_b4) {
488
+				if ($amount >= 0) {
489
+					$amount_formatted = $mny->sign . $amount_formatted;
490
+				} else {
491
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+				}
493
+			} else {
494
+				$amount_formatted = $amount_formatted . $mny->sign;
495
+			}
496
+
497
+			// filter to allow global setting of display_code
498
+			$display_code = (bool) apply_filters(
499
+				'FHEE__EEH_Template__format_currency__display_code',
500
+				$display_code
501
+			);
502
+
503
+			// add currency code ?
504
+			$amount_formatted = $display_code
505
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+				: $amount_formatted;
507
+		}
508
+		// filter results
509
+		$amount_formatted = apply_filters(
510
+			'FHEE__EEH_Template__format_currency__amount_formatted',
511
+			$amount_formatted,
512
+			$mny,
513
+			$return_raw
514
+		);
515
+		// clean up vars
516
+		unset($mny);
517
+		// return formatted currency amount
518
+		return $amount_formatted;
519
+	}
520
+
521
+
522
+	/**
523
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
524
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
+	 * related status model or model object (i.e. in documentation etc.)
526
+	 *
527
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
+	 *                            match, then 'Unknown' will be returned.
529
+	 * @param boolean $plural     Whether to return plural or not
530
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
+	 * @return string             The localized label for the status id.
532
+	 * @throws EE_Error
533
+	 */
534
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
+	{
536
+		$status = EEM_Status::instance()->localized_status(
537
+			[$status_id => esc_html__('unknown', 'event_espresso')],
538
+			$plural,
539
+			$schema
540
+		);
541
+		return $status[ $status_id ];
542
+	}
543
+
544
+
545
+	/**
546
+	 * This helper just returns a button or link for the given parameters
547
+	 *
548
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
549
+	 * @param string $label What is the label you want displayed for the button
550
+	 * @param string $class what class is used for the button (defaults to 'button--primary')
551
+	 * @param string $icon
552
+	 * @param string $title
553
+	 * @return string the html output for the button
554
+	 */
555
+	public static function get_button_or_link($url, $label, $class = 'button--primary', $icon = '', $title = '')
556
+	{
557
+		$icon_html = '';
558
+		if (! empty($icon)) {
559
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
+			$dashicons = array_filter($dashicons);
561
+			$count     = count($dashicons);
562
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
+			foreach ($dashicons as $dashicon) {
564
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
+			}
567
+			$icon_html .= $count > 1 ? '</span>' : '';
568
+		}
569
+		// sanitize & escape
570
+		$id    = sanitize_title_with_dashes($label);
571
+		$url   = esc_url_raw($url);
572
+		$class = esc_attr($class);
573
+		$title = esc_attr($title);
574
+		$label = esc_html($label);
575
+		return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
+	}
577
+
578
+
579
+	/**
580
+	 * This returns a generated link that will load the related help tab on admin pages.
581
+	 *
582
+	 * @param string      $help_tab_id the id for the connected help tab
583
+	 * @param bool|string $page        The page identifier for the page the help tab is on
584
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
+	 * @return string              generated link
588
+	 */
589
+	public static function get_help_tab_link(
590
+		$help_tab_id,
591
+		$page = false,
592
+		$action = false,
593
+		$icon_style = false,
594
+		$help_text = false
595
+	) {
596
+		global $allowedtags;
597
+		/** @var RequestInterface $request */
598
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
600
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
+
602
+
603
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
+		$help_text    = ! $help_text ? '' : $help_text;
606
+		return '<a id="'
607
+			   . esc_attr($help_tab_lnk)
608
+			   . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
+			   . esc_attr($icon)
610
+			   . '" title="'
611
+			   . esc_attr__(
612
+				   'Click to open the \'Help\' tab for more information about this feature.',
613
+				   'event_espresso'
614
+			   )
615
+			   . '" > '
616
+			   . wp_kses($help_text, $allowedtags)
617
+			   . ' </a>';
618
+	}
619
+
620
+
621
+	/**
622
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
623
+	 *
624
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
625
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
626
+	 * @param EE_Help_Tour
627
+	 * @return string         html
628
+	 * @throws EE_Error
629
+	 */
630
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
631
+	{
632
+		global $allowedtags;
633
+		$id    = $tour->get_slug();
634
+		$stops = $tour->get_stops();
635
+
636
+		$content = '<ol style="display:none" id="' . esc_attr($id) . '">';
637
+
638
+		foreach ($stops as $stop) {
639
+			$data_id    = ! empty($stop['id'])
640
+				? ' data-id="' . esc_attr($stop['id']) . '"'
641
+				: '';
642
+
643
+			$data_class = empty($data_id) && ! empty($stop['class'])
644
+				? ' data-class="' . esc_attr($stop['class']) . '"'
645
+				: '';
646
+
647
+			// if container is set to modal then let's make sure we set the options accordingly
648
+			if (empty($data_id) && empty($data_class)) {
649
+				$stop['options']['modal']  = true;
650
+				$stop['options']['expose'] = true;
651
+			}
652
+
653
+			$custom_class  = ! empty($stop['custom_class'])
654
+				? ' class="' . esc_attr($stop['custom_class']) . '"'
655
+				: '';
656
+			$button_text   = ! empty($stop['button_text'])
657
+				? ' data-button="' . esc_html($stop['button_text']) . '"'
658
+				: '';
659
+			$inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660
+
661
+			// options
662
+			if (isset($stop['options']) && is_array($stop['options'])) {
663
+				$options = ' data-options="';
664
+				foreach ($stop['options'] as $option => $value) {
665
+					$options .= esc_attr($option) . ':' . esc_attr($value) . ';';
666
+				}
667
+				$options .= '"';
668
+			} else {
669
+				$options = '';
670
+			}
671
+
672
+			// let's put all together
673
+			$content .= '<li'
674
+						. $data_id
675
+						. $data_class
676
+						. $custom_class
677
+						. $button_text
678
+						. $options
679
+						. '>'
680
+						. $inner_content
681
+						. '</li>';
682
+		}
683
+
684
+		$content .= '</ol>';
685
+		return $content;
686
+	}
687
+
688
+
689
+	/**
690
+	 * This is a helper method to generate a status legend for a given status array.
691
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
692
+	 * status_array.
693
+	 *
694
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
695
+	 *                               array(
696
+	 *                               'status_item' => 'status_name'
697
+	 *                               )
698
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
699
+	 *                               the legend.
700
+	 * @return string               html structure for status.
701
+	 * @throws EE_Error
702
+	 */
703
+	public static function status_legend($status_array, $active_status = '')
704
+	{
705
+		if (! is_array($status_array)) {
706
+			throw new EE_Error(
707
+				esc_html__(
708
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
709
+					'event_espresso'
710
+				)
711
+			);
712
+		}
713
+
714
+		$content = '
715 715
             <div class="ee-list-table-legend-container">
716 716
                 <h4 class="status-legend-title">
717 717
                     ' . esc_html__('Status Legend', 'event_espresso') . '
718 718
                 </h4>
719 719
                 <dl class="ee-list-table-legend">';
720 720
 
721
-        foreach ($status_array as $item => $status) {
722
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
-            $content      .= '
721
+		foreach ($status_array as $item => $status) {
722
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
+			$content      .= '
724 724
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
725 725
                         <span class="' . esc_attr('ee-status-legend ee-status-legend--' . $status) . '"></span>
726 726
                         <span class="ee-legend-description">
727 727
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
728 728
                         </span>
729 729
                     </dt>';
730
-        }
730
+		}
731 731
 
732
-        $content .= '
732
+		$content .= '
733 733
                 </dl>
734 734
             </div>
735 735
 ';
736
-        return $content;
737
-    }
738
-
739
-
740
-    /**
741
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
742
-     * that's nice for presenting in the wp admin
743
-     *
744
-     * @param mixed $data
745
-     * @return string
746
-     */
747
-    public static function layout_array_as_table($data)
748
-    {
749
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
750
-            $data = (array) $data;
751
-        }
752
-        ob_start();
753
-        if (is_array($data)) {
754
-            if (EEH_Array::is_associative_array($data)) { ?>
736
+		return $content;
737
+	}
738
+
739
+
740
+	/**
741
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
742
+	 * that's nice for presenting in the wp admin
743
+	 *
744
+	 * @param mixed $data
745
+	 * @return string
746
+	 */
747
+	public static function layout_array_as_table($data)
748
+	{
749
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
750
+			$data = (array) $data;
751
+		}
752
+		ob_start();
753
+		if (is_array($data)) {
754
+			if (EEH_Array::is_associative_array($data)) { ?>
755 755
                 <table class="widefat">
756 756
                     <tbody>
757 757
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -769,292 +769,292 @@  discard block
 block discarded – undo
769 769
             <?php } else { ?>
770 770
                 <ul>
771 771
                     <?php
772
-                    foreach ($data as $datum) {
773
-                        echo "<li>";
774
-                        echo self::layout_array_as_table($datum);
775
-                        echo "</li>";
776
-                    } ?>
772
+					foreach ($data as $datum) {
773
+						echo "<li>";
774
+						echo self::layout_array_as_table($datum);
775
+						echo "</li>";
776
+					} ?>
777 777
                 </ul>
778 778
             <?php }
779
-        } else {
780
-            // simple value
781
-            echo esc_html($data);
782
-        }
783
-        return ob_get_clean();
784
-    }
785
-
786
-
787
-    /**
788
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
789
-     *
790
-     * @param        $total_items
791
-     * @param        $current
792
-     * @param        $per_page
793
-     * @param        $url
794
-     * @param bool   $show_num_field
795
-     * @param string $paged_arg_name
796
-     * @param array  $items_label
797
-     * @see   self:get_paging_html() for argument docs.
798
-     * @since 4.4.0
799
-     */
800
-    public static function paging_html(
801
-        $total_items,
802
-        $current,
803
-        $per_page,
804
-        $url,
805
-        $show_num_field = true,
806
-        $paged_arg_name = 'paged',
807
-        $items_label = []
808
-    ) {
809
-        echo self::get_paging_html(
810
-            $total_items,
811
-            $current,
812
-            $per_page,
813
-            $url,
814
-            $show_num_field,
815
-            $paged_arg_name,
816
-            $items_label
817
-        );
818
-    }
819
-
820
-
821
-    /**
822
-     * A method for generating paging similar to WP_List_Table
823
-     *
824
-     * @param integer $total_items      How many total items there are to page.
825
-     * @param integer $current          What the current page is.
826
-     * @param integer $per_page         How many items per page.
827
-     * @param string  $url              What the base url for page links is.
828
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
829
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
830
-     * @param array   $items_label      An array of singular/plural values for the items label:
831
-     *                                  array(
832
-     *                                  'single' => 'item',
833
-     *                                  'plural' => 'items'
834
-     *                                  )
835
-     * @return  string
836
-     * @since    4.4.0
837
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
838
-     */
839
-    public static function get_paging_html(
840
-        $total_items,
841
-        $current,
842
-        $per_page,
843
-        $url,
844
-        $show_num_field = true,
845
-        $paged_arg_name = 'paged',
846
-        $items_label = []
847
-    ) {
848
-        $page_links     = [];
849
-        $disable_first  = $disable_last = '';
850
-        $total_items    = (int) $total_items;
851
-        $per_page       = (int) $per_page;
852
-        $current        = (int) $current;
853
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
854
-
855
-        // filter items_label
856
-        $items_label = apply_filters(
857
-            'FHEE__EEH_Template__get_paging_html__items_label',
858
-            $items_label
859
-        );
860
-
861
-        if (
862
-            empty($items_label)
863
-            || ! is_array($items_label)
864
-            || ! isset($items_label['single'])
865
-            || ! isset($items_label['plural'])
866
-        ) {
867
-            $items_label = [
868
-                'single' => esc_html__('1 item', 'event_espresso'),
869
-                'plural' => esc_html__('%s items', 'event_espresso'),
870
-            ];
871
-        } else {
872
-            $items_label = [
873
-                'single' => '1 ' . esc_html($items_label['single']),
874
-                'plural' => '%s ' . esc_html($items_label['plural']),
875
-            ];
876
-        }
877
-
878
-        $total_pages = ceil($total_items / $per_page);
879
-
880
-        if ($total_pages <= 1) {
881
-            return '';
882
-        }
883
-
884
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885
-
886
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
887
-
888
-        if ($current === 1) {
889
-            $disable_first = ' disabled';
890
-        }
891
-        if ($current == $total_pages) {
892
-            $disable_last = ' disabled';
893
-        }
894
-
895
-        $page_links[] = sprintf(
896
-            "<a class='%s' title='%s' href='%s'>%s</a>",
897
-            'first-page' . $disable_first,
898
-            esc_attr__('Go to the first page', 'event_espresso'),
899
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900
-            '&laquo;'
901
-        );
902
-
903
-        $page_links[] = sprintf(
904
-            '<a class="%s" title="%s" href="%s">%s</a>',
905
-            'prev-page' . $disable_first,
906
-            esc_attr__('Go to the previous page', 'event_espresso'),
907
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908
-            '&lsaquo;'
909
-        );
910
-
911
-        if (! $show_num_field) {
912
-            $html_current_page = $current;
913
-        } else {
914
-            $html_current_page = sprintf(
915
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
916
-                esc_attr__('Current page', 'event_espresso'),
917
-                esc_attr($current),
918
-                strlen($total_pages)
919
-            );
920
-        }
921
-
922
-        $html_total_pages = sprintf(
923
-            '<span class="total-pages">%s</span>',
924
-            number_format_i18n($total_pages)
925
-        );
926
-        $page_links[]     = sprintf(
927
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928
-            $html_current_page,
929
-            $html_total_pages,
930
-            '<span class="paging-input">',
931
-            '</span>'
932
-        );
933
-
934
-        $page_links[] = sprintf(
935
-            '<a class="%s" title="%s" href="%s">%s</a>',
936
-            'next-page' . $disable_last,
937
-            esc_attr__('Go to the next page', 'event_espresso'),
938
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939
-            '&rsaquo;'
940
-        );
941
-
942
-        $page_links[] = sprintf(
943
-            '<a class="%s" title="%s" href="%s">%s</a>',
944
-            'last-page' . $disable_last,
945
-            esc_attr__('Go to the last page', 'event_espresso'),
946
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947
-            '&raquo;'
948
-        );
949
-
950
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
951
-        // set page class
952
-        if ($total_pages) {
953
-            $page_class = $total_pages < 2 ? ' one-page' : '';
954
-        } else {
955
-            $page_class = ' no-pages';
956
-        }
957
-
958
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
959
-    }
960
-
961
-
962
-    /**
963
-     * @param string $wrap_class
964
-     * @param string $wrap_id
965
-     * @return string
966
-     */
967
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
968
-    {
969
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
970
-        if (
971
-            ! $admin
972
-            && ! apply_filters(
973
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
974
-                EE_Registry::instance()->CFG->admin->show_reg_footer
975
-            )
976
-        ) {
977
-            return '';
978
-        }
979
-        $tag        = $admin ? 'span' : 'div';
980
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
981
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
982
-        $attributes .= ! empty($wrap_class)
983
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
984
-            : ' class="powered-by-event-espresso-credit"';
985
-        $query_args = array_merge(
986
-            [
987
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
988
-                'utm_source'   => 'powered_by_event_espresso',
989
-                'utm_medium'   => 'link',
990
-                'utm_campaign' => 'powered_by',
991
-            ],
992
-            $query_args
993
-        );
994
-        $powered_by = apply_filters(
995
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
996
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
997
-        );
998
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
999
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
1000
-        return (string) apply_filters(
1001
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
1002
-            sprintf(
1003
-                esc_html_x(
1004
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
1005
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
1006
-                    'event_espresso'
1007
-                ),
1008
-                "<{$tag}{$attributes}>",
1009
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
1010
-                $admin ? '' : '<br />'
1011
-            ),
1012
-            $wrap_class,
1013
-            $wrap_id
1014
-        );
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * @param string $image_name
1020
-     * @return string|null
1021
-     * @since   4.10.14.p
1022
-     */
1023
-    public static function getScreenshotUrl($image_name)
1024
-    {
1025
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1026
-    }
779
+		} else {
780
+			// simple value
781
+			echo esc_html($data);
782
+		}
783
+		return ob_get_clean();
784
+	}
785
+
786
+
787
+	/**
788
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
789
+	 *
790
+	 * @param        $total_items
791
+	 * @param        $current
792
+	 * @param        $per_page
793
+	 * @param        $url
794
+	 * @param bool   $show_num_field
795
+	 * @param string $paged_arg_name
796
+	 * @param array  $items_label
797
+	 * @see   self:get_paging_html() for argument docs.
798
+	 * @since 4.4.0
799
+	 */
800
+	public static function paging_html(
801
+		$total_items,
802
+		$current,
803
+		$per_page,
804
+		$url,
805
+		$show_num_field = true,
806
+		$paged_arg_name = 'paged',
807
+		$items_label = []
808
+	) {
809
+		echo self::get_paging_html(
810
+			$total_items,
811
+			$current,
812
+			$per_page,
813
+			$url,
814
+			$show_num_field,
815
+			$paged_arg_name,
816
+			$items_label
817
+		);
818
+	}
819
+
820
+
821
+	/**
822
+	 * A method for generating paging similar to WP_List_Table
823
+	 *
824
+	 * @param integer $total_items      How many total items there are to page.
825
+	 * @param integer $current          What the current page is.
826
+	 * @param integer $per_page         How many items per page.
827
+	 * @param string  $url              What the base url for page links is.
828
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
829
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
830
+	 * @param array   $items_label      An array of singular/plural values for the items label:
831
+	 *                                  array(
832
+	 *                                  'single' => 'item',
833
+	 *                                  'plural' => 'items'
834
+	 *                                  )
835
+	 * @return  string
836
+	 * @since    4.4.0
837
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
838
+	 */
839
+	public static function get_paging_html(
840
+		$total_items,
841
+		$current,
842
+		$per_page,
843
+		$url,
844
+		$show_num_field = true,
845
+		$paged_arg_name = 'paged',
846
+		$items_label = []
847
+	) {
848
+		$page_links     = [];
849
+		$disable_first  = $disable_last = '';
850
+		$total_items    = (int) $total_items;
851
+		$per_page       = (int) $per_page;
852
+		$current        = (int) $current;
853
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
854
+
855
+		// filter items_label
856
+		$items_label = apply_filters(
857
+			'FHEE__EEH_Template__get_paging_html__items_label',
858
+			$items_label
859
+		);
860
+
861
+		if (
862
+			empty($items_label)
863
+			|| ! is_array($items_label)
864
+			|| ! isset($items_label['single'])
865
+			|| ! isset($items_label['plural'])
866
+		) {
867
+			$items_label = [
868
+				'single' => esc_html__('1 item', 'event_espresso'),
869
+				'plural' => esc_html__('%s items', 'event_espresso'),
870
+			];
871
+		} else {
872
+			$items_label = [
873
+				'single' => '1 ' . esc_html($items_label['single']),
874
+				'plural' => '%s ' . esc_html($items_label['plural']),
875
+			];
876
+		}
877
+
878
+		$total_pages = ceil($total_items / $per_page);
879
+
880
+		if ($total_pages <= 1) {
881
+			return '';
882
+		}
883
+
884
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885
+
886
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
887
+
888
+		if ($current === 1) {
889
+			$disable_first = ' disabled';
890
+		}
891
+		if ($current == $total_pages) {
892
+			$disable_last = ' disabled';
893
+		}
894
+
895
+		$page_links[] = sprintf(
896
+			"<a class='%s' title='%s' href='%s'>%s</a>",
897
+			'first-page' . $disable_first,
898
+			esc_attr__('Go to the first page', 'event_espresso'),
899
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900
+			'&laquo;'
901
+		);
902
+
903
+		$page_links[] = sprintf(
904
+			'<a class="%s" title="%s" href="%s">%s</a>',
905
+			'prev-page' . $disable_first,
906
+			esc_attr__('Go to the previous page', 'event_espresso'),
907
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908
+			'&lsaquo;'
909
+		);
910
+
911
+		if (! $show_num_field) {
912
+			$html_current_page = $current;
913
+		} else {
914
+			$html_current_page = sprintf(
915
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
916
+				esc_attr__('Current page', 'event_espresso'),
917
+				esc_attr($current),
918
+				strlen($total_pages)
919
+			);
920
+		}
921
+
922
+		$html_total_pages = sprintf(
923
+			'<span class="total-pages">%s</span>',
924
+			number_format_i18n($total_pages)
925
+		);
926
+		$page_links[]     = sprintf(
927
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928
+			$html_current_page,
929
+			$html_total_pages,
930
+			'<span class="paging-input">',
931
+			'</span>'
932
+		);
933
+
934
+		$page_links[] = sprintf(
935
+			'<a class="%s" title="%s" href="%s">%s</a>',
936
+			'next-page' . $disable_last,
937
+			esc_attr__('Go to the next page', 'event_espresso'),
938
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939
+			'&rsaquo;'
940
+		);
941
+
942
+		$page_links[] = sprintf(
943
+			'<a class="%s" title="%s" href="%s">%s</a>',
944
+			'last-page' . $disable_last,
945
+			esc_attr__('Go to the last page', 'event_espresso'),
946
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947
+			'&raquo;'
948
+		);
949
+
950
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
951
+		// set page class
952
+		if ($total_pages) {
953
+			$page_class = $total_pages < 2 ? ' one-page' : '';
954
+		} else {
955
+			$page_class = ' no-pages';
956
+		}
957
+
958
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
959
+	}
960
+
961
+
962
+	/**
963
+	 * @param string $wrap_class
964
+	 * @param string $wrap_id
965
+	 * @return string
966
+	 */
967
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
968
+	{
969
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
970
+		if (
971
+			! $admin
972
+			&& ! apply_filters(
973
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
974
+				EE_Registry::instance()->CFG->admin->show_reg_footer
975
+			)
976
+		) {
977
+			return '';
978
+		}
979
+		$tag        = $admin ? 'span' : 'div';
980
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
981
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
982
+		$attributes .= ! empty($wrap_class)
983
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
984
+			: ' class="powered-by-event-espresso-credit"';
985
+		$query_args = array_merge(
986
+			[
987
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
988
+				'utm_source'   => 'powered_by_event_espresso',
989
+				'utm_medium'   => 'link',
990
+				'utm_campaign' => 'powered_by',
991
+			],
992
+			$query_args
993
+		);
994
+		$powered_by = apply_filters(
995
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
996
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
997
+		);
998
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
999
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
1000
+		return (string) apply_filters(
1001
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
1002
+			sprintf(
1003
+				esc_html_x(
1004
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
1005
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
1006
+					'event_espresso'
1007
+				),
1008
+				"<{$tag}{$attributes}>",
1009
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
1010
+				$admin ? '' : '<br />'
1011
+			),
1012
+			$wrap_class,
1013
+			$wrap_id
1014
+		);
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * @param string $image_name
1020
+	 * @return string|null
1021
+	 * @since   4.10.14.p
1022
+	 */
1023
+	public static function getScreenshotUrl($image_name)
1024
+	{
1025
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1026
+	}
1027 1027
 }
1028 1028
 
1029 1029
 
1030 1030
 if (! function_exists('espresso_pagination')) {
1031
-    /**
1032
-     *    espresso_pagination
1033
-     *
1034
-     * @access    public
1035
-     * @return    void
1036
-     */
1037
-    function espresso_pagination()
1038
-    {
1039
-        global $wp_query;
1040
-        $big        = 999999999; // need an unlikely integer
1041
-        $pagination = paginate_links(
1042
-            [
1043
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1044
-                'format'       => '?paged=%#%',
1045
-                'current'      => max(1, get_query_var('paged')),
1046
-                'total'        => $wp_query->max_num_pages,
1047
-                'show_all'     => true,
1048
-                'end_size'     => 10,
1049
-                'mid_size'     => 6,
1050
-                'prev_next'    => true,
1051
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
1052
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
1053
-                'type'         => 'plain',
1054
-                'add_args'     => false,
1055
-                'add_fragment' => '',
1056
-            ]
1057
-        );
1058
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1059
-    }
1031
+	/**
1032
+	 *    espresso_pagination
1033
+	 *
1034
+	 * @access    public
1035
+	 * @return    void
1036
+	 */
1037
+	function espresso_pagination()
1038
+	{
1039
+		global $wp_query;
1040
+		$big        = 999999999; // need an unlikely integer
1041
+		$pagination = paginate_links(
1042
+			[
1043
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1044
+				'format'       => '?paged=%#%',
1045
+				'current'      => max(1, get_query_var('paged')),
1046
+				'total'        => $wp_query->max_num_pages,
1047
+				'show_all'     => true,
1048
+				'end_size'     => 10,
1049
+				'mid_size'     => 6,
1050
+				'prev_next'    => true,
1051
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
1052
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
1053
+				'type'         => 'plain',
1054
+				'add_args'     => false,
1055
+				'add_fragment' => '',
1056
+			]
1057
+		);
1058
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1059
+	}
1060 1060
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderFactory;
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8
-if (! function_exists('espresso_get_template_part')) {
8
+if ( ! function_exists('espresso_get_template_part')) {
9 9
     /**
10 10
      * espresso_get_template_part
11 11
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 }
22 22
 
23 23
 
24
-if (! function_exists('espresso_get_object_css_class')) {
24
+if ( ! function_exists('espresso_get_object_css_class')) {
25 25
     /**
26 26
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27 27
      *
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public static function load_espresso_theme_functions()
74 74
     {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
75
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
77
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
78 78
             }
79 79
         }
80 80
     }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     public static function get_espresso_themes()
89 89
     {
90 90
         if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
91
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
92 92
             if (empty($espresso_themes)) {
93 93
                 return [];
94 94
             }
95 95
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
96
+                unset($espresso_themes[$key]);
97 97
             }
98 98
             EEH_Template::$_espresso_themes = [];
99 99
             foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
100
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
101 101
             }
102 102
         }
103 103
         return EEH_Template::$_espresso_themes;
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                 // get array of EE Custom Post Types
214 214
                 $EE_CPTs = $custom_post_types->getDefinitions();
215 215
                 // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
216
+                if (isset($EE_CPTs[$post_type])) {
217 217
                     $archive_or_single = is_archive() ? 'archive' : '';
218 218
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
219
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
220 220
                 }
221 221
             }
222 222
             // currently active EE template theme
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
             // array of paths to folders that may contain templates
226 226
             $template_folder_paths = [
227 227
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
229 229
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
230 230
                 EVENT_ESPRESSO_TEMPLATE_DIR,
231 231
             ];
232 232
 
233 233
             // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
234
+            if ( ! $check_if_custom) {
235
+                $core_paths = [
236 236
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
237
+                    EE_PUBLIC.$current_theme,
238 238
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
239
+                    EE_TEMPLATES.$current_theme,
240 240
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241 241
                     EE_PLUGIN_DIR_PATH,
242 242
                 ];
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
                     );
272 272
                     if ($common_base_path !== '') {
273 273
                         // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
274
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
275 275
                     } else {
276 276
                         // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
277
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
278 278
                     }
279 279
                     // build up our template locations array by adding our resolved paths
280 280
                     $full_template_paths[] = $resolved_path;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283 283
                 array_unshift($full_template_paths, $template);
284 284
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
285
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
286 286
             }
287 287
             // filter final array of full template paths
288 288
             $full_template_paths = apply_filters(
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 }
334 334
             }
335 335
             $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
336
+            $last_offset = $index + 1;
337 337
         }
338 338
         return substr($common_base_path, 0, -1);
339 339
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372 372
 
373 373
         // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
374
+        if ( ! $template_path || ! is_readable($template_path)) {
375 375
             // ignore whether template is accessible ?
376 376
             if ($throw_exceptions) {
377 377
                 throw new DomainException(
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return '';
382 382
         }
383 383
         // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
384
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
385 385
             $template_args = [$template_args];
386 386
         }
387 387
         extract($template_args, EXTR_SKIP);
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411 411
     {
412 412
         // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
413
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
414 414
         // da muddle
415 415
         $class = '';
416 416
         // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
417
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
418 418
         // is the passed object an EE object ?
419 419
         if ($object instanceof EE_Base_Class) {
420 420
             // grab the exact type of object
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
                 // no specifics just yet...
425 425
                 default:
426 426
                     $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
427
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
428 428
             }
429 429
         }
430
-        return $prefix . $class . $suffix;
430
+        return $prefix.$class.$suffix;
431 431
     }
432 432
 
433 433
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         // filter raw amount (allows 0.00 to be changed to "free" for example)
463 463
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464 464
         // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
465
+        if ( ! is_float($amount_formatted)) {
466 466
             return esc_html($amount_formatted);
467 467
         }
468 468
         try {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             $mny = null;
474 474
         }
475 475
         // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
476
+        if ( ! $mny instanceof EE_Currency_Config) {
477 477
             // set default config country currency settings
478 478
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479 479
                 ? EE_Registry::instance()->CFG->currency
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
         // format float
483 483
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484 484
         // add formatting ?
485
-        if (! $return_raw) {
485
+        if ( ! $return_raw) {
486 486
             // add currency sign
487 487
             if ($mny->sign_b4) {
488 488
                 if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
489
+                    $amount_formatted = $mny->sign.$amount_formatted;
490 490
                 } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
491
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
492 492
                 }
493 493
             } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
494
+                $amount_formatted = $amount_formatted.$mny->sign;
495 495
             }
496 496
 
497 497
             // filter to allow global setting of display_code
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
             // add currency code ?
504 504
             $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
505
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
506 506
                 : $amount_formatted;
507 507
         }
508 508
         // filter results
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             $plural,
539 539
             $schema
540 540
         );
541
-        return $status[ $status_id ];
541
+        return $status[$status_id];
542 542
     }
543 543
 
544 544
 
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
     public static function get_button_or_link($url, $label, $class = 'button--primary', $icon = '', $title = '')
556 556
     {
557 557
         $icon_html = '';
558
-        if (! empty($icon)) {
558
+        if ( ! empty($icon)) {
559 559
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560 560
             $dashicons = array_filter($dashicons);
561 561
             $count     = count($dashicons);
562 562
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563 563
             foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
564
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
566 566
             }
567 567
             $icon_html .= $count > 1 ? '</span>' : '';
568 568
         }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601 601
 
602 602
 
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
603
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
604 604
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605 605
         $help_text    = ! $help_text ? '' : $help_text;
606 606
         return '<a id="'
@@ -633,15 +633,15 @@  discard block
 block discarded – undo
633 633
         $id    = $tour->get_slug();
634 634
         $stops = $tour->get_stops();
635 635
 
636
-        $content = '<ol style="display:none" id="' . esc_attr($id) . '">';
636
+        $content = '<ol style="display:none" id="'.esc_attr($id).'">';
637 637
 
638 638
         foreach ($stops as $stop) {
639
-            $data_id    = ! empty($stop['id'])
640
-                ? ' data-id="' . esc_attr($stop['id']) . '"'
639
+            $data_id = ! empty($stop['id'])
640
+                ? ' data-id="'.esc_attr($stop['id']).'"'
641 641
                 : '';
642 642
 
643 643
             $data_class = empty($data_id) && ! empty($stop['class'])
644
-                ? ' data-class="' . esc_attr($stop['class']) . '"'
644
+                ? ' data-class="'.esc_attr($stop['class']).'"'
645 645
                 : '';
646 646
 
647 647
             // if container is set to modal then let's make sure we set the options accordingly
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
             }
652 652
 
653 653
             $custom_class  = ! empty($stop['custom_class'])
654
-                ? ' class="' . esc_attr($stop['custom_class']) . '"'
654
+                ? ' class="'.esc_attr($stop['custom_class']).'"'
655 655
                 : '';
656 656
             $button_text   = ! empty($stop['button_text'])
657
-                ? ' data-button="' . esc_html($stop['button_text']) . '"'
657
+                ? ' data-button="'.esc_html($stop['button_text']).'"'
658 658
                 : '';
659 659
             $inner_content = isset($stop['content']) ? wp_kses($stop['content'], $allowedtags) : '';
660 660
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
             if (isset($stop['options']) && is_array($stop['options'])) {
663 663
                 $options = ' data-options="';
664 664
                 foreach ($stop['options'] as $option => $value) {
665
-                    $options .= esc_attr($option) . ':' . esc_attr($value) . ';';
665
+                    $options .= esc_attr($option).':'.esc_attr($value).';';
666 666
                 }
667 667
                 $options .= '"';
668 668
             } else {
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      */
703 703
     public static function status_legend($status_array, $active_status = '')
704 704
     {
705
-        if (! is_array($status_array)) {
705
+        if ( ! is_array($status_array)) {
706 706
             throw new EE_Error(
707 707
                 esc_html__(
708 708
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -714,17 +714,17 @@  discard block
 block discarded – undo
714 714
         $content = '
715 715
             <div class="ee-list-table-legend-container">
716 716
                 <h4 class="status-legend-title">
717
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
717
+                    ' . esc_html__('Status Legend', 'event_espresso').'
718 718
                 </h4>
719 719
                 <dl class="ee-list-table-legend">';
720 720
 
721 721
         foreach ($status_array as $item => $status) {
722 722
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
723
-            $content      .= '
724
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
725
-                        <span class="' . esc_attr('ee-status-legend ee-status-legend--' . $status) . '"></span>
723
+            $content .= '
724
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
725
+                        <span class="' . esc_attr('ee-status-legend ee-status-legend--'.$status).'"></span>
726 726
                         <span class="ee-legend-description">
727
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
727
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
728 728
                         </span>
729 729
                     </dt>';
730 730
         }
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
             ];
871 871
         } else {
872 872
             $items_label = [
873
-                'single' => '1 ' . esc_html($items_label['single']),
874
-                'plural' => '%s ' . esc_html($items_label['plural']),
873
+                'single' => '1 '.esc_html($items_label['single']),
874
+                'plural' => '%s '.esc_html($items_label['plural']),
875 875
             ];
876 876
         }
877 877
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 
884 884
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
885 885
 
886
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
886
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
887 887
 
888 888
         if ($current === 1) {
889 889
             $disable_first = ' disabled';
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 
895 895
         $page_links[] = sprintf(
896 896
             "<a class='%s' title='%s' href='%s'>%s</a>",
897
-            'first-page' . $disable_first,
897
+            'first-page'.$disable_first,
898 898
             esc_attr__('Go to the first page', 'event_espresso'),
899 899
             esc_url_raw(remove_query_arg($paged_arg_name, $url)),
900 900
             '&laquo;'
@@ -902,13 +902,13 @@  discard block
 block discarded – undo
902 902
 
903 903
         $page_links[] = sprintf(
904 904
             '<a class="%s" title="%s" href="%s">%s</a>',
905
-            'prev-page' . $disable_first,
905
+            'prev-page'.$disable_first,
906 906
             esc_attr__('Go to the previous page', 'event_espresso'),
907 907
             esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
908 908
             '&lsaquo;'
909 909
         );
910 910
 
911
-        if (! $show_num_field) {
911
+        if ( ! $show_num_field) {
912 912
             $html_current_page = $current;
913 913
         } else {
914 914
             $html_current_page = sprintf(
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
             '<span class="total-pages">%s</span>',
924 924
             number_format_i18n($total_pages)
925 925
         );
926
-        $page_links[]     = sprintf(
926
+        $page_links[] = sprintf(
927 927
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
928 928
             $html_current_page,
929 929
             $html_total_pages,
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 
934 934
         $page_links[] = sprintf(
935 935
             '<a class="%s" title="%s" href="%s">%s</a>',
936
-            'next-page' . $disable_last,
936
+            'next-page'.$disable_last,
937 937
             esc_attr__('Go to the next page', 'event_espresso'),
938 938
             esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
939 939
             '&rsaquo;'
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
 
942 942
         $page_links[] = sprintf(
943 943
             '<a class="%s" title="%s" href="%s">%s</a>',
944
-            'last-page' . $disable_last,
944
+            'last-page'.$disable_last,
945 945
             esc_attr__('Go to the last page', 'event_espresso'),
946 946
             esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
947 947
             '&raquo;'
948 948
         );
949 949
 
950
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
950
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
951 951
         // set page class
952 952
         if ($total_pages) {
953 953
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
             $page_class = ' no-pages';
956 956
         }
957 957
 
958
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
958
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
959 959
     }
960 960
 
961 961
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         );
994 994
         $powered_by = apply_filters(
995 995
             'FHEE__EEH_Template__powered_by_event_espresso_text',
996
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
996
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
997 997
         );
998 998
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
999 999
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
      */
1023 1023
     public static function getScreenshotUrl($image_name)
1024 1024
     {
1025
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
1025
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
1026 1026
     }
1027 1027
 }
1028 1028
 
1029 1029
 
1030
-if (! function_exists('espresso_pagination')) {
1030
+if ( ! function_exists('espresso_pagination')) {
1031 1031
     /**
1032 1032
      *    espresso_pagination
1033 1033
      *
@@ -1055,6 +1055,6 @@  discard block
 block discarded – undo
1055 1055
                 'add_fragment' => '',
1056 1056
             ]
1057 1057
         );
1058
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1058
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
1059 1059
     }
1060 1060
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/IframeEmbedButton.php 1 patch
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -13,271 +13,271 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @var string $iframe_name
18
-     */
19
-    private $iframe_name;
16
+	/**
17
+	 * @var string $iframe_name
18
+	 */
19
+	private $iframe_name;
20 20
 
21
-    /**
22
-     * @var string $route_name
23
-     */
24
-    private $route_name;
21
+	/**
22
+	 * @var string $route_name
23
+	 */
24
+	private $route_name;
25 25
 
26
-    /**
27
-     * @var string $slug
28
-     */
29
-    private $slug;
26
+	/**
27
+	 * @var string $slug
28
+	 */
29
+	private $slug;
30 30
 
31
-    /**
32
-     * @var boolean $append_filterable_content
33
-     */
34
-    private $append_filterable_content;
31
+	/**
32
+	 * @var boolean $append_filterable_content
33
+	 */
34
+	private $append_filterable_content;
35 35
 
36 36
 
37
-    /**
38
-     * IframeEmbedButton constructor.
39
-     *
40
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
41
-     * @param string $route_name  the name of the registered route
42
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
43
-     *                            will most likely be "event" since that's the only usage atm
44
-     */
45
-    public function __construct($iframe_name, $route_name, $slug = 'event')
46
-    {
47
-        $this->iframe_name = $iframe_name;
48
-        $this->route_name = $route_name;
49
-        $this->slug = $slug;
50
-    }
37
+	/**
38
+	 * IframeEmbedButton constructor.
39
+	 *
40
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
41
+	 * @param string $route_name  the name of the registered route
42
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
43
+	 *                            will most likely be "event" since that's the only usage atm
44
+	 */
45
+	public function __construct($iframe_name, $route_name, $slug = 'event')
46
+	{
47
+		$this->iframe_name = $iframe_name;
48
+		$this->route_name = $route_name;
49
+		$this->slug = $slug;
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * Adds an iframe embed code button to the Event editor.
55
-     */
56
-    public function addEventEditorIframeEmbedButtonFilter()
57
-    {
58
-        // add button for iframe code to event editor.
59
-        add_filter(
60
-            'get_sample_permalink_html',
61
-            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
62
-            10,
63
-            2
64
-        );
65
-        add_action(
66
-            'admin_enqueue_scripts',
67
-            array($this, 'embedButtonAssets'),
68
-            10
69
-        );
70
-    }
53
+	/**
54
+	 * Adds an iframe embed code button to the Event editor.
55
+	 */
56
+	public function addEventEditorIframeEmbedButtonFilter()
57
+	{
58
+		// add button for iframe code to event editor.
59
+		add_filter(
60
+			'get_sample_permalink_html',
61
+			array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
62
+			10,
63
+			2
64
+		);
65
+		add_action(
66
+			'admin_enqueue_scripts',
67
+			array($this, 'embedButtonAssets'),
68
+			10
69
+		);
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * @param $permalink_string
75
-     * @param $id
76
-     * @return string
77
-     */
78
-    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
79
-    {
80
-        return $this->eventEditorIframeEmbedButton(
81
-            $permalink_string,
82
-            $id
83
-        );
84
-    }
73
+	/**
74
+	 * @param $permalink_string
75
+	 * @param $id
76
+	 * @return string
77
+	 */
78
+	public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
79
+	{
80
+		return $this->eventEditorIframeEmbedButton(
81
+			$permalink_string,
82
+			$id
83
+		);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * iframe embed code button to the Event editor.
89
-     *
90
-     * @param string $permalink_string
91
-     * @param int    $id
92
-     * @return string
93
-     */
94
-    public function eventEditorIframeEmbedButton(
95
-        $permalink_string,
96
-        $id
97
-    ) {
98
-        // make sure this is ONLY when editing and the event id has been set.
99
-        if (! empty($id)) {
100
-            $post = get_post($id);
101
-            // if NOT event then let's get out.
102
-            if ($post->post_type !== 'espresso_events') {
103
-                return $permalink_string;
104
-            }
105
-            $permalink_string .= $this->embedButtonHtml([$this->slug => $id]);
106
-        }
107
-        return $permalink_string;
108
-    }
87
+	/**
88
+	 * iframe embed code button to the Event editor.
89
+	 *
90
+	 * @param string $permalink_string
91
+	 * @param int    $id
92
+	 * @return string
93
+	 */
94
+	public function eventEditorIframeEmbedButton(
95
+		$permalink_string,
96
+		$id
97
+	) {
98
+		// make sure this is ONLY when editing and the event id has been set.
99
+		if (! empty($id)) {
100
+			$post = get_post($id);
101
+			// if NOT event then let's get out.
102
+			if ($post->post_type !== 'espresso_events') {
103
+				return $permalink_string;
104
+			}
105
+			$permalink_string .= $this->embedButtonHtml([$this->slug => $id]);
106
+		}
107
+		return $permalink_string;
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
113
-     *
114
-     * @param string $action name of the WP do_action() to hook into
115
-     */
116
-    public function addActionIframeEmbedButton($action)
117
-    {
118
-        // add button for iframe code to event editor.
119
-        add_action(
120
-            $action,
121
-            array($this, 'addActionIframeEmbedButtonCallback'),
122
-            10,
123
-            2
124
-        );
125
-    }
111
+	/**
112
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
113
+	 *
114
+	 * @param string $action name of the WP do_action() to hook into
115
+	 */
116
+	public function addActionIframeEmbedButton($action)
117
+	{
118
+		// add button for iframe code to event editor.
119
+		add_action(
120
+			$action,
121
+			array($this, 'addActionIframeEmbedButtonCallback'),
122
+			10,
123
+			2
124
+		);
125
+	}
126 126
 
127 127
 
128
-    /**
129
-     * @return void
130
-     */
131
-    public function addActionIframeEmbedButtonCallback()
132
-    {
133
-        echo $this->embedButtonHtml(); // already escaped
134
-    }
128
+	/**
129
+	 * @return void
130
+	 */
131
+	public function addActionIframeEmbedButtonCallback()
132
+	{
133
+		echo $this->embedButtonHtml(); // already escaped
134
+	}
135 135
 
136 136
 
137
-    /**
138
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
139
-     *
140
-     * @param string $filter     name of the WP apply_filters() to hook into
141
-     * @param bool   $append     if true, will add iframe embed button to end of content,
142
-     *                           else if false, will add to the beginning of the content
143
-     */
144
-    public function addFilterIframeEmbedButton($filter, $append = true)
145
-    {
146
-        $this->append_filterable_content = $append;
147
-        // add button for iframe code to event editor.
148
-        add_filter(
149
-            $filter,
150
-            array($this, 'addFilterIframeEmbedButtonCallback'),
151
-            10
152
-        );
153
-    }
137
+	/**
138
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
139
+	 *
140
+	 * @param string $filter     name of the WP apply_filters() to hook into
141
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
142
+	 *                           else if false, will add to the beginning of the content
143
+	 */
144
+	public function addFilterIframeEmbedButton($filter, $append = true)
145
+	{
146
+		$this->append_filterable_content = $append;
147
+		// add button for iframe code to event editor.
148
+		add_filter(
149
+			$filter,
150
+			array($this, 'addFilterIframeEmbedButtonCallback'),
151
+			10
152
+		);
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * @param array|string $filterable_content
158
-     * @return array|string
159
-     */
160
-    public function addFilterIframeEmbedButtonCallback($filterable_content)
161
-    {
162
-        $embedButtonHtml = $this->embedButtonHtml();
163
-        if (is_array($filterable_content)) {
164
-            $filterable_content = $this->append_filterable_content
165
-                ? $filterable_content + array($this->route_name => $embedButtonHtml)
166
-                : array($this->route_name => $embedButtonHtml) + $filterable_content;
167
-        } else {
168
-            $filterable_content = $this->append_filterable_content
169
-                ? $filterable_content . $embedButtonHtml
170
-                : $embedButtonHtml . $filterable_content;
171
-        }
172
-        return $filterable_content;
173
-    }
156
+	/**
157
+	 * @param array|string $filterable_content
158
+	 * @return array|string
159
+	 */
160
+	public function addFilterIframeEmbedButtonCallback($filterable_content)
161
+	{
162
+		$embedButtonHtml = $this->embedButtonHtml();
163
+		if (is_array($filterable_content)) {
164
+			$filterable_content = $this->append_filterable_content
165
+				? $filterable_content + array($this->route_name => $embedButtonHtml)
166
+				: array($this->route_name => $embedButtonHtml) + $filterable_content;
167
+		} else {
168
+			$filterable_content = $this->append_filterable_content
169
+				? $filterable_content . $embedButtonHtml
170
+				: $embedButtonHtml . $filterable_content;
171
+		}
172
+		return $filterable_content;
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * iframe_embed_html
178
-     *
179
-     * @param array  $query_args
180
-     * @param string $button_class
181
-     * @return string
182
-     */
183
-    public function embedButtonHtml($query_args = array(), $button_class = '')
184
-    {
185
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
186
-        $query_args = (array) $query_args + array($this->route_name => 'iframe');
187
-        $query_args = (array) apply_filters(
188
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
189
-            $query_args
190
-        );
191
-        // add this route to our localized vars
192
-        $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
193
-            ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
194
-            : array();
195
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
196
-        \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
197
-        $iframe_embed_html = \EEH_HTML::link(
198
-            '#',
199
-            sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
200
-            sprintf(
201
-                esc_html__(
202
-                    'click here to generate code for embedding %1$s iframe into another site.',
203
-                    'event_espresso'
204
-                ),
205
-                \EEH_Inflector::add_indefinite_article($this->iframe_name)
206
-            ),
207
-            esc_attr($this->route_name) . "-iframe-embed-trigger-js",
208
-            'iframe-embed-trigger-js button button--secondary ' . esc_attr($button_class),
209
-            '',
210
-            ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
211
-        );
212
-        $iframe_embed_html .= \EEH_HTML::div(
213
-            '',
214
-            esc_attr($this->route_name) . "-iframe-js",
215
-            'iframe-embed-wrapper-js',
216
-            'display:none;'
217
-        );
218
-        $iframe_embed_html .= esc_html(
219
-            \EEH_HTML::div(
220
-                '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
221
-                '',
222
-                '',
223
-                'width:100%; height: 500px;'
224
-            )
225
-        );
226
-        $iframe_embed_html .= \EEH_HTML::divx();
227
-        return $iframe_embed_html;
228
-    }
176
+	/**
177
+	 * iframe_embed_html
178
+	 *
179
+	 * @param array  $query_args
180
+	 * @param string $button_class
181
+	 * @return string
182
+	 */
183
+	public function embedButtonHtml($query_args = array(), $button_class = '')
184
+	{
185
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
186
+		$query_args = (array) $query_args + array($this->route_name => 'iframe');
187
+		$query_args = (array) apply_filters(
188
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
189
+			$query_args
190
+		);
191
+		// add this route to our localized vars
192
+		$iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
193
+			? \EE_Registry::$i18n_js_strings['iframe_module_routes']
194
+			: array();
195
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
196
+		\EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
197
+		$iframe_embed_html = \EEH_HTML::link(
198
+			'#',
199
+			sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
200
+			sprintf(
201
+				esc_html__(
202
+					'click here to generate code for embedding %1$s iframe into another site.',
203
+					'event_espresso'
204
+				),
205
+				\EEH_Inflector::add_indefinite_article($this->iframe_name)
206
+			),
207
+			esc_attr($this->route_name) . "-iframe-embed-trigger-js",
208
+			'iframe-embed-trigger-js button button--secondary ' . esc_attr($button_class),
209
+			'',
210
+			' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
211
+		);
212
+		$iframe_embed_html .= \EEH_HTML::div(
213
+			'',
214
+			esc_attr($this->route_name) . "-iframe-js",
215
+			'iframe-embed-wrapper-js',
216
+			'display:none;'
217
+		);
218
+		$iframe_embed_html .= esc_html(
219
+			\EEH_HTML::div(
220
+				'<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
221
+				'',
222
+				'',
223
+				'width:100%; height: 500px;'
224
+			)
225
+		);
226
+		$iframe_embed_html .= \EEH_HTML::divx();
227
+		return $iframe_embed_html;
228
+	}
229 229
 
230 230
 
231
-    /**
232
-     * enqueue iframe button js
233
-     */
234
-    public function embedButtonAssets()
235
-    {
236
-        \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
237
-            'copy and paste the following into any other site\'s content to display this event:',
238
-            'event_espresso'
239
-        );
240
-        \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
241
-            'click anywhere outside of this window to close it.',
242
-            'event_espresso'
243
-        );
244
-        wp_register_script(
245
-            'iframe_embed_button',
246
-            plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
247
-            array('ee-dialog'),
248
-            EVENT_ESPRESSO_VERSION,
249
-            true
250
-        );
251
-        wp_enqueue_script('iframe_embed_button');
252
-    }
231
+	/**
232
+	 * enqueue iframe button js
233
+	 */
234
+	public function embedButtonAssets()
235
+	{
236
+		\EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
237
+			'copy and paste the following into any other site\'s content to display this event:',
238
+			'event_espresso'
239
+		);
240
+		\EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
241
+			'click anywhere outside of this window to close it.',
242
+			'event_espresso'
243
+		);
244
+		wp_register_script(
245
+			'iframe_embed_button',
246
+			plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
247
+			array('ee-dialog'),
248
+			EVENT_ESPRESSO_VERSION,
249
+			true
250
+		);
251
+		wp_enqueue_script('iframe_embed_button');
252
+	}
253 253
 
254 254
 
255
-    /**
256
-     * generates embed button sections for admin pages
257
-     *
258
-     * @param array $embed_buttons
259
-     * @return string
260
-     */
261
-    public function addIframeEmbedButtonsSection(array $embed_buttons)
262
-    {
263
-        $embed_buttons = (array) apply_filters(
264
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
265
-            $embed_buttons
266
-        );
267
-        if (empty($embed_buttons)) {
268
-            return '';
269
-        }
270
-        // add button for iframe code to event editor.
271
-        $html = \EEH_HTML::br(2);
272
-        $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
273
-        $html .= \EEH_HTML::p(
274
-            esc_html__(
275
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
276
-                'event_espresso'
277
-            )
278
-        );
279
-        $html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
280
-        $html .= \EEH_HTML::br(2);
281
-        return $html;
282
-    }
255
+	/**
256
+	 * generates embed button sections for admin pages
257
+	 *
258
+	 * @param array $embed_buttons
259
+	 * @return string
260
+	 */
261
+	public function addIframeEmbedButtonsSection(array $embed_buttons)
262
+	{
263
+		$embed_buttons = (array) apply_filters(
264
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
265
+			$embed_buttons
266
+		);
267
+		if (empty($embed_buttons)) {
268
+			return '';
269
+		}
270
+		// add button for iframe code to event editor.
271
+		$html = \EEH_HTML::br(2);
272
+		$html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
273
+		$html .= \EEH_HTML::p(
274
+			esc_html__(
275
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
276
+				'event_espresso'
277
+			)
278
+		);
279
+		$html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
280
+		$html .= \EEH_HTML::br(2);
281
+		return $html;
282
+	}
283 283
 }
Please login to merge, or discard this patch.
line_item_display/EE_Admin_Table_Line_Item_Display_Strategy.strategy.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -13,358 +13,358 @@
 block discarded – undo
13 13
 
14 14
 class EE_Admin_Table_Line_Item_Display_Strategy implements EEI_Line_Item_Display
15 15
 {
16
-    /**
17
-     * @var bool
18
-     */
19
-    protected $prices_include_taxes = false;
20
-
21
-    /**
22
-     * whether to display the taxes row or not
23
-     *
24
-     * @var bool
25
-     */
26
-    protected $_show_taxes = false;
27
-
28
-
29
-    /**
30
-     * html for any tax rows
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_taxes_html = '';
35
-
36
-
37
-    /**
38
-     * total amount including tax we can bill for at this time
39
-     *
40
-     * @var float $_grand_total
41
-     */
42
-    protected $_grand_total = 0.00;
43
-
44
-
45
-    public function __construct()
46
-    {
47
-        $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes;
48
-    }
49
-
50
-    /**
51
-     * @return float
52
-     */
53
-    public function grand_total()
54
-    {
55
-        return $this->_grand_total;
56
-    }
57
-
58
-
59
-    /**
60
-     * This is used to output a single
61
-     * @param EE_Line_Item $line_item
62
-     * @param array        $options
63
-     * @return mixed
64
-     */
65
-    public function display_line_item(EE_Line_Item $line_item, $options = array())
66
-    {
67
-        $html = '';
68
-        // set some default options and merge with incoming
69
-        $default_options = array(
70
-            'use_table_wrapper' => true,
71
-            'table_css_class' => 'admin-primary-mbox-tbl striped',
72
-            'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr',
73
-            'total_tr_css_class' => 'admin-primary-mbox-total-tr'
74
-        );
75
-        $options = array_merge($default_options, (array) $options);
76
-
77
-        switch ($line_item->type()) {
78
-            case EEM_Line_Item::type_line_item:
79
-                // item row
80
-                $html .= $this->_item_row($line_item, $options);
81
-                break;
82
-
83
-            case EEM_Line_Item::type_sub_line_item:
84
-                $html .= $this->_sub_item_row($line_item, $options);
85
-                break;
86
-
87
-            case EEM_Line_Item::type_sub_total:
88
-                if ($line_item->quantity() === 0) {
89
-                    return $html;
90
-                }
91
-                // loop through children
92
-                $child_line_items = $line_item->children();
93
-                // loop through children
94
-                foreach ($child_line_items as $child_line_item) {
95
-                    // recursively feed children back into this method
96
-                    $html .= $this->display_line_item($child_line_item, $options);
97
-                }
98
-                $html .= $this->_sub_total_row($line_item, $options);
99
-                break;
100
-
101
-            case EEM_Line_Item::type_tax:
102
-                if ($this->_show_taxes) {
103
-                    $this->_taxes_html .= $this->_tax_row($line_item, $options);
104
-                }
105
-                break;
106
-
107
-            case EEM_Line_Item::type_tax_sub_total:
108
-                foreach ($line_item->children() as $child_line_item) {
109
-                    if ($child_line_item->type() == EEM_Line_Item::type_tax) {
110
-                        $this->display_line_item($child_line_item, $options);
111
-                    }
112
-                }
113
-                break;
114
-
115
-            case EEM_Line_Item::type_total:
116
-                // determine whether to display taxes or not
117
-                $this->_show_taxes = $line_item->get_total_tax() > 0 ? true : false;
118
-                // get all child line items
119
-                $children = $line_item->children();
120
-
121
-                // loop thru all non-tax child line items
122
-                foreach ($children as $child_line_item) {
123
-                        $html .= $this->display_line_item($child_line_item, $options);
124
-                }
125
-
126
-                $html .= $this->_taxes_html;
127
-                $html .= $this->_total_row($line_item, $options);
128
-                if ($options['use_table_wrapper']) {
129
-                    $html = $this->_table_header($options) . $html . $this->_table_footer($options);
130
-                }
131
-                break;
132
-        }
133
-
134
-        return $html;
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * Table header for display.
141
-     * @since   4.8
142
-     * @param array $options
143
-     * @return string
144
-     */
145
-    protected function _table_header($options)
146
-    {
147
-        $html = EEH_HTML::table('', '', $options['table_css_class']);
148
-        $html .= EEH_HTML::thead();
149
-        $html .= EEH_HTML::tr();
150
-        $html .= EEH_HTML::th(esc_html__('Name', 'event_espresso'), '', 'jst-left');
151
-        $html .= EEH_HTML::th(esc_html__('Type', 'event_espresso'), '', 'jst-left');
152
-        $html .= EEH_HTML::th(esc_html__('Amount', 'event_espresso'), '', 'jst-rght');
153
-        $html .= EEH_HTML::th(esc_html__('Qty', 'event_espresso'), '', 'jst-rght');
154
-        $html .= EEH_HTML::th(esc_html__('Line Total', 'event_espresso'), '', 'jst-rght');
155
-        $html .= EEH_HTML::tbody();
156
-        return $html;
157
-    }
158
-
159
-
160
-    /**
161
-     * Table footer for display
162
-     * @since 4.8
163
-     * @param array $options array of options for the table.
164
-     * @return string
165
-     */
166
-    protected function _table_footer($options)
167
-    {
168
-        return EEH_HTML::tbodyx() .  EEH_HTML::tablex();
169
-    }
170
-
171
-
172
-
173
-    /**
174
-     *    _item_row
175
-     *
176
-     * @param EE_Line_Item $line_item
177
-     * @param array        $options
178
-     * @return mixed
179
-     */
180
-    protected function _item_row(EE_Line_Item $line_item, $options = array())
181
-    {
182
-        $line_item_related_object = $line_item->get_object();
183
-        $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null;
184
-        // start of row
185
-        $html = EEH_HTML::tr('', '', 'item');
186
-
187
-
188
-        // Name Column
189
-        $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
190
-
191
-        // related object scope.
192
-        $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : '';
193
-        $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name;
194
-        $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : '';
195
-
196
-
197
-        $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name();
198
-        $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html;
199
-        $name_html .= $line_item->is_taxable() ? ' *' : '';
200
-        // maybe preface with icon?
201
-        $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html;
202
-        $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
203
-        $name_html .=  sprintf(
204
-            _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
205
-            '<span class="ee-line-item-related-parent-object">',
206
-            $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : esc_html__('Item:', 'event_espresso'),
207
-            $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name,
208
-            '</span>'
209
-        );
210
-
211
-        $name_html = apply_filters(
212
-            'FHEE__EE_Admin_Table_Line_Item_Display_Strategy___item_row__name_html',
213
-            $name_html,
214
-            $line_item,
215
-            $options
216
-        );
217
-
218
-        $html .= EEH_HTML::td($name_html, '', 'ee-line-item-name-td jst-left');
219
-        // Type Column
220
-        $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
221
-        $type_html .= $this->_get_cancellations($line_item);
222
-        $type_html .= $line_item->OBJ_type() ? '<br />' : '';
223
-        $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
224
-        $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(esc_html__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
225
-        $html .= EEH_HTML::td($type_html, '', 'ee-line-item-type-td jst-left');
226
-
227
-
228
-        // Amount Column
229
-        if ($line_item->is_percent()) {
230
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'ee-line-item-amount-td jst-rght');
231
-        } else {
232
-            $include_taxes = $this->prices_include_taxes
233
-                ? '<br /><span class="grey-text">'
234
-                  . sprintf(
235
-                      /* translators: 1: money amount like $123 */
236
-                      esc_html__('%1$s before taxes', 'event_espresso'),
237
-                      $line_item->pretaxTotal() / $line_item->quantity()
238
-                  )
239
-                  . '</span>'
240
-                : '';
241
-            $price = $line_item->unit_price_no_code();
242
-            $html .= EEH_HTML::td($price . $include_taxes, '', 'ee-line-item-amount-td jst-rght');
243
-        }
244
-
245
-        // QTY column
246
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'ee-line-item-quantity-td jst-rght');
247
-
248
-        // total column
249
-        $total = EEH_Template::format_currency($line_item->pretaxTotal(), false, false);
250
-        $html .= EEH_HTML::td($total, '', 'ee-line-item-total-td jst-rght');
251
-
252
-        // finish things off and return
253
-        $html .= EEH_HTML::trx();
254
-        return $html;
255
-    }
256
-
257
-
258
-
259
-    /**
260
-     *    _get_cancellations
261
-     *
262
-     * @param EE_Line_Item $line_item
263
-     * @return string
264
-     */
265
-    protected function _get_cancellations(EE_Line_Item $line_item)
266
-    {
267
-        $html = '';
268
-        $cancellations = $line_item->get_cancellations();
269
-        $cancellation = reset($cancellations);
270
-        if ($cancellation instanceof EE_Line_Item) {
271
-            $html .= ' <span class="ee-line-item-id">';
272
-            $html .= sprintf(
273
-                _n(
274
-                    '(%1$s Cancellation)',
275
-                    '(%1$s Cancellations)',
276
-                    $cancellation->quantity(),
277
-                    'event_espresso'
278
-                ),
279
-                $cancellation->quantity()
280
-            );
281
-            $html .= '</span>';
282
-        }
283
-        return $html;
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     *  _sub_item_row
290
-     *
291
-     * @param EE_Line_Item $line_item
292
-     * @param array        $options
293
-     * @return mixed
294
-     */
295
-    protected function _sub_item_row(EE_Line_Item $line_item, $options = array())
296
-    {
297
-        // for now we're not showing sub-items
298
-        return '';
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     *  _tax_row
305
-     *
306
-     * @param EE_Line_Item $line_item
307
-     * @param array        $options
308
-     * @return mixed
309
-     */
310
-    protected function _tax_row(EE_Line_Item $line_item, $options = array())
311
-    {
312
-        // start of row
313
-        $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
314
-        // name th
315
-        $tax_details = $line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)';
316
-        $html .= EEH_HTML::th(
317
-            $tax_details,
318
-            '',
319
-            'jst-rght',
320
-            '',
321
-            ' colspan="4"'
322
-        );
323
-        // total th
324
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
325
-        // end of row
326
-        $html .= EEH_HTML::trx();
327
-        return $html;
328
-    }
329
-
330
-
331
-
332
-
333
-    /**
334
-     *  _total_row
335
-     *
336
-     * @param EE_Line_Item $line_item
337
-     * @param string       $text
338
-     * @param array        $options
339
-     * @return mixed
340
-     */
341
-    protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
342
-    {
343
-        // currently not showing subtotal row
344
-        return '';
345
-    }
346
-
347
-
348
-
349
-    /**
350
-     *  _total_row
351
-     *
352
-     * @param EE_Line_Item $line_item
353
-     * @param array        $options
354
-     * @return mixed
355
-     */
356
-    protected function _total_row(EE_Line_Item $line_item, $options = array())
357
-    {
358
-        // start of row
359
-        $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
360
-        // Total th label
361
-        $total_label = sprintf(esc_html__('Transaction Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
362
-        $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"');
363
-        // total th
364
-
365
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
366
-        // end of row
367
-        $html .= EEH_HTML::trx();
368
-        return $html;
369
-    }
16
+	/**
17
+	 * @var bool
18
+	 */
19
+	protected $prices_include_taxes = false;
20
+
21
+	/**
22
+	 * whether to display the taxes row or not
23
+	 *
24
+	 * @var bool
25
+	 */
26
+	protected $_show_taxes = false;
27
+
28
+
29
+	/**
30
+	 * html for any tax rows
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_taxes_html = '';
35
+
36
+
37
+	/**
38
+	 * total amount including tax we can bill for at this time
39
+	 *
40
+	 * @var float $_grand_total
41
+	 */
42
+	protected $_grand_total = 0.00;
43
+
44
+
45
+	public function __construct()
46
+	{
47
+		$this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes;
48
+	}
49
+
50
+	/**
51
+	 * @return float
52
+	 */
53
+	public function grand_total()
54
+	{
55
+		return $this->_grand_total;
56
+	}
57
+
58
+
59
+	/**
60
+	 * This is used to output a single
61
+	 * @param EE_Line_Item $line_item
62
+	 * @param array        $options
63
+	 * @return mixed
64
+	 */
65
+	public function display_line_item(EE_Line_Item $line_item, $options = array())
66
+	{
67
+		$html = '';
68
+		// set some default options and merge with incoming
69
+		$default_options = array(
70
+			'use_table_wrapper' => true,
71
+			'table_css_class' => 'admin-primary-mbox-tbl striped',
72
+			'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr',
73
+			'total_tr_css_class' => 'admin-primary-mbox-total-tr'
74
+		);
75
+		$options = array_merge($default_options, (array) $options);
76
+
77
+		switch ($line_item->type()) {
78
+			case EEM_Line_Item::type_line_item:
79
+				// item row
80
+				$html .= $this->_item_row($line_item, $options);
81
+				break;
82
+
83
+			case EEM_Line_Item::type_sub_line_item:
84
+				$html .= $this->_sub_item_row($line_item, $options);
85
+				break;
86
+
87
+			case EEM_Line_Item::type_sub_total:
88
+				if ($line_item->quantity() === 0) {
89
+					return $html;
90
+				}
91
+				// loop through children
92
+				$child_line_items = $line_item->children();
93
+				// loop through children
94
+				foreach ($child_line_items as $child_line_item) {
95
+					// recursively feed children back into this method
96
+					$html .= $this->display_line_item($child_line_item, $options);
97
+				}
98
+				$html .= $this->_sub_total_row($line_item, $options);
99
+				break;
100
+
101
+			case EEM_Line_Item::type_tax:
102
+				if ($this->_show_taxes) {
103
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
104
+				}
105
+				break;
106
+
107
+			case EEM_Line_Item::type_tax_sub_total:
108
+				foreach ($line_item->children() as $child_line_item) {
109
+					if ($child_line_item->type() == EEM_Line_Item::type_tax) {
110
+						$this->display_line_item($child_line_item, $options);
111
+					}
112
+				}
113
+				break;
114
+
115
+			case EEM_Line_Item::type_total:
116
+				// determine whether to display taxes or not
117
+				$this->_show_taxes = $line_item->get_total_tax() > 0 ? true : false;
118
+				// get all child line items
119
+				$children = $line_item->children();
120
+
121
+				// loop thru all non-tax child line items
122
+				foreach ($children as $child_line_item) {
123
+						$html .= $this->display_line_item($child_line_item, $options);
124
+				}
125
+
126
+				$html .= $this->_taxes_html;
127
+				$html .= $this->_total_row($line_item, $options);
128
+				if ($options['use_table_wrapper']) {
129
+					$html = $this->_table_header($options) . $html . $this->_table_footer($options);
130
+				}
131
+				break;
132
+		}
133
+
134
+		return $html;
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * Table header for display.
141
+	 * @since   4.8
142
+	 * @param array $options
143
+	 * @return string
144
+	 */
145
+	protected function _table_header($options)
146
+	{
147
+		$html = EEH_HTML::table('', '', $options['table_css_class']);
148
+		$html .= EEH_HTML::thead();
149
+		$html .= EEH_HTML::tr();
150
+		$html .= EEH_HTML::th(esc_html__('Name', 'event_espresso'), '', 'jst-left');
151
+		$html .= EEH_HTML::th(esc_html__('Type', 'event_espresso'), '', 'jst-left');
152
+		$html .= EEH_HTML::th(esc_html__('Amount', 'event_espresso'), '', 'jst-rght');
153
+		$html .= EEH_HTML::th(esc_html__('Qty', 'event_espresso'), '', 'jst-rght');
154
+		$html .= EEH_HTML::th(esc_html__('Line Total', 'event_espresso'), '', 'jst-rght');
155
+		$html .= EEH_HTML::tbody();
156
+		return $html;
157
+	}
158
+
159
+
160
+	/**
161
+	 * Table footer for display
162
+	 * @since 4.8
163
+	 * @param array $options array of options for the table.
164
+	 * @return string
165
+	 */
166
+	protected function _table_footer($options)
167
+	{
168
+		return EEH_HTML::tbodyx() .  EEH_HTML::tablex();
169
+	}
170
+
171
+
172
+
173
+	/**
174
+	 *    _item_row
175
+	 *
176
+	 * @param EE_Line_Item $line_item
177
+	 * @param array        $options
178
+	 * @return mixed
179
+	 */
180
+	protected function _item_row(EE_Line_Item $line_item, $options = array())
181
+	{
182
+		$line_item_related_object = $line_item->get_object();
183
+		$parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null;
184
+		// start of row
185
+		$html = EEH_HTML::tr('', '', 'item');
186
+
187
+
188
+		// Name Column
189
+		$name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
190
+
191
+		// related object scope.
192
+		$parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : '';
193
+		$parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name;
194
+		$parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : '';
195
+
196
+
197
+		$name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name();
198
+		$name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html;
199
+		$name_html .= $line_item->is_taxable() ? ' *' : '';
200
+		// maybe preface with icon?
201
+		$name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html;
202
+		$name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
203
+		$name_html .=  sprintf(
204
+			_x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
205
+			'<span class="ee-line-item-related-parent-object">',
206
+			$line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : esc_html__('Item:', 'event_espresso'),
207
+			$parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name,
208
+			'</span>'
209
+		);
210
+
211
+		$name_html = apply_filters(
212
+			'FHEE__EE_Admin_Table_Line_Item_Display_Strategy___item_row__name_html',
213
+			$name_html,
214
+			$line_item,
215
+			$options
216
+		);
217
+
218
+		$html .= EEH_HTML::td($name_html, '', 'ee-line-item-name-td jst-left');
219
+		// Type Column
220
+		$type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
221
+		$type_html .= $this->_get_cancellations($line_item);
222
+		$type_html .= $line_item->OBJ_type() ? '<br />' : '';
223
+		$code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
224
+		$type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(esc_html__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
225
+		$html .= EEH_HTML::td($type_html, '', 'ee-line-item-type-td jst-left');
226
+
227
+
228
+		// Amount Column
229
+		if ($line_item->is_percent()) {
230
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'ee-line-item-amount-td jst-rght');
231
+		} else {
232
+			$include_taxes = $this->prices_include_taxes
233
+				? '<br /><span class="grey-text">'
234
+				  . sprintf(
235
+					  /* translators: 1: money amount like $123 */
236
+					  esc_html__('%1$s before taxes', 'event_espresso'),
237
+					  $line_item->pretaxTotal() / $line_item->quantity()
238
+				  )
239
+				  . '</span>'
240
+				: '';
241
+			$price = $line_item->unit_price_no_code();
242
+			$html .= EEH_HTML::td($price . $include_taxes, '', 'ee-line-item-amount-td jst-rght');
243
+		}
244
+
245
+		// QTY column
246
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'ee-line-item-quantity-td jst-rght');
247
+
248
+		// total column
249
+		$total = EEH_Template::format_currency($line_item->pretaxTotal(), false, false);
250
+		$html .= EEH_HTML::td($total, '', 'ee-line-item-total-td jst-rght');
251
+
252
+		// finish things off and return
253
+		$html .= EEH_HTML::trx();
254
+		return $html;
255
+	}
256
+
257
+
258
+
259
+	/**
260
+	 *    _get_cancellations
261
+	 *
262
+	 * @param EE_Line_Item $line_item
263
+	 * @return string
264
+	 */
265
+	protected function _get_cancellations(EE_Line_Item $line_item)
266
+	{
267
+		$html = '';
268
+		$cancellations = $line_item->get_cancellations();
269
+		$cancellation = reset($cancellations);
270
+		if ($cancellation instanceof EE_Line_Item) {
271
+			$html .= ' <span class="ee-line-item-id">';
272
+			$html .= sprintf(
273
+				_n(
274
+					'(%1$s Cancellation)',
275
+					'(%1$s Cancellations)',
276
+					$cancellation->quantity(),
277
+					'event_espresso'
278
+				),
279
+				$cancellation->quantity()
280
+			);
281
+			$html .= '</span>';
282
+		}
283
+		return $html;
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 *  _sub_item_row
290
+	 *
291
+	 * @param EE_Line_Item $line_item
292
+	 * @param array        $options
293
+	 * @return mixed
294
+	 */
295
+	protected function _sub_item_row(EE_Line_Item $line_item, $options = array())
296
+	{
297
+		// for now we're not showing sub-items
298
+		return '';
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 *  _tax_row
305
+	 *
306
+	 * @param EE_Line_Item $line_item
307
+	 * @param array        $options
308
+	 * @return mixed
309
+	 */
310
+	protected function _tax_row(EE_Line_Item $line_item, $options = array())
311
+	{
312
+		// start of row
313
+		$html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
314
+		// name th
315
+		$tax_details = $line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)';
316
+		$html .= EEH_HTML::th(
317
+			$tax_details,
318
+			'',
319
+			'jst-rght',
320
+			'',
321
+			' colspan="4"'
322
+		);
323
+		// total th
324
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
325
+		// end of row
326
+		$html .= EEH_HTML::trx();
327
+		return $html;
328
+	}
329
+
330
+
331
+
332
+
333
+	/**
334
+	 *  _total_row
335
+	 *
336
+	 * @param EE_Line_Item $line_item
337
+	 * @param string       $text
338
+	 * @param array        $options
339
+	 * @return mixed
340
+	 */
341
+	protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
342
+	{
343
+		// currently not showing subtotal row
344
+		return '';
345
+	}
346
+
347
+
348
+
349
+	/**
350
+	 *  _total_row
351
+	 *
352
+	 * @param EE_Line_Item $line_item
353
+	 * @param array        $options
354
+	 * @return mixed
355
+	 */
356
+	protected function _total_row(EE_Line_Item $line_item, $options = array())
357
+	{
358
+		// start of row
359
+		$html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
360
+		// Total th label
361
+		$total_label = sprintf(esc_html__('Transaction Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
362
+		$html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"');
363
+		// total th
364
+
365
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
366
+		// end of row
367
+		$html .= EEH_HTML::trx();
368
+		return $html;
369
+	}
370 370
 }
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1221 added lines, -1221 removed lines patch added patch discarded remove patch
@@ -16,1278 +16,1278 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * This is used to hold the reports template data which is setup early in the request.
21
-     *
22
-     * @type array
23
-     */
24
-    protected $_reports_template_data = array();
19
+	/**
20
+	 * This is used to hold the reports template data which is setup early in the request.
21
+	 *
22
+	 * @type array
23
+	 */
24
+	protected $_reports_template_data = array();
25 25
 
26 26
 
27
-    /**
28
-     * Extend_Registrations_Admin_Page constructor.
29
-     *
30
-     * @param bool $routing
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
-        }
40
-    }
27
+	/**
28
+	 * Extend_Registrations_Admin_Page constructor.
29
+	 *
30
+	 * @param bool $routing
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
+		}
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Extending page configuration.
45
-     */
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        $new_page_routes = array(
53
-            'reports'                      => array(
54
-                'func'       => '_registration_reports',
55
-                'capability' => 'ee_read_registrations',
56
-            ),
57
-            'registration_checkins'        => array(
58
-                'func'       => '_registration_checkin_list_table',
59
-                'capability' => 'ee_read_checkins',
60
-            ),
61
-            'newsletter_selected_send'     => array(
62
-                'func'       => '_newsletter_selected_send',
63
-                'noheader'   => true,
64
-                'capability' => 'ee_send_message',
65
-            ),
66
-            'delete_checkin_rows'          => array(
67
-                'func'       => '_delete_checkin_rows',
68
-                'noheader'   => true,
69
-                'capability' => 'ee_delete_checkins',
70
-            ),
71
-            'delete_checkin_row'           => array(
72
-                'func'       => '_delete_checkin_row',
73
-                'noheader'   => true,
74
-                'capability' => 'ee_delete_checkin',
75
-                'obj_id'     => $reg_id,
76
-            ),
77
-            'toggle_checkin_status'        => array(
78
-                'func'       => '_toggle_checkin_status',
79
-                'noheader'   => true,
80
-                'capability' => 'ee_edit_checkin',
81
-                'obj_id'     => $reg_id,
82
-            ),
83
-            'toggle_checkin_status_bulk'   => array(
84
-                'func'       => '_toggle_checkin_status',
85
-                'noheader'   => true,
86
-                'capability' => 'ee_edit_checkins',
87
-            ),
88
-            'event_registrations'          => array(
89
-                'func'       => '_event_registrations_list_table',
90
-                'capability' => 'ee_read_checkins',
91
-            ),
92
-            'registrations_checkin_report' => array(
93
-                'func'       => '_registrations_checkin_report',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_read_registrations',
96
-            ),
97
-        );
98
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
-        $new_page_config = array(
100
-            'reports'               => array(
101
-                'nav'           => array(
102
-                    'label' => esc_html__('Reports', 'event_espresso'),
103
-                    'order' => 30,
104
-                ),
105
-                'help_tabs'     => array(
106
-                    'registrations_reports_help_tab' => array(
107
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
-                        'filename' => 'registrations_reports',
109
-                    ),
110
-                ),
111
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
-                'require_nonce' => false,
113
-            ),
114
-            'event_registrations'   => array(
115
-                'nav'           => array(
116
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
-                    'order'      => 10,
118
-                    'persistent' => true,
119
-                ),
120
-                'help_tabs'     => array(
121
-                    'registrations_event_checkin_help_tab'                       => array(
122
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
-                        'filename' => 'registrations_event_checkin',
124
-                    ),
125
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
126
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
-                        'filename' => 'registrations_event_checkin_table_column_headings',
128
-                    ),
129
-                    'registrations_event_checkin_filters_help_tab'               => array(
130
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
-                        'filename' => 'registrations_event_checkin_filters',
132
-                    ),
133
-                    'registrations_event_checkin_views_help_tab'                 => array(
134
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
-                        'filename' => 'registrations_event_checkin_views',
136
-                    ),
137
-                    'registrations_event_checkin_other_help_tab'                 => array(
138
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
-                        'filename' => 'registrations_event_checkin_other',
140
-                    ),
141
-                ),
142
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
143
-                // 'help_tour'     => array('Event_Checkin_Help_Tour'),
144
-                'qtips'         => array('Registration_List_Table_Tips'),
145
-                'list_table'    => 'EE_Event_Registrations_List_Table',
146
-                'metaboxes'     => array(),
147
-                'require_nonce' => false,
148
-            ),
149
-            'registration_checkins' => array(
150
-                'nav'           => array(
151
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
-                    'order'      => 15,
153
-                    'persistent' => false,
154
-                    'url'        => '',
155
-                ),
156
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
-                // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
158
-                'metaboxes'     => array(),
159
-                'require_nonce' => false,
160
-            ),
161
-        );
162
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
163
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
164
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
165
-    }
43
+	/**
44
+	 * Extending page configuration.
45
+	 */
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		$new_page_routes = array(
53
+			'reports'                      => array(
54
+				'func'       => '_registration_reports',
55
+				'capability' => 'ee_read_registrations',
56
+			),
57
+			'registration_checkins'        => array(
58
+				'func'       => '_registration_checkin_list_table',
59
+				'capability' => 'ee_read_checkins',
60
+			),
61
+			'newsletter_selected_send'     => array(
62
+				'func'       => '_newsletter_selected_send',
63
+				'noheader'   => true,
64
+				'capability' => 'ee_send_message',
65
+			),
66
+			'delete_checkin_rows'          => array(
67
+				'func'       => '_delete_checkin_rows',
68
+				'noheader'   => true,
69
+				'capability' => 'ee_delete_checkins',
70
+			),
71
+			'delete_checkin_row'           => array(
72
+				'func'       => '_delete_checkin_row',
73
+				'noheader'   => true,
74
+				'capability' => 'ee_delete_checkin',
75
+				'obj_id'     => $reg_id,
76
+			),
77
+			'toggle_checkin_status'        => array(
78
+				'func'       => '_toggle_checkin_status',
79
+				'noheader'   => true,
80
+				'capability' => 'ee_edit_checkin',
81
+				'obj_id'     => $reg_id,
82
+			),
83
+			'toggle_checkin_status_bulk'   => array(
84
+				'func'       => '_toggle_checkin_status',
85
+				'noheader'   => true,
86
+				'capability' => 'ee_edit_checkins',
87
+			),
88
+			'event_registrations'          => array(
89
+				'func'       => '_event_registrations_list_table',
90
+				'capability' => 'ee_read_checkins',
91
+			),
92
+			'registrations_checkin_report' => array(
93
+				'func'       => '_registrations_checkin_report',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_read_registrations',
96
+			),
97
+		);
98
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
+		$new_page_config = array(
100
+			'reports'               => array(
101
+				'nav'           => array(
102
+					'label' => esc_html__('Reports', 'event_espresso'),
103
+					'order' => 30,
104
+				),
105
+				'help_tabs'     => array(
106
+					'registrations_reports_help_tab' => array(
107
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
+						'filename' => 'registrations_reports',
109
+					),
110
+				),
111
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
+				'require_nonce' => false,
113
+			),
114
+			'event_registrations'   => array(
115
+				'nav'           => array(
116
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
+					'order'      => 10,
118
+					'persistent' => true,
119
+				),
120
+				'help_tabs'     => array(
121
+					'registrations_event_checkin_help_tab'                       => array(
122
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
+						'filename' => 'registrations_event_checkin',
124
+					),
125
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
126
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
+						'filename' => 'registrations_event_checkin_table_column_headings',
128
+					),
129
+					'registrations_event_checkin_filters_help_tab'               => array(
130
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
+						'filename' => 'registrations_event_checkin_filters',
132
+					),
133
+					'registrations_event_checkin_views_help_tab'                 => array(
134
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
+						'filename' => 'registrations_event_checkin_views',
136
+					),
137
+					'registrations_event_checkin_other_help_tab'                 => array(
138
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
+						'filename' => 'registrations_event_checkin_other',
140
+					),
141
+				),
142
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
143
+				// 'help_tour'     => array('Event_Checkin_Help_Tour'),
144
+				'qtips'         => array('Registration_List_Table_Tips'),
145
+				'list_table'    => 'EE_Event_Registrations_List_Table',
146
+				'metaboxes'     => array(),
147
+				'require_nonce' => false,
148
+			),
149
+			'registration_checkins' => array(
150
+				'nav'           => array(
151
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
+					'order'      => 15,
153
+					'persistent' => false,
154
+					'url'        => '',
155
+				),
156
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
+				// 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
158
+				'metaboxes'     => array(),
159
+				'require_nonce' => false,
160
+			),
161
+		);
162
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
163
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
164
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * Ajax hooks for all routes in this page.
170
-     */
171
-    protected function _ajax_hooks()
172
-    {
173
-        parent::_ajax_hooks();
174
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
175
-    }
168
+	/**
169
+	 * Ajax hooks for all routes in this page.
170
+	 */
171
+	protected function _ajax_hooks()
172
+	{
173
+		parent::_ajax_hooks();
174
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
175
+	}
176 176
 
177 177
 
178
-    /**
179
-     * Global scripts for all routes in this page.
180
-     */
181
-    public function load_scripts_styles()
182
-    {
183
-        parent::load_scripts_styles();
184
-        // if newsletter message type is active then let's add filter and load js for it.
185
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
186
-            // enqueue newsletter js
187
-            wp_enqueue_script(
188
-                'ee-newsletter-trigger',
189
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
-                array('ee-dialog'),
191
-                EVENT_ESPRESSO_VERSION,
192
-                true
193
-            );
194
-            wp_enqueue_style(
195
-                'ee-newsletter-trigger-css',
196
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
-                array(),
198
-                EVENT_ESPRESSO_VERSION
199
-            );
200
-            // hook in buttons for newsletter message type trigger.
201
-            add_action(
202
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
203
-                array($this, 'add_newsletter_action_buttons'),
204
-                10
205
-            );
206
-        }
207
-    }
178
+	/**
179
+	 * Global scripts for all routes in this page.
180
+	 */
181
+	public function load_scripts_styles()
182
+	{
183
+		parent::load_scripts_styles();
184
+		// if newsletter message type is active then let's add filter and load js for it.
185
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
186
+			// enqueue newsletter js
187
+			wp_enqueue_script(
188
+				'ee-newsletter-trigger',
189
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
+				array('ee-dialog'),
191
+				EVENT_ESPRESSO_VERSION,
192
+				true
193
+			);
194
+			wp_enqueue_style(
195
+				'ee-newsletter-trigger-css',
196
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
+				array(),
198
+				EVENT_ESPRESSO_VERSION
199
+			);
200
+			// hook in buttons for newsletter message type trigger.
201
+			add_action(
202
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
203
+				array($this, 'add_newsletter_action_buttons'),
204
+				10
205
+			);
206
+		}
207
+	}
208 208
 
209 209
 
210
-    /**
211
-     * Scripts and styles for just the reports route.
212
-     */
213
-    public function load_scripts_styles_reports()
214
-    {
215
-        wp_register_script(
216
-            'ee-reg-reports-js',
217
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
-            array('google-charts'),
219
-            EVENT_ESPRESSO_VERSION,
220
-            true
221
-        );
222
-        wp_enqueue_script('ee-reg-reports-js');
223
-        $this->_registration_reports_js_setup();
224
-    }
210
+	/**
211
+	 * Scripts and styles for just the reports route.
212
+	 */
213
+	public function load_scripts_styles_reports()
214
+	{
215
+		wp_register_script(
216
+			'ee-reg-reports-js',
217
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
+			array('google-charts'),
219
+			EVENT_ESPRESSO_VERSION,
220
+			true
221
+		);
222
+		wp_enqueue_script('ee-reg-reports-js');
223
+		$this->_registration_reports_js_setup();
224
+	}
225 225
 
226 226
 
227
-    /**
228
-     * Register screen options for event_registrations route.
229
-     */
230
-    protected function _add_screen_options_event_registrations()
231
-    {
232
-        $this->_per_page_screen_option();
233
-    }
227
+	/**
228
+	 * Register screen options for event_registrations route.
229
+	 */
230
+	protected function _add_screen_options_event_registrations()
231
+	{
232
+		$this->_per_page_screen_option();
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * Register screen options for registration_checkins route
238
-     */
239
-    protected function _add_screen_options_registration_checkins()
240
-    {
241
-        $page_title = $this->_admin_page_title;
242
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
243
-        $this->_per_page_screen_option();
244
-        $this->_admin_page_title = $page_title;
245
-    }
236
+	/**
237
+	 * Register screen options for registration_checkins route
238
+	 */
239
+	protected function _add_screen_options_registration_checkins()
240
+	{
241
+		$page_title = $this->_admin_page_title;
242
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
243
+		$this->_per_page_screen_option();
244
+		$this->_admin_page_title = $page_title;
245
+	}
246 246
 
247 247
 
248
-    /**
249
-     * Set views property for event_registrations route.
250
-     */
251
-    protected function _set_list_table_views_event_registrations()
252
-    {
253
-        $this->_views = array(
254
-            'all' => array(
255
-                'slug'        => 'all',
256
-                'label'       => esc_html__('All', 'event_espresso'),
257
-                'count'       => 0,
258
-                'bulk_action' => ! isset($this->_req_data['event_id'])
259
-                    ? array()
260
-                    : array(
261
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
262
-                    ),
263
-            ),
264
-        );
265
-    }
248
+	/**
249
+	 * Set views property for event_registrations route.
250
+	 */
251
+	protected function _set_list_table_views_event_registrations()
252
+	{
253
+		$this->_views = array(
254
+			'all' => array(
255
+				'slug'        => 'all',
256
+				'label'       => esc_html__('All', 'event_espresso'),
257
+				'count'       => 0,
258
+				'bulk_action' => ! isset($this->_req_data['event_id'])
259
+					? array()
260
+					: array(
261
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
262
+					),
263
+			),
264
+		);
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * Set views property for registration_checkins route.
270
-     */
271
-    protected function _set_list_table_views_registration_checkins()
272
-    {
273
-        $this->_views = array(
274
-            'all' => array(
275
-                'slug'        => 'all',
276
-                'label'       => esc_html__('All', 'event_espresso'),
277
-                'count'       => 0,
278
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
279
-            ),
280
-        );
281
-    }
268
+	/**
269
+	 * Set views property for registration_checkins route.
270
+	 */
271
+	protected function _set_list_table_views_registration_checkins()
272
+	{
273
+		$this->_views = array(
274
+			'all' => array(
275
+				'slug'        => 'all',
276
+				'label'       => esc_html__('All', 'event_espresso'),
277
+				'count'       => 0,
278
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
279
+			),
280
+		);
281
+	}
282 282
 
283 283
 
284
-    /**
285
-     * callback for ajax action.
286
-     *
287
-     * @since 4.3.0
288
-     * @return void (JSON)
289
-     * @throws EE_Error
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    public function get_newsletter_form_content()
295
-    {
296
-        // do a nonce check cause we're not coming in from an normal route here.
297
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
-            $this->_req_data['get_newsletter_form_content_nonce']
299
-        ) : '';
300
-        $nonce_ref = 'get_newsletter_form_content_nonce';
301
-        $this->_verify_nonce($nonce, $nonce_ref);
302
-        // let's get the mtp for the incoming MTP_ ID
303
-        if (! isset($this->_req_data['GRP_ID'])) {
304
-            EE_Error::add_error(
305
-                esc_html__(
306
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
307
-                    'event_espresso'
308
-                ),
309
-                __FILE__,
310
-                __FUNCTION__,
311
-                __LINE__
312
-            );
313
-            $this->_template_args['success'] = false;
314
-            $this->_template_args['error'] = true;
315
-            $this->_return_json();
316
-        }
317
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
-            EE_Error::add_error(
320
-                sprintf(
321
-                    esc_html__(
322
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
-                        'event_espresso'
324
-                    ),
325
-                    $this->_req_data['GRP_ID']
326
-                ),
327
-                __FILE__,
328
-                __FUNCTION__,
329
-                __LINE__
330
-            );
331
-            $this->_template_args['success'] = false;
332
-            $this->_template_args['error'] = true;
333
-            $this->_return_json();
334
-        }
335
-        $MTPs = $MTPG->context_templates();
336
-        $MTPs = $MTPs['attendee'];
337
-        $template_fields = array();
338
-        /** @var EE_Message_Template $MTP */
339
-        foreach ($MTPs as $MTP) {
340
-            $field = $MTP->get('MTP_template_field');
341
-            if ($field === 'content') {
342
-                $content = $MTP->get('MTP_content');
343
-                if (! empty($content['newsletter_content'])) {
344
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
345
-                }
346
-                continue;
347
-            }
348
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
-        }
350
-        $this->_template_args['success'] = true;
351
-        $this->_template_args['error'] = false;
352
-        $this->_template_args['data'] = array(
353
-            'batch_message_from'    => isset($template_fields['from'])
354
-                ? $template_fields['from']
355
-                : '',
356
-            'batch_message_subject' => isset($template_fields['subject'])
357
-                ? $template_fields['subject']
358
-                : '',
359
-            'batch_message_content' => isset($template_fields['newsletter_content'])
360
-                ? $template_fields['newsletter_content']
361
-                : '',
362
-        );
363
-        $this->_return_json();
364
-    }
284
+	/**
285
+	 * callback for ajax action.
286
+	 *
287
+	 * @since 4.3.0
288
+	 * @return void (JSON)
289
+	 * @throws EE_Error
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	public function get_newsletter_form_content()
295
+	{
296
+		// do a nonce check cause we're not coming in from an normal route here.
297
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
+			$this->_req_data['get_newsletter_form_content_nonce']
299
+		) : '';
300
+		$nonce_ref = 'get_newsletter_form_content_nonce';
301
+		$this->_verify_nonce($nonce, $nonce_ref);
302
+		// let's get the mtp for the incoming MTP_ ID
303
+		if (! isset($this->_req_data['GRP_ID'])) {
304
+			EE_Error::add_error(
305
+				esc_html__(
306
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
307
+					'event_espresso'
308
+				),
309
+				__FILE__,
310
+				__FUNCTION__,
311
+				__LINE__
312
+			);
313
+			$this->_template_args['success'] = false;
314
+			$this->_template_args['error'] = true;
315
+			$this->_return_json();
316
+		}
317
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
+		if (! $MTPG instanceof EE_Message_Template_Group) {
319
+			EE_Error::add_error(
320
+				sprintf(
321
+					esc_html__(
322
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
+						'event_espresso'
324
+					),
325
+					$this->_req_data['GRP_ID']
326
+				),
327
+				__FILE__,
328
+				__FUNCTION__,
329
+				__LINE__
330
+			);
331
+			$this->_template_args['success'] = false;
332
+			$this->_template_args['error'] = true;
333
+			$this->_return_json();
334
+		}
335
+		$MTPs = $MTPG->context_templates();
336
+		$MTPs = $MTPs['attendee'];
337
+		$template_fields = array();
338
+		/** @var EE_Message_Template $MTP */
339
+		foreach ($MTPs as $MTP) {
340
+			$field = $MTP->get('MTP_template_field');
341
+			if ($field === 'content') {
342
+				$content = $MTP->get('MTP_content');
343
+				if (! empty($content['newsletter_content'])) {
344
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
345
+				}
346
+				continue;
347
+			}
348
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
+		}
350
+		$this->_template_args['success'] = true;
351
+		$this->_template_args['error'] = false;
352
+		$this->_template_args['data'] = array(
353
+			'batch_message_from'    => isset($template_fields['from'])
354
+				? $template_fields['from']
355
+				: '',
356
+			'batch_message_subject' => isset($template_fields['subject'])
357
+				? $template_fields['subject']
358
+				: '',
359
+			'batch_message_content' => isset($template_fields['newsletter_content'])
360
+				? $template_fields['newsletter_content']
361
+				: '',
362
+		);
363
+		$this->_return_json();
364
+	}
365 365
 
366 366
 
367
-    /**
368
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
-     *
370
-     * @since 4.3.0
371
-     * @param EE_Admin_List_Table $list_table
372
-     * @return void
373
-     * @throws InvalidArgumentException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidInterfaceException
376
-     */
377
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
-    {
379
-        if (
380
-            ! EE_Registry::instance()->CAP->current_user_can(
381
-                'ee_send_message',
382
-                'espresso_registrations_newsletter_selected_send'
383
-            )
384
-        ) {
385
-            return;
386
-        }
387
-        $routes_to_add_to = array(
388
-            'contact_list',
389
-            'event_registrations',
390
-            'default',
391
-        );
392
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
-            if (
394
-                ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
395
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
396
-            ) {
397
-                echo '';
398
-            } else {
399
-                $button_text = sprintf(
400
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
401
-                    '<span class="send-selected-newsletter-count">0</span>'
402
-                );
403
-                echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
404
-                     . '<span class="dashicons dashicons-email "></span>'
405
-                     . $button_text
406
-                     . '</button>';
407
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
408
-            }
409
-        }
410
-    }
367
+	/**
368
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
+	 *
370
+	 * @since 4.3.0
371
+	 * @param EE_Admin_List_Table $list_table
372
+	 * @return void
373
+	 * @throws InvalidArgumentException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidInterfaceException
376
+	 */
377
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
+	{
379
+		if (
380
+			! EE_Registry::instance()->CAP->current_user_can(
381
+				'ee_send_message',
382
+				'espresso_registrations_newsletter_selected_send'
383
+			)
384
+		) {
385
+			return;
386
+		}
387
+		$routes_to_add_to = array(
388
+			'contact_list',
389
+			'event_registrations',
390
+			'default',
391
+		);
392
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
+			if (
394
+				($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
395
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
396
+			) {
397
+				echo '';
398
+			} else {
399
+				$button_text = sprintf(
400
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
401
+					'<span class="send-selected-newsletter-count">0</span>'
402
+				);
403
+				echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
404
+					 . '<span class="dashicons dashicons-email "></span>'
405
+					 . $button_text
406
+					 . '</button>';
407
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
408
+			}
409
+		}
410
+	}
411 411
 
412 412
 
413
-    /**
414
-     * @throws DomainException
415
-     * @throws EE_Error
416
-     * @throws InvalidArgumentException
417
-     * @throws InvalidDataTypeException
418
-     * @throws InvalidInterfaceException
419
-     */
420
-    public function newsletter_send_form_skeleton()
421
-    {
422
-        $list_table = $this->_list_table_object;
423
-        $codes = array();
424
-        // need to templates for the newsletter message type for the template selector.
425
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
426
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
427
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
428
-        );
429
-        foreach ($mtps as $mtp) {
430
-            $name = $mtp->name();
431
-            $values[] = array(
432
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
433
-                'id'   => $mtp->ID(),
434
-            );
435
-        }
436
-        // need to get a list of shortcodes that are available for the newsletter message type.
437
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
438
-            'newsletter',
439
-            'email',
440
-            array(),
441
-            'attendee',
442
-            false
443
-        );
444
-        foreach ($shortcodes as $field => $shortcode_array) {
445
-            $available_shortcodes = array();
446
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
447
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
448
-                    ? 'content'
449
-                    : $field;
450
-                $field_id = 'batch-message-' . strtolower($field_id);
451
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
452
-                                          . $shortcode
453
-                                          . '" data-linked-input-id="' . $field_id . '">'
454
-                                          . $shortcode
455
-                                          . '</span>';
456
-            }
457
-            $codes[ $field ] = implode(', ', $available_shortcodes);
458
-        }
459
-        $shortcodes = $codes;
460
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
461
-        $form_template_args = array(
462
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
463
-            'form_route'        => 'newsletter_selected_send',
464
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
465
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
466
-            'redirect_back_to'  => $this->_req_action,
467
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
468
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
469
-            'shortcodes'        => $shortcodes,
470
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
471
-        );
472
-        EEH_Template::display_template($form_template, $form_template_args);
473
-    }
413
+	/**
414
+	 * @throws DomainException
415
+	 * @throws EE_Error
416
+	 * @throws InvalidArgumentException
417
+	 * @throws InvalidDataTypeException
418
+	 * @throws InvalidInterfaceException
419
+	 */
420
+	public function newsletter_send_form_skeleton()
421
+	{
422
+		$list_table = $this->_list_table_object;
423
+		$codes = array();
424
+		// need to templates for the newsletter message type for the template selector.
425
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
426
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
427
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
428
+		);
429
+		foreach ($mtps as $mtp) {
430
+			$name = $mtp->name();
431
+			$values[] = array(
432
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
433
+				'id'   => $mtp->ID(),
434
+			);
435
+		}
436
+		// need to get a list of shortcodes that are available for the newsletter message type.
437
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
438
+			'newsletter',
439
+			'email',
440
+			array(),
441
+			'attendee',
442
+			false
443
+		);
444
+		foreach ($shortcodes as $field => $shortcode_array) {
445
+			$available_shortcodes = array();
446
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
447
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
448
+					? 'content'
449
+					: $field;
450
+				$field_id = 'batch-message-' . strtolower($field_id);
451
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
452
+										  . $shortcode
453
+										  . '" data-linked-input-id="' . $field_id . '">'
454
+										  . $shortcode
455
+										  . '</span>';
456
+			}
457
+			$codes[ $field ] = implode(', ', $available_shortcodes);
458
+		}
459
+		$shortcodes = $codes;
460
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
461
+		$form_template_args = array(
462
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
463
+			'form_route'        => 'newsletter_selected_send',
464
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
465
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
466
+			'redirect_back_to'  => $this->_req_action,
467
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
468
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
469
+			'shortcodes'        => $shortcodes,
470
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
471
+		);
472
+		EEH_Template::display_template($form_template, $form_template_args);
473
+	}
474 474
 
475 475
 
476
-    /**
477
-     * Handles sending selected registrations/contacts a newsletter.
478
-     *
479
-     * @since  4.3.0
480
-     * @return void
481
-     * @throws EE_Error
482
-     * @throws InvalidArgumentException
483
-     * @throws InvalidDataTypeException
484
-     * @throws InvalidInterfaceException
485
-     */
486
-    protected function _newsletter_selected_send()
487
-    {
488
-        $success = true;
489
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
490
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
491
-            EE_Error::add_error(
492
-                esc_html__(
493
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
494
-                    'event_espresso'
495
-                ),
496
-                __FILE__,
497
-                __FUNCTION__,
498
-                __LINE__
499
-            );
500
-            $success = false;
501
-        }
502
-        if ($success) {
503
-            // update Message template in case there are any changes
504
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
505
-                $this->_req_data['newsletter_mtp_selected']
506
-            );
507
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
508
-                ? $Message_Template_Group->context_templates()
509
-                : array();
510
-            if (empty($Message_Templates)) {
511
-                EE_Error::add_error(
512
-                    esc_html__(
513
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
514
-                        'event_espresso'
515
-                    ),
516
-                    __FILE__,
517
-                    __FUNCTION__,
518
-                    __LINE__
519
-                );
520
-            }
521
-            // let's just update the specific fields
522
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
523
-                if ($Message_Template instanceof EE_Message_Template) {
524
-                    $field = $Message_Template->get('MTP_template_field');
525
-                    $content = $Message_Template->get('MTP_content');
526
-                    $new_content = $content;
527
-                    switch ($field) {
528
-                        case 'from':
529
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
530
-                                ? $this->_req_data['batch_message']['from']
531
-                                : $content;
532
-                            break;
533
-                        case 'subject':
534
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
535
-                                ? $this->_req_data['batch_message']['subject']
536
-                                : $content;
537
-                            break;
538
-                        case 'content':
539
-                            $new_content = $content;
540
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
541
-                                ? $this->_req_data['batch_message']['content']
542
-                                : $content['newsletter_content'];
543
-                            break;
544
-                        default:
545
-                            // continue the foreach loop, we don't want to set $new_content nor save.
546
-                            continue 2;
547
-                    }
548
-                    $Message_Template->set('MTP_content', $new_content);
549
-                    $Message_Template->save();
550
-                }
551
-            }
552
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
553
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
554
-                ? $this->_req_data['batch_message']['id_type']
555
-                : 'registration';
556
-            // id_type will affect how we assemble the ids.
557
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
558
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
559
-                : array();
560
-            $registrations_used_for_contact_data = array();
561
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
562
-            switch ($id_type) {
563
-                case 'registration':
564
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
565
-                        array(
566
-                            array(
567
-                                'REG_ID' => array('IN', $ids),
568
-                            ),
569
-                        )
570
-                    );
571
-                    break;
572
-                case 'contact':
573
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
574
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
575
-                                                                               $ids
576
-                                                                           );
577
-                    break;
578
-            }
579
-            do_action_ref_array(
580
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
581
-                array(
582
-                    $registrations_used_for_contact_data,
583
-                    $Message_Template_Group->ID(),
584
-                )
585
-            );
586
-            // kept for backward compat, internally we no longer use this action.
587
-            // @deprecated 4.8.36.rc.002
588
-            $contacts = $id_type === 'registration'
589
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
590
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
591
-            do_action_ref_array(
592
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
593
-                array(
594
-                    $contacts,
595
-                    $Message_Template_Group->ID(),
596
-                )
597
-            );
598
-        }
599
-        $query_args = array(
600
-            'action' => ! empty($this->_req_data['redirect_back_to'])
601
-                ? $this->_req_data['redirect_back_to']
602
-                : 'default',
603
-        );
604
-        $this->_redirect_after_action(false, '', '', $query_args, true);
605
-    }
476
+	/**
477
+	 * Handles sending selected registrations/contacts a newsletter.
478
+	 *
479
+	 * @since  4.3.0
480
+	 * @return void
481
+	 * @throws EE_Error
482
+	 * @throws InvalidArgumentException
483
+	 * @throws InvalidDataTypeException
484
+	 * @throws InvalidInterfaceException
485
+	 */
486
+	protected function _newsletter_selected_send()
487
+	{
488
+		$success = true;
489
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
490
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
491
+			EE_Error::add_error(
492
+				esc_html__(
493
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
494
+					'event_espresso'
495
+				),
496
+				__FILE__,
497
+				__FUNCTION__,
498
+				__LINE__
499
+			);
500
+			$success = false;
501
+		}
502
+		if ($success) {
503
+			// update Message template in case there are any changes
504
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
505
+				$this->_req_data['newsletter_mtp_selected']
506
+			);
507
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
508
+				? $Message_Template_Group->context_templates()
509
+				: array();
510
+			if (empty($Message_Templates)) {
511
+				EE_Error::add_error(
512
+					esc_html__(
513
+						'Unable to retrieve message template fields from the db. Messages not sent.',
514
+						'event_espresso'
515
+					),
516
+					__FILE__,
517
+					__FUNCTION__,
518
+					__LINE__
519
+				);
520
+			}
521
+			// let's just update the specific fields
522
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
523
+				if ($Message_Template instanceof EE_Message_Template) {
524
+					$field = $Message_Template->get('MTP_template_field');
525
+					$content = $Message_Template->get('MTP_content');
526
+					$new_content = $content;
527
+					switch ($field) {
528
+						case 'from':
529
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
530
+								? $this->_req_data['batch_message']['from']
531
+								: $content;
532
+							break;
533
+						case 'subject':
534
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
535
+								? $this->_req_data['batch_message']['subject']
536
+								: $content;
537
+							break;
538
+						case 'content':
539
+							$new_content = $content;
540
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
541
+								? $this->_req_data['batch_message']['content']
542
+								: $content['newsletter_content'];
543
+							break;
544
+						default:
545
+							// continue the foreach loop, we don't want to set $new_content nor save.
546
+							continue 2;
547
+					}
548
+					$Message_Template->set('MTP_content', $new_content);
549
+					$Message_Template->save();
550
+				}
551
+			}
552
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
553
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
554
+				? $this->_req_data['batch_message']['id_type']
555
+				: 'registration';
556
+			// id_type will affect how we assemble the ids.
557
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
558
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
559
+				: array();
560
+			$registrations_used_for_contact_data = array();
561
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
562
+			switch ($id_type) {
563
+				case 'registration':
564
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
565
+						array(
566
+							array(
567
+								'REG_ID' => array('IN', $ids),
568
+							),
569
+						)
570
+					);
571
+					break;
572
+				case 'contact':
573
+					$registrations_used_for_contact_data = EEM_Registration::instance()
574
+																		   ->get_latest_registration_for_each_of_given_contacts(
575
+																			   $ids
576
+																		   );
577
+					break;
578
+			}
579
+			do_action_ref_array(
580
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
581
+				array(
582
+					$registrations_used_for_contact_data,
583
+					$Message_Template_Group->ID(),
584
+				)
585
+			);
586
+			// kept for backward compat, internally we no longer use this action.
587
+			// @deprecated 4.8.36.rc.002
588
+			$contacts = $id_type === 'registration'
589
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
590
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
591
+			do_action_ref_array(
592
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
593
+				array(
594
+					$contacts,
595
+					$Message_Template_Group->ID(),
596
+				)
597
+			);
598
+		}
599
+		$query_args = array(
600
+			'action' => ! empty($this->_req_data['redirect_back_to'])
601
+				? $this->_req_data['redirect_back_to']
602
+				: 'default',
603
+		);
604
+		$this->_redirect_after_action(false, '', '', $query_args, true);
605
+	}
606 606
 
607 607
 
608
-    /**
609
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
610
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
611
-     */
612
-    protected function _registration_reports_js_setup()
613
-    {
614
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
615
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
616
-    }
608
+	/**
609
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
610
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
611
+	 */
612
+	protected function _registration_reports_js_setup()
613
+	{
614
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
615
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
616
+	}
617 617
 
618 618
 
619
-    /**
620
-     *        generates Business Reports regarding Registrations
621
-     *
622
-     * @access protected
623
-     * @return void
624
-     * @throws DomainException
625
-     */
626
-    protected function _registration_reports()
627
-    {
628
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
629
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
630
-            $template_path,
631
-            $this->_reports_template_data,
632
-            true
633
-        );
634
-        // the final template wrapper
635
-        $this->display_admin_page_with_no_sidebar();
636
-    }
619
+	/**
620
+	 *        generates Business Reports regarding Registrations
621
+	 *
622
+	 * @access protected
623
+	 * @return void
624
+	 * @throws DomainException
625
+	 */
626
+	protected function _registration_reports()
627
+	{
628
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
629
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
630
+			$template_path,
631
+			$this->_reports_template_data,
632
+			true
633
+		);
634
+		// the final template wrapper
635
+		$this->display_admin_page_with_no_sidebar();
636
+	}
637 637
 
638 638
 
639
-    /**
640
-     * Generates Business Report showing total registrations per day.
641
-     *
642
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
643
-     * @return string
644
-     * @throws EE_Error
645
-     * @throws InvalidArgumentException
646
-     * @throws InvalidDataTypeException
647
-     * @throws InvalidInterfaceException
648
-     */
649
-    private function _registrations_per_day_report($period = '-1 month')
650
-    {
651
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
652
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
653
-        $results = (array) $results;
654
-        $regs = array();
655
-        $subtitle = '';
656
-        if ($results) {
657
-            $column_titles = array();
658
-            $tracker = 0;
659
-            foreach ($results as $result) {
660
-                $report_column_values = array();
661
-                foreach ($result as $property_name => $property_value) {
662
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
663
-                        : (int) $property_value;
664
-                    $report_column_values[] = $property_value;
665
-                    if ($tracker === 0) {
666
-                        if ($property_name === 'Registration_REG_date') {
667
-                            $column_titles[] = esc_html__(
668
-                                'Date (only days with registrations are shown)',
669
-                                'event_espresso'
670
-                            );
671
-                        } else {
672
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
673
-                        }
674
-                    }
675
-                }
676
-                $tracker++;
677
-                $regs[] = $report_column_values;
678
-            }
679
-            // make sure the column_titles is pushed to the beginning of the array
680
-            array_unshift($regs, $column_titles);
681
-            // setup the date range.
682
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
683
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
684
-            $ending_date = new DateTime("now", $DateTimeZone);
685
-            $subtitle = sprintf(
686
-                wp_strip_all_tags(
687
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
688
-                ),
689
-                $beginning_date->format('Y-m-d'),
690
-                $ending_date->format('Y-m-d')
691
-            );
692
-        }
693
-        $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
694
-        $report_params = array(
695
-            'title'     => $report_title,
696
-            'subtitle'  => $subtitle,
697
-            'id'        => $report_ID,
698
-            'regs'      => $regs,
699
-            'noResults' => empty($regs),
700
-            'noRegsMsg' => sprintf(
701
-                wp_strip_all_tags(
702
-                    __(
703
-                        '%sThere are currently no registration records in the last month for this report.%s',
704
-                        'event_espresso'
705
-                    )
706
-                ),
707
-                '<h2>' . $report_title . '</h2><p>',
708
-                '</p>'
709
-            ),
710
-        );
711
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
712
-        return $report_ID;
713
-    }
639
+	/**
640
+	 * Generates Business Report showing total registrations per day.
641
+	 *
642
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
643
+	 * @return string
644
+	 * @throws EE_Error
645
+	 * @throws InvalidArgumentException
646
+	 * @throws InvalidDataTypeException
647
+	 * @throws InvalidInterfaceException
648
+	 */
649
+	private function _registrations_per_day_report($period = '-1 month')
650
+	{
651
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
652
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
653
+		$results = (array) $results;
654
+		$regs = array();
655
+		$subtitle = '';
656
+		if ($results) {
657
+			$column_titles = array();
658
+			$tracker = 0;
659
+			foreach ($results as $result) {
660
+				$report_column_values = array();
661
+				foreach ($result as $property_name => $property_value) {
662
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
663
+						: (int) $property_value;
664
+					$report_column_values[] = $property_value;
665
+					if ($tracker === 0) {
666
+						if ($property_name === 'Registration_REG_date') {
667
+							$column_titles[] = esc_html__(
668
+								'Date (only days with registrations are shown)',
669
+								'event_espresso'
670
+							);
671
+						} else {
672
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
673
+						}
674
+					}
675
+				}
676
+				$tracker++;
677
+				$regs[] = $report_column_values;
678
+			}
679
+			// make sure the column_titles is pushed to the beginning of the array
680
+			array_unshift($regs, $column_titles);
681
+			// setup the date range.
682
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
683
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
684
+			$ending_date = new DateTime("now", $DateTimeZone);
685
+			$subtitle = sprintf(
686
+				wp_strip_all_tags(
687
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
688
+				),
689
+				$beginning_date->format('Y-m-d'),
690
+				$ending_date->format('Y-m-d')
691
+			);
692
+		}
693
+		$report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
694
+		$report_params = array(
695
+			'title'     => $report_title,
696
+			'subtitle'  => $subtitle,
697
+			'id'        => $report_ID,
698
+			'regs'      => $regs,
699
+			'noResults' => empty($regs),
700
+			'noRegsMsg' => sprintf(
701
+				wp_strip_all_tags(
702
+					__(
703
+						'%sThere are currently no registration records in the last month for this report.%s',
704
+						'event_espresso'
705
+					)
706
+				),
707
+				'<h2>' . $report_title . '</h2><p>',
708
+				'</p>'
709
+			),
710
+		);
711
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
712
+		return $report_ID;
713
+	}
714 714
 
715 715
 
716
-    /**
717
-     * Generates Business Report showing total registrations per event.
718
-     *
719
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
720
-     * @return string
721
-     * @throws EE_Error
722
-     * @throws InvalidArgumentException
723
-     * @throws InvalidDataTypeException
724
-     * @throws InvalidInterfaceException
725
-     */
726
-    private function _registrations_per_event_report($period = '-1 month')
727
-    {
728
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
729
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
730
-        $results = (array) $results;
731
-        $regs = array();
732
-        $subtitle = '';
733
-        if ($results) {
734
-            $column_titles = array();
735
-            $tracker = 0;
736
-            foreach ($results as $result) {
737
-                $report_column_values = array();
738
-                foreach ($result as $property_name => $property_value) {
739
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
740
-                        $property_value,
741
-                        4,
742
-                        '...'
743
-                    ) : (int) $property_value;
744
-                    $report_column_values[] = $property_value;
745
-                    if ($tracker === 0) {
746
-                        if ($property_name === 'Registration_Event') {
747
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
748
-                        } else {
749
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
750
-                        }
751
-                    }
752
-                }
753
-                $tracker++;
754
-                $regs[] = $report_column_values;
755
-            }
756
-            // make sure the column_titles is pushed to the beginning of the array
757
-            array_unshift($regs, $column_titles);
758
-            // setup the date range.
759
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
760
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
761
-            $ending_date = new DateTime("now", $DateTimeZone);
762
-            $subtitle = sprintf(
763
-                wp_strip_all_tags(
764
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
765
-                ),
766
-                $beginning_date->format('Y-m-d'),
767
-                $ending_date->format('Y-m-d')
768
-            );
769
-        }
770
-        $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
771
-        $report_params = array(
772
-            'title'     => $report_title,
773
-            'subtitle'  => $subtitle,
774
-            'id'        => $report_ID,
775
-            'regs'      => $regs,
776
-            'noResults' => empty($regs),
777
-            'noRegsMsg' => sprintf(
778
-                wp_strip_all_tags(
779
-                    __(
780
-                        '%sThere are currently no registration records in the last month for this report.%s',
781
-                        'event_espresso'
782
-                    )
783
-                ),
784
-                '<h2>' . $report_title . '</h2><p>',
785
-                '</p>'
786
-            ),
787
-        );
788
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
789
-        return $report_ID;
790
-    }
716
+	/**
717
+	 * Generates Business Report showing total registrations per event.
718
+	 *
719
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
720
+	 * @return string
721
+	 * @throws EE_Error
722
+	 * @throws InvalidArgumentException
723
+	 * @throws InvalidDataTypeException
724
+	 * @throws InvalidInterfaceException
725
+	 */
726
+	private function _registrations_per_event_report($period = '-1 month')
727
+	{
728
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
729
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
730
+		$results = (array) $results;
731
+		$regs = array();
732
+		$subtitle = '';
733
+		if ($results) {
734
+			$column_titles = array();
735
+			$tracker = 0;
736
+			foreach ($results as $result) {
737
+				$report_column_values = array();
738
+				foreach ($result as $property_name => $property_value) {
739
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
740
+						$property_value,
741
+						4,
742
+						'...'
743
+					) : (int) $property_value;
744
+					$report_column_values[] = $property_value;
745
+					if ($tracker === 0) {
746
+						if ($property_name === 'Registration_Event') {
747
+							$column_titles[] = esc_html__('Event', 'event_espresso');
748
+						} else {
749
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
750
+						}
751
+					}
752
+				}
753
+				$tracker++;
754
+				$regs[] = $report_column_values;
755
+			}
756
+			// make sure the column_titles is pushed to the beginning of the array
757
+			array_unshift($regs, $column_titles);
758
+			// setup the date range.
759
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
760
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
761
+			$ending_date = new DateTime("now", $DateTimeZone);
762
+			$subtitle = sprintf(
763
+				wp_strip_all_tags(
764
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
765
+				),
766
+				$beginning_date->format('Y-m-d'),
767
+				$ending_date->format('Y-m-d')
768
+			);
769
+		}
770
+		$report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
771
+		$report_params = array(
772
+			'title'     => $report_title,
773
+			'subtitle'  => $subtitle,
774
+			'id'        => $report_ID,
775
+			'regs'      => $regs,
776
+			'noResults' => empty($regs),
777
+			'noRegsMsg' => sprintf(
778
+				wp_strip_all_tags(
779
+					__(
780
+						'%sThere are currently no registration records in the last month for this report.%s',
781
+						'event_espresso'
782
+					)
783
+				),
784
+				'<h2>' . $report_title . '</h2><p>',
785
+				'</p>'
786
+			),
787
+		);
788
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
789
+		return $report_ID;
790
+	}
791 791
 
792 792
 
793
-    /**
794
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
795
-     *
796
-     * @access protected
797
-     * @return void
798
-     * @throws EE_Error
799
-     * @throws InvalidArgumentException
800
-     * @throws InvalidDataTypeException
801
-     * @throws InvalidInterfaceException
802
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
803
-     */
804
-    protected function _registration_checkin_list_table()
805
-    {
806
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
807
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
808
-        /** @var EE_Registration $registration */
809
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
810
-        if (! $registration instanceof EE_Registration) {
811
-            throw new EE_Error(
812
-                sprintf(
813
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
814
-                    $reg_id
815
-                )
816
-            );
817
-        }
818
-        $attendee = $registration->attendee();
819
-        $this->_admin_page_title .= $this->get_action_link_or_button(
820
-            'new_registration',
821
-            'add-registrant',
822
-            array('event_id' => $registration->event_ID()),
823
-            'add-new-h2'
824
-        );
825
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
826
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
827
-        $legend_items = array(
828
-            'checkin'  => array(
829
-                'class' => $checked_in->cssClasses(),
830
-                'desc'  => $checked_in->legendLabel(),
831
-            ),
832
-            'checkout' => array(
833
-                'class' => $checked_out->cssClasses(),
834
-                'desc'  => $checked_out->legendLabel(),
835
-            ),
836
-        );
837
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
838
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
839
-        /** @var EE_Datetime $datetime */
840
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
841
-        $datetime_label = '';
842
-        if ($datetime instanceof EE_Datetime) {
843
-            $datetime_label = $datetime->get_dtt_display_name(true);
844
-            $datetime_label .= ! empty($datetime_label)
845
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
846
-                : $datetime->get_dtt_display_name();
847
-        }
848
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
849
-            ? EE_Admin_Page::add_query_args_and_nonce(
850
-                array(
851
-                    'action'   => 'event_registrations',
852
-                    'event_id' => $registration->event_ID(),
853
-                    'DTT_ID'   => $dtt_id,
854
-                ),
855
-                $this->_admin_base_url
856
-            )
857
-            : '';
858
-        $datetime_link = ! empty($datetime_link)
859
-            ? '<a href="' . $datetime_link . '">'
860
-              . '<span id="checkin-dtt">'
861
-              . $datetime_label
862
-              . '</span></a>'
863
-            : $datetime_label;
864
-        $attendee_name = $attendee instanceof EE_Attendee
865
-            ? $attendee->full_name()
866
-            : '';
867
-        $attendee_link = $attendee instanceof EE_Attendee
868
-            ? $attendee->get_admin_details_link()
869
-            : '';
870
-        $attendee_link = ! empty($attendee_link)
871
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
872
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
873
-              . '<span id="checkin-attendee-name">'
874
-              . $attendee_name
875
-              . '</span></a>'
876
-            : '';
877
-        $event_link = $registration->event() instanceof EE_Event
878
-            ? $registration->event()->get_admin_details_link()
879
-            : '';
880
-        $event_link = ! empty($event_link)
881
-            ? '<a href="' . $event_link . '"'
882
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
883
-              . '<span id="checkin-event-name">'
884
-              . $registration->event_name()
885
-              . '</span>'
886
-              . '</a>'
887
-            : '';
888
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
889
-            ? '<h2>' . sprintf(
890
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
891
-                $attendee_link,
892
-                $datetime_link,
893
-                $event_link
894
-            ) . '</h2>'
895
-            : '';
896
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
897
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
898
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
899
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
900
-        $this->display_admin_list_table_page_with_no_sidebar();
901
-    }
793
+	/**
794
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
795
+	 *
796
+	 * @access protected
797
+	 * @return void
798
+	 * @throws EE_Error
799
+	 * @throws InvalidArgumentException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws InvalidInterfaceException
802
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
803
+	 */
804
+	protected function _registration_checkin_list_table()
805
+	{
806
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
807
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
808
+		/** @var EE_Registration $registration */
809
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
810
+		if (! $registration instanceof EE_Registration) {
811
+			throw new EE_Error(
812
+				sprintf(
813
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
814
+					$reg_id
815
+				)
816
+			);
817
+		}
818
+		$attendee = $registration->attendee();
819
+		$this->_admin_page_title .= $this->get_action_link_or_button(
820
+			'new_registration',
821
+			'add-registrant',
822
+			array('event_id' => $registration->event_ID()),
823
+			'add-new-h2'
824
+		);
825
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
826
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
827
+		$legend_items = array(
828
+			'checkin'  => array(
829
+				'class' => $checked_in->cssClasses(),
830
+				'desc'  => $checked_in->legendLabel(),
831
+			),
832
+			'checkout' => array(
833
+				'class' => $checked_out->cssClasses(),
834
+				'desc'  => $checked_out->legendLabel(),
835
+			),
836
+		);
837
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
838
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
839
+		/** @var EE_Datetime $datetime */
840
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
841
+		$datetime_label = '';
842
+		if ($datetime instanceof EE_Datetime) {
843
+			$datetime_label = $datetime->get_dtt_display_name(true);
844
+			$datetime_label .= ! empty($datetime_label)
845
+				? ' (' . $datetime->get_dtt_display_name() . ')'
846
+				: $datetime->get_dtt_display_name();
847
+		}
848
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
849
+			? EE_Admin_Page::add_query_args_and_nonce(
850
+				array(
851
+					'action'   => 'event_registrations',
852
+					'event_id' => $registration->event_ID(),
853
+					'DTT_ID'   => $dtt_id,
854
+				),
855
+				$this->_admin_base_url
856
+			)
857
+			: '';
858
+		$datetime_link = ! empty($datetime_link)
859
+			? '<a href="' . $datetime_link . '">'
860
+			  . '<span id="checkin-dtt">'
861
+			  . $datetime_label
862
+			  . '</span></a>'
863
+			: $datetime_label;
864
+		$attendee_name = $attendee instanceof EE_Attendee
865
+			? $attendee->full_name()
866
+			: '';
867
+		$attendee_link = $attendee instanceof EE_Attendee
868
+			? $attendee->get_admin_details_link()
869
+			: '';
870
+		$attendee_link = ! empty($attendee_link)
871
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
872
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
873
+			  . '<span id="checkin-attendee-name">'
874
+			  . $attendee_name
875
+			  . '</span></a>'
876
+			: '';
877
+		$event_link = $registration->event() instanceof EE_Event
878
+			? $registration->event()->get_admin_details_link()
879
+			: '';
880
+		$event_link = ! empty($event_link)
881
+			? '<a href="' . $event_link . '"'
882
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
883
+			  . '<span id="checkin-event-name">'
884
+			  . $registration->event_name()
885
+			  . '</span>'
886
+			  . '</a>'
887
+			: '';
888
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
889
+			? '<h2>' . sprintf(
890
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
891
+				$attendee_link,
892
+				$datetime_link,
893
+				$event_link
894
+			) . '</h2>'
895
+			: '';
896
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
897
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
898
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
899
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
900
+		$this->display_admin_list_table_page_with_no_sidebar();
901
+	}
902 902
 
903 903
 
904
-    /**
905
-     * toggle the Check-in status for the given registration (coming from ajax)
906
-     *
907
-     * @return void (JSON)
908
-     * @throws EE_Error
909
-     * @throws InvalidArgumentException
910
-     * @throws InvalidDataTypeException
911
-     * @throws InvalidInterfaceException
912
-     */
913
-    public function toggle_checkin_status()
914
-    {
915
-        // first make sure we have the necessary data
916
-        if (! isset($this->_req_data['_regid'])) {
917
-            EE_Error::add_error(
918
-                esc_html__(
919
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
920
-                    'event_espresso'
921
-                ),
922
-                __FILE__,
923
-                __FUNCTION__,
924
-                __LINE__
925
-            );
926
-            $this->_template_args['success'] = false;
927
-            $this->_template_args['error'] = true;
928
-            $this->_return_json();
929
-        };
930
-        // do a nonce check cause we're not coming in from an normal route here.
931
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
932
-            : '';
933
-        $nonce_ref = 'checkin_nonce';
934
-        $this->_verify_nonce($nonce, $nonce_ref);
935
-        // beautiful! Made it this far so let's get the status.
936
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
937
-        // setup new class to return via ajax
938
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
939
-        $this->_template_args['success'] = true;
940
-        $this->_return_json();
941
-    }
904
+	/**
905
+	 * toggle the Check-in status for the given registration (coming from ajax)
906
+	 *
907
+	 * @return void (JSON)
908
+	 * @throws EE_Error
909
+	 * @throws InvalidArgumentException
910
+	 * @throws InvalidDataTypeException
911
+	 * @throws InvalidInterfaceException
912
+	 */
913
+	public function toggle_checkin_status()
914
+	{
915
+		// first make sure we have the necessary data
916
+		if (! isset($this->_req_data['_regid'])) {
917
+			EE_Error::add_error(
918
+				esc_html__(
919
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
920
+					'event_espresso'
921
+				),
922
+				__FILE__,
923
+				__FUNCTION__,
924
+				__LINE__
925
+			);
926
+			$this->_template_args['success'] = false;
927
+			$this->_template_args['error'] = true;
928
+			$this->_return_json();
929
+		};
930
+		// do a nonce check cause we're not coming in from an normal route here.
931
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
932
+			: '';
933
+		$nonce_ref = 'checkin_nonce';
934
+		$this->_verify_nonce($nonce, $nonce_ref);
935
+		// beautiful! Made it this far so let's get the status.
936
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
937
+		// setup new class to return via ajax
938
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
939
+		$this->_template_args['success'] = true;
940
+		$this->_return_json();
941
+	}
942 942
 
943 943
 
944
-    /**
945
-     * handles toggling the checkin status for the registration,
946
-     *
947
-     * @access protected
948
-     * @return int|void
949
-     * @throws EE_Error
950
-     * @throws InvalidArgumentException
951
-     * @throws InvalidDataTypeException
952
-     * @throws InvalidInterfaceException
953
-     */
954
-    protected function _toggle_checkin_status()
955
-    {
956
-        // first let's get the query args out of the way for the redirect
957
-        $query_args = array(
958
-            'action'   => 'event_registrations',
959
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
960
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
961
-        );
962
-        $new_status = false;
963
-        // bulk action check in toggle
964
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
965
-            // cycle thru checkboxes
966
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
967
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
968
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
969
-            }
970
-        } elseif (isset($this->_req_data['_regid'])) {
971
-            // coming from ajax request
972
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
973
-            $query_args['DTT_ID'] = $DTT_ID;
974
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
975
-        } else {
976
-            EE_Error::add_error(
977
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
978
-                __FILE__,
979
-                __FUNCTION__,
980
-                __LINE__
981
-            );
982
-        }
983
-        if (defined('DOING_AJAX')) {
984
-            return $new_status;
985
-        }
986
-        $this->_redirect_after_action(false, '', '', $query_args, true);
987
-    }
944
+	/**
945
+	 * handles toggling the checkin status for the registration,
946
+	 *
947
+	 * @access protected
948
+	 * @return int|void
949
+	 * @throws EE_Error
950
+	 * @throws InvalidArgumentException
951
+	 * @throws InvalidDataTypeException
952
+	 * @throws InvalidInterfaceException
953
+	 */
954
+	protected function _toggle_checkin_status()
955
+	{
956
+		// first let's get the query args out of the way for the redirect
957
+		$query_args = array(
958
+			'action'   => 'event_registrations',
959
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
960
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
961
+		);
962
+		$new_status = false;
963
+		// bulk action check in toggle
964
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
965
+			// cycle thru checkboxes
966
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
967
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
968
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
969
+			}
970
+		} elseif (isset($this->_req_data['_regid'])) {
971
+			// coming from ajax request
972
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
973
+			$query_args['DTT_ID'] = $DTT_ID;
974
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
975
+		} else {
976
+			EE_Error::add_error(
977
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
978
+				__FILE__,
979
+				__FUNCTION__,
980
+				__LINE__
981
+			);
982
+		}
983
+		if (defined('DOING_AJAX')) {
984
+			return $new_status;
985
+		}
986
+		$this->_redirect_after_action(false, '', '', $query_args, true);
987
+	}
988 988
 
989 989
 
990
-    /**
991
-     * This is toggles a single Check-in for the given registration and datetime.
992
-     *
993
-     * @param  int $REG_ID The registration we're toggling
994
-     * @param  int $DTT_ID The datetime we're toggling
995
-     * @return int The new status toggled to.
996
-     * @throws EE_Error
997
-     * @throws InvalidArgumentException
998
-     * @throws InvalidDataTypeException
999
-     * @throws InvalidInterfaceException
1000
-     */
1001
-    private function _toggle_checkin($REG_ID, $DTT_ID)
1002
-    {
1003
-        /** @var EE_Registration $REG */
1004
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1005
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
1006
-        if ($new_status !== false) {
1007
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1008
-        } else {
1009
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1010
-            $new_status = false;
1011
-        }
1012
-        return $new_status;
1013
-    }
990
+	/**
991
+	 * This is toggles a single Check-in for the given registration and datetime.
992
+	 *
993
+	 * @param  int $REG_ID The registration we're toggling
994
+	 * @param  int $DTT_ID The datetime we're toggling
995
+	 * @return int The new status toggled to.
996
+	 * @throws EE_Error
997
+	 * @throws InvalidArgumentException
998
+	 * @throws InvalidDataTypeException
999
+	 * @throws InvalidInterfaceException
1000
+	 */
1001
+	private function _toggle_checkin($REG_ID, $DTT_ID)
1002
+	{
1003
+		/** @var EE_Registration $REG */
1004
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1005
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
1006
+		if ($new_status !== false) {
1007
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1008
+		} else {
1009
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1010
+			$new_status = false;
1011
+		}
1012
+		return $new_status;
1013
+	}
1014 1014
 
1015 1015
 
1016
-    /**
1017
-     * Takes care of deleting multiple EE_Checkin table rows
1018
-     *
1019
-     * @access protected
1020
-     * @return void
1021
-     * @throws EE_Error
1022
-     * @throws InvalidArgumentException
1023
-     * @throws InvalidDataTypeException
1024
-     * @throws InvalidInterfaceException
1025
-     */
1026
-    protected function _delete_checkin_rows()
1027
-    {
1028
-        $query_args = array(
1029
-            'action'  => 'registration_checkins',
1030
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1031
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1032
-        );
1033
-        $errors = 0;
1034
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1035
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1036
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1037
-                    $errors++;
1038
-                }
1039
-            }
1040
-        } else {
1041
-            EE_Error::add_error(
1042
-                esc_html__(
1043
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1044
-                    'event_espresso'
1045
-                ),
1046
-                __FILE__,
1047
-                __FUNCTION__,
1048
-                __LINE__
1049
-            );
1050
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1051
-        }
1052
-        if ($errors > 0) {
1053
-            EE_Error::add_error(
1054
-                sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1055
-                __FILE__,
1056
-                __FUNCTION__,
1057
-                __LINE__
1058
-            );
1059
-        } else {
1060
-            EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1061
-        }
1062
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1063
-    }
1016
+	/**
1017
+	 * Takes care of deleting multiple EE_Checkin table rows
1018
+	 *
1019
+	 * @access protected
1020
+	 * @return void
1021
+	 * @throws EE_Error
1022
+	 * @throws InvalidArgumentException
1023
+	 * @throws InvalidDataTypeException
1024
+	 * @throws InvalidInterfaceException
1025
+	 */
1026
+	protected function _delete_checkin_rows()
1027
+	{
1028
+		$query_args = array(
1029
+			'action'  => 'registration_checkins',
1030
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1031
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1032
+		);
1033
+		$errors = 0;
1034
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1035
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1036
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1037
+					$errors++;
1038
+				}
1039
+			}
1040
+		} else {
1041
+			EE_Error::add_error(
1042
+				esc_html__(
1043
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1044
+					'event_espresso'
1045
+				),
1046
+				__FILE__,
1047
+				__FUNCTION__,
1048
+				__LINE__
1049
+			);
1050
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1051
+		}
1052
+		if ($errors > 0) {
1053
+			EE_Error::add_error(
1054
+				sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1055
+				__FILE__,
1056
+				__FUNCTION__,
1057
+				__LINE__
1058
+			);
1059
+		} else {
1060
+			EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1061
+		}
1062
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1063
+	}
1064 1064
 
1065 1065
 
1066
-    /**
1067
-     * Deletes a single EE_Checkin row
1068
-     *
1069
-     * @return void
1070
-     * @throws EE_Error
1071
-     * @throws InvalidArgumentException
1072
-     * @throws InvalidDataTypeException
1073
-     * @throws InvalidInterfaceException
1074
-     */
1075
-    protected function _delete_checkin_row()
1076
-    {
1077
-        $query_args = array(
1078
-            'action'  => 'registration_checkins',
1079
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1080
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1081
-        );
1082
-        if (! empty($this->_req_data['CHK_ID'])) {
1083
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1084
-                EE_Error::add_error(
1085
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1086
-                    __FILE__,
1087
-                    __FUNCTION__,
1088
-                    __LINE__
1089
-                );
1090
-            } else {
1091
-                EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1092
-            }
1093
-        } else {
1094
-            EE_Error::add_error(
1095
-                esc_html__(
1096
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1097
-                    'event_espresso'
1098
-                ),
1099
-                __FILE__,
1100
-                __FUNCTION__,
1101
-                __LINE__
1102
-            );
1103
-        }
1104
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1105
-    }
1066
+	/**
1067
+	 * Deletes a single EE_Checkin row
1068
+	 *
1069
+	 * @return void
1070
+	 * @throws EE_Error
1071
+	 * @throws InvalidArgumentException
1072
+	 * @throws InvalidDataTypeException
1073
+	 * @throws InvalidInterfaceException
1074
+	 */
1075
+	protected function _delete_checkin_row()
1076
+	{
1077
+		$query_args = array(
1078
+			'action'  => 'registration_checkins',
1079
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1080
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1081
+		);
1082
+		if (! empty($this->_req_data['CHK_ID'])) {
1083
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1084
+				EE_Error::add_error(
1085
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1086
+					__FILE__,
1087
+					__FUNCTION__,
1088
+					__LINE__
1089
+				);
1090
+			} else {
1091
+				EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1092
+			}
1093
+		} else {
1094
+			EE_Error::add_error(
1095
+				esc_html__(
1096
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1097
+					'event_espresso'
1098
+				),
1099
+				__FILE__,
1100
+				__FUNCTION__,
1101
+				__LINE__
1102
+			);
1103
+		}
1104
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1105
+	}
1106 1106
 
1107 1107
 
1108
-    /**
1109
-     *        generates HTML for the Event Registrations List Table
1110
-     *
1111
-     * @access protected
1112
-     * @return void
1113
-     * @throws EE_Error
1114
-     * @throws InvalidArgumentException
1115
-     * @throws InvalidDataTypeException
1116
-     * @throws InvalidInterfaceException
1117
-     */
1118
-    protected function _event_registrations_list_table()
1119
-    {
1120
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1121
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1122
-            ? $this->get_action_link_or_button(
1123
-                'new_registration',
1124
-                'add-registrant',
1125
-                array('event_id' => $this->_req_data['event_id']),
1126
-                'add-new-h2',
1127
-                '',
1128
-                false
1129
-            )
1130
-            : '';
1131
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1132
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1133
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1134
-        $legend_items = array(
1135
-            'star-icon'        => array(
1136
-                'class' => 'dashicons dashicons-star-filled gold-icon ee-icon-size-8',
1137
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1138
-            ),
1139
-            'checkin'          => array(
1140
-                'class' => $checked_in->cssClasses(),
1141
-                'desc'  => $checked_in->legendLabel(),
1142
-            ),
1143
-            'checkout'         => array(
1144
-                'class' => $checked_out->cssClasses(),
1145
-                'desc'  => $checked_out->legendLabel(),
1146
-            ),
1147
-            'nocheckinrecord'  => array(
1148
-                'class' => $checked_never->cssClasses(),
1149
-                'desc'  => $checked_never->legendLabel(),
1150
-            ),
1151
-            'approved_status'  => array(
1152
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_approved,
1153
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1154
-            ),
1155
-            'cancelled_status' => array(
1156
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_cancelled,
1157
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1158
-            ),
1159
-            'declined_status'  => array(
1160
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_declined,
1161
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1162
-            ),
1163
-            'not_approved'     => array(
1164
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_not_approved,
1165
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1166
-            ),
1167
-            'pending_status'   => array(
1168
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_pending_payment,
1169
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1170
-            ),
1171
-            'wait_list'        => array(
1172
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_wait_list,
1173
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1174
-            ),
1175
-        );
1176
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1177
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1178
-        /** @var EE_Event $event */
1179
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1180
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1181
-            ? '<h2>' . sprintf(
1182
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1183
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1184
-            ) . '</h2>'
1185
-            : '';
1186
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1187
-        // the event.
1188
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1189
-        $datetime = null;
1190
-        if ($event instanceof EE_Event) {
1191
-            $datetimes_on_event = $event->datetimes();
1192
-            if (count($datetimes_on_event) === 1) {
1193
-                $datetime = reset($datetimes_on_event);
1194
-            }
1195
-        }
1196
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1197
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1198
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1199
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1200
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1201
-            $this->_template_args['before_list_table'] .= $datetime->name();
1202
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1203
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1204
-        }
1205
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1206
-        // column represents
1207
-        if (! $datetime instanceof EE_Datetime) {
1208
-            $this->_template_args['before_list_table'] .= '<h3 class="description">'
1209
-                                                          . esc_html__(
1210
-                                                              'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1211
-                                                              'event_espresso'
1212
-                                                          )
1213
-                                                          . '</h3>';
1214
-        }
1215
-        $this->display_admin_list_table_page_with_no_sidebar();
1216
-    }
1108
+	/**
1109
+	 *        generates HTML for the Event Registrations List Table
1110
+	 *
1111
+	 * @access protected
1112
+	 * @return void
1113
+	 * @throws EE_Error
1114
+	 * @throws InvalidArgumentException
1115
+	 * @throws InvalidDataTypeException
1116
+	 * @throws InvalidInterfaceException
1117
+	 */
1118
+	protected function _event_registrations_list_table()
1119
+	{
1120
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1121
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1122
+			? $this->get_action_link_or_button(
1123
+				'new_registration',
1124
+				'add-registrant',
1125
+				array('event_id' => $this->_req_data['event_id']),
1126
+				'add-new-h2',
1127
+				'',
1128
+				false
1129
+			)
1130
+			: '';
1131
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1132
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1133
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1134
+		$legend_items = array(
1135
+			'star-icon'        => array(
1136
+				'class' => 'dashicons dashicons-star-filled gold-icon ee-icon-size-8',
1137
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1138
+			),
1139
+			'checkin'          => array(
1140
+				'class' => $checked_in->cssClasses(),
1141
+				'desc'  => $checked_in->legendLabel(),
1142
+			),
1143
+			'checkout'         => array(
1144
+				'class' => $checked_out->cssClasses(),
1145
+				'desc'  => $checked_out->legendLabel(),
1146
+			),
1147
+			'nocheckinrecord'  => array(
1148
+				'class' => $checked_never->cssClasses(),
1149
+				'desc'  => $checked_never->legendLabel(),
1150
+			),
1151
+			'approved_status'  => array(
1152
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_approved,
1153
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1154
+			),
1155
+			'cancelled_status' => array(
1156
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_cancelled,
1157
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1158
+			),
1159
+			'declined_status'  => array(
1160
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_declined,
1161
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1162
+			),
1163
+			'not_approved'     => array(
1164
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_not_approved,
1165
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1166
+			),
1167
+			'pending_status'   => array(
1168
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_pending_payment,
1169
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1170
+			),
1171
+			'wait_list'        => array(
1172
+				'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_wait_list,
1173
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1174
+			),
1175
+		);
1176
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1177
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1178
+		/** @var EE_Event $event */
1179
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1180
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1181
+			? '<h2>' . sprintf(
1182
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1183
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1184
+			) . '</h2>'
1185
+			: '';
1186
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1187
+		// the event.
1188
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1189
+		$datetime = null;
1190
+		if ($event instanceof EE_Event) {
1191
+			$datetimes_on_event = $event->datetimes();
1192
+			if (count($datetimes_on_event) === 1) {
1193
+				$datetime = reset($datetimes_on_event);
1194
+			}
1195
+		}
1196
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1197
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1198
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1199
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1200
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1201
+			$this->_template_args['before_list_table'] .= $datetime->name();
1202
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1203
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1204
+		}
1205
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1206
+		// column represents
1207
+		if (! $datetime instanceof EE_Datetime) {
1208
+			$this->_template_args['before_list_table'] .= '<h3 class="description">'
1209
+														  . esc_html__(
1210
+															  'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1211
+															  'event_espresso'
1212
+														  )
1213
+														  . '</h3>';
1214
+		}
1215
+		$this->display_admin_list_table_page_with_no_sidebar();
1216
+	}
1217 1217
 
1218
-    /**
1219
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1220
-     * conditions)
1221
-     *
1222
-     * @return void ends the request by a redirect or download
1223
-     */
1224
-    public function _registrations_checkin_report()
1225
-    {
1226
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1227
-    }
1218
+	/**
1219
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1220
+	 * conditions)
1221
+	 *
1222
+	 * @return void ends the request by a redirect or download
1223
+	 */
1224
+	public function _registrations_checkin_report()
1225
+	{
1226
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1227
+	}
1228 1228
 
1229
-    /**
1230
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1231
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1232
-     *
1233
-     * @param array $request
1234
-     * @param int   $per_page
1235
-     * @param bool  $count
1236
-     * @return array
1237
-     * @throws EE_Error
1238
-     */
1239
-    protected function _get_checkin_query_params_from_request(
1240
-        $request,
1241
-        $per_page = 10,
1242
-        $count = false
1243
-    ) {
1244
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1245
-        // unlike the regular registrations list table,
1246
-        $status_ids_array = apply_filters(
1247
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1248
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1249
-        );
1250
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1251
-        return $query_params;
1252
-    }
1229
+	/**
1230
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1231
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1232
+	 *
1233
+	 * @param array $request
1234
+	 * @param int   $per_page
1235
+	 * @param bool  $count
1236
+	 * @return array
1237
+	 * @throws EE_Error
1238
+	 */
1239
+	protected function _get_checkin_query_params_from_request(
1240
+		$request,
1241
+		$per_page = 10,
1242
+		$count = false
1243
+	) {
1244
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1245
+		// unlike the regular registrations list table,
1246
+		$status_ids_array = apply_filters(
1247
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1248
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1249
+		);
1250
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1251
+		return $query_params;
1252
+	}
1253 1253
 
1254 1254
 
1255
-    /**
1256
-     * Gets registrations for an event
1257
-     *
1258
-     * @param int    $per_page
1259
-     * @param bool   $count whether to return count or data.
1260
-     * @param bool   $trash
1261
-     * @param string $orderby
1262
-     * @return EE_Registration[]|int
1263
-     * @throws EE_Error
1264
-     * @throws InvalidArgumentException
1265
-     * @throws InvalidDataTypeException
1266
-     * @throws InvalidInterfaceException
1267
-     */
1268
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1269
-    {
1270
-        // normalize some request params that get setup by the parent `get_registrations` method.
1271
-        $request = $this->_req_data;
1272
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1273
-        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1274
-        if ($trash) {
1275
-            $request['status'] = 'trash';
1276
-        }
1277
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1278
-        /**
1279
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1280
-         *
1281
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1282
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1283
-         *                             or if you have the development copy of EE you can view this at the path:
1284
-         *                             /docs/G--Model-System/model-query-params.md
1285
-         */
1286
-        $query_params['group_by'] = '';
1255
+	/**
1256
+	 * Gets registrations for an event
1257
+	 *
1258
+	 * @param int    $per_page
1259
+	 * @param bool   $count whether to return count or data.
1260
+	 * @param bool   $trash
1261
+	 * @param string $orderby
1262
+	 * @return EE_Registration[]|int
1263
+	 * @throws EE_Error
1264
+	 * @throws InvalidArgumentException
1265
+	 * @throws InvalidDataTypeException
1266
+	 * @throws InvalidInterfaceException
1267
+	 */
1268
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1269
+	{
1270
+		// normalize some request params that get setup by the parent `get_registrations` method.
1271
+		$request = $this->_req_data;
1272
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1273
+		$request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1274
+		if ($trash) {
1275
+			$request['status'] = 'trash';
1276
+		}
1277
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1278
+		/**
1279
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1280
+		 *
1281
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1282
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1283
+		 *                             or if you have the development copy of EE you can view this at the path:
1284
+		 *                             /docs/G--Model-System/model-query-params.md
1285
+		 */
1286
+		$query_params['group_by'] = '';
1287 1287
 
1288
-        return $count
1289
-            ? EEM_Registration::instance()->count($query_params)
1290
-            /** @type EE_Registration[] */
1291
-            : EEM_Registration::instance()->get_all($query_params);
1292
-    }
1288
+		return $count
1289
+			? EEM_Registration::instance()->count($query_params)
1290
+			/** @type EE_Registration[] */
1291
+			: EEM_Registration::instance()->get_all($query_params);
1292
+	}
1293 1293
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
     public function __construct($routing = true)
33 33
     {
34 34
         parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
35
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
36
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
37
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
38
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
39 39
         }
40 40
     }
41 41
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected function _extend_page_config()
47 47
     {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
48
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
49 49
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50 50
             ? $this->_req_data['_REG_ID']
51 51
             : 0;
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
             // enqueue newsletter js
187 187
             wp_enqueue_script(
188 188
                 'ee-newsletter-trigger',
189
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
189
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
190 190
                 array('ee-dialog'),
191 191
                 EVENT_ESPRESSO_VERSION,
192 192
                 true
193 193
             );
194 194
             wp_enqueue_style(
195 195
                 'ee-newsletter-trigger-css',
196
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
196
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
197 197
                 array(),
198 198
                 EVENT_ESPRESSO_VERSION
199 199
             );
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     {
215 215
         wp_register_script(
216 216
             'ee-reg-reports-js',
217
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
217
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
218 218
             array('google-charts'),
219 219
             EVENT_ESPRESSO_VERSION,
220 220
             true
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $nonce_ref = 'get_newsletter_form_content_nonce';
301 301
         $this->_verify_nonce($nonce, $nonce_ref);
302 302
         // let's get the mtp for the incoming MTP_ ID
303
-        if (! isset($this->_req_data['GRP_ID'])) {
303
+        if ( ! isset($this->_req_data['GRP_ID'])) {
304 304
             EE_Error::add_error(
305 305
                 esc_html__(
306 306
                     'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             $this->_return_json();
316 316
         }
317 317
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
-        if (! $MTPG instanceof EE_Message_Template_Group) {
318
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
319 319
             EE_Error::add_error(
320 320
                 sprintf(
321 321
                     esc_html__(
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
             $field = $MTP->get('MTP_template_field');
341 341
             if ($field === 'content') {
342 342
                 $content = $MTP->get('MTP_content');
343
-                if (! empty($content['newsletter_content'])) {
343
+                if ( ! empty($content['newsletter_content'])) {
344 344
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
345 345
                 }
346 346
                 continue;
347 347
             }
348
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
348
+            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
349 349
         }
350 350
         $this->_template_args['success'] = true;
351 351
         $this->_template_args['error'] = false;
@@ -447,17 +447,17 @@  discard block
 block discarded – undo
447 447
                 $field_id = $field === '[NEWSLETTER_CONTENT]'
448 448
                     ? 'content'
449 449
                     : $field;
450
-                $field_id = 'batch-message-' . strtolower($field_id);
450
+                $field_id = 'batch-message-'.strtolower($field_id);
451 451
                 $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
452 452
                                           . $shortcode
453
-                                          . '" data-linked-input-id="' . $field_id . '">'
453
+                                          . '" data-linked-input-id="'.$field_id.'">'
454 454
                                           . $shortcode
455 455
                                           . '</span>';
456 456
             }
457
-            $codes[ $field ] = implode(', ', $available_shortcodes);
457
+            $codes[$field] = implode(', ', $available_shortcodes);
458 458
         }
459 459
         $shortcodes = $codes;
460
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
460
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
461 461
         $form_template_args = array(
462 462
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
463 463
             'form_route'        => 'newsletter_selected_send',
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
      */
626 626
     protected function _registration_reports()
627 627
     {
628
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
628
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
629 629
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
630 630
             $template_path,
631 631
             $this->_reports_template_data,
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
             array_unshift($regs, $column_titles);
681 681
             // setup the date range.
682 682
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
683
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
683
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
684 684
             $ending_date = new DateTime("now", $DateTimeZone);
685 685
             $subtitle = sprintf(
686 686
                 wp_strip_all_tags(
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
                         'event_espresso'
705 705
                     )
706 706
                 ),
707
-                '<h2>' . $report_title . '</h2><p>',
707
+                '<h2>'.$report_title.'</h2><p>',
708 708
                 '</p>'
709 709
             ),
710 710
         );
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
             array_unshift($regs, $column_titles);
758 758
             // setup the date range.
759 759
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
760
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
760
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
761 761
             $ending_date = new DateTime("now", $DateTimeZone);
762 762
             $subtitle = sprintf(
763 763
                 wp_strip_all_tags(
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
                         'event_espresso'
782 782
                     )
783 783
                 ),
784
-                '<h2>' . $report_title . '</h2><p>',
784
+                '<h2>'.$report_title.'</h2><p>',
785 785
                 '</p>'
786 786
             ),
787 787
         );
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
         $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
808 808
         /** @var EE_Registration $registration */
809 809
         $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
810
-        if (! $registration instanceof EE_Registration) {
810
+        if ( ! $registration instanceof EE_Registration) {
811 811
             throw new EE_Error(
812 812
                 sprintf(
813 813
                     esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
         if ($datetime instanceof EE_Datetime) {
843 843
             $datetime_label = $datetime->get_dtt_display_name(true);
844 844
             $datetime_label .= ! empty($datetime_label)
845
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
845
+                ? ' ('.$datetime->get_dtt_display_name().')'
846 846
                 : $datetime->get_dtt_display_name();
847 847
         }
848 848
         $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             )
857 857
             : '';
858 858
         $datetime_link = ! empty($datetime_link)
859
-            ? '<a href="' . $datetime_link . '">'
859
+            ? '<a href="'.$datetime_link.'">'
860 860
               . '<span id="checkin-dtt">'
861 861
               . $datetime_label
862 862
               . '</span></a>'
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
             ? $attendee->get_admin_details_link()
869 869
             : '';
870 870
         $attendee_link = ! empty($attendee_link)
871
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
872
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
871
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
872
+              . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">'
873 873
               . '<span id="checkin-attendee-name">'
874 874
               . $attendee_name
875 875
               . '</span></a>'
@@ -878,25 +878,25 @@  discard block
 block discarded – undo
878 878
             ? $registration->event()->get_admin_details_link()
879 879
             : '';
880 880
         $event_link = ! empty($event_link)
881
-            ? '<a href="' . $event_link . '"'
882
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
881
+            ? '<a href="'.$event_link.'"'
882
+              . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
883 883
               . '<span id="checkin-event-name">'
884 884
               . $registration->event_name()
885 885
               . '</span>'
886 886
               . '</a>'
887 887
             : '';
888 888
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
889
-            ? '<h2>' . sprintf(
889
+            ? '<h2>'.sprintf(
890 890
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
891 891
                 $attendee_link,
892 892
                 $datetime_link,
893 893
                 $event_link
894
-            ) . '</h2>'
894
+            ).'</h2>'
895 895
             : '';
896 896
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
897
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
897
+            ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : '';
898 898
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
899
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
899
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
900 900
         $this->display_admin_list_table_page_with_no_sidebar();
901 901
     }
902 902
 
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
     public function toggle_checkin_status()
914 914
     {
915 915
         // first make sure we have the necessary data
916
-        if (! isset($this->_req_data['_regid'])) {
916
+        if ( ! isset($this->_req_data['_regid'])) {
917 917
             EE_Error::add_error(
918 918
                 esc_html__(
919 919
                     'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
         // beautiful! Made it this far so let's get the status.
936 936
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
937 937
         // setup new class to return via ajax
938
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
938
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
939 939
         $this->_template_args['success'] = true;
940 940
         $this->_return_json();
941 941
     }
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
         );
962 962
         $new_status = false;
963 963
         // bulk action check in toggle
964
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
964
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
965 965
             // cycle thru checkboxes
966 966
             while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
967 967
                 $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
@@ -1031,9 +1031,9 @@  discard block
 block discarded – undo
1031 1031
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1032 1032
         );
1033 1033
         $errors = 0;
1034
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1034
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1035 1035
             while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1036
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1036
+                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1037 1037
                     $errors++;
1038 1038
                 }
1039 1039
             }
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1080 1080
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1081 1081
         );
1082
-        if (! empty($this->_req_data['CHK_ID'])) {
1083
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1082
+        if ( ! empty($this->_req_data['CHK_ID'])) {
1083
+            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1084 1084
                 EE_Error::add_error(
1085 1085
                     esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1086 1086
                     __FILE__,
@@ -1149,27 +1149,27 @@  discard block
 block discarded – undo
1149 1149
                 'desc'  => $checked_never->legendLabel(),
1150 1150
             ),
1151 1151
             'approved_status'  => array(
1152
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_approved,
1152
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_approved,
1153 1153
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1154 1154
             ),
1155 1155
             'cancelled_status' => array(
1156
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_cancelled,
1156
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_cancelled,
1157 1157
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1158 1158
             ),
1159 1159
             'declined_status'  => array(
1160
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_declined,
1160
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_declined,
1161 1161
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1162 1162
             ),
1163 1163
             'not_approved'     => array(
1164
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_not_approved,
1164
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_not_approved,
1165 1165
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1166 1166
             ),
1167 1167
             'pending_status'   => array(
1168
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_pending_payment,
1168
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_pending_payment,
1169 1169
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1170 1170
             ),
1171 1171
             'wait_list'        => array(
1172
-                'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_wait_list,
1172
+                'class' => 'ee-status-legend ee-status-legend--'.EEM_Registration::status_id_wait_list,
1173 1173
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1174 1174
             ),
1175 1175
         );
@@ -1178,10 +1178,10 @@  discard block
 block discarded – undo
1178 1178
         /** @var EE_Event $event */
1179 1179
         $event = EEM_Event::instance()->get_one_by_ID($event_id);
1180 1180
         $this->_template_args['before_list_table'] = $event instanceof EE_Event
1181
-            ? '<h2>' . sprintf(
1181
+            ? '<h2>'.sprintf(
1182 1182
                 esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1183 1183
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1184
-            ) . '</h2>'
1184
+            ).'</h2>'
1185 1185
             : '';
1186 1186
         // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1187 1187
         // the event.
@@ -1199,12 +1199,12 @@  discard block
 block discarded – undo
1199 1199
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1200 1200
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1201 1201
             $this->_template_args['before_list_table'] .= $datetime->name();
1202
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1202
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1203 1203
             $this->_template_args['before_list_table'] .= '</span></h2>';
1204 1204
         }
1205 1205
         // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1206 1206
         // column represents
1207
-        if (! $datetime instanceof EE_Datetime) {
1207
+        if ( ! $datetime instanceof EE_Datetime) {
1208 1208
             $this->_template_args['before_list_table'] .= '<h3 class="description">'
1209 1209
                                                           . esc_html__(
1210 1210
                                                               'In this view, the check-in status represents the latest check-in record for the registration in that row.',
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +569 added lines, -569 removed lines patch added patch discarded remove patch
@@ -12,581 +12,581 @@
 block discarded – undo
12 12
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
13 13
 {
14 14
 
15
-    /**
16
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
17
-     *
18
-     * @var EE_Datetime[]
19
-     */
20
-    protected $_dtts_for_event = array();
21
-
22
-
23
-    /**
24
-     * The event if one is specified in the request
25
-     *
26
-     * @var EE_Event
27
-     */
28
-    protected $_evt = null;
29
-
30
-
31
-    /**
32
-     * The DTT_ID if the current view has a specified datetime.
33
-     *
34
-     * @var int $_cur_dtt_id
35
-     */
36
-    protected $_cur_dtt_id = 0;
37
-
38
-
39
-    /**
40
-     * EE_Event_Registrations_List_Table constructor.
41
-     *
42
-     * @param \Registrations_Admin_Page $admin_page
43
-     */
44
-    public function __construct($admin_page)
45
-    {
46
-        parent::__construct($admin_page);
47
-        $this->_status = $this->_admin_page->get_registration_status_array();
48
-    }
49
-
50
-
51
-    protected function _setup_data()
52
-    {
53
-        $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55
-        $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56
-            $this->_per_page,
57
-            true
58
-        ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59
-    }
60
-
61
-
62
-    protected function _set_properties()
63
-    {
64
-        $return_url = $this->getReturnUrl();
65
-
66
-        $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
67
-        $this->_wp_list_args = array(
68
-            'singular' => esc_html__('registrant', 'event_espresso'),
69
-            'plural'   => esc_html__('registrants', 'event_espresso'),
70
-            'ajax'     => true,
71
-            'screen'   => $this->_admin_page->get_current_screen()->id,
72
-        );
73
-        $columns = array();
74
-        $this->_columns = array(
75
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
76
-            'status' => '',
77
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
78
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
79
-            'Event'               => esc_html__('Event', 'event_espresso'),
80
-            'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
81
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
82
-            'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
83
-            'TXN_total'           => esc_html__('Total', 'event_espresso'),
84
-        );
85
-        // Add/remove columns when an event has been selected
86
-        if (! empty($evt_id)) {
87
-            // Render a checkbox column
88
-            $columns['cb'] = '<input type="checkbox" />';
89
-            $this->_has_checkbox_column = true;
90
-            // Remove the 'Event' column
91
-            unset($this->_columns['Event']);
92
-        }
93
-        $this->_columns = array_merge($columns, $this->_columns);
94
-        $this->_primary_column = '_REG_att_checked_in';
95
-        if (
96
-            ! empty($evt_id)
97
-            && EE_Registry::instance()->CAP->current_user_can(
98
-                'ee_read_registrations',
99
-                'espresso_registrations_registrations_reports',
100
-                $evt_id
101
-            )
102
-        ) {
103
-            $this->_bottom_buttons = array(
104
-                'report' => array(
105
-                    'route'         => 'registrations_report',
106
-                    'extra_request' =>
107
-                        array(
108
-                            'EVT_ID'     => $evt_id,
109
-                            'return_url' => $return_url,
110
-                        ),
111
-                ),
112
-            );
113
-        }
114
-        $this->_bottom_buttons['report_filtered'] = array(
115
-            'route'         => 'registrations_checkin_report',
116
-            'extra_request' => array(
117
-                'use_filters' => true,
118
-                'filters'     => array_merge(
119
-                    array(
120
-                        'EVT_ID' => $evt_id,
121
-                    ),
122
-                    array_diff_key(
123
-                        $this->_req_data,
124
-                        array_flip(
125
-                            array(
126
-                                'page',
127
-                                'action',
128
-                                'default_nonce',
129
-                            )
130
-                        )
131
-                    )
132
-                ),
133
-                'return_url'  => $return_url,
134
-            ),
135
-        );
136
-        $this->_sortable_columns = array(
137
-            /**
138
-             * Allows users to change the default sort if they wish.
139
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
140
-             *
141
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
142
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
143
-             * for a specific list table you can use the provided reference to this object instance.
144
-             */
145
-            'ATT_name' => array(
146
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
147
-                true,
148
-                $this,
149
-            )
150
-                ? array('ATT_lname' => true)
151
-                : array('ATT_fname' => true),
152
-            'Event'    => array('Event.EVT_name' => false),
153
-        );
154
-        $this->_hidden_columns = array();
155
-        $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
156
-        $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
157
-    }
158
-
159
-
160
-    /**
161
-     * @param \EE_Registration $item
162
-     * @return string
163
-     */
164
-    protected function _get_row_class($item)
165
-    {
166
-        $class = parent::_get_row_class($item);
167
-        // add status class
168
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
169
-        if ($this->_has_checkbox_column) {
170
-            $class .= ' has-checkbox-column';
171
-        }
172
-        return $class;
173
-    }
174
-
175
-
176
-    /**
177
-     * @return array
178
-     * @throws \EE_Error
179
-     */
180
-    protected function _get_table_filters()
181
-    {
182
-        $filters = $where = array();
183
-        $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
184
-        if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
185
-            // this means we don't have an event so let's setup a filter dropdown for all the events to select
186
-            // note possible capability restrictions
187
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
188
-                $where['status**'] = array('!=', 'private');
189
-            }
190
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
191
-                $where['EVT_wp_user'] = get_current_user_id();
192
-            }
193
-            $events = EEM_Event::instance()->get_all(
194
-                array(
195
-                    $where,
196
-                    'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
197
-                )
198
-            );
199
-            $evts[] = array(
200
-                'id'   => 0,
201
-                'text' => esc_html__(' - select an event - ', 'event_espresso'),
202
-            );
203
-            $checked = 'checked';
204
-            /** @var EE_Event $evt */
205
-            foreach ($events as $evt) {
206
-                // any registrations for this event?
207
-                if (! $evt->get_count_of_all_registrations()) {
208
-                    continue;
209
-                }
210
-                $evts[] = array(
211
-                    'id'    => $evt->ID(),
212
-                    'text'  => apply_filters(
213
-                        'FHEE__EE_Event_Registrations___get_table_filters__event_name',
214
-                        $evt->get('EVT_name'),
215
-                        $evt
216
-                    ),
217
-                    'class' => $evt->is_expired() ? 'ee-expired-event' : '',
218
-                );
219
-                if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
220
-                    $checked = '';
221
-                }
222
-            }
223
-            $event_filter = '<div class="ee-event-filter">';
224
-            $event_filter .= '<label for="event_id">';
225
-            $event_filter .= esc_html__('Check-in Status for', 'event_espresso');
226
-            $event_filter .= '</label>&nbsp;&nbsp;';
227
-            $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
228
-            $event_filter .= '<span class="ee-event-filter-toggle">';
229
-            $event_filter .= '<label for="js-ee-hide-expired-events">';
230
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '>&nbsp;&nbsp;';
231
-            $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
232
-            $event_filter .= '</label>';
233
-            $event_filter .= '</span>';
234
-            $event_filter .= '</div>';
235
-            $filters[] = $event_filter;
236
-        }
237
-        if (! empty($this->_dtts_for_event)) {
238
-            // DTT datetimes filter
239
-            $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
240
-            if (count($this->_dtts_for_event) > 1) {
241
-                $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
242
-                foreach ($this->_dtts_for_event as $dtt) {
243
-                    $datetime_string = $dtt->name();
244
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
245
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
246
-                    $dtts[ $dtt->ID() ] = $datetime_string;
247
-                }
248
-                $input = new EE_Select_Input(
249
-                    $dtts,
250
-                    array(
251
-                        'html_name' => 'DTT_ID',
252
-                        'html_id'   => 'DTT_ID',
253
-                        'default'   => $this->_cur_dtt_id,
254
-                    )
255
-                );
256
-                $filters[] = $input->get_html_for_input();
257
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
258
-            }
259
-        }
260
-        return $filters;
261
-    }
262
-
263
-
264
-    protected function _add_view_counts()
265
-    {
266
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
267
-    }
268
-
269
-
270
-    /**
271
-     * @return int
272
-     * @throws \EE_Error
273
-     */
274
-    protected function _get_total_event_attendees()
275
-    {
276
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
277
-        $DTT_ID = $this->_cur_dtt_id;
278
-        $query_params = array();
279
-        if ($EVT_ID) {
280
-            $query_params[0]['EVT_ID'] = $EVT_ID;
281
-        }
282
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
283
-        if ($DTT_ID) {
284
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
285
-        }
286
-        $status_ids_array = apply_filters(
287
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
288
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
289
-        );
290
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
291
-        return EEM_Registration::instance()->count($query_params);
292
-    }
293
-
294
-
295
-    /**
296
-     *    column status
297
-     *
298
-     * @param EE_Registration $registration
299
-     * @return string
300
-     * @throws EE_Error
301
-     */
302
-    public function column_status(EE_Registration $registration)
303
-    {
304
-        return '
15
+	/**
16
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
17
+	 *
18
+	 * @var EE_Datetime[]
19
+	 */
20
+	protected $_dtts_for_event = array();
21
+
22
+
23
+	/**
24
+	 * The event if one is specified in the request
25
+	 *
26
+	 * @var EE_Event
27
+	 */
28
+	protected $_evt = null;
29
+
30
+
31
+	/**
32
+	 * The DTT_ID if the current view has a specified datetime.
33
+	 *
34
+	 * @var int $_cur_dtt_id
35
+	 */
36
+	protected $_cur_dtt_id = 0;
37
+
38
+
39
+	/**
40
+	 * EE_Event_Registrations_List_Table constructor.
41
+	 *
42
+	 * @param \Registrations_Admin_Page $admin_page
43
+	 */
44
+	public function __construct($admin_page)
45
+	{
46
+		parent::__construct($admin_page);
47
+		$this->_status = $this->_admin_page->get_registration_status_array();
48
+	}
49
+
50
+
51
+	protected function _setup_data()
52
+	{
53
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55
+		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56
+			$this->_per_page,
57
+			true
58
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59
+	}
60
+
61
+
62
+	protected function _set_properties()
63
+	{
64
+		$return_url = $this->getReturnUrl();
65
+
66
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
67
+		$this->_wp_list_args = array(
68
+			'singular' => esc_html__('registrant', 'event_espresso'),
69
+			'plural'   => esc_html__('registrants', 'event_espresso'),
70
+			'ajax'     => true,
71
+			'screen'   => $this->_admin_page->get_current_screen()->id,
72
+		);
73
+		$columns = array();
74
+		$this->_columns = array(
75
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
76
+			'status' => '',
77
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
78
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
79
+			'Event'               => esc_html__('Event', 'event_espresso'),
80
+			'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
81
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
82
+			'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
83
+			'TXN_total'           => esc_html__('Total', 'event_espresso'),
84
+		);
85
+		// Add/remove columns when an event has been selected
86
+		if (! empty($evt_id)) {
87
+			// Render a checkbox column
88
+			$columns['cb'] = '<input type="checkbox" />';
89
+			$this->_has_checkbox_column = true;
90
+			// Remove the 'Event' column
91
+			unset($this->_columns['Event']);
92
+		}
93
+		$this->_columns = array_merge($columns, $this->_columns);
94
+		$this->_primary_column = '_REG_att_checked_in';
95
+		if (
96
+			! empty($evt_id)
97
+			&& EE_Registry::instance()->CAP->current_user_can(
98
+				'ee_read_registrations',
99
+				'espresso_registrations_registrations_reports',
100
+				$evt_id
101
+			)
102
+		) {
103
+			$this->_bottom_buttons = array(
104
+				'report' => array(
105
+					'route'         => 'registrations_report',
106
+					'extra_request' =>
107
+						array(
108
+							'EVT_ID'     => $evt_id,
109
+							'return_url' => $return_url,
110
+						),
111
+				),
112
+			);
113
+		}
114
+		$this->_bottom_buttons['report_filtered'] = array(
115
+			'route'         => 'registrations_checkin_report',
116
+			'extra_request' => array(
117
+				'use_filters' => true,
118
+				'filters'     => array_merge(
119
+					array(
120
+						'EVT_ID' => $evt_id,
121
+					),
122
+					array_diff_key(
123
+						$this->_req_data,
124
+						array_flip(
125
+							array(
126
+								'page',
127
+								'action',
128
+								'default_nonce',
129
+							)
130
+						)
131
+					)
132
+				),
133
+				'return_url'  => $return_url,
134
+			),
135
+		);
136
+		$this->_sortable_columns = array(
137
+			/**
138
+			 * Allows users to change the default sort if they wish.
139
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
140
+			 *
141
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
142
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
143
+			 * for a specific list table you can use the provided reference to this object instance.
144
+			 */
145
+			'ATT_name' => array(
146
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
147
+				true,
148
+				$this,
149
+			)
150
+				? array('ATT_lname' => true)
151
+				: array('ATT_fname' => true),
152
+			'Event'    => array('Event.EVT_name' => false),
153
+		);
154
+		$this->_hidden_columns = array();
155
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
156
+		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param \EE_Registration $item
162
+	 * @return string
163
+	 */
164
+	protected function _get_row_class($item)
165
+	{
166
+		$class = parent::_get_row_class($item);
167
+		// add status class
168
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
169
+		if ($this->_has_checkbox_column) {
170
+			$class .= ' has-checkbox-column';
171
+		}
172
+		return $class;
173
+	}
174
+
175
+
176
+	/**
177
+	 * @return array
178
+	 * @throws \EE_Error
179
+	 */
180
+	protected function _get_table_filters()
181
+	{
182
+		$filters = $where = array();
183
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
184
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
185
+			// this means we don't have an event so let's setup a filter dropdown for all the events to select
186
+			// note possible capability restrictions
187
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
188
+				$where['status**'] = array('!=', 'private');
189
+			}
190
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
191
+				$where['EVT_wp_user'] = get_current_user_id();
192
+			}
193
+			$events = EEM_Event::instance()->get_all(
194
+				array(
195
+					$where,
196
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
197
+				)
198
+			);
199
+			$evts[] = array(
200
+				'id'   => 0,
201
+				'text' => esc_html__(' - select an event - ', 'event_espresso'),
202
+			);
203
+			$checked = 'checked';
204
+			/** @var EE_Event $evt */
205
+			foreach ($events as $evt) {
206
+				// any registrations for this event?
207
+				if (! $evt->get_count_of_all_registrations()) {
208
+					continue;
209
+				}
210
+				$evts[] = array(
211
+					'id'    => $evt->ID(),
212
+					'text'  => apply_filters(
213
+						'FHEE__EE_Event_Registrations___get_table_filters__event_name',
214
+						$evt->get('EVT_name'),
215
+						$evt
216
+					),
217
+					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
218
+				);
219
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
220
+					$checked = '';
221
+				}
222
+			}
223
+			$event_filter = '<div class="ee-event-filter">';
224
+			$event_filter .= '<label for="event_id">';
225
+			$event_filter .= esc_html__('Check-in Status for', 'event_espresso');
226
+			$event_filter .= '</label>&nbsp;&nbsp;';
227
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
228
+			$event_filter .= '<span class="ee-event-filter-toggle">';
229
+			$event_filter .= '<label for="js-ee-hide-expired-events">';
230
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '>&nbsp;&nbsp;';
231
+			$event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
232
+			$event_filter .= '</label>';
233
+			$event_filter .= '</span>';
234
+			$event_filter .= '</div>';
235
+			$filters[] = $event_filter;
236
+		}
237
+		if (! empty($this->_dtts_for_event)) {
238
+			// DTT datetimes filter
239
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
240
+			if (count($this->_dtts_for_event) > 1) {
241
+				$dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
242
+				foreach ($this->_dtts_for_event as $dtt) {
243
+					$datetime_string = $dtt->name();
244
+					$datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
245
+					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
246
+					$dtts[ $dtt->ID() ] = $datetime_string;
247
+				}
248
+				$input = new EE_Select_Input(
249
+					$dtts,
250
+					array(
251
+						'html_name' => 'DTT_ID',
252
+						'html_id'   => 'DTT_ID',
253
+						'default'   => $this->_cur_dtt_id,
254
+					)
255
+				);
256
+				$filters[] = $input->get_html_for_input();
257
+				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
258
+			}
259
+		}
260
+		return $filters;
261
+	}
262
+
263
+
264
+	protected function _add_view_counts()
265
+	{
266
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
267
+	}
268
+
269
+
270
+	/**
271
+	 * @return int
272
+	 * @throws \EE_Error
273
+	 */
274
+	protected function _get_total_event_attendees()
275
+	{
276
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
277
+		$DTT_ID = $this->_cur_dtt_id;
278
+		$query_params = array();
279
+		if ($EVT_ID) {
280
+			$query_params[0]['EVT_ID'] = $EVT_ID;
281
+		}
282
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
283
+		if ($DTT_ID) {
284
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
285
+		}
286
+		$status_ids_array = apply_filters(
287
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
288
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
289
+		);
290
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
291
+		return EEM_Registration::instance()->count($query_params);
292
+	}
293
+
294
+
295
+	/**
296
+	 *    column status
297
+	 *
298
+	 * @param EE_Registration $registration
299
+	 * @return string
300
+	 * @throws EE_Error
301
+	 */
302
+	public function column_status(EE_Registration $registration)
303
+	{
304
+		return '
305 305
         <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" 
306 306
         aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">        
307 307
         </span>';
308
-    }
309
-
310
-
311
-    /**
312
-     * @param \EE_Registration $item
313
-     * @return string
314
-     * @throws \EE_Error
315
-     */
316
-    public function column_cb($item)
317
-    {
318
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
319
-    }
320
-
321
-
322
-    /**
323
-     * column_REG_att_checked_in
324
-     *
325
-     * @param EE_Registration $item
326
-     * @return string
327
-     * @throws EE_Error
328
-     * @throws InvalidArgumentException
329
-     * @throws InvalidDataTypeException
330
-     * @throws InvalidInterfaceException
331
-     */
332
-    public function column__REG_att_checked_in(EE_Registration $item)
333
-    {
334
-        $attendee = $item->attendee();
335
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
336
-
337
-        if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
338
-            $latest_related_datetime = $item->get_latest_related_datetime();
339
-            if ($latest_related_datetime instanceof EE_Datetime) {
340
-                $this->_cur_dtt_id = $latest_related_datetime->ID();
341
-            }
342
-        }
343
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
344
-            $item,
345
-            $this->_cur_dtt_id
346
-        );
347
-        $nonce = wp_create_nonce('checkin_nonce');
348
-        $toggle_active = ! empty($this->_cur_dtt_id)
349
-                         && EE_Registry::instance()->CAP->current_user_can(
350
-                             'ee_edit_checkin',
351
-                             'espresso_registrations_toggle_checkin_status',
352
-                             $item->ID()
353
-                         )
354
-            ? ' clickable trigger-checkin'
355
-            : '';
356
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
357
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
358
-               . ' data-_regid="' . $item->ID() . '"'
359
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
360
-               . ' data-nonce="' . $nonce . '">'
361
-               . '</span>'
362
-               . $mobile_view_content;
363
-    }
364
-
365
-
366
-    /**
367
-     * @param \EE_Registration $item
368
-     * @return mixed|string|void
369
-     * @throws \EE_Error
370
-     */
371
-    public function column_ATT_name(EE_Registration $item)
372
-    {
373
-        $attendee = $item->attendee();
374
-        if (! $attendee instanceof EE_Attendee) {
375
-            return esc_html__('No contact record for this registration.', 'event_espresso');
376
-        }
377
-        // edit attendee link
378
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
379
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
380
-            REG_ADMIN_URL
381
-        );
382
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
383
-            'ee_edit_contacts',
384
-            'espresso_registrations_edit_attendee'
385
-        )
386
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
387
-              . $item->attendee()->full_name()
388
-              . '</a>'
389
-            : $item->attendee()->full_name();
390
-        $name_link .= $item->count() === 1
391
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon ee-icon-size-8"></div></sup>	'
392
-            : '';
393
-        // add group details
394
-        $name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
395
-        // add regcode
396
-        $link = EE_Admin_Page::add_query_args_and_nonce(
397
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
398
-            REG_ADMIN_URL
399
-        );
400
-        $name_link .= '<br>';
401
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
402
-            'ee_read_registration',
403
-            'view_registration',
404
-            $item->ID()
405
-        )
406
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
407
-              . $item->reg_code()
408
-              . '</a>'
409
-            : $item->reg_code();
410
-        // status
411
-        $name_link .= '<br><span class="ee-status-text-small">';
412
-        $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
413
-        $name_link .= '</span>';
414
-        $actions = array();
415
-        $DTT_ID = $this->_cur_dtt_id;
416
-        $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
417
-            ? $item->get_latest_related_datetime()
418
-            : null;
419
-        $DTT_ID = $latest_related_datetime instanceof EE_Datetime
420
-            ? $latest_related_datetime->ID()
421
-            : $DTT_ID;
422
-        if (
423
-            ! empty($DTT_ID)
424
-            && EE_Registry::instance()->CAP->current_user_can(
425
-                'ee_read_checkins',
426
-                'espresso_registrations_registration_checkins'
427
-            )
428
-        ) {
429
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
430
-                array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
431
-                REG_ADMIN_URL
432
-            );
433
-            // get the timestamps for this registration's checkins, related to the selected datetime
434
-            $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
435
-            if (! empty($timestamps)) {
436
-                // get the last timestamp
437
-                $last_timestamp = end($timestamps);
438
-                // checked in or checked out?
439
-                $checkin_status = $last_timestamp->get('CHK_in')
440
-                    ? esc_html__('Checked In', 'event_espresso')
441
-                    : esc_html__('Checked Out', 'event_espresso');
442
-                // get timestamp string
443
-                $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
444
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
445
-                                      . esc_attr__(
446
-                                          'View this registrant\'s check-ins/checkouts for the datetime',
447
-                                          'event_espresso'
448
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
449
-            }
450
-        }
451
-        return (! empty($DTT_ID) && ! empty($timestamps))
452
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
453
-            : $name_link;
454
-    }
455
-
456
-
457
-    /**
458
-     * @param \EE_Registration $item
459
-     * @return string
460
-     */
461
-    public function column_ATT_email(EE_Registration $item)
462
-    {
463
-        $attendee = $item->attendee();
464
-        return $attendee instanceof EE_Attendee ? $attendee->email() : '';
465
-    }
466
-
467
-
468
-    /**
469
-     * @param \EE_Registration $item
470
-     * @return bool|string
471
-     * @throws \EE_Error
472
-     */
473
-    public function column_Event(EE_Registration $item)
474
-    {
475
-        try {
476
-            $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
477
-            $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
478
-                array('action' => 'event_registrations', 'event_id' => $event->ID()),
479
-                REG_ADMIN_URL
480
-            );
481
-            $event_label = EE_Registry::instance()->CAP->current_user_can(
482
-                'ee_read_checkins',
483
-                'espresso_registrations_registration_checkins'
484
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
485
-                . esc_attr__(
486
-                    'View Checkins for this Event',
487
-                    'event_espresso'
488
-                ) . '">' . $event->name() . '</a>' : $event->name();
489
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
490
-            $event_label = esc_html__('Unknown', 'event_espresso');
491
-        }
492
-        return $event_label;
493
-    }
494
-
495
-
496
-    /**
497
-     * @param \EE_Registration $item
498
-     * @return mixed|string|void
499
-     */
500
-    public function column_PRC_name(EE_Registration $item)
501
-    {
502
-        return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
503
-    }
504
-
505
-
506
-    /**
507
-     * column_REG_final_price
508
-     *
509
-     * @param \EE_Registration $item
510
-     * @return string
511
-     */
512
-    public function column__REG_final_price(EE_Registration $item)
513
-    {
514
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
515
-    }
516
-
517
-
518
-    /**
519
-     * column_TXN_paid
520
-     *
521
-     * @param \EE_Registration $item
522
-     * @return string
523
-     * @throws \EE_Error
524
-     */
525
-    public function column_TXN_paid(EE_Registration $item)
526
-    {
527
-        if ($item->count() === 1) {
528
-            if ($item->transaction()->paid() >= $item->transaction()->total()) {
529
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
530
-            } else {
531
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
532
-                    array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
533
-                    TXN_ADMIN_URL
534
-                );
535
-                return EE_Registry::instance()->CAP->current_user_can(
536
-                    'ee_read_transaction',
537
-                    'espresso_transactions_view_transaction'
538
-                ) ? '
308
+	}
309
+
310
+
311
+	/**
312
+	 * @param \EE_Registration $item
313
+	 * @return string
314
+	 * @throws \EE_Error
315
+	 */
316
+	public function column_cb($item)
317
+	{
318
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
319
+	}
320
+
321
+
322
+	/**
323
+	 * column_REG_att_checked_in
324
+	 *
325
+	 * @param EE_Registration $item
326
+	 * @return string
327
+	 * @throws EE_Error
328
+	 * @throws InvalidArgumentException
329
+	 * @throws InvalidDataTypeException
330
+	 * @throws InvalidInterfaceException
331
+	 */
332
+	public function column__REG_att_checked_in(EE_Registration $item)
333
+	{
334
+		$attendee = $item->attendee();
335
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
336
+
337
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
338
+			$latest_related_datetime = $item->get_latest_related_datetime();
339
+			if ($latest_related_datetime instanceof EE_Datetime) {
340
+				$this->_cur_dtt_id = $latest_related_datetime->ID();
341
+			}
342
+		}
343
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
344
+			$item,
345
+			$this->_cur_dtt_id
346
+		);
347
+		$nonce = wp_create_nonce('checkin_nonce');
348
+		$toggle_active = ! empty($this->_cur_dtt_id)
349
+						 && EE_Registry::instance()->CAP->current_user_can(
350
+							 'ee_edit_checkin',
351
+							 'espresso_registrations_toggle_checkin_status',
352
+							 $item->ID()
353
+						 )
354
+			? ' clickable trigger-checkin'
355
+			: '';
356
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
357
+		return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
358
+			   . ' data-_regid="' . $item->ID() . '"'
359
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
360
+			   . ' data-nonce="' . $nonce . '">'
361
+			   . '</span>'
362
+			   . $mobile_view_content;
363
+	}
364
+
365
+
366
+	/**
367
+	 * @param \EE_Registration $item
368
+	 * @return mixed|string|void
369
+	 * @throws \EE_Error
370
+	 */
371
+	public function column_ATT_name(EE_Registration $item)
372
+	{
373
+		$attendee = $item->attendee();
374
+		if (! $attendee instanceof EE_Attendee) {
375
+			return esc_html__('No contact record for this registration.', 'event_espresso');
376
+		}
377
+		// edit attendee link
378
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
379
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
380
+			REG_ADMIN_URL
381
+		);
382
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
383
+			'ee_edit_contacts',
384
+			'espresso_registrations_edit_attendee'
385
+		)
386
+			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
387
+			  . $item->attendee()->full_name()
388
+			  . '</a>'
389
+			: $item->attendee()->full_name();
390
+		$name_link .= $item->count() === 1
391
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon ee-icon-size-8"></div></sup>	'
392
+			: '';
393
+		// add group details
394
+		$name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
395
+		// add regcode
396
+		$link = EE_Admin_Page::add_query_args_and_nonce(
397
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
398
+			REG_ADMIN_URL
399
+		);
400
+		$name_link .= '<br>';
401
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
402
+			'ee_read_registration',
403
+			'view_registration',
404
+			$item->ID()
405
+		)
406
+			? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
407
+			  . $item->reg_code()
408
+			  . '</a>'
409
+			: $item->reg_code();
410
+		// status
411
+		$name_link .= '<br><span class="ee-status-text-small">';
412
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
413
+		$name_link .= '</span>';
414
+		$actions = array();
415
+		$DTT_ID = $this->_cur_dtt_id;
416
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
417
+			? $item->get_latest_related_datetime()
418
+			: null;
419
+		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
420
+			? $latest_related_datetime->ID()
421
+			: $DTT_ID;
422
+		if (
423
+			! empty($DTT_ID)
424
+			&& EE_Registry::instance()->CAP->current_user_can(
425
+				'ee_read_checkins',
426
+				'espresso_registrations_registration_checkins'
427
+			)
428
+		) {
429
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
430
+				array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
431
+				REG_ADMIN_URL
432
+			);
433
+			// get the timestamps for this registration's checkins, related to the selected datetime
434
+			$timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
435
+			if (! empty($timestamps)) {
436
+				// get the last timestamp
437
+				$last_timestamp = end($timestamps);
438
+				// checked in or checked out?
439
+				$checkin_status = $last_timestamp->get('CHK_in')
440
+					? esc_html__('Checked In', 'event_espresso')
441
+					: esc_html__('Checked Out', 'event_espresso');
442
+				// get timestamp string
443
+				$timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
444
+				$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
445
+									  . esc_attr__(
446
+										  'View this registrant\'s check-ins/checkouts for the datetime',
447
+										  'event_espresso'
448
+									  ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
449
+			}
450
+		}
451
+		return (! empty($DTT_ID) && ! empty($timestamps))
452
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
453
+			: $name_link;
454
+	}
455
+
456
+
457
+	/**
458
+	 * @param \EE_Registration $item
459
+	 * @return string
460
+	 */
461
+	public function column_ATT_email(EE_Registration $item)
462
+	{
463
+		$attendee = $item->attendee();
464
+		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
465
+	}
466
+
467
+
468
+	/**
469
+	 * @param \EE_Registration $item
470
+	 * @return bool|string
471
+	 * @throws \EE_Error
472
+	 */
473
+	public function column_Event(EE_Registration $item)
474
+	{
475
+		try {
476
+			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
477
+			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
478
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
479
+				REG_ADMIN_URL
480
+			);
481
+			$event_label = EE_Registry::instance()->CAP->current_user_can(
482
+				'ee_read_checkins',
483
+				'espresso_registrations_registration_checkins'
484
+			) ? '<a href="' . $chkin_lnk_url . '" title="'
485
+				. esc_attr__(
486
+					'View Checkins for this Event',
487
+					'event_espresso'
488
+				) . '">' . $event->name() . '</a>' : $event->name();
489
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
490
+			$event_label = esc_html__('Unknown', 'event_espresso');
491
+		}
492
+		return $event_label;
493
+	}
494
+
495
+
496
+	/**
497
+	 * @param \EE_Registration $item
498
+	 * @return mixed|string|void
499
+	 */
500
+	public function column_PRC_name(EE_Registration $item)
501
+	{
502
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
503
+	}
504
+
505
+
506
+	/**
507
+	 * column_REG_final_price
508
+	 *
509
+	 * @param \EE_Registration $item
510
+	 * @return string
511
+	 */
512
+	public function column__REG_final_price(EE_Registration $item)
513
+	{
514
+		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
515
+	}
516
+
517
+
518
+	/**
519
+	 * column_TXN_paid
520
+	 *
521
+	 * @param \EE_Registration $item
522
+	 * @return string
523
+	 * @throws \EE_Error
524
+	 */
525
+	public function column_TXN_paid(EE_Registration $item)
526
+	{
527
+		if ($item->count() === 1) {
528
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
529
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
530
+			} else {
531
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
532
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
533
+					TXN_ADMIN_URL
534
+				);
535
+				return EE_Registry::instance()->CAP->current_user_can(
536
+					'ee_read_transaction',
537
+					'espresso_transactions_view_transaction'
538
+				) ? '
539 539
 				<span class="reg-pad-rght">
540 540
 					<a class="status-'
541
-                    . $item->transaction()->status_ID()
542
-                    . '" href="'
543
-                    . $view_txn_lnk_url
544
-                    . '"  title="'
545
-                    . esc_attr__('View Transaction', 'event_espresso')
546
-                    . '">
541
+					. $item->transaction()->status_ID()
542
+					. '" href="'
543
+					. $view_txn_lnk_url
544
+					. '"  title="'
545
+					. esc_attr__('View Transaction', 'event_espresso')
546
+					. '">
547 547
 						'
548
-                    . $item->transaction()->pretty_paid()
549
-                    . '
548
+					. $item->transaction()->pretty_paid()
549
+					. '
550 550
 					</a>
551 551
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
552
-            }
553
-        } else {
554
-            return '<span class="reg-pad-rght"></span>';
555
-        }
556
-    }
557
-
558
-
559
-    /**
560
-     *        column_TXN_total
561
-     *
562
-     * @param \EE_Registration $item
563
-     * @return string
564
-     * @throws \EE_Error
565
-     */
566
-    public function column_TXN_total(EE_Registration $item)
567
-    {
568
-        $txn = $item->transaction();
569
-        $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
570
-        if ($item->get('REG_count') === 1) {
571
-            $line_total_obj = $txn->total_line_item();
572
-            $txn_total = $line_total_obj instanceof EE_Line_Item
573
-                ? $line_total_obj->get_pretty('LIN_total')
574
-                : esc_html__(
575
-                    'View Transaction',
576
-                    'event_espresso'
577
-                );
578
-            return EE_Registry::instance()->CAP->current_user_can(
579
-                'ee_read_transaction',
580
-                'espresso_transactions_view_transaction'
581
-            ) ? '<a href="'
582
-                . $view_txn_url
583
-                . '" title="'
584
-                . esc_attr__('View Transaction', 'event_espresso')
585
-                . '"><span class="reg-pad-rght">'
586
-                . $txn_total
587
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
588
-        } else {
589
-            return '<span class="reg-pad-rght"></span>';
590
-        }
591
-    }
552
+			}
553
+		} else {
554
+			return '<span class="reg-pad-rght"></span>';
555
+		}
556
+	}
557
+
558
+
559
+	/**
560
+	 *        column_TXN_total
561
+	 *
562
+	 * @param \EE_Registration $item
563
+	 * @return string
564
+	 * @throws \EE_Error
565
+	 */
566
+	public function column_TXN_total(EE_Registration $item)
567
+	{
568
+		$txn = $item->transaction();
569
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
570
+		if ($item->get('REG_count') === 1) {
571
+			$line_total_obj = $txn->total_line_item();
572
+			$txn_total = $line_total_obj instanceof EE_Line_Item
573
+				? $line_total_obj->get_pretty('LIN_total')
574
+				: esc_html__(
575
+					'View Transaction',
576
+					'event_espresso'
577
+				);
578
+			return EE_Registry::instance()->CAP->current_user_can(
579
+				'ee_read_transaction',
580
+				'espresso_transactions_view_transaction'
581
+			) ? '<a href="'
582
+				. $view_txn_url
583
+				. '" title="'
584
+				. esc_attr__('View Transaction', 'event_espresso')
585
+				. '"><span class="reg-pad-rght">'
586
+				. $txn_total
587
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
588
+		} else {
589
+			return '<span class="reg-pad-rght"></span>';
590
+		}
591
+	}
592 592
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             'TXN_total'           => esc_html__('Total', 'event_espresso'),
84 84
         );
85 85
         // Add/remove columns when an event has been selected
86
-        if (! empty($evt_id)) {
86
+        if ( ! empty($evt_id)) {
87 87
             // Render a checkbox column
88 88
             $columns['cb'] = '<input type="checkbox" />';
89 89
             $this->_has_checkbox_column = true;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $class = parent::_get_row_class($item);
167 167
         // add status class
168
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
168
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
169 169
         if ($this->_has_checkbox_column) {
170 170
             $class .= ' has-checkbox-column';
171 171
         }
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
         if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
185 185
             // this means we don't have an event so let's setup a filter dropdown for all the events to select
186 186
             // note possible capability restrictions
187
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
187
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
188 188
                 $where['status**'] = array('!=', 'private');
189 189
             }
190
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
190
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
191 191
                 $where['EVT_wp_user'] = get_current_user_id();
192 192
             }
193 193
             $events = EEM_Event::instance()->get_all(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             /** @var EE_Event $evt */
205 205
             foreach ($events as $evt) {
206 206
                 // any registrations for this event?
207
-                if (! $evt->get_count_of_all_registrations()) {
207
+                if ( ! $evt->get_count_of_all_registrations()) {
208 208
                     continue;
209 209
                 }
210 210
                 $evts[] = array(
@@ -227,23 +227,23 @@  discard block
 block discarded – undo
227 227
             $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
228 228
             $event_filter .= '<span class="ee-event-filter-toggle">';
229 229
             $event_filter .= '<label for="js-ee-hide-expired-events">';
230
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '>&nbsp;&nbsp;';
230
+            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'>&nbsp;&nbsp;';
231 231
             $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
232 232
             $event_filter .= '</label>';
233 233
             $event_filter .= '</span>';
234 234
             $event_filter .= '</div>';
235 235
             $filters[] = $event_filter;
236 236
         }
237
-        if (! empty($this->_dtts_for_event)) {
237
+        if ( ! empty($this->_dtts_for_event)) {
238 238
             // DTT datetimes filter
239 239
             $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
240 240
             if (count($this->_dtts_for_event) > 1) {
241 241
                 $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
242 242
                 foreach ($this->_dtts_for_event as $dtt) {
243 243
                     $datetime_string = $dtt->name();
244
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
245
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
246
-                    $dtts[ $dtt->ID() ] = $datetime_string;
244
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
245
+                    $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
246
+                    $dtts[$dtt->ID()] = $datetime_string;
247 247
                 }
248 248
                 $input = new EE_Select_Input(
249 249
                     $dtts,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     )
255 255
                 );
256 256
                 $filters[] = $input->get_html_for_input();
257
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
257
+                $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
258 258
             }
259 259
         }
260 260
         return $filters;
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
     public function column_status(EE_Registration $registration)
303 303
     {
304 304
         return '
305
-        <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" 
306
-        aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">        
305
+        <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()).' ee-aria-tooltip" 
306
+        aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'">        
307 307
         </span>';
308 308
     }
309 309
 
@@ -353,11 +353,11 @@  discard block
 block discarded – undo
353 353
                          )
354 354
             ? ' clickable trigger-checkin'
355 355
             : '';
356
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
357
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
358
-               . ' data-_regid="' . $item->ID() . '"'
359
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
360
-               . ' data-nonce="' . $nonce . '">'
356
+        $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
357
+        return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"'
358
+               . ' data-_regid="'.$item->ID().'"'
359
+               . ' data-dttid="'.$this->_cur_dtt_id.'"'
360
+               . ' data-nonce="'.$nonce.'">'
361 361
                . '</span>'
362 362
                . $mobile_view_content;
363 363
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     public function column_ATT_name(EE_Registration $item)
372 372
     {
373 373
         $attendee = $item->attendee();
374
-        if (! $attendee instanceof EE_Attendee) {
374
+        if ( ! $attendee instanceof EE_Attendee) {
375 375
             return esc_html__('No contact record for this registration.', 'event_espresso');
376 376
         }
377 377
         // edit attendee link
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             'ee_edit_contacts',
384 384
             'espresso_registrations_edit_attendee'
385 385
         )
386
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
386
+            ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
387 387
               . $item->attendee()->full_name()
388 388
               . '</a>'
389 389
             : $item->attendee()->full_name();
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon ee-icon-size-8"></div></sup>	'
392 392
             : '';
393 393
         // add group details
394
-        $name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
394
+        $name_link .= '&nbsp;'.sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
395 395
         // add regcode
396 396
         $link = EE_Admin_Page::add_query_args_and_nonce(
397 397
             array('action' => 'view_registration', '_REG_ID' => $item->ID()),
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             'view_registration',
404 404
             $item->ID()
405 405
         )
406
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
406
+            ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
407 407
               . $item->reg_code()
408 408
               . '</a>'
409 409
             : $item->reg_code();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             );
433 433
             // get the timestamps for this registration's checkins, related to the selected datetime
434 434
             $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
435
-            if (! empty($timestamps)) {
435
+            if ( ! empty($timestamps)) {
436 436
                 // get the last timestamp
437 437
                 $last_timestamp = end($timestamps);
438 438
                 // checked in or checked out?
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
                     : esc_html__('Checked Out', 'event_espresso');
442 442
                 // get timestamp string
443 443
                 $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
444
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
444
+                $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'
445 445
                                       . esc_attr__(
446 446
                                           'View this registrant\'s check-ins/checkouts for the datetime',
447 447
                                           'event_espresso'
448
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
448
+                                      ).'">'.$checkin_status.': '.$timestamp_string.'</a>';
449 449
             }
450 450
         }
451
-        return (! empty($DTT_ID) && ! empty($timestamps))
451
+        return ( ! empty($DTT_ID) && ! empty($timestamps))
452 452
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
453 453
             : $name_link;
454 454
     }
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
             $event_label = EE_Registry::instance()->CAP->current_user_can(
482 482
                 'ee_read_checkins',
483 483
                 'espresso_registrations_registration_checkins'
484
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
484
+            ) ? '<a href="'.$chkin_lnk_url.'" title="'
485 485
                 . esc_attr__(
486 486
                     'View Checkins for this Event',
487 487
                     'event_espresso'
488
-                ) . '">' . $event->name() . '</a>' : $event->name();
488
+                ).'">'.$event->name().'</a>' : $event->name();
489 489
         } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
490 490
             $event_label = esc_html__('Unknown', 'event_espresso');
491 491
         }
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
      */
512 512
     public function column__REG_final_price(EE_Registration $item)
513 513
     {
514
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
514
+        return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
515 515
     }
516 516
 
517 517
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
                     . $item->transaction()->pretty_paid()
549 549
                     . '
550 550
 					</a>
551
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
551
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
552 552
             }
553 553
         } else {
554 554
             return '<span class="reg-pad-rght"></span>';
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                 . esc_attr__('View Transaction', 'event_espresso')
585 585
                 . '"><span class="reg-pad-rght">'
586 586
                 . $txn_total
587
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
587
+                . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
588 588
         } else {
589 589
             return '<span class="reg-pad-rght"></span>';
590 590
         }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Indentation   +1432 added lines, -1432 removed lines patch added patch discarded remove patch
@@ -16,1436 +16,1436 @@
 block discarded – undo
16 16
 class Extend_Events_Admin_Page extends Events_Admin_Page
17 17
 {
18 18
 
19
-    /**
20
-     * @var EE_Admin_Config
21
-     */
22
-    protected $admin_config;
23
-
24
-    /**
25
-     * @var AdvancedEditorAdminFormSection
26
-     */
27
-    protected $advanced_editor_admin_form;
28
-
29
-
30
-    /**
31
-     * Extend_Events_Admin_Page constructor.
32
-     *
33
-     * @param bool $routing
34
-     * @throws ReflectionException
35
-     */
36
-    public function __construct($routing = true)
37
-    {
38
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
39
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
40
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
41
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
42
-        }
43
-        parent::__construct($routing);
44
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
45
-    }
46
-
47
-
48
-    /**
49
-     * Sets routes.
50
-     *
51
-     * @throws EE_Error
52
-     * @throws InvalidArgumentException
53
-     * @throws InvalidDataTypeException
54
-     * @throws InvalidInterfaceException
55
-     * @throws Exception
56
-     */
57
-    protected function _extend_page_config()
58
-    {
59
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
60
-        // is there a evt_id in the request?
61
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
62
-            ? $this->_req_data['EVT_ID']
63
-            : 0;
64
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
65
-        // tkt_id?
66
-        $tkt_id                                          =
67
-            ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
68
-                ? $this->_req_data['TKT_ID']
69
-                : 0;
70
-        $new_page_routes                                 = [
71
-            'duplicate_event'          => [
72
-                'func'       => '_duplicate_event',
73
-                'capability' => 'ee_edit_event',
74
-                'obj_id'     => $evt_id,
75
-                'noheader'   => true,
76
-            ],
77
-            'import_page'              => [
78
-                'func'       => '_import_page',
79
-                'capability' => 'import',
80
-            ],
81
-            'import'                   => [
82
-                'func'       => '_import_events',
83
-                'capability' => 'import',
84
-                'noheader'   => true,
85
-            ],
86
-            'import_events'            => [
87
-                'func'       => '_import_events',
88
-                'capability' => 'import',
89
-                'noheader'   => true,
90
-            ],
91
-            'export_events'            => [
92
-                'func'       => '_events_export',
93
-                'capability' => 'export',
94
-                'noheader'   => true,
95
-            ],
96
-            'export_categories'        => [
97
-                'func'       => '_categories_export',
98
-                'capability' => 'export',
99
-                'noheader'   => true,
100
-            ],
101
-            'sample_export_file'       => [
102
-                'func'       => '_sample_export_file',
103
-                'capability' => 'export',
104
-                'noheader'   => true,
105
-            ],
106
-            'update_template_settings' => [
107
-                'func'       => '_update_template_settings',
108
-                'capability' => 'manage_options',
109
-                'noheader'   => true,
110
-            ],
111
-            'ticket_list_table'        => [
112
-                'func'       => '_tickets_overview_list_table',
113
-                'capability' => 'ee_read_default_tickets',
114
-            ],
115
-        ];
116
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
117
-        $this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
118
-        // don't load these meta boxes if using the advanced editor
119
-        if (
120
-            ! $this->admin_config->useAdvancedEditor()
121
-            || ! $this->feature->allowed('use_default_ticket_manager')
122
-        ) {
123
-            $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
124
-            $this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
125
-
126
-            $legacy_editor_page_routes = [
127
-                'trash_ticket'    => [
128
-                    'func'       => '_trash_or_restore_ticket',
129
-                    'capability' => 'ee_delete_default_ticket',
130
-                    'obj_id'     => $tkt_id,
131
-                    'noheader'   => true,
132
-                    'args'       => ['trash' => true],
133
-                ],
134
-                'trash_tickets'   => [
135
-                    'func'       => '_trash_or_restore_ticket',
136
-                    'capability' => 'ee_delete_default_tickets',
137
-                    'noheader'   => true,
138
-                    'args'       => ['trash' => true],
139
-                ],
140
-                'restore_ticket'  => [
141
-                    'func'       => '_trash_or_restore_ticket',
142
-                    'capability' => 'ee_delete_default_ticket',
143
-                    'obj_id'     => $tkt_id,
144
-                    'noheader'   => true,
145
-                ],
146
-                'restore_tickets' => [
147
-                    'func'       => '_trash_or_restore_ticket',
148
-                    'capability' => 'ee_delete_default_tickets',
149
-                    'noheader'   => true,
150
-                ],
151
-                'delete_ticket'   => [
152
-                    'func'       => '_delete_ticket',
153
-                    'capability' => 'ee_delete_default_ticket',
154
-                    'obj_id'     => $tkt_id,
155
-                    'noheader'   => true,
156
-                ],
157
-                'delete_tickets'  => [
158
-                    'func'       => '_delete_ticket',
159
-                    'capability' => 'ee_delete_default_tickets',
160
-                    'noheader'   => true,
161
-                ],
162
-            ];
163
-            $new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
164
-        }
165
-
166
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
167
-        // partial route/config override
168
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
169
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
170
-        // add tickets tab but only if there are more than one default ticket!
171
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
172
-            [['TKT_is_default' => 1]],
173
-            'TKT_ID',
174
-            true
175
-        );
176
-        if ($tkt_count > 1) {
177
-            $new_page_config = [
178
-                'ticket_list_table' => [
179
-                    'nav'           => [
180
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
181
-                        'order' => 60,
182
-                    ],
183
-                    'list_table'    => 'Tickets_List_Table',
184
-                    'require_nonce' => false,
185
-                ],
186
-            ];
187
-        }
188
-        // template settings
189
-        $new_page_config['template_settings'] = [
190
-            'nav'           => [
191
-                'label' => esc_html__('Templates', 'event_espresso'),
192
-                'order' => 30,
193
-            ],
194
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
195
-            'help_tabs'     => [
196
-                'general_settings_templates_help_tab' => [
197
-                    'title'    => esc_html__('Templates', 'event_espresso'),
198
-                    'filename' => 'general_settings_templates',
199
-                ],
200
-            ],
201
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
202
-            // 'help_tour'     => ['Templates_Help_Tour'],
203
-            'require_nonce' => false,
204
-        ];
205
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
206
-        // add filters and actions
207
-        // modifying _views
208
-        add_filter(
209
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
210
-            [$this, 'add_additional_datetime_button'],
211
-            10,
212
-            2
213
-        );
214
-        add_filter(
215
-            'FHEE_event_datetime_metabox_clone_button_template',
216
-            [$this, 'add_datetime_clone_button'],
217
-            10,
218
-            2
219
-        );
220
-        add_filter(
221
-            'FHEE_event_datetime_metabox_timezones_template',
222
-            [$this, 'datetime_timezones_template'],
223
-            10,
224
-            2
225
-        );
226
-        // filters for event list table
227
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
228
-        add_filter(
229
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
230
-            [$this, 'extra_list_table_actions'],
231
-            10,
232
-            2
233
-        );
234
-        // legend item
235
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
236
-        add_action('admin_init', [$this, 'admin_init']);
237
-        // load additional handlers
238
-        $this->handleActionRequest();
239
-    }
240
-
241
-
242
-    private function getRequestAction()
243
-    {
244
-        return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null;
245
-    }
246
-
247
-
248
-    /**
249
-     * @throws Exception
250
-     */
251
-    private function handleActionRequest()
252
-    {
253
-        $action = $this->getRequestAction();
254
-        if ($action) {
255
-            // setup Advanced Editor ???
256
-            if ($action === 'default_event_settings' || $action === 'update_default_event_settings') {
257
-                $this->advanced_editor_admin_form = $this->loader->getShared(
258
-                    'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
259
-                );
260
-            }
261
-        }
262
-    }
263
-
264
-
265
-    /**
266
-     * admin_init
267
-     */
268
-    public function admin_init()
269
-    {
270
-        EE_Registry::$i18n_js_strings = array_merge(
271
-            EE_Registry::$i18n_js_strings,
272
-            [
273
-                'image_confirm'          => esc_html__(
274
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
275
-                    'event_espresso'
276
-                ),
277
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
278
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
279
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
280
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
281
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
282
-            ]
283
-        );
284
-    }
285
-
286
-
287
-    /**
288
-     * Add per page screen options to the default ticket list table view.
289
-     *
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    protected function _add_screen_options_ticket_list_table()
295
-    {
296
-        $this->_per_page_screen_option();
297
-    }
298
-
299
-
300
-    /**
301
-     * @param string $return
302
-     * @param int    $id
303
-     * @param string $new_title
304
-     * @param string $new_slug
305
-     * @return string
306
-     */
307
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
308
-    {
309
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
310
-        // make sure this is only when editing
311
-        if (! empty($id)) {
312
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
313
-                ['action' => 'duplicate_event', 'EVT_ID' => $id],
314
-                $this->_admin_base_url
315
-            );
316
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
317
-            $return .= '<a href="'
318
-                       . $href
319
-                       . '" title="'
320
-                       . $title
321
-                       . '" id="ee-duplicate-event-button" class="button button--secondary"  value="duplicate_event">'
322
-                       . $title
323
-                       . '</a>';
324
-        }
325
-        return $return;
326
-    }
327
-
328
-
329
-    /**
330
-     * Set the list table views for the default ticket list table view.
331
-     */
332
-    public function _set_list_table_views_ticket_list_table()
333
-    {
334
-        $this->_views = [
335
-            'all'     => [
336
-                'slug'        => 'all',
337
-                'label'       => esc_html__('All', 'event_espresso'),
338
-                'count'       => 0,
339
-                'bulk_action' => [
340
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
341
-                ],
342
-            ],
343
-            'trashed' => [
344
-                'slug'        => 'trashed',
345
-                'label'       => esc_html__('Trash', 'event_espresso'),
346
-                'count'       => 0,
347
-                'bulk_action' => [
348
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
349
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
350
-                ],
351
-            ],
352
-        ];
353
-    }
354
-
355
-
356
-    /**
357
-     * Enqueue scripts and styles for the event editor.
358
-     */
359
-    public function load_scripts_styles_edit()
360
-    {
361
-        if (! $this->admin_config->useAdvancedEditor()) {
362
-            wp_register_script(
363
-                'ee-event-editor-heartbeat',
364
-                EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
365
-                ['ee_admin_js', 'heartbeat'],
366
-                EVENT_ESPRESSO_VERSION,
367
-                true
368
-            );
369
-            wp_enqueue_script('ee-accounting');
370
-            wp_enqueue_script('ee-event-editor-heartbeat');
371
-        }
372
-        wp_enqueue_script('event_editor_js');
373
-        // styles
374
-        wp_enqueue_style('espresso-ui-theme');
375
-    }
376
-
377
-
378
-    /**
379
-     * Returns template for the additional datetime.
380
-     *
381
-     * @param $template
382
-     * @param $template_args
383
-     * @return mixed
384
-     * @throws DomainException
385
-     */
386
-    public function add_additional_datetime_button($template, $template_args)
387
-    {
388
-        return EEH_Template::display_template(
389
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
390
-            $template_args,
391
-            true
392
-        );
393
-    }
394
-
395
-
396
-    /**
397
-     * Returns the template for cloning a datetime.
398
-     *
399
-     * @param $template
400
-     * @param $template_args
401
-     * @return mixed
402
-     * @throws DomainException
403
-     */
404
-    public function add_datetime_clone_button($template, $template_args)
405
-    {
406
-        return EEH_Template::display_template(
407
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
408
-            $template_args,
409
-            true
410
-        );
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns the template for datetime timezones.
416
-     *
417
-     * @param $template
418
-     * @param $template_args
419
-     * @return mixed
420
-     * @throws DomainException
421
-     */
422
-    public function datetime_timezones_template($template, $template_args)
423
-    {
424
-        return EEH_Template::display_template(
425
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
426
-            $template_args,
427
-            true
428
-        );
429
-    }
430
-
431
-
432
-    /**
433
-     * Sets the views for the default list table view.
434
-     *
435
-     * @throws EE_Error
436
-     */
437
-    protected function _set_list_table_views_default()
438
-    {
439
-        parent::_set_list_table_views_default();
440
-        $new_views    = [
441
-            'today' => [
442
-                'slug'        => 'today',
443
-                'label'       => esc_html__('Today', 'event_espresso'),
444
-                'count'       => $this->total_events_today(),
445
-                'bulk_action' => [
446
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
447
-                ],
448
-            ],
449
-            'month' => [
450
-                'slug'        => 'month',
451
-                'label'       => esc_html__('This Month', 'event_espresso'),
452
-                'count'       => $this->total_events_this_month(),
453
-                'bulk_action' => [
454
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
455
-                ],
456
-            ],
457
-        ];
458
-        $this->_views = array_merge($this->_views, $new_views);
459
-    }
460
-
461
-
462
-    /**
463
-     * Returns the extra action links for the default list table view.
464
-     *
465
-     * @param array    $action_links
466
-     * @param EE_Event $event
467
-     * @return array
468
-     * @throws EE_Error
469
-     * @throws InvalidArgumentException
470
-     * @throws InvalidDataTypeException
471
-     * @throws InvalidInterfaceException
472
-     * @throws ReflectionException
473
-     */
474
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
475
-    {
476
-        if (
477
-            EE_Registry::instance()->CAP->current_user_can(
478
-                'ee_read_registrations',
479
-                'espresso_registrations_reports',
480
-                $event->ID()
481
-            )
482
-        ) {
483
-            $reports_query_args = [
484
-                'action' => 'reports',
485
-                'EVT_ID' => $event->ID(),
486
-            ];
487
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
488
-            $action_links[]     = '<a href="'
489
-                                  . $reports_link
490
-                                  . '" title="'
491
-                                  . esc_attr__('View Report', 'event_espresso')
492
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
493
-                                  . "\n\t";
494
-        }
495
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
496
-            EE_Registry::instance()->load_helper('MSG_Template');
497
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
498
-                'see_notifications_for',
499
-                null,
500
-                ['EVT_ID' => $event->ID()]
501
-            );
502
-        }
503
-        return $action_links;
504
-    }
505
-
506
-
507
-    /**
508
-     * @param $items
509
-     * @return mixed
510
-     */
511
-    public function additional_legend_items($items)
512
-    {
513
-        if (
514
-            EE_Registry::instance()->CAP->current_user_can(
515
-                'ee_read_registrations',
516
-                'espresso_registrations_reports'
517
-            )
518
-        ) {
519
-            $items['reports'] = [
520
-                'class' => 'dashicons dashicons-chart-bar',
521
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
522
-            ];
523
-        }
524
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
525
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
526
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
527
-            // (can only use numeric offsets when treating strings as arrays)
528
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
529
-                $items['view_related_messages'] = [
530
-                    'class' => $related_for_icon['css_class'],
531
-                    'desc'  => $related_for_icon['label'],
532
-                ];
533
-            }
534
-        }
535
-        return $items;
536
-    }
537
-
538
-
539
-    /**
540
-     * This is the callback method for the duplicate event route
541
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
542
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
543
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
544
-     * After duplication the redirect is to the new event edit page.
545
-     *
546
-     * @return void
547
-     * @throws EE_Error If EE_Event is not available with given ID
548
-     * @throws InvalidArgumentException
549
-     * @throws InvalidDataTypeException
550
-     * @throws InvalidInterfaceException
551
-     * @throws ReflectionException
552
-     * @access protected
553
-     */
554
-    protected function _duplicate_event()
555
-    {
556
-        // first make sure the ID for the event is in the request.
557
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
558
-        if (! isset($this->_req_data['EVT_ID'])) {
559
-            EE_Error::add_error(
560
-                esc_html__(
561
-                    'In order to duplicate an event an Event ID is required.  None was given.',
562
-                    'event_espresso'
563
-                ),
564
-                __FILE__,
565
-                __FUNCTION__,
566
-                __LINE__
567
-            );
568
-            $this->_redirect_after_action(false, '', '', [], true);
569
-            return;
570
-        }
571
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
572
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
573
-        if (! $orig_event instanceof EE_Event) {
574
-            throw new EE_Error(
575
-                sprintf(
576
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
577
-                    $this->_req_data['EVT_ID']
578
-                )
579
-            );
580
-        }
581
-        // k now let's clone the $orig_event before getting relations
582
-        $new_event = clone $orig_event;
583
-        // original datetimes
584
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
585
-        // other original relations
586
-        $orig_ven = $orig_event->get_many_related('Venue');
587
-        // reset the ID and modify other details to make it clear this is a dupe
588
-        $new_event->set('EVT_ID', 0);
589
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
590
-        $new_event->set('EVT_name', $new_name);
591
-        $new_event->set(
592
-            'EVT_slug',
593
-            wp_unique_post_slug(
594
-                sanitize_title($orig_event->name()),
595
-                0,
596
-                'publish',
597
-                'espresso_events',
598
-                0
599
-            )
600
-        );
601
-        $new_event->set('status', 'draft');
602
-        // duplicate discussion settings
603
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
604
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
605
-        // save the new event
606
-        $new_event->save();
607
-        // venues
608
-        foreach ($orig_ven as $ven) {
609
-            $new_event->_add_relation_to($ven, 'Venue');
610
-        }
611
-        $new_event->save();
612
-        // now we need to get the question group relations and handle that
613
-        // first primary question groups
614
-        $orig_primary_qgs = $orig_event->get_many_related(
615
-            'Question_Group',
616
-            [['Event_Question_Group.EQG_primary' => true]]
617
-        );
618
-        if (! empty($orig_primary_qgs)) {
619
-            foreach ($orig_primary_qgs as $id => $obj) {
620
-                if ($obj instanceof EE_Question_Group) {
621
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
622
-                }
623
-            }
624
-        }
625
-        // next additional attendee question groups
626
-        $orig_additional_qgs = $orig_event->get_many_related(
627
-            'Question_Group',
628
-            [['Event_Question_Group.EQG_additional' => true]]
629
-        );
630
-        if (! empty($orig_additional_qgs)) {
631
-            foreach ($orig_additional_qgs as $id => $obj) {
632
-                if ($obj instanceof EE_Question_Group) {
633
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
634
-                }
635
-            }
636
-        }
637
-
638
-        $new_event->save();
639
-
640
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
641
-        $cloned_tickets = [];
642
-        foreach ($orig_datetimes as $orig_dtt) {
643
-            if (! $orig_dtt instanceof EE_Datetime) {
644
-                continue;
645
-            }
646
-            $new_dtt   = clone $orig_dtt;
647
-            $orig_tkts = $orig_dtt->tickets();
648
-            // save new dtt then add to event
649
-            $new_dtt->set('DTT_ID', 0);
650
-            $new_dtt->set('DTT_sold', 0);
651
-            $new_dtt->set_reserved(0);
652
-            $new_dtt->save();
653
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
654
-            $new_event->save();
655
-            // now let's get the ticket relations setup.
656
-            foreach ((array) $orig_tkts as $orig_tkt) {
657
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
658
-                if (! $orig_tkt instanceof EE_Ticket) {
659
-                    continue;
660
-                }
661
-                // is this ticket archived?  If it is then let's skip
662
-                if ($orig_tkt->get('TKT_deleted')) {
663
-                    continue;
664
-                }
665
-                // does this original ticket already exist in the clone_tickets cache?
666
-                //  If so we'll just use the new ticket from it.
667
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
668
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
669
-                } else {
670
-                    $new_tkt = clone $orig_tkt;
671
-                    // get relations on the $orig_tkt that we need to setup.
672
-                    $orig_prices = $orig_tkt->prices();
673
-                    $new_tkt->set('TKT_ID', 0);
674
-                    $new_tkt->set('TKT_sold', 0);
675
-                    $new_tkt->set('TKT_reserved', 0);
676
-                    $new_tkt->save(); // make sure new ticket has ID.
677
-                    // price relations on new ticket need to be setup.
678
-                    foreach ($orig_prices as $orig_price) {
679
-                        $new_price = clone $orig_price;
680
-                        $new_price->set('PRC_ID', 0);
681
-                        $new_price->save();
682
-                        $new_tkt->_add_relation_to($new_price, 'Price');
683
-                        $new_tkt->save();
684
-                    }
685
-
686
-                    do_action(
687
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
688
-                        $orig_tkt,
689
-                        $new_tkt,
690
-                        $orig_prices,
691
-                        $orig_event,
692
-                        $orig_dtt,
693
-                        $new_dtt
694
-                    );
695
-                }
696
-                // k now we can add the new ticket as a relation to the new datetime
697
-                // and make sure its added to our cached $cloned_tickets array
698
-                // for use with later datetimes that have the same ticket.
699
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
700
-                $new_dtt->save();
701
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
702
-            }
703
-        }
704
-        // clone taxonomy information
705
-        $taxonomies_to_clone_with = apply_filters(
706
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
707
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
708
-        );
709
-        // get terms for original event (notice)
710
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
711
-        // loop through terms and add them to new event.
712
-        foreach ($orig_terms as $term) {
713
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
714
-        }
715
-
716
-        // duplicate other core WP_Post items for this event.
717
-        // post thumbnail (feature image).
718
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
719
-        if ($feature_image_id) {
720
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
721
-        }
722
-
723
-        // duplicate page_template setting
724
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
725
-        if ($page_template) {
726
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
727
-        }
728
-
729
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
730
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
731
-        if ($new_event->ID()) {
732
-            $redirect_args = [
733
-                'post'   => $new_event->ID(),
734
-                'action' => 'edit',
735
-            ];
736
-            EE_Error::add_success(
737
-                esc_html__(
738
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
739
-                    'event_espresso'
740
-                )
741
-            );
742
-        } else {
743
-            $redirect_args = [
744
-                'action' => 'default',
745
-            ];
746
-            EE_Error::add_error(
747
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
748
-                __FILE__,
749
-                __FUNCTION__,
750
-                __LINE__
751
-            );
752
-        }
753
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
754
-    }
755
-
756
-
757
-    /**
758
-     * Generates output for the import page.
759
-     *
760
-     * @throws DomainException
761
-     * @throws EE_Error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidDataTypeException
764
-     * @throws InvalidInterfaceException
765
-     */
766
-    protected function _import_page()
767
-    {
768
-        $title                                      = esc_html__('Import', 'event_espresso');
769
-        $intro                                      = esc_html__(
770
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
771
-            'event_espresso'
772
-        );
773
-        $form_url                                   = EVENTS_ADMIN_URL;
774
-        $action                                     = 'import_events';
775
-        $type                                       = 'csv';
776
-        $this->_template_args['form']               = EE_Import::instance()->upload_form(
777
-            $title,
778
-            $intro,
779
-            $form_url,
780
-            $action,
781
-            $type
782
-        );
783
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
784
-            ['action' => 'sample_export_file'],
785
-            $this->_admin_base_url
786
-        );
787
-        $content                                    = EEH_Template::display_template(
788
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
789
-            $this->_template_args,
790
-            true
791
-        );
792
-        $this->_template_args['admin_page_content'] = $content;
793
-        $this->display_admin_page_with_sidebar();
794
-    }
795
-
796
-
797
-    /**
798
-     * _import_events
799
-     * This handles displaying the screen and running imports for importing events.
800
-     *
801
-     * @return void
802
-     * @throws EE_Error
803
-     * @throws InvalidArgumentException
804
-     * @throws InvalidDataTypeException
805
-     * @throws InvalidInterfaceException
806
-     */
807
-    protected function _import_events()
808
-    {
809
-        require_once(EE_CLASSES . 'EE_Import.class.php');
810
-        $success = EE_Import::instance()->import();
811
-        $this->_redirect_after_action($success, 'Import File', 'ran', ['action' => 'import_page'], true);
812
-    }
813
-
814
-
815
-    /**
816
-     * _events_export
817
-     * Will export all (or just the given event) to a Excel compatible file.
818
-     *
819
-     * @access protected
820
-     * @return void
821
-     */
822
-    protected function _events_export()
823
-    {
824
-        if (isset($this->_req_data['EVT_ID'])) {
825
-            $event_ids = $this->_req_data['EVT_ID'];
826
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
827
-            $event_ids = $this->_req_data['EVT_IDs'];
828
-        } else {
829
-            $event_ids = null;
830
-        }
831
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
832
-        $new_request_args = [
833
-            'export' => 'report',
834
-            'action' => 'all_event_data',
835
-            'EVT_ID' => $event_ids,
836
-        ];
837
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
838
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
839
-            require_once(EE_CLASSES . 'EE_Export.class.php');
840
-            $EE_Export = EE_Export::instance($this->_req_data);
841
-            if ($EE_Export instanceof EE_Export) {
842
-                $EE_Export->export();
843
-            }
844
-        }
845
-    }
846
-
847
-
848
-    /**
849
-     * handle category exports()
850
-     *
851
-     * @return void
852
-     */
853
-    protected function _categories_export()
854
-    {
855
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
856
-        $new_request_args = [
857
-            'export'       => 'report',
858
-            'action'       => 'categories',
859
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
860
-        ];
861
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
862
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
863
-            require_once(EE_CLASSES . 'EE_Export.class.php');
864
-            $EE_Export = EE_Export::instance($this->_req_data);
865
-            if ($EE_Export instanceof EE_Export) {
866
-                $EE_Export->export();
867
-            }
868
-        }
869
-    }
870
-
871
-
872
-    /**
873
-     * Creates a sample CSV file for importing
874
-     */
875
-    protected function _sample_export_file()
876
-    {
877
-        $EE_Export = EE_Export::instance();
878
-        if ($EE_Export instanceof EE_Export) {
879
-            $EE_Export->export();
880
-        }
881
-    }
882
-
883
-
884
-    /*************        Template Settings        *************/
885
-    /**
886
-     * Generates template settings page output
887
-     *
888
-     * @throws DomainException
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     */
894
-    protected function _template_settings()
895
-    {
896
-        $this->_template_args['values'] = $this->_yes_no_values;
897
-        /**
898
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
899
-         * from General_Settings_Admin_Page to here.
900
-         */
901
-        $this->_template_args = apply_filters(
902
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
903
-            $this->_template_args
904
-        );
905
-        $this->_set_add_edit_form_tags('update_template_settings');
906
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
907
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
909
-            $this->_template_args,
910
-            true
911
-        );
912
-        $this->display_admin_page_with_sidebar();
913
-    }
914
-
915
-
916
-    /**
917
-     * Handler for updating template settings.
918
-     *
919
-     * @throws EE_Error
920
-     * @throws InvalidArgumentException
921
-     * @throws InvalidDataTypeException
922
-     * @throws InvalidInterfaceException
923
-     */
924
-    protected function _update_template_settings()
925
-    {
926
-        /**
927
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
928
-         * from General_Settings_Admin_Page to here.
929
-         */
930
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
931
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
932
-            EE_Registry::instance()->CFG->template_settings,
933
-            $this->_req_data
934
-        );
935
-        // update custom post type slugs and detect if we need to flush rewrite rules
936
-        $old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
937
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
938
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
939
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
940
-        $what                                              = 'Template Settings';
941
-        $success                                           = $this->_update_espresso_configuration(
942
-            $what,
943
-            EE_Registry::instance()->CFG->template_settings,
944
-            __FILE__,
945
-            __FUNCTION__,
946
-            __LINE__
947
-        );
948
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
949
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
950
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
951
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
952
-            );
953
-            $rewrite_rules->flush();
954
-        }
955
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
956
-    }
957
-
958
-
959
-    /**
960
-     * _premium_event_editor_meta_boxes
961
-     * add all metaboxes related to the event_editor
962
-     *
963
-     * @access protected
964
-     * @return void
965
-     * @throws EE_Error
966
-     * @throws InvalidArgumentException
967
-     * @throws InvalidDataTypeException
968
-     * @throws InvalidInterfaceException
969
-     * @throws ReflectionException
970
-     */
971
-    protected function _premium_event_editor_meta_boxes()
972
-    {
973
-        $this->verify_cpt_object();
974
-        // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
975
-        if (
976
-            ! $this->admin_config->useAdvancedEditor()
977
-            || ! $this->feature->allowed('use_reg_options_meta_box')
978
-        ) {
979
-            $this->addMetaBox(
980
-                'espresso_event_editor_event_options',
981
-                esc_html__('Event Registration Options', 'event_espresso'),
982
-                [$this, 'registration_options_meta_box'],
983
-                $this->page_slug,
984
-                'side',
985
-                'core'
986
-            );
987
-        }
988
-    }
989
-
990
-
991
-    /**
992
-     * override caf metabox
993
-     *
994
-     * @return void
995
-     * @throws DomainException
996
-     * @throws EE_Error
997
-     */
998
-    public function registration_options_meta_box()
999
-    {
1000
-        $yes_no_values                                    = [
1001
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
1002
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
1003
-        ];
1004
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
1005
-            [
1006
-                EEM_Registration::status_id_cancelled,
1007
-                EEM_Registration::status_id_declined,
1008
-                EEM_Registration::status_id_incomplete,
1009
-                EEM_Registration::status_id_wait_list,
1010
-            ],
1011
-            true
1012
-        );
1013
-        $template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
1014
-        $template_args['_event']                          = $this->_cpt_model_obj;
1015
-        $template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
1016
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
1017
-            'default_reg_status',
1018
-            $default_reg_status_values,
1019
-            $this->_cpt_model_obj->default_registration_status()
1020
-        );
1021
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
1022
-            'display_desc',
1023
-            $yes_no_values,
1024
-            $this->_cpt_model_obj->display_description()
1025
-        );
1026
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
1027
-            'display_ticket_selector',
1028
-            $yes_no_values,
1029
-            $this->_cpt_model_obj->display_ticket_selector(),
1030
-            '',
1031
-            '',
1032
-            false
1033
-        );
1034
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1035
-            'EVT_default_registration_status',
1036
-            $default_reg_status_values,
1037
-            $this->_cpt_model_obj->default_registration_status()
1038
-        );
1039
-        $template_args['additional_registration_options'] = apply_filters(
1040
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1041
-            '',
1042
-            $template_args,
1043
-            $yes_no_values,
1044
-            $default_reg_status_values
1045
-        );
1046
-        EEH_Template::display_template(
1047
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1048
-            $template_args
1049
-        );
1050
-    }
1051
-
1052
-
1053
-
1054
-    /**
1055
-     * wp_list_table_mods for caf
1056
-     * ============================
1057
-     */
1058
-    /**
1059
-     * hook into list table filters and provide filters for caffeinated list table
1060
-     *
1061
-     * @param array $old_filters    any existing filters present
1062
-     * @param array $list_table_obj the list table object
1063
-     * @return array                  new filters
1064
-     * @throws EE_Error
1065
-     * @throws InvalidArgumentException
1066
-     * @throws InvalidDataTypeException
1067
-     * @throws InvalidInterfaceException
1068
-     * @throws ReflectionException
1069
-     */
1070
-    public function list_table_filters($old_filters, $list_table_obj)
1071
-    {
1072
-        $filters = [];
1073
-        // first month/year filters
1074
-        $filters[] = $this->espresso_event_months_dropdown();
1075
-        $status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1076
-        // active status dropdown
1077
-        if ($status !== 'draft') {
1078
-            $filters[] = $this->active_status_dropdown(
1079
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1080
-            );
1081
-            $filters[] = $this->venuesDropdown(
1082
-                isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1083
-            );
1084
-        }
1085
-        // category filter
1086
-        $filters[] = $this->category_dropdown();
1087
-        return array_merge($old_filters, $filters);
1088
-    }
1089
-
1090
-
1091
-    /**
1092
-     * espresso_event_months_dropdown
1093
-     *
1094
-     * @access public
1095
-     * @return string                dropdown listing month/year selections for events.
1096
-     */
1097
-    public function espresso_event_months_dropdown()
1098
-    {
1099
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1100
-        // Note we need to include any other filters that are set!
1101
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1102
-        // categories?
1103
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1104
-            ? $this->_req_data['EVT_CAT']
1105
-            : null;
1106
-        // active status?
1107
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1108
-        $cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1109
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1110
-    }
1111
-
1112
-
1113
-    /**
1114
-     * returns a list of "active" statuses on the event
1115
-     *
1116
-     * @param string $current_value whatever the current active status is
1117
-     * @return string
1118
-     */
1119
-    public function active_status_dropdown($current_value = '')
1120
-    {
1121
-        $select_name = 'active_status';
1122
-        $values      = [
1123
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1124
-            'active'   => esc_html__('Active', 'event_espresso'),
1125
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1126
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1127
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1128
-        ];
1129
-
1130
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1131
-    }
1132
-
1133
-
1134
-    /**
1135
-     * returns a list of "venues"
1136
-     *
1137
-     * @param string $current_value whatever the current active status is
1138
-     * @return string
1139
-     * @throws EE_Error
1140
-     * @throws InvalidArgumentException
1141
-     * @throws InvalidDataTypeException
1142
-     * @throws InvalidInterfaceException
1143
-     * @throws ReflectionException
1144
-     */
1145
-    protected function venuesDropdown($current_value = '')
1146
-    {
1147
-        $select_name = 'venue';
1148
-        $values      = [
1149
-            '' => esc_html__('All Venues', 'event_espresso'),
1150
-        ];
1151
-        // populate the list of venues.
1152
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1153
-        $venues      = $venue_model->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1154
-
1155
-        foreach ($venues as $venue) {
1156
-            $values[ $venue->ID() ] = $venue->name();
1157
-        }
1158
-
1159
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * output a dropdown of the categories for the category filter on the event admin list table
1165
-     *
1166
-     * @access  public
1167
-     * @return string html
1168
-     */
1169
-    public function category_dropdown()
1170
-    {
1171
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1172
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1173
-    }
1174
-
1175
-
1176
-    /**
1177
-     * get total number of events today
1178
-     *
1179
-     * @access public
1180
-     * @return int
1181
-     * @throws EE_Error
1182
-     * @throws InvalidArgumentException
1183
-     * @throws InvalidDataTypeException
1184
-     * @throws InvalidInterfaceException
1185
-     */
1186
-    public function total_events_today()
1187
-    {
1188
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1189
-            'DTT_EVT_start',
1190
-            date('Y-m-d') . ' 00:00:00',
1191
-            'Y-m-d H:i:s',
1192
-            'UTC'
1193
-        );
1194
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1195
-            'DTT_EVT_start',
1196
-            date('Y-m-d') . ' 23:59:59',
1197
-            'Y-m-d H:i:s',
1198
-            'UTC'
1199
-        );
1200
-        $where = [
1201
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1202
-        ];
1203
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1204
-    }
1205
-
1206
-
1207
-    /**
1208
-     * get total number of events this month
1209
-     *
1210
-     * @access public
1211
-     * @return int
1212
-     * @throws EE_Error
1213
-     * @throws InvalidArgumentException
1214
-     * @throws InvalidDataTypeException
1215
-     * @throws InvalidInterfaceException
1216
-     */
1217
-    public function total_events_this_month()
1218
-    {
1219
-        // Dates
1220
-        $this_year_r     = date('Y');
1221
-        $this_month_r    = date('m');
1222
-        $days_this_month = date('t');
1223
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1224
-            'DTT_EVT_start',
1225
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1226
-            'Y-m-d H:i:s',
1227
-            'UTC'
1228
-        );
1229
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1230
-            'DTT_EVT_start',
1231
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1232
-            'Y-m-d H:i:s',
1233
-            'UTC'
1234
-        );
1235
-        $where           = [
1236
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1237
-        ];
1238
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1239
-    }
1240
-
1241
-
1242
-    /** DEFAULT TICKETS STUFF **/
1243
-
1244
-    /**
1245
-     * Output default tickets list table view.
1246
-     *
1247
-     * @throws DomainException
1248
-     * @throws EE_Error
1249
-     * @throws InvalidArgumentException
1250
-     * @throws InvalidDataTypeException
1251
-     * @throws InvalidInterfaceException
1252
-     */
1253
-    public function _tickets_overview_list_table()
1254
-    {
1255
-        if (
1256
-            $this->admin_config->useAdvancedEditor()
1257
-            && $this->feature->allowed('use_default_ticket_manager')
1258
-        ) {
1259
-            // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1260
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1261
-                EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1262
-                [],
1263
-                true
1264
-            );
1265
-            $this->display_admin_page_with_no_sidebar();
1266
-        } else {
1267
-            $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1268
-            $this->display_admin_list_table_page_with_no_sidebar();
1269
-        }
1270
-    }
1271
-
1272
-
1273
-    /**
1274
-     * @param int  $per_page
1275
-     * @param bool $count
1276
-     * @param bool $trashed
1277
-     * @return EE_Soft_Delete_Base_Class[]|int
1278
-     * @throws EE_Error
1279
-     * @throws InvalidArgumentException
1280
-     * @throws InvalidDataTypeException
1281
-     * @throws InvalidInterfaceException
1282
-     */
1283
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1284
-    {
1285
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1286
-        $order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1287
-        switch ($orderby) {
1288
-            case 'TKT_name':
1289
-                $orderby = ['TKT_name' => $order];
1290
-                break;
1291
-            case 'TKT_price':
1292
-                $orderby = ['TKT_price' => $order];
1293
-                break;
1294
-            case 'TKT_uses':
1295
-                $orderby = ['TKT_uses' => $order];
1296
-                break;
1297
-            case 'TKT_min':
1298
-                $orderby = ['TKT_min' => $order];
1299
-                break;
1300
-            case 'TKT_max':
1301
-                $orderby = ['TKT_max' => $order];
1302
-                break;
1303
-            case 'TKT_qty':
1304
-                $orderby = ['TKT_qty' => $order];
1305
-                break;
1306
-        }
1307
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1308
-            ? $this->_req_data['paged']
1309
-            : 1;
1310
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1311
-            ? $this->_req_data['perpage']
1312
-            : $per_page;
1313
-        $_where       = [
1314
-            'TKT_is_default' => 1,
1315
-            'TKT_deleted'    => $trashed,
1316
-        ];
1317
-        $offset       = ($current_page - 1) * $per_page;
1318
-        $limit        = [$offset, $per_page];
1319
-        if (isset($this->_req_data['s'])) {
1320
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1321
-            $_where['OR'] = [
1322
-                'TKT_name'        => ['LIKE', $sstr],
1323
-                'TKT_description' => ['LIKE', $sstr],
1324
-            ];
1325
-        }
1326
-        $query_params = [
1327
-            $_where,
1328
-            'order_by' => $orderby,
1329
-            'limit'    => $limit,
1330
-            'group_by' => 'TKT_ID',
1331
-        ];
1332
-        if ($count) {
1333
-            return EEM_Ticket::instance()->count_deleted_and_undeleted([$_where]);
1334
-        }
1335
-        return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * @param bool $trash
1341
-     * @throws EE_Error
1342
-     * @throws InvalidArgumentException
1343
-     * @throws InvalidDataTypeException
1344
-     * @throws InvalidInterfaceException
1345
-     */
1346
-    protected function _trash_or_restore_ticket($trash = false)
1347
-    {
1348
-        $success = 1;
1349
-        $TKT     = EEM_Ticket::instance();
1350
-        // checkboxes?
1351
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352
-            // if array has more than one element then success message should be plural
1353
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1354
-            // cycle thru the boxes
1355
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1356
-                if ($trash) {
1357
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1358
-                        $success = 0;
1359
-                    }
1360
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1361
-                    $success = 0;
1362
-                }
1363
-            }
1364
-        } else {
1365
-            // grab single id and trash
1366
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1367
-            if ($trash) {
1368
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1369
-                    $success = 0;
1370
-                }
1371
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1372
-                $success = 0;
1373
-            }
1374
-        }
1375
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1376
-        $query_args  = [
1377
-            'action' => 'ticket_list_table',
1378
-            'status' => $trash ? '' : 'trashed',
1379
-        ];
1380
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1381
-    }
1382
-
1383
-
1384
-    /**
1385
-     * Handles trashing default ticket.
1386
-     *
1387
-     * @throws EE_Error
1388
-     * @throws InvalidArgumentException
1389
-     * @throws InvalidDataTypeException
1390
-     * @throws InvalidInterfaceException
1391
-     * @throws ReflectionException
1392
-     */
1393
-    protected function _delete_ticket()
1394
-    {
1395
-        $success = 1;
1396
-        // checkboxes?
1397
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1398
-            // if array has more than one element then success message should be plural
1399
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1400
-            // cycle thru the boxes
1401
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1402
-                // delete
1403
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1404
-                    $success = 0;
1405
-                }
1406
-            }
1407
-        } else {
1408
-            // grab single id and trash
1409
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1410
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1411
-                $success = 0;
1412
-            }
1413
-        }
1414
-        $action_desc = 'deleted';
1415
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1416
-        $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
1417
-            [['TKT_is_default' => 1]],
1418
-            'TKT_ID',
1419
-            true
1420
-        );
1421
-        $query_args   = $ticket_count
1422
-            ? []
1423
-            : [
1424
-                'action' => 'ticket_list_table',
1425
-                'status' => 'trashed',
1426
-            ];
1427
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1428
-    }
1429
-
1430
-
1431
-    /**
1432
-     * @param int $TKT_ID
1433
-     * @return bool|int
1434
-     * @throws EE_Error
1435
-     * @throws InvalidArgumentException
1436
-     * @throws InvalidDataTypeException
1437
-     * @throws InvalidInterfaceException
1438
-     * @throws ReflectionException
1439
-     */
1440
-    protected function _delete_the_ticket($TKT_ID)
1441
-    {
1442
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1443
-        if (! $ticket instanceof EE_Ticket) {
1444
-            return false;
1445
-        }
1446
-        $ticket->_remove_relations('Datetime');
1447
-        // delete all related prices first
1448
-        $ticket->delete_related_permanently('Price');
1449
-        return $ticket->delete_permanently();
1450
-    }
19
+	/**
20
+	 * @var EE_Admin_Config
21
+	 */
22
+	protected $admin_config;
23
+
24
+	/**
25
+	 * @var AdvancedEditorAdminFormSection
26
+	 */
27
+	protected $advanced_editor_admin_form;
28
+
29
+
30
+	/**
31
+	 * Extend_Events_Admin_Page constructor.
32
+	 *
33
+	 * @param bool $routing
34
+	 * @throws ReflectionException
35
+	 */
36
+	public function __construct($routing = true)
37
+	{
38
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
39
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
40
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
41
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
42
+		}
43
+		parent::__construct($routing);
44
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
45
+	}
46
+
47
+
48
+	/**
49
+	 * Sets routes.
50
+	 *
51
+	 * @throws EE_Error
52
+	 * @throws InvalidArgumentException
53
+	 * @throws InvalidDataTypeException
54
+	 * @throws InvalidInterfaceException
55
+	 * @throws Exception
56
+	 */
57
+	protected function _extend_page_config()
58
+	{
59
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
60
+		// is there a evt_id in the request?
61
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
62
+			? $this->_req_data['EVT_ID']
63
+			: 0;
64
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
65
+		// tkt_id?
66
+		$tkt_id                                          =
67
+			! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
68
+				? $this->_req_data['TKT_ID']
69
+				: 0;
70
+		$new_page_routes                                 = [
71
+			'duplicate_event'          => [
72
+				'func'       => '_duplicate_event',
73
+				'capability' => 'ee_edit_event',
74
+				'obj_id'     => $evt_id,
75
+				'noheader'   => true,
76
+			],
77
+			'import_page'              => [
78
+				'func'       => '_import_page',
79
+				'capability' => 'import',
80
+			],
81
+			'import'                   => [
82
+				'func'       => '_import_events',
83
+				'capability' => 'import',
84
+				'noheader'   => true,
85
+			],
86
+			'import_events'            => [
87
+				'func'       => '_import_events',
88
+				'capability' => 'import',
89
+				'noheader'   => true,
90
+			],
91
+			'export_events'            => [
92
+				'func'       => '_events_export',
93
+				'capability' => 'export',
94
+				'noheader'   => true,
95
+			],
96
+			'export_categories'        => [
97
+				'func'       => '_categories_export',
98
+				'capability' => 'export',
99
+				'noheader'   => true,
100
+			],
101
+			'sample_export_file'       => [
102
+				'func'       => '_sample_export_file',
103
+				'capability' => 'export',
104
+				'noheader'   => true,
105
+			],
106
+			'update_template_settings' => [
107
+				'func'       => '_update_template_settings',
108
+				'capability' => 'manage_options',
109
+				'noheader'   => true,
110
+			],
111
+			'ticket_list_table'        => [
112
+				'func'       => '_tickets_overview_list_table',
113
+				'capability' => 'ee_read_default_tickets',
114
+			],
115
+		];
116
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
117
+		$this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
118
+		// don't load these meta boxes if using the advanced editor
119
+		if (
120
+			! $this->admin_config->useAdvancedEditor()
121
+			|| ! $this->feature->allowed('use_default_ticket_manager')
122
+		) {
123
+			$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
124
+			$this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
125
+
126
+			$legacy_editor_page_routes = [
127
+				'trash_ticket'    => [
128
+					'func'       => '_trash_or_restore_ticket',
129
+					'capability' => 'ee_delete_default_ticket',
130
+					'obj_id'     => $tkt_id,
131
+					'noheader'   => true,
132
+					'args'       => ['trash' => true],
133
+				],
134
+				'trash_tickets'   => [
135
+					'func'       => '_trash_or_restore_ticket',
136
+					'capability' => 'ee_delete_default_tickets',
137
+					'noheader'   => true,
138
+					'args'       => ['trash' => true],
139
+				],
140
+				'restore_ticket'  => [
141
+					'func'       => '_trash_or_restore_ticket',
142
+					'capability' => 'ee_delete_default_ticket',
143
+					'obj_id'     => $tkt_id,
144
+					'noheader'   => true,
145
+				],
146
+				'restore_tickets' => [
147
+					'func'       => '_trash_or_restore_ticket',
148
+					'capability' => 'ee_delete_default_tickets',
149
+					'noheader'   => true,
150
+				],
151
+				'delete_ticket'   => [
152
+					'func'       => '_delete_ticket',
153
+					'capability' => 'ee_delete_default_ticket',
154
+					'obj_id'     => $tkt_id,
155
+					'noheader'   => true,
156
+				],
157
+				'delete_tickets'  => [
158
+					'func'       => '_delete_ticket',
159
+					'capability' => 'ee_delete_default_tickets',
160
+					'noheader'   => true,
161
+				],
162
+			];
163
+			$new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
164
+		}
165
+
166
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
167
+		// partial route/config override
168
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
169
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
170
+		// add tickets tab but only if there are more than one default ticket!
171
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
172
+			[['TKT_is_default' => 1]],
173
+			'TKT_ID',
174
+			true
175
+		);
176
+		if ($tkt_count > 1) {
177
+			$new_page_config = [
178
+				'ticket_list_table' => [
179
+					'nav'           => [
180
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
181
+						'order' => 60,
182
+					],
183
+					'list_table'    => 'Tickets_List_Table',
184
+					'require_nonce' => false,
185
+				],
186
+			];
187
+		}
188
+		// template settings
189
+		$new_page_config['template_settings'] = [
190
+			'nav'           => [
191
+				'label' => esc_html__('Templates', 'event_espresso'),
192
+				'order' => 30,
193
+			],
194
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
195
+			'help_tabs'     => [
196
+				'general_settings_templates_help_tab' => [
197
+					'title'    => esc_html__('Templates', 'event_espresso'),
198
+					'filename' => 'general_settings_templates',
199
+				],
200
+			],
201
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
202
+			// 'help_tour'     => ['Templates_Help_Tour'],
203
+			'require_nonce' => false,
204
+		];
205
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
206
+		// add filters and actions
207
+		// modifying _views
208
+		add_filter(
209
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
210
+			[$this, 'add_additional_datetime_button'],
211
+			10,
212
+			2
213
+		);
214
+		add_filter(
215
+			'FHEE_event_datetime_metabox_clone_button_template',
216
+			[$this, 'add_datetime_clone_button'],
217
+			10,
218
+			2
219
+		);
220
+		add_filter(
221
+			'FHEE_event_datetime_metabox_timezones_template',
222
+			[$this, 'datetime_timezones_template'],
223
+			10,
224
+			2
225
+		);
226
+		// filters for event list table
227
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
228
+		add_filter(
229
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
230
+			[$this, 'extra_list_table_actions'],
231
+			10,
232
+			2
233
+		);
234
+		// legend item
235
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
236
+		add_action('admin_init', [$this, 'admin_init']);
237
+		// load additional handlers
238
+		$this->handleActionRequest();
239
+	}
240
+
241
+
242
+	private function getRequestAction()
243
+	{
244
+		return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null;
245
+	}
246
+
247
+
248
+	/**
249
+	 * @throws Exception
250
+	 */
251
+	private function handleActionRequest()
252
+	{
253
+		$action = $this->getRequestAction();
254
+		if ($action) {
255
+			// setup Advanced Editor ???
256
+			if ($action === 'default_event_settings' || $action === 'update_default_event_settings') {
257
+				$this->advanced_editor_admin_form = $this->loader->getShared(
258
+					'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
259
+				);
260
+			}
261
+		}
262
+	}
263
+
264
+
265
+	/**
266
+	 * admin_init
267
+	 */
268
+	public function admin_init()
269
+	{
270
+		EE_Registry::$i18n_js_strings = array_merge(
271
+			EE_Registry::$i18n_js_strings,
272
+			[
273
+				'image_confirm'          => esc_html__(
274
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
275
+					'event_espresso'
276
+				),
277
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
278
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
279
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
280
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
281
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
282
+			]
283
+		);
284
+	}
285
+
286
+
287
+	/**
288
+	 * Add per page screen options to the default ticket list table view.
289
+	 *
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	protected function _add_screen_options_ticket_list_table()
295
+	{
296
+		$this->_per_page_screen_option();
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param string $return
302
+	 * @param int    $id
303
+	 * @param string $new_title
304
+	 * @param string $new_slug
305
+	 * @return string
306
+	 */
307
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
308
+	{
309
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
310
+		// make sure this is only when editing
311
+		if (! empty($id)) {
312
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
313
+				['action' => 'duplicate_event', 'EVT_ID' => $id],
314
+				$this->_admin_base_url
315
+			);
316
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
317
+			$return .= '<a href="'
318
+					   . $href
319
+					   . '" title="'
320
+					   . $title
321
+					   . '" id="ee-duplicate-event-button" class="button button--secondary"  value="duplicate_event">'
322
+					   . $title
323
+					   . '</a>';
324
+		}
325
+		return $return;
326
+	}
327
+
328
+
329
+	/**
330
+	 * Set the list table views for the default ticket list table view.
331
+	 */
332
+	public function _set_list_table_views_ticket_list_table()
333
+	{
334
+		$this->_views = [
335
+			'all'     => [
336
+				'slug'        => 'all',
337
+				'label'       => esc_html__('All', 'event_espresso'),
338
+				'count'       => 0,
339
+				'bulk_action' => [
340
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
341
+				],
342
+			],
343
+			'trashed' => [
344
+				'slug'        => 'trashed',
345
+				'label'       => esc_html__('Trash', 'event_espresso'),
346
+				'count'       => 0,
347
+				'bulk_action' => [
348
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
349
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
350
+				],
351
+			],
352
+		];
353
+	}
354
+
355
+
356
+	/**
357
+	 * Enqueue scripts and styles for the event editor.
358
+	 */
359
+	public function load_scripts_styles_edit()
360
+	{
361
+		if (! $this->admin_config->useAdvancedEditor()) {
362
+			wp_register_script(
363
+				'ee-event-editor-heartbeat',
364
+				EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
365
+				['ee_admin_js', 'heartbeat'],
366
+				EVENT_ESPRESSO_VERSION,
367
+				true
368
+			);
369
+			wp_enqueue_script('ee-accounting');
370
+			wp_enqueue_script('ee-event-editor-heartbeat');
371
+		}
372
+		wp_enqueue_script('event_editor_js');
373
+		// styles
374
+		wp_enqueue_style('espresso-ui-theme');
375
+	}
376
+
377
+
378
+	/**
379
+	 * Returns template for the additional datetime.
380
+	 *
381
+	 * @param $template
382
+	 * @param $template_args
383
+	 * @return mixed
384
+	 * @throws DomainException
385
+	 */
386
+	public function add_additional_datetime_button($template, $template_args)
387
+	{
388
+		return EEH_Template::display_template(
389
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
390
+			$template_args,
391
+			true
392
+		);
393
+	}
394
+
395
+
396
+	/**
397
+	 * Returns the template for cloning a datetime.
398
+	 *
399
+	 * @param $template
400
+	 * @param $template_args
401
+	 * @return mixed
402
+	 * @throws DomainException
403
+	 */
404
+	public function add_datetime_clone_button($template, $template_args)
405
+	{
406
+		return EEH_Template::display_template(
407
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
408
+			$template_args,
409
+			true
410
+		);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns the template for datetime timezones.
416
+	 *
417
+	 * @param $template
418
+	 * @param $template_args
419
+	 * @return mixed
420
+	 * @throws DomainException
421
+	 */
422
+	public function datetime_timezones_template($template, $template_args)
423
+	{
424
+		return EEH_Template::display_template(
425
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
426
+			$template_args,
427
+			true
428
+		);
429
+	}
430
+
431
+
432
+	/**
433
+	 * Sets the views for the default list table view.
434
+	 *
435
+	 * @throws EE_Error
436
+	 */
437
+	protected function _set_list_table_views_default()
438
+	{
439
+		parent::_set_list_table_views_default();
440
+		$new_views    = [
441
+			'today' => [
442
+				'slug'        => 'today',
443
+				'label'       => esc_html__('Today', 'event_espresso'),
444
+				'count'       => $this->total_events_today(),
445
+				'bulk_action' => [
446
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
447
+				],
448
+			],
449
+			'month' => [
450
+				'slug'        => 'month',
451
+				'label'       => esc_html__('This Month', 'event_espresso'),
452
+				'count'       => $this->total_events_this_month(),
453
+				'bulk_action' => [
454
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
455
+				],
456
+			],
457
+		];
458
+		$this->_views = array_merge($this->_views, $new_views);
459
+	}
460
+
461
+
462
+	/**
463
+	 * Returns the extra action links for the default list table view.
464
+	 *
465
+	 * @param array    $action_links
466
+	 * @param EE_Event $event
467
+	 * @return array
468
+	 * @throws EE_Error
469
+	 * @throws InvalidArgumentException
470
+	 * @throws InvalidDataTypeException
471
+	 * @throws InvalidInterfaceException
472
+	 * @throws ReflectionException
473
+	 */
474
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
475
+	{
476
+		if (
477
+			EE_Registry::instance()->CAP->current_user_can(
478
+				'ee_read_registrations',
479
+				'espresso_registrations_reports',
480
+				$event->ID()
481
+			)
482
+		) {
483
+			$reports_query_args = [
484
+				'action' => 'reports',
485
+				'EVT_ID' => $event->ID(),
486
+			];
487
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
488
+			$action_links[]     = '<a href="'
489
+								  . $reports_link
490
+								  . '" title="'
491
+								  . esc_attr__('View Report', 'event_espresso')
492
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
493
+								  . "\n\t";
494
+		}
495
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
496
+			EE_Registry::instance()->load_helper('MSG_Template');
497
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
498
+				'see_notifications_for',
499
+				null,
500
+				['EVT_ID' => $event->ID()]
501
+			);
502
+		}
503
+		return $action_links;
504
+	}
505
+
506
+
507
+	/**
508
+	 * @param $items
509
+	 * @return mixed
510
+	 */
511
+	public function additional_legend_items($items)
512
+	{
513
+		if (
514
+			EE_Registry::instance()->CAP->current_user_can(
515
+				'ee_read_registrations',
516
+				'espresso_registrations_reports'
517
+			)
518
+		) {
519
+			$items['reports'] = [
520
+				'class' => 'dashicons dashicons-chart-bar',
521
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
522
+			];
523
+		}
524
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
525
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
526
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
527
+			// (can only use numeric offsets when treating strings as arrays)
528
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
529
+				$items['view_related_messages'] = [
530
+					'class' => $related_for_icon['css_class'],
531
+					'desc'  => $related_for_icon['label'],
532
+				];
533
+			}
534
+		}
535
+		return $items;
536
+	}
537
+
538
+
539
+	/**
540
+	 * This is the callback method for the duplicate event route
541
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
542
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
543
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
544
+	 * After duplication the redirect is to the new event edit page.
545
+	 *
546
+	 * @return void
547
+	 * @throws EE_Error If EE_Event is not available with given ID
548
+	 * @throws InvalidArgumentException
549
+	 * @throws InvalidDataTypeException
550
+	 * @throws InvalidInterfaceException
551
+	 * @throws ReflectionException
552
+	 * @access protected
553
+	 */
554
+	protected function _duplicate_event()
555
+	{
556
+		// first make sure the ID for the event is in the request.
557
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
558
+		if (! isset($this->_req_data['EVT_ID'])) {
559
+			EE_Error::add_error(
560
+				esc_html__(
561
+					'In order to duplicate an event an Event ID is required.  None was given.',
562
+					'event_espresso'
563
+				),
564
+				__FILE__,
565
+				__FUNCTION__,
566
+				__LINE__
567
+			);
568
+			$this->_redirect_after_action(false, '', '', [], true);
569
+			return;
570
+		}
571
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
572
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
573
+		if (! $orig_event instanceof EE_Event) {
574
+			throw new EE_Error(
575
+				sprintf(
576
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
577
+					$this->_req_data['EVT_ID']
578
+				)
579
+			);
580
+		}
581
+		// k now let's clone the $orig_event before getting relations
582
+		$new_event = clone $orig_event;
583
+		// original datetimes
584
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
585
+		// other original relations
586
+		$orig_ven = $orig_event->get_many_related('Venue');
587
+		// reset the ID and modify other details to make it clear this is a dupe
588
+		$new_event->set('EVT_ID', 0);
589
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
590
+		$new_event->set('EVT_name', $new_name);
591
+		$new_event->set(
592
+			'EVT_slug',
593
+			wp_unique_post_slug(
594
+				sanitize_title($orig_event->name()),
595
+				0,
596
+				'publish',
597
+				'espresso_events',
598
+				0
599
+			)
600
+		);
601
+		$new_event->set('status', 'draft');
602
+		// duplicate discussion settings
603
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
604
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
605
+		// save the new event
606
+		$new_event->save();
607
+		// venues
608
+		foreach ($orig_ven as $ven) {
609
+			$new_event->_add_relation_to($ven, 'Venue');
610
+		}
611
+		$new_event->save();
612
+		// now we need to get the question group relations and handle that
613
+		// first primary question groups
614
+		$orig_primary_qgs = $orig_event->get_many_related(
615
+			'Question_Group',
616
+			[['Event_Question_Group.EQG_primary' => true]]
617
+		);
618
+		if (! empty($orig_primary_qgs)) {
619
+			foreach ($orig_primary_qgs as $id => $obj) {
620
+				if ($obj instanceof EE_Question_Group) {
621
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
622
+				}
623
+			}
624
+		}
625
+		// next additional attendee question groups
626
+		$orig_additional_qgs = $orig_event->get_many_related(
627
+			'Question_Group',
628
+			[['Event_Question_Group.EQG_additional' => true]]
629
+		);
630
+		if (! empty($orig_additional_qgs)) {
631
+			foreach ($orig_additional_qgs as $id => $obj) {
632
+				if ($obj instanceof EE_Question_Group) {
633
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
634
+				}
635
+			}
636
+		}
637
+
638
+		$new_event->save();
639
+
640
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
641
+		$cloned_tickets = [];
642
+		foreach ($orig_datetimes as $orig_dtt) {
643
+			if (! $orig_dtt instanceof EE_Datetime) {
644
+				continue;
645
+			}
646
+			$new_dtt   = clone $orig_dtt;
647
+			$orig_tkts = $orig_dtt->tickets();
648
+			// save new dtt then add to event
649
+			$new_dtt->set('DTT_ID', 0);
650
+			$new_dtt->set('DTT_sold', 0);
651
+			$new_dtt->set_reserved(0);
652
+			$new_dtt->save();
653
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
654
+			$new_event->save();
655
+			// now let's get the ticket relations setup.
656
+			foreach ((array) $orig_tkts as $orig_tkt) {
657
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
658
+				if (! $orig_tkt instanceof EE_Ticket) {
659
+					continue;
660
+				}
661
+				// is this ticket archived?  If it is then let's skip
662
+				if ($orig_tkt->get('TKT_deleted')) {
663
+					continue;
664
+				}
665
+				// does this original ticket already exist in the clone_tickets cache?
666
+				//  If so we'll just use the new ticket from it.
667
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
668
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
669
+				} else {
670
+					$new_tkt = clone $orig_tkt;
671
+					// get relations on the $orig_tkt that we need to setup.
672
+					$orig_prices = $orig_tkt->prices();
673
+					$new_tkt->set('TKT_ID', 0);
674
+					$new_tkt->set('TKT_sold', 0);
675
+					$new_tkt->set('TKT_reserved', 0);
676
+					$new_tkt->save(); // make sure new ticket has ID.
677
+					// price relations on new ticket need to be setup.
678
+					foreach ($orig_prices as $orig_price) {
679
+						$new_price = clone $orig_price;
680
+						$new_price->set('PRC_ID', 0);
681
+						$new_price->save();
682
+						$new_tkt->_add_relation_to($new_price, 'Price');
683
+						$new_tkt->save();
684
+					}
685
+
686
+					do_action(
687
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
688
+						$orig_tkt,
689
+						$new_tkt,
690
+						$orig_prices,
691
+						$orig_event,
692
+						$orig_dtt,
693
+						$new_dtt
694
+					);
695
+				}
696
+				// k now we can add the new ticket as a relation to the new datetime
697
+				// and make sure its added to our cached $cloned_tickets array
698
+				// for use with later datetimes that have the same ticket.
699
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
700
+				$new_dtt->save();
701
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
702
+			}
703
+		}
704
+		// clone taxonomy information
705
+		$taxonomies_to_clone_with = apply_filters(
706
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
707
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
708
+		);
709
+		// get terms for original event (notice)
710
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
711
+		// loop through terms and add them to new event.
712
+		foreach ($orig_terms as $term) {
713
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
714
+		}
715
+
716
+		// duplicate other core WP_Post items for this event.
717
+		// post thumbnail (feature image).
718
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
719
+		if ($feature_image_id) {
720
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
721
+		}
722
+
723
+		// duplicate page_template setting
724
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
725
+		if ($page_template) {
726
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
727
+		}
728
+
729
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
730
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
731
+		if ($new_event->ID()) {
732
+			$redirect_args = [
733
+				'post'   => $new_event->ID(),
734
+				'action' => 'edit',
735
+			];
736
+			EE_Error::add_success(
737
+				esc_html__(
738
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
739
+					'event_espresso'
740
+				)
741
+			);
742
+		} else {
743
+			$redirect_args = [
744
+				'action' => 'default',
745
+			];
746
+			EE_Error::add_error(
747
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
748
+				__FILE__,
749
+				__FUNCTION__,
750
+				__LINE__
751
+			);
752
+		}
753
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
754
+	}
755
+
756
+
757
+	/**
758
+	 * Generates output for the import page.
759
+	 *
760
+	 * @throws DomainException
761
+	 * @throws EE_Error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidDataTypeException
764
+	 * @throws InvalidInterfaceException
765
+	 */
766
+	protected function _import_page()
767
+	{
768
+		$title                                      = esc_html__('Import', 'event_espresso');
769
+		$intro                                      = esc_html__(
770
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
771
+			'event_espresso'
772
+		);
773
+		$form_url                                   = EVENTS_ADMIN_URL;
774
+		$action                                     = 'import_events';
775
+		$type                                       = 'csv';
776
+		$this->_template_args['form']               = EE_Import::instance()->upload_form(
777
+			$title,
778
+			$intro,
779
+			$form_url,
780
+			$action,
781
+			$type
782
+		);
783
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
784
+			['action' => 'sample_export_file'],
785
+			$this->_admin_base_url
786
+		);
787
+		$content                                    = EEH_Template::display_template(
788
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
789
+			$this->_template_args,
790
+			true
791
+		);
792
+		$this->_template_args['admin_page_content'] = $content;
793
+		$this->display_admin_page_with_sidebar();
794
+	}
795
+
796
+
797
+	/**
798
+	 * _import_events
799
+	 * This handles displaying the screen and running imports for importing events.
800
+	 *
801
+	 * @return void
802
+	 * @throws EE_Error
803
+	 * @throws InvalidArgumentException
804
+	 * @throws InvalidDataTypeException
805
+	 * @throws InvalidInterfaceException
806
+	 */
807
+	protected function _import_events()
808
+	{
809
+		require_once(EE_CLASSES . 'EE_Import.class.php');
810
+		$success = EE_Import::instance()->import();
811
+		$this->_redirect_after_action($success, 'Import File', 'ran', ['action' => 'import_page'], true);
812
+	}
813
+
814
+
815
+	/**
816
+	 * _events_export
817
+	 * Will export all (or just the given event) to a Excel compatible file.
818
+	 *
819
+	 * @access protected
820
+	 * @return void
821
+	 */
822
+	protected function _events_export()
823
+	{
824
+		if (isset($this->_req_data['EVT_ID'])) {
825
+			$event_ids = $this->_req_data['EVT_ID'];
826
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
827
+			$event_ids = $this->_req_data['EVT_IDs'];
828
+		} else {
829
+			$event_ids = null;
830
+		}
831
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
832
+		$new_request_args = [
833
+			'export' => 'report',
834
+			'action' => 'all_event_data',
835
+			'EVT_ID' => $event_ids,
836
+		];
837
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
838
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
839
+			require_once(EE_CLASSES . 'EE_Export.class.php');
840
+			$EE_Export = EE_Export::instance($this->_req_data);
841
+			if ($EE_Export instanceof EE_Export) {
842
+				$EE_Export->export();
843
+			}
844
+		}
845
+	}
846
+
847
+
848
+	/**
849
+	 * handle category exports()
850
+	 *
851
+	 * @return void
852
+	 */
853
+	protected function _categories_export()
854
+	{
855
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
856
+		$new_request_args = [
857
+			'export'       => 'report',
858
+			'action'       => 'categories',
859
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
860
+		];
861
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
862
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
863
+			require_once(EE_CLASSES . 'EE_Export.class.php');
864
+			$EE_Export = EE_Export::instance($this->_req_data);
865
+			if ($EE_Export instanceof EE_Export) {
866
+				$EE_Export->export();
867
+			}
868
+		}
869
+	}
870
+
871
+
872
+	/**
873
+	 * Creates a sample CSV file for importing
874
+	 */
875
+	protected function _sample_export_file()
876
+	{
877
+		$EE_Export = EE_Export::instance();
878
+		if ($EE_Export instanceof EE_Export) {
879
+			$EE_Export->export();
880
+		}
881
+	}
882
+
883
+
884
+	/*************        Template Settings        *************/
885
+	/**
886
+	 * Generates template settings page output
887
+	 *
888
+	 * @throws DomainException
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 */
894
+	protected function _template_settings()
895
+	{
896
+		$this->_template_args['values'] = $this->_yes_no_values;
897
+		/**
898
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
899
+		 * from General_Settings_Admin_Page to here.
900
+		 */
901
+		$this->_template_args = apply_filters(
902
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
903
+			$this->_template_args
904
+		);
905
+		$this->_set_add_edit_form_tags('update_template_settings');
906
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
907
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
909
+			$this->_template_args,
910
+			true
911
+		);
912
+		$this->display_admin_page_with_sidebar();
913
+	}
914
+
915
+
916
+	/**
917
+	 * Handler for updating template settings.
918
+	 *
919
+	 * @throws EE_Error
920
+	 * @throws InvalidArgumentException
921
+	 * @throws InvalidDataTypeException
922
+	 * @throws InvalidInterfaceException
923
+	 */
924
+	protected function _update_template_settings()
925
+	{
926
+		/**
927
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
928
+		 * from General_Settings_Admin_Page to here.
929
+		 */
930
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
931
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
932
+			EE_Registry::instance()->CFG->template_settings,
933
+			$this->_req_data
934
+		);
935
+		// update custom post type slugs and detect if we need to flush rewrite rules
936
+		$old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
937
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
938
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
939
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
940
+		$what                                              = 'Template Settings';
941
+		$success                                           = $this->_update_espresso_configuration(
942
+			$what,
943
+			EE_Registry::instance()->CFG->template_settings,
944
+			__FILE__,
945
+			__FUNCTION__,
946
+			__LINE__
947
+		);
948
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
949
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
950
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
951
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
952
+			);
953
+			$rewrite_rules->flush();
954
+		}
955
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
956
+	}
957
+
958
+
959
+	/**
960
+	 * _premium_event_editor_meta_boxes
961
+	 * add all metaboxes related to the event_editor
962
+	 *
963
+	 * @access protected
964
+	 * @return void
965
+	 * @throws EE_Error
966
+	 * @throws InvalidArgumentException
967
+	 * @throws InvalidDataTypeException
968
+	 * @throws InvalidInterfaceException
969
+	 * @throws ReflectionException
970
+	 */
971
+	protected function _premium_event_editor_meta_boxes()
972
+	{
973
+		$this->verify_cpt_object();
974
+		// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
975
+		if (
976
+			! $this->admin_config->useAdvancedEditor()
977
+			|| ! $this->feature->allowed('use_reg_options_meta_box')
978
+		) {
979
+			$this->addMetaBox(
980
+				'espresso_event_editor_event_options',
981
+				esc_html__('Event Registration Options', 'event_espresso'),
982
+				[$this, 'registration_options_meta_box'],
983
+				$this->page_slug,
984
+				'side',
985
+				'core'
986
+			);
987
+		}
988
+	}
989
+
990
+
991
+	/**
992
+	 * override caf metabox
993
+	 *
994
+	 * @return void
995
+	 * @throws DomainException
996
+	 * @throws EE_Error
997
+	 */
998
+	public function registration_options_meta_box()
999
+	{
1000
+		$yes_no_values                                    = [
1001
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
1002
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
1003
+		];
1004
+		$default_reg_status_values                        = EEM_Registration::reg_status_array(
1005
+			[
1006
+				EEM_Registration::status_id_cancelled,
1007
+				EEM_Registration::status_id_declined,
1008
+				EEM_Registration::status_id_incomplete,
1009
+				EEM_Registration::status_id_wait_list,
1010
+			],
1011
+			true
1012
+		);
1013
+		$template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
1014
+		$template_args['_event']                          = $this->_cpt_model_obj;
1015
+		$template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
1016
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
1017
+			'default_reg_status',
1018
+			$default_reg_status_values,
1019
+			$this->_cpt_model_obj->default_registration_status()
1020
+		);
1021
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
1022
+			'display_desc',
1023
+			$yes_no_values,
1024
+			$this->_cpt_model_obj->display_description()
1025
+		);
1026
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
1027
+			'display_ticket_selector',
1028
+			$yes_no_values,
1029
+			$this->_cpt_model_obj->display_ticket_selector(),
1030
+			'',
1031
+			'',
1032
+			false
1033
+		);
1034
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
1035
+			'EVT_default_registration_status',
1036
+			$default_reg_status_values,
1037
+			$this->_cpt_model_obj->default_registration_status()
1038
+		);
1039
+		$template_args['additional_registration_options'] = apply_filters(
1040
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1041
+			'',
1042
+			$template_args,
1043
+			$yes_no_values,
1044
+			$default_reg_status_values
1045
+		);
1046
+		EEH_Template::display_template(
1047
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1048
+			$template_args
1049
+		);
1050
+	}
1051
+
1052
+
1053
+
1054
+	/**
1055
+	 * wp_list_table_mods for caf
1056
+	 * ============================
1057
+	 */
1058
+	/**
1059
+	 * hook into list table filters and provide filters for caffeinated list table
1060
+	 *
1061
+	 * @param array $old_filters    any existing filters present
1062
+	 * @param array $list_table_obj the list table object
1063
+	 * @return array                  new filters
1064
+	 * @throws EE_Error
1065
+	 * @throws InvalidArgumentException
1066
+	 * @throws InvalidDataTypeException
1067
+	 * @throws InvalidInterfaceException
1068
+	 * @throws ReflectionException
1069
+	 */
1070
+	public function list_table_filters($old_filters, $list_table_obj)
1071
+	{
1072
+		$filters = [];
1073
+		// first month/year filters
1074
+		$filters[] = $this->espresso_event_months_dropdown();
1075
+		$status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1076
+		// active status dropdown
1077
+		if ($status !== 'draft') {
1078
+			$filters[] = $this->active_status_dropdown(
1079
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1080
+			);
1081
+			$filters[] = $this->venuesDropdown(
1082
+				isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1083
+			);
1084
+		}
1085
+		// category filter
1086
+		$filters[] = $this->category_dropdown();
1087
+		return array_merge($old_filters, $filters);
1088
+	}
1089
+
1090
+
1091
+	/**
1092
+	 * espresso_event_months_dropdown
1093
+	 *
1094
+	 * @access public
1095
+	 * @return string                dropdown listing month/year selections for events.
1096
+	 */
1097
+	public function espresso_event_months_dropdown()
1098
+	{
1099
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1100
+		// Note we need to include any other filters that are set!
1101
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1102
+		// categories?
1103
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1104
+			? $this->_req_data['EVT_CAT']
1105
+			: null;
1106
+		// active status?
1107
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1108
+		$cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1109
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1110
+	}
1111
+
1112
+
1113
+	/**
1114
+	 * returns a list of "active" statuses on the event
1115
+	 *
1116
+	 * @param string $current_value whatever the current active status is
1117
+	 * @return string
1118
+	 */
1119
+	public function active_status_dropdown($current_value = '')
1120
+	{
1121
+		$select_name = 'active_status';
1122
+		$values      = [
1123
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1124
+			'active'   => esc_html__('Active', 'event_espresso'),
1125
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1126
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1127
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1128
+		];
1129
+
1130
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1131
+	}
1132
+
1133
+
1134
+	/**
1135
+	 * returns a list of "venues"
1136
+	 *
1137
+	 * @param string $current_value whatever the current active status is
1138
+	 * @return string
1139
+	 * @throws EE_Error
1140
+	 * @throws InvalidArgumentException
1141
+	 * @throws InvalidDataTypeException
1142
+	 * @throws InvalidInterfaceException
1143
+	 * @throws ReflectionException
1144
+	 */
1145
+	protected function venuesDropdown($current_value = '')
1146
+	{
1147
+		$select_name = 'venue';
1148
+		$values      = [
1149
+			'' => esc_html__('All Venues', 'event_espresso'),
1150
+		];
1151
+		// populate the list of venues.
1152
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1153
+		$venues      = $venue_model->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1154
+
1155
+		foreach ($venues as $venue) {
1156
+			$values[ $venue->ID() ] = $venue->name();
1157
+		}
1158
+
1159
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * output a dropdown of the categories for the category filter on the event admin list table
1165
+	 *
1166
+	 * @access  public
1167
+	 * @return string html
1168
+	 */
1169
+	public function category_dropdown()
1170
+	{
1171
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1172
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1173
+	}
1174
+
1175
+
1176
+	/**
1177
+	 * get total number of events today
1178
+	 *
1179
+	 * @access public
1180
+	 * @return int
1181
+	 * @throws EE_Error
1182
+	 * @throws InvalidArgumentException
1183
+	 * @throws InvalidDataTypeException
1184
+	 * @throws InvalidInterfaceException
1185
+	 */
1186
+	public function total_events_today()
1187
+	{
1188
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1189
+			'DTT_EVT_start',
1190
+			date('Y-m-d') . ' 00:00:00',
1191
+			'Y-m-d H:i:s',
1192
+			'UTC'
1193
+		);
1194
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1195
+			'DTT_EVT_start',
1196
+			date('Y-m-d') . ' 23:59:59',
1197
+			'Y-m-d H:i:s',
1198
+			'UTC'
1199
+		);
1200
+		$where = [
1201
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1202
+		];
1203
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1204
+	}
1205
+
1206
+
1207
+	/**
1208
+	 * get total number of events this month
1209
+	 *
1210
+	 * @access public
1211
+	 * @return int
1212
+	 * @throws EE_Error
1213
+	 * @throws InvalidArgumentException
1214
+	 * @throws InvalidDataTypeException
1215
+	 * @throws InvalidInterfaceException
1216
+	 */
1217
+	public function total_events_this_month()
1218
+	{
1219
+		// Dates
1220
+		$this_year_r     = date('Y');
1221
+		$this_month_r    = date('m');
1222
+		$days_this_month = date('t');
1223
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1224
+			'DTT_EVT_start',
1225
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1226
+			'Y-m-d H:i:s',
1227
+			'UTC'
1228
+		);
1229
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1230
+			'DTT_EVT_start',
1231
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1232
+			'Y-m-d H:i:s',
1233
+			'UTC'
1234
+		);
1235
+		$where           = [
1236
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1237
+		];
1238
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1239
+	}
1240
+
1241
+
1242
+	/** DEFAULT TICKETS STUFF **/
1243
+
1244
+	/**
1245
+	 * Output default tickets list table view.
1246
+	 *
1247
+	 * @throws DomainException
1248
+	 * @throws EE_Error
1249
+	 * @throws InvalidArgumentException
1250
+	 * @throws InvalidDataTypeException
1251
+	 * @throws InvalidInterfaceException
1252
+	 */
1253
+	public function _tickets_overview_list_table()
1254
+	{
1255
+		if (
1256
+			$this->admin_config->useAdvancedEditor()
1257
+			&& $this->feature->allowed('use_default_ticket_manager')
1258
+		) {
1259
+			// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1260
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1261
+				EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1262
+				[],
1263
+				true
1264
+			);
1265
+			$this->display_admin_page_with_no_sidebar();
1266
+		} else {
1267
+			$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1268
+			$this->display_admin_list_table_page_with_no_sidebar();
1269
+		}
1270
+	}
1271
+
1272
+
1273
+	/**
1274
+	 * @param int  $per_page
1275
+	 * @param bool $count
1276
+	 * @param bool $trashed
1277
+	 * @return EE_Soft_Delete_Base_Class[]|int
1278
+	 * @throws EE_Error
1279
+	 * @throws InvalidArgumentException
1280
+	 * @throws InvalidDataTypeException
1281
+	 * @throws InvalidInterfaceException
1282
+	 */
1283
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1284
+	{
1285
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1286
+		$order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1287
+		switch ($orderby) {
1288
+			case 'TKT_name':
1289
+				$orderby = ['TKT_name' => $order];
1290
+				break;
1291
+			case 'TKT_price':
1292
+				$orderby = ['TKT_price' => $order];
1293
+				break;
1294
+			case 'TKT_uses':
1295
+				$orderby = ['TKT_uses' => $order];
1296
+				break;
1297
+			case 'TKT_min':
1298
+				$orderby = ['TKT_min' => $order];
1299
+				break;
1300
+			case 'TKT_max':
1301
+				$orderby = ['TKT_max' => $order];
1302
+				break;
1303
+			case 'TKT_qty':
1304
+				$orderby = ['TKT_qty' => $order];
1305
+				break;
1306
+		}
1307
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1308
+			? $this->_req_data['paged']
1309
+			: 1;
1310
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1311
+			? $this->_req_data['perpage']
1312
+			: $per_page;
1313
+		$_where       = [
1314
+			'TKT_is_default' => 1,
1315
+			'TKT_deleted'    => $trashed,
1316
+		];
1317
+		$offset       = ($current_page - 1) * $per_page;
1318
+		$limit        = [$offset, $per_page];
1319
+		if (isset($this->_req_data['s'])) {
1320
+			$sstr         = '%' . $this->_req_data['s'] . '%';
1321
+			$_where['OR'] = [
1322
+				'TKT_name'        => ['LIKE', $sstr],
1323
+				'TKT_description' => ['LIKE', $sstr],
1324
+			];
1325
+		}
1326
+		$query_params = [
1327
+			$_where,
1328
+			'order_by' => $orderby,
1329
+			'limit'    => $limit,
1330
+			'group_by' => 'TKT_ID',
1331
+		];
1332
+		if ($count) {
1333
+			return EEM_Ticket::instance()->count_deleted_and_undeleted([$_where]);
1334
+		}
1335
+		return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * @param bool $trash
1341
+	 * @throws EE_Error
1342
+	 * @throws InvalidArgumentException
1343
+	 * @throws InvalidDataTypeException
1344
+	 * @throws InvalidInterfaceException
1345
+	 */
1346
+	protected function _trash_or_restore_ticket($trash = false)
1347
+	{
1348
+		$success = 1;
1349
+		$TKT     = EEM_Ticket::instance();
1350
+		// checkboxes?
1351
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352
+			// if array has more than one element then success message should be plural
1353
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1354
+			// cycle thru the boxes
1355
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1356
+				if ($trash) {
1357
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1358
+						$success = 0;
1359
+					}
1360
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1361
+					$success = 0;
1362
+				}
1363
+			}
1364
+		} else {
1365
+			// grab single id and trash
1366
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1367
+			if ($trash) {
1368
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1369
+					$success = 0;
1370
+				}
1371
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1372
+				$success = 0;
1373
+			}
1374
+		}
1375
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1376
+		$query_args  = [
1377
+			'action' => 'ticket_list_table',
1378
+			'status' => $trash ? '' : 'trashed',
1379
+		];
1380
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1381
+	}
1382
+
1383
+
1384
+	/**
1385
+	 * Handles trashing default ticket.
1386
+	 *
1387
+	 * @throws EE_Error
1388
+	 * @throws InvalidArgumentException
1389
+	 * @throws InvalidDataTypeException
1390
+	 * @throws InvalidInterfaceException
1391
+	 * @throws ReflectionException
1392
+	 */
1393
+	protected function _delete_ticket()
1394
+	{
1395
+		$success = 1;
1396
+		// checkboxes?
1397
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1398
+			// if array has more than one element then success message should be plural
1399
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1400
+			// cycle thru the boxes
1401
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1402
+				// delete
1403
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1404
+					$success = 0;
1405
+				}
1406
+			}
1407
+		} else {
1408
+			// grab single id and trash
1409
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1410
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1411
+				$success = 0;
1412
+			}
1413
+		}
1414
+		$action_desc = 'deleted';
1415
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1416
+		$ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
1417
+			[['TKT_is_default' => 1]],
1418
+			'TKT_ID',
1419
+			true
1420
+		);
1421
+		$query_args   = $ticket_count
1422
+			? []
1423
+			: [
1424
+				'action' => 'ticket_list_table',
1425
+				'status' => 'trashed',
1426
+			];
1427
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1428
+	}
1429
+
1430
+
1431
+	/**
1432
+	 * @param int $TKT_ID
1433
+	 * @return bool|int
1434
+	 * @throws EE_Error
1435
+	 * @throws InvalidArgumentException
1436
+	 * @throws InvalidDataTypeException
1437
+	 * @throws InvalidInterfaceException
1438
+	 * @throws ReflectionException
1439
+	 */
1440
+	protected function _delete_the_ticket($TKT_ID)
1441
+	{
1442
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1443
+		if (! $ticket instanceof EE_Ticket) {
1444
+			return false;
1445
+		}
1446
+		$ticket->_remove_relations('Datetime');
1447
+		// delete all related prices first
1448
+		$ticket->delete_related_permanently('Price');
1449
+		return $ticket->delete_permanently();
1450
+	}
1451 1451
 }
Please login to merge, or discard this patch.
admin/extend/messages/Custom_Messages_Template_List_Table.class.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -12,259 +12,259 @@
 block discarded – undo
12 12
 class Custom_Messages_Template_List_Table extends Messages_Template_List_Table
13 13
 {
14 14
 
15
-    /**
16
-     * Setup initial data.
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->get_admin_page()->get_message_templates(
21
-            $this->_per_page,
22
-            $this->_view,
23
-            false,
24
-            false,
25
-            false
26
-        );
27
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
28
-            $this->_per_page,
29
-            $this->_view,
30
-            true,
31
-            true,
32
-            false
33
-        );
34
-    }
15
+	/**
16
+	 * Setup initial data.
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->get_admin_page()->get_message_templates(
21
+			$this->_per_page,
22
+			$this->_view,
23
+			false,
24
+			false,
25
+			false
26
+		);
27
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
28
+			$this->_per_page,
29
+			$this->_view,
30
+			true,
31
+			true,
32
+			false
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Set initial properties
39
-     */
40
-    protected function _set_properties()
41
-    {
42
-        parent::_set_properties();
43
-        $this->_wp_list_args = array(
44
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
45
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
46
-            'ajax'     => true, // for now,
47
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
48
-        );
37
+	/**
38
+	 * Set initial properties
39
+	 */
40
+	protected function _set_properties()
41
+	{
42
+		parent::_set_properties();
43
+		$this->_wp_list_args = array(
44
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
45
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
46
+			'ajax'     => true, // for now,
47
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
48
+		);
49 49
 
50
-        $this->_columns = array_merge(
51
-            array(
52
-                'cb'   => '<input type="checkbox" />',
53
-                'name' => esc_html__('Template Name', 'event_espresso'),
54
-            ),
55
-            $this->_columns,
56
-            array(
57
-                'events'  => esc_html__('Events', 'event_espresso'),
58
-                'actions' => '',
59
-            )
60
-        );
61
-    }
50
+		$this->_columns = array_merge(
51
+			array(
52
+				'cb'   => '<input type="checkbox" />',
53
+				'name' => esc_html__('Template Name', 'event_espresso'),
54
+			),
55
+			$this->_columns,
56
+			array(
57
+				'events'  => esc_html__('Events', 'event_espresso'),
58
+				'actions' => '',
59
+			)
60
+		);
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * Custom message for when there are no items found.
66
-     *
67
-     * @since 4.3.0
68
-     */
69
-    public function no_items()
70
-    {
71
-        if ($this->_view !== 'trashed') {
72
-            printf(
73
-                esc_html__(
74
-                    '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
75
-                    'event_espresso'
76
-                ),
77
-                '<strong>',
78
-                '</strong>'
79
-            );
80
-        } else {
81
-            parent::no_items();
82
-        }
83
-    }
64
+	/**
65
+	 * Custom message for when there are no items found.
66
+	 *
67
+	 * @since 4.3.0
68
+	 */
69
+	public function no_items()
70
+	{
71
+		if ($this->_view !== 'trashed') {
72
+			printf(
73
+				esc_html__(
74
+					'%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
75
+					'event_espresso'
76
+				),
77
+				'<strong>',
78
+				'</strong>'
79
+			);
80
+		} else {
81
+			parent::no_items();
82
+		}
83
+	}
84 84
 
85 85
 
86
-    /**
87
-     * @param EE_Message_Template_Group $item
88
-     * @return string
89
-     */
90
-    public function column_cb($item)
91
-    {
92
-        return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID());
93
-    }
86
+	/**
87
+	 * @param EE_Message_Template_Group $item
88
+	 * @return string
89
+	 */
90
+	public function column_cb($item)
91
+	{
92
+		return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID());
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * @param EE_Message_Template_Group $item
98
-     * @return string
99
-     */
100
-    public function column_name($item)
101
-    {
102
-        return '<p>' . $item->name() . '</p>';
103
-    }
96
+	/**
97
+	 * @param EE_Message_Template_Group $item
98
+	 * @return string
99
+	 */
100
+	public function column_name($item)
101
+	{
102
+		return '<p>' . $item->name() . '</p>';
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @param EE_Message_Template_Group $item
108
-     * @return string
109
-     */
110
-    public function column_actions($item)
111
-    {
112
-        if (
113
-            EE_Registry::instance()->CAP->current_user_can(
114
-                'ee_edit_messages',
115
-                'espresso_messages_add_new_message_template'
116
-            )
117
-        ) {
118
-            $create_args = array(
119
-                'GRP_ID'       => $item->ID(),
120
-                'messenger'    => $item->messenger(),
121
-                'message_type' => $item->message_type(),
122
-                'action'       => 'add_new_message_template',
123
-            );
124
-            $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
125
-            return sprintf(
126
-                '<p><a href="%s" class="button button--secondary">%s</a></p>',
127
-                $create_link,
128
-                esc_html__('Create Custom', 'event_espresso')
129
-            );
130
-        }
131
-        return '';
132
-    }
106
+	/**
107
+	 * @param EE_Message_Template_Group $item
108
+	 * @return string
109
+	 */
110
+	public function column_actions($item)
111
+	{
112
+		if (
113
+			EE_Registry::instance()->CAP->current_user_can(
114
+				'ee_edit_messages',
115
+				'espresso_messages_add_new_message_template'
116
+			)
117
+		) {
118
+			$create_args = array(
119
+				'GRP_ID'       => $item->ID(),
120
+				'messenger'    => $item->messenger(),
121
+				'message_type' => $item->message_type(),
122
+				'action'       => 'add_new_message_template',
123
+			);
124
+			$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
125
+			return sprintf(
126
+				'<p><a href="%s" class="button button--secondary">%s</a></p>',
127
+				$create_link,
128
+				esc_html__('Create Custom', 'event_espresso')
129
+			);
130
+		}
131
+		return '';
132
+	}
133 133
 
134
-    /**
135
-     * Set the view counts on the _views property
136
-     */
137
-    protected function _add_view_counts()
138
-    {
139
-        foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
-                $this->_per_page,
142
-                $view,
143
-                true,
144
-                true,
145
-                false
146
-            );
147
-        }
148
-    }
134
+	/**
135
+	 * Set the view counts on the _views property
136
+	 */
137
+	protected function _add_view_counts()
138
+	{
139
+		foreach ($this->_views as $view => $args) {
140
+			$this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
+				$this->_per_page,
142
+				$view,
143
+				true,
144
+				true,
145
+				false
146
+			);
147
+		}
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * column_events
153
-     * This provides a count of events using this custom template
154
-     *
155
-     * @param  EE_Message_Template_Group $item message_template group data
156
-     * @return string column output
157
-     */
158
-    public function column_events($item)
159
-    {
160
-        return $item->count_events();
161
-    }
151
+	/**
152
+	 * column_events
153
+	 * This provides a count of events using this custom template
154
+	 *
155
+	 * @param  EE_Message_Template_Group $item message_template group data
156
+	 * @return string column output
157
+	 */
158
+	public function column_events($item)
159
+	{
160
+		return $item->count_events();
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * Add additional actions for custom message template list view.
166
-     *
167
-     * @param EE_Message_Template_Group $item
168
-     * @return array
169
-     * @throws EE_Error
170
-     */
171
-    protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
172
-    {
173
-        $actions = parent::_get_actions_for_messenger_column($item);
164
+	/**
165
+	 * Add additional actions for custom message template list view.
166
+	 *
167
+	 * @param EE_Message_Template_Group $item
168
+	 * @return array
169
+	 * @throws EE_Error
170
+	 */
171
+	protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
172
+	{
173
+		$actions = parent::_get_actions_for_messenger_column($item);
174 174
 
175
-        // add additional actions for trash/restore etc.
176
-        $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
177
-            'action'   => 'trash_message_template',
178
-            'id'       => $item->GRP_ID(),
179
-            'noheader' => true,
180
-        ), EE_MSG_ADMIN_URL);
181
-        // restore link
182
-        $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
183
-            'action'   => 'restore_message_template',
184
-            'id'       => $item->GRP_ID(),
185
-            'noheader' => true,
186
-        ), EE_MSG_ADMIN_URL);
187
-        // delete price link
188
-        $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
189
-            'action'   => 'delete_message_template',
190
-            'id'       => $item->GRP_ID(),
191
-            'noheader' => true,
192
-        ), EE_MSG_ADMIN_URL);
175
+		// add additional actions for trash/restore etc.
176
+		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
177
+			'action'   => 'trash_message_template',
178
+			'id'       => $item->GRP_ID(),
179
+			'noheader' => true,
180
+		), EE_MSG_ADMIN_URL);
181
+		// restore link
182
+		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
183
+			'action'   => 'restore_message_template',
184
+			'id'       => $item->GRP_ID(),
185
+			'noheader' => true,
186
+		), EE_MSG_ADMIN_URL);
187
+		// delete price link
188
+		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
189
+			'action'   => 'delete_message_template',
190
+			'id'       => $item->GRP_ID(),
191
+			'noheader' => true,
192
+		), EE_MSG_ADMIN_URL);
193 193
 
194
-        if (
195
-            ! $item->get('MTP_deleted')
196
-            && EE_Registry::instance()->CAP->current_user_can(
197
-                'ee_delete_message',
198
-                'espresso_messages_trash_message_template',
199
-                $item->ID()
200
-            )
201
-        ) {
202
-            $actions['trash'] = '<a href="'
203
-                                . $trash_lnk_url
204
-                                . '" title="'
205
-                                . esc_attr__('Move Template Group to Trash', 'event_espresso')
206
-                                . '">'
207
-                                . esc_html__('Move to Trash', 'event_espresso')
208
-                                . '</a>';
209
-        } else {
210
-            if (
211
-                EE_Registry::instance()->CAP->current_user_can(
212
-                    'ee_delete_message',
213
-                    'espresso_messages_restore_message_template',
214
-                    $item->ID()
215
-                )
216
-            ) {
217
-                $actions['restore'] = '<a href="'
218
-                                      . $restore_lnk_url
219
-                                      . '" title="'
220
-                                      . esc_attr__('Restore Message Template', 'event_espresso')
221
-                                      . '">'
222
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
223
-            }
194
+		if (
195
+			! $item->get('MTP_deleted')
196
+			&& EE_Registry::instance()->CAP->current_user_can(
197
+				'ee_delete_message',
198
+				'espresso_messages_trash_message_template',
199
+				$item->ID()
200
+			)
201
+		) {
202
+			$actions['trash'] = '<a href="'
203
+								. $trash_lnk_url
204
+								. '" title="'
205
+								. esc_attr__('Move Template Group to Trash', 'event_espresso')
206
+								. '">'
207
+								. esc_html__('Move to Trash', 'event_espresso')
208
+								. '</a>';
209
+		} else {
210
+			if (
211
+				EE_Registry::instance()->CAP->current_user_can(
212
+					'ee_delete_message',
213
+					'espresso_messages_restore_message_template',
214
+					$item->ID()
215
+				)
216
+			) {
217
+				$actions['restore'] = '<a href="'
218
+									  . $restore_lnk_url
219
+									  . '" title="'
220
+									  . esc_attr__('Restore Message Template', 'event_espresso')
221
+									  . '">'
222
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
223
+			}
224 224
 
225
-            if (
226
-                $this->_view === 'trashed'
227
-                && EE_Registry::instance()->CAP->current_user_can(
228
-                    'ee_delete_message',
229
-                    'espresso_messages_delete_message_template',
230
-                    $item->ID()
231
-                )
232
-            ) {
233
-                $actions['delete'] = '<a href="'
234
-                                     . $delete_lnk_url
235
-                                     . '" title="'
236
-                                     . esc_attr__('Delete Template Group Permanently', 'event_espresso')
237
-                                     . '">'
238
-                                     . esc_html__('Delete Permanently', 'event_espresso')
239
-                                     . '</a>';
240
-            }
241
-        }
242
-        return $actions;
243
-    }
225
+			if (
226
+				$this->_view === 'trashed'
227
+				&& EE_Registry::instance()->CAP->current_user_can(
228
+					'ee_delete_message',
229
+					'espresso_messages_delete_message_template',
230
+					$item->ID()
231
+				)
232
+			) {
233
+				$actions['delete'] = '<a href="'
234
+									 . $delete_lnk_url
235
+									 . '" title="'
236
+									 . esc_attr__('Delete Template Group Permanently', 'event_espresso')
237
+									 . '">'
238
+									 . esc_html__('Delete Permanently', 'event_espresso')
239
+									 . '</a>';
240
+			}
241
+		}
242
+		return $actions;
243
+	}
244 244
 
245 245
 
246
-    /**
247
-     * Generate dropdown filter select input for messengers
248
-     *
249
-     * @param bool $global
250
-     * @return string
251
-     * @throws EE_Error
252
-     */
253
-    protected function _get_messengers_dropdown_filter($global = true)
254
-    {
255
-        return parent::_get_messengers_dropdown_filter(false);
256
-    }
246
+	/**
247
+	 * Generate dropdown filter select input for messengers
248
+	 *
249
+	 * @param bool $global
250
+	 * @return string
251
+	 * @throws EE_Error
252
+	 */
253
+	protected function _get_messengers_dropdown_filter($global = true)
254
+	{
255
+		return parent::_get_messengers_dropdown_filter(false);
256
+	}
257 257
 
258 258
 
259
-    /**
260
-     * Generate dropdown filter select input for message types
261
-     *
262
-     * @param bool $global
263
-     * @return string
264
-     * @throws EE_Error
265
-     */
266
-    protected function _get_message_types_dropdown_filter($global = true)
267
-    {
268
-        return parent::_get_message_types_dropdown_filter(false);
269
-    }
259
+	/**
260
+	 * Generate dropdown filter select input for message types
261
+	 *
262
+	 * @param bool $global
263
+	 * @return string
264
+	 * @throws EE_Error
265
+	 */
266
+	protected function _get_message_types_dropdown_filter($global = true)
267
+	{
268
+		return parent::_get_message_types_dropdown_filter(false);
269
+	}
270 270
 }
Please login to merge, or discard this patch.