Completed
Branch master (d4ace2)
by
unknown
04:43
created
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110 110
             EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111 111
         ];
112
-        $sort_values   = [
112
+        $sort_values = [
113 113
             EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114 114
             EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115 115
         ];
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
                 // Before widget (defined by themes).
329 329
                 echo wp_kses($before_widget, AllowedTags::getAllowedTags());
330 330
                 // Display the widget title if one was input (before and after defined by themes).
331
-                if (! empty($title)) {
332
-                    echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags());
331
+                if ( ! empty($title)) {
332
+                    echo wp_kses($before_title.$title.$after_title, AllowedTags::getAllowedTags());
333 333
                 }
334 334
                 echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags());
335 335
                 // After widget (defined by themes).
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      */
349 349
     public function make_the_title_a_link($title)
350 350
     {
351
-        return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
351
+        return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>';
352 352
     }
353 353
 
354 354
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             foreach ($sizes as $image_size) {
430 430
                 $image_size = trim($image_size);
431 431
                 // no big images plz
432
-                if (! in_array($image_size, ['large', 'post-thumbnail'])) {
432
+                if ( ! in_array($image_size, ['large', 'post-thumbnail'])) {
433 433
                     $image_sizes[] =
434 434
                         EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
435 435
                 }
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
     private function parseWidgetSettings(array $instance)
457 457
     {
458 458
         $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
459
-        $this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
459
+        $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name'])
460 460
             ? $instance['category_name']
461 461
             : false;
462 462
         $this->show_expired = isset($instance['show_expired'])
@@ -514,24 +514,24 @@  discard block
 block discarded – undo
514 514
         }
515 515
         $list_items = '';
516 516
         foreach ($events as $event) {
517
-            if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
517
+            if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) {
518 518
                 $event_url = $this->eventUrl($event);
519 519
                 $list_items .= '
520
-                <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '"
520
+                <li id="ee-upcoming-events-widget-li-' . absint($event->ID()).'"
521 521
                     class="ee-upcoming-events-widget-li"
522 522
                 >
523 523
                     <h5 class="ee-upcoming-events-widget-title-h5">
524
-                        <a class="ee-widget-event-name-a' . $this->linkClass($event) . '" href="' . $event_url . '">
525
-                            ' . esc_html($event->name()) . '
524
+                        <a class="ee-widget-event-name-a' . $this->linkClass($event).'" href="'.$event_url.'">
525
+                            ' . esc_html($event->name()).'
526 526
                         </a>
527 527
                     </h5>
528
-                    ' . $this->eventWidgetContent($event, $event_url) . '
528
+                    ' . $this->eventWidgetContent($event, $event_url).'
529 529
                 </li>';
530 530
             }
531 531
         }
532 532
         return '
533 533
             <ul class="ee-upcoming-events-widget-ul">
534
-                ' . $list_items . '
534
+                ' . $list_items.'
535 535
             </ul>';
536 536
     }
537 537
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
         return EEM_Event::instance()->get_all(
564 564
             [
565 565
                 $this->queryWhereParams(),
566
-                'limit'    => '0,' . $this->limit,
566
+                'limit'    => '0,'.$this->limit,
567 567
                 'order_by' => 'Datetime.DTT_EVT_start',
568 568
                 'order'    => $this->order,
569 569
                 'group_by' => 'EVT_ID',
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
         if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
652 652
             $content .= '
653 653
                 <div class="ee-upcoming-events-widget-img-dv">
654
-                    <a class="ee-upcoming-events-widget-img" href="' . $event_url . '">
655
-                        ' . get_the_post_thumbnail($event->ID(), $this->image_size) . '
654
+                    <a class="ee-upcoming-events-widget-img" href="' . $event_url.'">
655
+                        ' . get_the_post_thumbnail($event->ID(), $this->image_size).'
656 656
                     </a>
657 657
                 </div>';
658 658
         }
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
 
664 664
         if ($this->show_desc) {
665 665
             $allowedtags = AllowedTags::getAllowedTags();
666
-            $desc    = $event->short_description(25);
667
-            $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
666
+            $desc = $event->short_description(25);
667
+            $content .= $desc ? '<p style="margin-top: .5em">'.wp_kses($desc, $allowedtags).'</p>' : '';
668 668
         }
669 669
 
670 670
         return $content;
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
      */
681 681
     private function eventDates(EE_Event $event)
682 682
     {
683
-        $date_format        = apply_filters(
683
+        $date_format = apply_filters(
684 684
             'FHEE__espresso_event_date_range__date_format',
685 685
             get_option('date_format')
686 686
         );
687
-        $time_format        = apply_filters(
687
+        $time_format = apply_filters(
688 688
             'FHEE__espresso_event_date_range__time_format',
689 689
             get_option('time_format')
690 690
         );
Please login to merge, or discard this patch.
Indentation   +618 added lines, -618 removed lines patch added patch discarded remove patch
@@ -13,109 +13,109 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class EEW_Upcoming_Events extends EspressoWidget
15 15
 {
16
-    /**
17
-     * @var string
18
-     */
19
-    private $title;
20
-    /**
21
-     * @var string
22
-     */
23
-    private $events_category;
24
-
25
-    /**
26
-     * @var bool
27
-     */
28
-    private $show_expired;
29
-
30
-    /**
31
-     * @var string
32
-     */
33
-    private $image_size;
34
-
35
-    /**
36
-     * @var bool
37
-     */
38
-    private $show_desc;
39
-
40
-    /**
41
-     * @var bool
42
-     */
43
-    private $show_dates;
44
-
45
-    /**
46
-     * @var string
47
-     */
48
-    private $date_limit;
49
-
50
-    /**
51
-     * @var string
52
-     */
53
-    private $date_range;
54
-
55
-    /**
56
-     * @var string
57
-     */
58
-    private $limit;
59
-
60
-    /**
61
-     * @var string
62
-     */
63
-    private $order;
64
-
65
-
66
-    /**
67
-     * Register widget with WordPress.
68
-     */
69
-    public function __construct()
70
-    {
71
-        parent::__construct(
72
-            esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
73
-            ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
74
-        );
75
-    }
76
-
77
-
78
-    /**
79
-     * Back-end widget form.
80
-     *
81
-     * @param array $instance Previously saved values from database.
82
-     * @return void
83
-     * @throws EE_Error
84
-     * @throws ReflectionException
85
-     * @see WP_Widget::form()
86
-     */
87
-    public function form($instance)
88
-    {
89
-
90
-        EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
91
-        // Set up some default widget settings.
92
-        $defaults = [
93
-            'title'           => esc_html__('Upcoming Events', 'event_espresso'),
94
-            'category_name'   => '',
95
-            'show_expired'    => 0,
96
-            'show_desc'       => true,
97
-            'show_dates'      => true,
98
-            'show_everywhere' => false,
99
-            'date_limit'      => 2,
100
-            'limit'           => 10,
101
-            'sort'            => 'ASC',
102
-            'date_range'      => false,
103
-            'image_size'      => 'medium',
104
-        ];
105
-
106
-        $instance = wp_parse_args((array) $instance, $defaults);
107
-        // don't add HTML labels for EE_Form_Fields generated inputs
108
-        add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
109
-        $yes_no_values = [
110
-            EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
111
-            EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
112
-        ];
113
-        $sort_values   = [
114
-            EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
115
-            EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
116
-        ];
117
-
118
-        ?>
16
+	/**
17
+	 * @var string
18
+	 */
19
+	private $title;
20
+	/**
21
+	 * @var string
22
+	 */
23
+	private $events_category;
24
+
25
+	/**
26
+	 * @var bool
27
+	 */
28
+	private $show_expired;
29
+
30
+	/**
31
+	 * @var string
32
+	 */
33
+	private $image_size;
34
+
35
+	/**
36
+	 * @var bool
37
+	 */
38
+	private $show_desc;
39
+
40
+	/**
41
+	 * @var bool
42
+	 */
43
+	private $show_dates;
44
+
45
+	/**
46
+	 * @var string
47
+	 */
48
+	private $date_limit;
49
+
50
+	/**
51
+	 * @var string
52
+	 */
53
+	private $date_range;
54
+
55
+	/**
56
+	 * @var string
57
+	 */
58
+	private $limit;
59
+
60
+	/**
61
+	 * @var string
62
+	 */
63
+	private $order;
64
+
65
+
66
+	/**
67
+	 * Register widget with WordPress.
68
+	 */
69
+	public function __construct()
70
+	{
71
+		parent::__construct(
72
+			esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
73
+			['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
74
+		);
75
+	}
76
+
77
+
78
+	/**
79
+	 * Back-end widget form.
80
+	 *
81
+	 * @param array $instance Previously saved values from database.
82
+	 * @return void
83
+	 * @throws EE_Error
84
+	 * @throws ReflectionException
85
+	 * @see WP_Widget::form()
86
+	 */
87
+	public function form($instance)
88
+	{
89
+
90
+		EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
91
+		// Set up some default widget settings.
92
+		$defaults = [
93
+			'title'           => esc_html__('Upcoming Events', 'event_espresso'),
94
+			'category_name'   => '',
95
+			'show_expired'    => 0,
96
+			'show_desc'       => true,
97
+			'show_dates'      => true,
98
+			'show_everywhere' => false,
99
+			'date_limit'      => 2,
100
+			'limit'           => 10,
101
+			'sort'            => 'ASC',
102
+			'date_range'      => false,
103
+			'image_size'      => 'medium',
104
+		];
105
+
106
+		$instance = wp_parse_args((array) $instance, $defaults);
107
+		// don't add HTML labels for EE_Form_Fields generated inputs
108
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
109
+		$yes_no_values = [
110
+			EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
111
+			EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
112
+		];
113
+		$sort_values   = [
114
+			EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
115
+			EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
116
+		];
117
+
118
+		?>
119 119
 
120 120
         <!-- Widget Title: Text Input -->
121 121
 
@@ -152,38 +152,38 @@  discard block
 block discarded – undo
152 152
                 <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?>
153 153
             </label>
154 154
             <?php
155
-            $show_expired_options   = $yes_no_values;
156
-            $show_expired_options[] = EE_Question_Option::new_instance(
157
-                ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
158
-            );
159
-            echo wp_kses(
160
-                EEH_Form_Fields::select(
161
-                    esc_html__('Show Expired Events:', 'event_espresso'),
162
-                    $instance['show_expired'],
163
-                    $show_expired_options,
164
-                    $this->fieldName('show_expired'),
165
-                    $this->fieldID('show_expired')
166
-                ),
167
-                AllowedTags::getWithFormTags()
168
-            );
169
-            ?>
155
+			$show_expired_options   = $yes_no_values;
156
+			$show_expired_options[] = EE_Question_Option::new_instance(
157
+				['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
158
+			);
159
+			echo wp_kses(
160
+				EEH_Form_Fields::select(
161
+					esc_html__('Show Expired Events:', 'event_espresso'),
162
+					$instance['show_expired'],
163
+					$show_expired_options,
164
+					$this->fieldName('show_expired'),
165
+					$this->fieldID('show_expired')
166
+				),
167
+				AllowedTags::getWithFormTags()
168
+			);
169
+			?>
170 170
         </p>
171 171
         <p>
172 172
             <label for="<?php echo esc_attr($this->fieldID('sort')); ?>">
173 173
                 <?php esc_html_e('Sort Events:', 'event_espresso'); ?>
174 174
             </label>
175 175
             <?php
176
-            echo wp_kses(
177
-                EEH_Form_Fields::select(
178
-                    esc_html__('Sort Events:', 'event_espresso'),
179
-                    $instance['sort'],
180
-                    $sort_values,
181
-                    $this->fieldName('sort'),
182
-                    $this->fieldID('sort')
183
-                ),
184
-                AllowedTags::getWithFormTags()
185
-            );
186
-            ?>
176
+			echo wp_kses(
177
+				EEH_Form_Fields::select(
178
+					esc_html__('Sort Events:', 'event_espresso'),
179
+					$instance['sort'],
180
+					$sort_values,
181
+					$this->fieldName('sort'),
182
+					$this->fieldID('sort')
183
+				),
184
+				AllowedTags::getWithFormTags()
185
+			);
186
+			?>
187 187
         </p>
188 188
         <p>
189 189
             <label for="<?php echo esc_attr($this->fieldID('image_size')); ?>">
@@ -197,51 +197,51 @@  discard block
 block discarded – undo
197 197
                 <?php esc_html_e('Show Description:', 'event_espresso'); ?>
198 198
             </label>
199 199
             <?php
200
-            echo wp_kses(
201
-                EEH_Form_Fields::select(
202
-                    esc_html__('Show Description:', 'event_espresso'),
203
-                    $instance['show_desc'],
204
-                    $yes_no_values,
205
-                    $this->fieldName('show_desc'),
206
-                    $this->fieldID('show_desc')
207
-                ),
208
-                AllowedTags::getWithFormTags()
209
-            );
210
-            ?>
200
+			echo wp_kses(
201
+				EEH_Form_Fields::select(
202
+					esc_html__('Show Description:', 'event_espresso'),
203
+					$instance['show_desc'],
204
+					$yes_no_values,
205
+					$this->fieldName('show_desc'),
206
+					$this->fieldID('show_desc')
207
+				),
208
+				AllowedTags::getWithFormTags()
209
+			);
210
+			?>
211 211
         </p>
212 212
         <p>
213 213
             <label for="<?php echo esc_attr($this->fieldID('show_dates')); ?>">
214 214
                 <?php esc_html_e('Show Dates:', 'event_espresso'); ?>
215 215
             </label>
216 216
             <?php
217
-            echo wp_kses(
218
-                EEH_Form_Fields::select(
219
-                    esc_html__('Show Dates:', 'event_espresso'),
220
-                    $instance['show_dates'],
221
-                    $yes_no_values,
222
-                    $this->fieldName('show_dates'),
223
-                    $this->fieldID('show_dates')
224
-                ),
225
-                AllowedTags::getWithFormTags()
226
-            );
227
-            ?>
217
+			echo wp_kses(
218
+				EEH_Form_Fields::select(
219
+					esc_html__('Show Dates:', 'event_espresso'),
220
+					$instance['show_dates'],
221
+					$yes_no_values,
222
+					$this->fieldName('show_dates'),
223
+					$this->fieldID('show_dates')
224
+				),
225
+				AllowedTags::getWithFormTags()
226
+			);
227
+			?>
228 228
         </p>
229 229
         <p>
230 230
             <label for="<?php echo esc_attr($this->fieldID('show_everywhere')); ?>">
231 231
                 <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?>
232 232
             </label>
233 233
             <?php
234
-            echo wp_kses(
235
-                EEH_Form_Fields::select(
236
-                    esc_html__('Show on all Pages:', 'event_espresso'),
237
-                    $instance['show_everywhere'],
238
-                    $yes_no_values,
239
-                    $this->fieldName('show_everywhere'),
240
-                    $this->fieldID('show_everywhere')
241
-                ),
242
-                AllowedTags::getWithFormTags()
243
-            );
244
-            ?>
234
+			echo wp_kses(
235
+				EEH_Form_Fields::select(
236
+					esc_html__('Show on all Pages:', 'event_espresso'),
237
+					$instance['show_everywhere'],
238
+					$yes_no_values,
239
+					$this->fieldName('show_everywhere'),
240
+					$this->fieldID('show_everywhere')
241
+				),
242
+				AllowedTags::getWithFormTags()
243
+			);
244
+			?>
245 245
         </p>
246 246
         <p>
247 247
             <label for="<?php echo esc_attr($this->fieldID('date_limit')); ?>">
@@ -259,287 +259,287 @@  discard block
 block discarded – undo
259 259
                 <?php esc_html_e('Show Date Range:', 'event_espresso'); ?>
260 260
             </label>
261 261
             <?php
262
-            echo wp_kses(
263
-                EEH_Form_Fields::select(
264
-                    esc_html__('Show Date Range:', 'event_espresso'),
265
-                    $instance['date_range'],
266
-                    $yes_no_values,
267
-                    $this->fieldName('date_range'),
268
-                    $this->fieldID('date_range')
269
-                ),
270
-                AllowedTags::getWithFormTags()
271
-            );
272
-            ?>
262
+			echo wp_kses(
263
+				EEH_Form_Fields::select(
264
+					esc_html__('Show Date Range:', 'event_espresso'),
265
+					$instance['date_range'],
266
+					$yes_no_values,
267
+					$this->fieldName('date_range'),
268
+					$this->fieldID('date_range')
269
+				),
270
+				AllowedTags::getWithFormTags()
271
+			);
272
+			?>
273 273
             <span class="description">
274 274
                 <br />
275 275
                 <?php esc_html_e(
276
-                    'This setting will replace the list of dates in the widget.',
277
-                    'event_espresso'
278
-                ); ?>
276
+					'This setting will replace the list of dates in the widget.',
277
+					'event_espresso'
278
+				); ?>
279 279
             </span>
280 280
         </p>
281 281
 
282 282
         <?php
283
-    }
284
-
285
-
286
-    /**
287
-     * Sanitize widget form values as they are saved.
288
-     *
289
-     * @param array $new_instance Values just sent to be saved.
290
-     * @param array $old_instance Previously saved values from database.
291
-     *
292
-     * @return array Updated safe values to be saved.
293
-     * @see WP_Widget::update()
294
-     *
295
-     */
296
-    public function update($new_instance, $old_instance)
297
-    {
298
-        $instance                    = $old_instance;
299
-        $instance['title']           = ! empty($new_instance['title']) ? strip_tags((string) $new_instance['title']) : '';
300
-        $instance['category_name']   = $new_instance['category_name'];
301
-        $instance['show_expired']    = $new_instance['show_expired'];
302
-        $instance['limit']           = $new_instance['limit'];
303
-        $instance['sort']            = $new_instance['sort'];
304
-        $instance['image_size']      = $new_instance['image_size'];
305
-        $instance['show_desc']       = $new_instance['show_desc'];
306
-        $instance['show_dates']      = $new_instance['show_dates'];
307
-        $instance['show_everywhere'] = $new_instance['show_everywhere'];
308
-        $instance['date_limit']      = $new_instance['date_limit'];
309
-        $instance['date_range']      = $new_instance['date_range'];
310
-        return $instance;
311
-    }
312
-
313
-
314
-    /**
315
-     * Front-end display of widget.
316
-     *
317
-     * @param array $args     Widget arguments.
318
-     * @param array $instance Saved values from database.
319
-     * @throws EE_Error
320
-     * @throws ReflectionException
321
-     * @see WP_Widget::widget()
322
-     *
323
-     */
324
-    public function widget($args, $instance)
325
-    {
326
-
327
-        global $post;
328
-        // make sure there is some kinda post object
329
-        if ($post instanceof WP_Post) {
330
-            $before_widget = '';
331
-            $before_title  = '';
332
-            $after_title   = '';
333
-            $after_widget  = '';
334
-            // but NOT an events archives page, cuz that would be like two event lists on the same page
335
-            $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
336
-            if ($show_everywhere || ! ($post->post_type == EspressoPostType::EVENTS && is_archive())) {
337
-                // let's use some of the event helper functions'
338
-                // make separate vars out of attributes
339
-                extract($args);
340
-
341
-                // grab widget settings
342
-                $this->parseWidgetSettings($instance);
343
-                $title = $this->widgetTitle();
344
-
345
-                // Before widget (defined by themes).
346
-                echo wp_kses($before_widget, AllowedTags::getAllowedTags());
347
-                // Display the widget title if one was input (before and after defined by themes).
348
-                if (! empty($title)) {
349
-                    echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags());
350
-                }
351
-                echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags());
352
-                // After widget (defined by themes).
353
-                echo wp_kses($after_widget, AllowedTags::getAllowedTags());
354
-            }
355
-        }
356
-    }
357
-
358
-
359
-    /**
360
-     * make_the_title_a_link
361
-     * callback for widget_title filter
362
-     *
363
-     * @param $title
364
-     * @return string
365
-     */
366
-    public function make_the_title_a_link($title)
367
-    {
368
-        return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
369
-    }
370
-
371
-
372
-    /**
373
-     * @param string $field_name
374
-     * @return string
375
-     * @since   4.10.14.p
376
-     */
377
-    public function fieldID($field_name)
378
-    {
379
-        return parent::get_field_id($field_name);
380
-    }
381
-
382
-
383
-    /**
384
-     * @param string $field_name
385
-     * @return string
386
-     * @since   4.10.14.p
387
-     */
388
-    public function fieldName($field_name)
389
-    {
390
-        return parent::get_field_name($field_name);
391
-    }
392
-
393
-
394
-    /**
395
-     * @param array $instance
396
-     * @throws EE_Error
397
-     * @throws ReflectionException
398
-     * @since   4.10.14.p
399
-     */
400
-    private function eventCategoriesSelector(array $instance)
401
-    {
402
-        $event_categories = [];
403
-        $categories       = EEM_Term::instance()->get_all_ee_categories(true);
404
-        if ($categories) {
405
-            foreach ($categories as $category) {
406
-                if ($category instanceof EE_Term) {
407
-                    $event_categories[] =
408
-                        EE_Question_Option::new_instance(
409
-                            [
410
-                                'QSO_value' => $category->get('slug'),
411
-                                'QSO_desc'  => $category->get('name'),
412
-                            ]
413
-                        );
414
-                }
415
-            }
416
-        }
417
-        array_unshift(
418
-            $event_categories,
419
-            EE_Question_Option::new_instance(
420
-                [
421
-                    'QSO_value' => '',
422
-                    'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
423
-                ]
424
-            )
425
-        );
426
-        echo wp_kses(
427
-            EEH_Form_Fields::select(
428
-                esc_html__('Event Category:', 'event_espresso'),
429
-                $instance['category_name'],
430
-                $event_categories,
431
-                $this->fieldName('category_name'),
432
-                $this->fieldID('category_name')
433
-            ),
434
-            AllowedTags::getWithFormTags()
435
-        );
436
-    }
437
-
438
-
439
-    /**
440
-     * @param array $instance
441
-     * @since   4.10.14.p
442
-     */
443
-    private function imageSizeSelector(array $instance)
444
-    {
445
-        $image_sizes = [];
446
-        $sizes       = get_intermediate_image_sizes();
447
-        if ($sizes) {
448
-            // loop thru images and create option objects out of them
449
-            foreach ($sizes as $image_size) {
450
-                $image_size = trim($image_size);
451
-                // no big images plz
452
-                if (! in_array($image_size, ['large', 'post-thumbnail'])) {
453
-                    $image_sizes[] =
454
-                        EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
455
-                }
456
-            }
457
-            $image_sizes[] =
458
-                EE_Question_Option::new_instance(
459
-                    ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
460
-                );
461
-        }
462
-        echo wp_kses(
463
-            EEH_Form_Fields::select(
464
-                esc_html__('Image Size:', 'event_espresso'),
465
-                $instance['image_size'],
466
-                $image_sizes,
467
-                $this->fieldName('image_size'),
468
-                $this->fieldID('image_size')
469
-            ),
470
-            AllowedTags::getWithFormTags()
471
-        );
472
-    }
473
-
474
-
475
-    /**
476
-     * @param array $instance
477
-     * @since   4.10.14.p
478
-     */
479
-    private function parseWidgetSettings(array $instance)
480
-    {
481
-        $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
482
-        $this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
483
-            ? $instance['category_name']
484
-            : false;
485
-        $this->show_expired = isset($instance['show_expired'])
486
-            ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
487
-            : 0;
488
-        $this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
489
-            ? $instance['image_size']
490
-            : 'medium';
491
-        $this->show_desc    = ! isset($instance['show_desc'])
492
-                              || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
493
-        $this->show_dates   = ! isset($instance['show_dates'])
494
-                              || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
495
-        $this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
496
-            ? $instance['date_limit']
497
-            : null;
498
-        $this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
499
-            ? $instance['date_range']
500
-            : false;
501
-        $this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
502
-        $this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
503
-            ? 'DESC'
504
-            : 'ASC';
505
-    }
506
-
507
-
508
-    /**
509
-     * @return mixed|void
510
-     * @since   4.10.14.p
511
-     */
512
-    private function widgetTitle()
513
-    {
514
-        // add function to make the title a link
515
-        add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
516
-        // filter the title
517
-        $title = apply_filters('widget_title', $this->title);
518
-        // remove the function from the filter, so it does not affect other widgets
519
-        remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
520
-        return $title;
521
-    }
522
-
523
-
524
-    /**
525
-     * @param WP_Post $post
526
-     * @return string
527
-     * @throws EE_Error
528
-     * @throws ReflectionException
529
-     * @since   4.10.14.p
530
-     */
531
-    private function widgetContent(WP_Post $post)
532
-    {
533
-        // run the query
534
-        $events = $this->getUpcomingEvents();
535
-        if (empty($events)) {
536
-            return '';
537
-        }
538
-        $list_items = '';
539
-        foreach ($events as $event) {
540
-            if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
541
-                $event_url = $this->eventUrl($event);
542
-                $list_items .= '
283
+	}
284
+
285
+
286
+	/**
287
+	 * Sanitize widget form values as they are saved.
288
+	 *
289
+	 * @param array $new_instance Values just sent to be saved.
290
+	 * @param array $old_instance Previously saved values from database.
291
+	 *
292
+	 * @return array Updated safe values to be saved.
293
+	 * @see WP_Widget::update()
294
+	 *
295
+	 */
296
+	public function update($new_instance, $old_instance)
297
+	{
298
+		$instance                    = $old_instance;
299
+		$instance['title']           = ! empty($new_instance['title']) ? strip_tags((string) $new_instance['title']) : '';
300
+		$instance['category_name']   = $new_instance['category_name'];
301
+		$instance['show_expired']    = $new_instance['show_expired'];
302
+		$instance['limit']           = $new_instance['limit'];
303
+		$instance['sort']            = $new_instance['sort'];
304
+		$instance['image_size']      = $new_instance['image_size'];
305
+		$instance['show_desc']       = $new_instance['show_desc'];
306
+		$instance['show_dates']      = $new_instance['show_dates'];
307
+		$instance['show_everywhere'] = $new_instance['show_everywhere'];
308
+		$instance['date_limit']      = $new_instance['date_limit'];
309
+		$instance['date_range']      = $new_instance['date_range'];
310
+		return $instance;
311
+	}
312
+
313
+
314
+	/**
315
+	 * Front-end display of widget.
316
+	 *
317
+	 * @param array $args     Widget arguments.
318
+	 * @param array $instance Saved values from database.
319
+	 * @throws EE_Error
320
+	 * @throws ReflectionException
321
+	 * @see WP_Widget::widget()
322
+	 *
323
+	 */
324
+	public function widget($args, $instance)
325
+	{
326
+
327
+		global $post;
328
+		// make sure there is some kinda post object
329
+		if ($post instanceof WP_Post) {
330
+			$before_widget = '';
331
+			$before_title  = '';
332
+			$after_title   = '';
333
+			$after_widget  = '';
334
+			// but NOT an events archives page, cuz that would be like two event lists on the same page
335
+			$show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
336
+			if ($show_everywhere || ! ($post->post_type == EspressoPostType::EVENTS && is_archive())) {
337
+				// let's use some of the event helper functions'
338
+				// make separate vars out of attributes
339
+				extract($args);
340
+
341
+				// grab widget settings
342
+				$this->parseWidgetSettings($instance);
343
+				$title = $this->widgetTitle();
344
+
345
+				// Before widget (defined by themes).
346
+				echo wp_kses($before_widget, AllowedTags::getAllowedTags());
347
+				// Display the widget title if one was input (before and after defined by themes).
348
+				if (! empty($title)) {
349
+					echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags());
350
+				}
351
+				echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags());
352
+				// After widget (defined by themes).
353
+				echo wp_kses($after_widget, AllowedTags::getAllowedTags());
354
+			}
355
+		}
356
+	}
357
+
358
+
359
+	/**
360
+	 * make_the_title_a_link
361
+	 * callback for widget_title filter
362
+	 *
363
+	 * @param $title
364
+	 * @return string
365
+	 */
366
+	public function make_the_title_a_link($title)
367
+	{
368
+		return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
369
+	}
370
+
371
+
372
+	/**
373
+	 * @param string $field_name
374
+	 * @return string
375
+	 * @since   4.10.14.p
376
+	 */
377
+	public function fieldID($field_name)
378
+	{
379
+		return parent::get_field_id($field_name);
380
+	}
381
+
382
+
383
+	/**
384
+	 * @param string $field_name
385
+	 * @return string
386
+	 * @since   4.10.14.p
387
+	 */
388
+	public function fieldName($field_name)
389
+	{
390
+		return parent::get_field_name($field_name);
391
+	}
392
+
393
+
394
+	/**
395
+	 * @param array $instance
396
+	 * @throws EE_Error
397
+	 * @throws ReflectionException
398
+	 * @since   4.10.14.p
399
+	 */
400
+	private function eventCategoriesSelector(array $instance)
401
+	{
402
+		$event_categories = [];
403
+		$categories       = EEM_Term::instance()->get_all_ee_categories(true);
404
+		if ($categories) {
405
+			foreach ($categories as $category) {
406
+				if ($category instanceof EE_Term) {
407
+					$event_categories[] =
408
+						EE_Question_Option::new_instance(
409
+							[
410
+								'QSO_value' => $category->get('slug'),
411
+								'QSO_desc'  => $category->get('name'),
412
+							]
413
+						);
414
+				}
415
+			}
416
+		}
417
+		array_unshift(
418
+			$event_categories,
419
+			EE_Question_Option::new_instance(
420
+				[
421
+					'QSO_value' => '',
422
+					'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
423
+				]
424
+			)
425
+		);
426
+		echo wp_kses(
427
+			EEH_Form_Fields::select(
428
+				esc_html__('Event Category:', 'event_espresso'),
429
+				$instance['category_name'],
430
+				$event_categories,
431
+				$this->fieldName('category_name'),
432
+				$this->fieldID('category_name')
433
+			),
434
+			AllowedTags::getWithFormTags()
435
+		);
436
+	}
437
+
438
+
439
+	/**
440
+	 * @param array $instance
441
+	 * @since   4.10.14.p
442
+	 */
443
+	private function imageSizeSelector(array $instance)
444
+	{
445
+		$image_sizes = [];
446
+		$sizes       = get_intermediate_image_sizes();
447
+		if ($sizes) {
448
+			// loop thru images and create option objects out of them
449
+			foreach ($sizes as $image_size) {
450
+				$image_size = trim($image_size);
451
+				// no big images plz
452
+				if (! in_array($image_size, ['large', 'post-thumbnail'])) {
453
+					$image_sizes[] =
454
+						EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
455
+				}
456
+			}
457
+			$image_sizes[] =
458
+				EE_Question_Option::new_instance(
459
+					['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
460
+				);
461
+		}
462
+		echo wp_kses(
463
+			EEH_Form_Fields::select(
464
+				esc_html__('Image Size:', 'event_espresso'),
465
+				$instance['image_size'],
466
+				$image_sizes,
467
+				$this->fieldName('image_size'),
468
+				$this->fieldID('image_size')
469
+			),
470
+			AllowedTags::getWithFormTags()
471
+		);
472
+	}
473
+
474
+
475
+	/**
476
+	 * @param array $instance
477
+	 * @since   4.10.14.p
478
+	 */
479
+	private function parseWidgetSettings(array $instance)
480
+	{
481
+		$this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
482
+		$this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
483
+			? $instance['category_name']
484
+			: false;
485
+		$this->show_expired = isset($instance['show_expired'])
486
+			? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
487
+			: 0;
488
+		$this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
489
+			? $instance['image_size']
490
+			: 'medium';
491
+		$this->show_desc    = ! isset($instance['show_desc'])
492
+							  || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
493
+		$this->show_dates   = ! isset($instance['show_dates'])
494
+							  || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
495
+		$this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
496
+			? $instance['date_limit']
497
+			: null;
498
+		$this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
499
+			? $instance['date_range']
500
+			: false;
501
+		$this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
502
+		$this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
503
+			? 'DESC'
504
+			: 'ASC';
505
+	}
506
+
507
+
508
+	/**
509
+	 * @return mixed|void
510
+	 * @since   4.10.14.p
511
+	 */
512
+	private function widgetTitle()
513
+	{
514
+		// add function to make the title a link
515
+		add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
516
+		// filter the title
517
+		$title = apply_filters('widget_title', $this->title);
518
+		// remove the function from the filter, so it does not affect other widgets
519
+		remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
520
+		return $title;
521
+	}
522
+
523
+
524
+	/**
525
+	 * @param WP_Post $post
526
+	 * @return string
527
+	 * @throws EE_Error
528
+	 * @throws ReflectionException
529
+	 * @since   4.10.14.p
530
+	 */
531
+	private function widgetContent(WP_Post $post)
532
+	{
533
+		// run the query
534
+		$events = $this->getUpcomingEvents();
535
+		if (empty($events)) {
536
+			return '';
537
+		}
538
+		$list_items = '';
539
+		foreach ($events as $event) {
540
+			if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
541
+				$event_url = $this->eventUrl($event);
542
+				$list_items .= '
543 543
                 <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '"
544 544
                     class="ee-upcoming-events-widget-li"
545 545
                 >
@@ -550,194 +550,194 @@  discard block
 block discarded – undo
550 550
                     </h5>
551 551
                     ' . $this->eventWidgetContent($event, $event_url) . '
552 552
                 </li>';
553
-            }
554
-        }
555
-        return '
553
+			}
554
+		}
555
+		return '
556 556
             <ul class="ee-upcoming-events-widget-ul">
557 557
                 ' . $list_items . '
558 558
             </ul>';
559
-    }
560
-
561
-
562
-    /**
563
-     * @param EE_Event $event
564
-     * @return string|null
565
-     * @throws EE_Error
566
-     * @since   4.10.14.p
567
-     */
568
-    private function eventUrl(EE_Event $event)
569
-    {
570
-        return esc_url_raw(
571
-            apply_filters(
572
-                'FHEE_EEW_Upcoming_Events__widget__event_url',
573
-                $event->get_permalink(),
574
-                $event
575
-            )
576
-        );
577
-    }
578
-
579
-
580
-    /**
581
-     * @return EE_Base_Class[]
582
-     * @throws EE_Error
583
-     */
584
-    private function getUpcomingEvents()
585
-    {
586
-        return EEM_Event::instance()->get_all(
587
-            [
588
-                $this->queryWhereParams(),
589
-                'limit'    => '0,' . $this->limit,
590
-                'order_by' => 'Datetime.DTT_EVT_start',
591
-                'order'    => $this->order,
592
-                'group_by' => 'EVT_ID',
593
-            ]
594
-        );
595
-    }
596
-
597
-
598
-    /**
599
-     * @return mixed|void
600
-     * @throws EE_Error
601
-     * @since   4.10.14.p
602
-     */
603
-    private function queryWhereParams()
604
-    {
605
-        // start to build our where clause
606
-        $where = [
607
-            'status' => ['IN', ['publish', 'sold_out']],
608
-        ];
609
-        // add category
610
-        if ($this->events_category) {
611
-            $where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
612
-            $where['Term_Taxonomy.Term.slug'] = $this->events_category;
613
-        }
614
-        // if NOT expired then we want events that start today or in the future
615
-        // if NOT show expired then we want events that start today or in the future
616
-        if ($this->show_expired == 0) {
617
-            $where['Datetime.DTT_EVT_end'] = [
618
-                '>=',
619
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
620
-            ];
621
-        }
622
-        // if show ONLY expired we want events that ended prior to today
623
-        if ($this->show_expired == 2) {
624
-            $where['Datetime.DTT_EVT_end'] = [
625
-                '<=',
626
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
627
-            ];
628
-        }
629
-        // allow $where to be filtered
630
-        return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
631
-    }
632
-
633
-
634
-    /**
635
-     * @param EE_Event $event
636
-     * @return string
637
-     * @throws EE_Error
638
-     * @throws ReflectionException
639
-     * @since   4.10.14.p
640
-     */
641
-    private function linkClass(EE_Event $event)
642
-    {
643
-        // how big is the event name ?
644
-        $name_length = strlen($event->name());
645
-        switch ($name_length) {
646
-            case $name_length > 70:
647
-                return ' three-line';
648
-            case $name_length > 35:
649
-                return ' two-line';
650
-        }
651
-        return ' one-line';
652
-    }
653
-
654
-
655
-    /**
656
-     * @param EE_Event $event
657
-     * @param string   $event_url
658
-     * @return mixed|string|void
659
-     * @throws EE_Error
660
-     * @throws ReflectionException
661
-     * @since   4.10.14.p
662
-     */
663
-    private function eventWidgetContent(EE_Event $event, $event_url = '')
664
-    {
665
-        if (post_password_required($event->ID())) {
666
-            return apply_filters(
667
-                'FHEE_EEW_Upcoming_Events__widget__password_form',
668
-                get_the_password_form($event->ID()),
669
-                $event
670
-            );
671
-        }
672
-
673
-        $content = '';
674
-        if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
675
-            $content .= '
559
+	}
560
+
561
+
562
+	/**
563
+	 * @param EE_Event $event
564
+	 * @return string|null
565
+	 * @throws EE_Error
566
+	 * @since   4.10.14.p
567
+	 */
568
+	private function eventUrl(EE_Event $event)
569
+	{
570
+		return esc_url_raw(
571
+			apply_filters(
572
+				'FHEE_EEW_Upcoming_Events__widget__event_url',
573
+				$event->get_permalink(),
574
+				$event
575
+			)
576
+		);
577
+	}
578
+
579
+
580
+	/**
581
+	 * @return EE_Base_Class[]
582
+	 * @throws EE_Error
583
+	 */
584
+	private function getUpcomingEvents()
585
+	{
586
+		return EEM_Event::instance()->get_all(
587
+			[
588
+				$this->queryWhereParams(),
589
+				'limit'    => '0,' . $this->limit,
590
+				'order_by' => 'Datetime.DTT_EVT_start',
591
+				'order'    => $this->order,
592
+				'group_by' => 'EVT_ID',
593
+			]
594
+		);
595
+	}
596
+
597
+
598
+	/**
599
+	 * @return mixed|void
600
+	 * @throws EE_Error
601
+	 * @since   4.10.14.p
602
+	 */
603
+	private function queryWhereParams()
604
+	{
605
+		// start to build our where clause
606
+		$where = [
607
+			'status' => ['IN', ['publish', 'sold_out']],
608
+		];
609
+		// add category
610
+		if ($this->events_category) {
611
+			$where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
612
+			$where['Term_Taxonomy.Term.slug'] = $this->events_category;
613
+		}
614
+		// if NOT expired then we want events that start today or in the future
615
+		// if NOT show expired then we want events that start today or in the future
616
+		if ($this->show_expired == 0) {
617
+			$where['Datetime.DTT_EVT_end'] = [
618
+				'>=',
619
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
620
+			];
621
+		}
622
+		// if show ONLY expired we want events that ended prior to today
623
+		if ($this->show_expired == 2) {
624
+			$where['Datetime.DTT_EVT_end'] = [
625
+				'<=',
626
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
627
+			];
628
+		}
629
+		// allow $where to be filtered
630
+		return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
631
+	}
632
+
633
+
634
+	/**
635
+	 * @param EE_Event $event
636
+	 * @return string
637
+	 * @throws EE_Error
638
+	 * @throws ReflectionException
639
+	 * @since   4.10.14.p
640
+	 */
641
+	private function linkClass(EE_Event $event)
642
+	{
643
+		// how big is the event name ?
644
+		$name_length = strlen($event->name());
645
+		switch ($name_length) {
646
+			case $name_length > 70:
647
+				return ' three-line';
648
+			case $name_length > 35:
649
+				return ' two-line';
650
+		}
651
+		return ' one-line';
652
+	}
653
+
654
+
655
+	/**
656
+	 * @param EE_Event $event
657
+	 * @param string   $event_url
658
+	 * @return mixed|string|void
659
+	 * @throws EE_Error
660
+	 * @throws ReflectionException
661
+	 * @since   4.10.14.p
662
+	 */
663
+	private function eventWidgetContent(EE_Event $event, $event_url = '')
664
+	{
665
+		if (post_password_required($event->ID())) {
666
+			return apply_filters(
667
+				'FHEE_EEW_Upcoming_Events__widget__password_form',
668
+				get_the_password_form($event->ID()),
669
+				$event
670
+			);
671
+		}
672
+
673
+		$content = '';
674
+		if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
675
+			$content .= '
676 676
                 <div class="ee-upcoming-events-widget-img-dv">
677 677
                     <a class="ee-upcoming-events-widget-img" href="' . $event_url . '">
678 678
                         ' . get_the_post_thumbnail($event->ID(), $this->image_size) . '
679 679
                     </a>
680 680
                 </div>';
681
-        }
682
-
683
-        if ($this->show_dates) {
684
-            $content .= $this->eventDates($event);
685
-        }
686
-
687
-        if ($this->show_desc) {
688
-            $allowedtags = AllowedTags::getAllowedTags();
689
-            $desc    = $event->short_description(25);
690
-            $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
691
-        }
692
-
693
-        return $content;
694
-    }
695
-
696
-
697
-    /**
698
-     * @param EE_Event $event
699
-     * @return string
700
-     * @throws EE_Error
701
-     * @throws ReflectionException
702
-     * @since   4.10.14.p
703
-     */
704
-    private function eventDates(EE_Event $event)
705
-    {
706
-        $date_format        = apply_filters(
707
-            'FHEE__espresso_event_date_range__date_format',
708
-            get_option('date_format')
709
-        );
710
-        $time_format        = apply_filters(
711
-            'FHEE__espresso_event_date_range__time_format',
712
-            get_option('time_format')
713
-        );
714
-        $single_date_format = apply_filters(
715
-            'FHEE__espresso_event_date_range__single_date_format',
716
-            get_option('date_format')
717
-        );
718
-        $single_time_format = apply_filters(
719
-            'FHEE__espresso_event_date_range__single_time_format',
720
-            get_option('time_format')
721
-        );
722
-        if ($this->date_range == true) {
723
-            return espresso_event_date_range(
724
-                $date_format,
725
-                $time_format,
726
-                $single_date_format,
727
-                $single_time_format,
728
-                $event->ID(),
729
-                false
730
-            );
731
-        }
732
-        return espresso_list_of_event_dates(
733
-            $event->ID(),
734
-            $date_format,
735
-            $time_format,
736
-            false,
737
-            null,
738
-            true,
739
-            true,
740
-            $this->date_limit
741
-        );
742
-    }
681
+		}
682
+
683
+		if ($this->show_dates) {
684
+			$content .= $this->eventDates($event);
685
+		}
686
+
687
+		if ($this->show_desc) {
688
+			$allowedtags = AllowedTags::getAllowedTags();
689
+			$desc    = $event->short_description(25);
690
+			$content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
691
+		}
692
+
693
+		return $content;
694
+	}
695
+
696
+
697
+	/**
698
+	 * @param EE_Event $event
699
+	 * @return string
700
+	 * @throws EE_Error
701
+	 * @throws ReflectionException
702
+	 * @since   4.10.14.p
703
+	 */
704
+	private function eventDates(EE_Event $event)
705
+	{
706
+		$date_format        = apply_filters(
707
+			'FHEE__espresso_event_date_range__date_format',
708
+			get_option('date_format')
709
+		);
710
+		$time_format        = apply_filters(
711
+			'FHEE__espresso_event_date_range__time_format',
712
+			get_option('time_format')
713
+		);
714
+		$single_date_format = apply_filters(
715
+			'FHEE__espresso_event_date_range__single_date_format',
716
+			get_option('date_format')
717
+		);
718
+		$single_time_format = apply_filters(
719
+			'FHEE__espresso_event_date_range__single_time_format',
720
+			get_option('time_format')
721
+		);
722
+		if ($this->date_range == true) {
723
+			return espresso_event_date_range(
724
+				$date_format,
725
+				$time_format,
726
+				$single_date_format,
727
+				$single_time_format,
728
+				$event->ID(),
729
+				false
730
+			);
731
+		}
732
+		return espresso_list_of_event_dates(
733
+			$event->ID(),
734
+			$date_format,
735
+			$time_format,
736
+			false,
737
+			null,
738
+			true,
739
+			true,
740
+			$this->date_limit
741
+		);
742
+	}
743 743
 }
Please login to merge, or discard this patch.
public/template_tags.php 2 patches
Indentation   +1085 added lines, -1085 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function is_espresso_event($event = null): bool
24 24
 {
25
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
26
-        return false;
27
-    }
28
-    // extract EE_Event object from passed param regardless of what it is (within reason of course)
29
-    $event = EEH_Event_View::get_event($event);
30
-    // do we have a valid event ?
31
-    return $event instanceof EE_Event;
25
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
26
+		return false;
27
+	}
28
+	// extract EE_Event object from passed param regardless of what it is (within reason of course)
29
+	$event = EEH_Event_View::get_event($event);
30
+	// do we have a valid event ?
31
+	return $event instanceof EE_Event;
32 32
 }
33 33
 
34 34
 /**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function is_espresso_event_single(): bool
41 41
 {
42
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
43
-        return false;
44
-    }
45
-    global $wp_query;
46
-    // return conditionals set by CPTs
47
-    return $wp_query instanceof WP_Query
48
-        && isset($wp_query->is_espresso_event_single)
49
-        && $wp_query->is_espresso_event_single;
42
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
43
+		return false;
44
+	}
45
+	global $wp_query;
46
+	// return conditionals set by CPTs
47
+	return $wp_query instanceof WP_Query
48
+		&& isset($wp_query->is_espresso_event_single)
49
+		&& $wp_query->is_espresso_event_single;
50 50
 }
51 51
 
52 52
 /**
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function is_espresso_event_archive(): bool
59 59
 {
60
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
61
-        return false;
62
-    }
63
-    global $wp_query;
64
-    return $wp_query instanceof WP_Query
65
-        && isset($wp_query->is_espresso_event_archive)
66
-        && $wp_query->is_espresso_event_archive;
60
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
61
+		return false;
62
+	}
63
+	global $wp_query;
64
+	return $wp_query instanceof WP_Query
65
+		&& isset($wp_query->is_espresso_event_archive)
66
+		&& $wp_query->is_espresso_event_archive;
67 67
 }
68 68
 
69 69
 /**
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
  */
75 75
 function is_espresso_event_taxonomy(): bool
76 76
 {
77
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
78
-        return false;
79
-    }
80
-    global $wp_query;
81
-    return $wp_query instanceof WP_Query
82
-        && isset($wp_query->is_espresso_event_taxonomy)
83
-        && $wp_query->is_espresso_event_taxonomy;
77
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
78
+		return false;
79
+	}
80
+	global $wp_query;
81
+	return $wp_query instanceof WP_Query
82
+		&& isset($wp_query->is_espresso_event_taxonomy)
83
+		&& $wp_query->is_espresso_event_taxonomy;
84 84
 }
85 85
 
86 86
 /**
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function is_espresso_venue($venue = null): bool
96 96
 {
97
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
98
-        return false;
99
-    }
100
-    // extract EE_Venue object from passed param regardless of what it is (within reason of course)
101
-    $venue = EEH_Venue_View::get_venue($venue, false);
102
-    // do we have a valid event ?
103
-    return $venue instanceof EE_Venue;
97
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
98
+		return false;
99
+	}
100
+	// extract EE_Venue object from passed param regardless of what it is (within reason of course)
101
+	$venue = EEH_Venue_View::get_venue($venue, false);
102
+	// do we have a valid event ?
103
+	return $venue instanceof EE_Venue;
104 104
 }
105 105
 
106 106
 /**
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function is_espresso_venue_single(): bool
113 113
 {
114
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
115
-        return false;
116
-    }
117
-    global $wp_query;
118
-    return $wp_query instanceof WP_Query
119
-        && isset($wp_query->is_espresso_venue_single)
120
-        && $wp_query->is_espresso_venue_single;
114
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
115
+		return false;
116
+	}
117
+	global $wp_query;
118
+	return $wp_query instanceof WP_Query
119
+		&& isset($wp_query->is_espresso_venue_single)
120
+		&& $wp_query->is_espresso_venue_single;
121 121
 }
122 122
 
123 123
 /**
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
  */
129 129
 function is_espresso_venue_archive(): bool
130 130
 {
131
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
132
-        return false;
133
-    }
134
-    global $wp_query;
135
-    return $wp_query instanceof WP_Query
136
-        && isset($wp_query->is_espresso_venue_archive)
137
-        && $wp_query->is_espresso_venue_archive;
131
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
132
+		return false;
133
+	}
134
+	global $wp_query;
135
+	return $wp_query instanceof WP_Query
136
+		&& isset($wp_query->is_espresso_venue_archive)
137
+		&& $wp_query->is_espresso_venue_archive;
138 138
 }
139 139
 
140 140
 /**
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function is_espresso_venue_taxonomy(): bool
147 147
 {
148
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
149
-        return false;
150
-    }
151
-    global $wp_query;
152
-    return $wp_query instanceof WP_Query
153
-        && isset($wp_query->is_espresso_venue_taxonomy)
154
-        && $wp_query->is_espresso_venue_taxonomy;
148
+	if (! can_use_espresso_conditionals(__FUNCTION__)) {
149
+		return false;
150
+	}
151
+	global $wp_query;
152
+	return $wp_query instanceof WP_Query
153
+		&& isset($wp_query->is_espresso_venue_taxonomy)
154
+		&& $wp_query->is_espresso_venue_taxonomy;
155 155
 }
156 156
 
157 157
 /**
@@ -163,62 +163,62 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function can_use_espresso_conditionals($conditional_tag): bool
165 165
 {
166
-    if (! did_action('AHEE__EE_System__initialize')) {
167
-        EE_Error::doing_it_wrong(
168
-            __FUNCTION__,
169
-            sprintf(
170
-                esc_html__(
171
-                    'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.',
172
-                    'event_espresso'
173
-                ),
174
-                $conditional_tag
175
-            ),
176
-            '4.4.0'
177
-        );
178
-        return false;
179
-    }
180
-    return true;
166
+	if (! did_action('AHEE__EE_System__initialize')) {
167
+		EE_Error::doing_it_wrong(
168
+			__FUNCTION__,
169
+			sprintf(
170
+				esc_html__(
171
+					'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.',
172
+					'event_espresso'
173
+				),
174
+				$conditional_tag
175
+			),
176
+			'4.4.0'
177
+		);
178
+		return false;
179
+	}
180
+	return true;
181 181
 }
182 182
 
183 183
 
184 184
 /*************************** Event Queries ***************************/
185 185
 
186 186
 if (! function_exists('espresso_get_events')) {
187
-    /**
188
-     *    espresso_get_events
189
-     *
190
-     * @param array $params
191
-     * @return array
192
-     */
193
-    function espresso_get_events($params = [])
194
-    {
195
-        //set default params
196
-        $default_espresso_events_params = [
197
-            'limit'         => 10,
198
-            'show_expired'  => false,
199
-            'month'         => null,
200
-            'category_slug' => null,
201
-            'order_by'      => 'start_date',
202
-            'sort'          => 'ASC',
203
-        ];
204
-        // allow the defaults to be filtered
205
-        $default_espresso_events_params = apply_filters(
206
-            'espresso_get_events__default_espresso_events_params',
207
-            $default_espresso_events_params
208
-        );
209
-        // grab params and merge with defaults, then extract
210
-        $params = array_merge($default_espresso_events_params, $params);
211
-        // run the query
212
-        $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
213
-        // assign results to a variable so we can return it
214
-        $events = $events_query->have_posts() ? $events_query->posts : [];
215
-        // but first reset the query and postdata
216
-        wp_reset_query();
217
-        wp_reset_postdata();
218
-        EED_Events_Archive::remove_all_events_archive_filters();
219
-        unset($events_query);
220
-        return $events;
221
-    }
187
+	/**
188
+	 *    espresso_get_events
189
+	 *
190
+	 * @param array $params
191
+	 * @return array
192
+	 */
193
+	function espresso_get_events($params = [])
194
+	{
195
+		//set default params
196
+		$default_espresso_events_params = [
197
+			'limit'         => 10,
198
+			'show_expired'  => false,
199
+			'month'         => null,
200
+			'category_slug' => null,
201
+			'order_by'      => 'start_date',
202
+			'sort'          => 'ASC',
203
+		];
204
+		// allow the defaults to be filtered
205
+		$default_espresso_events_params = apply_filters(
206
+			'espresso_get_events__default_espresso_events_params',
207
+			$default_espresso_events_params
208
+		);
209
+		// grab params and merge with defaults, then extract
210
+		$params = array_merge($default_espresso_events_params, $params);
211
+		// run the query
212
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
213
+		// assign results to a variable so we can return it
214
+		$events = $events_query->have_posts() ? $events_query->posts : [];
215
+		// but first reset the query and postdata
216
+		wp_reset_query();
217
+		wp_reset_postdata();
218
+		EED_Events_Archive::remove_all_events_archive_filters();
219
+		unset($events_query);
220
+		return $events;
221
+	}
222 222
 }
223 223
 
224 224
 
@@ -233,115 +233,115 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function espresso_load_ticket_selector()
235 235
 {
236
-    EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module');
236
+	EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module');
237 237
 }
238 238
 
239 239
 if (! function_exists('espresso_ticket_selector')) {
240
-    /**
241
-     * espresso_ticket_selector
242
-     *
243
-     * @param null $event
244
-     * @throws EE_Error
245
-     * @throws ReflectionException
246
-     */
247
-    function espresso_ticket_selector($event = null)
248
-    {
249
-        if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) {
250
-            espresso_load_ticket_selector();
251
-            EED_Ticket_Selector::set_definitions();
252
-            echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped
253
-        }
254
-    }
240
+	/**
241
+	 * espresso_ticket_selector
242
+	 *
243
+	 * @param null $event
244
+	 * @throws EE_Error
245
+	 * @throws ReflectionException
246
+	 */
247
+	function espresso_ticket_selector($event = null)
248
+	{
249
+		if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) {
250
+			espresso_load_ticket_selector();
251
+			EED_Ticket_Selector::set_definitions();
252
+			echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped
253
+		}
254
+	}
255 255
 }
256 256
 
257 257
 
258 258
 if (! function_exists('espresso_view_details_btn')) {
259
-    /**
260
-     * espresso_view_details_btn
261
-     *
262
-     * @param null $event
263
-     * @throws EE_Error
264
-     * @throws ReflectionException
265
-     */
266
-    function espresso_view_details_btn($event = null)
267
-    {
268
-        if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) {
269
-            espresso_load_ticket_selector();
270
-            echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped
271
-        }
272
-    }
259
+	/**
260
+	 * espresso_view_details_btn
261
+	 *
262
+	 * @param null $event
263
+	 * @throws EE_Error
264
+	 * @throws ReflectionException
265
+	 */
266
+	function espresso_view_details_btn($event = null)
267
+	{
268
+		if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) {
269
+			espresso_load_ticket_selector();
270
+			echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped
271
+		}
272
+	}
273 273
 }
274 274
 
275 275
 
276 276
 /*************************** EEH_Event_View ***************************/
277 277
 
278 278
 if (! function_exists('espresso_load_event_list_assets')) {
279
-    /**
280
-     * espresso_load_event_list_assets
281
-     * ensures that event list styles and scripts are loaded
282
-     *
283
-     * @return void
284
-     */
285
-    function espresso_load_event_list_assets()
286
-    {
287
-        $event_list = EED_Events_Archive::instance();
288
-        add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10);
289
-        add_filter('FHEE_enable_default_espresso_css', '__return_true');
290
-    }
279
+	/**
280
+	 * espresso_load_event_list_assets
281
+	 * ensures that event list styles and scripts are loaded
282
+	 *
283
+	 * @return void
284
+	 */
285
+	function espresso_load_event_list_assets()
286
+	{
287
+		$event_list = EED_Events_Archive::instance();
288
+		add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10);
289
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
290
+	}
291 291
 }
292 292
 
293 293
 
294 294
 if (! function_exists('espresso_event_reg_button')) {
295
-    /**
296
-     * espresso_event_reg_button
297
-     * returns the "Register Now" button if event is active,
298
-     * an inactive button like status banner if the event is not active
299
-     * or a "Read More" button if so desired
300
-     *
301
-     * @param null $btn_text_if_active
302
-     * @param bool $btn_text_if_inactive
303
-     * @param bool $EVT_ID
304
-     * @return void
305
-     * @throws EE_Error
306
-     * @throws ReflectionException
307
-     */
308
-    function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false)
309
-    {
310
-        $event = EEH_Event_View::get_event($EVT_ID);
311
-        if (! $event instanceof EE_Event) {
312
-            return;
313
-        }
314
-        $event_status = $event->get_active_status();
315
-        switch ($event_status) {
316
-            case EE_Datetime::sold_out :
317
-                $btn_text = __('Sold Out', 'event_espresso');
318
-                $class    = 'ee-pink';
319
-                break;
320
-            case EE_Datetime::expired :
321
-                $btn_text = __('Event is Over', 'event_espresso');
322
-                $class    = 'ee-grey';
323
-                break;
324
-            case EE_Datetime::inactive :
325
-                $btn_text = __('Event Not Active', 'event_espresso');
326
-                $class    = 'ee-grey';
327
-                break;
328
-            case EE_Datetime::cancelled :
329
-                $btn_text = __('Event was Cancelled', 'event_espresso');
330
-                $class    = 'ee-red';
331
-                break;
332
-            case EE_Datetime::upcoming :
333
-            case EE_Datetime::active :
334
-            default :
335
-                $btn_text = ! empty($btn_text_if_active)
336
-                    ? $btn_text_if_active
337
-                    : __('Register Now', 'event_espresso');
338
-                $class    = 'ee-green';
339
-        }
340
-        if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
341
-            $btn_text = $btn_text_if_inactive;
342
-            $class    = 'ee-grey';
343
-        }
344
-        ?>
295
+	/**
296
+	 * espresso_event_reg_button
297
+	 * returns the "Register Now" button if event is active,
298
+	 * an inactive button like status banner if the event is not active
299
+	 * or a "Read More" button if so desired
300
+	 *
301
+	 * @param null $btn_text_if_active
302
+	 * @param bool $btn_text_if_inactive
303
+	 * @param bool $EVT_ID
304
+	 * @return void
305
+	 * @throws EE_Error
306
+	 * @throws ReflectionException
307
+	 */
308
+	function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false)
309
+	{
310
+		$event = EEH_Event_View::get_event($EVT_ID);
311
+		if (! $event instanceof EE_Event) {
312
+			return;
313
+		}
314
+		$event_status = $event->get_active_status();
315
+		switch ($event_status) {
316
+			case EE_Datetime::sold_out :
317
+				$btn_text = __('Sold Out', 'event_espresso');
318
+				$class    = 'ee-pink';
319
+				break;
320
+			case EE_Datetime::expired :
321
+				$btn_text = __('Event is Over', 'event_espresso');
322
+				$class    = 'ee-grey';
323
+				break;
324
+			case EE_Datetime::inactive :
325
+				$btn_text = __('Event Not Active', 'event_espresso');
326
+				$class    = 'ee-grey';
327
+				break;
328
+			case EE_Datetime::cancelled :
329
+				$btn_text = __('Event was Cancelled', 'event_espresso');
330
+				$class    = 'ee-red';
331
+				break;
332
+			case EE_Datetime::upcoming :
333
+			case EE_Datetime::active :
334
+			default :
335
+				$btn_text = ! empty($btn_text_if_active)
336
+					? $btn_text_if_active
337
+					: __('Register Now', 'event_espresso');
338
+				$class    = 'ee-green';
339
+		}
340
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
341
+			$btn_text = $btn_text_if_inactive;
342
+			$class    = 'ee-grey';
343
+		}
344
+		?>
345 345
         <a class="ee-button ee-register-button <?php echo esc_attr($class); ?>"
346 346
             href="<?php espresso_event_link_url($EVT_ID); ?>"
347 347
             <?php echo AttributesSanitizer::clean(EED_Events_Archive::link_target(), AllowedTags::getAllowedTags(), 'a'); ?>
@@ -349,244 +349,244 @@  discard block
 block discarded – undo
349 349
             <?php echo esc_html($btn_text); ?>
350 350
         </a>
351 351
         <?php
352
-    }
352
+	}
353 353
 }
354 354
 
355 355
 
356 356
 if (! function_exists('espresso_display_ticket_selector')) {
357
-    /**
358
-     * espresso_display_ticket_selector
359
-     * whether or not to display the Ticket Selector for an event
360
-     *
361
-     * @param bool $EVT_ID
362
-     * @return boolean
363
-     * @throws EE_Error
364
-     * @throws ReflectionException
365
-     */
366
-    function espresso_display_ticket_selector($EVT_ID = false)
367
-    {
368
-        return EEH_Event_View::display_ticket_selector($EVT_ID);
369
-    }
357
+	/**
358
+	 * espresso_display_ticket_selector
359
+	 * whether or not to display the Ticket Selector for an event
360
+	 *
361
+	 * @param bool $EVT_ID
362
+	 * @return boolean
363
+	 * @throws EE_Error
364
+	 * @throws ReflectionException
365
+	 */
366
+	function espresso_display_ticket_selector($EVT_ID = false)
367
+	{
368
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
369
+	}
370 370
 }
371 371
 
372 372
 
373 373
 if (! function_exists('espresso_event_status_banner')) {
374
-    /**
375
-     * espresso_event_status
376
-     * returns a banner showing the event status if it is sold out, expired, or inactive
377
-     *
378
-     * @param bool $EVT_ID
379
-     * @return string
380
-     * @throws EE_Error
381
-     * @throws ReflectionException
382
-     */
383
-    function espresso_event_status_banner($EVT_ID = false)
384
-    {
385
-        return EEH_Event_View::event_status($EVT_ID);
386
-    }
374
+	/**
375
+	 * espresso_event_status
376
+	 * returns a banner showing the event status if it is sold out, expired, or inactive
377
+	 *
378
+	 * @param bool $EVT_ID
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 * @throws ReflectionException
382
+	 */
383
+	function espresso_event_status_banner($EVT_ID = false)
384
+	{
385
+		return EEH_Event_View::event_status($EVT_ID);
386
+	}
387 387
 }
388 388
 
389 389
 
390 390
 if (! function_exists('espresso_event_status')) {
391
-    /**
392
-     * espresso_event_status
393
-     * returns the event status if it is sold out, expired, or inactive
394
-     *
395
-     * @param int  $EVT_ID
396
-     * @param bool $echo
397
-     * @return string
398
-     * @throws EE_Error
399
-     * @throws ReflectionException
400
-     */
401
-    function espresso_event_status($EVT_ID = 0, $echo = true)
402
-    {
403
-        return EEH_Event_View::event_active_status($EVT_ID, $echo);
404
-    }
391
+	/**
392
+	 * espresso_event_status
393
+	 * returns the event status if it is sold out, expired, or inactive
394
+	 *
395
+	 * @param int  $EVT_ID
396
+	 * @param bool $echo
397
+	 * @return string
398
+	 * @throws EE_Error
399
+	 * @throws ReflectionException
400
+	 */
401
+	function espresso_event_status($EVT_ID = 0, $echo = true)
402
+	{
403
+		return EEH_Event_View::event_active_status($EVT_ID, $echo);
404
+	}
405 405
 }
406 406
 
407 407
 
408 408
 if (! function_exists('espresso_event_categories')) {
409
-    /**
410
-     * espresso_event_categories
411
-     * returns the terms associated with an event
412
-     *
413
-     * @param int  $EVT_ID
414
-     * @param bool $hide_uncategorized
415
-     * @param bool $echo
416
-     * @return string
417
-     * @throws EE_Error
418
-     * @throws ReflectionException
419
-     */
420
-    function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true)
421
-    {
422
-        if ($echo) {
423
-            echo wp_kses(EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized), AllowedTags::getWithFormTags());
424
-            return '';
425
-        }
426
-        return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
427
-    }
409
+	/**
410
+	 * espresso_event_categories
411
+	 * returns the terms associated with an event
412
+	 *
413
+	 * @param int  $EVT_ID
414
+	 * @param bool $hide_uncategorized
415
+	 * @param bool $echo
416
+	 * @return string
417
+	 * @throws EE_Error
418
+	 * @throws ReflectionException
419
+	 */
420
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true)
421
+	{
422
+		if ($echo) {
423
+			echo wp_kses(EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized), AllowedTags::getWithFormTags());
424
+			return '';
425
+		}
426
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
427
+	}
428 428
 }
429 429
 
430 430
 
431 431
 if (! function_exists('espresso_event_tickets_available')) {
432
-    /**
433
-     * espresso_event_tickets_available
434
-     * returns the ticket types available for purchase for an event
435
-     *
436
-     * @param int  $EVT_ID
437
-     * @param bool $echo
438
-     * @param bool $format
439
-     * @return string
440
-     * @throws EE_Error
441
-     * @throws ReflectionException
442
-     */
443
-    function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true)
444
-    {
445
-        $tickets = EEH_Event_View::event_tickets_available($EVT_ID);
446
-        if (is_array($tickets) && ! empty($tickets)) {
447
-            // if formatting then $html will be a string, else it will be an array of ticket objects
448
-            $html =
449
-                $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : [];
450
-            foreach ($tickets as $ticket) {
451
-                if ($ticket instanceof EE_Ticket) {
452
-                    if ($format) {
453
-                        $html .= '<li id="ee-event-tickets-li-'
454
-                                 . esc_attr($ticket->ID())
455
-                                 . '" class="ee-event-tickets-li">';
456
-                        $html .= esc_html($ticket->name()) . ' ';
457
-                        $html .= EEH_Template::format_currency(
458
-                            $ticket->get_ticket_total_with_taxes()
459
-                        ); // already escaped
460
-                        $html .= '</li>';
461
-                    } else {
462
-                        $html[] = $ticket;
463
-                    }
464
-                }
465
-            }
466
-            if ($format) {
467
-                $html .= '</ul>';
468
-            }
469
-            if ($echo && $format) {
470
-                echo wp_kses($html, AllowedTags::getAllowedTags());
471
-                return '';
472
-            }
473
-            return $html;
474
-        }
475
-        return '';
476
-    }
432
+	/**
433
+	 * espresso_event_tickets_available
434
+	 * returns the ticket types available for purchase for an event
435
+	 *
436
+	 * @param int  $EVT_ID
437
+	 * @param bool $echo
438
+	 * @param bool $format
439
+	 * @return string
440
+	 * @throws EE_Error
441
+	 * @throws ReflectionException
442
+	 */
443
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true)
444
+	{
445
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
446
+		if (is_array($tickets) && ! empty($tickets)) {
447
+			// if formatting then $html will be a string, else it will be an array of ticket objects
448
+			$html =
449
+				$format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : [];
450
+			foreach ($tickets as $ticket) {
451
+				if ($ticket instanceof EE_Ticket) {
452
+					if ($format) {
453
+						$html .= '<li id="ee-event-tickets-li-'
454
+								 . esc_attr($ticket->ID())
455
+								 . '" class="ee-event-tickets-li">';
456
+						$html .= esc_html($ticket->name()) . ' ';
457
+						$html .= EEH_Template::format_currency(
458
+							$ticket->get_ticket_total_with_taxes()
459
+						); // already escaped
460
+						$html .= '</li>';
461
+					} else {
462
+						$html[] = $ticket;
463
+					}
464
+				}
465
+			}
466
+			if ($format) {
467
+				$html .= '</ul>';
468
+			}
469
+			if ($echo && $format) {
470
+				echo wp_kses($html, AllowedTags::getAllowedTags());
471
+				return '';
472
+			}
473
+			return $html;
474
+		}
475
+		return '';
476
+	}
477 477
 }
478 478
 
479 479
 if (! function_exists('espresso_event_date_obj')) {
480
-    /**
481
-     * espresso_event_date_obj
482
-     * returns the primary date object for an event
483
-     *
484
-     * @param bool $EVT_ID
485
-     * @return EE_Datetime|null
486
-     * @throws EE_Error
487
-     * @throws ReflectionException
488
-     */
489
-    function espresso_event_date_obj($EVT_ID = false)
490
-    {
491
-        return EEH_Event_View::get_primary_date_obj($EVT_ID);
492
-    }
480
+	/**
481
+	 * espresso_event_date_obj
482
+	 * returns the primary date object for an event
483
+	 *
484
+	 * @param bool $EVT_ID
485
+	 * @return EE_Datetime|null
486
+	 * @throws EE_Error
487
+	 * @throws ReflectionException
488
+	 */
489
+	function espresso_event_date_obj($EVT_ID = false)
490
+	{
491
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
492
+	}
493 493
 }
494 494
 
495 495
 
496 496
 if (! function_exists('espresso_event_date')) {
497
-    /**
498
-     * espresso_event_date
499
-     * returns the primary date for an event
500
-     *
501
-     * @param string $date_format
502
-     * @param string $time_format
503
-     * @param bool   $EVT_ID
504
-     * @param bool   $echo
505
-     * @return string
506
-     * @throws EE_Error
507
-     * @throws ReflectionException
508
-     */
509
-    function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true)
510
-    {
511
-        $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
512
-        $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
513
-        $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
514
-        $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
515
-        if ($echo) {
516
-            echo wp_kses(EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags());
517
-            return '';
518
-        }
519
-        return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
520
-
521
-    }
497
+	/**
498
+	 * espresso_event_date
499
+	 * returns the primary date for an event
500
+	 *
501
+	 * @param string $date_format
502
+	 * @param string $time_format
503
+	 * @param bool   $EVT_ID
504
+	 * @param bool   $echo
505
+	 * @return string
506
+	 * @throws EE_Error
507
+	 * @throws ReflectionException
508
+	 */
509
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true)
510
+	{
511
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
512
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
513
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
514
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
515
+		if ($echo) {
516
+			echo wp_kses(EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags());
517
+			return '';
518
+		}
519
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
520
+
521
+	}
522 522
 }
523 523
 
524 524
 
525 525
 if (! function_exists('espresso_list_of_event_dates')) {
526
-    /**
527
-     * espresso_list_of_event_dates
528
-     * returns a unordered list of dates for an event
529
-     *
530
-     * @param int    $EVT_ID
531
-     * @param string $date_format
532
-     * @param string $time_format
533
-     * @param bool   $echo
534
-     * @param null   $show_expired
535
-     * @param bool   $format
536
-     * @param bool   $add_breaks
537
-     * @param null   $limit
538
-     * @return string
539
-     * @throws EE_Error
540
-     * @throws ReflectionException
541
-     */
542
-    function espresso_list_of_event_dates(
543
-        $EVT_ID = 0,
544
-        $date_format = '',
545
-        $time_format = '',
546
-        $echo = true,
547
-        $show_expired = null,
548
-        $format = true,
549
-        $add_breaks = true,
550
-        $limit = null
551
-    ) {
552
-        $allowedtags = AllowedTags::getAllowedTags();
553
-
554
-        $DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int');
555
-        $arguments = apply_filters(
556
-            'FHEE__espresso_list_of_event_dates__arguments',
557
-            [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ]
558
-        );
559
-        [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments;
560
-        $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
561
-        $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
562
-        $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
563
-        $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
564
-        $datetimes   = $DTT_ID
565
-            ? [EEH_Event_View::get_date_obj($DTT_ID)]
566
-            : EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit);
567
-        if (! $format) {
568
-            return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
569
-        }
570
-        $newline = $add_breaks ? '<br />' : '';
571
-        if (is_array($datetimes) && ! empty($datetimes)) {
572
-            global $post;
526
+	/**
527
+	 * espresso_list_of_event_dates
528
+	 * returns a unordered list of dates for an event
529
+	 *
530
+	 * @param int    $EVT_ID
531
+	 * @param string $date_format
532
+	 * @param string $time_format
533
+	 * @param bool   $echo
534
+	 * @param null   $show_expired
535
+	 * @param bool   $format
536
+	 * @param bool   $add_breaks
537
+	 * @param null   $limit
538
+	 * @return string
539
+	 * @throws EE_Error
540
+	 * @throws ReflectionException
541
+	 */
542
+	function espresso_list_of_event_dates(
543
+		$EVT_ID = 0,
544
+		$date_format = '',
545
+		$time_format = '',
546
+		$echo = true,
547
+		$show_expired = null,
548
+		$format = true,
549
+		$add_breaks = true,
550
+		$limit = null
551
+	) {
552
+		$allowedtags = AllowedTags::getAllowedTags();
553
+
554
+		$DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int');
555
+		$arguments = apply_filters(
556
+			'FHEE__espresso_list_of_event_dates__arguments',
557
+			[ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ]
558
+		);
559
+		[$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments;
560
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
561
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
562
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
563
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
564
+		$datetimes   = $DTT_ID
565
+			? [EEH_Event_View::get_date_obj($DTT_ID)]
566
+			: EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit);
567
+		if (! $format) {
568
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
569
+		}
570
+		$newline = $add_breaks ? '<br />' : '';
571
+		if (is_array($datetimes) && ! empty($datetimes)) {
572
+			global $post;
573 573
 			$cols = count($datetimes);
574 574
 			$cols = $cols >= 3 ? 'big' : 'small';
575 575
 			$ul_class = "ee-event-datetimes-ul ee-event-datetimes-ul--{$cols}";
576 576
 			$html = '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="'. $ul_class.'">';
577 577
 
578
-            foreach ($datetimes as $datetime) {
579
-                if ($datetime instanceof EE_Datetime) {
578
+			foreach ($datetimes as $datetime) {
579
+				if ($datetime instanceof EE_Datetime) {
580 580
 
581
-                    $datetime_name        = $datetime->name();
582
-                    $datetime_html        = ! empty($datetime_name)
583
-                        ? '
581
+					$datetime_name        = $datetime->name();
582
+					$datetime_html        = ! empty($datetime_name)
583
+						? '
584 584
                         <strong class="ee-event-datetimes-li-date-name">
585 585
                           ' . esc_html($datetime_name) . '
586 586
                        </strong>' . $newline
587
-                        : '';
587
+						: '';
588 588
 
589
-                    $datetime_html .= '
589
+					$datetime_html .= '
590 590
                         <span class="ee-event-datetimes-li-daterange">
591 591
 							<span class="dashicons dashicons-calendar"></span>&nbsp;'
592 592
 							. $datetime->date_range($date_format). '
@@ -598,501 +598,501 @@  discard block
 block discarded – undo
598 598
 						</span>
599 599
                         ';
600 600
 
601
-                    $venue = $datetime->venue();
602
-                    if ($venue instanceof EE_Venue) {
603
-                    	$venue_name      = esc_html($venue->name());
604
-                        $datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">';
605
-                        $datetime_html .= '<span class="dashicons dashicons-admin-home"></span>&nbsp;';
606
-                        $datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">';
607
-                        $datetime_html .= $venue_name . '</a></span>';
608
-                    }
609
-
610
-                    $datetime_description = $datetime->description();
611
-                    $datetime_html .= ! empty($datetime_description)
612
-                        ? '
601
+					$venue = $datetime->venue();
602
+					if ($venue instanceof EE_Venue) {
603
+						$venue_name      = esc_html($venue->name());
604
+						$datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">';
605
+						$datetime_html .= '<span class="dashicons dashicons-admin-home"></span>&nbsp;';
606
+						$datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">';
607
+						$datetime_html .= $venue_name . '</a></span>';
608
+					}
609
+
610
+					$datetime_description = $datetime->description();
611
+					$datetime_html .= ! empty($datetime_description)
612
+						? '
613 613
                         <span class="ee-event-datetimes-li-date-desc">
614 614
                             ' . wp_kses($datetime_description, $allowedtags) . '
615 615
                         </span>' . $newline
616
-                        : '';
616
+						: '';
617 617
 
618
-                    $datetime_html = apply_filters(
619
-                        'FHEE__espresso_list_of_event_dates__datetime_html',
620
-                        $datetime_html,
621
-                        $datetime,
622
-                        $arguments
623
-                    );
618
+					$datetime_html = apply_filters(
619
+						'FHEE__espresso_list_of_event_dates__datetime_html',
620
+						$datetime_html,
621
+						$datetime,
622
+						$arguments
623
+					);
624 624
 
625
-                    $DTD_ID        = esc_attr($datetime->ID());
626
-                    $active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status());
625
+					$DTD_ID        = esc_attr($datetime->ID());
626
+					$active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status());
627 627
 
628
-                    $html .= '
628
+					$html .= '
629 629
                     <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li ' . $active_status . '">
630 630
                         ' . $datetime_html . '
631 631
                     </li>';
632
-                }
633
-            }
634
-            $html .= '</ul>';
635
-            $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime);
636
-        } else {
637
-            $html =
638
-                '
632
+				}
633
+			}
634
+			$html .= '</ul>';
635
+			$html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime);
636
+		} else {
637
+			$html =
638
+				'
639 639
             <p>
640 640
                 <span class="dashicons dashicons-marker pink-text"></span>
641 641
                 ' . esc_html__(
642
-                    'There are no upcoming dates for this event.',
643
-                    'event_espresso'
644
-                ) . '
642
+					'There are no upcoming dates for this event.',
643
+					'event_espresso'
644
+				) . '
645 645
             </p>
646 646
             <br/>';
647
-        }
648
-        if ($echo) {
649
-            echo wp_kses($html, AllowedTags::getWithFormTags());
650
-            return '';
651
-        }
652
-        return $html;
653
-    }
647
+		}
648
+		if ($echo) {
649
+			echo wp_kses($html, AllowedTags::getWithFormTags());
650
+			return '';
651
+		}
652
+		return $html;
653
+	}
654 654
 }
655 655
 
656 656
 
657 657
 if (! function_exists('espresso_event_end_date')) {
658
-    /**
659
-     * espresso_event_end_date
660
-     * returns the last date for an event
661
-     *
662
-     * @param string $date_format
663
-     * @param string $time_format
664
-     * @param bool   $EVT_ID
665
-     * @param bool   $echo
666
-     * @return string
667
-     * @throws EE_Error
668
-     * @throws ReflectionException
669
-     */
670
-    function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true)
671
-    {
672
-        $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
673
-        $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
674
-        $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
675
-        $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
676
-        if ($echo) {
677
-            echo wp_kses(EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags());
678
-            return '';
679
-        }
680
-        return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
681
-    }
658
+	/**
659
+	 * espresso_event_end_date
660
+	 * returns the last date for an event
661
+	 *
662
+	 * @param string $date_format
663
+	 * @param string $time_format
664
+	 * @param bool   $EVT_ID
665
+	 * @param bool   $echo
666
+	 * @return string
667
+	 * @throws EE_Error
668
+	 * @throws ReflectionException
669
+	 */
670
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true)
671
+	{
672
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
673
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
674
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
675
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
676
+		if ($echo) {
677
+			echo wp_kses(EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags());
678
+			return '';
679
+		}
680
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
681
+	}
682 682
 }
683 683
 
684 684
 if (! function_exists('espresso_event_date_range')) {
685
-    /**
686
-     * espresso_event_date_range
687
-     * returns the first and last chronologically ordered dates for an event (if different)
688
-     *
689
-     * @param string $date_format
690
-     * @param string $time_format
691
-     * @param string $single_date_format
692
-     * @param string $single_time_format
693
-     * @param bool   $EVT_ID
694
-     * @param bool   $echo
695
-     * @return string
696
-     * @throws EE_Error
697
-     * @throws ReflectionException
698
-     */
699
-    function espresso_event_date_range(
700
-        $date_format = '',
701
-        $time_format = '',
702
-        $single_date_format = '',
703
-        $single_time_format = '',
704
-        $EVT_ID = false,
705
-        $echo = true
706
-    ) {
707
-        // set and filter date and time formats when a range is returned
708
-        $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
709
-        $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
710
-        // get the start and end date with NO time portion
711
-        $the_event_date     = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
712
-        $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
713
-        // now we can determine if date range spans more than one day
714
-        if ($the_event_date != $the_event_end_date) {
715
-            $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
716
-            $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
717
-            $html        = sprintf(
718
-            /* translators: 1: first event date, 2: last event date */
719
-                esc_html__('%1$s - %2$s', 'event_espresso'),
720
-                EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
721
-                EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
722
-            );
723
-        } else {
724
-            // set and filter date and time formats when only a single datetime is returned
725
-            $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
726
-            $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
727
-            $single_date_format =
728
-                apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
729
-            $single_time_format =
730
-                apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
731
-            $html               =
732
-                EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
733
-        }
734
-        if ($echo) {
735
-            echo wp_kses($html, AllowedTags::getAllowedTags());
736
-            return '';
737
-        }
738
-        return $html;
739
-    }
685
+	/**
686
+	 * espresso_event_date_range
687
+	 * returns the first and last chronologically ordered dates for an event (if different)
688
+	 *
689
+	 * @param string $date_format
690
+	 * @param string $time_format
691
+	 * @param string $single_date_format
692
+	 * @param string $single_time_format
693
+	 * @param bool   $EVT_ID
694
+	 * @param bool   $echo
695
+	 * @return string
696
+	 * @throws EE_Error
697
+	 * @throws ReflectionException
698
+	 */
699
+	function espresso_event_date_range(
700
+		$date_format = '',
701
+		$time_format = '',
702
+		$single_date_format = '',
703
+		$single_time_format = '',
704
+		$EVT_ID = false,
705
+		$echo = true
706
+	) {
707
+		// set and filter date and time formats when a range is returned
708
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
709
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
710
+		// get the start and end date with NO time portion
711
+		$the_event_date     = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
712
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
713
+		// now we can determine if date range spans more than one day
714
+		if ($the_event_date != $the_event_end_date) {
715
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
716
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
717
+			$html        = sprintf(
718
+			/* translators: 1: first event date, 2: last event date */
719
+				esc_html__('%1$s - %2$s', 'event_espresso'),
720
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
721
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
722
+			);
723
+		} else {
724
+			// set and filter date and time formats when only a single datetime is returned
725
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
726
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
727
+			$single_date_format =
728
+				apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
729
+			$single_time_format =
730
+				apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
731
+			$html               =
732
+				EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
733
+		}
734
+		if ($echo) {
735
+			echo wp_kses($html, AllowedTags::getAllowedTags());
736
+			return '';
737
+		}
738
+		return $html;
739
+	}
740 740
 }
741 741
 
742 742
 if (! function_exists('espresso_next_upcoming_datetime_obj')) {
743
-    /**
744
-     * espresso_next_upcoming_datetime_obj
745
-     * returns the next upcoming datetime object for an event
746
-     *
747
-     * @param int $EVT_ID
748
-     * @return EE_Datetime|null
749
-     * @throws EE_Error
750
-     */
751
-    function espresso_next_upcoming_datetime_obj($EVT_ID = 0)
752
-    {
753
-        return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID);
754
-    }
743
+	/**
744
+	 * espresso_next_upcoming_datetime_obj
745
+	 * returns the next upcoming datetime object for an event
746
+	 *
747
+	 * @param int $EVT_ID
748
+	 * @return EE_Datetime|null
749
+	 * @throws EE_Error
750
+	 */
751
+	function espresso_next_upcoming_datetime_obj($EVT_ID = 0)
752
+	{
753
+		return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID);
754
+	}
755 755
 }
756 756
 
757 757
 if (! function_exists('espresso_next_upcoming_datetime')) {
758
-    /**
759
-     * espresso_next_upcoming_datetime
760
-     * returns the start date and time for the next upcoming event.
761
-     *
762
-     * @param string $date_format
763
-     * @param string $time_format
764
-     * @param int    $EVT_ID
765
-     * @param bool   $echo
766
-     * @return string
767
-     * @throws EE_Error
768
-     * @throws ReflectionException
769
-     */
770
-    function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true)
771
-    {
772
-
773
-        $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
774
-        $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format);
775
-
776
-        $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
777
-        $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format);
778
-
779
-        $datetime_format = trim($date_format . ' ' . $time_format);
780
-
781
-        $datetime = espresso_next_upcoming_datetime_obj($EVT_ID);
782
-
783
-        if (! $datetime instanceof EE_Datetime) {
784
-            return '';
785
-        }
786
-        if ($echo) {
787
-            echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format));
788
-            return '';
789
-        }
790
-        return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
791
-    }
758
+	/**
759
+	 * espresso_next_upcoming_datetime
760
+	 * returns the start date and time for the next upcoming event.
761
+	 *
762
+	 * @param string $date_format
763
+	 * @param string $time_format
764
+	 * @param int    $EVT_ID
765
+	 * @param bool   $echo
766
+	 * @return string
767
+	 * @throws EE_Error
768
+	 * @throws ReflectionException
769
+	 */
770
+	function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true)
771
+	{
772
+
773
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
774
+		$date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format);
775
+
776
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
777
+		$time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format);
778
+
779
+		$datetime_format = trim($date_format . ' ' . $time_format);
780
+
781
+		$datetime = espresso_next_upcoming_datetime_obj($EVT_ID);
782
+
783
+		if (! $datetime instanceof EE_Datetime) {
784
+			return '';
785
+		}
786
+		if ($echo) {
787
+			echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format));
788
+			return '';
789
+		}
790
+		return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
791
+	}
792 792
 }
793 793
 
794 794
 if (! function_exists('espresso_event_date_as_calendar_page')) {
795
-    /**
796
-     * espresso_event_date_as_calendar_page
797
-     * returns the primary date for an event, stylized to appear as the page of a calendar
798
-     *
799
-     * @param bool $EVT_ID
800
-     * @return void
801
-     * @throws EE_Error
802
-     * @throws ReflectionException
803
-     */
804
-    function espresso_event_date_as_calendar_page($EVT_ID = false)
805
-    {
806
-        EEH_Event_View::event_date_as_calendar_page($EVT_ID);
807
-    }
795
+	/**
796
+	 * espresso_event_date_as_calendar_page
797
+	 * returns the primary date for an event, stylized to appear as the page of a calendar
798
+	 *
799
+	 * @param bool $EVT_ID
800
+	 * @return void
801
+	 * @throws EE_Error
802
+	 * @throws ReflectionException
803
+	 */
804
+	function espresso_event_date_as_calendar_page($EVT_ID = false)
805
+	{
806
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
807
+	}
808 808
 }
809 809
 
810 810
 
811 811
 if (! function_exists('espresso_event_link_url')) {
812
-    /**
813
-     * espresso_event_link_url
814
-     *
815
-     * @param int  $EVT_ID
816
-     * @param bool $echo
817
-     * @return string
818
-     * @throws EE_Error
819
-     * @throws ReflectionException
820
-     */
821
-    function espresso_event_link_url($EVT_ID = 0, $echo = true)
822
-    {
823
-        if ($echo) {
824
-            echo wp_kses(EEH_Event_View::event_link_url($EVT_ID), AllowedTags::getWithFormTags());
825
-            return '';
826
-        }
827
-        return EEH_Event_View::event_link_url($EVT_ID);
828
-    }
812
+	/**
813
+	 * espresso_event_link_url
814
+	 *
815
+	 * @param int  $EVT_ID
816
+	 * @param bool $echo
817
+	 * @return string
818
+	 * @throws EE_Error
819
+	 * @throws ReflectionException
820
+	 */
821
+	function espresso_event_link_url($EVT_ID = 0, $echo = true)
822
+	{
823
+		if ($echo) {
824
+			echo wp_kses(EEH_Event_View::event_link_url($EVT_ID), AllowedTags::getWithFormTags());
825
+			return '';
826
+		}
827
+		return EEH_Event_View::event_link_url($EVT_ID);
828
+	}
829 829
 }
830 830
 
831 831
 
832 832
 if (! function_exists('espresso_event_has_content_or_excerpt')) {
833
-    /**
834
-     *    espresso_event_has_content_or_excerpt
835
-     *
836
-     * @access    public
837
-     * @param bool $EVT_ID
838
-     * @return    boolean
839
-     * @throws EE_Error
840
-     * @throws ReflectionException
841
-     */
842
-    function espresso_event_has_content_or_excerpt($EVT_ID = false)
843
-    {
844
-        return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
845
-    }
833
+	/**
834
+	 *    espresso_event_has_content_or_excerpt
835
+	 *
836
+	 * @access    public
837
+	 * @param bool $EVT_ID
838
+	 * @return    boolean
839
+	 * @throws EE_Error
840
+	 * @throws ReflectionException
841
+	 */
842
+	function espresso_event_has_content_or_excerpt($EVT_ID = false)
843
+	{
844
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
845
+	}
846 846
 }
847 847
 
848 848
 
849 849
 if (! function_exists('espresso_event_content_or_excerpt')) {
850
-    /**
851
-     * espresso_event_content_or_excerpt
852
-     *
853
-     * @param int  $num_words
854
-     * @param null $more
855
-     * @param bool $echo
856
-     * @return string
857
-     */
858
-    function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true)
859
-    {
860
-        if ($echo) {
861
-            echo wp_kses(EEH_Event_View::event_content_or_excerpt($num_words, $more), AllowedTags::getWithFormTags());
862
-            return '';
863
-        }
864
-        return EEH_Event_View::event_content_or_excerpt($num_words, $more);
865
-    }
850
+	/**
851
+	 * espresso_event_content_or_excerpt
852
+	 *
853
+	 * @param int  $num_words
854
+	 * @param null $more
855
+	 * @param bool $echo
856
+	 * @return string
857
+	 */
858
+	function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true)
859
+	{
860
+		if ($echo) {
861
+			echo wp_kses(EEH_Event_View::event_content_or_excerpt($num_words, $more), AllowedTags::getWithFormTags());
862
+			return '';
863
+		}
864
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
865
+	}
866 866
 }
867 867
 
868 868
 
869 869
 if (! function_exists('espresso_event_phone')) {
870
-    /**
871
-     * espresso_event_phone
872
-     *
873
-     * @param int  $EVT_ID
874
-     * @param bool $echo
875
-     * @return string
876
-     * @throws EE_Error
877
-     * @throws ReflectionException
878
-     */
879
-    function espresso_event_phone($EVT_ID = 0, $echo = true)
880
-    {
881
-        if ($echo) {
882
-            echo wp_kses(EEH_Event_View::event_phone($EVT_ID), AllowedTags::getWithFormTags());
883
-            return '';
884
-        }
885
-        return EEH_Event_View::event_phone($EVT_ID);
886
-    }
870
+	/**
871
+	 * espresso_event_phone
872
+	 *
873
+	 * @param int  $EVT_ID
874
+	 * @param bool $echo
875
+	 * @return string
876
+	 * @throws EE_Error
877
+	 * @throws ReflectionException
878
+	 */
879
+	function espresso_event_phone($EVT_ID = 0, $echo = true)
880
+	{
881
+		if ($echo) {
882
+			echo wp_kses(EEH_Event_View::event_phone($EVT_ID), AllowedTags::getWithFormTags());
883
+			return '';
884
+		}
885
+		return EEH_Event_View::event_phone($EVT_ID);
886
+	}
887 887
 }
888 888
 
889 889
 
890 890
 if (! function_exists('espresso_edit_event_link')) {
891
-    /**
892
-     * espresso_edit_event_link
893
-     * returns a link to edit an event
894
-     *
895
-     * @param int  $EVT_ID
896
-     * @param bool $echo
897
-     * @return string
898
-     * @throws EE_Error
899
-     * @throws ReflectionException
900
-     */
901
-    function espresso_edit_event_link($EVT_ID = 0, $echo = true)
902
-    {
903
-        if ($echo) {
904
-            echo wp_kses(EEH_Event_View::edit_event_link($EVT_ID), AllowedTags::getWithFormTags());
905
-            return '';
906
-        }
907
-        return EEH_Event_View::edit_event_link($EVT_ID);
908
-    }
891
+	/**
892
+	 * espresso_edit_event_link
893
+	 * returns a link to edit an event
894
+	 *
895
+	 * @param int  $EVT_ID
896
+	 * @param bool $echo
897
+	 * @return string
898
+	 * @throws EE_Error
899
+	 * @throws ReflectionException
900
+	 */
901
+	function espresso_edit_event_link($EVT_ID = 0, $echo = true)
902
+	{
903
+		if ($echo) {
904
+			echo wp_kses(EEH_Event_View::edit_event_link($EVT_ID), AllowedTags::getWithFormTags());
905
+			return '';
906
+		}
907
+		return EEH_Event_View::edit_event_link($EVT_ID);
908
+	}
909 909
 }
910 910
 
911 911
 
912 912
 if (! function_exists('espresso_organization_name')) {
913
-    /**
914
-     * espresso_organization_name
915
-     *
916
-     * @param bool $echo
917
-     * @return string
918
-     * @throws EE_Error
919
-     */
920
-    function espresso_organization_name($echo = true)
921
-    {
922
-        if ($echo) {
923
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('name'));
924
-            return '';
925
-        }
926
-        return EE_Registry::instance()->CFG->organization->get_pretty('name');
927
-    }
913
+	/**
914
+	 * espresso_organization_name
915
+	 *
916
+	 * @param bool $echo
917
+	 * @return string
918
+	 * @throws EE_Error
919
+	 */
920
+	function espresso_organization_name($echo = true)
921
+	{
922
+		if ($echo) {
923
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('name'));
924
+			return '';
925
+		}
926
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
927
+	}
928 928
 }
929 929
 
930 930
 if (! function_exists('espresso_organization_address')) {
931
-    /**
932
-     * espresso_organization_address
933
-     *
934
-     * @param string $type
935
-     * @return string
936
-     */
937
-    function espresso_organization_address($type = 'inline')
938
-    {
939
-        if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
940
-            $address = new EventEspresso\core\domain\entities\GenericAddress(
941
-                EE_Registry::instance()->CFG->organization->address_1,
942
-                EE_Registry::instance()->CFG->organization->address_2,
943
-                EE_Registry::instance()->CFG->organization->city,
944
-                EE_Registry::instance()->CFG->organization->STA_ID,
945
-                EE_Registry::instance()->CFG->organization->zip,
946
-                EE_Registry::instance()->CFG->organization->CNT_ISO
947
-            );
948
-            return EEH_Address::format($address, $type);
949
-        }
950
-        return '';
951
-    }
931
+	/**
932
+	 * espresso_organization_address
933
+	 *
934
+	 * @param string $type
935
+	 * @return string
936
+	 */
937
+	function espresso_organization_address($type = 'inline')
938
+	{
939
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
940
+			$address = new EventEspresso\core\domain\entities\GenericAddress(
941
+				EE_Registry::instance()->CFG->organization->address_1,
942
+				EE_Registry::instance()->CFG->organization->address_2,
943
+				EE_Registry::instance()->CFG->organization->city,
944
+				EE_Registry::instance()->CFG->organization->STA_ID,
945
+				EE_Registry::instance()->CFG->organization->zip,
946
+				EE_Registry::instance()->CFG->organization->CNT_ISO
947
+			);
948
+			return EEH_Address::format($address, $type);
949
+		}
950
+		return '';
951
+	}
952 952
 }
953 953
 
954 954
 if (! function_exists('espresso_organization_email')) {
955
-    /**
956
-     * espresso_organization_email
957
-     *
958
-     * @param bool $echo
959
-     * @return string
960
-     * @throws EE_Error
961
-     */
962
-    function espresso_organization_email($echo = true)
963
-    {
964
-        if ($echo) {
965
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('email'));
966
-            return '';
967
-        }
968
-        return EE_Registry::instance()->CFG->organization->get_pretty('email');
969
-    }
955
+	/**
956
+	 * espresso_organization_email
957
+	 *
958
+	 * @param bool $echo
959
+	 * @return string
960
+	 * @throws EE_Error
961
+	 */
962
+	function espresso_organization_email($echo = true)
963
+	{
964
+		if ($echo) {
965
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('email'));
966
+			return '';
967
+		}
968
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
969
+	}
970 970
 }
971 971
 
972 972
 if (! function_exists('espresso_organization_logo_url')) {
973
-    /**
974
-     * espresso_organization_logo_url
975
-     *
976
-     * @param bool $echo
977
-     * @return string
978
-     * @throws EE_Error
979
-     */
980
-    function espresso_organization_logo_url($echo = true)
981
-    {
982
-        if ($echo) {
983
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('logo_url'));
984
-            return '';
985
-        }
986
-        return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
987
-    }
973
+	/**
974
+	 * espresso_organization_logo_url
975
+	 *
976
+	 * @param bool $echo
977
+	 * @return string
978
+	 * @throws EE_Error
979
+	 */
980
+	function espresso_organization_logo_url($echo = true)
981
+	{
982
+		if ($echo) {
983
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('logo_url'));
984
+			return '';
985
+		}
986
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
987
+	}
988 988
 }
989 989
 
990 990
 if (! function_exists('espresso_organization_facebook')) {
991
-    /**
992
-     * espresso_organization_facebook
993
-     *
994
-     * @param bool $echo
995
-     * @return string
996
-     * @throws EE_Error
997
-     */
998
-    function espresso_organization_facebook($echo = true)
999
-    {
1000
-        if ($echo) {
1001
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('facebook'));
1002
-            return '';
1003
-        }
1004
-        return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
1005
-    }
991
+	/**
992
+	 * espresso_organization_facebook
993
+	 *
994
+	 * @param bool $echo
995
+	 * @return string
996
+	 * @throws EE_Error
997
+	 */
998
+	function espresso_organization_facebook($echo = true)
999
+	{
1000
+		if ($echo) {
1001
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('facebook'));
1002
+			return '';
1003
+		}
1004
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
1005
+	}
1006 1006
 }
1007 1007
 
1008 1008
 if (! function_exists('espresso_organization_twitter')) {
1009
-    /**
1010
-     * espresso_organization_twitter
1011
-     *
1012
-     * @param bool $echo
1013
-     * @return string
1014
-     * @throws EE_Error
1015
-     */
1016
-    function espresso_organization_twitter($echo = true)
1017
-    {
1018
-        if ($echo) {
1019
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('twitter'));
1020
-            return '';
1021
-        }
1022
-        return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
1023
-    }
1009
+	/**
1010
+	 * espresso_organization_twitter
1011
+	 *
1012
+	 * @param bool $echo
1013
+	 * @return string
1014
+	 * @throws EE_Error
1015
+	 */
1016
+	function espresso_organization_twitter($echo = true)
1017
+	{
1018
+		if ($echo) {
1019
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('twitter'));
1020
+			return '';
1021
+		}
1022
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
1023
+	}
1024 1024
 }
1025 1025
 
1026 1026
 if (! function_exists('espresso_organization_linkedin')) {
1027
-    /**
1028
-     * espresso_organization_linkedin
1029
-     *
1030
-     * @param bool $echo
1031
-     * @return string
1032
-     * @throws EE_Error
1033
-     */
1034
-    function espresso_organization_linkedin($echo = true)
1035
-    {
1036
-        if ($echo) {
1037
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('linkedin'));
1038
-            return '';
1039
-        }
1040
-        return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
1041
-    }
1027
+	/**
1028
+	 * espresso_organization_linkedin
1029
+	 *
1030
+	 * @param bool $echo
1031
+	 * @return string
1032
+	 * @throws EE_Error
1033
+	 */
1034
+	function espresso_organization_linkedin($echo = true)
1035
+	{
1036
+		if ($echo) {
1037
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('linkedin'));
1038
+			return '';
1039
+		}
1040
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
1041
+	}
1042 1042
 }
1043 1043
 
1044 1044
 if (! function_exists('espresso_organization_pinterest')) {
1045
-    /**
1046
-     * espresso_organization_pinterest
1047
-     *
1048
-     * @param bool $echo
1049
-     * @return string
1050
-     * @throws EE_Error
1051
-     */
1052
-    function espresso_organization_pinterest($echo = true)
1053
-    {
1054
-        if ($echo) {
1055
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('pinterest'));
1056
-            return '';
1057
-        }
1058
-        return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
1059
-    }
1045
+	/**
1046
+	 * espresso_organization_pinterest
1047
+	 *
1048
+	 * @param bool $echo
1049
+	 * @return string
1050
+	 * @throws EE_Error
1051
+	 */
1052
+	function espresso_organization_pinterest($echo = true)
1053
+	{
1054
+		if ($echo) {
1055
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('pinterest'));
1056
+			return '';
1057
+		}
1058
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
1059
+	}
1060 1060
 }
1061 1061
 
1062 1062
 if (! function_exists('espresso_organization_google')) {
1063
-    /**
1064
-     * espresso_organization_google
1065
-     *
1066
-     * @param bool $echo
1067
-     * @return string
1068
-     * @throws EE_Error
1069
-     */
1070
-    function espresso_organization_google($echo = true)
1071
-    {
1072
-        if ($echo) {
1073
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('google'));
1074
-            return '';
1075
-        }
1076
-        return EE_Registry::instance()->CFG->organization->get_pretty('google');
1077
-    }
1063
+	/**
1064
+	 * espresso_organization_google
1065
+	 *
1066
+	 * @param bool $echo
1067
+	 * @return string
1068
+	 * @throws EE_Error
1069
+	 */
1070
+	function espresso_organization_google($echo = true)
1071
+	{
1072
+		if ($echo) {
1073
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('google'));
1074
+			return '';
1075
+		}
1076
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
1077
+	}
1078 1078
 }
1079 1079
 
1080 1080
 if (! function_exists('espresso_organization_instagram')) {
1081
-    /**
1082
-     * espresso_organization_instagram
1083
-     *
1084
-     * @param bool $echo
1085
-     * @return string
1086
-     * @throws EE_Error
1087
-     */
1088
-    function espresso_organization_instagram($echo = true)
1089
-    {
1090
-        if ($echo) {
1091
-            echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('instagram'));
1092
-            return '';
1093
-        }
1094
-        return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
1095
-    }
1081
+	/**
1082
+	 * espresso_organization_instagram
1083
+	 *
1084
+	 * @param bool $echo
1085
+	 * @return string
1086
+	 * @throws EE_Error
1087
+	 */
1088
+	function espresso_organization_instagram($echo = true)
1089
+	{
1090
+		if ($echo) {
1091
+			echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('instagram'));
1092
+			return '';
1093
+		}
1094
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
1095
+	}
1096 1096
 }
1097 1097
 
1098 1098
 
@@ -1100,345 +1100,345 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
 
1102 1102
 if (! function_exists('espresso_event_venues')) {
1103
-    /**
1104
-     * espresso_event_venues
1105
-     *
1106
-     * @return array  all venues related to an event
1107
-     * @throws EE_Error
1108
-     * @throws ReflectionException
1109
-     */
1110
-    function espresso_event_venues()
1111
-    {
1112
-        return EEH_Venue_View::get_event_venues();
1113
-    }
1103
+	/**
1104
+	 * espresso_event_venues
1105
+	 *
1106
+	 * @return array  all venues related to an event
1107
+	 * @throws EE_Error
1108
+	 * @throws ReflectionException
1109
+	 */
1110
+	function espresso_event_venues()
1111
+	{
1112
+		return EEH_Venue_View::get_event_venues();
1113
+	}
1114 1114
 }
1115 1115
 
1116 1116
 
1117 1117
 if (! function_exists('espresso_venue_id')) {
1118
-    /**
1119
-     *    espresso_venue_name
1120
-     *
1121
-     * @access    public
1122
-     * @param int $EVT_ID
1123
-     * @return    string
1124
-     * @throws EE_Error
1125
-     * @throws ReflectionException
1126
-     */
1127
-    function espresso_venue_id($EVT_ID = 0)
1128
-    {
1129
-        $venue = EEH_Venue_View::get_venue($EVT_ID);
1130
-        return $venue instanceof EE_Venue ? $venue->ID() : 0;
1131
-    }
1118
+	/**
1119
+	 *    espresso_venue_name
1120
+	 *
1121
+	 * @access    public
1122
+	 * @param int $EVT_ID
1123
+	 * @return    string
1124
+	 * @throws EE_Error
1125
+	 * @throws ReflectionException
1126
+	 */
1127
+	function espresso_venue_id($EVT_ID = 0)
1128
+	{
1129
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
1130
+		return $venue instanceof EE_Venue ? $venue->ID() : 0;
1131
+	}
1132 1132
 }
1133 1133
 
1134 1134
 
1135 1135
 if (! function_exists('espresso_is_venue_private')) {
1136
-    /**
1137
-     * Return whether a venue is private or not.
1138
-     *
1139
-     * @param int $VNU_ID optional, the venue id to check.
1140
-     *
1141
-     * @return bool | null
1142
-     * @throws EE_Error
1143
-     * @throws ReflectionException
1144
-     * @see EEH_Venue_View::get_venue() for more info on expected return results.
1145
-     */
1146
-    function espresso_is_venue_private($VNU_ID = 0)
1147
-    {
1148
-        return EEH_Venue_View::is_venue_private($VNU_ID);
1149
-    }
1136
+	/**
1137
+	 * Return whether a venue is private or not.
1138
+	 *
1139
+	 * @param int $VNU_ID optional, the venue id to check.
1140
+	 *
1141
+	 * @return bool | null
1142
+	 * @throws EE_Error
1143
+	 * @throws ReflectionException
1144
+	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
1145
+	 */
1146
+	function espresso_is_venue_private($VNU_ID = 0)
1147
+	{
1148
+		return EEH_Venue_View::is_venue_private($VNU_ID);
1149
+	}
1150 1150
 }
1151 1151
 
1152 1152
 
1153 1153
 if (! function_exists('espresso_venue_is_password_protected')) {
1154
-    /**
1155
-     * returns true or false if a venue is password protected or not
1156
-     *
1157
-     * @param int $VNU_ID optional, the venue id to check.
1158
-     * @return bool
1159
-     * @throws EE_Error
1160
-     * @throws ReflectionException
1161
-     */
1162
-    function espresso_venue_is_password_protected($VNU_ID = 0)
1163
-    {
1164
-        EE_Registry::instance()->load_helper('Venue_View');
1165
-        return EEH_Venue_View::is_venue_password_protected($VNU_ID);
1166
-    }
1154
+	/**
1155
+	 * returns true or false if a venue is password protected or not
1156
+	 *
1157
+	 * @param int $VNU_ID optional, the venue id to check.
1158
+	 * @return bool
1159
+	 * @throws EE_Error
1160
+	 * @throws ReflectionException
1161
+	 */
1162
+	function espresso_venue_is_password_protected($VNU_ID = 0)
1163
+	{
1164
+		EE_Registry::instance()->load_helper('Venue_View');
1165
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
1166
+	}
1167 1167
 }
1168 1168
 
1169 1169
 
1170 1170
 if (! function_exists('espresso_password_protected_venue_form')) {
1171
-    /**
1172
-     * Returns a password form if venue is password protected.
1173
-     *
1174
-     * @param int $VNU_ID optional, the venue id to check.
1175
-     * @return string
1176
-     * @throws EE_Error
1177
-     * @throws ReflectionException
1178
-     */
1179
-    function espresso_password_protected_venue_form($VNU_ID = 0)
1180
-    {
1181
-        EE_Registry::instance()->load_helper('Venue_View');
1182
-        return EEH_Venue_View::password_protected_venue_form($VNU_ID);
1183
-    }
1171
+	/**
1172
+	 * Returns a password form if venue is password protected.
1173
+	 *
1174
+	 * @param int $VNU_ID optional, the venue id to check.
1175
+	 * @return string
1176
+	 * @throws EE_Error
1177
+	 * @throws ReflectionException
1178
+	 */
1179
+	function espresso_password_protected_venue_form($VNU_ID = 0)
1180
+	{
1181
+		EE_Registry::instance()->load_helper('Venue_View');
1182
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
1183
+	}
1184 1184
 }
1185 1185
 
1186 1186
 
1187 1187
 if (! function_exists('espresso_venue_name')) {
1188
-    /**
1189
-     *    espresso_venue_name
1190
-     *
1191
-     * @access    public
1192
-     * @param int    $VNU_ID
1193
-     * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website
1194
-     * @param bool   $echo
1195
-     * @return    string
1196
-     * @throws EE_Error
1197
-     * @throws ReflectionException
1198
-     */
1199
-    function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true)
1200
-    {
1201
-        if ($echo) {
1202
-            echo wp_kses(EEH_Venue_View::venue_name($link_to, $VNU_ID), AllowedTags::getWithFormTags());
1203
-            return '';
1204
-        }
1205
-        return EEH_Venue_View::venue_name($link_to, $VNU_ID);
1206
-    }
1188
+	/**
1189
+	 *    espresso_venue_name
1190
+	 *
1191
+	 * @access    public
1192
+	 * @param int    $VNU_ID
1193
+	 * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website
1194
+	 * @param bool   $echo
1195
+	 * @return    string
1196
+	 * @throws EE_Error
1197
+	 * @throws ReflectionException
1198
+	 */
1199
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true)
1200
+	{
1201
+		if ($echo) {
1202
+			echo wp_kses(EEH_Venue_View::venue_name($link_to, $VNU_ID), AllowedTags::getWithFormTags());
1203
+			return '';
1204
+		}
1205
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
1206
+	}
1207 1207
 }
1208 1208
 
1209 1209
 
1210 1210
 if (! function_exists('espresso_venue_link')) {
1211
-    /**
1212
-     *    espresso_venue_link
1213
-     *
1214
-     * @access    public
1215
-     * @param int    $VNU_ID
1216
-     * @param string $text
1217
-     * @return    string
1218
-     * @throws EE_Error
1219
-     * @throws ReflectionException
1220
-     */
1221
-    function espresso_venue_link($VNU_ID = 0, $text = '')
1222
-    {
1223
-        return EEH_Venue_View::venue_details_link($VNU_ID, $text);
1224
-    }
1211
+	/**
1212
+	 *    espresso_venue_link
1213
+	 *
1214
+	 * @access    public
1215
+	 * @param int    $VNU_ID
1216
+	 * @param string $text
1217
+	 * @return    string
1218
+	 * @throws EE_Error
1219
+	 * @throws ReflectionException
1220
+	 */
1221
+	function espresso_venue_link($VNU_ID = 0, $text = '')
1222
+	{
1223
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
1224
+	}
1225 1225
 }
1226 1226
 
1227 1227
 
1228 1228
 if (! function_exists('espresso_venue_description')) {
1229
-    /**
1230
-     *    espresso_venue_description
1231
-     *
1232
-     * @access    public
1233
-     * @param bool $VNU_ID
1234
-     * @param bool $echo
1235
-     * @return    string
1236
-     * @throws EE_Error
1237
-     * @throws ReflectionException
1238
-     */
1239
-    function espresso_venue_description($VNU_ID = false, $echo = true)
1240
-    {
1241
-        if ($echo) {
1242
-            echo wp_kses(EEH_Venue_View::venue_description($VNU_ID), AllowedTags::getWithFormTags());
1243
-            return '';
1244
-        }
1245
-        return EEH_Venue_View::venue_description($VNU_ID);
1246
-    }
1229
+	/**
1230
+	 *    espresso_venue_description
1231
+	 *
1232
+	 * @access    public
1233
+	 * @param bool $VNU_ID
1234
+	 * @param bool $echo
1235
+	 * @return    string
1236
+	 * @throws EE_Error
1237
+	 * @throws ReflectionException
1238
+	 */
1239
+	function espresso_venue_description($VNU_ID = false, $echo = true)
1240
+	{
1241
+		if ($echo) {
1242
+			echo wp_kses(EEH_Venue_View::venue_description($VNU_ID), AllowedTags::getWithFormTags());
1243
+			return '';
1244
+		}
1245
+		return EEH_Venue_View::venue_description($VNU_ID);
1246
+	}
1247 1247
 }
1248 1248
 
1249 1249
 
1250 1250
 if (! function_exists('espresso_venue_excerpt')) {
1251
-    /**
1252
-     *    espresso_venue_excerpt
1253
-     *
1254
-     * @access    public
1255
-     * @param int  $VNU_ID
1256
-     * @param bool $echo
1257
-     * @return    string
1258
-     * @throws EE_Error
1259
-     * @throws ReflectionException
1260
-     */
1261
-    function espresso_venue_excerpt($VNU_ID = 0, $echo = true)
1262
-    {
1263
-        if ($echo) {
1264
-            echo wp_kses(EEH_Venue_View::venue_excerpt($VNU_ID), AllowedTags::getWithFormTags());
1265
-            return '';
1266
-        }
1267
-        return EEH_Venue_View::venue_excerpt($VNU_ID);
1268
-    }
1251
+	/**
1252
+	 *    espresso_venue_excerpt
1253
+	 *
1254
+	 * @access    public
1255
+	 * @param int  $VNU_ID
1256
+	 * @param bool $echo
1257
+	 * @return    string
1258
+	 * @throws EE_Error
1259
+	 * @throws ReflectionException
1260
+	 */
1261
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = true)
1262
+	{
1263
+		if ($echo) {
1264
+			echo wp_kses(EEH_Venue_View::venue_excerpt($VNU_ID), AllowedTags::getWithFormTags());
1265
+			return '';
1266
+		}
1267
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1268
+	}
1269 1269
 }
1270 1270
 
1271 1271
 
1272 1272
 if (! function_exists('espresso_venue_categories')) {
1273
-    /**
1274
-     * espresso_venue_categories
1275
-     * returns the terms associated with a venue
1276
-     *
1277
-     * @param int  $VNU_ID
1278
-     * @param bool $hide_uncategorized
1279
-     * @param bool $echo
1280
-     * @return string
1281
-     * @throws EE_Error
1282
-     * @throws ReflectionException
1283
-     */
1284
-    function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true)
1285
-    {
1286
-        if ($echo) {
1287
-            echo wp_kses(EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized), AllowedTags::getWithFormTags());
1288
-            return '';
1289
-        }
1290
-        return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1291
-    }
1273
+	/**
1274
+	 * espresso_venue_categories
1275
+	 * returns the terms associated with a venue
1276
+	 *
1277
+	 * @param int  $VNU_ID
1278
+	 * @param bool $hide_uncategorized
1279
+	 * @param bool $echo
1280
+	 * @return string
1281
+	 * @throws EE_Error
1282
+	 * @throws ReflectionException
1283
+	 */
1284
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true)
1285
+	{
1286
+		if ($echo) {
1287
+			echo wp_kses(EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized), AllowedTags::getWithFormTags());
1288
+			return '';
1289
+		}
1290
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1291
+	}
1292 1292
 }
1293 1293
 
1294 1294
 
1295 1295
 if (! function_exists('espresso_venue_address')) {
1296
-    /**
1297
-     * espresso_venue_address
1298
-     * returns a formatted block of html  for displaying a venue's address
1299
-     *
1300
-     * @param string $type 'inline' or 'multiline'
1301
-     * @param int    $VNU_ID
1302
-     * @param bool   $echo
1303
-     * @return string
1304
-     * @throws EE_Error
1305
-     * @throws ReflectionException
1306
-     */
1307
-    function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true)
1308
-    {
1309
-        if ($echo) {
1310
-            echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID), AllowedTags::getWithFormTags());
1311
-            return '';
1312
-        }
1313
-        return EEH_Venue_View::venue_address($type, $VNU_ID);
1314
-    }
1296
+	/**
1297
+	 * espresso_venue_address
1298
+	 * returns a formatted block of html  for displaying a venue's address
1299
+	 *
1300
+	 * @param string $type 'inline' or 'multiline'
1301
+	 * @param int    $VNU_ID
1302
+	 * @param bool   $echo
1303
+	 * @return string
1304
+	 * @throws EE_Error
1305
+	 * @throws ReflectionException
1306
+	 */
1307
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true)
1308
+	{
1309
+		if ($echo) {
1310
+			echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID), AllowedTags::getWithFormTags());
1311
+			return '';
1312
+		}
1313
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1314
+	}
1315 1315
 }
1316 1316
 
1317 1317
 
1318 1318
 if (! function_exists('espresso_venue_raw_address')) {
1319
-    /**
1320
-     * espresso_venue_address
1321
-     * returns an UN-formatted string containing a venue's address
1322
-     *
1323
-     * @param string $type 'inline' or 'multiline'
1324
-     * @param int    $VNU_ID
1325
-     * @param bool   $echo
1326
-     * @return string
1327
-     * @throws EE_Error
1328
-     * @throws ReflectionException
1329
-     */
1330
-    function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true)
1331
-    {
1332
-        if ($echo) {
1333
-            echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID, false, false), AllowedTags::getWithFormTags());
1334
-            return '';
1335
-        }
1336
-        return EEH_Venue_View::venue_address($type, $VNU_ID, false, false);
1337
-    }
1319
+	/**
1320
+	 * espresso_venue_address
1321
+	 * returns an UN-formatted string containing a venue's address
1322
+	 *
1323
+	 * @param string $type 'inline' or 'multiline'
1324
+	 * @param int    $VNU_ID
1325
+	 * @param bool   $echo
1326
+	 * @return string
1327
+	 * @throws EE_Error
1328
+	 * @throws ReflectionException
1329
+	 */
1330
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true)
1331
+	{
1332
+		if ($echo) {
1333
+			echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID, false, false), AllowedTags::getWithFormTags());
1334
+			return '';
1335
+		}
1336
+		return EEH_Venue_View::venue_address($type, $VNU_ID, false, false);
1337
+	}
1338 1338
 }
1339 1339
 
1340 1340
 
1341 1341
 if (! function_exists('espresso_venue_has_address')) {
1342
-    /**
1343
-     * espresso_venue_has_address
1344
-     * returns TRUE or FALSE if a Venue has address information
1345
-     *
1346
-     * @param int $VNU_ID
1347
-     * @return bool
1348
-     * @throws EE_Error
1349
-     * @throws ReflectionException
1350
-     */
1351
-    function espresso_venue_has_address($VNU_ID = 0)
1352
-    {
1353
-        return EEH_Venue_View::venue_has_address($VNU_ID);
1354
-    }
1342
+	/**
1343
+	 * espresso_venue_has_address
1344
+	 * returns TRUE or FALSE if a Venue has address information
1345
+	 *
1346
+	 * @param int $VNU_ID
1347
+	 * @return bool
1348
+	 * @throws EE_Error
1349
+	 * @throws ReflectionException
1350
+	 */
1351
+	function espresso_venue_has_address($VNU_ID = 0)
1352
+	{
1353
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1354
+	}
1355 1355
 }
1356 1356
 
1357 1357
 
1358 1358
 if (! function_exists('espresso_venue_gmap')) {
1359
-    /**
1360
-     * espresso_venue_gmap
1361
-     * returns a google map for the venue address
1362
-     *
1363
-     * @param int   $VNU_ID
1364
-     * @param bool  $map_ID
1365
-     * @param array $gmap
1366
-     * @param bool  $echo
1367
-     * @return string
1368
-     * @throws EE_Error
1369
-     * @throws ReflectionException
1370
-     */
1371
-    function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true)
1372
-    {
1373
-        if ($echo) {
1374
-            echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped
1375
-            return '';
1376
-        }
1377
-        return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1378
-    }
1359
+	/**
1360
+	 * espresso_venue_gmap
1361
+	 * returns a google map for the venue address
1362
+	 *
1363
+	 * @param int   $VNU_ID
1364
+	 * @param bool  $map_ID
1365
+	 * @param array $gmap
1366
+	 * @param bool  $echo
1367
+	 * @return string
1368
+	 * @throws EE_Error
1369
+	 * @throws ReflectionException
1370
+	 */
1371
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true)
1372
+	{
1373
+		if ($echo) {
1374
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped
1375
+			return '';
1376
+		}
1377
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1378
+	}
1379 1379
 }
1380 1380
 
1381 1381
 
1382 1382
 if (! function_exists('espresso_venue_phone')) {
1383
-    /**
1384
-     * espresso_venue_phone
1385
-     *
1386
-     * @param int  $VNU_ID
1387
-     * @param bool $echo
1388
-     * @return string
1389
-     * @throws EE_Error
1390
-     * @throws ReflectionException
1391
-     */
1392
-    function espresso_venue_phone($VNU_ID = 0, $echo = true)
1393
-    {
1394
-        if ($echo) {
1395
-            echo wp_kses(EEH_Venue_View::venue_phone($VNU_ID), AllowedTags::getWithFormTags());
1396
-            return '';
1397
-        }
1398
-        return EEH_Venue_View::venue_phone($VNU_ID);
1399
-    }
1383
+	/**
1384
+	 * espresso_venue_phone
1385
+	 *
1386
+	 * @param int  $VNU_ID
1387
+	 * @param bool $echo
1388
+	 * @return string
1389
+	 * @throws EE_Error
1390
+	 * @throws ReflectionException
1391
+	 */
1392
+	function espresso_venue_phone($VNU_ID = 0, $echo = true)
1393
+	{
1394
+		if ($echo) {
1395
+			echo wp_kses(EEH_Venue_View::venue_phone($VNU_ID), AllowedTags::getWithFormTags());
1396
+			return '';
1397
+		}
1398
+		return EEH_Venue_View::venue_phone($VNU_ID);
1399
+	}
1400 1400
 }
1401 1401
 
1402 1402
 
1403 1403
 if (! function_exists('espresso_venue_website')) {
1404
-    /**
1405
-     * espresso_venue_website
1406
-     *
1407
-     * @param int  $VNU_ID
1408
-     * @param bool $echo
1409
-     * @return string
1410
-     * @throws EE_Error
1411
-     * @throws ReflectionException
1412
-     */
1413
-    function espresso_venue_website($VNU_ID = 0, $echo = true)
1414
-    {
1415
-        if ($echo) {
1416
-            echo wp_kses(EEH_Venue_View::venue_website_link($VNU_ID), AllowedTags::getWithFormTags());
1417
-            return '';
1418
-        }
1419
-        return EEH_Venue_View::venue_website_link($VNU_ID);
1420
-    }
1404
+	/**
1405
+	 * espresso_venue_website
1406
+	 *
1407
+	 * @param int  $VNU_ID
1408
+	 * @param bool $echo
1409
+	 * @return string
1410
+	 * @throws EE_Error
1411
+	 * @throws ReflectionException
1412
+	 */
1413
+	function espresso_venue_website($VNU_ID = 0, $echo = true)
1414
+	{
1415
+		if ($echo) {
1416
+			echo wp_kses(EEH_Venue_View::venue_website_link($VNU_ID), AllowedTags::getWithFormTags());
1417
+			return '';
1418
+		}
1419
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1420
+	}
1421 1421
 }
1422 1422
 
1423 1423
 
1424 1424
 if (! function_exists('espresso_edit_venue_link')) {
1425
-    /**
1426
-     * espresso_edit_venue_link
1427
-     *
1428
-     * @param int  $VNU_ID
1429
-     * @param bool $echo
1430
-     * @return string
1431
-     * @throws EE_Error
1432
-     * @throws ReflectionException
1433
-     */
1434
-    function espresso_edit_venue_link($VNU_ID = 0, $echo = true)
1435
-    {
1436
-        if ($echo) {
1437
-            echo wp_kses(EEH_Venue_View::edit_venue_link($VNU_ID), AllowedTags::getWithFormTags());
1438
-            return '';
1439
-        }
1440
-        return EEH_Venue_View::edit_venue_link($VNU_ID);
1441
-    }
1425
+	/**
1426
+	 * espresso_edit_venue_link
1427
+	 *
1428
+	 * @param int  $VNU_ID
1429
+	 * @param bool $echo
1430
+	 * @return string
1431
+	 * @throws EE_Error
1432
+	 * @throws ReflectionException
1433
+	 */
1434
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = true)
1435
+	{
1436
+		if ($echo) {
1437
+			echo wp_kses(EEH_Venue_View::edit_venue_link($VNU_ID), AllowedTags::getWithFormTags());
1438
+			return '';
1439
+		}
1440
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1441
+	}
1442 1442
 }
1443 1443
 
1444 1444
 
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function is_espresso_event($event = null): bool
24 24
 {
25
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
25
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
26 26
         return false;
27 27
     }
28 28
     // extract EE_Event object from passed param regardless of what it is (within reason of course)
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function is_espresso_event_single(): bool
41 41
 {
42
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
42
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
43 43
         return false;
44 44
     }
45 45
     global $wp_query;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function is_espresso_event_archive(): bool
59 59
 {
60
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
60
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
61 61
         return false;
62 62
     }
63 63
     global $wp_query;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
  */
75 75
 function is_espresso_event_taxonomy(): bool
76 76
 {
77
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
77
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
78 78
         return false;
79 79
     }
80 80
     global $wp_query;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function is_espresso_venue($venue = null): bool
96 96
 {
97
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
97
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
98 98
         return false;
99 99
     }
100 100
     // extract EE_Venue object from passed param regardless of what it is (within reason of course)
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function is_espresso_venue_single(): bool
113 113
 {
114
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
114
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
115 115
         return false;
116 116
     }
117 117
     global $wp_query;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
  */
129 129
 function is_espresso_venue_archive(): bool
130 130
 {
131
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
131
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
132 132
         return false;
133 133
     }
134 134
     global $wp_query;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function is_espresso_venue_taxonomy(): bool
147 147
 {
148
-    if (! can_use_espresso_conditionals(__FUNCTION__)) {
148
+    if ( ! can_use_espresso_conditionals(__FUNCTION__)) {
149 149
         return false;
150 150
     }
151 151
     global $wp_query;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function can_use_espresso_conditionals($conditional_tag): bool
165 165
 {
166
-    if (! did_action('AHEE__EE_System__initialize')) {
166
+    if ( ! did_action('AHEE__EE_System__initialize')) {
167 167
         EE_Error::doing_it_wrong(
168 168
             __FUNCTION__,
169 169
             sprintf(
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 /*************************** Event Queries ***************************/
185 185
 
186
-if (! function_exists('espresso_get_events')) {
186
+if ( ! function_exists('espresso_get_events')) {
187 187
     /**
188 188
      *    espresso_get_events
189 189
      *
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function espresso_load_ticket_selector()
235 235
 {
236
-    EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module');
236
+    EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
237 237
 }
238 238
 
239
-if (! function_exists('espresso_ticket_selector')) {
239
+if ( ! function_exists('espresso_ticket_selector')) {
240 240
     /**
241 241
      * espresso_ticket_selector
242 242
      *
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     function espresso_ticket_selector($event = null)
248 248
     {
249
-        if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) {
249
+        if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', false)) {
250 250
             espresso_load_ticket_selector();
251 251
             EED_Ticket_Selector::set_definitions();
252 252
             echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 }
256 256
 
257 257
 
258
-if (! function_exists('espresso_view_details_btn')) {
258
+if ( ! function_exists('espresso_view_details_btn')) {
259 259
     /**
260 260
      * espresso_view_details_btn
261 261
      *
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     function espresso_view_details_btn($event = null)
267 267
     {
268
-        if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) {
268
+        if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', false)) {
269 269
             espresso_load_ticket_selector();
270 270
             echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped
271 271
         }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 /*************************** EEH_Event_View ***************************/
277 277
 
278
-if (! function_exists('espresso_load_event_list_assets')) {
278
+if ( ! function_exists('espresso_load_event_list_assets')) {
279 279
     /**
280 280
      * espresso_load_event_list_assets
281 281
      * ensures that event list styles and scripts are loaded
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 }
292 292
 
293 293
 
294
-if (! function_exists('espresso_event_reg_button')) {
294
+if ( ! function_exists('espresso_event_reg_button')) {
295 295
     /**
296 296
      * espresso_event_reg_button
297 297
      * returns the "Register Now" button if event is active,
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false)
309 309
     {
310 310
         $event = EEH_Event_View::get_event($EVT_ID);
311
-        if (! $event instanceof EE_Event) {
311
+        if ( ! $event instanceof EE_Event) {
312 312
             return;
313 313
         }
314 314
         $event_status = $event->get_active_status();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 }
354 354
 
355 355
 
356
-if (! function_exists('espresso_display_ticket_selector')) {
356
+if ( ! function_exists('espresso_display_ticket_selector')) {
357 357
     /**
358 358
      * espresso_display_ticket_selector
359 359
      * whether or not to display the Ticket Selector for an event
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 }
371 371
 
372 372
 
373
-if (! function_exists('espresso_event_status_banner')) {
373
+if ( ! function_exists('espresso_event_status_banner')) {
374 374
     /**
375 375
      * espresso_event_status
376 376
      * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 }
388 388
 
389 389
 
390
-if (! function_exists('espresso_event_status')) {
390
+if ( ! function_exists('espresso_event_status')) {
391 391
     /**
392 392
      * espresso_event_status
393 393
      * returns the event status if it is sold out, expired, or inactive
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 }
406 406
 
407 407
 
408
-if (! function_exists('espresso_event_categories')) {
408
+if ( ! function_exists('espresso_event_categories')) {
409 409
     /**
410 410
      * espresso_event_categories
411 411
      * returns the terms associated with an event
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 }
429 429
 
430 430
 
431
-if (! function_exists('espresso_event_tickets_available')) {
431
+if ( ! function_exists('espresso_event_tickets_available')) {
432 432
     /**
433 433
      * espresso_event_tickets_available
434 434
      * returns the ticket types available for purchase for an event
@@ -446,14 +446,14 @@  discard block
 block discarded – undo
446 446
         if (is_array($tickets) && ! empty($tickets)) {
447 447
             // if formatting then $html will be a string, else it will be an array of ticket objects
448 448
             $html =
449
-                $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : [];
449
+                $format ? '<ul id="ee-event-tickets-ul-'.esc_attr($EVT_ID).'" class="ee-event-tickets-ul">' : [];
450 450
             foreach ($tickets as $ticket) {
451 451
                 if ($ticket instanceof EE_Ticket) {
452 452
                     if ($format) {
453 453
                         $html .= '<li id="ee-event-tickets-li-'
454 454
                                  . esc_attr($ticket->ID())
455 455
                                  . '" class="ee-event-tickets-li">';
456
-                        $html .= esc_html($ticket->name()) . ' ';
456
+                        $html .= esc_html($ticket->name()).' ';
457 457
                         $html .= EEH_Template::format_currency(
458 458
                             $ticket->get_ticket_total_with_taxes()
459 459
                         ); // already escaped
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     }
477 477
 }
478 478
 
479
-if (! function_exists('espresso_event_date_obj')) {
479
+if ( ! function_exists('espresso_event_date_obj')) {
480 480
     /**
481 481
      * espresso_event_date_obj
482 482
      * returns the primary date object for an event
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 }
494 494
 
495 495
 
496
-if (! function_exists('espresso_event_date')) {
496
+if ( ! function_exists('espresso_event_date')) {
497 497
     /**
498 498
      * espresso_event_date
499 499
      * returns the primary date for an event
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 }
523 523
 
524 524
 
525
-if (! function_exists('espresso_list_of_event_dates')) {
525
+if ( ! function_exists('espresso_list_of_event_dates')) {
526 526
     /**
527 527
      * espresso_list_of_event_dates
528 528
      * returns a unordered list of dates for an event
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
         $DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int');
555 555
         $arguments = apply_filters(
556 556
             'FHEE__espresso_list_of_event_dates__arguments',
557
-            [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ]
557
+            [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID]
558 558
         );
559 559
         [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments;
560 560
         $date_format = ! empty($date_format) ? $date_format : get_option('date_format');
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         $datetimes   = $DTT_ID
565 565
             ? [EEH_Event_View::get_date_obj($DTT_ID)]
566 566
             : EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit);
567
-        if (! $format) {
567
+        if ( ! $format) {
568 568
             return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
569 569
         }
570 570
         $newline = $add_breaks ? '<br />' : '';
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			$cols = count($datetimes);
574 574
 			$cols = $cols >= 3 ? 'big' : 'small';
575 575
 			$ul_class = "ee-event-datetimes-ul ee-event-datetimes-ul--{$cols}";
576
-			$html = '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="'. $ul_class.'">';
576
+			$html = '<ul id="ee-event-datetimes-ul-'.esc_attr($post->ID).'" class="'.$ul_class.'">';
577 577
 
578 578
             foreach ($datetimes as $datetime) {
579 579
                 if ($datetime instanceof EE_Datetime) {
@@ -582,36 +582,36 @@  discard block
 block discarded – undo
582 582
                     $datetime_html        = ! empty($datetime_name)
583 583
                         ? '
584 584
                         <strong class="ee-event-datetimes-li-date-name">
585
-                          ' . esc_html($datetime_name) . '
585
+                          ' . esc_html($datetime_name).'
586 586
                        </strong>' . $newline
587 587
                         : '';
588 588
 
589 589
                     $datetime_html .= '
590 590
                         <span class="ee-event-datetimes-li-daterange">
591 591
 							<span class="dashicons dashicons-calendar"></span>&nbsp;'
592
-							. $datetime->date_range($date_format). '
592
+							. $datetime->date_range($date_format).'
593 593
 						</span>
594 594
                         <br/>
595 595
                         <span class="ee-event-datetimes-li-timerange">
596 596
 							<span class="dashicons dashicons-clock"></span>&nbsp;'
597
-							. $datetime->time_range($time_format) . '
597
+							. $datetime->time_range($time_format).'
598 598
 						</span>
599 599
                         ';
600 600
 
601 601
                     $venue = $datetime->venue();
602 602
                     if ($venue instanceof EE_Venue) {
603
-                    	$venue_name      = esc_html($venue->name());
603
+                    	$venue_name = esc_html($venue->name());
604 604
                         $datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">';
605 605
                         $datetime_html .= '<span class="dashicons dashicons-admin-home"></span>&nbsp;';
606
-                        $datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">';
607
-                        $datetime_html .= $venue_name . '</a></span>';
606
+                        $datetime_html .= '<a href="'.esc_url_raw($venue->get_permalink()).'" target="_blank">';
607
+                        $datetime_html .= $venue_name.'</a></span>';
608 608
                     }
609 609
 
610 610
                     $datetime_description = $datetime->description();
611 611
                     $datetime_html .= ! empty($datetime_description)
612 612
                         ? '
613 613
                         <span class="ee-event-datetimes-li-date-desc">
614
-                            ' . wp_kses($datetime_description, $allowedtags) . '
614
+                            ' . wp_kses($datetime_description, $allowedtags).'
615 615
                         </span>' . $newline
616 616
                         : '';
617 617
 
@@ -623,11 +623,11 @@  discard block
 block discarded – undo
623 623
                     );
624 624
 
625 625
                     $DTD_ID        = esc_attr($datetime->ID());
626
-                    $active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status());
626
+                    $active_status = esc_attr('ee-event-datetimes-li-'.$datetime->get_active_status());
627 627
 
628 628
                     $html .= '
629
-                    <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li ' . $active_status . '">
630
-                        ' . $datetime_html . '
629
+                    <li id="ee-event-datetimes-li-' . $DTD_ID.'" class="ee-event-datetimes-li '.$active_status.'">
630
+                        ' . $datetime_html.'
631 631
                     </li>';
632 632
                 }
633 633
             }
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
                 ' . esc_html__(
642 642
                     'There are no upcoming dates for this event.',
643 643
                     'event_espresso'
644
-                ) . '
644
+                ).'
645 645
             </p>
646 646
             <br/>';
647 647
         }
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 }
655 655
 
656 656
 
657
-if (! function_exists('espresso_event_end_date')) {
657
+if ( ! function_exists('espresso_event_end_date')) {
658 658
     /**
659 659
      * espresso_event_end_date
660 660
      * returns the last date for an event
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     }
682 682
 }
683 683
 
684
-if (! function_exists('espresso_event_date_range')) {
684
+if ( ! function_exists('espresso_event_date_range')) {
685 685
     /**
686 686
      * espresso_event_date_range
687 687
      * returns the first and last chronologically ordered dates for an event (if different)
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
     }
740 740
 }
741 741
 
742
-if (! function_exists('espresso_next_upcoming_datetime_obj')) {
742
+if ( ! function_exists('espresso_next_upcoming_datetime_obj')) {
743 743
     /**
744 744
      * espresso_next_upcoming_datetime_obj
745 745
      * returns the next upcoming datetime object for an event
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
     }
755 755
 }
756 756
 
757
-if (! function_exists('espresso_next_upcoming_datetime')) {
757
+if ( ! function_exists('espresso_next_upcoming_datetime')) {
758 758
     /**
759 759
      * espresso_next_upcoming_datetime
760 760
      * returns the start date and time for the next upcoming event.
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
         $time_format = ! empty($time_format) ? $time_format : get_option('time_format');
777 777
         $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format);
778 778
 
779
-        $datetime_format = trim($date_format . ' ' . $time_format);
779
+        $datetime_format = trim($date_format.' '.$time_format);
780 780
 
781 781
         $datetime = espresso_next_upcoming_datetime_obj($EVT_ID);
782 782
 
783
-        if (! $datetime instanceof EE_Datetime) {
783
+        if ( ! $datetime instanceof EE_Datetime) {
784 784
             return '';
785 785
         }
786 786
         if ($echo) {
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     }
792 792
 }
793 793
 
794
-if (! function_exists('espresso_event_date_as_calendar_page')) {
794
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
795 795
     /**
796 796
      * espresso_event_date_as_calendar_page
797 797
      * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 }
809 809
 
810 810
 
811
-if (! function_exists('espresso_event_link_url')) {
811
+if ( ! function_exists('espresso_event_link_url')) {
812 812
     /**
813 813
      * espresso_event_link_url
814 814
      *
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 }
830 830
 
831 831
 
832
-if (! function_exists('espresso_event_has_content_or_excerpt')) {
832
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
833 833
     /**
834 834
      *    espresso_event_has_content_or_excerpt
835 835
      *
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 }
847 847
 
848 848
 
849
-if (! function_exists('espresso_event_content_or_excerpt')) {
849
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
850 850
     /**
851 851
      * espresso_event_content_or_excerpt
852 852
      *
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 }
867 867
 
868 868
 
869
-if (! function_exists('espresso_event_phone')) {
869
+if ( ! function_exists('espresso_event_phone')) {
870 870
     /**
871 871
      * espresso_event_phone
872 872
      *
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 }
888 888
 
889 889
 
890
-if (! function_exists('espresso_edit_event_link')) {
890
+if ( ! function_exists('espresso_edit_event_link')) {
891 891
     /**
892 892
      * espresso_edit_event_link
893 893
      * returns a link to edit an event
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 }
910 910
 
911 911
 
912
-if (! function_exists('espresso_organization_name')) {
912
+if ( ! function_exists('espresso_organization_name')) {
913 913
     /**
914 914
      * espresso_organization_name
915 915
      *
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
     }
928 928
 }
929 929
 
930
-if (! function_exists('espresso_organization_address')) {
930
+if ( ! function_exists('espresso_organization_address')) {
931 931
     /**
932 932
      * espresso_organization_address
933 933
      *
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
     }
952 952
 }
953 953
 
954
-if (! function_exists('espresso_organization_email')) {
954
+if ( ! function_exists('espresso_organization_email')) {
955 955
     /**
956 956
      * espresso_organization_email
957 957
      *
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
     }
970 970
 }
971 971
 
972
-if (! function_exists('espresso_organization_logo_url')) {
972
+if ( ! function_exists('espresso_organization_logo_url')) {
973 973
     /**
974 974
      * espresso_organization_logo_url
975 975
      *
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
     }
988 988
 }
989 989
 
990
-if (! function_exists('espresso_organization_facebook')) {
990
+if ( ! function_exists('espresso_organization_facebook')) {
991 991
     /**
992 992
      * espresso_organization_facebook
993 993
      *
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
     }
1006 1006
 }
1007 1007
 
1008
-if (! function_exists('espresso_organization_twitter')) {
1008
+if ( ! function_exists('espresso_organization_twitter')) {
1009 1009
     /**
1010 1010
      * espresso_organization_twitter
1011 1011
      *
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
     }
1024 1024
 }
1025 1025
 
1026
-if (! function_exists('espresso_organization_linkedin')) {
1026
+if ( ! function_exists('espresso_organization_linkedin')) {
1027 1027
     /**
1028 1028
      * espresso_organization_linkedin
1029 1029
      *
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
     }
1042 1042
 }
1043 1043
 
1044
-if (! function_exists('espresso_organization_pinterest')) {
1044
+if ( ! function_exists('espresso_organization_pinterest')) {
1045 1045
     /**
1046 1046
      * espresso_organization_pinterest
1047 1047
      *
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
     }
1060 1060
 }
1061 1061
 
1062
-if (! function_exists('espresso_organization_google')) {
1062
+if ( ! function_exists('espresso_organization_google')) {
1063 1063
     /**
1064 1064
      * espresso_organization_google
1065 1065
      *
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
     }
1078 1078
 }
1079 1079
 
1080
-if (! function_exists('espresso_organization_instagram')) {
1080
+if ( ! function_exists('espresso_organization_instagram')) {
1081 1081
     /**
1082 1082
      * espresso_organization_instagram
1083 1083
      *
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 /*************************** EEH_Venue_View ***************************/
1100 1100
 
1101 1101
 
1102
-if (! function_exists('espresso_event_venues')) {
1102
+if ( ! function_exists('espresso_event_venues')) {
1103 1103
     /**
1104 1104
      * espresso_event_venues
1105 1105
      *
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 }
1115 1115
 
1116 1116
 
1117
-if (! function_exists('espresso_venue_id')) {
1117
+if ( ! function_exists('espresso_venue_id')) {
1118 1118
     /**
1119 1119
      *    espresso_venue_name
1120 1120
      *
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 }
1133 1133
 
1134 1134
 
1135
-if (! function_exists('espresso_is_venue_private')) {
1135
+if ( ! function_exists('espresso_is_venue_private')) {
1136 1136
     /**
1137 1137
      * Return whether a venue is private or not.
1138 1138
      *
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 }
1151 1151
 
1152 1152
 
1153
-if (! function_exists('espresso_venue_is_password_protected')) {
1153
+if ( ! function_exists('espresso_venue_is_password_protected')) {
1154 1154
     /**
1155 1155
      * returns true or false if a venue is password protected or not
1156 1156
      *
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 }
1168 1168
 
1169 1169
 
1170
-if (! function_exists('espresso_password_protected_venue_form')) {
1170
+if ( ! function_exists('espresso_password_protected_venue_form')) {
1171 1171
     /**
1172 1172
      * Returns a password form if venue is password protected.
1173 1173
      *
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 }
1185 1185
 
1186 1186
 
1187
-if (! function_exists('espresso_venue_name')) {
1187
+if ( ! function_exists('espresso_venue_name')) {
1188 1188
     /**
1189 1189
      *    espresso_venue_name
1190 1190
      *
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 }
1208 1208
 
1209 1209
 
1210
-if (! function_exists('espresso_venue_link')) {
1210
+if ( ! function_exists('espresso_venue_link')) {
1211 1211
     /**
1212 1212
      *    espresso_venue_link
1213 1213
      *
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 }
1226 1226
 
1227 1227
 
1228
-if (! function_exists('espresso_venue_description')) {
1228
+if ( ! function_exists('espresso_venue_description')) {
1229 1229
     /**
1230 1230
      *    espresso_venue_description
1231 1231
      *
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 }
1248 1248
 
1249 1249
 
1250
-if (! function_exists('espresso_venue_excerpt')) {
1250
+if ( ! function_exists('espresso_venue_excerpt')) {
1251 1251
     /**
1252 1252
      *    espresso_venue_excerpt
1253 1253
      *
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 }
1270 1270
 
1271 1271
 
1272
-if (! function_exists('espresso_venue_categories')) {
1272
+if ( ! function_exists('espresso_venue_categories')) {
1273 1273
     /**
1274 1274
      * espresso_venue_categories
1275 1275
      * returns the terms associated with a venue
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 }
1293 1293
 
1294 1294
 
1295
-if (! function_exists('espresso_venue_address')) {
1295
+if ( ! function_exists('espresso_venue_address')) {
1296 1296
     /**
1297 1297
      * espresso_venue_address
1298 1298
      * returns a formatted block of html  for displaying a venue's address
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
 }
1316 1316
 
1317 1317
 
1318
-if (! function_exists('espresso_venue_raw_address')) {
1318
+if ( ! function_exists('espresso_venue_raw_address')) {
1319 1319
     /**
1320 1320
      * espresso_venue_address
1321 1321
      * returns an UN-formatted string containing a venue's address
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 }
1339 1339
 
1340 1340
 
1341
-if (! function_exists('espresso_venue_has_address')) {
1341
+if ( ! function_exists('espresso_venue_has_address')) {
1342 1342
     /**
1343 1343
      * espresso_venue_has_address
1344 1344
      * returns TRUE or FALSE if a Venue has address information
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 }
1356 1356
 
1357 1357
 
1358
-if (! function_exists('espresso_venue_gmap')) {
1358
+if ( ! function_exists('espresso_venue_gmap')) {
1359 1359
     /**
1360 1360
      * espresso_venue_gmap
1361 1361
      * returns a google map for the venue address
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 }
1380 1380
 
1381 1381
 
1382
-if (! function_exists('espresso_venue_phone')) {
1382
+if ( ! function_exists('espresso_venue_phone')) {
1383 1383
     /**
1384 1384
      * espresso_venue_phone
1385 1385
      *
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 }
1401 1401
 
1402 1402
 
1403
-if (! function_exists('espresso_venue_website')) {
1403
+if ( ! function_exists('espresso_venue_website')) {
1404 1404
     /**
1405 1405
      * espresso_venue_website
1406 1406
      *
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 }
1422 1422
 
1423 1423
 
1424
-if (! function_exists('espresso_edit_venue_link')) {
1424
+if ( ! function_exists('espresso_edit_venue_link')) {
1425 1425
     /**
1426 1426
      * espresso_edit_venue_link
1427 1427
      *
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -37,138 +37,138 @@
 block discarded – undo
37 37
  * @since           4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time.
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time.
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
 <div class="error">
49 49
 	<p>
50 50
 		<?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
 	</p>
56 56
 </div>
57 57
 <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
 <div class="error">
74 74
 	<p>
75 75
 		<?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
-                    );
86
-                    ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
+					);
86
+					?>
87 87
 	</p>
88 88
 </div>
89 89
 <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96 96
 
97
-        require_once __DIR__ . '/vendor/autoload.php';
97
+		require_once __DIR__ . '/vendor/autoload.php';
98 98
 
99
-        /**
100
-         * espresso_version
101
-         * Returns the plugin version
102
-         *
103
-         * @return string
104
-         */
105
-        function espresso_version(): string
106
-        {
107
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.19.rc.000');
108
-        }
99
+		/**
100
+		 * espresso_version
101
+		 * Returns the plugin version
102
+		 *
103
+		 * @return string
104
+		 */
105
+		function espresso_version(): string
106
+		{
107
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.19.rc.000');
108
+		}
109 109
 
110
-        /**
111
-         * espresso_plugin_activation
112
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
-         */
114
-        function espresso_plugin_activation()
115
-        {
116
-            update_option('ee_espresso_activation', true);
117
-            update_option('event-espresso-core_allow_tracking', 'no');
118
-            update_option('event-espresso-core_tracking_notice', 'hide');
119
-            // Run WP GraphQL activation callback
120
-            espressoLoadWpGraphQL();
121
-            graphql_activation_callback();
122
-        }
110
+		/**
111
+		 * espresso_plugin_activation
112
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
+		 */
114
+		function espresso_plugin_activation()
115
+		{
116
+			update_option('ee_espresso_activation', true);
117
+			update_option('event-espresso-core_allow_tracking', 'no');
118
+			update_option('event-espresso-core_tracking_notice', 'hide');
119
+			// Run WP GraphQL activation callback
120
+			espressoLoadWpGraphQL();
121
+			graphql_activation_callback();
122
+		}
123 123
 
124
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
124
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
125 125
 
126
-        /**
127
-         * espresso_plugin_deactivation
128
-         */
129
-        function espresso_plugin_deactivation()
130
-        {
131
-            // Run WP GraphQL deactivation callback
132
-            espressoLoadWpGraphQL();
133
-            graphql_deactivation_callback();
134
-            delete_option('event-espresso-core_allow_tracking');
135
-            delete_option('event-espresso-core_tracking_notice');
136
-        }
137
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
126
+		/**
127
+		 * espresso_plugin_deactivation
128
+		 */
129
+		function espresso_plugin_deactivation()
130
+		{
131
+			// Run WP GraphQL deactivation callback
132
+			espressoLoadWpGraphQL();
133
+			graphql_deactivation_callback();
134
+			delete_option('event-espresso-core_allow_tracking');
135
+			delete_option('event-espresso-core_tracking_notice');
136
+		}
137
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
138 138
 
139
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
140
-        bootstrap_espresso();
141
-    }
139
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
140
+		bootstrap_espresso();
141
+	}
142 142
 }
143 143
 
144 144
 if (! function_exists('espresso_deactivate_plugin')) {
145
-    /**
146
-     *    deactivate_plugin
147
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
-     *
149
-     * @access public
150
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
-     * @return    void
152
-     */
153
-    function espresso_deactivate_plugin(string $plugin_basename = '')
154
-    {
155
-        if (! function_exists('deactivate_plugins')) {
156
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
-        }
158
-        unset($_GET['activate'], $_REQUEST['activate']);
159
-        deactivate_plugins($plugin_basename);
160
-    }
145
+	/**
146
+	 *    deactivate_plugin
147
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
+	 *
149
+	 * @access public
150
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
+	 * @return    void
152
+	 */
153
+	function espresso_deactivate_plugin(string $plugin_basename = '')
154
+	{
155
+		if (! function_exists('deactivate_plugins')) {
156
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
+		}
158
+		unset($_GET['activate'], $_REQUEST['activate']);
159
+		deactivate_plugins($plugin_basename);
160
+	}
161 161
 }
162 162
 
163 163
 
164 164
 if (! function_exists('espressoLoadWpGraphQL')) {
165
-    function espressoLoadWpGraphQL()
166
-    {
167
-        if (
168
-            ! class_exists('WPGraphQL')
169
-            && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
-        ) {
171
-            require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
-        }
173
-    }
165
+	function espressoLoadWpGraphQL()
166
+	{
167
+		if (
168
+			! class_exists('WPGraphQL')
169
+			&& is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
+		) {
171
+			require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
+		}
173
+	}
174 174
 }
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1242 added lines, -1242 removed lines patch added patch discarded remove patch
@@ -16,1313 +16,1313 @@
 block discarded – undo
16 16
  */
17 17
 class Extend_Registrations_Admin_Page extends Registrations_Admin_Page
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 = [];
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 = [];
25 25
 
26 26
 
27
-    /**
28
-     * Extend_Registrations_Admin_Page constructor.
29
-     *
30
-     * @param bool $routing
31
-     * @throws EE_Error
32
-     * @throws ReflectionException
33
-     */
34
-    public function __construct($routing = true)
35
-    {
36
-        parent::__construct($routing);
37
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
-        }
42
-    }
27
+	/**
28
+	 * Extend_Registrations_Admin_Page constructor.
29
+	 *
30
+	 * @param bool $routing
31
+	 * @throws EE_Error
32
+	 * @throws ReflectionException
33
+	 */
34
+	public function __construct($routing = true)
35
+	{
36
+		parent::__construct($routing);
37
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
38
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
+		}
42
+	}
43 43
 
44 44
 
45
-    protected function _set_page_config()
46
-    {
47
-        parent::_set_page_config();
45
+	protected function _set_page_config()
46
+	{
47
+		parent::_set_page_config();
48 48
 
49
-        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
50
-        $reg_id                                           =
51
-            ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
52
-                ? $this->_req_data['_REG_ID']
53
-                : 0;
54
-        $new_page_routes                                  = [
55
-            'reports'                      => [
56
-                'func'       => '_registration_reports',
57
-                'capability' => 'ee_read_registrations',
58
-            ],
59
-            'registration_checkins'        => [
60
-                'func'       => '_registration_checkin_list_table',
61
-                'capability' => 'ee_read_checkins',
62
-            ],
63
-            'newsletter_selected_send'     => [
64
-                'func'       => '_newsletter_selected_send',
65
-                'noheader'   => true,
66
-                'capability' => 'ee_send_message',
67
-            ],
68
-            'delete_checkin_rows'          => [
69
-                'func'       => '_delete_checkin_rows',
70
-                'noheader'   => true,
71
-                'capability' => 'ee_delete_checkins',
72
-            ],
73
-            'delete_checkin_row'           => [
74
-                'func'       => '_delete_checkin_row',
75
-                'noheader'   => true,
76
-                'capability' => 'ee_delete_checkin',
77
-                'obj_id'     => $reg_id,
78
-            ],
79
-            'toggle_checkin_status'        => [
80
-                'func'       => '_toggle_checkin_status',
81
-                'noheader'   => true,
82
-                'capability' => 'ee_edit_checkin',
83
-                'obj_id'     => $reg_id,
84
-            ],
85
-            'toggle_checkin_status_bulk'   => [
86
-                'func'       => '_toggle_checkin_status',
87
-                'noheader'   => true,
88
-                'capability' => 'ee_edit_checkins',
89
-            ],
90
-            'event_registrations'          => [
91
-                'func'       => '_event_registrations_list_table',
92
-                'capability' => 'ee_read_checkins',
93
-            ],
94
-            'registrations_checkin_report' => [
95
-                'func'       => '_registrations_checkin_report',
96
-                'noheader'   => true,
97
-                'capability' => 'ee_read_registrations',
98
-            ],
99
-        ];
100
-        $this->_page_routes                               = array_merge($this->_page_routes, $new_page_routes);
101
-        $new_page_config                                  = [
102
-            'reports'               => [
103
-                'nav'           => [
104
-                    'label' => esc_html__('Reports', 'event_espresso'),
105
-                    'icon'  => 'dashicons-chart-bar',
106
-                    'order' => 30,
107
-                ],
108
-                'help_tabs'     => [
109
-                    'registrations_reports_help_tab' => [
110
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
-                        'filename' => 'registrations_reports',
112
-                    ],
113
-                ],
114
-                'require_nonce' => false,
115
-            ],
116
-            'event_registrations'   => [
117
-                'nav'           => [
118
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
119
-                    'icon'       => 'dashicons-yes-alt',
120
-                    'order'      => 10,
121
-                    'persistent' => true,
122
-                ],
123
-                'help_tabs'     => [
124
-                    'registrations_event_checkin_help_tab'                       => [
125
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
-                        'filename' => 'registrations_event_checkin',
127
-                    ],
128
-                    'registrations_event_checkin_table_column_headings_help_tab' => [
129
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
-                        'filename' => 'registrations_event_checkin_table_column_headings',
131
-                    ],
132
-                    'registrations_event_checkin_filters_help_tab'               => [
133
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
-                        'filename' => 'registrations_event_checkin_filters',
135
-                    ],
136
-                    'registrations_event_checkin_views_help_tab'                 => [
137
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
-                        'filename' => 'registrations_event_checkin_views',
139
-                    ],
140
-                    'registrations_event_checkin_other_help_tab'                 => [
141
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
-                        'filename' => 'registrations_event_checkin_other',
143
-                    ],
144
-                ],
145
-                'list_table'    => 'EE_Event_Registrations_List_Table',
146
-                'metaboxes'     => [],
147
-                'require_nonce' => false,
148
-            ],
149
-            'registration_checkins' => [
150
-                'nav'           => [
151
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
-                    'icon'       => 'dashicons-list-view',
153
-                    'order'      => 15,
154
-                    'persistent' => false,
155
-                    'url'        => '',
156
-                ],
157
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
-                'metaboxes'     => [],
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
-    }
49
+		$this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
50
+		$reg_id                                           =
51
+			! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
52
+				? $this->_req_data['_REG_ID']
53
+				: 0;
54
+		$new_page_routes                                  = [
55
+			'reports'                      => [
56
+				'func'       => '_registration_reports',
57
+				'capability' => 'ee_read_registrations',
58
+			],
59
+			'registration_checkins'        => [
60
+				'func'       => '_registration_checkin_list_table',
61
+				'capability' => 'ee_read_checkins',
62
+			],
63
+			'newsletter_selected_send'     => [
64
+				'func'       => '_newsletter_selected_send',
65
+				'noheader'   => true,
66
+				'capability' => 'ee_send_message',
67
+			],
68
+			'delete_checkin_rows'          => [
69
+				'func'       => '_delete_checkin_rows',
70
+				'noheader'   => true,
71
+				'capability' => 'ee_delete_checkins',
72
+			],
73
+			'delete_checkin_row'           => [
74
+				'func'       => '_delete_checkin_row',
75
+				'noheader'   => true,
76
+				'capability' => 'ee_delete_checkin',
77
+				'obj_id'     => $reg_id,
78
+			],
79
+			'toggle_checkin_status'        => [
80
+				'func'       => '_toggle_checkin_status',
81
+				'noheader'   => true,
82
+				'capability' => 'ee_edit_checkin',
83
+				'obj_id'     => $reg_id,
84
+			],
85
+			'toggle_checkin_status_bulk'   => [
86
+				'func'       => '_toggle_checkin_status',
87
+				'noheader'   => true,
88
+				'capability' => 'ee_edit_checkins',
89
+			],
90
+			'event_registrations'          => [
91
+				'func'       => '_event_registrations_list_table',
92
+				'capability' => 'ee_read_checkins',
93
+			],
94
+			'registrations_checkin_report' => [
95
+				'func'       => '_registrations_checkin_report',
96
+				'noheader'   => true,
97
+				'capability' => 'ee_read_registrations',
98
+			],
99
+		];
100
+		$this->_page_routes                               = array_merge($this->_page_routes, $new_page_routes);
101
+		$new_page_config                                  = [
102
+			'reports'               => [
103
+				'nav'           => [
104
+					'label' => esc_html__('Reports', 'event_espresso'),
105
+					'icon'  => 'dashicons-chart-bar',
106
+					'order' => 30,
107
+				],
108
+				'help_tabs'     => [
109
+					'registrations_reports_help_tab' => [
110
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
+						'filename' => 'registrations_reports',
112
+					],
113
+				],
114
+				'require_nonce' => false,
115
+			],
116
+			'event_registrations'   => [
117
+				'nav'           => [
118
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
119
+					'icon'       => 'dashicons-yes-alt',
120
+					'order'      => 10,
121
+					'persistent' => true,
122
+				],
123
+				'help_tabs'     => [
124
+					'registrations_event_checkin_help_tab'                       => [
125
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
+						'filename' => 'registrations_event_checkin',
127
+					],
128
+					'registrations_event_checkin_table_column_headings_help_tab' => [
129
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
+						'filename' => 'registrations_event_checkin_table_column_headings',
131
+					],
132
+					'registrations_event_checkin_filters_help_tab'               => [
133
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
+						'filename' => 'registrations_event_checkin_filters',
135
+					],
136
+					'registrations_event_checkin_views_help_tab'                 => [
137
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
+						'filename' => 'registrations_event_checkin_views',
139
+					],
140
+					'registrations_event_checkin_other_help_tab'                 => [
141
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
+						'filename' => 'registrations_event_checkin_other',
143
+					],
144
+				],
145
+				'list_table'    => 'EE_Event_Registrations_List_Table',
146
+				'metaboxes'     => [],
147
+				'require_nonce' => false,
148
+			],
149
+			'registration_checkins' => [
150
+				'nav'           => [
151
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
+					'icon'       => 'dashicons-list-view',
153
+					'order'      => 15,
154
+					'persistent' => false,
155
+					'url'        => '',
156
+				],
157
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
+				'metaboxes'     => [],
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', [$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', [$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
-            wp_enqueue_style(
187
-                'ee_message_shortcodes',
188
-                EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css',
189
-                [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN],
190
-                EVENT_ESPRESSO_VERSION
191
-            );
192
-            // enqueue newsletter js
193
-            wp_enqueue_script(
194
-                'ee-newsletter-trigger',
195
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
196
-                ['ee-dialog'],
197
-                EVENT_ESPRESSO_VERSION,
198
-                true
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
-                [$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
+			wp_enqueue_style(
187
+				'ee_message_shortcodes',
188
+				EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css',
189
+				[EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN],
190
+				EVENT_ESPRESSO_VERSION
191
+			);
192
+			// enqueue newsletter js
193
+			wp_enqueue_script(
194
+				'ee-newsletter-trigger',
195
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
196
+				['ee-dialog'],
197
+				EVENT_ESPRESSO_VERSION,
198
+				true
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
+				[$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
-            ['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
+			['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 = [
254
-            'all' => [
255
-                'slug'        => 'all',
256
-                'label'       => esc_html__('All', 'event_espresso'),
257
-                'count'       => 0,
258
-                'bulk_action' => ! isset($this->_req_data['event_id'])
259
-                    ? []
260
-                    : [
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 = [
254
+			'all' => [
255
+				'slug'        => 'all',
256
+				'label'       => esc_html__('All', 'event_espresso'),
257
+				'count'       => 0,
258
+				'bulk_action' => ! isset($this->_req_data['event_id'])
259
+					? []
260
+					: [
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 = [
274
-            'all' => [
275
-                'slug'        => 'all',
276
-                'label'       => esc_html__('All', 'event_espresso'),
277
-                'count'       => 0,
278
-                'bulk_action' => ['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 = [
274
+			'all' => [
275
+				'slug'        => 'all',
276
+				'label'       => esc_html__('All', 'event_espresso'),
277
+				'count'       => 0,
278
+				'bulk_action' => ['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
-     * @return void (JSON)
288
-     * @throws EE_Error
289
-     * @throws InvalidArgumentException
290
-     * @throws InvalidDataTypeException
291
-     * @throws InvalidInterfaceException
292
-     * @throws ReflectionException
293
-     * @since 4.3.0
294
-     */
295
-    public function get_newsletter_form_content()
296
-    {
297
-        // do a nonce check cause we're not coming in from an normal route here.
298
-        $nonce     = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
-            $this->_req_data['get_newsletter_form_content_nonce']
300
-        ) : '';
301
-        $nonce_ref = 'get_newsletter_form_content_nonce';
302
-        $this->_verify_nonce($nonce, $nonce_ref);
303
-        // let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
305
-            EE_Error::add_error(
306
-                esc_html__(
307
-                    '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).',
308
-                    'event_espresso'
309
-                ),
310
-                __FILE__,
311
-                __FUNCTION__,
312
-                __LINE__
313
-            );
314
-            $this->_template_args['success'] = false;
315
-            $this->_template_args['error']   = true;
316
-            $this->_return_json();
317
-        }
318
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
320
-            EE_Error::add_error(
321
-                sprintf(
322
-                    esc_html__(
323
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
-                        'event_espresso'
325
-                    ),
326
-                    $this->_req_data['GRP_ID']
327
-                ),
328
-                __FILE__,
329
-                __FUNCTION__,
330
-                __LINE__
331
-            );
332
-            $this->_template_args['success'] = false;
333
-            $this->_template_args['error']   = true;
334
-            $this->_return_json();
335
-        }
336
-        $MTPs            = $MTPG->context_templates();
337
-        $MTPs            = $MTPs['attendee'];
338
-        $template_fields = [];
339
-        /** @var EE_Message_Template $MTP */
340
-        foreach ($MTPs as $MTP) {
341
-            $field = $MTP->get('MTP_template_field');
342
-            if ($field === 'content') {
343
-                $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
345
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
346
-                }
347
-                continue;
348
-            }
349
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
350
-        }
351
-        $this->_template_args['success'] = true;
352
-        $this->_template_args['error']   = false;
353
-        $this->_template_args['data']    = [
354
-            'batch_message_from'    => $template_fields['from'] ?? '',
355
-            'batch_message_subject' => $template_fields['subject'] ?? '',
356
-            'batch_message_content' => $template_fields['newsletter_content'] ?? '',
357
-        ];
358
-        $this->_return_json();
359
-    }
284
+	/**
285
+	 * callback for ajax action.
286
+	 *
287
+	 * @return void (JSON)
288
+	 * @throws EE_Error
289
+	 * @throws InvalidArgumentException
290
+	 * @throws InvalidDataTypeException
291
+	 * @throws InvalidInterfaceException
292
+	 * @throws ReflectionException
293
+	 * @since 4.3.0
294
+	 */
295
+	public function get_newsletter_form_content()
296
+	{
297
+		// do a nonce check cause we're not coming in from an normal route here.
298
+		$nonce     = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
+			$this->_req_data['get_newsletter_form_content_nonce']
300
+		) : '';
301
+		$nonce_ref = 'get_newsletter_form_content_nonce';
302
+		$this->_verify_nonce($nonce, $nonce_ref);
303
+		// let's get the mtp for the incoming MTP_ ID
304
+		if (! isset($this->_req_data['GRP_ID'])) {
305
+			EE_Error::add_error(
306
+				esc_html__(
307
+					'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).',
308
+					'event_espresso'
309
+				),
310
+				__FILE__,
311
+				__FUNCTION__,
312
+				__LINE__
313
+			);
314
+			$this->_template_args['success'] = false;
315
+			$this->_template_args['error']   = true;
316
+			$this->_return_json();
317
+		}
318
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
+		if (! $MTPG instanceof EE_Message_Template_Group) {
320
+			EE_Error::add_error(
321
+				sprintf(
322
+					esc_html__(
323
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
+						'event_espresso'
325
+					),
326
+					$this->_req_data['GRP_ID']
327
+				),
328
+				__FILE__,
329
+				__FUNCTION__,
330
+				__LINE__
331
+			);
332
+			$this->_template_args['success'] = false;
333
+			$this->_template_args['error']   = true;
334
+			$this->_return_json();
335
+		}
336
+		$MTPs            = $MTPG->context_templates();
337
+		$MTPs            = $MTPs['attendee'];
338
+		$template_fields = [];
339
+		/** @var EE_Message_Template $MTP */
340
+		foreach ($MTPs as $MTP) {
341
+			$field = $MTP->get('MTP_template_field');
342
+			if ($field === 'content') {
343
+				$content = $MTP->get('MTP_content');
344
+				if (! empty($content['newsletter_content'])) {
345
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
346
+				}
347
+				continue;
348
+			}
349
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
350
+		}
351
+		$this->_template_args['success'] = true;
352
+		$this->_template_args['error']   = false;
353
+		$this->_template_args['data']    = [
354
+			'batch_message_from'    => $template_fields['from'] ?? '',
355
+			'batch_message_subject' => $template_fields['subject'] ?? '',
356
+			'batch_message_content' => $template_fields['newsletter_content'] ?? '',
357
+		];
358
+		$this->_return_json();
359
+	}
360 360
 
361 361
 
362
-    /**
363
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
364
-     *
365
-     * @param EE_Admin_List_Table $list_table
366
-     * @return void
367
-     * @throws InvalidArgumentException
368
-     * @throws InvalidDataTypeException
369
-     * @throws InvalidInterfaceException
370
-     * @since 4.3.0
371
-     */
372
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
373
-    {
374
-        if (
375
-        ! EE_Registry::instance()->CAP->current_user_can(
376
-            'ee_send_message',
377
-            'espresso_registrations_newsletter_selected_send'
378
-        )
379
-        ) {
380
-            return;
381
-        }
382
-        $routes_to_add_to = [
383
-            'contact_list',
384
-            'event_registrations',
385
-            'default',
386
-        ];
387
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
388
-            if (
389
-                ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
390
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
391
-            ) {
392
-                echo '';
393
-            } else {
394
-                $button_text = sprintf(
395
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
396
-                    '<span class="send-selected-newsletter-count">0</span>'
397
-                );
398
-                echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
399
-                     . '<span class="dashicons dashicons-email "></span>'
400
-                     . $button_text
401
-                     . '</button>';
402
-                add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']);
403
-            }
404
-        }
405
-    }
362
+	/**
363
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
364
+	 *
365
+	 * @param EE_Admin_List_Table $list_table
366
+	 * @return void
367
+	 * @throws InvalidArgumentException
368
+	 * @throws InvalidDataTypeException
369
+	 * @throws InvalidInterfaceException
370
+	 * @since 4.3.0
371
+	 */
372
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
373
+	{
374
+		if (
375
+		! EE_Registry::instance()->CAP->current_user_can(
376
+			'ee_send_message',
377
+			'espresso_registrations_newsletter_selected_send'
378
+		)
379
+		) {
380
+			return;
381
+		}
382
+		$routes_to_add_to = [
383
+			'contact_list',
384
+			'event_registrations',
385
+			'default',
386
+		];
387
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
388
+			if (
389
+				($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
390
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
391
+			) {
392
+				echo '';
393
+			} else {
394
+				$button_text = sprintf(
395
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
396
+					'<span class="send-selected-newsletter-count">0</span>'
397
+				);
398
+				echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
399
+					 . '<span class="dashicons dashicons-email "></span>'
400
+					 . $button_text
401
+					 . '</button>';
402
+				add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']);
403
+			}
404
+		}
405
+	}
406 406
 
407 407
 
408
-    /**
409
-     * @throws DomainException
410
-     * @throws EE_Error
411
-     * @throws InvalidArgumentException
412
-     * @throws InvalidDataTypeException
413
-     * @throws InvalidInterfaceException
414
-     * @throws ReflectionException
415
-     */
416
-    public function newsletter_send_form_skeleton()
417
-    {
418
-        $list_table = $this->_list_table_object;
419
-        $codes      = [];
420
-        // need to templates for the newsletter message type for the template selector.
421
-        $values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0];
422
-        $mtps     = EEM_Message_Template_Group::instance()->get_all(
423
-            [['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']]
424
-        );
425
-        foreach ($mtps as $mtp) {
426
-            $name     = $mtp->name();
427
-            $values[] = [
428
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
-                'id'   => $mtp->ID(),
430
-            ];
431
-        }
432
-        // need to get a list of shortcodes that are available for the newsletter message type.
433
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
434
-            'newsletter',
435
-            'email',
436
-            [],
437
-            'attendee',
438
-            false
439
-        );
408
+	/**
409
+	 * @throws DomainException
410
+	 * @throws EE_Error
411
+	 * @throws InvalidArgumentException
412
+	 * @throws InvalidDataTypeException
413
+	 * @throws InvalidInterfaceException
414
+	 * @throws ReflectionException
415
+	 */
416
+	public function newsletter_send_form_skeleton()
417
+	{
418
+		$list_table = $this->_list_table_object;
419
+		$codes      = [];
420
+		// need to templates for the newsletter message type for the template selector.
421
+		$values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0];
422
+		$mtps     = EEM_Message_Template_Group::instance()->get_all(
423
+			[['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']]
424
+		);
425
+		foreach ($mtps as $mtp) {
426
+			$name     = $mtp->name();
427
+			$values[] = [
428
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
+				'id'   => $mtp->ID(),
430
+			];
431
+		}
432
+		// need to get a list of shortcodes that are available for the newsletter message type.
433
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
434
+			'newsletter',
435
+			'email',
436
+			[],
437
+			'attendee',
438
+			false
439
+		);
440 440
 
441
-        foreach ($shortcodes as $field => $shortcode_array) {
442
-            $available_shortcodes = [];
443
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
444
-                $field_id               = $field === '[NEWSLETTER_CONTENT]'
445
-                    ? 'content'
446
-                    : strtolower($field);
447
-                $field_id               = "batch-message-$field_id";
448
-                $available_shortcodes[] = '
441
+		foreach ($shortcodes as $field => $shortcode_array) {
442
+			$available_shortcodes = [];
443
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
444
+				$field_id               = $field === '[NEWSLETTER_CONTENT]'
445
+					? 'content'
446
+					: strtolower($field);
447
+				$field_id               = "batch-message-$field_id";
448
+				$available_shortcodes[] = '
449 449
                 <span class="js-shortcode-selection"
450 450
                       data-value="' . $shortcode . '"
451 451
                       data-linked-input-id="' . $field_id . '"
452 452
                 >' . $shortcode . '</span>';
453
-            }
454
-            $codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>';
455
-        }
453
+			}
454
+			$codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>';
455
+		}
456 456
 
457
-        EEH_Template::display_template(
458
-            REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php',
459
-            [
460
-                'form_action'       => admin_url('admin.php?page=espresso_registrations'),
461
-                'form_route'        => 'newsletter_selected_send',
462
-                'form_nonce_name'   => 'newsletter_selected_send_nonce',
463
-                'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
464
-                'redirect_back_to'  => $this->_req_action,
465
-                'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
466
-                'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
467
-                'shortcodes'        => $codes,
468
-                'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
469
-            ]
470
-        );
471
-    }
457
+		EEH_Template::display_template(
458
+			REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php',
459
+			[
460
+				'form_action'       => admin_url('admin.php?page=espresso_registrations'),
461
+				'form_route'        => 'newsletter_selected_send',
462
+				'form_nonce_name'   => 'newsletter_selected_send_nonce',
463
+				'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
464
+				'redirect_back_to'  => $this->_req_action,
465
+				'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
466
+				'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
467
+				'shortcodes'        => $codes,
468
+				'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
469
+			]
470
+		);
471
+	}
472 472
 
473 473
 
474
-    /**
475
-     * Handles sending selected registrations/contacts a newsletter.
476
-     *
477
-     * @return void
478
-     * @throws EE_Error
479
-     * @throws InvalidArgumentException
480
-     * @throws InvalidDataTypeException
481
-     * @throws InvalidInterfaceException
482
-     * @throws ReflectionException
483
-     * @since  4.3.0
484
-     */
485
-    protected function _newsletter_selected_send()
486
-    {
487
-        $success = true;
488
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
-            EE_Error::add_error(
491
-                esc_html__(
492
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
-                    'event_espresso'
494
-                ),
495
-                __FILE__,
496
-                __FUNCTION__,
497
-                __LINE__
498
-            );
499
-            $success = false;
500
-        }
501
-        if ($success) {
502
-            // update Message template in case there are any changes
503
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
-                $this->_req_data['newsletter_mtp_selected']
505
-            );
506
-            $Message_Templates      = $Message_Template_Group instanceof EE_Message_Template_Group
507
-                ? $Message_Template_Group->context_templates()
508
-                : [];
509
-            if (empty($Message_Templates)) {
510
-                EE_Error::add_error(
511
-                    esc_html__(
512
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
513
-                        'event_espresso'
514
-                    ),
515
-                    __FILE__,
516
-                    __FUNCTION__,
517
-                    __LINE__
518
-                );
519
-            }
520
-            // let's just update the specific fields
521
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
522
-                if ($Message_Template instanceof EE_Message_Template) {
523
-                    $field       = $Message_Template->get('MTP_template_field');
524
-                    $content     = $Message_Template->get('MTP_content');
525
-                    $new_content = $content;
526
-                    switch ($field) {
527
-                        case 'from':
528
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
529
-                                ? $this->_req_data['batch_message']['from']
530
-                                : $content;
531
-                            break;
532
-                        case 'subject':
533
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
534
-                                ? $this->_req_data['batch_message']['subject']
535
-                                : $content;
536
-                            break;
537
-                        case 'content':
538
-                            $new_content                       = $content;
539
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
-                                ? $this->_req_data['batch_message']['content']
541
-                                : $content['newsletter_content'];
542
-                            break;
543
-                        default:
544
-                            // continue the foreach loop, we don't want to set $new_content nor save.
545
-                            continue 2;
546
-                    }
547
-                    $Message_Template->set('MTP_content', $new_content);
548
-                    $Message_Template->save();
549
-                }
550
-            }
551
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
-                ? $this->_req_data['batch_message']['id_type']
554
-                : 'registration';
555
-            // id_type will affect how we assemble the ids.
556
-            $ids                                 = ! empty($this->_req_data['batch_message']['ids'])
557
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
-                : [];
559
-            $registrations_used_for_contact_data = [];
560
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
561
-            switch ($id_type) {
562
-                case 'registration':
563
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
-                        [
565
-                            [
566
-                                'REG_ID' => ['IN', $ids],
567
-                            ],
568
-                        ]
569
-                    );
570
-                    break;
571
-                case 'contact':
572
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
573
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
574
-                                                                               $ids
575
-                                                                           );
576
-                    break;
577
-            }
578
-            do_action_ref_array(
579
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
580
-                [
581
-                    $registrations_used_for_contact_data,
582
-                    $Message_Template_Group->ID(),
583
-                ]
584
-            );
585
-            // kept for backward compat, internally we no longer use this action.
586
-            // @deprecated 4.8.36.rc.002
587
-            $contacts = $id_type === 'registration'
588
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
589
-                : EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]);
590
-            do_action_ref_array(
591
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
592
-                [
593
-                    $contacts,
594
-                    $Message_Template_Group->ID(),
595
-                ]
596
-            );
597
-        }
598
-        $query_args = [
599
-            'action' => ! empty($this->_req_data['redirect_back_to'])
600
-                ? $this->_req_data['redirect_back_to']
601
-                : 'default',
602
-        ];
603
-        $this->_redirect_after_action(false, '', '', $query_args, true);
604
-    }
474
+	/**
475
+	 * Handles sending selected registrations/contacts a newsletter.
476
+	 *
477
+	 * @return void
478
+	 * @throws EE_Error
479
+	 * @throws InvalidArgumentException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws InvalidInterfaceException
482
+	 * @throws ReflectionException
483
+	 * @since  4.3.0
484
+	 */
485
+	protected function _newsletter_selected_send()
486
+	{
487
+		$success = true;
488
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
+			EE_Error::add_error(
491
+				esc_html__(
492
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
+					'event_espresso'
494
+				),
495
+				__FILE__,
496
+				__FUNCTION__,
497
+				__LINE__
498
+			);
499
+			$success = false;
500
+		}
501
+		if ($success) {
502
+			// update Message template in case there are any changes
503
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
+				$this->_req_data['newsletter_mtp_selected']
505
+			);
506
+			$Message_Templates      = $Message_Template_Group instanceof EE_Message_Template_Group
507
+				? $Message_Template_Group->context_templates()
508
+				: [];
509
+			if (empty($Message_Templates)) {
510
+				EE_Error::add_error(
511
+					esc_html__(
512
+						'Unable to retrieve message template fields from the db. Messages not sent.',
513
+						'event_espresso'
514
+					),
515
+					__FILE__,
516
+					__FUNCTION__,
517
+					__LINE__
518
+				);
519
+			}
520
+			// let's just update the specific fields
521
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
522
+				if ($Message_Template instanceof EE_Message_Template) {
523
+					$field       = $Message_Template->get('MTP_template_field');
524
+					$content     = $Message_Template->get('MTP_content');
525
+					$new_content = $content;
526
+					switch ($field) {
527
+						case 'from':
528
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
529
+								? $this->_req_data['batch_message']['from']
530
+								: $content;
531
+							break;
532
+						case 'subject':
533
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
534
+								? $this->_req_data['batch_message']['subject']
535
+								: $content;
536
+							break;
537
+						case 'content':
538
+							$new_content                       = $content;
539
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
+								? $this->_req_data['batch_message']['content']
541
+								: $content['newsletter_content'];
542
+							break;
543
+						default:
544
+							// continue the foreach loop, we don't want to set $new_content nor save.
545
+							continue 2;
546
+					}
547
+					$Message_Template->set('MTP_content', $new_content);
548
+					$Message_Template->save();
549
+				}
550
+			}
551
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
+				? $this->_req_data['batch_message']['id_type']
554
+				: 'registration';
555
+			// id_type will affect how we assemble the ids.
556
+			$ids                                 = ! empty($this->_req_data['batch_message']['ids'])
557
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
+				: [];
559
+			$registrations_used_for_contact_data = [];
560
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
561
+			switch ($id_type) {
562
+				case 'registration':
563
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
+						[
565
+							[
566
+								'REG_ID' => ['IN', $ids],
567
+							],
568
+						]
569
+					);
570
+					break;
571
+				case 'contact':
572
+					$registrations_used_for_contact_data = EEM_Registration::instance()
573
+																		   ->get_latest_registration_for_each_of_given_contacts(
574
+																			   $ids
575
+																		   );
576
+					break;
577
+			}
578
+			do_action_ref_array(
579
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
580
+				[
581
+					$registrations_used_for_contact_data,
582
+					$Message_Template_Group->ID(),
583
+				]
584
+			);
585
+			// kept for backward compat, internally we no longer use this action.
586
+			// @deprecated 4.8.36.rc.002
587
+			$contacts = $id_type === 'registration'
588
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
589
+				: EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]);
590
+			do_action_ref_array(
591
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
592
+				[
593
+					$contacts,
594
+					$Message_Template_Group->ID(),
595
+				]
596
+			);
597
+		}
598
+		$query_args = [
599
+			'action' => ! empty($this->_req_data['redirect_back_to'])
600
+				? $this->_req_data['redirect_back_to']
601
+				: 'default',
602
+		];
603
+		$this->_redirect_after_action(false, '', '', $query_args, true);
604
+	}
605 605
 
606 606
 
607
-    /**
608
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
609
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
610
-     */
611
-    protected function _registration_reports_js_setup()
612
-    {
613
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
614
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
615
-    }
607
+	/**
608
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
609
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
610
+	 */
611
+	protected function _registration_reports_js_setup()
612
+	{
613
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
614
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
615
+	}
616 616
 
617 617
 
618
-    /**
619
-     *        generates Business Reports regarding Registrations
620
-     *
621
-     * @access protected
622
-     * @return void
623
-     * @throws DomainException
624
-     * @throws EE_Error
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
-    }
618
+	/**
619
+	 *        generates Business Reports regarding Registrations
620
+	 *
621
+	 * @access protected
622
+	 * @return void
623
+	 * @throws DomainException
624
+	 * @throws EE_Error
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
-     * @throws ReflectionException
649
-     */
650
-    private function _registrations_per_day_report($period = '-1 month')
651
-    {
652
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
653
-        $results   = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
654
-        $results   = (array) $results;
655
-        $regs      = [];
656
-        $subtitle  = '';
657
-        if ($results) {
658
-            $column_titles = [];
659
-            $tracker       = 0;
660
-            foreach ($results as $result) {
661
-                $report_column_values = [];
662
-                foreach ($result as $property_name => $property_value) {
663
-                    $property_value         = $property_name === 'Registration_REG_date' ? $property_value
664
-                        : (int) $property_value;
665
-                    $report_column_values[] = $property_value;
666
-                    if ($tracker === 0) {
667
-                        if ($property_name === 'Registration_REG_date') {
668
-                            $column_titles[] = esc_html__(
669
-                                'Date (only days with registrations are shown)',
670
-                                'event_espresso'
671
-                            );
672
-                        } else {
673
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
674
-                        }
675
-                    }
676
-                }
677
-                $tracker++;
678
-                $regs[] = $report_column_values;
679
-            }
680
-            // make sure the column_titles is pushed to the beginning of the array
681
-            array_unshift($regs, $column_titles);
682
-            // setup the date range.
683
-            $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
684
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
685
-            $ending_date    = new DateTime("now", $DateTimeZone);
686
-            $subtitle       = sprintf(
687
-                wp_strip_all_tags(
688
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
689
-                ),
690
-                $beginning_date->format('Y-m-d'),
691
-                $ending_date->format('Y-m-d')
692
-            );
693
-        }
694
-        $report_title  = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
695
-        $report_params = [
696
-            'title'     => $report_title,
697
-            'subtitle'  => $subtitle,
698
-            'id'        => $report_ID,
699
-            'regs'      => $regs,
700
-            'noResults' => empty($regs),
701
-            'noRegsMsg' => sprintf(
702
-                wp_strip_all_tags(
703
-                    __(
704
-                        '%sThere are currently no registration records in the last month for this report.%s',
705
-                        'event_espresso'
706
-                    )
707
-                ),
708
-                '<h2>' . $report_title . '</h2><p>',
709
-                '</p>'
710
-            ),
711
-        ];
712
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
713
-        return $report_ID;
714
-    }
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
+	 * @throws ReflectionException
649
+	 */
650
+	private function _registrations_per_day_report($period = '-1 month')
651
+	{
652
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
653
+		$results   = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
654
+		$results   = (array) $results;
655
+		$regs      = [];
656
+		$subtitle  = '';
657
+		if ($results) {
658
+			$column_titles = [];
659
+			$tracker       = 0;
660
+			foreach ($results as $result) {
661
+				$report_column_values = [];
662
+				foreach ($result as $property_name => $property_value) {
663
+					$property_value         = $property_name === 'Registration_REG_date' ? $property_value
664
+						: (int) $property_value;
665
+					$report_column_values[] = $property_value;
666
+					if ($tracker === 0) {
667
+						if ($property_name === 'Registration_REG_date') {
668
+							$column_titles[] = esc_html__(
669
+								'Date (only days with registrations are shown)',
670
+								'event_espresso'
671
+							);
672
+						} else {
673
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
674
+						}
675
+					}
676
+				}
677
+				$tracker++;
678
+				$regs[] = $report_column_values;
679
+			}
680
+			// make sure the column_titles is pushed to the beginning of the array
681
+			array_unshift($regs, $column_titles);
682
+			// setup the date range.
683
+			$DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
684
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
685
+			$ending_date    = new DateTime("now", $DateTimeZone);
686
+			$subtitle       = sprintf(
687
+				wp_strip_all_tags(
688
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
689
+				),
690
+				$beginning_date->format('Y-m-d'),
691
+				$ending_date->format('Y-m-d')
692
+			);
693
+		}
694
+		$report_title  = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
695
+		$report_params = [
696
+			'title'     => $report_title,
697
+			'subtitle'  => $subtitle,
698
+			'id'        => $report_ID,
699
+			'regs'      => $regs,
700
+			'noResults' => empty($regs),
701
+			'noRegsMsg' => sprintf(
702
+				wp_strip_all_tags(
703
+					__(
704
+						'%sThere are currently no registration records in the last month for this report.%s',
705
+						'event_espresso'
706
+					)
707
+				),
708
+				'<h2>' . $report_title . '</h2><p>',
709
+				'</p>'
710
+			),
711
+		];
712
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
713
+		return $report_ID;
714
+	}
715 715
 
716 716
 
717
-    /**
718
-     * Generates Business Report showing total registrations per event.
719
-     *
720
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
721
-     * @return string
722
-     * @throws EE_Error
723
-     * @throws InvalidArgumentException
724
-     * @throws InvalidDataTypeException
725
-     * @throws InvalidInterfaceException
726
-     * @throws ReflectionException
727
-     */
728
-    private function _registrations_per_event_report($period = '-1 month')
729
-    {
730
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
731
-        $results   = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
732
-        $results   = (array) $results;
733
-        $regs      = [];
734
-        $subtitle  = '';
735
-        if ($results) {
736
-            $column_titles = [];
737
-            $tracker       = 0;
738
-            foreach ($results as $result) {
739
-                $report_column_values = [];
740
-                foreach ($result as $property_name => $property_value) {
741
-                    $property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
742
-                        $property_value,
743
-                        4,
744
-                        '...'
745
-                    ) : (int) $property_value;
746
-                    $report_column_values[] = $property_value;
747
-                    if ($tracker === 0) {
748
-                        if ($property_name === 'Registration_Event') {
749
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
750
-                        } else {
751
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
752
-                        }
753
-                    }
754
-                }
755
-                $tracker++;
756
-                $regs[] = $report_column_values;
757
-            }
758
-            // make sure the column_titles is pushed to the beginning of the array
759
-            array_unshift($regs, $column_titles);
760
-            // setup the date range.
761
-            $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
762
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
763
-            $ending_date    = new DateTime("now", $DateTimeZone);
764
-            $subtitle       = sprintf(
765
-                wp_strip_all_tags(
766
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
767
-                ),
768
-                $beginning_date->format('Y-m-d'),
769
-                $ending_date->format('Y-m-d')
770
-            );
771
-        }
772
-        $report_title  = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
773
-        $report_params = [
774
-            'title'     => $report_title,
775
-            'subtitle'  => $subtitle,
776
-            'id'        => $report_ID,
777
-            'regs'      => $regs,
778
-            'noResults' => empty($regs),
779
-            'noRegsMsg' => sprintf(
780
-                wp_strip_all_tags(
781
-                    __(
782
-                        '%sThere are currently no registration records in the last month for this report.%s',
783
-                        'event_espresso'
784
-                    )
785
-                ),
786
-                '<h2>' . $report_title . '</h2><p>',
787
-                '</p>'
788
-            ),
789
-        ];
790
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
791
-        return $report_ID;
792
-    }
717
+	/**
718
+	 * Generates Business Report showing total registrations per event.
719
+	 *
720
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
721
+	 * @return string
722
+	 * @throws EE_Error
723
+	 * @throws InvalidArgumentException
724
+	 * @throws InvalidDataTypeException
725
+	 * @throws InvalidInterfaceException
726
+	 * @throws ReflectionException
727
+	 */
728
+	private function _registrations_per_event_report($period = '-1 month')
729
+	{
730
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
731
+		$results   = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
732
+		$results   = (array) $results;
733
+		$regs      = [];
734
+		$subtitle  = '';
735
+		if ($results) {
736
+			$column_titles = [];
737
+			$tracker       = 0;
738
+			foreach ($results as $result) {
739
+				$report_column_values = [];
740
+				foreach ($result as $property_name => $property_value) {
741
+					$property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
742
+						$property_value,
743
+						4,
744
+						'...'
745
+					) : (int) $property_value;
746
+					$report_column_values[] = $property_value;
747
+					if ($tracker === 0) {
748
+						if ($property_name === 'Registration_Event') {
749
+							$column_titles[] = esc_html__('Event', 'event_espresso');
750
+						} else {
751
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
752
+						}
753
+					}
754
+				}
755
+				$tracker++;
756
+				$regs[] = $report_column_values;
757
+			}
758
+			// make sure the column_titles is pushed to the beginning of the array
759
+			array_unshift($regs, $column_titles);
760
+			// setup the date range.
761
+			$DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
762
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
763
+			$ending_date    = new DateTime("now", $DateTimeZone);
764
+			$subtitle       = sprintf(
765
+				wp_strip_all_tags(
766
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
767
+				),
768
+				$beginning_date->format('Y-m-d'),
769
+				$ending_date->format('Y-m-d')
770
+			);
771
+		}
772
+		$report_title  = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
773
+		$report_params = [
774
+			'title'     => $report_title,
775
+			'subtitle'  => $subtitle,
776
+			'id'        => $report_ID,
777
+			'regs'      => $regs,
778
+			'noResults' => empty($regs),
779
+			'noRegsMsg' => sprintf(
780
+				wp_strip_all_tags(
781
+					__(
782
+						'%sThere are currently no registration records in the last month for this report.%s',
783
+						'event_espresso'
784
+					)
785
+				),
786
+				'<h2>' . $report_title . '</h2><p>',
787
+				'</p>'
788
+			),
789
+		];
790
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
791
+		return $report_ID;
792
+	}
793 793
 
794 794
 
795
-    /**
796
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
797
-     *
798
-     * @access protected
799
-     * @return void
800
-     * @throws EE_Error
801
-     * @throws InvalidArgumentException
802
-     * @throws InvalidDataTypeException
803
-     * @throws InvalidInterfaceException
804
-     * @throws EntityNotFoundException
805
-     * @throws ReflectionException
806
-     */
807
-    protected function _registration_checkin_list_table()
808
-    {
809
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
810
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
811
-        /** @var EE_Registration $registration */
812
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
813
-        if (! $registration instanceof EE_Registration) {
814
-            throw new EE_Error(
815
-                sprintf(
816
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
817
-                    $reg_id
818
-                )
819
-            );
820
-        }
821
-        $attendee                                 = $registration->attendee();
822
-        $this->_admin_page_title                  .= $this->get_action_link_or_button(
823
-            'new_registration',
824
-            'add-registrant',
825
-            ['event_id' => $registration->event_ID()],
826
-            'add-new-h2'
827
-        );
828
-        $checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
829
-        $checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
830
-        $legend_items                             = [
831
-            'checkin'  => [
832
-                'class' => $checked_in->cssClasses(),
833
-                'desc'  => $checked_in->legendLabel(),
834
-            ],
835
-            'checkout' => [
836
-                'class' => $checked_out->cssClasses(),
837
-                'desc'  => $checked_out->legendLabel(),
838
-            ],
839
-        ];
840
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
841
-        $dtt_id                                   =
842
-            isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
843
-        /** @var EE_Datetime $datetime */
844
-        $datetime       = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
845
-        $datetime_label = '';
846
-        if ($datetime instanceof EE_Datetime) {
847
-            $datetime_label = $datetime->get_dtt_display_name(true);
848
-            $datetime_label .= ! empty($datetime_label)
849
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
850
-                : $datetime->get_dtt_display_name();
851
-        }
852
-        $datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
853
-            ? EE_Admin_Page::add_query_args_and_nonce(
854
-                [
855
-                    'action'   => 'event_registrations',
856
-                    'event_id' => $registration->event_ID(),
857
-                    'DTT_ID'   => $dtt_id,
858
-                ],
859
-                $this->_admin_base_url
860
-            )
861
-            : '';
862
-        $datetime_link                                    = ! empty($datetime_link)
863
-            ? '<a href="' . $datetime_link . '">'
864
-              . '<span id="checkin-dtt">'
865
-              . $datetime_label
866
-              . '</span></a>'
867
-            : $datetime_label;
868
-        $attendee_name                                    = $attendee instanceof EE_Attendee
869
-            ? $attendee->full_name()
870
-            : '';
871
-        $attendee_link                                    = $attendee instanceof EE_Attendee
872
-            ? $attendee->get_admin_details_link()
873
-            : '';
874
-        $attendee_link                                    = ! empty($attendee_link)
875
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
876
-              . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
877
-              . '<span id="checkin-attendee-name">'
878
-              . $attendee_name
879
-              . '</span></a>'
880
-            : '';
881
-        $event_link                                       = $registration->event() instanceof EE_Event
882
-            ? $registration->event()->get_admin_details_link()
883
-            : '';
884
-        $event_link                                       = ! empty($event_link)
885
-            ? '<a href="' . $event_link . '"'
886
-              . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
887
-              . '<span id="checkin-event-name">'
888
-              . $registration->event_name()
889
-              . '</span>'
890
-              . '</a>'
891
-            : '';
892
-        $this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
893
-            ? '<h2>' . sprintf(
894
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
895
-                $attendee_link,
896
-                $datetime_link,
897
-                $event_link
898
-            ) . '</h2>'
899
-            : '';
900
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
901
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
902
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
903
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
904
-        $this->display_admin_list_table_page_with_no_sidebar();
905
-    }
795
+	/**
796
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
797
+	 *
798
+	 * @access protected
799
+	 * @return void
800
+	 * @throws EE_Error
801
+	 * @throws InvalidArgumentException
802
+	 * @throws InvalidDataTypeException
803
+	 * @throws InvalidInterfaceException
804
+	 * @throws EntityNotFoundException
805
+	 * @throws ReflectionException
806
+	 */
807
+	protected function _registration_checkin_list_table()
808
+	{
809
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
810
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
811
+		/** @var EE_Registration $registration */
812
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
813
+		if (! $registration instanceof EE_Registration) {
814
+			throw new EE_Error(
815
+				sprintf(
816
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
817
+					$reg_id
818
+				)
819
+			);
820
+		}
821
+		$attendee                                 = $registration->attendee();
822
+		$this->_admin_page_title                  .= $this->get_action_link_or_button(
823
+			'new_registration',
824
+			'add-registrant',
825
+			['event_id' => $registration->event_ID()],
826
+			'add-new-h2'
827
+		);
828
+		$checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
829
+		$checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
830
+		$legend_items                             = [
831
+			'checkin'  => [
832
+				'class' => $checked_in->cssClasses(),
833
+				'desc'  => $checked_in->legendLabel(),
834
+			],
835
+			'checkout' => [
836
+				'class' => $checked_out->cssClasses(),
837
+				'desc'  => $checked_out->legendLabel(),
838
+			],
839
+		];
840
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
841
+		$dtt_id                                   =
842
+			isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
843
+		/** @var EE_Datetime $datetime */
844
+		$datetime       = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
845
+		$datetime_label = '';
846
+		if ($datetime instanceof EE_Datetime) {
847
+			$datetime_label = $datetime->get_dtt_display_name(true);
848
+			$datetime_label .= ! empty($datetime_label)
849
+				? ' (' . $datetime->get_dtt_display_name() . ')'
850
+				: $datetime->get_dtt_display_name();
851
+		}
852
+		$datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
853
+			? EE_Admin_Page::add_query_args_and_nonce(
854
+				[
855
+					'action'   => 'event_registrations',
856
+					'event_id' => $registration->event_ID(),
857
+					'DTT_ID'   => $dtt_id,
858
+				],
859
+				$this->_admin_base_url
860
+			)
861
+			: '';
862
+		$datetime_link                                    = ! empty($datetime_link)
863
+			? '<a href="' . $datetime_link . '">'
864
+			  . '<span id="checkin-dtt">'
865
+			  . $datetime_label
866
+			  . '</span></a>'
867
+			: $datetime_label;
868
+		$attendee_name                                    = $attendee instanceof EE_Attendee
869
+			? $attendee->full_name()
870
+			: '';
871
+		$attendee_link                                    = $attendee instanceof EE_Attendee
872
+			? $attendee->get_admin_details_link()
873
+			: '';
874
+		$attendee_link                                    = ! empty($attendee_link)
875
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
876
+			  . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
877
+			  . '<span id="checkin-attendee-name">'
878
+			  . $attendee_name
879
+			  . '</span></a>'
880
+			: '';
881
+		$event_link                                       = $registration->event() instanceof EE_Event
882
+			? $registration->event()->get_admin_details_link()
883
+			: '';
884
+		$event_link                                       = ! empty($event_link)
885
+			? '<a href="' . $event_link . '"'
886
+			  . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
887
+			  . '<span id="checkin-event-name">'
888
+			  . $registration->event_name()
889
+			  . '</span>'
890
+			  . '</a>'
891
+			: '';
892
+		$this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
893
+			? '<h2>' . sprintf(
894
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
895
+				$attendee_link,
896
+				$datetime_link,
897
+				$event_link
898
+			) . '</h2>'
899
+			: '';
900
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
901
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
902
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
903
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
904
+		$this->display_admin_list_table_page_with_no_sidebar();
905
+	}
906 906
 
907 907
 
908
-    /**
909
-     * toggle the Check-in status for the given registration (coming from ajax)
910
-     *
911
-     * @return void (JSON)
912
-     * @throws EE_Error
913
-     * @throws InvalidArgumentException
914
-     * @throws InvalidDataTypeException
915
-     * @throws InvalidInterfaceException
916
-     * @throws ReflectionException
917
-     */
918
-    public function toggle_checkin_status()
919
-    {
920
-        // first make sure we have the necessary data
921
-        if (! isset($this->_req_data['_regid'])) {
922
-            EE_Error::add_error(
923
-                esc_html__(
924
-                    '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',
925
-                    'event_espresso'
926
-                ),
927
-                __FILE__,
928
-                __FUNCTION__,
929
-                __LINE__
930
-            );
931
-            $this->_template_args['success'] = false;
932
-            $this->_template_args['error']   = true;
933
-            $this->_return_json();
934
-        };
935
-        // do a nonce check cause we're not coming in from an normal route here.
936
-        $nonce     = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
937
-            : '';
938
-        $nonce_ref = 'checkin_nonce';
939
-        $this->_verify_nonce($nonce, $nonce_ref);
940
-        // beautiful! Made it this far so let's get the status.
941
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
942
-        // setup new class to return via ajax
943
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
944
-        $this->_template_args['success']            = true;
945
-        $this->_return_json();
946
-    }
908
+	/**
909
+	 * toggle the Check-in status for the given registration (coming from ajax)
910
+	 *
911
+	 * @return void (JSON)
912
+	 * @throws EE_Error
913
+	 * @throws InvalidArgumentException
914
+	 * @throws InvalidDataTypeException
915
+	 * @throws InvalidInterfaceException
916
+	 * @throws ReflectionException
917
+	 */
918
+	public function toggle_checkin_status()
919
+	{
920
+		// first make sure we have the necessary data
921
+		if (! isset($this->_req_data['_regid'])) {
922
+			EE_Error::add_error(
923
+				esc_html__(
924
+					'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',
925
+					'event_espresso'
926
+				),
927
+				__FILE__,
928
+				__FUNCTION__,
929
+				__LINE__
930
+			);
931
+			$this->_template_args['success'] = false;
932
+			$this->_template_args['error']   = true;
933
+			$this->_return_json();
934
+		};
935
+		// do a nonce check cause we're not coming in from an normal route here.
936
+		$nonce     = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
937
+			: '';
938
+		$nonce_ref = 'checkin_nonce';
939
+		$this->_verify_nonce($nonce, $nonce_ref);
940
+		// beautiful! Made it this far so let's get the status.
941
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
942
+		// setup new class to return via ajax
943
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
944
+		$this->_template_args['success']            = true;
945
+		$this->_return_json();
946
+	}
947 947
 
948 948
 
949
-    /**
950
-     * handles toggling the checkin status for the registration,
951
-     *
952
-     * @access protected
953
-     * @return int|void
954
-     * @throws EE_Error
955
-     * @throws InvalidArgumentException
956
-     * @throws InvalidDataTypeException
957
-     * @throws InvalidInterfaceException
958
-     * @throws ReflectionException
959
-     */
960
-    protected function _toggle_checkin_status()
961
-    {
962
-        // first let's get the query args out of the way for the redirect
963
-        $query_args = [
964
-            'action'   => 'event_registrations',
965
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
966
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
967
-        ];
968
-        $new_status = false;
969
-        // bulk action check in toggle
970
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
971
-            // cycle thru checkboxes
972
-            $checkboxes = $this->_req_data['checkbox'];
973
-            foreach (array_keys($checkboxes) as $REG_ID) {
974
-                $DTT_ID     = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
975
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
976
-            }
977
-        } elseif (isset($this->_req_data['_regid'])) {
978
-            // coming from ajax request
979
-            $DTT_ID               = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
980
-            $query_args['DTT_ID'] = $DTT_ID;
981
-            $new_status           = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
982
-        } else {
983
-            EE_Error::add_error(
984
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
985
-                __FILE__,
986
-                __FUNCTION__,
987
-                __LINE__
988
-            );
989
-        }
990
-        if (defined('DOING_AJAX')) {
991
-            return $new_status;
992
-        }
993
-        $this->_redirect_after_action(false, '', '', $query_args, true);
994
-    }
949
+	/**
950
+	 * handles toggling the checkin status for the registration,
951
+	 *
952
+	 * @access protected
953
+	 * @return int|void
954
+	 * @throws EE_Error
955
+	 * @throws InvalidArgumentException
956
+	 * @throws InvalidDataTypeException
957
+	 * @throws InvalidInterfaceException
958
+	 * @throws ReflectionException
959
+	 */
960
+	protected function _toggle_checkin_status()
961
+	{
962
+		// first let's get the query args out of the way for the redirect
963
+		$query_args = [
964
+			'action'   => 'event_registrations',
965
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
966
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
967
+		];
968
+		$new_status = false;
969
+		// bulk action check in toggle
970
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
971
+			// cycle thru checkboxes
972
+			$checkboxes = $this->_req_data['checkbox'];
973
+			foreach (array_keys($checkboxes) as $REG_ID) {
974
+				$DTT_ID     = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
975
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
976
+			}
977
+		} elseif (isset($this->_req_data['_regid'])) {
978
+			// coming from ajax request
979
+			$DTT_ID               = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
980
+			$query_args['DTT_ID'] = $DTT_ID;
981
+			$new_status           = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
982
+		} else {
983
+			EE_Error::add_error(
984
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
985
+				__FILE__,
986
+				__FUNCTION__,
987
+				__LINE__
988
+			);
989
+		}
990
+		if (defined('DOING_AJAX')) {
991
+			return $new_status;
992
+		}
993
+		$this->_redirect_after_action(false, '', '', $query_args, true);
994
+	}
995 995
 
996 996
 
997
-    /**
998
-     * This is toggles a single Check-in for the given registration and datetime.
999
-     *
1000
-     * @param int $REG_ID The registration we're toggling
1001
-     * @param int $DTT_ID The datetime we're toggling
1002
-     * @return int The new status toggled to.
1003
-     * @throws EE_Error
1004
-     * @throws InvalidArgumentException
1005
-     * @throws InvalidDataTypeException
1006
-     * @throws InvalidInterfaceException
1007
-     * @throws ReflectionException
1008
-     */
1009
-    private function _toggle_checkin($REG_ID, $DTT_ID)
1010
-    {
1011
-        /** @var EE_Registration $REG */
1012
-        $REG        = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1013
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
1014
-        if ($new_status !== false) {
1015
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1016
-        } else {
1017
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1018
-            $new_status = false;
1019
-        }
1020
-        return $new_status;
1021
-    }
997
+	/**
998
+	 * This is toggles a single Check-in for the given registration and datetime.
999
+	 *
1000
+	 * @param int $REG_ID The registration we're toggling
1001
+	 * @param int $DTT_ID The datetime we're toggling
1002
+	 * @return int The new status toggled to.
1003
+	 * @throws EE_Error
1004
+	 * @throws InvalidArgumentException
1005
+	 * @throws InvalidDataTypeException
1006
+	 * @throws InvalidInterfaceException
1007
+	 * @throws ReflectionException
1008
+	 */
1009
+	private function _toggle_checkin($REG_ID, $DTT_ID)
1010
+	{
1011
+		/** @var EE_Registration $REG */
1012
+		$REG        = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1013
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
1014
+		if ($new_status !== false) {
1015
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1016
+		} else {
1017
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1018
+			$new_status = false;
1019
+		}
1020
+		return $new_status;
1021
+	}
1022 1022
 
1023 1023
 
1024
-    /**
1025
-     * Takes care of deleting multiple EE_Checkin table rows
1026
-     *
1027
-     * @access protected
1028
-     * @return void
1029
-     * @throws EE_Error
1030
-     * @throws InvalidArgumentException
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidInterfaceException
1033
-     * @throws ReflectionException
1034
-     */
1035
-    protected function _delete_checkin_rows()
1036
-    {
1037
-        $query_args = [
1038
-            'action'  => 'registration_checkins',
1039
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1040
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1041
-        ];
1042
-        $errors     = 0;
1043
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1044
-            $checkboxes = $this->_req_data['checkbox'];
1045
-            foreach (array_keys($checkboxes) as $CHK_ID) {
1046
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1047
-                    $errors++;
1048
-                }
1049
-            }
1050
-        } else {
1051
-            EE_Error::add_error(
1052
-                esc_html__(
1053
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1054
-                    'event_espresso'
1055
-                ),
1056
-                __FILE__,
1057
-                __FUNCTION__,
1058
-                __LINE__
1059
-            );
1060
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1061
-        }
1062
-        if ($errors > 0) {
1063
-            EE_Error::add_error(
1064
-                sprintf(
1065
-                    esc_html__('There were %d records that did not delete successfully', 'event_espresso'),
1066
-                    $errors
1067
-                ),
1068
-                __FILE__,
1069
-                __FUNCTION__,
1070
-                __LINE__
1071
-            );
1072
-        } else {
1073
-            EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1074
-        }
1075
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1076
-    }
1024
+	/**
1025
+	 * Takes care of deleting multiple EE_Checkin table rows
1026
+	 *
1027
+	 * @access protected
1028
+	 * @return void
1029
+	 * @throws EE_Error
1030
+	 * @throws InvalidArgumentException
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidInterfaceException
1033
+	 * @throws ReflectionException
1034
+	 */
1035
+	protected function _delete_checkin_rows()
1036
+	{
1037
+		$query_args = [
1038
+			'action'  => 'registration_checkins',
1039
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1040
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1041
+		];
1042
+		$errors     = 0;
1043
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1044
+			$checkboxes = $this->_req_data['checkbox'];
1045
+			foreach (array_keys($checkboxes) as $CHK_ID) {
1046
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1047
+					$errors++;
1048
+				}
1049
+			}
1050
+		} else {
1051
+			EE_Error::add_error(
1052
+				esc_html__(
1053
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1054
+					'event_espresso'
1055
+				),
1056
+				__FILE__,
1057
+				__FUNCTION__,
1058
+				__LINE__
1059
+			);
1060
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1061
+		}
1062
+		if ($errors > 0) {
1063
+			EE_Error::add_error(
1064
+				sprintf(
1065
+					esc_html__('There were %d records that did not delete successfully', 'event_espresso'),
1066
+					$errors
1067
+				),
1068
+				__FILE__,
1069
+				__FUNCTION__,
1070
+				__LINE__
1071
+			);
1072
+		} else {
1073
+			EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1074
+		}
1075
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1076
+	}
1077 1077
 
1078 1078
 
1079
-    /**
1080
-     * Deletes a single EE_Checkin row
1081
-     *
1082
-     * @return void
1083
-     * @throws EE_Error
1084
-     * @throws InvalidArgumentException
1085
-     * @throws InvalidDataTypeException
1086
-     * @throws InvalidInterfaceException
1087
-     * @throws ReflectionException
1088
-     */
1089
-    protected function _delete_checkin_row()
1090
-    {
1091
-        $query_args = [
1092
-            'action'  => 'registration_checkins',
1093
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1094
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1095
-        ];
1096
-        if (! empty($this->_req_data['CHK_ID'])) {
1097
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1098
-                EE_Error::add_error(
1099
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1100
-                    __FILE__,
1101
-                    __FUNCTION__,
1102
-                    __LINE__
1103
-                );
1104
-            } else {
1105
-                EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1106
-            }
1107
-        } else {
1108
-            EE_Error::add_error(
1109
-                esc_html__(
1110
-                    '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',
1111
-                    'event_espresso'
1112
-                ),
1113
-                __FILE__,
1114
-                __FUNCTION__,
1115
-                __LINE__
1116
-            );
1117
-        }
1118
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1119
-    }
1079
+	/**
1080
+	 * Deletes a single EE_Checkin row
1081
+	 *
1082
+	 * @return void
1083
+	 * @throws EE_Error
1084
+	 * @throws InvalidArgumentException
1085
+	 * @throws InvalidDataTypeException
1086
+	 * @throws InvalidInterfaceException
1087
+	 * @throws ReflectionException
1088
+	 */
1089
+	protected function _delete_checkin_row()
1090
+	{
1091
+		$query_args = [
1092
+			'action'  => 'registration_checkins',
1093
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1094
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1095
+		];
1096
+		if (! empty($this->_req_data['CHK_ID'])) {
1097
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1098
+				EE_Error::add_error(
1099
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1100
+					__FILE__,
1101
+					__FUNCTION__,
1102
+					__LINE__
1103
+				);
1104
+			} else {
1105
+				EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1106
+			}
1107
+		} else {
1108
+			EE_Error::add_error(
1109
+				esc_html__(
1110
+					'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',
1111
+					'event_espresso'
1112
+				),
1113
+				__FILE__,
1114
+				__FUNCTION__,
1115
+				__LINE__
1116
+			);
1117
+		}
1118
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1119
+	}
1120 1120
 
1121 1121
 
1122
-    /**
1123
-     *        generates HTML for the Event Registrations List Table
1124
-     *
1125
-     * @access protected
1126
-     * @return void
1127
-     * @throws EE_Error
1128
-     * @throws InvalidArgumentException
1129
-     * @throws InvalidDataTypeException
1130
-     * @throws InvalidInterfaceException
1131
-     * @throws ReflectionException
1132
-     */
1133
-    protected function _event_registrations_list_table()
1134
-    {
1135
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1136
-        $this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1137
-            ? $this->get_action_link_or_button(
1138
-                'new_registration',
1139
-                'add-registrant',
1140
-                ['event_id' => $this->_req_data['event_id']],
1141
-                'add-new-h2',
1142
-                '',
1143
-                false
1144
-            )
1145
-            : '';
1146
-        $checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1147
-        $checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1148
-        $checked_never                            = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1149
-        $checkin_invalid                          = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1150
-        $legend_items                             = [
1151
-            'star-icon'        => [
1152
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1153
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1154
-            ],
1155
-            'checkin'          => [
1156
-                'class' => $checked_in->cssClasses(),
1157
-                'desc'  => $checked_in->legendLabel(),
1158
-            ],
1159
-            'checkout'         => [
1160
-                'class' => $checked_out->cssClasses(),
1161
-                'desc'  => $checked_out->legendLabel(),
1162
-            ],
1163
-            'nocheckinrecord'  => [
1164
-                'class' => $checked_never->cssClasses(),
1165
-                'desc'  => $checked_never->legendLabel(),
1166
-            ],
1167
-            'canNotCheckin'    => [
1168
-                'class' => $checkin_invalid->cssClasses(),
1169
-                'desc'  => $checkin_invalid->legendLabel(),
1170
-            ],
1171
-            'approved_status'  => [
1172
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1173
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1174
-            ],
1175
-            'cancelled_status' => [
1176
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1177
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1178
-            ],
1179
-            'declined_status'  => [
1180
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1181
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1182
-            ],
1183
-            'not_approved'     => [
1184
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1185
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1186
-            ],
1187
-            'pending_status'   => [
1188
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1189
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1190
-            ],
1191
-            'wait_list'        => [
1192
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1193
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1194
-            ],
1195
-        ];
1196
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1197
-        $event_id                                 =
1198
-            isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1199
-        /** @var EE_Event $event */
1200
-        $event                                     = EEM_Event::instance()->get_one_by_ID($event_id);
1201
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1202
-            ? '<h2>
1122
+	/**
1123
+	 *        generates HTML for the Event Registrations List Table
1124
+	 *
1125
+	 * @access protected
1126
+	 * @return void
1127
+	 * @throws EE_Error
1128
+	 * @throws InvalidArgumentException
1129
+	 * @throws InvalidDataTypeException
1130
+	 * @throws InvalidInterfaceException
1131
+	 * @throws ReflectionException
1132
+	 */
1133
+	protected function _event_registrations_list_table()
1134
+	{
1135
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1136
+		$this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1137
+			? $this->get_action_link_or_button(
1138
+				'new_registration',
1139
+				'add-registrant',
1140
+				['event_id' => $this->_req_data['event_id']],
1141
+				'add-new-h2',
1142
+				'',
1143
+				false
1144
+			)
1145
+			: '';
1146
+		$checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1147
+		$checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1148
+		$checked_never                            = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1149
+		$checkin_invalid                          = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1150
+		$legend_items                             = [
1151
+			'star-icon'        => [
1152
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1153
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1154
+			],
1155
+			'checkin'          => [
1156
+				'class' => $checked_in->cssClasses(),
1157
+				'desc'  => $checked_in->legendLabel(),
1158
+			],
1159
+			'checkout'         => [
1160
+				'class' => $checked_out->cssClasses(),
1161
+				'desc'  => $checked_out->legendLabel(),
1162
+			],
1163
+			'nocheckinrecord'  => [
1164
+				'class' => $checked_never->cssClasses(),
1165
+				'desc'  => $checked_never->legendLabel(),
1166
+			],
1167
+			'canNotCheckin'    => [
1168
+				'class' => $checkin_invalid->cssClasses(),
1169
+				'desc'  => $checkin_invalid->legendLabel(),
1170
+			],
1171
+			'approved_status'  => [
1172
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1173
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1174
+			],
1175
+			'cancelled_status' => [
1176
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1177
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1178
+			],
1179
+			'declined_status'  => [
1180
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1181
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1182
+			],
1183
+			'not_approved'     => [
1184
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1185
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1186
+			],
1187
+			'pending_status'   => [
1188
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1189
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1190
+			],
1191
+			'wait_list'        => [
1192
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1193
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1194
+			],
1195
+		];
1196
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1197
+		$event_id                                 =
1198
+			isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1199
+		/** @var EE_Event $event */
1200
+		$event                                     = EEM_Event::instance()->get_one_by_ID($event_id);
1201
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1202
+			? '<h2>
1203 1203
                 ' . sprintf(
1204
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1205
-                "<span class='ee-event-name'>{$event->name()}</span>"
1206
-            )
1207
-            : '';
1208
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1209
-        // the event.
1210
-        $DTT_ID   = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1211
-        $datetime = null;
1212
-        if ($event instanceof EE_Event) {
1213
-            $datetimes_on_event = $event->datetimes();
1214
-            if (count($datetimes_on_event) === 1) {
1215
-                $datetime = reset($datetimes_on_event);
1216
-            }
1217
-        }
1218
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1219
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1220
-            $active_status                             = $datetime->get_active_status();
1221
-            $datetime_status                           =
1222
-                '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1223
-                esc_attr($active_status) . '">'
1224
-                . EEH_Template::pretty_status($active_status, false, 'sentence')
1225
-                . '</span>';
1226
-            $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1227
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1228
-            $this->_template_args['before_list_table'] .= $datetime->name();
1229
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1230
-            $this->_template_args['before_list_table'] .= $datetime_status;
1231
-            $this->_template_args['before_list_table'] .= '</span>';
1232
-        }
1233
-        $this->_template_args['before_list_table'] .= '</h2>';
1234
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1235
-        // column represents
1236
-        if (! $datetime instanceof EE_Datetime) {
1237
-            $this->_template_args['before_list_table'] .= '
1204
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1205
+				"<span class='ee-event-name'>{$event->name()}</span>"
1206
+			)
1207
+			: '';
1208
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1209
+		// the event.
1210
+		$DTT_ID   = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1211
+		$datetime = null;
1212
+		if ($event instanceof EE_Event) {
1213
+			$datetimes_on_event = $event->datetimes();
1214
+			if (count($datetimes_on_event) === 1) {
1215
+				$datetime = reset($datetimes_on_event);
1216
+			}
1217
+		}
1218
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1219
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1220
+			$active_status                             = $datetime->get_active_status();
1221
+			$datetime_status                           =
1222
+				'<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1223
+				esc_attr($active_status) . '">'
1224
+				. EEH_Template::pretty_status($active_status, false, 'sentence')
1225
+				. '</span>';
1226
+			$this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1227
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1228
+			$this->_template_args['before_list_table'] .= $datetime->name();
1229
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1230
+			$this->_template_args['before_list_table'] .= $datetime_status;
1231
+			$this->_template_args['before_list_table'] .= '</span>';
1232
+		}
1233
+		$this->_template_args['before_list_table'] .= '</h2>';
1234
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1235
+		// column represents
1236
+		if (! $datetime instanceof EE_Datetime) {
1237
+			$this->_template_args['before_list_table'] .= '
1238 1238
                 <div class="description ee-status-outline ee-status-bg--info" style="white-space: normal;">
1239 1239
                     <h2 style="margin: 1rem; padding: 0;">' . esc_html__(
1240
-                        'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1241
-                        'event_espresso'
1242
-                    ) . '</h2>
1240
+						'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1241
+						'event_espresso'
1242
+					) . '</h2>
1243 1243
                 </div>';
1244
-        }
1245
-        $this->display_admin_list_table_page_with_no_sidebar();
1246
-    }
1244
+		}
1245
+		$this->display_admin_list_table_page_with_no_sidebar();
1246
+	}
1247 1247
 
1248 1248
 
1249
-    /**
1250
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1251
-     * conditions)
1252
-     *
1253
-     * @return void ends the request by a redirect or download
1254
-     */
1255
-    public function _registrations_checkin_report()
1256
-    {
1257
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1258
-    }
1249
+	/**
1250
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1251
+	 * conditions)
1252
+	 *
1253
+	 * @return void ends the request by a redirect or download
1254
+	 */
1255
+	public function _registrations_checkin_report()
1256
+	{
1257
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1258
+	}
1259 1259
 
1260 1260
 
1261
-    /**
1262
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1263
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1264
-     *
1265
-     * @param array $request
1266
-     * @param int   $per_page
1267
-     * @param bool  $count
1268
-     * @return array
1269
-     * @throws EE_Error
1270
-     */
1271
-    protected function _get_checkin_query_params_from_request(
1272
-        $request,
1273
-        $per_page = 10,
1274
-        $count = false
1275
-    ) {
1276
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1277
-        // unlike the regular registrations list table,
1278
-        $status_ids_array          = apply_filters(
1279
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1280
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1281
-        );
1282
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
1283
-        return $query_params;
1284
-    }
1261
+	/**
1262
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1263
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1264
+	 *
1265
+	 * @param array $request
1266
+	 * @param int   $per_page
1267
+	 * @param bool  $count
1268
+	 * @return array
1269
+	 * @throws EE_Error
1270
+	 */
1271
+	protected function _get_checkin_query_params_from_request(
1272
+		$request,
1273
+		$per_page = 10,
1274
+		$count = false
1275
+	) {
1276
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1277
+		// unlike the regular registrations list table,
1278
+		$status_ids_array          = apply_filters(
1279
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1280
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1281
+		);
1282
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
1283
+		return $query_params;
1284
+	}
1285 1285
 
1286 1286
 
1287
-    /**
1288
-     * Gets registrations for an event
1289
-     *
1290
-     * @param int    $per_page
1291
-     * @param bool   $count whether to return count or data.
1292
-     * @param bool   $trash
1293
-     * @param string $orderby
1294
-     * @return EE_Registration[]|int
1295
-     * @throws EE_Error
1296
-     * @throws InvalidArgumentException
1297
-     * @throws InvalidDataTypeException
1298
-     * @throws InvalidInterfaceException
1299
-     * @throws ReflectionException
1300
-     */
1301
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1302
-    {
1303
-        // set some defaults, these will get overridden if included in the actual request parameters
1304
-        $defaults = [
1305
-            'orderby' => $orderby,
1306
-            'order'   => 'ASC',
1307
-        ];
1308
-        if ($trash) {
1309
-            $defaults['status'] = 'trash';
1310
-        }
1311
-        $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1287
+	/**
1288
+	 * Gets registrations for an event
1289
+	 *
1290
+	 * @param int    $per_page
1291
+	 * @param bool   $count whether to return count or data.
1292
+	 * @param bool   $trash
1293
+	 * @param string $orderby
1294
+	 * @return EE_Registration[]|int
1295
+	 * @throws EE_Error
1296
+	 * @throws InvalidArgumentException
1297
+	 * @throws InvalidDataTypeException
1298
+	 * @throws InvalidInterfaceException
1299
+	 * @throws ReflectionException
1300
+	 */
1301
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1302
+	{
1303
+		// set some defaults, these will get overridden if included in the actual request parameters
1304
+		$defaults = [
1305
+			'orderby' => $orderby,
1306
+			'order'   => 'ASC',
1307
+		];
1308
+		if ($trash) {
1309
+			$defaults['status'] = 'trash';
1310
+		}
1311
+		$query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1312 1312
 
1313
-        /**
1314
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1315
-         *
1316
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1317
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1318
-         *                             or if you have the development copy of EE you can view this at the path:
1319
-         *                             /docs/G--Model-System/model-query-params.md
1320
-         */
1321
-        $query_params['group_by'] = '';
1313
+		/**
1314
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1315
+		 *
1316
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1317
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1318
+		 *                             or if you have the development copy of EE you can view this at the path:
1319
+		 *                             /docs/G--Model-System/model-query-params.md
1320
+		 */
1321
+		$query_params['group_by'] = '';
1322 1322
 
1323
-        return $count
1324
-            ? EEM_Registration::instance()->count($query_params)
1325
-            /** @type EE_Registration[] */
1326
-            : EEM_Registration::instance()->get_all($query_params);
1327
-    }
1323
+		return $count
1324
+			? EEM_Registration::instance()->count($query_params)
1325
+			/** @type EE_Registration[] */
1326
+			: EEM_Registration::instance()->get_all($query_params);
1327
+	}
1328 1328
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
     public function __construct($routing = true)
35 35
     {
36 36
         parent::__construct($routing);
37
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
37
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
39
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
40
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
41 41
         }
42 42
     }
43 43
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
     {
47 47
         parent::_set_page_config();
48 48
 
49
-        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
50 50
         $reg_id                                           =
51 51
             ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
52 52
                 ? $this->_req_data['_REG_ID']
53 53
                 : 0;
54
-        $new_page_routes                                  = [
54
+        $new_page_routes = [
55 55
             'reports'                      => [
56 56
                 'func'       => '_registration_reports',
57 57
                 'capability' => 'ee_read_registrations',
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
         if (EEH_MSG_Template::is_mt_active('newsletter')) {
186 186
             wp_enqueue_style(
187 187
                 'ee_message_shortcodes',
188
-                EE_MSG_ASSETS_URL . 'ee_message_shortcodes.css',
188
+                EE_MSG_ASSETS_URL.'ee_message_shortcodes.css',
189 189
                 [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN],
190 190
                 EVENT_ESPRESSO_VERSION
191 191
             );
192 192
             // enqueue newsletter js
193 193
             wp_enqueue_script(
194 194
                 'ee-newsletter-trigger',
195
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
195
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
196 196
                 ['ee-dialog'],
197 197
                 EVENT_ESPRESSO_VERSION,
198 198
                 true
@@ -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
             ['google-charts'],
219 219
             EVENT_ESPRESSO_VERSION,
220 220
             true
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $nonce_ref = 'get_newsletter_form_content_nonce';
302 302
         $this->_verify_nonce($nonce, $nonce_ref);
303 303
         // let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
304
+        if ( ! isset($this->_req_data['GRP_ID'])) {
305 305
             EE_Error::add_error(
306 306
                 esc_html__(
307 307
                     '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).',
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             $this->_return_json();
317 317
         }
318 318
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
320 320
             EE_Error::add_error(
321 321
                 sprintf(
322 322
                     esc_html__(
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
             $field = $MTP->get('MTP_template_field');
342 342
             if ($field === 'content') {
343 343
                 $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
344
+                if ( ! empty($content['newsletter_content'])) {
345 345
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
346 346
                 }
347 347
                 continue;
348 348
             }
349
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
+            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
350 350
         }
351 351
         $this->_template_args['success'] = true;
352 352
         $this->_template_args['error']   = false;
@@ -447,15 +447,15 @@  discard block
 block discarded – undo
447 447
                 $field_id               = "batch-message-$field_id";
448 448
                 $available_shortcodes[] = '
449 449
                 <span class="js-shortcode-selection"
450
-                      data-value="' . $shortcode . '"
451
-                      data-linked-input-id="' . $field_id . '"
452
-                >' . $shortcode . '</span>';
450
+                      data-value="' . $shortcode.'"
451
+                      data-linked-input-id="' . $field_id.'"
452
+                >' . $shortcode.'</span>';
453 453
             }
454
-            $codes[ $field ] = '<ul><li>' . implode('</li><li>', $available_shortcodes) . '</li></ul>';
454
+            $codes[$field] = '<ul><li>'.implode('</li><li>', $available_shortcodes).'</li></ul>';
455 455
         }
456 456
 
457 457
         EEH_Template::display_template(
458
-            REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php',
458
+            REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php',
459 459
             [
460 460
                 'form_action'       => admin_url('admin.php?page=espresso_registrations'),
461 461
                 '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,
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
             array_unshift($regs, $column_titles);
682 682
             // setup the date range.
683 683
             $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
684
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
684
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
685 685
             $ending_date    = new DateTime("now", $DateTimeZone);
686 686
             $subtitle       = sprintf(
687 687
                 wp_strip_all_tags(
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
                         'event_espresso'
706 706
                     )
707 707
                 ),
708
-                '<h2>' . $report_title . '</h2><p>',
708
+                '<h2>'.$report_title.'</h2><p>',
709 709
                 '</p>'
710 710
             ),
711 711
         ];
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             foreach ($results as $result) {
739 739
                 $report_column_values = [];
740 740
                 foreach ($result as $property_name => $property_value) {
741
-                    $property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
741
+                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
742 742
                         $property_value,
743 743
                         4,
744 744
                         '...'
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
             array_unshift($regs, $column_titles);
760 760
             // setup the date range.
761 761
             $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
762
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
762
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
763 763
             $ending_date    = new DateTime("now", $DateTimeZone);
764 764
             $subtitle       = sprintf(
765 765
                 wp_strip_all_tags(
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
                         'event_espresso'
784 784
                     )
785 785
                 ),
786
-                '<h2>' . $report_title . '</h2><p>',
786
+                '<h2>'.$report_title.'</h2><p>',
787 787
                 '</p>'
788 788
             ),
789 789
         ];
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
         $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
811 811
         /** @var EE_Registration $registration */
812 812
         $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
813
-        if (! $registration instanceof EE_Registration) {
813
+        if ( ! $registration instanceof EE_Registration) {
814 814
             throw new EE_Error(
815 815
                 sprintf(
816 816
                     esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
                 )
819 819
             );
820 820
         }
821
-        $attendee                                 = $registration->attendee();
822
-        $this->_admin_page_title                  .= $this->get_action_link_or_button(
821
+        $attendee = $registration->attendee();
822
+        $this->_admin_page_title .= $this->get_action_link_or_button(
823 823
             'new_registration',
824 824
             'add-registrant',
825 825
             ['event_id' => $registration->event_ID()],
@@ -846,10 +846,10 @@  discard block
 block discarded – undo
846 846
         if ($datetime instanceof EE_Datetime) {
847 847
             $datetime_label = $datetime->get_dtt_display_name(true);
848 848
             $datetime_label .= ! empty($datetime_label)
849
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
849
+                ? ' ('.$datetime->get_dtt_display_name().')'
850 850
                 : $datetime->get_dtt_display_name();
851 851
         }
852
-        $datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
852
+        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
853 853
             ? EE_Admin_Page::add_query_args_and_nonce(
854 854
                 [
855 855
                     'action'   => 'event_registrations',
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
                 $this->_admin_base_url
860 860
             )
861 861
             : '';
862
-        $datetime_link                                    = ! empty($datetime_link)
863
-            ? '<a href="' . $datetime_link . '">'
862
+        $datetime_link = ! empty($datetime_link)
863
+            ? '<a href="'.$datetime_link.'">'
864 864
               . '<span id="checkin-dtt">'
865 865
               . $datetime_label
866 866
               . '</span></a>'
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
             ? $attendee->get_admin_details_link()
873 873
             : '';
874 874
         $attendee_link                                    = ! empty($attendee_link)
875
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
876
-              . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
875
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
876
+              . ' aria-label="'.esc_html__('Click for attendee details', 'event_espresso').'">'
877 877
               . '<span id="checkin-attendee-name">'
878 878
               . $attendee_name
879 879
               . '</span></a>'
@@ -882,25 +882,25 @@  discard block
 block discarded – undo
882 882
             ? $registration->event()->get_admin_details_link()
883 883
             : '';
884 884
         $event_link                                       = ! empty($event_link)
885
-            ? '<a href="' . $event_link . '"'
886
-              . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
885
+            ? '<a href="'.$event_link.'"'
886
+              . ' aria-label="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
887 887
               . '<span id="checkin-event-name">'
888 888
               . $registration->event_name()
889 889
               . '</span>'
890 890
               . '</a>'
891 891
             : '';
892
-        $this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
893
-            ? '<h2>' . sprintf(
892
+        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
893
+            ? '<h2>'.sprintf(
894 894
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
895 895
                 $attendee_link,
896 896
                 $datetime_link,
897 897
                 $event_link
898
-            ) . '</h2>'
898
+            ).'</h2>'
899 899
             : '';
900 900
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
901
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
901
+            ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : '';
902 902
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
903
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
903
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
904 904
         $this->display_admin_list_table_page_with_no_sidebar();
905 905
     }
906 906
 
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
     public function toggle_checkin_status()
919 919
     {
920 920
         // first make sure we have the necessary data
921
-        if (! isset($this->_req_data['_regid'])) {
921
+        if ( ! isset($this->_req_data['_regid'])) {
922 922
             EE_Error::add_error(
923 923
                 esc_html__(
924 924
                     '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',
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
         // beautiful! Made it this far so let's get the status.
941 941
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
942 942
         // setup new class to return via ajax
943
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
943
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
944 944
         $this->_template_args['success']            = true;
945 945
         $this->_return_json();
946 946
     }
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
         ];
968 968
         $new_status = false;
969 969
         // bulk action check in toggle
970
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
970
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
971 971
             // cycle thru checkboxes
972 972
             $checkboxes = $this->_req_data['checkbox'];
973 973
             foreach (array_keys($checkboxes) as $REG_ID) {
@@ -1039,11 +1039,11 @@  discard block
 block discarded – undo
1039 1039
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1040 1040
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1041 1041
         ];
1042
-        $errors     = 0;
1043
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1042
+        $errors = 0;
1043
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1044 1044
             $checkboxes = $this->_req_data['checkbox'];
1045 1045
             foreach (array_keys($checkboxes) as $CHK_ID) {
1046
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1046
+                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1047 1047
                     $errors++;
1048 1048
                 }
1049 1049
             }
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1094 1094
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1095 1095
         ];
1096
-        if (! empty($this->_req_data['CHK_ID'])) {
1097
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1096
+        if ( ! empty($this->_req_data['CHK_ID'])) {
1097
+            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1098 1098
                 EE_Error::add_error(
1099 1099
                     esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1100 1100
                     __FILE__,
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
     protected function _event_registrations_list_table()
1134 1134
     {
1135 1135
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1136
-        $this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1136
+        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1137 1137
             ? $this->get_action_link_or_button(
1138 1138
                 'new_registration',
1139 1139
                 'add-registrant',
@@ -1169,27 +1169,27 @@  discard block
 block discarded – undo
1169 1169
                 'desc'  => $checkin_invalid->legendLabel(),
1170 1170
             ],
1171 1171
             'approved_status'  => [
1172
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1172
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_approved,
1173 1173
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1174 1174
             ],
1175 1175
             'cancelled_status' => [
1176
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1176
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_cancelled,
1177 1177
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1178 1178
             ],
1179 1179
             'declined_status'  => [
1180
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1180
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_declined,
1181 1181
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1182 1182
             ],
1183 1183
             'not_approved'     => [
1184
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1184
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_not_approved,
1185 1185
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1186 1186
             ],
1187 1187
             'pending_status'   => [
1188
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1188
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_pending_payment,
1189 1189
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1190 1190
             ],
1191 1191
             'wait_list'        => [
1192
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1192
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_wait_list,
1193 1193
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1194 1194
             ],
1195 1195
         ];
@@ -1219,27 +1219,27 @@  discard block
 block discarded – undo
1219 1219
         if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1220 1220
             $active_status                             = $datetime->get_active_status();
1221 1221
             $datetime_status                           =
1222
-                '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1223
-                esc_attr($active_status) . '">'
1222
+                '<span class="ee-status ee-status-bg--'.esc_attr($active_status).' event-active-status-'.
1223
+                esc_attr($active_status).'">'
1224 1224
                 . EEH_Template::pretty_status($active_status, false, 'sentence')
1225 1225
                 . '</span>';
1226 1226
             $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1227 1227
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1228 1228
             $this->_template_args['before_list_table'] .= $datetime->name();
1229
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1229
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1230 1230
             $this->_template_args['before_list_table'] .= $datetime_status;
1231 1231
             $this->_template_args['before_list_table'] .= '</span>';
1232 1232
         }
1233 1233
         $this->_template_args['before_list_table'] .= '</h2>';
1234 1234
         // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1235 1235
         // column represents
1236
-        if (! $datetime instanceof EE_Datetime) {
1236
+        if ( ! $datetime instanceof EE_Datetime) {
1237 1237
             $this->_template_args['before_list_table'] .= '
1238 1238
                 <div class="description ee-status-outline ee-status-bg--info" style="white-space: normal;">
1239 1239
                     <h2 style="margin: 1rem; padding: 0;">' . esc_html__(
1240 1240
                         'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1241 1241
                         'event_espresso'
1242
-                    ) . '</h2>
1242
+                    ).'</h2>
1243 1243
                 </div>';
1244 1244
         }
1245 1245
         $this->display_admin_list_table_page_with_no_sidebar();
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
     ) {
1276 1276
         $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1277 1277
         // unlike the regular registrations list table,
1278
-        $status_ids_array          = apply_filters(
1278
+        $status_ids_array = apply_filters(
1279 1279
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1280 1280
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1281 1281
         );
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_EE_Registrations_List_Table.class.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -12,155 +12,155 @@
 block discarded – undo
12 12
  */
13 13
 class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table
14 14
 {
15
-    /**
16
-     * @param EE_Registration $registration
17
-     * @return string
18
-     * @throws EE_Error
19
-     * @throws InvalidArgumentException
20
-     * @throws InvalidDataTypeException
21
-     * @throws InvalidInterfaceException
22
-     * @throws ReflectionException
23
-     */
24
-    public function column_event_name(EE_Registration $registration): string
25
-    {
26
-        $this->_set_related_details($registration);
27
-        $edit_event                = $this->editEventLink($registration);
28
-        $actions['event_filter']   = $this->eventFilterLink($registration);
29
-        $actions['event_checkins'] = $this->viewCheckinsLink($registration);
30
-        return $this->columnContent(
31
-            'event_name',
32
-             $edit_event . $this->row_actions($actions)
33
-        );
34
-    }
15
+	/**
16
+	 * @param EE_Registration $registration
17
+	 * @return string
18
+	 * @throws EE_Error
19
+	 * @throws InvalidArgumentException
20
+	 * @throws InvalidDataTypeException
21
+	 * @throws InvalidInterfaceException
22
+	 * @throws ReflectionException
23
+	 */
24
+	public function column_event_name(EE_Registration $registration): string
25
+	{
26
+		$this->_set_related_details($registration);
27
+		$edit_event                = $this->editEventLink($registration);
28
+		$actions['event_filter']   = $this->eventFilterLink($registration);
29
+		$actions['event_checkins'] = $this->viewCheckinsLink($registration);
30
+		return $this->columnContent(
31
+			'event_name',
32
+			 $edit_event . $this->row_actions($actions)
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @param EE_Registration $registration
39
-     * @return string
40
-     * @throws EE_Error
41
-     * @throws InvalidArgumentException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidInterfaceException
44
-     * @throws ReflectionException
45
-     */
46
-    public function column_DTT_EVT_start(EE_Registration $registration): string
47
-    {
48
-        $ticket                = $registration->ticket();
49
-        $datetimes             = $ticket instanceof EE_Ticket
50
-            ? $ticket->datetimes(['default_where_conditions' => 'none'])
51
-            : [];
52
-        $datetimes_for_display = [];
53
-        foreach ($datetimes as $datetime) {
54
-            $datetime_string         = '<div class="ee-reg-list-dates-list-date">';
55
-            $datetime_string         .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
56
-            $datetime_string         .= $this->row_actions(
57
-                [
58
-                    'datetime_filter'   => $this->datetimeFilterLink($registration, $datetime),
59
-                    'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime),
60
-                ]
61
-            );
62
-            $datetime_string         .= '</div>';
63
-            $datetimes_for_display[] = $datetime_string;
64
-        }
65
-        return $this->columnContent(
66
-            'DTT_EVT_start',
67
-            $this->generateDisplayForDateTimes($datetimes_for_display)
68
-        );
69
-    }
37
+	/**
38
+	 * @param EE_Registration $registration
39
+	 * @return string
40
+	 * @throws EE_Error
41
+	 * @throws InvalidArgumentException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws ReflectionException
45
+	 */
46
+	public function column_DTT_EVT_start(EE_Registration $registration): string
47
+	{
48
+		$ticket                = $registration->ticket();
49
+		$datetimes             = $ticket instanceof EE_Ticket
50
+			? $ticket->datetimes(['default_where_conditions' => 'none'])
51
+			: [];
52
+		$datetimes_for_display = [];
53
+		foreach ($datetimes as $datetime) {
54
+			$datetime_string         = '<div class="ee-reg-list-dates-list-date">';
55
+			$datetime_string         .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
56
+			$datetime_string         .= $this->row_actions(
57
+				[
58
+					'datetime_filter'   => $this->datetimeFilterLink($registration, $datetime),
59
+					'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime),
60
+				]
61
+			);
62
+			$datetime_string         .= '</div>';
63
+			$datetimes_for_display[] = $datetime_string;
64
+		}
65
+		return $this->columnContent(
66
+			'DTT_EVT_start',
67
+			$this->generateDisplayForDateTimes($datetimes_for_display)
68
+		);
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * @param EE_Registration $registration
74
-     * @return string
75
-     * @throws EE_Error
76
-     * @throws ReflectionException
77
-     */
78
-    public function column_REG_ticket(EE_Registration $registration): string
79
-    {
80
-        $ticket      = $registration->ticket();
81
-        $ticket_name = $this->ticketName($ticket);
82
-        $actions     = [
83
-            'ticket_filter'   => $this->ticketFilterLink($ticket),
84
-            'ticket_checkins' => $this->viewCheckinsLink($registration, null, $ticket),
85
-        ];
86
-        return $this->columnContent(
87
-            'REG_ticket',
88
-            $ticket_name . $this->row_actions($actions)
89
-        );
90
-    }
72
+	/**
73
+	 * @param EE_Registration $registration
74
+	 * @return string
75
+	 * @throws EE_Error
76
+	 * @throws ReflectionException
77
+	 */
78
+	public function column_REG_ticket(EE_Registration $registration): string
79
+	{
80
+		$ticket      = $registration->ticket();
81
+		$ticket_name = $this->ticketName($ticket);
82
+		$actions     = [
83
+			'ticket_filter'   => $this->ticketFilterLink($ticket),
84
+			'ticket_checkins' => $this->viewCheckinsLink($registration, null, $ticket),
85
+		];
86
+		return $this->columnContent(
87
+			'REG_ticket',
88
+			$ticket_name . $this->row_actions($actions)
89
+		);
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @param EE_Registration $registration
95
-     * @param EE_Datetime     $datetime
96
-     * @return string
97
-     * @throws EE_Error
98
-     * @throws ReflectionException
99
-     * @since 5.0.18.p
100
-     */
101
-    protected function datetimeFilterLink(EE_Registration $registration, EE_Datetime $datetime): string
102
-    {
103
-        $datetime_filter_url = EE_Admin_Page::add_query_args_and_nonce(
104
-            [
105
-                'event_id'    => $registration->event_ID(),
106
-                'datetime_id' => $datetime->ID(),
107
-            ],
108
-            REG_ADMIN_URL
109
-        );
110
-        return '
93
+	/**
94
+	 * @param EE_Registration $registration
95
+	 * @param EE_Datetime     $datetime
96
+	 * @return string
97
+	 * @throws EE_Error
98
+	 * @throws ReflectionException
99
+	 * @since 5.0.18.p
100
+	 */
101
+	protected function datetimeFilterLink(EE_Registration $registration, EE_Datetime $datetime): string
102
+	{
103
+		$datetime_filter_url = EE_Admin_Page::add_query_args_and_nonce(
104
+			[
105
+				'event_id'    => $registration->event_ID(),
106
+				'datetime_id' => $datetime->ID(),
107
+			],
108
+			REG_ADMIN_URL
109
+		);
110
+		return '
111 111
             <a  class="ee-aria-tooltip ee-datetime-filter-link"
112 112
                 href="' . $datetime_filter_url . '"
113 113
                 aria-label="' . sprintf(
114
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
115
-                $datetime->name() ?: esc_attr__('this datetime', 'event_espresso'),
116
-            ) . '"
114
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
115
+				$datetime->name() ?: esc_attr__('this datetime', 'event_espresso'),
116
+			) . '"
117 117
             >
118 118
                 <span class="dashicons dashicons-groups dashicons--small"></span>
119 119
             </a>';
120
-    }
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * @param EE_Registration  $registration
125
-     * @param EE_Datetime|null $datetime
126
-     * @param EE_Ticket|null   $ticket
127
-     * @return string
128
-     * @throws EE_Error
129
-     * @throws ReflectionException
130
-     * @since 5.0.18.p
131
-     */
132
-    private function viewCheckinsLink(
133
-        EE_Registration $registration,
134
-        ?EE_Datetime $datetime = null,
135
-        ?EE_Ticket $ticket = null
136
-    ): string {
137
-        if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) {
138
-            return '';
139
-        }
140
-        $text  = esc_html__('View Check-ins', 'event_espresso');
141
-        $label = esc_attr__('View Check-ins for this Event', 'event_espresso');
142
-        $class = 'ee-aria-tooltip';
123
+	/**
124
+	 * @param EE_Registration  $registration
125
+	 * @param EE_Datetime|null $datetime
126
+	 * @param EE_Ticket|null   $ticket
127
+	 * @return string
128
+	 * @throws EE_Error
129
+	 * @throws ReflectionException
130
+	 * @since 5.0.18.p
131
+	 */
132
+	private function viewCheckinsLink(
133
+		EE_Registration $registration,
134
+		?EE_Datetime $datetime = null,
135
+		?EE_Ticket $ticket = null
136
+	): string {
137
+		if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) {
138
+			return '';
139
+		}
140
+		$text  = esc_html__('View Check-ins', 'event_espresso');
141
+		$label = esc_attr__('View Check-ins for this Event', 'event_espresso');
142
+		$class = 'ee-aria-tooltip';
143 143
 
144
-        $url_params = [
145
-            'action'   => 'event_registrations',
146
-            'event_id' => $registration->event_ID(),
147
-        ];
148
-        if ($datetime instanceof EE_Datetime) {
149
-            $url_params['DTT_ID'] = $datetime->ID();
150
-            $text                 = '';
151
-            $label                = esc_attr__('View Check-ins for this Datetime', 'event_espresso');
152
-            $class                .= ' ee-status-color--' . $datetime->get_active_status();
153
-        }
154
-        if ($ticket instanceof EE_Ticket) {
155
-            $url_params['TKT_ID'] = $ticket->ID();
156
-            $text                 = esc_html__('View Check-ins', 'event_espresso');
157
-            $label                = esc_attr__('View Check-ins for this Ticket', 'event_espresso');
158
-            $class                .= ' ee-status-color--' . $ticket->ticket_status();
159
-        }
160
-        $url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
161
-        return "
144
+		$url_params = [
145
+			'action'   => 'event_registrations',
146
+			'event_id' => $registration->event_ID(),
147
+		];
148
+		if ($datetime instanceof EE_Datetime) {
149
+			$url_params['DTT_ID'] = $datetime->ID();
150
+			$text                 = '';
151
+			$label                = esc_attr__('View Check-ins for this Datetime', 'event_espresso');
152
+			$class                .= ' ee-status-color--' . $datetime->get_active_status();
153
+		}
154
+		if ($ticket instanceof EE_Ticket) {
155
+			$url_params['TKT_ID'] = $ticket->ID();
156
+			$text                 = esc_html__('View Check-ins', 'event_espresso');
157
+			$label                = esc_attr__('View Check-ins for this Ticket', 'event_espresso');
158
+			$class                .= ' ee-status-color--' . $ticket->ticket_status();
159
+		}
160
+		$url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
161
+		return "
162 162
         <a aria-label='$label' class='$class' href='$url'>
163 163
             <span class='dashicons dashicons-yes-alt dashicons--small'></span>$text
164 164
         </a>";
165
-    }
165
+	}
166 166
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $actions['event_checkins'] = $this->viewCheckinsLink($registration);
30 30
         return $this->columnContent(
31 31
             'event_name',
32
-             $edit_event . $this->row_actions($actions)
32
+             $edit_event.$this->row_actions($actions)
33 33
         );
34 34
     }
35 35
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             : [];
52 52
         $datetimes_for_display = [];
53 53
         foreach ($datetimes as $datetime) {
54
-            $datetime_string         = '<div class="ee-reg-list-dates-list-date">';
54
+            $datetime_string = '<div class="ee-reg-list-dates-list-date">';
55 55
             $datetime_string         .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
56 56
             $datetime_string         .= $this->row_actions(
57 57
                 [
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                     'datetime_checkins' => $this->viewCheckinsLink($registration, $datetime),
60 60
                 ]
61 61
             );
62
-            $datetime_string         .= '</div>';
62
+            $datetime_string .= '</div>';
63 63
             $datetimes_for_display[] = $datetime_string;
64 64
         }
65 65
         return $this->columnContent(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         ];
86 86
         return $this->columnContent(
87 87
             'REG_ticket',
88
-            $ticket_name . $this->row_actions($actions)
88
+            $ticket_name.$this->row_actions($actions)
89 89
         );
90 90
     }
91 91
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         );
110 110
         return '
111 111
             <a  class="ee-aria-tooltip ee-datetime-filter-link"
112
-                href="' . $datetime_filter_url . '"
112
+                href="' . $datetime_filter_url.'"
113 113
                 aria-label="' . sprintf(
114 114
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
115 115
                 $datetime->name() ?: esc_attr__('this datetime', 'event_espresso'),
116
-            ) . '"
116
+            ).'"
117 117
             >
118 118
                 <span class="dashicons dashicons-groups dashicons--small"></span>
119 119
             </a>';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         ?EE_Datetime $datetime = null,
135 135
         ?EE_Ticket $ticket = null
136 136
     ): string {
137
-        if (! $this->caps_handler->userCanReadRegistrationCheckin($registration)) {
137
+        if ( ! $this->caps_handler->userCanReadRegistrationCheckin($registration)) {
138 138
             return '';
139 139
         }
140 140
         $text  = esc_html__('View Check-ins', 'event_espresso');
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
             $url_params['DTT_ID'] = $datetime->ID();
150 150
             $text                 = '';
151 151
             $label                = esc_attr__('View Check-ins for this Datetime', 'event_espresso');
152
-            $class                .= ' ee-status-color--' . $datetime->get_active_status();
152
+            $class .= ' ee-status-color--'.$datetime->get_active_status();
153 153
         }
154 154
         if ($ticket instanceof EE_Ticket) {
155 155
             $url_params['TKT_ID'] = $ticket->ID();
156 156
             $text                 = esc_html__('View Check-ins', 'event_espresso');
157 157
             $label                = esc_attr__('View Check-ins for this Ticket', 'event_espresso');
158
-            $class                .= ' ee-status-color--' . $ticket->ticket_status();
158
+            $class .= ' ee-status-color--'.$ticket->ticket_status();
159 159
         }
160 160
         $url = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
161 161
         return "
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +477 added lines, -477 removed lines patch added patch discarded remove patch
@@ -17,229 +17,229 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class EE_Event_Registrations_List_Table extends EE_Registrations_List_Table
19 19
 {
20
-    /**
21
-     * @var Extend_Registrations_Admin_Page
22
-     */
23
-    protected EE_Admin_Page $_admin_page;
24
-
25
-    /**
26
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
27
-     */
28
-    protected DatetimesForEventCheckIn  $datetimes_for_event;
29
-
30
-    protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null;
31
-
32
-    /**
33
-     * The DTT_ID if the current view has a specified datetime.
34
-     */
35
-    protected int          $datetime_id = 0;
36
-
37
-    protected ?EE_Datetime $datetime    = null;
38
-
39
-    /**
40
-     * The event ID if one is specified in the request
41
-     */
42
-    protected int       $event_id      = 0;
43
-
44
-    protected ?EE_Event $event         = null;
45
-
46
-    protected bool      $hide_expired  = false;
47
-
48
-    protected bool      $hide_upcoming = false;
49
-
50
-    protected array     $_status       = [];
51
-
52
-
53
-    /**
54
-     * EE_Event_Registrations_List_Table constructor.
55
-     *
56
-     * @param Registrations_Admin_Page $admin_page
57
-     * @throws EE_Error
58
-     * @throws ReflectionException
59
-     */
60
-    public function __construct($admin_page)
61
-    {
62
-        $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
63
-        $this->resolveRequestVars();
64
-        parent::__construct($admin_page);
65
-    }
66
-
67
-
68
-    /**
69
-     * @throws EE_Error
70
-     * @throws ReflectionException
71
-     * @since 5.0.0.p
72
-     */
73
-    private function resolveRequestVars()
74
-    {
75
-        $this->event_id            = $this->request->getRequestParam('event_id', 0, DataType::INTEGER);
76
-        $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
77
-        // if we're filtering for a specific event and it only has one datetime, then grab its ID
78
-        $this->datetime    = $this->datetimes_for_event->getOneDatetimeForEvent();
79
-        $this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0;
80
-        // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
81
-        $this->datetime_id = $this->request->getRequestParam(
82
-            'DTT_ID',
83
-            $this->datetime_id,
84
-            DataType::INTEGER
85
-        );
86
-    }
87
-
88
-
89
-    /**
90
-     * @throws EE_Error
91
-     * @throws ReflectionException
92
-     */
93
-    protected function _setup_data()
94
-    {
95
-        $this->_data = $this->_view !== 'trash'
96
-            ? $this->_admin_page->get_event_attendees($this->_per_page)
97
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
98
-
99
-        $this->_all_data_count = $this->_view !== 'trash'
100
-            ? $this->_admin_page->get_event_attendees($this->_per_page, true)
101
-            : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
102
-    }
103
-
104
-
105
-    /**
106
-     * @throws ReflectionException
107
-     * @throws EE_Error
108
-     */
109
-    protected function _set_properties()
110
-    {
111
-        $this->_wp_list_args = [
112
-            'singular' => esc_html__('registrant', 'event_espresso'),
113
-            'plural'   => esc_html__('registrants', 'event_espresso'),
114
-            'ajax'     => true,
115
-            'screen'   => $this->_admin_page->get_current_screen()->id,
116
-        ];
117
-        $columns             = [];
118
-
119
-        $this->_columns = [
120
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes-alt"></span>',
121
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
122
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
123
-            'Event'               => esc_html__('Event', 'event_espresso'),
124
-            'REG_ticket'          => esc_html__('Ticket', 'event_espresso'),
125
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
126
-            '_REG_paid'           => esc_html__('REG Paid', 'event_espresso'),
127
-            'TXN_total'           => esc_html__('TXN Paid/Total', 'event_espresso'),
128
-        ];
129
-        // Add/remove columns when an event has been selected
130
-        if (! empty($this->event_id)) {
131
-            // Render a checkbox column
132
-            $columns['cb']              = '<input type="checkbox" />';
133
-            $this->_has_checkbox_column = true;
134
-            // Remove the 'Event' column
135
-            unset($this->_columns['Event']);
136
-        }
137
-        $this->_columns        = array_merge($columns, $this->_columns);
138
-        $this->_primary_column = '_REG_att_checked_in';
139
-
140
-        $csv_report = RegistrationsCsvReportParams::getRequestParams(
141
-            $this->getReturnUrl(),
142
-            $this->_admin_page->get_request_data(),
143
-            $this->event_id,
144
-            $this->datetime_id
145
-        );
146
-        if (! empty($csv_report)) {
147
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
148
-        }
149
-
150
-        $this->_sortable_columns = [
151
-            /**
152
-             * Allows users to change the default sort if they wish.
153
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
154
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
155
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
156
-             * for a specific list table you can use the provided reference to this object instance.
157
-             */
158
-            'ATT_name' => [
159
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
160
-                true,
161
-                $this,
162
-            ]
163
-                ? ['ATT_lname' => true]
164
-                : ['ATT_fname' => true],
165
-            'Event'    => ['Event.EVT_name' => false],
166
-        ];
167
-        $this->_hidden_columns   = [];
168
-        $this->event             = EEM_Event::instance()->get_one_by_ID($this->event_id);
169
-        if ($this->event instanceof EE_Event) {
170
-            $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event);
171
-        }
172
-    }
173
-
174
-
175
-    /**
176
-     * @param EE_Registration $item
177
-     * @return string
178
-     */
179
-    protected function _get_row_class($item): string
180
-    {
181
-        $class = parent::_get_row_class($item);
182
-        if ($this->_has_checkbox_column) {
183
-            $class .= ' has-checkbox-column';
184
-        }
185
-        return $class;
186
-    }
187
-
188
-
189
-    /**
190
-     * @return array
191
-     * @throws EE_Error
192
-     * @throws ReflectionException
193
-     */
194
-    protected function _get_table_filters()
195
-    {
196
-        $filters               = [];
197
-        $this->hide_expired    = $this->request->getRequestParam('hide_expired', false, DataType::BOOL);
198
-        $this->hide_upcoming   = $this->request->getRequestParam('hide_upcoming', false, DataType::BOOL);
199
-        $hide_expired_checked  = $this->hide_expired ? 'checked' : '';
200
-        $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
201
-        // get datetimes for ALL active events (note possible capability restrictions)
202
-        $events          = $this->datetimes_for_event->getAllEvents();
203
-        $event_options[] = [
204
-            'id'   => 0,
205
-            'text' => esc_html__(' - select an event - ', 'event_espresso'),
206
-        ];
207
-        foreach ($events as $event) {
208
-            // any registrations for this event?
209
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
210
-                continue;
211
-            }
212
-            $expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
213
-            $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : '';
214
-
215
-            $event_options[] = [
216
-                'id'    => $event->ID(),
217
-                'text'  => apply_filters(
218
-                    'FHEE__EE_Event_Registrations___get_table_filters__event_name',
219
-                    $event->name(),
220
-                    $event
221
-                ),
222
-                'class' => $expired_class . $upcoming_class,
223
-            ];
224
-            if ($event->ID() === $this->event_id) {
225
-                $this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
226
-                $hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
227
-                $this->hide_upcoming   = $upcoming_class === '' ? $this->hide_upcoming : false;
228
-                $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
229
-            }
230
-        }
231
-
232
-        $select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
233
-        $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
234
-        $select_input = EEH_Form_Fields::select_input(
235
-            'event_id',
236
-            $event_options,
237
-            $this->event_id,
238
-            '',
239
-            $select_class
240
-        );
241
-
242
-        $filters[] = '
20
+	/**
21
+	 * @var Extend_Registrations_Admin_Page
22
+	 */
23
+	protected EE_Admin_Page $_admin_page;
24
+
25
+	/**
26
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
27
+	 */
28
+	protected DatetimesForEventCheckIn  $datetimes_for_event;
29
+
30
+	protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null;
31
+
32
+	/**
33
+	 * The DTT_ID if the current view has a specified datetime.
34
+	 */
35
+	protected int          $datetime_id = 0;
36
+
37
+	protected ?EE_Datetime $datetime    = null;
38
+
39
+	/**
40
+	 * The event ID if one is specified in the request
41
+	 */
42
+	protected int       $event_id      = 0;
43
+
44
+	protected ?EE_Event $event         = null;
45
+
46
+	protected bool      $hide_expired  = false;
47
+
48
+	protected bool      $hide_upcoming = false;
49
+
50
+	protected array     $_status       = [];
51
+
52
+
53
+	/**
54
+	 * EE_Event_Registrations_List_Table constructor.
55
+	 *
56
+	 * @param Registrations_Admin_Page $admin_page
57
+	 * @throws EE_Error
58
+	 * @throws ReflectionException
59
+	 */
60
+	public function __construct($admin_page)
61
+	{
62
+		$this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
63
+		$this->resolveRequestVars();
64
+		parent::__construct($admin_page);
65
+	}
66
+
67
+
68
+	/**
69
+	 * @throws EE_Error
70
+	 * @throws ReflectionException
71
+	 * @since 5.0.0.p
72
+	 */
73
+	private function resolveRequestVars()
74
+	{
75
+		$this->event_id            = $this->request->getRequestParam('event_id', 0, DataType::INTEGER);
76
+		$this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
77
+		// if we're filtering for a specific event and it only has one datetime, then grab its ID
78
+		$this->datetime    = $this->datetimes_for_event->getOneDatetimeForEvent();
79
+		$this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0;
80
+		// else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
81
+		$this->datetime_id = $this->request->getRequestParam(
82
+			'DTT_ID',
83
+			$this->datetime_id,
84
+			DataType::INTEGER
85
+		);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @throws EE_Error
91
+	 * @throws ReflectionException
92
+	 */
93
+	protected function _setup_data()
94
+	{
95
+		$this->_data = $this->_view !== 'trash'
96
+			? $this->_admin_page->get_event_attendees($this->_per_page)
97
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
98
+
99
+		$this->_all_data_count = $this->_view !== 'trash'
100
+			? $this->_admin_page->get_event_attendees($this->_per_page, true)
101
+			: $this->_admin_page->get_event_attendees($this->_per_page, true, true);
102
+	}
103
+
104
+
105
+	/**
106
+	 * @throws ReflectionException
107
+	 * @throws EE_Error
108
+	 */
109
+	protected function _set_properties()
110
+	{
111
+		$this->_wp_list_args = [
112
+			'singular' => esc_html__('registrant', 'event_espresso'),
113
+			'plural'   => esc_html__('registrants', 'event_espresso'),
114
+			'ajax'     => true,
115
+			'screen'   => $this->_admin_page->get_current_screen()->id,
116
+		];
117
+		$columns             = [];
118
+
119
+		$this->_columns = [
120
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes-alt"></span>',
121
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
122
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
123
+			'Event'               => esc_html__('Event', 'event_espresso'),
124
+			'REG_ticket'          => esc_html__('Ticket', 'event_espresso'),
125
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
126
+			'_REG_paid'           => esc_html__('REG Paid', 'event_espresso'),
127
+			'TXN_total'           => esc_html__('TXN Paid/Total', 'event_espresso'),
128
+		];
129
+		// Add/remove columns when an event has been selected
130
+		if (! empty($this->event_id)) {
131
+			// Render a checkbox column
132
+			$columns['cb']              = '<input type="checkbox" />';
133
+			$this->_has_checkbox_column = true;
134
+			// Remove the 'Event' column
135
+			unset($this->_columns['Event']);
136
+		}
137
+		$this->_columns        = array_merge($columns, $this->_columns);
138
+		$this->_primary_column = '_REG_att_checked_in';
139
+
140
+		$csv_report = RegistrationsCsvReportParams::getRequestParams(
141
+			$this->getReturnUrl(),
142
+			$this->_admin_page->get_request_data(),
143
+			$this->event_id,
144
+			$this->datetime_id
145
+		);
146
+		if (! empty($csv_report)) {
147
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
148
+		}
149
+
150
+		$this->_sortable_columns = [
151
+			/**
152
+			 * Allows users to change the default sort if they wish.
153
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
154
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
155
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
156
+			 * for a specific list table you can use the provided reference to this object instance.
157
+			 */
158
+			'ATT_name' => [
159
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
160
+				true,
161
+				$this,
162
+			]
163
+				? ['ATT_lname' => true]
164
+				: ['ATT_fname' => true],
165
+			'Event'    => ['Event.EVT_name' => false],
166
+		];
167
+		$this->_hidden_columns   = [];
168
+		$this->event             = EEM_Event::instance()->get_one_by_ID($this->event_id);
169
+		if ($this->event instanceof EE_Event) {
170
+			$this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event);
171
+		}
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param EE_Registration $item
177
+	 * @return string
178
+	 */
179
+	protected function _get_row_class($item): string
180
+	{
181
+		$class = parent::_get_row_class($item);
182
+		if ($this->_has_checkbox_column) {
183
+			$class .= ' has-checkbox-column';
184
+		}
185
+		return $class;
186
+	}
187
+
188
+
189
+	/**
190
+	 * @return array
191
+	 * @throws EE_Error
192
+	 * @throws ReflectionException
193
+	 */
194
+	protected function _get_table_filters()
195
+	{
196
+		$filters               = [];
197
+		$this->hide_expired    = $this->request->getRequestParam('hide_expired', false, DataType::BOOL);
198
+		$this->hide_upcoming   = $this->request->getRequestParam('hide_upcoming', false, DataType::BOOL);
199
+		$hide_expired_checked  = $this->hide_expired ? 'checked' : '';
200
+		$hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
201
+		// get datetimes for ALL active events (note possible capability restrictions)
202
+		$events          = $this->datetimes_for_event->getAllEvents();
203
+		$event_options[] = [
204
+			'id'   => 0,
205
+			'text' => esc_html__(' - select an event - ', 'event_espresso'),
206
+		];
207
+		foreach ($events as $event) {
208
+			// any registrations for this event?
209
+			if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
210
+				continue;
211
+			}
212
+			$expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
213
+			$upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : '';
214
+
215
+			$event_options[] = [
216
+				'id'    => $event->ID(),
217
+				'text'  => apply_filters(
218
+					'FHEE__EE_Event_Registrations___get_table_filters__event_name',
219
+					$event->name(),
220
+					$event
221
+				),
222
+				'class' => $expired_class . $upcoming_class,
223
+			];
224
+			if ($event->ID() === $this->event_id) {
225
+				$this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
226
+				$hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
227
+				$this->hide_upcoming   = $upcoming_class === '' ? $this->hide_upcoming : false;
228
+				$hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
229
+			}
230
+		}
231
+
232
+		$select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
233
+		$select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
234
+		$select_input = EEH_Form_Fields::select_input(
235
+			'event_id',
236
+			$event_options,
237
+			$this->event_id,
238
+			'',
239
+			$select_class
240
+		);
241
+
242
+		$filters[] = '
243 243
         <div class="ee-event-filter__wrapper">
244 244
             <label class="ee-event-filter-main-label">
245 245
                 ' . esc_html__('Check-in Status for', 'event_espresso') . '
@@ -249,301 +249,301 @@  discard block
 block discarded – undo
249 249
                     <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
250 250
                     ' . $select_input . '
251 251
                 </span>';
252
-        // DTT datetimes filter
253
-        $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
254
-            $hide_upcoming_checked === 'checked'
255
-        );
256
-        if (count($datetimes_for_event) > 1) {
257
-            $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
258
-            foreach ($datetimes_for_event as $datetime) {
259
-                if ($datetime instanceof EE_Datetime) {
260
-                    $datetime_string = $datetime->name();
261
-                    $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
262
-                    $datetime_string .= $datetime->date_and_time_range();
263
-                    $datetime_string .= $datetime->is_active() ? ' ∗' : '';
264
-                    $datetime_string .= $datetime->is_expired() ? ' «' : '';
265
-                    $datetime_string .= $datetime->is_upcoming() ? ' »' : '';
266
-                    // now put it all together
267
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
268
-                }
269
-            }
270
-            $filters[] = '
252
+		// DTT datetimes filter
253
+		$datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
254
+			$hide_upcoming_checked === 'checked'
255
+		);
256
+		if (count($datetimes_for_event) > 1) {
257
+			$datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
258
+			foreach ($datetimes_for_event as $datetime) {
259
+				if ($datetime instanceof EE_Datetime) {
260
+					$datetime_string = $datetime->name();
261
+					$datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
262
+					$datetime_string .= $datetime->date_and_time_range();
263
+					$datetime_string .= $datetime->is_active() ? ' ∗' : '';
264
+					$datetime_string .= $datetime->is_expired() ? ' «' : '';
265
+					$datetime_string .= $datetime->is_upcoming() ? ' »' : '';
266
+					// now put it all together
267
+					$datetimes[ $datetime->ID() ] = $datetime_string;
268
+				}
269
+			}
270
+			$filters[] = '
271 271
                 <span class="ee-datetime-selector">
272 272
                     <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
273 273
                     ' . EEH_Form_Fields::select_input(
274
-                        'DTT_ID',
275
-                        $datetimes,
276
-                        $this->datetime_id
277
-                    ) . '
274
+						'DTT_ID',
275
+						$datetimes,
276
+						$this->datetime_id
277
+					) . '
278 278
                 </span>';
279
-        }
280
-        $filters[] = '
279
+		}
280
+		$filters[] = '
281 281
                 <span class="ee-hide-upcoming-check">
282 282
                     <label for="js-ee-hide-upcoming-events">
283 283
                         <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" '
284
-                         . $hide_upcoming_checked
285
-                         . '>
284
+						 . $hide_upcoming_checked
285
+						 . '>
286 286
                             '
287
-                         . esc_html__('Hide Upcoming Events', 'event_espresso')
288
-                         . '
287
+						 . esc_html__('Hide Upcoming Events', 'event_espresso')
288
+						 . '
289 289
                     </label>
290 290
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip"
291 291
                           aria-label="'
292
-                         . esc_html__(
293
-                             'Will not display events with start dates in the future (ie: have not yet begun)',
294
-                             'event_espresso'
295
-                         ) . '"
292
+						 . esc_html__(
293
+							 'Will not display events with start dates in the future (ie: have not yet begun)',
294
+							 'event_espresso'
295
+						 ) . '"
296 296
                     ></span>
297 297
                 </span>
298 298
                 <span class="ee-hide-expired-check">
299 299
                     <label for="js-ee-hide-expired-events">
300 300
                         <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" '
301
-                         . $hide_expired_checked
302
-                         . '>
301
+						 . $hide_expired_checked
302
+						 . '>
303 303
                             ' . esc_html__('Hide Expired Events', 'event_espresso') . '
304 304
                     </label>
305 305
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip"
306 306
                           aria-label="'
307
-                         . esc_html__(
308
-                             'Will not display events with end dates in the past (ie: have already finished)',
309
-                             'event_espresso'
310
-                         )
311
-                         . '"
307
+						 . esc_html__(
308
+							 'Will not display events with end dates in the past (ie: have already finished)',
309
+							 'event_espresso'
310
+						 )
311
+						 . '"
312 312
                     ></span>
313 313
                 </span>
314 314
             </div>
315 315
         </div>';
316
-        return $filters;
317
-    }
318
-
319
-
320
-    /**
321
-     * @throws EE_Error
322
-     * @throws ReflectionException
323
-     */
324
-    protected function _add_view_counts()
325
-    {
326
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
327
-    }
328
-
329
-
330
-    /**
331
-     * @return int
332
-     * @throws EE_Error
333
-     * @throws ReflectionException
334
-     */
335
-    protected function _get_total_event_attendees(): int
336
-    {
337
-        $query_params = [];
338
-        if ($this->event_id) {
339
-            $query_params[0]['EVT_ID'] = $this->event_id;
340
-        }
341
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
342
-        if ($this->datetime_id) {
343
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
344
-        }
345
-        $status_ids_array          = apply_filters(
346
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
347
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
348
-        );
349
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
350
-        return EEM_Registration::instance()->count($query_params);
351
-    }
352
-
353
-
354
-    /**
355
-     * @param EE_Registration $item
356
-     * @return string
357
-     * @throws EE_Error
358
-     * @throws ReflectionException
359
-     */
360
-    public function column_cb($item): string
361
-    {
362
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
363
-    }
364
-
365
-
366
-    /**
367
-     * column_REG_att_checked_in
368
-     *
369
-     * @param EE_Registration $registration
370
-     * @return string
371
-     * @throws EE_Error
372
-     * @throws InvalidArgumentException
373
-     * @throws InvalidDataTypeException
374
-     * @throws InvalidInterfaceException
375
-     * @throws ReflectionException
376
-     */
377
-    public function column__REG_att_checked_in(EE_Registration $registration): string
378
-    {
379
-        // we need a local variable for the datetime for each row
380
-        // (so that we don't pollute state for the entire table)
381
-        // so let's try to get it from the registration's event
382
-        $DTT_ID = $this->datetime_id;
383
-        if (! $DTT_ID) {
384
-            $reg_ticket_datetimes = $registration->ticket()->datetimes();
385
-            if (count($reg_ticket_datetimes) === 1) {
386
-                $reg_ticket_datetime = reset($reg_ticket_datetimes);
387
-                $DTT_ID              = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0;
388
-            }
389
-        }
390
-
391
-        if (! $DTT_ID) {
392
-            $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
393
-            $datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
394
-            $DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
395
-        }
396
-
397
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
398
-            $registration,
399
-            $DTT_ID
400
-        );
401
-
402
-        $aria_label     = $checkin_status_dashicon->ariaLabel();
403
-        $dashicon_class = $checkin_status_dashicon->cssClasses();
404
-        $attributes     = ' onClick="return false"';
405
-        $button_class   = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
406
-
407
-        if ($DTT_ID && $this->caps_handler->userCanEditRegistrationCheckin($registration)) {
408
-            // overwrite the disabled attribute with data attributes for performing checkin
409
-            $attributes   = 'data-_regid="' . $registration->ID() . '"';
410
-            $attributes   .= ' data-dttid="' . $DTT_ID . '"';
411
-            $attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
412
-            $button_class .= ' clickable trigger-checkin';
413
-        }
414
-
415
-        $content = '
316
+		return $filters;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @throws EE_Error
322
+	 * @throws ReflectionException
323
+	 */
324
+	protected function _add_view_counts()
325
+	{
326
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
327
+	}
328
+
329
+
330
+	/**
331
+	 * @return int
332
+	 * @throws EE_Error
333
+	 * @throws ReflectionException
334
+	 */
335
+	protected function _get_total_event_attendees(): int
336
+	{
337
+		$query_params = [];
338
+		if ($this->event_id) {
339
+			$query_params[0]['EVT_ID'] = $this->event_id;
340
+		}
341
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
342
+		if ($this->datetime_id) {
343
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
344
+		}
345
+		$status_ids_array          = apply_filters(
346
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
347
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
348
+		);
349
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
350
+		return EEM_Registration::instance()->count($query_params);
351
+	}
352
+
353
+
354
+	/**
355
+	 * @param EE_Registration $item
356
+	 * @return string
357
+	 * @throws EE_Error
358
+	 * @throws ReflectionException
359
+	 */
360
+	public function column_cb($item): string
361
+	{
362
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
363
+	}
364
+
365
+
366
+	/**
367
+	 * column_REG_att_checked_in
368
+	 *
369
+	 * @param EE_Registration $registration
370
+	 * @return string
371
+	 * @throws EE_Error
372
+	 * @throws InvalidArgumentException
373
+	 * @throws InvalidDataTypeException
374
+	 * @throws InvalidInterfaceException
375
+	 * @throws ReflectionException
376
+	 */
377
+	public function column__REG_att_checked_in(EE_Registration $registration): string
378
+	{
379
+		// we need a local variable for the datetime for each row
380
+		// (so that we don't pollute state for the entire table)
381
+		// so let's try to get it from the registration's event
382
+		$DTT_ID = $this->datetime_id;
383
+		if (! $DTT_ID) {
384
+			$reg_ticket_datetimes = $registration->ticket()->datetimes();
385
+			if (count($reg_ticket_datetimes) === 1) {
386
+				$reg_ticket_datetime = reset($reg_ticket_datetimes);
387
+				$DTT_ID              = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0;
388
+			}
389
+		}
390
+
391
+		if (! $DTT_ID) {
392
+			$this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
393
+			$datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
394
+			$DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
395
+		}
396
+
397
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
398
+			$registration,
399
+			$DTT_ID
400
+		);
401
+
402
+		$aria_label     = $checkin_status_dashicon->ariaLabel();
403
+		$dashicon_class = $checkin_status_dashicon->cssClasses();
404
+		$attributes     = ' onClick="return false"';
405
+		$button_class   = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
406
+
407
+		if ($DTT_ID && $this->caps_handler->userCanEditRegistrationCheckin($registration)) {
408
+			// overwrite the disabled attribute with data attributes for performing checkin
409
+			$attributes   = 'data-_regid="' . $registration->ID() . '"';
410
+			$attributes   .= ' data-dttid="' . $DTT_ID . '"';
411
+			$attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
412
+			$button_class .= ' clickable trigger-checkin';
413
+		}
414
+
415
+		$content = '
416 416
         <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
417 417
             <span class="' . $dashicon_class . '" ></span>
418 418
         </button>
419 419
         <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
420
-        return $this->columnContent('_REG_att_checked_in', $content, 'center');
421
-    }
422
-
423
-
424
-    /**
425
-     * @param EE_Registration $registration
426
-     * @return string
427
-     * @throws EE_Error
428
-     * @throws ReflectionException
429
-     */
430
-    public function column_ATT_name(EE_Registration $registration): string
431
-    {
432
-        $attendee = $registration->attendee();
433
-        if (! $attendee instanceof EE_Attendee) {
434
-            return esc_html__('No contact record for this registration.', 'event_espresso');
435
-        }
436
-        // edit attendee link
437
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
438
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
439
-            REG_ADMIN_URL
440
-        );
441
-        $name_link    = '
420
+		return $this->columnContent('_REG_att_checked_in', $content, 'center');
421
+	}
422
+
423
+
424
+	/**
425
+	 * @param EE_Registration $registration
426
+	 * @return string
427
+	 * @throws EE_Error
428
+	 * @throws ReflectionException
429
+	 */
430
+	public function column_ATT_name(EE_Registration $registration): string
431
+	{
432
+		$attendee = $registration->attendee();
433
+		if (! $attendee instanceof EE_Attendee) {
434
+			return esc_html__('No contact record for this registration.', 'event_espresso');
435
+		}
436
+		// edit attendee link
437
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
438
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
439
+			REG_ADMIN_URL
440
+		);
441
+		$name_link    = '
442 442
             <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
443 443
             aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
444 444
             </span>';
445
-        $status        = esc_attr($registration->status_ID());
446
-        $name_link    .= $this->caps_handler->userCanEditContacts()
447
-            ? '
445
+		$status        = esc_attr($registration->status_ID());
446
+		$name_link    .= $this->caps_handler->userCanEditContacts()
447
+			? '
448 448
             <a class="ee-aria-tooltip ee-status-color--' . $status . '"
449 449
                href="' . $edit_lnk_url . '"
450 450
                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
451 451
             >
452 452
                 ' . $registration->attendee()->full_name() . '
453 453
             </a>'
454
-            : $registration->attendee()->full_name();
455
-        $name_link    .= $registration->count() === 1
456
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
457
-            : '';
458
-        // add group details
459
-        $name_link .= '&nbsp;' . sprintf(
460
-            esc_html__('(%s of %s)', 'event_espresso'),
461
-            $registration->count(),
462
-            $registration->group_size()
463
-        );
464
-        // add regcode
465
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
466
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
467
-            REG_ADMIN_URL
468
-        );
469
-        $name_link .= '<br>';
470
-        $name_link .= $this->caps_handler->userCanReadRegistration($registration)
471
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
472
-                'View Registration Details',
473
-                'event_espresso'
474
-            ) . '">'
475
-              . $registration->reg_code()
476
-              . '</a>'
477
-            : $registration->reg_code();
478
-
479
-        $actions = [];
480
-        if ($this->datetime_id && $this->caps_handler->userCanReadRegistrationCheckins()) {
481
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
482
-                ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
483
-                REG_ADMIN_URL
484
-            );
485
-            // get the timestamps for this registration's checkins, related to the selected datetime
486
-            /** @var EE_Checkin[] $checkins */
487
-            $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
488
-            if (! empty($checkins)) {
489
-                // get the last timestamp
490
-                $last_checkin = end($checkins);
491
-                // get timestamp string
492
-                $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
493
-                $actions['checkin'] = '
454
+			: $registration->attendee()->full_name();
455
+		$name_link    .= $registration->count() === 1
456
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
457
+			: '';
458
+		// add group details
459
+		$name_link .= '&nbsp;' . sprintf(
460
+			esc_html__('(%s of %s)', 'event_espresso'),
461
+			$registration->count(),
462
+			$registration->group_size()
463
+		);
464
+		// add regcode
465
+		$link      = EE_Admin_Page::add_query_args_and_nonce(
466
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
467
+			REG_ADMIN_URL
468
+		);
469
+		$name_link .= '<br>';
470
+		$name_link .= $this->caps_handler->userCanReadRegistration($registration)
471
+			? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
472
+				'View Registration Details',
473
+				'event_espresso'
474
+			) . '">'
475
+			  . $registration->reg_code()
476
+			  . '</a>'
477
+			: $registration->reg_code();
478
+
479
+		$actions = [];
480
+		if ($this->datetime_id && $this->caps_handler->userCanReadRegistrationCheckins()) {
481
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
482
+				['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
483
+				REG_ADMIN_URL
484
+			);
485
+			// get the timestamps for this registration's checkins, related to the selected datetime
486
+			/** @var EE_Checkin[] $checkins */
487
+			$checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
488
+			if (! empty($checkins)) {
489
+				// get the last timestamp
490
+				$last_checkin = end($checkins);
491
+				// get timestamp string
492
+				$timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
493
+				$actions['checkin'] = '
494 494
                     <a  class="ee-aria-tooltip"
495 495
                         href="' . $checkin_list_url . '"
496 496
                         aria-label="' . esc_attr__(
497
-                            'View this registrant\'s check-ins/checkouts for the datetime',
498
-                            'event_espresso'
499
-                        ) . '"
497
+							'View this registrant\'s check-ins/checkouts for the datetime',
498
+							'event_espresso'
499
+						) . '"
500 500
                     >
501 501
                         ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
502 502
                     </a>';
503
-            }
504
-        }
505
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
506
-            ? $name_link . $this->row_actions($actions, true)
507
-            : $name_link;
508
-        return $this->columnContent('ATT_name', $content);
509
-    }
510
-
511
-
512
-    /**
513
-     * @param EE_Registration $registration
514
-     * @return string
515
-     * @throws EE_Error
516
-     * @throws ReflectionException
517
-     */
518
-    public function column_Event(EE_Registration $registration): string
519
-    {
520
-        try {
521
-            $event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
522
-            $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
523
-                ['action' => 'event_registrations', 'event_id' => $event->ID()],
524
-                REG_ADMIN_URL
525
-            );
526
-            $content          = $this->caps_handler->userCanReadRegistrationCheckins()
527
-                ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
528
-                . esc_attr__(
529
-                    'View Check-ins for this Event',
530
-                    'event_espresso'
531
-                ) . '">' . $event->name() . '</a>' : $event->name();
532
-        } catch (EntityNotFoundException $e) {
533
-            $content = esc_html__('Unknown', 'event_espresso');
534
-        }
535
-        return $this->columnContent('Event', $content);
536
-    }
537
-
538
-
539
-    /**
540
-     * @param EE_Registration $registration
541
-     * @return string
542
-     * @throws EE_Error
543
-     * @throws ReflectionException
544
-     */
545
-    public function column_PRC_name(EE_Registration $registration): string
546
-    {
547
-        return $this->column_REG_ticket($registration);
548
-    }
503
+			}
504
+		}
505
+		$content = (! empty($this->datetime_id) && ! empty($checkins))
506
+			? $name_link . $this->row_actions($actions, true)
507
+			: $name_link;
508
+		return $this->columnContent('ATT_name', $content);
509
+	}
510
+
511
+
512
+	/**
513
+	 * @param EE_Registration $registration
514
+	 * @return string
515
+	 * @throws EE_Error
516
+	 * @throws ReflectionException
517
+	 */
518
+	public function column_Event(EE_Registration $registration): string
519
+	{
520
+		try {
521
+			$event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
522
+			$checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
523
+				['action' => 'event_registrations', 'event_id' => $event->ID()],
524
+				REG_ADMIN_URL
525
+			);
526
+			$content          = $this->caps_handler->userCanReadRegistrationCheckins()
527
+				? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
528
+				. esc_attr__(
529
+					'View Check-ins for this Event',
530
+					'event_espresso'
531
+				) . '">' . $event->name() . '</a>' : $event->name();
532
+		} catch (EntityNotFoundException $e) {
533
+			$content = esc_html__('Unknown', 'event_espresso');
534
+		}
535
+		return $this->columnContent('Event', $content);
536
+	}
537
+
538
+
539
+	/**
540
+	 * @param EE_Registration $registration
541
+	 * @return string
542
+	 * @throws EE_Error
543
+	 * @throws ReflectionException
544
+	 */
545
+	public function column_PRC_name(EE_Registration $registration): string
546
+	{
547
+		return $this->column_REG_ticket($registration);
548
+	}
549 549
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             'ajax'     => true,
115 115
             'screen'   => $this->_admin_page->get_current_screen()->id,
116 116
         ];
117
-        $columns             = [];
117
+        $columns = [];
118 118
 
119 119
         $this->_columns = [
120 120
             '_REG_att_checked_in' => '<span class="dashicons dashicons-yes-alt"></span>',
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'TXN_total'           => esc_html__('TXN Paid/Total', 'event_espresso'),
128 128
         ];
129 129
         // Add/remove columns when an event has been selected
130
-        if (! empty($this->event_id)) {
130
+        if ( ! empty($this->event_id)) {
131 131
             // Render a checkbox column
132 132
             $columns['cb']              = '<input type="checkbox" />';
133 133
             $this->_has_checkbox_column = true;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             $this->event_id,
144 144
             $this->datetime_id
145 145
         );
146
-        if (! empty($csv_report)) {
146
+        if ( ! empty($csv_report)) {
147 147
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
148 148
         }
149 149
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         ];
207 207
         foreach ($events as $event) {
208 208
             // any registrations for this event?
209
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
209
+            if ( ! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
210 210
                 continue;
211 211
             }
212 212
             $expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                     $event->name(),
220 220
                     $event
221 221
                 ),
222
-                'class' => $expired_class . $upcoming_class,
222
+                'class' => $expired_class.$upcoming_class,
223 223
             ];
224 224
             if ($event->ID() === $this->event_id) {
225 225
                 $this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
         $filters[] = '
243 243
         <div class="ee-event-filter__wrapper">
244 244
             <label class="ee-event-filter-main-label">
245
-                ' . esc_html__('Check-in Status for', 'event_espresso') . '
245
+                ' . esc_html__('Check-in Status for', 'event_espresso').'
246 246
             </label>
247 247
             <div class="ee-event-filter ee-status-outline ee-status-bg--info">
248 248
                 <span class="ee-event-selector">
249
-                    <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
250
-                    ' . $select_input . '
249
+                    <label for="event_id">' . esc_html__('Event', 'event_espresso').'</label>
250
+                    ' . $select_input.'
251 251
                 </span>';
252 252
         // DTT datetimes filter
253 253
         $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
@@ -258,23 +258,23 @@  discard block
 block discarded – undo
258 258
             foreach ($datetimes_for_event as $datetime) {
259 259
                 if ($datetime instanceof EE_Datetime) {
260 260
                     $datetime_string = $datetime->name();
261
-                    $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
261
+                    $datetime_string = ! empty($datetime_string) ? $datetime_string.': ' : '';
262 262
                     $datetime_string .= $datetime->date_and_time_range();
263 263
                     $datetime_string .= $datetime->is_active() ? ' ∗' : '';
264 264
                     $datetime_string .= $datetime->is_expired() ? ' «' : '';
265 265
                     $datetime_string .= $datetime->is_upcoming() ? ' »' : '';
266 266
                     // now put it all together
267
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
267
+                    $datetimes[$datetime->ID()] = $datetime_string;
268 268
                 }
269 269
             }
270 270
             $filters[] = '
271 271
                 <span class="ee-datetime-selector">
272
-                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
272
+                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label>
273 273
                     ' . EEH_Form_Fields::select_input(
274 274
                         'DTT_ID',
275 275
                         $datetimes,
276 276
                         $this->datetime_id
277
-                    ) . '
277
+                    ).'
278 278
                 </span>';
279 279
         }
280 280
         $filters[] = '
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                          . esc_html__(
293 293
                              'Will not display events with start dates in the future (ie: have not yet begun)',
294 294
                              'event_espresso'
295
-                         ) . '"
295
+                         ).'"
296 296
                     ></span>
297 297
                 </span>
298 298
                 <span class="ee-hide-expired-check">
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                         <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" '
301 301
                          . $hide_expired_checked
302 302
                          . '>
303
-                            ' . esc_html__('Hide Expired Events', 'event_espresso') . '
303
+                            ' . esc_html__('Hide Expired Events', 'event_espresso').'
304 304
                     </label>
305 305
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip"
306 306
                           aria-label="'
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         if ($this->datetime_id) {
343 343
             $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
344 344
         }
345
-        $status_ids_array          = apply_filters(
345
+        $status_ids_array = apply_filters(
346 346
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
347 347
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
348 348
         );
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
         // (so that we don't pollute state for the entire table)
381 381
         // so let's try to get it from the registration's event
382 382
         $DTT_ID = $this->datetime_id;
383
-        if (! $DTT_ID) {
383
+        if ( ! $DTT_ID) {
384 384
             $reg_ticket_datetimes = $registration->ticket()->datetimes();
385 385
             if (count($reg_ticket_datetimes) === 1) {
386 386
                 $reg_ticket_datetime = reset($reg_ticket_datetimes);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             }
389 389
         }
390 390
 
391
-        if (! $DTT_ID) {
391
+        if ( ! $DTT_ID) {
392 392
             $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
393 393
             $datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
394 394
             $DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
 
407 407
         if ($DTT_ID && $this->caps_handler->userCanEditRegistrationCheckin($registration)) {
408 408
             // overwrite the disabled attribute with data attributes for performing checkin
409
-            $attributes   = 'data-_regid="' . $registration->ID() . '"';
410
-            $attributes   .= ' data-dttid="' . $DTT_ID . '"';
411
-            $attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
409
+            $attributes = 'data-_regid="'.$registration->ID().'"';
410
+            $attributes   .= ' data-dttid="'.$DTT_ID.'"';
411
+            $attributes   .= ' data-nonce="'.wp_create_nonce('checkin_nonce').'"';
412 412
             $button_class .= ' clickable trigger-checkin';
413 413
         }
414 414
 
415 415
         $content = '
416
-        <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
417
-            <span class="' . $dashicon_class . '" ></span>
416
+        <button aria-label="' . $aria_label.'" class="'.$button_class.'" '.$attributes.'>
417
+            <span class="' . $dashicon_class.'" ></span>
418 418
         </button>
419
-        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
419
+        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration).'</span>';
420 420
         return $this->columnContent('_REG_att_checked_in', $content, 'center');
421 421
     }
422 422
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public function column_ATT_name(EE_Registration $registration): string
431 431
     {
432 432
         $attendee = $registration->attendee();
433
-        if (! $attendee instanceof EE_Attendee) {
433
+        if ( ! $attendee instanceof EE_Attendee) {
434 434
             return esc_html__('No contact record for this registration.', 'event_espresso');
435 435
         }
436 436
         // edit attendee link
@@ -438,40 +438,40 @@  discard block
 block discarded – undo
438 438
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
439 439
             REG_ADMIN_URL
440 440
         );
441
-        $name_link    = '
442
-            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
443
-            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
441
+        $name_link = '
442
+            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()).' ee-aria-tooltip"
443
+            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'">
444 444
             </span>';
445 445
         $status        = esc_attr($registration->status_ID());
446 446
         $name_link    .= $this->caps_handler->userCanEditContacts()
447 447
             ? '
448
-            <a class="ee-aria-tooltip ee-status-color--' . $status . '"
449
-               href="' . $edit_lnk_url . '"
450
-               aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
448
+            <a class="ee-aria-tooltip ee-status-color--' . $status.'"
449
+               href="' . $edit_lnk_url.'"
450
+               aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
451 451
             >
452
-                ' . $registration->attendee()->full_name() . '
452
+                ' . $registration->attendee()->full_name().'
453 453
             </a>'
454 454
             : $registration->attendee()->full_name();
455
-        $name_link    .= $registration->count() === 1
455
+        $name_link .= $registration->count() === 1
456 456
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
457 457
             : '';
458 458
         // add group details
459
-        $name_link .= '&nbsp;' . sprintf(
459
+        $name_link .= '&nbsp;'.sprintf(
460 460
             esc_html__('(%s of %s)', 'event_espresso'),
461 461
             $registration->count(),
462 462
             $registration->group_size()
463 463
         );
464 464
         // add regcode
465
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
465
+        $link = EE_Admin_Page::add_query_args_and_nonce(
466 466
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
467 467
             REG_ADMIN_URL
468 468
         );
469 469
         $name_link .= '<br>';
470 470
         $name_link .= $this->caps_handler->userCanReadRegistration($registration)
471
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
471
+            ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__(
472 472
                 'View Registration Details',
473 473
                 'event_espresso'
474
-            ) . '">'
474
+            ).'">'
475 475
               . $registration->reg_code()
476 476
               . '</a>'
477 477
             : $registration->reg_code();
@@ -485,25 +485,25 @@  discard block
 block discarded – undo
485 485
             // get the timestamps for this registration's checkins, related to the selected datetime
486 486
             /** @var EE_Checkin[] $checkins */
487 487
             $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
488
-            if (! empty($checkins)) {
488
+            if ( ! empty($checkins)) {
489 489
                 // get the last timestamp
490 490
                 $last_checkin = end($checkins);
491 491
                 // get timestamp string
492 492
                 $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
493 493
                 $actions['checkin'] = '
494 494
                     <a  class="ee-aria-tooltip"
495
-                        href="' . $checkin_list_url . '"
495
+                        href="' . $checkin_list_url.'"
496 496
                         aria-label="' . esc_attr__(
497 497
                             'View this registrant\'s check-ins/checkouts for the datetime',
498 498
                             'event_espresso'
499
-                        ) . '"
499
+                        ).'"
500 500
                     >
501
-                        ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
501
+                        ' . $last_checkin->getCheckInText().': '.$timestamp_string.'
502 502
                     </a>';
503 503
             }
504 504
         }
505
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
506
-            ? $name_link . $this->row_actions($actions, true)
505
+        $content = ( ! empty($this->datetime_id) && ! empty($checkins))
506
+            ? $name_link.$this->row_actions($actions, true)
507 507
             : $name_link;
508 508
         return $this->columnContent('ATT_name', $content);
509 509
     }
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
                 ['action' => 'event_registrations', 'event_id' => $event->ID()],
524 524
                 REG_ADMIN_URL
525 525
             );
526
-            $content          = $this->caps_handler->userCanReadRegistrationCheckins()
527
-                ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
526
+            $content = $this->caps_handler->userCanReadRegistrationCheckins()
527
+                ? '<a class="ee-aria-tooltip" href="'.$checkin_link_url.'" aria-label="'
528 528
                 . esc_attr__(
529 529
                     'View Check-ins for this Event',
530 530
                     'event_espresso'
531
-                ) . '">' . $event->name() . '</a>' : $event->name();
531
+                ).'">'.$event->name().'</a>' : $event->name();
532 532
         } catch (EntityNotFoundException $e) {
533 533
             $content = esc_html__('Unknown', 'event_espresso');
534 534
         }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Indentation   +1287 added lines, -1287 removed lines patch added patch discarded remove patch
@@ -17,1297 +17,1297 @@
 block discarded – undo
17 17
  */
18 18
 class Extend_Events_Admin_Page extends Events_Admin_Page
19 19
 {
20
-    /**
21
-     * Extend_Events_Admin_Page constructor.
22
-     *
23
-     * @param bool $routing
24
-     * @throws ReflectionException
25
-     */
26
-    public function __construct($routing = true)
27
-    {
28
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
29
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
30
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
31
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
32
-        }
33
-        parent::__construct($routing);
34
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
35
-    }
36
-
37
-
38
-    protected function _set_page_config()
39
-    {
40
-        parent::_set_page_config();
41
-
42
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
-        // is there an evt_id in the request?
44
-        $EVT_ID                                          = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
-        $EVT_ID                                          = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
-        $TKT_ID                                          = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
-        $new_page_routes                                 = [
48
-            'duplicate_event'          => [
49
-                'func'       => '_duplicate_event',
50
-                'capability' => 'ee_edit_event',
51
-                'obj_id'     => $EVT_ID,
52
-                'noheader'   => true,
53
-            ],
54
-            'import_page'              => [
55
-                'func'       => '_import_page',
56
-                'capability' => 'import',
57
-            ],
58
-            'import'                   => [
59
-                'func'       => '_import_events',
60
-                'capability' => 'import',
61
-                'noheader'   => true,
62
-            ],
63
-            'import_events'            => [
64
-                'func'       => '_import_events',
65
-                'capability' => 'import',
66
-                'noheader'   => true,
67
-            ],
68
-            'export_events'            => [
69
-                'func'       => '_events_export',
70
-                'capability' => 'export',
71
-                'noheader'   => true,
72
-            ],
73
-            'export_categories'        => [
74
-                'func'       => '_categories_export',
75
-                'capability' => 'export',
76
-                'noheader'   => true,
77
-            ],
78
-            'sample_export_file'       => [
79
-                'func'       => '_sample_export_file',
80
-                'capability' => 'export',
81
-                'noheader'   => true,
82
-            ],
83
-            'update_template_settings' => [
84
-                'func'       => '_update_template_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-            'ticket_list_table'        => [
89
-                'func'       => '_tickets_overview_list_table',
90
-                'capability' => 'ee_read_default_tickets',
91
-            ],
92
-        ];
93
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
94
-        $this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
95
-        // don't load these meta boxes if using the advanced editor
96
-        if (
97
-            ! $this->admin_config->useAdvancedEditor()
98
-            || ! $this->feature->allowed('use_default_ticket_manager')
99
-        ) {
100
-            $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
101
-            $this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
102
-
103
-            $legacy_editor_page_routes = [
104
-                'trash_ticket'    => [
105
-                    'func'       => '_trash_or_restore_ticket',
106
-                    'capability' => 'ee_delete_default_ticket',
107
-                    'obj_id'     => $TKT_ID,
108
-                    'noheader'   => true,
109
-                    'args'       => ['trash' => true],
110
-                ],
111
-                'trash_tickets'   => [
112
-                    'func'       => '_trash_or_restore_ticket',
113
-                    'capability' => 'ee_delete_default_tickets',
114
-                    'noheader'   => true,
115
-                    'args'       => ['trash' => true],
116
-                ],
117
-                'restore_ticket'  => [
118
-                    'func'       => '_trash_or_restore_ticket',
119
-                    'capability' => 'ee_delete_default_ticket',
120
-                    'obj_id'     => $TKT_ID,
121
-                    'noheader'   => true,
122
-                ],
123
-                'restore_tickets' => [
124
-                    'func'       => '_trash_or_restore_ticket',
125
-                    'capability' => 'ee_delete_default_tickets',
126
-                    'noheader'   => true,
127
-                ],
128
-                'delete_ticket'   => [
129
-                    'func'       => '_delete_ticket',
130
-                    'capability' => 'ee_delete_default_ticket',
131
-                    'obj_id'     => $TKT_ID,
132
-                    'noheader'   => true,
133
-                ],
134
-                'delete_tickets'  => [
135
-                    'func'       => '_delete_ticket',
136
-                    'capability' => 'ee_delete_default_tickets',
137
-                    'noheader'   => true,
138
-                ],
139
-            ];
140
-            $new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
141
-        }
142
-
143
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
144
-        // partial route/config override
145
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
146
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
147
-
148
-        // add default tickets tab and template settings nav tabs (note union at end)
149
-        $this->_page_config = [
150
-                                  'ticket_list_table' => [
151
-                                      'nav'           => [
152
-                                          'label' => esc_html__('Default Tickets', 'event_espresso'),
153
-                                          'icon'  => 'dashicons-tickets-alt',
154
-                                          'order' => 60,
155
-                                      ],
156
-                                      'list_table'    => 'Tickets_List_Table',
157
-                                      'require_nonce' => false,
158
-                                  ],
159
-                                  'template_settings' => [
160
-                                      'nav'           => [
161
-                                          'label' => esc_html__('Templates', 'event_espresso'),
162
-                                          'icon'  => 'dashicons-layout',
163
-                                          'order' => 30,
164
-                                      ],
165
-                                      'metaboxes'     => array_merge(
166
-                                          ['_publish_post_box'],
167
-                                          $this->_default_espresso_metaboxes
168
-                                      ),
169
-                                      'help_tabs'     => [
170
-                                          'general_settings_templates_help_tab' => [
171
-                                              'title'    => esc_html__('Templates', 'event_espresso'),
172
-                                              'filename' => 'general_settings_templates',
173
-                                          ],
174
-                                      ],
175
-                                      'require_nonce' => false,
176
-                                  ],
177
-                              ] + $this->_page_config;
178
-
179
-        // add filters and actions
180
-        // modifying _views
181
-        add_filter(
182
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
183
-            [$this, 'add_additional_datetime_button'],
184
-            10,
185
-            2
186
-        );
187
-        add_filter(
188
-            'FHEE_event_datetime_metabox_clone_button_template',
189
-            [$this, 'add_datetime_clone_button'],
190
-            10,
191
-            2
192
-        );
193
-        add_filter(
194
-            'FHEE_event_datetime_metabox_timezones_template',
195
-            [$this, 'datetime_timezones_template'],
196
-            10,
197
-            2
198
-        );
199
-        // filters for event list table
200
-        add_filter(
201
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
202
-            [$this, 'extra_list_table_actions'],
203
-            10,
204
-            2
205
-        );
206
-        // legend item
207
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
208
-        add_action('admin_init', [$this, 'admin_init']);
209
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
210
-        // add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 2);
211
-        DuplicateEventButton::addEventEditorPermalinkButton(8);
212
-    }
213
-
214
-
215
-    /**
216
-     * admin_init
217
-     */
218
-    public function admin_init()
219
-    {
220
-        EE_Registry::$i18n_js_strings = array_merge(
221
-            EE_Registry::$i18n_js_strings,
222
-            [
223
-                'image_confirm'          => esc_html__(
224
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
225
-                    'event_espresso'
226
-                ),
227
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
228
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
229
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
230
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
231
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
232
-            ]
233
-        );
234
-    }
235
-
236
-
237
-    /**
238
-     * Add per page screen options to the default ticket list table view.
239
-     *
240
-     * @throws InvalidArgumentException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidInterfaceException
243
-     */
244
-    protected function _add_screen_options_ticket_list_table()
245
-    {
246
-        $this->_per_page_screen_option();
247
-    }
248
-
249
-
250
-    /**
251
-     * @param string      $return    the current html
252
-     * @param int         $id        the post id for the page
253
-     * @param string|null $new_title What the title is
254
-     * @param string|null $new_slug  what the slug is
255
-     * @return string
256
-     * @deprecated 5.0.0.p
257
-     */
258
-    public function extra_permalink_field_buttons(
259
-        string $return,
260
-        int $id,
261
-        ?string $new_title,
262
-        ?string $new_slug
263
-    ): string {
264
-        $return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug);
265
-        return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug);
266
-    }
267
-
268
-
269
-    /**
270
-     * Set the list table views for the default ticket list table view.
271
-     */
272
-    public function _set_list_table_views_ticket_list_table()
273
-    {
274
-        $this->_views = [
275
-            'all'     => [
276
-                'slug'        => 'all',
277
-                'label'       => esc_html__('All', 'event_espresso'),
278
-                'count'       => 0,
279
-                'bulk_action' => [
280
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
281
-                ],
282
-            ],
283
-            'trashed' => [
284
-                'slug'        => 'trashed',
285
-                'label'       => esc_html__('Trash', 'event_espresso'),
286
-                'count'       => 0,
287
-                'bulk_action' => [
288
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
289
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
290
-                ],
291
-            ],
292
-        ];
293
-    }
294
-
295
-
296
-    /**
297
-     * Enqueue scripts and styles for the event editor.
298
-     */
299
-    public function load_scripts_styles_edit()
300
-    {
301
-        if (! $this->admin_config->useAdvancedEditor()) {
302
-            wp_register_script(
303
-                'ee-event-editor-heartbeat',
304
-                EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
305
-                ['ee_admin_js', 'heartbeat'],
306
-                EVENT_ESPRESSO_VERSION,
307
-                true
308
-            );
309
-            wp_enqueue_script('ee-accounting');
310
-            wp_enqueue_script('ee-event-editor-heartbeat');
311
-        }
312
-        wp_enqueue_script('event_editor_js');
313
-        wp_register_style(
314
-            'event-editor-css',
315
-            EVENTS_ASSETS_URL . 'event-editor.css',
316
-            ['ee-admin-css'],
317
-            EVENT_ESPRESSO_VERSION
318
-        );
319
-        wp_enqueue_style('event-editor-css');
320
-        // styles
321
-        wp_enqueue_style('espresso-ui-theme');
322
-    }
323
-
324
-
325
-    /**
326
-     * Sets the views for the default list table view.
327
-     *
328
-     * @throws EE_Error
329
-     * @throws ReflectionException
330
-     */
331
-    protected function _set_list_table_views_default()
332
-    {
333
-        parent::_set_list_table_views_default();
334
-        $new_views    = [
335
-            'today' => [
336
-                'slug'        => 'today',
337
-                'label'       => esc_html__('Today', 'event_espresso'),
338
-                'count'       => $this->total_events_today(),
339
-                'bulk_action' => [
340
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
341
-                ],
342
-            ],
343
-            'month' => [
344
-                'slug'        => 'month',
345
-                'label'       => esc_html__('This Month', 'event_espresso'),
346
-                'count'       => $this->total_events_this_month(),
347
-                'bulk_action' => [
348
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
349
-                ],
350
-            ],
351
-        ];
352
-        $this->_views = array_merge($this->_views, $new_views);
353
-    }
354
-
355
-
356
-    /**
357
-     * Returns the extra action links for the default list table view.
358
-     *
359
-     * @param array    $action_links
360
-     * @param EE_Event $event
361
-     * @return array
362
-     * @throws EE_Error
363
-     * @throws ReflectionException
364
-     */
365
-    public function extra_list_table_actions(array $action_links, EE_Event $event): array
366
-    {
367
-        if (
368
-        EE_Registry::instance()->CAP->current_user_can(
369
-            'ee_read_registrations',
370
-            'espresso_registrations_reports',
371
-            $event->ID()
372
-        )
373
-        ) {
374
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce(
375
-                [
376
-                    'action' => 'reports',
377
-                    'EVT_ID' => $event->ID(),
378
-                ],
379
-                REG_ADMIN_URL
380
-            );
381
-
382
-            $action_links[] = '
20
+	/**
21
+	 * Extend_Events_Admin_Page constructor.
22
+	 *
23
+	 * @param bool $routing
24
+	 * @throws ReflectionException
25
+	 */
26
+	public function __construct($routing = true)
27
+	{
28
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
29
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
30
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
31
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
32
+		}
33
+		parent::__construct($routing);
34
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
35
+	}
36
+
37
+
38
+	protected function _set_page_config()
39
+	{
40
+		parent::_set_page_config();
41
+
42
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
+		// is there an evt_id in the request?
44
+		$EVT_ID                                          = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
+		$EVT_ID                                          = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
+		$TKT_ID                                          = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
+		$new_page_routes                                 = [
48
+			'duplicate_event'          => [
49
+				'func'       => '_duplicate_event',
50
+				'capability' => 'ee_edit_event',
51
+				'obj_id'     => $EVT_ID,
52
+				'noheader'   => true,
53
+			],
54
+			'import_page'              => [
55
+				'func'       => '_import_page',
56
+				'capability' => 'import',
57
+			],
58
+			'import'                   => [
59
+				'func'       => '_import_events',
60
+				'capability' => 'import',
61
+				'noheader'   => true,
62
+			],
63
+			'import_events'            => [
64
+				'func'       => '_import_events',
65
+				'capability' => 'import',
66
+				'noheader'   => true,
67
+			],
68
+			'export_events'            => [
69
+				'func'       => '_events_export',
70
+				'capability' => 'export',
71
+				'noheader'   => true,
72
+			],
73
+			'export_categories'        => [
74
+				'func'       => '_categories_export',
75
+				'capability' => 'export',
76
+				'noheader'   => true,
77
+			],
78
+			'sample_export_file'       => [
79
+				'func'       => '_sample_export_file',
80
+				'capability' => 'export',
81
+				'noheader'   => true,
82
+			],
83
+			'update_template_settings' => [
84
+				'func'       => '_update_template_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+			'ticket_list_table'        => [
89
+				'func'       => '_tickets_overview_list_table',
90
+				'capability' => 'ee_read_default_tickets',
91
+			],
92
+		];
93
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
94
+		$this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
95
+		// don't load these meta boxes if using the advanced editor
96
+		if (
97
+			! $this->admin_config->useAdvancedEditor()
98
+			|| ! $this->feature->allowed('use_default_ticket_manager')
99
+		) {
100
+			$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
101
+			$this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
102
+
103
+			$legacy_editor_page_routes = [
104
+				'trash_ticket'    => [
105
+					'func'       => '_trash_or_restore_ticket',
106
+					'capability' => 'ee_delete_default_ticket',
107
+					'obj_id'     => $TKT_ID,
108
+					'noheader'   => true,
109
+					'args'       => ['trash' => true],
110
+				],
111
+				'trash_tickets'   => [
112
+					'func'       => '_trash_or_restore_ticket',
113
+					'capability' => 'ee_delete_default_tickets',
114
+					'noheader'   => true,
115
+					'args'       => ['trash' => true],
116
+				],
117
+				'restore_ticket'  => [
118
+					'func'       => '_trash_or_restore_ticket',
119
+					'capability' => 'ee_delete_default_ticket',
120
+					'obj_id'     => $TKT_ID,
121
+					'noheader'   => true,
122
+				],
123
+				'restore_tickets' => [
124
+					'func'       => '_trash_or_restore_ticket',
125
+					'capability' => 'ee_delete_default_tickets',
126
+					'noheader'   => true,
127
+				],
128
+				'delete_ticket'   => [
129
+					'func'       => '_delete_ticket',
130
+					'capability' => 'ee_delete_default_ticket',
131
+					'obj_id'     => $TKT_ID,
132
+					'noheader'   => true,
133
+				],
134
+				'delete_tickets'  => [
135
+					'func'       => '_delete_ticket',
136
+					'capability' => 'ee_delete_default_tickets',
137
+					'noheader'   => true,
138
+				],
139
+			];
140
+			$new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
141
+		}
142
+
143
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
144
+		// partial route/config override
145
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
146
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
147
+
148
+		// add default tickets tab and template settings nav tabs (note union at end)
149
+		$this->_page_config = [
150
+								  'ticket_list_table' => [
151
+									  'nav'           => [
152
+										  'label' => esc_html__('Default Tickets', 'event_espresso'),
153
+										  'icon'  => 'dashicons-tickets-alt',
154
+										  'order' => 60,
155
+									  ],
156
+									  'list_table'    => 'Tickets_List_Table',
157
+									  'require_nonce' => false,
158
+								  ],
159
+								  'template_settings' => [
160
+									  'nav'           => [
161
+										  'label' => esc_html__('Templates', 'event_espresso'),
162
+										  'icon'  => 'dashicons-layout',
163
+										  'order' => 30,
164
+									  ],
165
+									  'metaboxes'     => array_merge(
166
+										  ['_publish_post_box'],
167
+										  $this->_default_espresso_metaboxes
168
+									  ),
169
+									  'help_tabs'     => [
170
+										  'general_settings_templates_help_tab' => [
171
+											  'title'    => esc_html__('Templates', 'event_espresso'),
172
+											  'filename' => 'general_settings_templates',
173
+										  ],
174
+									  ],
175
+									  'require_nonce' => false,
176
+								  ],
177
+							  ] + $this->_page_config;
178
+
179
+		// add filters and actions
180
+		// modifying _views
181
+		add_filter(
182
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
183
+			[$this, 'add_additional_datetime_button'],
184
+			10,
185
+			2
186
+		);
187
+		add_filter(
188
+			'FHEE_event_datetime_metabox_clone_button_template',
189
+			[$this, 'add_datetime_clone_button'],
190
+			10,
191
+			2
192
+		);
193
+		add_filter(
194
+			'FHEE_event_datetime_metabox_timezones_template',
195
+			[$this, 'datetime_timezones_template'],
196
+			10,
197
+			2
198
+		);
199
+		// filters for event list table
200
+		add_filter(
201
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
202
+			[$this, 'extra_list_table_actions'],
203
+			10,
204
+			2
205
+		);
206
+		// legend item
207
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
208
+		add_action('admin_init', [$this, 'admin_init']);
209
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
210
+		// add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 2);
211
+		DuplicateEventButton::addEventEditorPermalinkButton(8);
212
+	}
213
+
214
+
215
+	/**
216
+	 * admin_init
217
+	 */
218
+	public function admin_init()
219
+	{
220
+		EE_Registry::$i18n_js_strings = array_merge(
221
+			EE_Registry::$i18n_js_strings,
222
+			[
223
+				'image_confirm'          => esc_html__(
224
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
225
+					'event_espresso'
226
+				),
227
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
228
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
229
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
230
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
231
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
232
+			]
233
+		);
234
+	}
235
+
236
+
237
+	/**
238
+	 * Add per page screen options to the default ticket list table view.
239
+	 *
240
+	 * @throws InvalidArgumentException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidInterfaceException
243
+	 */
244
+	protected function _add_screen_options_ticket_list_table()
245
+	{
246
+		$this->_per_page_screen_option();
247
+	}
248
+
249
+
250
+	/**
251
+	 * @param string      $return    the current html
252
+	 * @param int         $id        the post id for the page
253
+	 * @param string|null $new_title What the title is
254
+	 * @param string|null $new_slug  what the slug is
255
+	 * @return string
256
+	 * @deprecated 5.0.0.p
257
+	 */
258
+	public function extra_permalink_field_buttons(
259
+		string $return,
260
+		int $id,
261
+		?string $new_title,
262
+		?string $new_slug
263
+	): string {
264
+		$return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug);
265
+		return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug);
266
+	}
267
+
268
+
269
+	/**
270
+	 * Set the list table views for the default ticket list table view.
271
+	 */
272
+	public function _set_list_table_views_ticket_list_table()
273
+	{
274
+		$this->_views = [
275
+			'all'     => [
276
+				'slug'        => 'all',
277
+				'label'       => esc_html__('All', 'event_espresso'),
278
+				'count'       => 0,
279
+				'bulk_action' => [
280
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
281
+				],
282
+			],
283
+			'trashed' => [
284
+				'slug'        => 'trashed',
285
+				'label'       => esc_html__('Trash', 'event_espresso'),
286
+				'count'       => 0,
287
+				'bulk_action' => [
288
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
289
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
290
+				],
291
+			],
292
+		];
293
+	}
294
+
295
+
296
+	/**
297
+	 * Enqueue scripts and styles for the event editor.
298
+	 */
299
+	public function load_scripts_styles_edit()
300
+	{
301
+		if (! $this->admin_config->useAdvancedEditor()) {
302
+			wp_register_script(
303
+				'ee-event-editor-heartbeat',
304
+				EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
305
+				['ee_admin_js', 'heartbeat'],
306
+				EVENT_ESPRESSO_VERSION,
307
+				true
308
+			);
309
+			wp_enqueue_script('ee-accounting');
310
+			wp_enqueue_script('ee-event-editor-heartbeat');
311
+		}
312
+		wp_enqueue_script('event_editor_js');
313
+		wp_register_style(
314
+			'event-editor-css',
315
+			EVENTS_ASSETS_URL . 'event-editor.css',
316
+			['ee-admin-css'],
317
+			EVENT_ESPRESSO_VERSION
318
+		);
319
+		wp_enqueue_style('event-editor-css');
320
+		// styles
321
+		wp_enqueue_style('espresso-ui-theme');
322
+	}
323
+
324
+
325
+	/**
326
+	 * Sets the views for the default list table view.
327
+	 *
328
+	 * @throws EE_Error
329
+	 * @throws ReflectionException
330
+	 */
331
+	protected function _set_list_table_views_default()
332
+	{
333
+		parent::_set_list_table_views_default();
334
+		$new_views    = [
335
+			'today' => [
336
+				'slug'        => 'today',
337
+				'label'       => esc_html__('Today', 'event_espresso'),
338
+				'count'       => $this->total_events_today(),
339
+				'bulk_action' => [
340
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
341
+				],
342
+			],
343
+			'month' => [
344
+				'slug'        => 'month',
345
+				'label'       => esc_html__('This Month', 'event_espresso'),
346
+				'count'       => $this->total_events_this_month(),
347
+				'bulk_action' => [
348
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
349
+				],
350
+			],
351
+		];
352
+		$this->_views = array_merge($this->_views, $new_views);
353
+	}
354
+
355
+
356
+	/**
357
+	 * Returns the extra action links for the default list table view.
358
+	 *
359
+	 * @param array    $action_links
360
+	 * @param EE_Event $event
361
+	 * @return array
362
+	 * @throws EE_Error
363
+	 * @throws ReflectionException
364
+	 */
365
+	public function extra_list_table_actions(array $action_links, EE_Event $event): array
366
+	{
367
+		if (
368
+		EE_Registry::instance()->CAP->current_user_can(
369
+			'ee_read_registrations',
370
+			'espresso_registrations_reports',
371
+			$event->ID()
372
+		)
373
+		) {
374
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce(
375
+				[
376
+					'action' => 'reports',
377
+					'EVT_ID' => $event->ID(),
378
+				],
379
+				REG_ADMIN_URL
380
+			);
381
+
382
+			$action_links[] = '
383 383
                 <a href="' . $reports_link . '"
384 384
                     aria-label="' . esc_attr__('View Report', 'event_espresso') . '"
385 385
                     class="ee-aria-tooltip button button--icon-only"
386 386
                 >
387 387
                     <span class="dashicons dashicons-chart-bar"></span>
388 388
                 </a>';
389
-        }
390
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
391
-            EE_Registry::instance()->load_helper('MSG_Template');
392
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
393
-                'see_notifications_for',
394
-                null,
395
-                ['EVT_ID' => $event->ID()]
396
-            );
397
-        }
398
-        return $action_links;
399
-    }
400
-
401
-
402
-    /**
403
-     * @param $items
404
-     * @return mixed
405
-     */
406
-    public function additional_legend_items($items)
407
-    {
408
-        if (
409
-        EE_Registry::instance()->CAP->current_user_can(
410
-            'ee_read_registrations',
411
-            'espresso_registrations_reports'
412
-        )
413
-        ) {
414
-            $items['reports'] = [
415
-                'class' => 'dashicons dashicons-chart-bar',
416
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
417
-            ];
418
-        }
419
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
420
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
421
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
422
-            // (can only use numeric offsets when treating strings as arrays)
423
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
424
-                $items['view_related_messages'] = [
425
-                    'class' => $related_for_icon['css_class'],
426
-                    'desc'  => $related_for_icon['label'],
427
-                ];
428
-            }
429
-        }
430
-        return $items;
431
-    }
432
-
433
-
434
-    /**
435
-     * This is the callback method for the duplicate event route
436
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
437
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
438
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
439
-     * After duplication the redirect is to the new event edit page.
440
-     *
441
-     * @return void
442
-     * @throws EE_Error If EE_Event is not available with given ID
443
-     * @throws ReflectionException
444
-     * @access protected
445
-     */
446
-    protected function _duplicate_event()
447
-    {
448
-        // first make sure the ID for the event is in the request.
449
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
450
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
451
-        if (! $EVT_ID) {
452
-            EE_Error::add_error(
453
-                esc_html__(
454
-                    'In order to duplicate an event an Event ID is required.  None was given.',
455
-                    'event_espresso'
456
-                ),
457
-                __FILE__,
458
-                __FUNCTION__,
459
-                __LINE__
460
-            );
461
-            $this->_redirect_after_action(false, '', '', [], true);
462
-            return;
463
-        }
464
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
465
-        $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
466
-        if (! $orig_event instanceof EE_Event) {
467
-            throw new EE_Error(
468
-                sprintf(
469
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
470
-                    $EVT_ID
471
-                )
472
-            );
473
-        }
474
-        // k now let's clone the $orig_event before getting relations
475
-        $new_event = clone $orig_event;
476
-        // original datetimes
477
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
478
-        // other original relations
479
-        $orig_ven = $orig_event->get_many_related('Venue');
480
-        // reset the ID and modify other details to make it clear this is a dupe
481
-        $new_event->set('EVT_ID', 0);
482
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
483
-        $new_event->set('EVT_name', $new_name);
484
-        $new_event->set(
485
-            'EVT_slug',
486
-            wp_unique_post_slug(
487
-                sanitize_title($orig_event->name()),
488
-                0,
489
-                'publish',
490
-                EspressoPostType::EVENTS,
491
-                0
492
-            )
493
-        );
494
-        $new_event->set('status', 'draft');
495
-        // duplicate discussion settings
496
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
497
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
498
-        // save the new event
499
-        $new_event->save();
500
-        // venues
501
-        foreach ($orig_ven as $ven) {
502
-            $new_event->_add_relation_to($ven, 'Venue');
503
-        }
504
-        $new_event->save();
505
-        // now we need to get the question group relations and handle that
506
-        // first primary question groups
507
-        $orig_primary_qgs = $orig_event->get_many_related(
508
-            'Question_Group',
509
-            [['Event_Question_Group.EQG_primary' => true]]
510
-        );
511
-        if (! empty($orig_primary_qgs)) {
512
-            foreach ($orig_primary_qgs as $obj) {
513
-                if ($obj instanceof EE_Question_Group) {
514
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
515
-                }
516
-            }
517
-        }
518
-        // next additional attendee question groups
519
-        $orig_additional_qgs = $orig_event->get_many_related(
520
-            'Question_Group',
521
-            [['Event_Question_Group.EQG_additional' => true]]
522
-        );
523
-        if (! empty($orig_additional_qgs)) {
524
-            foreach ($orig_additional_qgs as $obj) {
525
-                if ($obj instanceof EE_Question_Group) {
526
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
527
-                }
528
-            }
529
-        }
530
-
531
-        $new_event->save();
532
-
533
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
534
-        $cloned_tickets = [];
535
-        foreach ($orig_datetimes as $orig_dtt) {
536
-            if (! $orig_dtt instanceof EE_Datetime) {
537
-                continue;
538
-            }
539
-            $new_dtt      = clone $orig_dtt;
540
-            $orig_tickets = $orig_dtt->tickets();
541
-            // save new dtt then add to event
542
-            $new_dtt->set('DTT_ID', 0);
543
-            $new_dtt->set('DTT_sold', 0);
544
-            $new_dtt->set_reserved(0);
545
-            $new_dtt->save();
546
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
547
-            $new_event->save();
548
-            // now let's get the ticket relations setup.
549
-            foreach ((array) $orig_tickets as $orig_ticket) {
550
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
551
-                if (! $orig_ticket instanceof EE_Ticket) {
552
-                    continue;
553
-                }
554
-                // is this ticket archived?  If it is then let's skip
555
-                if ($orig_ticket->get('TKT_deleted')) {
556
-                    continue;
557
-                }
558
-                // does this original ticket already exist in the clone_tickets cache?
559
-                //  If so we'll just use the new ticket from it.
560
-                if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
561
-                    $new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
562
-                } else {
563
-                    $new_ticket = clone $orig_ticket;
564
-                    // get relations on the $orig_ticket that we need to set up.
565
-                    $orig_prices = $orig_ticket->prices();
566
-                    $new_ticket->set('TKT_ID', 0);
567
-                    $new_ticket->set('TKT_sold', 0);
568
-                    $new_ticket->set('TKT_reserved', 0);
569
-                    // make sure new ticket has ID.
570
-                    $new_ticket->save();
571
-                    // price relations on new ticket need to be setup.
572
-                    foreach ($orig_prices as $orig_price) {
573
-                        // don't clone default prices, just add a relation
574
-                        if ($orig_price->is_default()) {
575
-                            $new_ticket->_add_relation_to($orig_price, 'Price');
576
-                            $new_ticket->save();
577
-                            continue;
578
-                        }
579
-                        $new_price = clone $orig_price;
580
-                        $new_price->set('PRC_ID', 0);
581
-                        $new_price->save();
582
-                        $new_ticket->_add_relation_to($new_price, 'Price');
583
-                    }
584
-                    $new_ticket->save();
585
-
586
-                    do_action(
587
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
588
-                        $orig_ticket,
589
-                        $new_ticket,
590
-                        $orig_prices,
591
-                        $orig_event,
592
-                        $orig_dtt,
593
-                        $new_dtt
594
-                    );
595
-                    $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
596
-                }
597
-                // k now we can add the new ticket as a relation to the new datetime
598
-                // and make sure it's added to our cached $cloned_tickets array
599
-                // for use with later datetimes that have the same ticket.
600
-                $new_dtt->_add_relation_to($new_ticket, 'Ticket');
601
-            }
602
-            $new_dtt->save();
603
-        }
604
-        // clone taxonomy information
605
-        $taxonomies_to_clone_with = apply_filters(
606
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
607
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
608
-        );
609
-        // get terms for original event (notice)
610
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
611
-        // loop through terms and add them to new event.
612
-        foreach ($orig_terms as $term) {
613
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
614
-        }
615
-
616
-        // duplicate other core WP_Post items for this event.
617
-        // post thumbnail (feature image).
618
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
619
-        if ($feature_image_id) {
620
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
621
-        }
622
-
623
-        // duplicate page_template setting
624
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
625
-        if ($page_template) {
626
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
627
-        }
628
-
629
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
630
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
631
-        if ($new_event->ID()) {
632
-            $redirect_args = [
633
-                'post'   => $new_event->ID(),
634
-                'action' => 'edit',
635
-            ];
636
-            EE_Error::add_success(
637
-                esc_html__(
638
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
639
-                    'event_espresso'
640
-                )
641
-            );
642
-        } else {
643
-            $redirect_args = [
644
-                'action' => 'default',
645
-            ];
646
-            EE_Error::add_error(
647
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
648
-                __FILE__,
649
-                __FUNCTION__,
650
-                __LINE__
651
-            );
652
-        }
653
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
654
-    }
655
-
656
-
657
-    /**
658
-     * Generates output for the import page.
659
-     *
660
-     * @throws EE_Error
661
-     */
662
-    protected function _import_page()
663
-    {
664
-        $title = esc_html__('Import', 'event_espresso');
665
-        $intro = esc_html__(
666
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
667
-            'event_espresso'
668
-        );
669
-
670
-        $form_url = EVENTS_ADMIN_URL;
671
-        $action   = 'import_events';
672
-        $type     = 'csv';
673
-
674
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
675
-            $title,
676
-            $intro,
677
-            $form_url,
678
-            $action,
679
-            $type
680
-        );
681
-
682
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
683
-            ['action' => 'sample_export_file'],
684
-            $this->_admin_base_url
685
-        );
686
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
687
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
688
-            $this->_template_args,
689
-            true
690
-        );
691
-        $this->display_admin_page_with_sidebar();
692
-    }
693
-
694
-
695
-    /**
696
-     * _import_events
697
-     * This handles displaying the screen and running imports for importing events.
698
-     *
699
-     * @return void
700
-     * @throws EE_Error
701
-     */
702
-    protected function _import_events()
703
-    {
704
-        require_once(EE_CLASSES . 'EE_Import.class.php');
705
-        $success = EE_Import::instance()->import();
706
-        $this->_redirect_after_action(
707
-            $success,
708
-            esc_html__('Import File', 'event_espresso'),
709
-            'ran',
710
-            ['action' => 'import_page'],
711
-            true
712
-        );
713
-    }
714
-
715
-
716
-    /**
717
-     * _events_export
718
-     * Will export all (or just the given event) to a Excel compatible file.
719
-     *
720
-     * @access protected
721
-     * @return void
722
-     */
723
-    protected function _events_export()
724
-    {
725
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
726
-        $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
727
-        $this->request->mergeRequestParams(
728
-            [
729
-                'export' => 'report',
730
-                'action' => 'all_event_data',
731
-                'EVT_ID' => $EVT_ID,
732
-            ]
733
-        );
734
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
735
-            require_once(EE_CLASSES . 'EE_Export.class.php');
736
-            $EE_Export = EE_Export::instance($this->request->requestParams());
737
-            $EE_Export->export();
738
-        }
739
-    }
740
-
741
-
742
-    /**
743
-     * handle category exports()
744
-     *
745
-     * @return void
746
-     */
747
-    protected function _categories_export()
748
-    {
749
-        $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
750
-        $this->request->mergeRequestParams(
751
-            [
752
-                'export' => 'report',
753
-                'action' => 'categories',
754
-                'EVT_ID' => $EVT_ID,
755
-            ]
756
-        );
757
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
758
-            require_once(EE_CLASSES . 'EE_Export.class.php');
759
-            $EE_Export = EE_Export::instance($this->request->requestParams());
760
-            $EE_Export->export();
761
-        }
762
-    }
763
-
764
-
765
-    /**
766
-     * Creates a sample CSV file for importing
767
-     */
768
-    protected function _sample_export_file()
769
-    {
770
-        $EE_Export = EE_Export::instance();
771
-        if ($EE_Export instanceof EE_Export) {
772
-            $EE_Export->export();
773
-        }
774
-    }
775
-
776
-
777
-    /*************        Template Settings        *************/
778
-    /**
779
-     * Generates template settings page output
780
-     *
781
-     * @throws DomainException
782
-     * @throws EE_Error
783
-     * @throws InvalidArgumentException
784
-     * @throws InvalidDataTypeException
785
-     * @throws InvalidInterfaceException
786
-     */
787
-    protected function _template_settings()
788
-    {
789
-        $this->_template_args['values'] = $this->_yes_no_values;
790
-        /**
791
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
792
-         * from General_Settings_Admin_Page to here.
793
-         */
794
-        $this->_template_args = apply_filters(
795
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
796
-            $this->_template_args
797
-        );
798
-        $this->_set_add_edit_form_tags('update_template_settings');
799
-        $this->_set_publish_post_box_vars();
800
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
801
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
802
-            $this->_template_args,
803
-            true
804
-        );
805
-        $this->display_admin_page_with_sidebar();
806
-    }
807
-
808
-
809
-    /**
810
-     * Handler for updating template settings.
811
-     *
812
-     * @throws EE_Error
813
-     */
814
-    protected function _update_template_settings()
815
-    {
816
-        /**
817
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
818
-         * from General_Settings_Admin_Page to here.
819
-         */
820
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
821
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
822
-            EE_Registry::instance()->CFG->template_settings,
823
-            $this->request->requestParams()
824
-        );
825
-        // update custom post type slugs and detect if we need to flush rewrite rules
826
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
827
-
828
-        $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
829
-
830
-        EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
831
-            ? EEH_URL::slugify($event_cpt_slug, 'events')
832
-            : EE_Registry::instance()->CFG->core->event_cpt_slug;
833
-
834
-        $what    = esc_html__('Template Settings', 'event_espresso');
835
-        $success = $this->_update_espresso_configuration(
836
-            $what,
837
-            EE_Registry::instance()->CFG->template_settings,
838
-            __FILE__,
839
-            __FUNCTION__,
840
-            __LINE__
841
-        );
842
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
843
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
844
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
845
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
846
-            );
847
-            $rewrite_rules->flush();
848
-        }
849
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
850
-    }
851
-
852
-
853
-    /**
854
-     * _premium_event_editor_meta_boxes
855
-     * add all metaboxes related to the event_editor
856
-     *
857
-     * @access protected
858
-     * @return void
859
-     * @throws EE_Error
860
-     * @throws ReflectionException
861
-     */
862
-    protected function _premium_event_editor_meta_boxes()
863
-    {
864
-        $this->verify_cpt_object();
865
-        // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
866
-        if (
867
-            ! $this->admin_config->useAdvancedEditor()
868
-            || ! $this->feature->allowed('use_reg_options_meta_box')
869
-        ) {
870
-            $this->addMetaBox(
871
-                'espresso_event_editor_event_options',
872
-                esc_html__('Event Registration Options', 'event_espresso'),
873
-                [$this, 'registration_options_meta_box'],
874
-                $this->page_slug,
875
-                'side',
876
-                'core'
877
-            );
878
-        }
879
-    }
880
-
881
-
882
-    /**
883
-     * override caf metabox
884
-     *
885
-     * @return void
886
-     * @throws EE_Error
887
-     * @throws ReflectionException
888
-     */
889
-    public function registration_options_meta_box()
890
-    {
891
-        $yes_no_values = [
892
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
893
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
894
-        ];
895
-
896
-        $default_reg_status_values = EEM_Registration::reg_status_array(
897
-            [
898
-                EEM_Registration::status_id_cancelled,
899
-                EEM_Registration::status_id_declined,
900
-                EEM_Registration::status_id_incomplete,
901
-                EEM_Registration::status_id_wait_list,
902
-            ],
903
-            true
904
-        );
905
-
906
-        $template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
907
-        $template_args['_event']           = $this->_cpt_model_obj;
908
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
909
-
910
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
911
-            'default_reg_status',
912
-            $default_reg_status_values,
913
-            $this->_cpt_model_obj->default_registration_status(),
914
-            '',
915
-            'ee-input-width--reg',
916
-            false
917
-        );
918
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
919
-            'display_desc',
920
-            $yes_no_values,
921
-            $this->_cpt_model_obj->display_description()
922
-        );
923
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
924
-            'display_ticket_selector',
925
-            $yes_no_values,
926
-            $this->_cpt_model_obj->display_ticket_selector(),
927
-            '',
928
-            'ee-input-width--small',
929
-            false
930
-        );
931
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
932
-            'EVT_default_registration_status',
933
-            $default_reg_status_values,
934
-            $this->_cpt_model_obj->default_registration_status(),
935
-            '',
936
-            'ee-input-width--reg',
937
-            false
938
-        );
939
-        $template_args['additional_registration_options'] = apply_filters(
940
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
941
-            '',
942
-            $template_args,
943
-            $yes_no_values,
944
-            $default_reg_status_values
945
-        );
946
-        EEH_Template::display_template(
947
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
948
-            $template_args
949
-        );
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * wp_list_table_mods for caf
956
-     * ============================
957
-     */
958
-
959
-
960
-    /**
961
-     * espresso_event_months_dropdown
962
-     *
963
-     * @deprecatd 5.0.0.p
964
-     * @access public
965
-     * @return string                dropdown listing month/year selections for events.
966
-     * @throws EE_Error
967
-     */
968
-    public function espresso_event_months_dropdown(): string
969
-    {
970
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
971
-        // Note we need to include any other filters that are set!
972
-        return EEH_Form_Fields::generate_event_months_dropdown(
973
-            $this->request->getRequestParam('month_range'),
974
-            $this->request->getRequestParam('status'),
975
-            $this->request->getRequestParam('EVT_CAT', 0, 'int'),
976
-            $this->request->getRequestParam('active_status')
977
-        );
978
-    }
979
-
980
-
981
-    /**
982
-     * returns a list of "active" statuses on the event
983
-     *
984
-     * @deprecatd 5.0.0.p
985
-     * @param string $current_value whatever the current active status is
986
-     * @return string
987
-     */
988
-    public function active_status_dropdown(string $current_value = ''): string
989
-    {
990
-        $select_name = 'active_status';
991
-        $values      = [
992
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
993
-            'active'   => esc_html__('Active', 'event_espresso'),
994
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
995
-            'expired'  => esc_html__('Expired', 'event_espresso'),
996
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
997
-        ];
998
-
999
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value);
1000
-    }
1001
-
1002
-
1003
-    /**
1004
-     * returns a list of "venues"
1005
-     *
1006
-     * @deprecatd 5.0.0.p
1007
-     * @param string $current_value whatever the current active status is
1008
-     * @return string
1009
-     * @throws EE_Error
1010
-     * @throws ReflectionException
1011
-     */
1012
-    protected function venuesDropdown(string $current_value = ''): string
1013
-    {
1014
-        $values = ['' => esc_html__('All Venues', 'event_espresso')];
1015
-        // populate the list of venues.
1016
-        $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1017
-
1018
-        foreach ($venues as $venue) {
1019
-            $values[ $venue->ID() ] = $venue->name();
1020
-        }
1021
-
1022
-        return EEH_Form_Fields::select_input('venue', $values, $current_value);
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * output a dropdown of the categories for the category filter on the event admin list table
1028
-     *
1029
-     * @deprecatd 5.0.0.p
1030
-     * @access  public
1031
-     * @return string html
1032
-     * @throws EE_Error
1033
-     * @throws ReflectionException
1034
-     */
1035
-    public function category_dropdown(): string
1036
-    {
1037
-        return EEH_Form_Fields::generate_event_category_dropdown(
1038
-            $this->request->getRequestParam('EVT_CAT', -1, 'int')
1039
-        );
1040
-    }
1041
-
1042
-
1043
-    /**
1044
-     * get total number of events today
1045
-     *
1046
-     * @access public
1047
-     * @return int
1048
-     * @throws EE_Error
1049
-     * @throws InvalidArgumentException
1050
-     * @throws InvalidDataTypeException
1051
-     * @throws InvalidInterfaceException
1052
-     * @throws ReflectionException
1053
-     */
1054
-    public function total_events_today(): int
1055
-    {
1056
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1057
-            'DTT_EVT_start',
1058
-            date('Y-m-d') . ' 00:00:00',
1059
-            'Y-m-d H:i:s',
1060
-            'UTC'
1061
-        );
1062
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1063
-            'DTT_EVT_start',
1064
-            date('Y-m-d') . ' 23:59:59',
1065
-            'Y-m-d H:i:s',
1066
-            'UTC'
1067
-        );
1068
-        $where = [
1069
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1070
-        ];
1071
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * get total number of events this month
1077
-     *
1078
-     * @access public
1079
-     * @return int
1080
-     * @throws EE_Error
1081
-     * @throws InvalidArgumentException
1082
-     * @throws InvalidDataTypeException
1083
-     * @throws InvalidInterfaceException
1084
-     * @throws ReflectionException
1085
-     */
1086
-    public function total_events_this_month(): int
1087
-    {
1088
-        // Dates
1089
-        $this_year_r     = date('Y');
1090
-        $this_month_r    = date('m');
1091
-        $days_this_month = date('t');
1092
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1093
-            'DTT_EVT_start',
1094
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1095
-            'Y-m-d H:i:s',
1096
-            'UTC'
1097
-        );
1098
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1099
-            'DTT_EVT_start',
1100
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1101
-            'Y-m-d H:i:s',
1102
-            'UTC'
1103
-        );
1104
-        $where           = [
1105
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1106
-        ];
1107
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1108
-    }
1109
-
1110
-
1111
-    /** DEFAULT TICKETS STUFF **/
1112
-
1113
-    /**
1114
-     * Output default tickets list table view.
1115
-     *
1116
-     * @throws EE_Error
1117
-     */
1118
-    public function _tickets_overview_list_table()
1119
-    {
1120
-        if (
1121
-            $this->admin_config->useAdvancedEditor()
1122
-            && $this->feature->allowed('use_default_ticket_manager')
1123
-        ) {
1124
-            // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1125
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1126
-                EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1127
-                [],
1128
-                true
1129
-            );
1130
-            $this->display_admin_page_with_no_sidebar();
1131
-        } else {
1132
-            $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1133
-            $this->display_admin_list_table_page_with_no_sidebar();
1134
-        }
1135
-    }
1136
-
1137
-
1138
-    /**
1139
-     * @param int  $per_page
1140
-     * @param bool $count
1141
-     * @param bool $trashed
1142
-     * @return EE_Soft_Delete_Base_Class[]|int
1143
-     * @throws EE_Error
1144
-     * @throws ReflectionException
1145
-     */
1146
-    public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false)
1147
-    {
1148
-        $orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1149
-        $order   = $this->request->getRequestParam('order', 'ASC');
1150
-        switch ($orderby) {
1151
-            case 'TKT_name':
1152
-                $orderby = ['TKT_name' => $order];
1153
-                break;
1154
-            case 'TKT_price':
1155
-                $orderby = ['TKT_price' => $order];
1156
-                break;
1157
-            case 'TKT_uses':
1158
-                $orderby = ['TKT_uses' => $order];
1159
-                break;
1160
-            case 'TKT_min':
1161
-                $orderby = ['TKT_min' => $order];
1162
-                break;
1163
-            case 'TKT_max':
1164
-                $orderby = ['TKT_max' => $order];
1165
-                break;
1166
-            case 'TKT_qty':
1167
-                $orderby = ['TKT_qty' => $order];
1168
-                break;
1169
-        }
1170
-
1171
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1172
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1173
-        $offset       = ($current_page - 1) * $per_page;
1174
-
1175
-        $where = [
1176
-            'TKT_is_default' => 1,
1177
-            'TKT_deleted'    => $trashed,
1178
-        ];
1179
-
1180
-        $search_term = $this->request->getRequestParam('s');
1181
-        if ($search_term) {
1182
-            $search_term = '%' . $search_term . '%';
1183
-            $where['OR'] = [
1184
-                'TKT_name'        => ['LIKE', $search_term],
1185
-                'TKT_description' => ['LIKE', $search_term],
1186
-            ];
1187
-        }
1188
-
1189
-        return $count
1190
-            ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1191
-            : EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1192
-                [
1193
-                    $where,
1194
-                    'order_by' => $orderby,
1195
-                    'limit'    => [$offset, $per_page],
1196
-                    'group_by' => 'TKT_ID',
1197
-                ]
1198
-            );
1199
-    }
1200
-
1201
-
1202
-    /**
1203
-     * @param bool $trash
1204
-     * @throws EE_Error
1205
-     * @throws InvalidArgumentException
1206
-     * @throws InvalidDataTypeException
1207
-     * @throws InvalidInterfaceException
1208
-     * @throws ReflectionException
1209
-     */
1210
-    protected function _trash_or_restore_ticket(bool $trash = false)
1211
-    {
1212
-        $success = 1;
1213
-        $TKT     = EEM_Ticket::instance();
1214
-        // checkboxes?
1215
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1216
-        if (! empty($checkboxes)) {
1217
-            // if array has more than one element then success message should be plural
1218
-            $success = count($checkboxes) > 1 ? 2 : 1;
1219
-            // cycle thru the boxes
1220
-            foreach ($checkboxes as $TKT_ID => $value) {
1221
-                if ($trash) {
1222
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1223
-                        $success = 0;
1224
-                    }
1225
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1226
-                    $success = 0;
1227
-                }
1228
-            }
1229
-        } else {
1230
-            // grab single id and trash
1231
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1232
-            if ($trash) {
1233
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1234
-                    $success = 0;
1235
-                }
1236
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1237
-                $success = 0;
1238
-            }
1239
-        }
1240
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1241
-        $query_args  = [
1242
-            'action' => 'ticket_list_table',
1243
-            'status' => $trash ? '' : 'trashed',
1244
-        ];
1245
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1246
-    }
1247
-
1248
-
1249
-    /**
1250
-     * Handles trashing default ticket.
1251
-     *
1252
-     * @throws EE_Error
1253
-     * @throws ReflectionException
1254
-     */
1255
-    protected function _delete_ticket()
1256
-    {
1257
-        $success = 1;
1258
-        // checkboxes?
1259
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1260
-        if (! empty($checkboxes)) {
1261
-            // if array has more than one element then success message should be plural
1262
-            $success = count($checkboxes) > 1 ? 2 : 1;
1263
-            // cycle thru the boxes
1264
-            foreach ($checkboxes as $TKT_ID => $value) {
1265
-                // delete
1266
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1267
-                    $success = 0;
1268
-                }
1269
-            }
1270
-        } else {
1271
-            // grab single id and trash
1272
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1273
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1274
-                $success = 0;
1275
-            }
1276
-        }
1277
-        $action_desc = 'deleted';
1278
-        $query_args  = [
1279
-            'action' => 'ticket_list_table',
1280
-            'status' => 'trashed',
1281
-        ];
1282
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1283
-        if (
1284
-        EEM_Ticket::instance()->count_deleted_and_undeleted(
1285
-            [['TKT_is_default' => 1]],
1286
-            'TKT_ID',
1287
-            true
1288
-        )
1289
-        ) {
1290
-            $query_args = [];
1291
-        }
1292
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1293
-    }
1294
-
1295
-
1296
-    /**
1297
-     * @param int $TKT_ID
1298
-     * @return bool|int
1299
-     * @throws EE_Error
1300
-     * @throws ReflectionException
1301
-     */
1302
-    protected function _delete_the_ticket(int $TKT_ID)
1303
-    {
1304
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1305
-        if (! $ticket instanceof EE_Ticket) {
1306
-            return false;
1307
-        }
1308
-        $ticket->_remove_relations('Datetime');
1309
-        // delete all related prices first
1310
-        $ticket->delete_related_permanently('Price');
1311
-        return $ticket->delete_permanently();
1312
-    }
389
+		}
390
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
391
+			EE_Registry::instance()->load_helper('MSG_Template');
392
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
393
+				'see_notifications_for',
394
+				null,
395
+				['EVT_ID' => $event->ID()]
396
+			);
397
+		}
398
+		return $action_links;
399
+	}
400
+
401
+
402
+	/**
403
+	 * @param $items
404
+	 * @return mixed
405
+	 */
406
+	public function additional_legend_items($items)
407
+	{
408
+		if (
409
+		EE_Registry::instance()->CAP->current_user_can(
410
+			'ee_read_registrations',
411
+			'espresso_registrations_reports'
412
+		)
413
+		) {
414
+			$items['reports'] = [
415
+				'class' => 'dashicons dashicons-chart-bar',
416
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
417
+			];
418
+		}
419
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
420
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
421
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
422
+			// (can only use numeric offsets when treating strings as arrays)
423
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
424
+				$items['view_related_messages'] = [
425
+					'class' => $related_for_icon['css_class'],
426
+					'desc'  => $related_for_icon['label'],
427
+				];
428
+			}
429
+		}
430
+		return $items;
431
+	}
432
+
433
+
434
+	/**
435
+	 * This is the callback method for the duplicate event route
436
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
437
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
438
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
439
+	 * After duplication the redirect is to the new event edit page.
440
+	 *
441
+	 * @return void
442
+	 * @throws EE_Error If EE_Event is not available with given ID
443
+	 * @throws ReflectionException
444
+	 * @access protected
445
+	 */
446
+	protected function _duplicate_event()
447
+	{
448
+		// first make sure the ID for the event is in the request.
449
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
450
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
451
+		if (! $EVT_ID) {
452
+			EE_Error::add_error(
453
+				esc_html__(
454
+					'In order to duplicate an event an Event ID is required.  None was given.',
455
+					'event_espresso'
456
+				),
457
+				__FILE__,
458
+				__FUNCTION__,
459
+				__LINE__
460
+			);
461
+			$this->_redirect_after_action(false, '', '', [], true);
462
+			return;
463
+		}
464
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
465
+		$orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
466
+		if (! $orig_event instanceof EE_Event) {
467
+			throw new EE_Error(
468
+				sprintf(
469
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
470
+					$EVT_ID
471
+				)
472
+			);
473
+		}
474
+		// k now let's clone the $orig_event before getting relations
475
+		$new_event = clone $orig_event;
476
+		// original datetimes
477
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
478
+		// other original relations
479
+		$orig_ven = $orig_event->get_many_related('Venue');
480
+		// reset the ID and modify other details to make it clear this is a dupe
481
+		$new_event->set('EVT_ID', 0);
482
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
483
+		$new_event->set('EVT_name', $new_name);
484
+		$new_event->set(
485
+			'EVT_slug',
486
+			wp_unique_post_slug(
487
+				sanitize_title($orig_event->name()),
488
+				0,
489
+				'publish',
490
+				EspressoPostType::EVENTS,
491
+				0
492
+			)
493
+		);
494
+		$new_event->set('status', 'draft');
495
+		// duplicate discussion settings
496
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
497
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
498
+		// save the new event
499
+		$new_event->save();
500
+		// venues
501
+		foreach ($orig_ven as $ven) {
502
+			$new_event->_add_relation_to($ven, 'Venue');
503
+		}
504
+		$new_event->save();
505
+		// now we need to get the question group relations and handle that
506
+		// first primary question groups
507
+		$orig_primary_qgs = $orig_event->get_many_related(
508
+			'Question_Group',
509
+			[['Event_Question_Group.EQG_primary' => true]]
510
+		);
511
+		if (! empty($orig_primary_qgs)) {
512
+			foreach ($orig_primary_qgs as $obj) {
513
+				if ($obj instanceof EE_Question_Group) {
514
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
515
+				}
516
+			}
517
+		}
518
+		// next additional attendee question groups
519
+		$orig_additional_qgs = $orig_event->get_many_related(
520
+			'Question_Group',
521
+			[['Event_Question_Group.EQG_additional' => true]]
522
+		);
523
+		if (! empty($orig_additional_qgs)) {
524
+			foreach ($orig_additional_qgs as $obj) {
525
+				if ($obj instanceof EE_Question_Group) {
526
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
527
+				}
528
+			}
529
+		}
530
+
531
+		$new_event->save();
532
+
533
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
534
+		$cloned_tickets = [];
535
+		foreach ($orig_datetimes as $orig_dtt) {
536
+			if (! $orig_dtt instanceof EE_Datetime) {
537
+				continue;
538
+			}
539
+			$new_dtt      = clone $orig_dtt;
540
+			$orig_tickets = $orig_dtt->tickets();
541
+			// save new dtt then add to event
542
+			$new_dtt->set('DTT_ID', 0);
543
+			$new_dtt->set('DTT_sold', 0);
544
+			$new_dtt->set_reserved(0);
545
+			$new_dtt->save();
546
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
547
+			$new_event->save();
548
+			// now let's get the ticket relations setup.
549
+			foreach ((array) $orig_tickets as $orig_ticket) {
550
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
551
+				if (! $orig_ticket instanceof EE_Ticket) {
552
+					continue;
553
+				}
554
+				// is this ticket archived?  If it is then let's skip
555
+				if ($orig_ticket->get('TKT_deleted')) {
556
+					continue;
557
+				}
558
+				// does this original ticket already exist in the clone_tickets cache?
559
+				//  If so we'll just use the new ticket from it.
560
+				if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
561
+					$new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
562
+				} else {
563
+					$new_ticket = clone $orig_ticket;
564
+					// get relations on the $orig_ticket that we need to set up.
565
+					$orig_prices = $orig_ticket->prices();
566
+					$new_ticket->set('TKT_ID', 0);
567
+					$new_ticket->set('TKT_sold', 0);
568
+					$new_ticket->set('TKT_reserved', 0);
569
+					// make sure new ticket has ID.
570
+					$new_ticket->save();
571
+					// price relations on new ticket need to be setup.
572
+					foreach ($orig_prices as $orig_price) {
573
+						// don't clone default prices, just add a relation
574
+						if ($orig_price->is_default()) {
575
+							$new_ticket->_add_relation_to($orig_price, 'Price');
576
+							$new_ticket->save();
577
+							continue;
578
+						}
579
+						$new_price = clone $orig_price;
580
+						$new_price->set('PRC_ID', 0);
581
+						$new_price->save();
582
+						$new_ticket->_add_relation_to($new_price, 'Price');
583
+					}
584
+					$new_ticket->save();
585
+
586
+					do_action(
587
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
588
+						$orig_ticket,
589
+						$new_ticket,
590
+						$orig_prices,
591
+						$orig_event,
592
+						$orig_dtt,
593
+						$new_dtt
594
+					);
595
+					$cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
596
+				}
597
+				// k now we can add the new ticket as a relation to the new datetime
598
+				// and make sure it's added to our cached $cloned_tickets array
599
+				// for use with later datetimes that have the same ticket.
600
+				$new_dtt->_add_relation_to($new_ticket, 'Ticket');
601
+			}
602
+			$new_dtt->save();
603
+		}
604
+		// clone taxonomy information
605
+		$taxonomies_to_clone_with = apply_filters(
606
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
607
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
608
+		);
609
+		// get terms for original event (notice)
610
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
611
+		// loop through terms and add them to new event.
612
+		foreach ($orig_terms as $term) {
613
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
614
+		}
615
+
616
+		// duplicate other core WP_Post items for this event.
617
+		// post thumbnail (feature image).
618
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
619
+		if ($feature_image_id) {
620
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
621
+		}
622
+
623
+		// duplicate page_template setting
624
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
625
+		if ($page_template) {
626
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
627
+		}
628
+
629
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
630
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
631
+		if ($new_event->ID()) {
632
+			$redirect_args = [
633
+				'post'   => $new_event->ID(),
634
+				'action' => 'edit',
635
+			];
636
+			EE_Error::add_success(
637
+				esc_html__(
638
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
639
+					'event_espresso'
640
+				)
641
+			);
642
+		} else {
643
+			$redirect_args = [
644
+				'action' => 'default',
645
+			];
646
+			EE_Error::add_error(
647
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
648
+				__FILE__,
649
+				__FUNCTION__,
650
+				__LINE__
651
+			);
652
+		}
653
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
654
+	}
655
+
656
+
657
+	/**
658
+	 * Generates output for the import page.
659
+	 *
660
+	 * @throws EE_Error
661
+	 */
662
+	protected function _import_page()
663
+	{
664
+		$title = esc_html__('Import', 'event_espresso');
665
+		$intro = esc_html__(
666
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
667
+			'event_espresso'
668
+		);
669
+
670
+		$form_url = EVENTS_ADMIN_URL;
671
+		$action   = 'import_events';
672
+		$type     = 'csv';
673
+
674
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
675
+			$title,
676
+			$intro,
677
+			$form_url,
678
+			$action,
679
+			$type
680
+		);
681
+
682
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
683
+			['action' => 'sample_export_file'],
684
+			$this->_admin_base_url
685
+		);
686
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
687
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
688
+			$this->_template_args,
689
+			true
690
+		);
691
+		$this->display_admin_page_with_sidebar();
692
+	}
693
+
694
+
695
+	/**
696
+	 * _import_events
697
+	 * This handles displaying the screen and running imports for importing events.
698
+	 *
699
+	 * @return void
700
+	 * @throws EE_Error
701
+	 */
702
+	protected function _import_events()
703
+	{
704
+		require_once(EE_CLASSES . 'EE_Import.class.php');
705
+		$success = EE_Import::instance()->import();
706
+		$this->_redirect_after_action(
707
+			$success,
708
+			esc_html__('Import File', 'event_espresso'),
709
+			'ran',
710
+			['action' => 'import_page'],
711
+			true
712
+		);
713
+	}
714
+
715
+
716
+	/**
717
+	 * _events_export
718
+	 * Will export all (or just the given event) to a Excel compatible file.
719
+	 *
720
+	 * @access protected
721
+	 * @return void
722
+	 */
723
+	protected function _events_export()
724
+	{
725
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
726
+		$EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
727
+		$this->request->mergeRequestParams(
728
+			[
729
+				'export' => 'report',
730
+				'action' => 'all_event_data',
731
+				'EVT_ID' => $EVT_ID,
732
+			]
733
+		);
734
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
735
+			require_once(EE_CLASSES . 'EE_Export.class.php');
736
+			$EE_Export = EE_Export::instance($this->request->requestParams());
737
+			$EE_Export->export();
738
+		}
739
+	}
740
+
741
+
742
+	/**
743
+	 * handle category exports()
744
+	 *
745
+	 * @return void
746
+	 */
747
+	protected function _categories_export()
748
+	{
749
+		$EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
750
+		$this->request->mergeRequestParams(
751
+			[
752
+				'export' => 'report',
753
+				'action' => 'categories',
754
+				'EVT_ID' => $EVT_ID,
755
+			]
756
+		);
757
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
758
+			require_once(EE_CLASSES . 'EE_Export.class.php');
759
+			$EE_Export = EE_Export::instance($this->request->requestParams());
760
+			$EE_Export->export();
761
+		}
762
+	}
763
+
764
+
765
+	/**
766
+	 * Creates a sample CSV file for importing
767
+	 */
768
+	protected function _sample_export_file()
769
+	{
770
+		$EE_Export = EE_Export::instance();
771
+		if ($EE_Export instanceof EE_Export) {
772
+			$EE_Export->export();
773
+		}
774
+	}
775
+
776
+
777
+	/*************        Template Settings        *************/
778
+	/**
779
+	 * Generates template settings page output
780
+	 *
781
+	 * @throws DomainException
782
+	 * @throws EE_Error
783
+	 * @throws InvalidArgumentException
784
+	 * @throws InvalidDataTypeException
785
+	 * @throws InvalidInterfaceException
786
+	 */
787
+	protected function _template_settings()
788
+	{
789
+		$this->_template_args['values'] = $this->_yes_no_values;
790
+		/**
791
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
792
+		 * from General_Settings_Admin_Page to here.
793
+		 */
794
+		$this->_template_args = apply_filters(
795
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
796
+			$this->_template_args
797
+		);
798
+		$this->_set_add_edit_form_tags('update_template_settings');
799
+		$this->_set_publish_post_box_vars();
800
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
801
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
802
+			$this->_template_args,
803
+			true
804
+		);
805
+		$this->display_admin_page_with_sidebar();
806
+	}
807
+
808
+
809
+	/**
810
+	 * Handler for updating template settings.
811
+	 *
812
+	 * @throws EE_Error
813
+	 */
814
+	protected function _update_template_settings()
815
+	{
816
+		/**
817
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
818
+		 * from General_Settings_Admin_Page to here.
819
+		 */
820
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
821
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
822
+			EE_Registry::instance()->CFG->template_settings,
823
+			$this->request->requestParams()
824
+		);
825
+		// update custom post type slugs and detect if we need to flush rewrite rules
826
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
827
+
828
+		$event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
829
+
830
+		EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
831
+			? EEH_URL::slugify($event_cpt_slug, 'events')
832
+			: EE_Registry::instance()->CFG->core->event_cpt_slug;
833
+
834
+		$what    = esc_html__('Template Settings', 'event_espresso');
835
+		$success = $this->_update_espresso_configuration(
836
+			$what,
837
+			EE_Registry::instance()->CFG->template_settings,
838
+			__FILE__,
839
+			__FUNCTION__,
840
+			__LINE__
841
+		);
842
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
843
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
844
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
845
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
846
+			);
847
+			$rewrite_rules->flush();
848
+		}
849
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
850
+	}
851
+
852
+
853
+	/**
854
+	 * _premium_event_editor_meta_boxes
855
+	 * add all metaboxes related to the event_editor
856
+	 *
857
+	 * @access protected
858
+	 * @return void
859
+	 * @throws EE_Error
860
+	 * @throws ReflectionException
861
+	 */
862
+	protected function _premium_event_editor_meta_boxes()
863
+	{
864
+		$this->verify_cpt_object();
865
+		// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
866
+		if (
867
+			! $this->admin_config->useAdvancedEditor()
868
+			|| ! $this->feature->allowed('use_reg_options_meta_box')
869
+		) {
870
+			$this->addMetaBox(
871
+				'espresso_event_editor_event_options',
872
+				esc_html__('Event Registration Options', 'event_espresso'),
873
+				[$this, 'registration_options_meta_box'],
874
+				$this->page_slug,
875
+				'side',
876
+				'core'
877
+			);
878
+		}
879
+	}
880
+
881
+
882
+	/**
883
+	 * override caf metabox
884
+	 *
885
+	 * @return void
886
+	 * @throws EE_Error
887
+	 * @throws ReflectionException
888
+	 */
889
+	public function registration_options_meta_box()
890
+	{
891
+		$yes_no_values = [
892
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
893
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
894
+		];
895
+
896
+		$default_reg_status_values = EEM_Registration::reg_status_array(
897
+			[
898
+				EEM_Registration::status_id_cancelled,
899
+				EEM_Registration::status_id_declined,
900
+				EEM_Registration::status_id_incomplete,
901
+				EEM_Registration::status_id_wait_list,
902
+			],
903
+			true
904
+		);
905
+
906
+		$template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
907
+		$template_args['_event']           = $this->_cpt_model_obj;
908
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
909
+
910
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
911
+			'default_reg_status',
912
+			$default_reg_status_values,
913
+			$this->_cpt_model_obj->default_registration_status(),
914
+			'',
915
+			'ee-input-width--reg',
916
+			false
917
+		);
918
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
919
+			'display_desc',
920
+			$yes_no_values,
921
+			$this->_cpt_model_obj->display_description()
922
+		);
923
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
924
+			'display_ticket_selector',
925
+			$yes_no_values,
926
+			$this->_cpt_model_obj->display_ticket_selector(),
927
+			'',
928
+			'ee-input-width--small',
929
+			false
930
+		);
931
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
932
+			'EVT_default_registration_status',
933
+			$default_reg_status_values,
934
+			$this->_cpt_model_obj->default_registration_status(),
935
+			'',
936
+			'ee-input-width--reg',
937
+			false
938
+		);
939
+		$template_args['additional_registration_options'] = apply_filters(
940
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
941
+			'',
942
+			$template_args,
943
+			$yes_no_values,
944
+			$default_reg_status_values
945
+		);
946
+		EEH_Template::display_template(
947
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
948
+			$template_args
949
+		);
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * wp_list_table_mods for caf
956
+	 * ============================
957
+	 */
958
+
959
+
960
+	/**
961
+	 * espresso_event_months_dropdown
962
+	 *
963
+	 * @deprecatd 5.0.0.p
964
+	 * @access public
965
+	 * @return string                dropdown listing month/year selections for events.
966
+	 * @throws EE_Error
967
+	 */
968
+	public function espresso_event_months_dropdown(): string
969
+	{
970
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
971
+		// Note we need to include any other filters that are set!
972
+		return EEH_Form_Fields::generate_event_months_dropdown(
973
+			$this->request->getRequestParam('month_range'),
974
+			$this->request->getRequestParam('status'),
975
+			$this->request->getRequestParam('EVT_CAT', 0, 'int'),
976
+			$this->request->getRequestParam('active_status')
977
+		);
978
+	}
979
+
980
+
981
+	/**
982
+	 * returns a list of "active" statuses on the event
983
+	 *
984
+	 * @deprecatd 5.0.0.p
985
+	 * @param string $current_value whatever the current active status is
986
+	 * @return string
987
+	 */
988
+	public function active_status_dropdown(string $current_value = ''): string
989
+	{
990
+		$select_name = 'active_status';
991
+		$values      = [
992
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
993
+			'active'   => esc_html__('Active', 'event_espresso'),
994
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
995
+			'expired'  => esc_html__('Expired', 'event_espresso'),
996
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
997
+		];
998
+
999
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value);
1000
+	}
1001
+
1002
+
1003
+	/**
1004
+	 * returns a list of "venues"
1005
+	 *
1006
+	 * @deprecatd 5.0.0.p
1007
+	 * @param string $current_value whatever the current active status is
1008
+	 * @return string
1009
+	 * @throws EE_Error
1010
+	 * @throws ReflectionException
1011
+	 */
1012
+	protected function venuesDropdown(string $current_value = ''): string
1013
+	{
1014
+		$values = ['' => esc_html__('All Venues', 'event_espresso')];
1015
+		// populate the list of venues.
1016
+		$venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1017
+
1018
+		foreach ($venues as $venue) {
1019
+			$values[ $venue->ID() ] = $venue->name();
1020
+		}
1021
+
1022
+		return EEH_Form_Fields::select_input('venue', $values, $current_value);
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * output a dropdown of the categories for the category filter on the event admin list table
1028
+	 *
1029
+	 * @deprecatd 5.0.0.p
1030
+	 * @access  public
1031
+	 * @return string html
1032
+	 * @throws EE_Error
1033
+	 * @throws ReflectionException
1034
+	 */
1035
+	public function category_dropdown(): string
1036
+	{
1037
+		return EEH_Form_Fields::generate_event_category_dropdown(
1038
+			$this->request->getRequestParam('EVT_CAT', -1, 'int')
1039
+		);
1040
+	}
1041
+
1042
+
1043
+	/**
1044
+	 * get total number of events today
1045
+	 *
1046
+	 * @access public
1047
+	 * @return int
1048
+	 * @throws EE_Error
1049
+	 * @throws InvalidArgumentException
1050
+	 * @throws InvalidDataTypeException
1051
+	 * @throws InvalidInterfaceException
1052
+	 * @throws ReflectionException
1053
+	 */
1054
+	public function total_events_today(): int
1055
+	{
1056
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1057
+			'DTT_EVT_start',
1058
+			date('Y-m-d') . ' 00:00:00',
1059
+			'Y-m-d H:i:s',
1060
+			'UTC'
1061
+		);
1062
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1063
+			'DTT_EVT_start',
1064
+			date('Y-m-d') . ' 23:59:59',
1065
+			'Y-m-d H:i:s',
1066
+			'UTC'
1067
+		);
1068
+		$where = [
1069
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1070
+		];
1071
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * get total number of events this month
1077
+	 *
1078
+	 * @access public
1079
+	 * @return int
1080
+	 * @throws EE_Error
1081
+	 * @throws InvalidArgumentException
1082
+	 * @throws InvalidDataTypeException
1083
+	 * @throws InvalidInterfaceException
1084
+	 * @throws ReflectionException
1085
+	 */
1086
+	public function total_events_this_month(): int
1087
+	{
1088
+		// Dates
1089
+		$this_year_r     = date('Y');
1090
+		$this_month_r    = date('m');
1091
+		$days_this_month = date('t');
1092
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1093
+			'DTT_EVT_start',
1094
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1095
+			'Y-m-d H:i:s',
1096
+			'UTC'
1097
+		);
1098
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1099
+			'DTT_EVT_start',
1100
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1101
+			'Y-m-d H:i:s',
1102
+			'UTC'
1103
+		);
1104
+		$where           = [
1105
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1106
+		];
1107
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1108
+	}
1109
+
1110
+
1111
+	/** DEFAULT TICKETS STUFF **/
1112
+
1113
+	/**
1114
+	 * Output default tickets list table view.
1115
+	 *
1116
+	 * @throws EE_Error
1117
+	 */
1118
+	public function _tickets_overview_list_table()
1119
+	{
1120
+		if (
1121
+			$this->admin_config->useAdvancedEditor()
1122
+			&& $this->feature->allowed('use_default_ticket_manager')
1123
+		) {
1124
+			// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1125
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1126
+				EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1127
+				[],
1128
+				true
1129
+			);
1130
+			$this->display_admin_page_with_no_sidebar();
1131
+		} else {
1132
+			$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1133
+			$this->display_admin_list_table_page_with_no_sidebar();
1134
+		}
1135
+	}
1136
+
1137
+
1138
+	/**
1139
+	 * @param int  $per_page
1140
+	 * @param bool $count
1141
+	 * @param bool $trashed
1142
+	 * @return EE_Soft_Delete_Base_Class[]|int
1143
+	 * @throws EE_Error
1144
+	 * @throws ReflectionException
1145
+	 */
1146
+	public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false)
1147
+	{
1148
+		$orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1149
+		$order   = $this->request->getRequestParam('order', 'ASC');
1150
+		switch ($orderby) {
1151
+			case 'TKT_name':
1152
+				$orderby = ['TKT_name' => $order];
1153
+				break;
1154
+			case 'TKT_price':
1155
+				$orderby = ['TKT_price' => $order];
1156
+				break;
1157
+			case 'TKT_uses':
1158
+				$orderby = ['TKT_uses' => $order];
1159
+				break;
1160
+			case 'TKT_min':
1161
+				$orderby = ['TKT_min' => $order];
1162
+				break;
1163
+			case 'TKT_max':
1164
+				$orderby = ['TKT_max' => $order];
1165
+				break;
1166
+			case 'TKT_qty':
1167
+				$orderby = ['TKT_qty' => $order];
1168
+				break;
1169
+		}
1170
+
1171
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1172
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1173
+		$offset       = ($current_page - 1) * $per_page;
1174
+
1175
+		$where = [
1176
+			'TKT_is_default' => 1,
1177
+			'TKT_deleted'    => $trashed,
1178
+		];
1179
+
1180
+		$search_term = $this->request->getRequestParam('s');
1181
+		if ($search_term) {
1182
+			$search_term = '%' . $search_term . '%';
1183
+			$where['OR'] = [
1184
+				'TKT_name'        => ['LIKE', $search_term],
1185
+				'TKT_description' => ['LIKE', $search_term],
1186
+			];
1187
+		}
1188
+
1189
+		return $count
1190
+			? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1191
+			: EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1192
+				[
1193
+					$where,
1194
+					'order_by' => $orderby,
1195
+					'limit'    => [$offset, $per_page],
1196
+					'group_by' => 'TKT_ID',
1197
+				]
1198
+			);
1199
+	}
1200
+
1201
+
1202
+	/**
1203
+	 * @param bool $trash
1204
+	 * @throws EE_Error
1205
+	 * @throws InvalidArgumentException
1206
+	 * @throws InvalidDataTypeException
1207
+	 * @throws InvalidInterfaceException
1208
+	 * @throws ReflectionException
1209
+	 */
1210
+	protected function _trash_or_restore_ticket(bool $trash = false)
1211
+	{
1212
+		$success = 1;
1213
+		$TKT     = EEM_Ticket::instance();
1214
+		// checkboxes?
1215
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1216
+		if (! empty($checkboxes)) {
1217
+			// if array has more than one element then success message should be plural
1218
+			$success = count($checkboxes) > 1 ? 2 : 1;
1219
+			// cycle thru the boxes
1220
+			foreach ($checkboxes as $TKT_ID => $value) {
1221
+				if ($trash) {
1222
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1223
+						$success = 0;
1224
+					}
1225
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1226
+					$success = 0;
1227
+				}
1228
+			}
1229
+		} else {
1230
+			// grab single id and trash
1231
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1232
+			if ($trash) {
1233
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1234
+					$success = 0;
1235
+				}
1236
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1237
+				$success = 0;
1238
+			}
1239
+		}
1240
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1241
+		$query_args  = [
1242
+			'action' => 'ticket_list_table',
1243
+			'status' => $trash ? '' : 'trashed',
1244
+		];
1245
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1246
+	}
1247
+
1248
+
1249
+	/**
1250
+	 * Handles trashing default ticket.
1251
+	 *
1252
+	 * @throws EE_Error
1253
+	 * @throws ReflectionException
1254
+	 */
1255
+	protected function _delete_ticket()
1256
+	{
1257
+		$success = 1;
1258
+		// checkboxes?
1259
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1260
+		if (! empty($checkboxes)) {
1261
+			// if array has more than one element then success message should be plural
1262
+			$success = count($checkboxes) > 1 ? 2 : 1;
1263
+			// cycle thru the boxes
1264
+			foreach ($checkboxes as $TKT_ID => $value) {
1265
+				// delete
1266
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1267
+					$success = 0;
1268
+				}
1269
+			}
1270
+		} else {
1271
+			// grab single id and trash
1272
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1273
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1274
+				$success = 0;
1275
+			}
1276
+		}
1277
+		$action_desc = 'deleted';
1278
+		$query_args  = [
1279
+			'action' => 'ticket_list_table',
1280
+			'status' => 'trashed',
1281
+		];
1282
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1283
+		if (
1284
+		EEM_Ticket::instance()->count_deleted_and_undeleted(
1285
+			[['TKT_is_default' => 1]],
1286
+			'TKT_ID',
1287
+			true
1288
+		)
1289
+		) {
1290
+			$query_args = [];
1291
+		}
1292
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1293
+	}
1294
+
1295
+
1296
+	/**
1297
+	 * @param int $TKT_ID
1298
+	 * @return bool|int
1299
+	 * @throws EE_Error
1300
+	 * @throws ReflectionException
1301
+	 */
1302
+	protected function _delete_the_ticket(int $TKT_ID)
1303
+	{
1304
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1305
+		if (! $ticket instanceof EE_Ticket) {
1306
+			return false;
1307
+		}
1308
+		$ticket->_remove_relations('Datetime');
1309
+		// delete all related prices first
1310
+		$ticket->delete_related_permanently('Price');
1311
+		return $ticket->delete_permanently();
1312
+	}
1313 1313
 }
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -28,358 +28,358 @@
 block discarded – undo
28 28
  */
29 29
 class EE_Brewing_Regular extends EE_BASE implements InterminableInterface
30 30
 {
31
-    /**
32
-     * @var EE_Dependency_Map
33
-     */
34
-    protected $dependency_map;
35
-
36
-    /**
37
-     * @var LoaderInterface
38
-     */
39
-    protected $loader;
40
-
41
-    /**
42
-     * @var TableAnalysis
43
-     */
44
-    protected $_table_analysis;
45
-
46
-    /**
47
-     * @var RouteHandler
48
-     */
49
-    protected $route_handler;
50
-
51
-
52
-    /**
53
-     * EE_Brewing_Regular constructor.
54
-     *
55
-     * @param EE_Dependency_Map $dependency_map
56
-     * @param LoaderInterface   $loader
57
-     * @param RouteHandler      $route_handler
58
-     * @param TableAnalysis     $table_analysis
59
-     */
60
-    public function __construct(
61
-        EE_Dependency_Map $dependency_map,
62
-        LoaderInterface $loader,
63
-        RouteHandler $route_handler,
64
-        TableAnalysis $table_analysis
65
-    ) {
66
-        $this->dependency_map  = $dependency_map;
67
-        $this->loader          = $loader;
68
-        $this->route_handler   = $route_handler;
69
-        $this->_table_analysis = $table_analysis;
70
-        if (defined('EE_CAFF_PATH')) {
71
-            // defined some new constants related to caffeinated folder
72
-            define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/');
73
-            define('EE_CAF_CORE', EE_CAFF_PATH . 'core/');
74
-            define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries/');
75
-            define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods/');
76
-        }
77
-    }
78
-
79
-
80
-    /**
81
-     * @throws EE_Error
82
-     */
83
-    public function caffeinated()
84
-    {
85
-        $this->setInitializationHooks();
86
-        $this->setApiRegistrationHooks();
87
-        $this->setSwitchHooks();
88
-        $this->setDefaultFilterHooks();
89
-        // caffeinated constructed
90
-        do_action('AHEE__EE_Brewing_Regular__construct__complete');
91
-    }
92
-
93
-
94
-    /**
95
-     * @throws Exception
96
-     */
97
-    public function initializePUE()
98
-    {
99
-        $this->dependency_map->registerDependencies(PueRequests::class, Route::getDefaultDependencies());
100
-        $this->route_handler->addRoute(PueRequests::class);
101
-    }
102
-
103
-
104
-    /**
105
-     * Various hooks used for extending features via registration of modules or extensions.
106
-     *
107
-     * @throws EE_Error
108
-     */
109
-    private function setApiRegistrationHooks()
110
-    {
111
-        add_filter(
112
-            'FHEE__EE_Config__register_modules__modules_to_register',
113
-            [$this, 'caffeinated_modules_to_register']
114
-        );
115
-        add_filter('FHEE__EE_Registry__load_helper__helper_paths', [$this, 'caf_helper_paths'], 10);
116
-        add_filter(
117
-            'AHEE__EE_System__load_core_configuration__complete',
118
-            function () {
119
-                EE_Register_Payment_Method::register(
120
-                    'caffeinated_payment_methods',
121
-                    [
122
-                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
123
-                    ]
124
-                );
125
-            }
126
-        );
127
-    }
128
-
129
-
130
-    /**
131
-     * Various hooks used for modifying initialization or activation processes.
132
-     */
133
-    private function setInitializationHooks()
134
-    {
135
-        // activation
136
-        add_action('AHEE__EEH_Activation__initialize_db_content', [$this, 'initialize_caf_db_content']);
137
-        // load caff init
138
-        add_action('AHEE__EE_System__set_hooks_for_core', [$this, 'caffeinated_init']);
139
-        // load caff scripts
140
-        add_action('wp_enqueue_scripts', [$this, 'enqueue_caffeinated_scripts'], 10);
141
-    }
142
-
143
-
144
-    /**
145
-     * Various hooks used for switch (on/off) type filters.
146
-     */
147
-    private function setSwitchHooks()
148
-    {
149
-        // remove the "powered by" credit link from receipts and invoices
150
-        add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
151
-        // seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
152
-        add_filter('FHEE__ee_show_affiliate_links', '__return_false');
153
-    }
154
-
155
-
156
-    /**
157
-     * Various filters for affecting default configuration values in the caffeinated
158
-     * context.
159
-     */
160
-    private function setDefaultFilterHooks()
161
-    {
162
-        add_filter(
163
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
164
-            '__return_true'
165
-        );
166
-    }
167
-
168
-
169
-    /**
170
-     * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
171
-     *
172
-     * @param array $paths original helper paths array
173
-     * @return array             new array of paths
174
-     */
175
-    public function caf_helper_paths(array $paths): array
176
-    {
177
-        $paths[] = EE_CAF_CORE . 'helpers/';
178
-        return $paths;
179
-    }
180
-
181
-
182
-    /**
183
-     * Upon brand-new activation, if this is a new activation of CAF, we want to add
184
-     * some global prices that will show off EE4's capabilities. However, if they're upgrading
185
-     * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
186
-     * This action should only be called when EE 4.x.0.P is initially activated.
187
-     * Right now the only CAF content are these global prices. If there's more in the future, then
188
-     * we should probably create a caf file to contain it all instead just a function like this.
189
-     * Right now, we ASSUME the only price types in the system are default ones
190
-     *
191
-     * @global wpdb $wpdb
192
-     */
193
-    public function initialize_caf_db_content()
194
-    {
195
-        global $wpdb;
196
-        // use same method of getting creator id as the version introducing the change
197
-        $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
198
-        $price_type_table   = $wpdb->prefix . "esp_price_type";
199
-        $price_table        = $wpdb->prefix . "esp_price";
200
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
201
-            $SQL                  =
202
-                'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
203
-            $tax_price_type_count = $wpdb->get_var($SQL);
204
-            if ($tax_price_type_count <= 1) {
205
-                $wpdb->insert(
206
-                    $price_type_table,
207
-                    [
208
-                        'PRT_name'       => esc_html__("Regional Tax", "event_espresso"),
209
-                        'PBT_ID'         => 4,
210
-                        'PRT_is_percent' => true,
211
-                        'PRT_order'      => 60,
212
-                        'PRT_deleted'    => false,
213
-                        'PRT_wp_user'    => $default_creator_id,
214
-                    ],
215
-                    [
216
-                        '%s',// PRT_name
217
-                        '%d',// PBT_id
218
-                        '%d',// PRT_is_percent
219
-                        '%d',// PRT_order
220
-                        '%d',// PRT_deleted
221
-                        '%d', // PRT_wp_user
222
-                    ]
223
-                );
224
-                // federal tax
225
-                $result = $wpdb->insert(
226
-                    $price_type_table,
227
-                    [
228
-                        'PRT_name'       => esc_html__("Federal Tax", "event_espresso"),
229
-                        'PBT_ID'         => 4,
230
-                        'PRT_is_percent' => true,
231
-                        'PRT_order'      => 60,
232
-                        'PRT_deleted'    => false,
233
-                        'PRT_wp_user'    => $default_creator_id,
234
-                    ],
235
-                    [
236
-                        '%s',// PRT_name
237
-                        '%d',// PBT_id
238
-                        '%d',// PRT_is_percent
239
-                        '%d',// PRT_order
240
-                        '%d',// PRT_deleted
241
-                        '%d' // PRT_wp_user
242
-                    ]
243
-                );
244
-                if ($result) {
245
-                    $wpdb->insert(
246
-                        $price_table,
247
-                        [
248
-                            'PRT_ID'         => $wpdb->insert_id,
249
-                            'PRC_amount'     => 15.00,
250
-                            'PRC_name'       => esc_html__("Sales Tax", "event_espresso"),
251
-                            'PRC_desc'       => '',
252
-                            'PRC_is_default' => true,
253
-                            'PRC_overrides'  => null,
254
-                            'PRC_deleted'    => false,
255
-                            'PRC_order'      => 60,
256
-                            'PRC_parent'     => null,
257
-                            'PRC_wp_user'    => $default_creator_id,
258
-                        ],
259
-                        [
260
-                            '%d',// PRT_id
261
-                            '%f',// PRC_amount
262
-                            '%s',// PRC_name
263
-                            '%s',// PRC_desc
264
-                            '%d',// PRC_is_default
265
-                            '%d',// PRC_overrides
266
-                            '%d',// PRC_deleted
267
-                            '%d',// PRC_order
268
-                            '%d',// PRC_parent
269
-                            '%d' // PRC_wp_user
270
-                        ]
271
-                    );
272
-                }
273
-            }
274
-        }
275
-    }
276
-
277
-
278
-    /**
279
-     *    caffeinated_modules_to_register
280
-     *
281
-     * @access public
282
-     * @param array $modules_to_register
283
-     * @return array
284
-     */
285
-    public function caffeinated_modules_to_register(array $modules_to_register = []): array
286
-    {
287
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
288
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR);
289
-            if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
290
-                $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
291
-            }
292
-        }
293
-        return $modules_to_register;
294
-    }
295
-
296
-
297
-    /**
298
-     * @throws EE_Error
299
-     * @throws InvalidArgumentException
300
-     * @throws ReflectionException
301
-     * @throws InvalidDataTypeException
302
-     * @throws InvalidInterfaceException
303
-     */
304
-    public function caffeinated_init()
305
-    {
306
-        // Custom Post Type hooks
307
-        add_filter(
308
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
309
-            [$this, 'filter_taxonomies']
310
-        );
311
-        add_filter(
312
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
313
-            [$this, 'filter_cpts']
314
-        );
315
-        add_filter(
316
-            'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
317
-            [$this, 'nav_metabox_items']
318
-        );
319
-        EE_Registry::instance()->load_file(
320
-            EE_CAFF_PATH,
321
-            'EE_Caf_Messages',
322
-            'class',
323
-            [],
324
-            false
325
-        );
326
-        // caffeinated_init__complete hook
327
-        do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
328
-    }
329
-
330
-
331
-    public function enqueue_caffeinated_scripts()
332
-    {
333
-        // sound of crickets...
334
-    }
335
-
336
-
337
-    /**
338
-     * callbacks below here
339
-     *
340
-     * @param array $taxonomy_array
341
-     * @return array
342
-     */
343
-    public function filter_taxonomies(array $taxonomy_array): array
344
-    {
345
-        $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
346
-        return $taxonomy_array;
347
-    }
348
-
349
-
350
-    /**
351
-     * @param array $cpt_array
352
-     * @return array
353
-     */
354
-    public function filter_cpts(array $cpt_array): array
355
-    {
356
-        $cpt_array[EspressoPostType::VENUES]['args']['show_in_nav_menus'] = true;
357
-        return $cpt_array;
358
-    }
359
-
360
-
361
-    /**
362
-     * @param array $menu_items
363
-     * @return array
364
-     */
365
-    public function nav_metabox_items(array $menu_items): array
366
-    {
367
-        $menu_items[] = [
368
-            'title'       => esc_html__('Venue List', 'event_espresso'),
369
-            'url'         => get_post_type_archive_link(EspressoPostType::VENUES),
370
-            'description' => esc_html__('Archive page for all venues.', 'event_espresso'),
371
-        ];
372
-        return $menu_items;
373
-    }
374
-
375
-
376
-    /**
377
-     * Gets the injected table analyzer, or throws an exception
378
-     *
379
-     * @return TableAnalysis
380
-     */
381
-    protected function _get_table_analysis(): TableAnalysis
382
-    {
383
-        return $this->_table_analysis;
384
-    }
31
+	/**
32
+	 * @var EE_Dependency_Map
33
+	 */
34
+	protected $dependency_map;
35
+
36
+	/**
37
+	 * @var LoaderInterface
38
+	 */
39
+	protected $loader;
40
+
41
+	/**
42
+	 * @var TableAnalysis
43
+	 */
44
+	protected $_table_analysis;
45
+
46
+	/**
47
+	 * @var RouteHandler
48
+	 */
49
+	protected $route_handler;
50
+
51
+
52
+	/**
53
+	 * EE_Brewing_Regular constructor.
54
+	 *
55
+	 * @param EE_Dependency_Map $dependency_map
56
+	 * @param LoaderInterface   $loader
57
+	 * @param RouteHandler      $route_handler
58
+	 * @param TableAnalysis     $table_analysis
59
+	 */
60
+	public function __construct(
61
+		EE_Dependency_Map $dependency_map,
62
+		LoaderInterface $loader,
63
+		RouteHandler $route_handler,
64
+		TableAnalysis $table_analysis
65
+	) {
66
+		$this->dependency_map  = $dependency_map;
67
+		$this->loader          = $loader;
68
+		$this->route_handler   = $route_handler;
69
+		$this->_table_analysis = $table_analysis;
70
+		if (defined('EE_CAFF_PATH')) {
71
+			// defined some new constants related to caffeinated folder
72
+			define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/');
73
+			define('EE_CAF_CORE', EE_CAFF_PATH . 'core/');
74
+			define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries/');
75
+			define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods/');
76
+		}
77
+	}
78
+
79
+
80
+	/**
81
+	 * @throws EE_Error
82
+	 */
83
+	public function caffeinated()
84
+	{
85
+		$this->setInitializationHooks();
86
+		$this->setApiRegistrationHooks();
87
+		$this->setSwitchHooks();
88
+		$this->setDefaultFilterHooks();
89
+		// caffeinated constructed
90
+		do_action('AHEE__EE_Brewing_Regular__construct__complete');
91
+	}
92
+
93
+
94
+	/**
95
+	 * @throws Exception
96
+	 */
97
+	public function initializePUE()
98
+	{
99
+		$this->dependency_map->registerDependencies(PueRequests::class, Route::getDefaultDependencies());
100
+		$this->route_handler->addRoute(PueRequests::class);
101
+	}
102
+
103
+
104
+	/**
105
+	 * Various hooks used for extending features via registration of modules or extensions.
106
+	 *
107
+	 * @throws EE_Error
108
+	 */
109
+	private function setApiRegistrationHooks()
110
+	{
111
+		add_filter(
112
+			'FHEE__EE_Config__register_modules__modules_to_register',
113
+			[$this, 'caffeinated_modules_to_register']
114
+		);
115
+		add_filter('FHEE__EE_Registry__load_helper__helper_paths', [$this, 'caf_helper_paths'], 10);
116
+		add_filter(
117
+			'AHEE__EE_System__load_core_configuration__complete',
118
+			function () {
119
+				EE_Register_Payment_Method::register(
120
+					'caffeinated_payment_methods',
121
+					[
122
+						'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
123
+					]
124
+				);
125
+			}
126
+		);
127
+	}
128
+
129
+
130
+	/**
131
+	 * Various hooks used for modifying initialization or activation processes.
132
+	 */
133
+	private function setInitializationHooks()
134
+	{
135
+		// activation
136
+		add_action('AHEE__EEH_Activation__initialize_db_content', [$this, 'initialize_caf_db_content']);
137
+		// load caff init
138
+		add_action('AHEE__EE_System__set_hooks_for_core', [$this, 'caffeinated_init']);
139
+		// load caff scripts
140
+		add_action('wp_enqueue_scripts', [$this, 'enqueue_caffeinated_scripts'], 10);
141
+	}
142
+
143
+
144
+	/**
145
+	 * Various hooks used for switch (on/off) type filters.
146
+	 */
147
+	private function setSwitchHooks()
148
+	{
149
+		// remove the "powered by" credit link from receipts and invoices
150
+		add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
151
+		// seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
152
+		add_filter('FHEE__ee_show_affiliate_links', '__return_false');
153
+	}
154
+
155
+
156
+	/**
157
+	 * Various filters for affecting default configuration values in the caffeinated
158
+	 * context.
159
+	 */
160
+	private function setDefaultFilterHooks()
161
+	{
162
+		add_filter(
163
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
164
+			'__return_true'
165
+		);
166
+	}
167
+
168
+
169
+	/**
170
+	 * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
171
+	 *
172
+	 * @param array $paths original helper paths array
173
+	 * @return array             new array of paths
174
+	 */
175
+	public function caf_helper_paths(array $paths): array
176
+	{
177
+		$paths[] = EE_CAF_CORE . 'helpers/';
178
+		return $paths;
179
+	}
180
+
181
+
182
+	/**
183
+	 * Upon brand-new activation, if this is a new activation of CAF, we want to add
184
+	 * some global prices that will show off EE4's capabilities. However, if they're upgrading
185
+	 * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
186
+	 * This action should only be called when EE 4.x.0.P is initially activated.
187
+	 * Right now the only CAF content are these global prices. If there's more in the future, then
188
+	 * we should probably create a caf file to contain it all instead just a function like this.
189
+	 * Right now, we ASSUME the only price types in the system are default ones
190
+	 *
191
+	 * @global wpdb $wpdb
192
+	 */
193
+	public function initialize_caf_db_content()
194
+	{
195
+		global $wpdb;
196
+		// use same method of getting creator id as the version introducing the change
197
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
198
+		$price_type_table   = $wpdb->prefix . "esp_price_type";
199
+		$price_table        = $wpdb->prefix . "esp_price";
200
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
201
+			$SQL                  =
202
+				'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
203
+			$tax_price_type_count = $wpdb->get_var($SQL);
204
+			if ($tax_price_type_count <= 1) {
205
+				$wpdb->insert(
206
+					$price_type_table,
207
+					[
208
+						'PRT_name'       => esc_html__("Regional Tax", "event_espresso"),
209
+						'PBT_ID'         => 4,
210
+						'PRT_is_percent' => true,
211
+						'PRT_order'      => 60,
212
+						'PRT_deleted'    => false,
213
+						'PRT_wp_user'    => $default_creator_id,
214
+					],
215
+					[
216
+						'%s',// PRT_name
217
+						'%d',// PBT_id
218
+						'%d',// PRT_is_percent
219
+						'%d',// PRT_order
220
+						'%d',// PRT_deleted
221
+						'%d', // PRT_wp_user
222
+					]
223
+				);
224
+				// federal tax
225
+				$result = $wpdb->insert(
226
+					$price_type_table,
227
+					[
228
+						'PRT_name'       => esc_html__("Federal Tax", "event_espresso"),
229
+						'PBT_ID'         => 4,
230
+						'PRT_is_percent' => true,
231
+						'PRT_order'      => 60,
232
+						'PRT_deleted'    => false,
233
+						'PRT_wp_user'    => $default_creator_id,
234
+					],
235
+					[
236
+						'%s',// PRT_name
237
+						'%d',// PBT_id
238
+						'%d',// PRT_is_percent
239
+						'%d',// PRT_order
240
+						'%d',// PRT_deleted
241
+						'%d' // PRT_wp_user
242
+					]
243
+				);
244
+				if ($result) {
245
+					$wpdb->insert(
246
+						$price_table,
247
+						[
248
+							'PRT_ID'         => $wpdb->insert_id,
249
+							'PRC_amount'     => 15.00,
250
+							'PRC_name'       => esc_html__("Sales Tax", "event_espresso"),
251
+							'PRC_desc'       => '',
252
+							'PRC_is_default' => true,
253
+							'PRC_overrides'  => null,
254
+							'PRC_deleted'    => false,
255
+							'PRC_order'      => 60,
256
+							'PRC_parent'     => null,
257
+							'PRC_wp_user'    => $default_creator_id,
258
+						],
259
+						[
260
+							'%d',// PRT_id
261
+							'%f',// PRC_amount
262
+							'%s',// PRC_name
263
+							'%s',// PRC_desc
264
+							'%d',// PRC_is_default
265
+							'%d',// PRC_overrides
266
+							'%d',// PRC_deleted
267
+							'%d',// PRC_order
268
+							'%d',// PRC_parent
269
+							'%d' // PRC_wp_user
270
+						]
271
+					);
272
+				}
273
+			}
274
+		}
275
+	}
276
+
277
+
278
+	/**
279
+	 *    caffeinated_modules_to_register
280
+	 *
281
+	 * @access public
282
+	 * @param array $modules_to_register
283
+	 * @return array
284
+	 */
285
+	public function caffeinated_modules_to_register(array $modules_to_register = []): array
286
+	{
287
+		if (is_readable(EE_CAFF_PATH . 'modules')) {
288
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR);
289
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
290
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
291
+			}
292
+		}
293
+		return $modules_to_register;
294
+	}
295
+
296
+
297
+	/**
298
+	 * @throws EE_Error
299
+	 * @throws InvalidArgumentException
300
+	 * @throws ReflectionException
301
+	 * @throws InvalidDataTypeException
302
+	 * @throws InvalidInterfaceException
303
+	 */
304
+	public function caffeinated_init()
305
+	{
306
+		// Custom Post Type hooks
307
+		add_filter(
308
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
309
+			[$this, 'filter_taxonomies']
310
+		);
311
+		add_filter(
312
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
313
+			[$this, 'filter_cpts']
314
+		);
315
+		add_filter(
316
+			'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
317
+			[$this, 'nav_metabox_items']
318
+		);
319
+		EE_Registry::instance()->load_file(
320
+			EE_CAFF_PATH,
321
+			'EE_Caf_Messages',
322
+			'class',
323
+			[],
324
+			false
325
+		);
326
+		// caffeinated_init__complete hook
327
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
328
+	}
329
+
330
+
331
+	public function enqueue_caffeinated_scripts()
332
+	{
333
+		// sound of crickets...
334
+	}
335
+
336
+
337
+	/**
338
+	 * callbacks below here
339
+	 *
340
+	 * @param array $taxonomy_array
341
+	 * @return array
342
+	 */
343
+	public function filter_taxonomies(array $taxonomy_array): array
344
+	{
345
+		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
346
+		return $taxonomy_array;
347
+	}
348
+
349
+
350
+	/**
351
+	 * @param array $cpt_array
352
+	 * @return array
353
+	 */
354
+	public function filter_cpts(array $cpt_array): array
355
+	{
356
+		$cpt_array[EspressoPostType::VENUES]['args']['show_in_nav_menus'] = true;
357
+		return $cpt_array;
358
+	}
359
+
360
+
361
+	/**
362
+	 * @param array $menu_items
363
+	 * @return array
364
+	 */
365
+	public function nav_metabox_items(array $menu_items): array
366
+	{
367
+		$menu_items[] = [
368
+			'title'       => esc_html__('Venue List', 'event_espresso'),
369
+			'url'         => get_post_type_archive_link(EspressoPostType::VENUES),
370
+			'description' => esc_html__('Archive page for all venues.', 'event_espresso'),
371
+		];
372
+		return $menu_items;
373
+	}
374
+
375
+
376
+	/**
377
+	 * Gets the injected table analyzer, or throws an exception
378
+	 *
379
+	 * @return TableAnalysis
380
+	 */
381
+	protected function _get_table_analysis(): TableAnalysis
382
+	{
383
+		return $this->_table_analysis;
384
+	}
385 385
 }
Please login to merge, or discard this patch.
PaymentMethods/PayPalCommerce/PayPalCheckout/forms/BillingForm.php 1 patch
Indentation   +552 added lines, -552 removed lines patch added patch discarded remove patch
@@ -38,556 +38,556 @@
 block discarded – undo
38 38
  */
39 39
 class BillingForm extends EE_Billing_Attendee_Info_Form
40 40
 {
41
-    /**
42
-     * Filepath to template files
43
-     *
44
-     * @var @template_path
45
-     */
46
-    protected $template_path;
47
-
48
-    /**
49
-     * @var EE_Transaction
50
-     */
51
-    protected $transaction;
52
-
53
-    /**
54
-     * @var EE_PMT_PayPalCheckout
55
-     */
56
-    protected $paypal_pmt;
57
-
58
-    /**
59
-     * @var string
60
-     */
61
-    protected $checkout_type;
62
-
63
-
64
-    /**
65
-     * Class constructor.
66
-     *
67
-     * @param EE_Payment_Method $payment_method
68
-     * @param array             $options
69
-     * @throws EE_Error
70
-     * @throws ReflectionException
71
-     */
72
-    public function __construct(EE_Payment_Method $payment_method, array $options = [])
73
-    {
74
-        $this->paypal_pmt    = $payment_method;
75
-        // Can't be too careful.
76
-        $this->transaction   = $options['transaction'] ?? null;
77
-        $this->template_path = $options['template_path'] ?? '';
78
-        $this->checkout_type = $payment_method->get_extra_meta(Domain::META_KEY_CHECKOUT_TYPE, true, '');
79
-        $pm_slug             = $payment_method->slug();
80
-        $parameters          = array_replace_recursive(
81
-            $options,
82
-            [
83
-                'name'        => 'PayPalCommerceBillingForm',
84
-                'html_id'     => 'pp-' . $pm_slug . '-billing-form',
85
-                'html_class'  => 'pp_commerce_billing_form',
86
-                'subsections' => [
87
-                    'eea_paypal_commerce_token' => new EE_Hidden_Input(
88
-                        [
89
-                            'html_id'   => 'eea-paypal-commerce-token',
90
-                            'html_name' => 'EEA_paymentToken',
91
-                            'default'   => '',
92
-                        ]
93
-                    ),
94
-                    'pp_order_nonce'            => new EE_Hidden_Input(
95
-                        [
96
-                            'html_id'   => 'eea-' . $pm_slug . '-order-nonce',
97
-                            'html_name' => 'pp_order_nonce',
98
-                            'default'   => '',
99
-                        ]
100
-                    ),
101
-                    'pp_order_id'               => new EE_Hidden_Input(
102
-                        [
103
-                            'html_id'   => 'eea-' . $pm_slug . '-order-id',
104
-                            'html_name' => 'pp_order_id',
105
-                            'default'   => '',
106
-                        ]
107
-                    ),
108
-                    'pp_order_status'           => new EE_Hidden_Input(
109
-                        [
110
-                            'html_id'   => 'eea-' . $pm_slug . '-order-status',
111
-                            'html_name' => 'pp_order_status',
112
-                            'default'   => '',
113
-                        ]
114
-                    ),
115
-                    'pp_order_amount'           => new EE_Hidden_Input(
116
-                        [
117
-                            'html_id'   => 'eea-' . $pm_slug . '-order-amount',
118
-                            'html_name' => 'pp_order_amount',
119
-                            'default'   => '',
120
-                        ]
121
-                    ),
122
-                ],
123
-            ]
124
-        );
125
-        // Add data tags to the PP script.
126
-        add_filter('script_loader_tag', [$this, 'addDataTagsToScript'], 10, 2);
127
-        parent::__construct($payment_method, $parameters);
128
-        // Add and exclude other sections.
129
-        $this->addPaymentSections();
130
-        // Additional actions and/or filters.
131
-        $this->loadActionsAndFilters();
132
-    }
133
-
134
-
135
-    /**
136
-     * Add PayPal payment sections.
137
-     *
138
-     * @return void
139
-     * @throws EE_Error
140
-     * @throws ReflectionException
141
-     */
142
-    public function addPaymentSections(): void
143
-    {
144
-        // Exclude the default billing form fields.
145
-        $this->exclude([
146
-            'first_name',
147
-            'last_name',
148
-            'email',
149
-        ]);
150
-        // Add PayPal Hosted Fields.
151
-        if ($this->checkout_type !== 'express_checkout') {
152
-            $this->addAdvancedCardFields();
153
-        }
154
-        // Add payment types separator, if both are enabled.
155
-        if ($this->checkout_type === 'all') {
156
-            $this->addTypesSeparator();
157
-        }
158
-        // Add PayPal Buttons section.
159
-        if ($this->checkout_type !== 'ppcp') {
160
-            $this->add_subsections(
161
-                [
162
-                    'paypal_commerce_pm_form' => $this->addPayPalCheckout(),
163
-                ]
164
-            );
165
-        }
166
-        // Exclude the rest billing form fields if the payment type is express checkout.
167
-        if ($this->checkout_type === 'express_checkout') {
168
-            $this->exclude([
169
-                'address',
170
-                'address2',
171
-                'state',
172
-                'phone',
173
-                'city',
174
-                'country',
175
-                'zip',
176
-            ]);
177
-            // Remove the Info subsection.
178
-            add_filter('FHEE__EE_Form_Section_Proper___construct__options_array', [$this, 'excludeInfoSubsection']);
179
-        }
180
-        $this->add_subsections(
181
-            [
182
-                'debug_content' => $this->addDebugContent($this->paypal_pmt),
183
-            ]
184
-        );
185
-    }
186
-
187
-
188
-    /**
189
-     * Additional actions and/or filters.
190
-     *
191
-     * @return void
192
-     */
193
-    public function loadActionsAndFilters(): void
194
-    {
195
-        add_filter(
196
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
197
-            [__CLASS__, 'excludeBillingFormFields'],
198
-            10,
199
-            2
200
-        );
201
-    }
202
-
203
-
204
-    /**
205
-     * Filter out billing form fields if pay button was used.
206
-     *
207
-     * @param EE_Billing_Info_Form $billing_form
208
-     * @param EE_Payment_Method    $payment_method
209
-     * @return EE_Billing_Info_Form
210
-     */
211
-    public static function excludeBillingFormFields(
212
-        EE_Billing_Info_Form $billing_form,
213
-        EE_Payment_Method    $payment_method
214
-    ): EE_Billing_Info_Form {
215
-        $request        = LoaderFactory::getShared(Request::class);
216
-        $request_params = $request->requestParams();
217
-        if (
218
-            // Only the PPC billing form.
219
-            $billing_form instanceof BillingForm
220
-            && ! empty($request_params['process_form_submission'])
221
-            && $request_params['process_form_submission'] === '1'
222
-            && ! empty($request_params['eep_ppc_skip_form_validation'])
223
-        ) {
224
-            // Hide card info fields.
225
-            $billing_form->exclude([
226
-                'pp_name_on_card',
227
-                'address',
228
-                'address2',
229
-                'state',
230
-                'phone',
231
-                'city',
232
-                'country',
233
-                'zip',
234
-            ]);
235
-        }
236
-        return $billing_form;
237
-    }
238
-
239
-
240
-    /**
241
-     * Add advanced card & debit card fields.
242
-     *
243
-     * @return void
244
-     * @throws EE_Error|ReflectionException
245
-     */
246
-    public function addAdvancedCardFields(): void
247
-    {
248
-        $pm_slug = $this->paypal_pmt->slug();
249
-        $this->add_subsections(
250
-            [
251
-                'pp_card_number'     => new EE_Form_Section_HTML(
252
-                    EEH_HTML::label(
253
-                        esc_html__('Card Number', 'event_espresso'),
254
-                        "$pm_slug-card-number-lbl",
255
-                        "$pm_slug-card-fields",
256
-                        "",
257
-                        'for="' . $pm_slug . '-card-number"'
258
-                    ) .
259
-                    EEH_HTML::p(
260
-                        "",
261
-                        "$pm_slug-card-number",
262
-                        "card_field $pm_slug-card-fields"
263
-                    )
264
-                ),
265
-                'pp_expiration_date' => new EE_Form_Section_HTML(
266
-                    EEH_HTML::label(
267
-                        esc_html__('Expiration Date', 'event_espresso'),
268
-                        "$pm_slug-expiration-date-lbl",
269
-                        "$pm_slug-card-fields",
270
-                        "",
271
-                        'for="' . $pm_slug . '-expiration-date"'
272
-                    ) .
273
-                    EEH_HTML::p(
274
-                        "",
275
-                        "$pm_slug-expiration-date",
276
-                        "card_field $pm_slug-card-fields"
277
-                    )
278
-                ),
279
-                'pp_card_cvv'        => new EE_Form_Section_HTML(
280
-                    EEH_HTML::label(
281
-                        esc_html__('CVV', 'event_espresso'),
282
-                        "$pm_slug-cvv-lbl",
283
-                        "$pm_slug-card-fields",
284
-                        "",
285
-                        'for="' . $pm_slug . '-cvv"'
286
-                    ) .
287
-                    EEH_HTML::p(
288
-                        "",
289
-                        "$pm_slug-cvv",
290
-                        "card_field $pm_slug-card-fields"
291
-                    )
292
-                ),
293
-                'pp_name_on_card'    => new EE_Text_Input(
294
-                    [
295
-                        'html_label_text' => esc_html__('Name On Card', 'event_espresso'),
296
-                        'html_id'         => $pm_slug . '-card-holder-name',
297
-                        'html_name'       => 'card-holder-name',
298
-                        'html_class'      => '',
299
-                        'required'        => true,
300
-                    ]
301
-                ),
302
-            ]
303
-        );
304
-        // Add the submit button at the end.
305
-        $this->add_subsections(
306
-            [
307
-                'pp_cc_submit' => new EE_Submit_Input(
308
-                    [
309
-                        'html_label_text' => esc_html__('Submit', 'event_espresso'),
310
-                        'html_id'         => $pm_slug,
311
-                        'html_class'      => 'eep-ppc-btn',
312
-                    ]
313
-                ),
314
-            ],
315
-            'phone',
316
-            false
317
-        );
318
-    }
319
-
320
-
321
-    /**
322
-     * Add advanced card & debit card fields.
323
-     *
324
-     * @return void
325
-     * @throws EE_Error|ReflectionException
326
-     */
327
-    public function addTypesSeparator(): void
328
-    {
329
-        $this->add_subsections(
330
-            [
331
-                'pp_payment_types_separator' => new EE_Form_Section_HTML(
332
-                    EEH_HTML::div(
333
-                        EEH_HTML::div(
334
-                            ' ',
335
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
336
-                            'eep-ppc-separator-line eep-left-floating'
337
-                        ) .
338
-                        EEH_HTML::div(
339
-                            esc_html__(' or ', 'event_espresso'),
340
-                            'eep-' . $this->paypal_pmt->slug() . '-separator-text',
341
-                            'eep-ppc-separator-text1 eep-mid-floating'
342
-                        ) . EEH_HTML::div(
343
-                            ' ',
344
-                            'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
345
-                            'eep-ppc-separator-line eep-right-floating'
346
-                        ),
347
-                        'eep-ppc-separator-holder',
348
-                        'eep-ppc-separator-holder'
349
-                    )
350
-                ),
351
-            ]
352
-        );
353
-    }
354
-
355
-
356
-    /**
357
-     * Exclude the info subsection from the PPC checkout form.
358
-     *
359
-     * @param array $options_array
360
-     * @return array
361
-     * @throws EE_Error
362
-     * @throws ReflectionException
363
-     */
364
-    public function excludeInfoSubsection(array $options_array): array
365
-    {
366
-        if (! empty($options_array['html_id'])
367
-            && $options_array['html_id'] === 'spco-payment-method-info-' . $this->paypal_pmt->slug()
368
-        ) {
369
-            if (! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
370
-                unset($options_array['subsections']['info']);
371
-            }
372
-        }
373
-        return $options_array;
374
-    }
375
-
376
-
377
-    /**
378
-     * Possibly adds debug content to PayPal commerce billing form.
379
-     *
380
-     * @param EE_Payment_Method $paypal_pm
381
-     * @return EE_Form_Section_Base
382
-     * @throws EE_Error|ReflectionException
383
-     */
384
-    public function addDebugContent(EE_Payment_Method $paypal_pm): EE_Form_Section_Base
385
-    {
386
-        if ($paypal_pm->debug_mode()) {
387
-            return new EE_Form_Section_Proper(
388
-                [
389
-                    'layout_strategy' => new EE_Template_Layout(
390
-                        [
391
-                            'layout_template_file' => $this->template_path . 'debugInfo.template.php',
392
-                            'template_args'        => [],
393
-                        ]
394
-                    ),
395
-                ]
396
-            );
397
-        }
398
-        return new EE_Form_Section_HTML();
399
-    }
400
-
401
-
402
-    /**
403
-     * Add PayPal checkout buttons.
404
-     *
405
-     * @return EE_Form_Section_Proper
406
-     * @throws EE_Error
407
-     */
408
-    public function addPayPalCheckout(): EE_Form_Section_Proper
409
-    {
410
-        $template_args['pm_slug'] = $this->paypal_pmt->slug();
411
-        return new EE_Form_Section_Proper(
412
-            [
413
-                'layout_strategy' => new EE_Template_Layout(
414
-                    [
415
-                        'layout_template_file' => $this->template_path . 'paymentButtons.template.php',
416
-                        'template_args'        => $template_args,
417
-                    ]
418
-                ),
419
-            ]
420
-        );
421
-    }
422
-
423
-
424
-    /**
425
-     * Load scripts and localize data needed for this form.
426
-     *
427
-     * @param $tag
428
-     * @param $handle
429
-     * @return string
430
-     */
431
-    public function addDataTagsToScript($tag, $handle): string
432
-    {
433
-        if ($handle === 'eea_paypal_commerce_js_lib') {
434
-            $bn_code  = PayPalExtraMetaManager::getPmOption($this->_pm_instance, Domain::META_KEY_BN_CODE);
435
-            $response = EED_PayPalCommerce::requestClientToken($this->paypal_pmt);
436
-            if (empty($response['client_token'])) {
437
-                return $tag;
438
-            }
439
-            $client_token = $response['client_token'];
440
-            $attributes   = " data-partner-attribution-id=\"$bn_code\" data-client-token=\"$client_token\"";
441
-            $tag          = str_replace('></script>', $attributes . '></script>', $tag);
442
-        }
443
-        return $tag;
444
-    }
445
-
446
-
447
-    /**
448
-     * Load scripts and localize data needed for this form.
449
-     *
450
-     * @return void
451
-     * @throws EE_Error
452
-     * @throws ReflectionException
453
-     * @throws Exception
454
-     */
455
-    public function enqueue_js(): void
456
-    {
457
-        $third_party   = EED_PayPalCommerce::isThirdParty($this->_pm_instance);
458
-        $currency      = CurrencyManager::currencyCode();
459
-        $client_id_key = Domain::META_KEY_CLIENT_ID;
460
-        // Scripts.
461
-        $scripts_src = 'https://www.paypal.com/sdk/js?components=buttons,hosted-fields&intent=capture';
462
-        if ($third_party) {
463
-            $client_id_key = Domain::META_KEY_PARTNER_CLIENT_ID;
464
-            $merchant_id   = PayPalExtraMetaManager::getPmOption(
465
-                $this->_pm_instance,
466
-                Domain::META_KEY_SELLER_MERCHANT_ID
467
-            );
468
-            $scripts_src .= "&merchant-id=$merchant_id";
469
-        }
470
-        $client_id   = PayPalExtraMetaManager::getPmOption($this->_pm_instance, $client_id_key);
471
-        $scripts_src .= "&client-id=$client_id&currency=$currency";
472
-        wp_enqueue_script('eea_paypal_commerce_js_lib', $scripts_src, [], null);
473
-        wp_enqueue_script(
474
-            'eea_paypal_commerce_js',
475
-            EEP_PAYPAL_COMMERCE_URL . 'assets/js/paypal-commerce-payments.js',
476
-            ['eea_paypal_commerce_js_lib'],
477
-            EVENT_ESPRESSO_VERSION,
478
-            true
479
-        );
480
-        // Styles.
481
-        wp_enqueue_style(
482
-            'eea_paypal_checkout_form_styles',
483
-            EEP_PAYPAL_COMMERCE_URL . 'assets' . DS . 'css' . DS . 'eea-paypal-checkout.css',
484
-            [],
485
-            EVENT_ESPRESSO_VERSION
486
-        );
487
-        // Localize the script with our transaction data.
488
-        $parameters = $this->localizeParameters();
489
-        wp_localize_script('eea_paypal_commerce_js', 'eeaPPCommerceParameters', $parameters);
490
-        parent::enqueue_js();
491
-    }
492
-
493
-
494
-    /**
495
-     * Get PayPal order if already created for this transaction and saved.
496
-     *
497
-     * @param string $transaction_id
498
-     * @return array
499
-     */
500
-    public function getPpOrder(string $transaction_id): array
501
-    {
502
-        try {
503
-            $pp_order        = PayPalExtraMetaManager::getPmOption($this->paypal_pmt, Domain::META_KEY_LAST_ORDER);
504
-            $pp_order_txn_id = $pp_order['ee_txn_id'] ?? false;
505
-            if ($pp_order_txn_id !== $transaction_id) {
506
-                // Old order data, delete it.
507
-                PayPalExtraMetaManager::deletePmOption($this->paypal_pmt, Domain::META_KEY_LAST_ORDER);
508
-                return [];
509
-            }
510
-        } catch (Exception $exception) {
511
-            return [];
512
-        }
513
-        return (array) $pp_order;
514
-    }
515
-
516
-
517
-    /**
518
-     * Form and return PayPal commerce parameters for script localization.
519
-     *
520
-     * @return array
521
-     * @throws EE_Error
522
-     * @throws ReflectionException
523
-     * @throws Exception
524
-     */
525
-    public function localizeParameters(): array
526
-    {
527
-        // Also tell the script about each instance of this PM.
528
-        $pm_versions            = [];
529
-        $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(
530
-            EEM_Payment_Method::scope_cart,
531
-            [['PMD_slug' => ['LIKE', '%paypalcheckout%']]]
532
-        );
533
-        foreach ($active_payment_methods as $payment_method) {
534
-            $pm_versions[ $payment_method->slug() ] = [
535
-                'pm_slug' => $payment_method->slug(),
536
-            ];
537
-        }
538
-        // Convert money for a display format.
539
-        $decimal_places = CurrencyManager::getDecimalPlaces();
540
-        $org_country    = isset(EE_Registry::instance()->CFG->organization)
541
-                          && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
542
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
543
-            : 'US';
544
-        $transaction_id = $this->transaction instanceof EE_Transaction ? $this->transaction->ID() : 0;
545
-        $currency_code  = CurrencyManager::currencyCode();
546
-        $paypal_order   = empty($transaction_id) ? [] : $this->getPpOrder($transaction_id);
547
-        $order_amount   = $paypal_order['purchase_units'][0]['payments']['captures'][0]['amount']['value'] ?? '';
548
-        return [
549
-            'pm_versions'            => $pm_versions,
550
-            'payment_currency'       => $currency_code,
551
-            'checkout_type'          => $this->checkout_type,
552
-            'currency_sign'          => EE_Registry::instance()->CFG->currency->sign,
553
-            'pp_order_id'            => $paypal_order['id'] ?? '',
554
-            'pp_order_status'        => $paypal_order['status'] ?? 'ORDER_STATUS_UNKNOWN',
555
-            'pp_order_amount'        => $order_amount,
556
-            'pp_order_nonce'         => wp_create_nonce(Domain::CAPTURE_ORDER_NONCE_NAME),
557
-            // The transaction ID is only used for logging errors.
558
-            'txn_id'                 => $transaction_id,
559
-            'org_country'            => $org_country,
560
-            'decimal_places'         => $decimal_places,
561
-            'site_name'              => get_bloginfo('name'),
562
-            'active_states'          => EED_PayPalCommerce::getActiveStates(),
563
-            'no_spco_error'          => esc_html__(
564
-                'It appears the SDK script was not loaded properly! Please refresh the page and try again or contact support.',
565
-                'event_espresso'
566
-            ),
567
-            'no_pm_error'            => esc_html__(
568
-                'It appears that PayPal Commerce checkout JavaScript was not loaded properly! Please refresh the page and try again or contact support. PayPal Commerce payments can\'t be processed.',
569
-                'event_espresso'
570
-            ),
571
-            'browser_not_supported'  => esc_html__(
572
-                'It appears that this browser is not supported by PayPal scripts. We apologize, but PayPal payments won\'t work in this browser version.',
573
-                'event_espresso'
574
-            ),
575
-            'get_token_error'        => esc_html__(
576
-                'There was an error while trying to get the payment token. Please refresh the page and try again or contact support.',
577
-                'event_espresso'
578
-            ),
579
-            'form_validation_notice' => esc_html__('Billing form information not valid.', 'event_espresso'),
580
-            'no_verification_token'  => esc_html__('Missing the Verification token.', 'event_espresso'),
581
-            'error_response'         => esc_html__('Got an error response (AJAX)', 'event_espresso'),
582
-            'payment_error'          => esc_html__(
583
-                'There was an error with this payment. See the logs for details.',
584
-                'event_espresso'
585
-            ),
586
-            'no_order_id'            => esc_html__('No Order ID found.', 'event_espresso'),
587
-            'general_pp_error'       => esc_html__('PayPal form threw an error.', 'event_espresso'),
588
-            'hf_render_error'        => esc_html__('Hosted fields could not be rendered!', 'event_espresso'),
589
-            'pm_capture_error'       => esc_html__('Payment could not be captured!', 'event_espresso'),
590
-            'not_acdc_eligible'      => esc_html__('This merchant is not eligible for Advanced Card Fields checkout type.', 'event_espresso'),
591
-        ];
592
-    }
41
+	/**
42
+	 * Filepath to template files
43
+	 *
44
+	 * @var @template_path
45
+	 */
46
+	protected $template_path;
47
+
48
+	/**
49
+	 * @var EE_Transaction
50
+	 */
51
+	protected $transaction;
52
+
53
+	/**
54
+	 * @var EE_PMT_PayPalCheckout
55
+	 */
56
+	protected $paypal_pmt;
57
+
58
+	/**
59
+	 * @var string
60
+	 */
61
+	protected $checkout_type;
62
+
63
+
64
+	/**
65
+	 * Class constructor.
66
+	 *
67
+	 * @param EE_Payment_Method $payment_method
68
+	 * @param array             $options
69
+	 * @throws EE_Error
70
+	 * @throws ReflectionException
71
+	 */
72
+	public function __construct(EE_Payment_Method $payment_method, array $options = [])
73
+	{
74
+		$this->paypal_pmt    = $payment_method;
75
+		// Can't be too careful.
76
+		$this->transaction   = $options['transaction'] ?? null;
77
+		$this->template_path = $options['template_path'] ?? '';
78
+		$this->checkout_type = $payment_method->get_extra_meta(Domain::META_KEY_CHECKOUT_TYPE, true, '');
79
+		$pm_slug             = $payment_method->slug();
80
+		$parameters          = array_replace_recursive(
81
+			$options,
82
+			[
83
+				'name'        => 'PayPalCommerceBillingForm',
84
+				'html_id'     => 'pp-' . $pm_slug . '-billing-form',
85
+				'html_class'  => 'pp_commerce_billing_form',
86
+				'subsections' => [
87
+					'eea_paypal_commerce_token' => new EE_Hidden_Input(
88
+						[
89
+							'html_id'   => 'eea-paypal-commerce-token',
90
+							'html_name' => 'EEA_paymentToken',
91
+							'default'   => '',
92
+						]
93
+					),
94
+					'pp_order_nonce'            => new EE_Hidden_Input(
95
+						[
96
+							'html_id'   => 'eea-' . $pm_slug . '-order-nonce',
97
+							'html_name' => 'pp_order_nonce',
98
+							'default'   => '',
99
+						]
100
+					),
101
+					'pp_order_id'               => new EE_Hidden_Input(
102
+						[
103
+							'html_id'   => 'eea-' . $pm_slug . '-order-id',
104
+							'html_name' => 'pp_order_id',
105
+							'default'   => '',
106
+						]
107
+					),
108
+					'pp_order_status'           => new EE_Hidden_Input(
109
+						[
110
+							'html_id'   => 'eea-' . $pm_slug . '-order-status',
111
+							'html_name' => 'pp_order_status',
112
+							'default'   => '',
113
+						]
114
+					),
115
+					'pp_order_amount'           => new EE_Hidden_Input(
116
+						[
117
+							'html_id'   => 'eea-' . $pm_slug . '-order-amount',
118
+							'html_name' => 'pp_order_amount',
119
+							'default'   => '',
120
+						]
121
+					),
122
+				],
123
+			]
124
+		);
125
+		// Add data tags to the PP script.
126
+		add_filter('script_loader_tag', [$this, 'addDataTagsToScript'], 10, 2);
127
+		parent::__construct($payment_method, $parameters);
128
+		// Add and exclude other sections.
129
+		$this->addPaymentSections();
130
+		// Additional actions and/or filters.
131
+		$this->loadActionsAndFilters();
132
+	}
133
+
134
+
135
+	/**
136
+	 * Add PayPal payment sections.
137
+	 *
138
+	 * @return void
139
+	 * @throws EE_Error
140
+	 * @throws ReflectionException
141
+	 */
142
+	public function addPaymentSections(): void
143
+	{
144
+		// Exclude the default billing form fields.
145
+		$this->exclude([
146
+			'first_name',
147
+			'last_name',
148
+			'email',
149
+		]);
150
+		// Add PayPal Hosted Fields.
151
+		if ($this->checkout_type !== 'express_checkout') {
152
+			$this->addAdvancedCardFields();
153
+		}
154
+		// Add payment types separator, if both are enabled.
155
+		if ($this->checkout_type === 'all') {
156
+			$this->addTypesSeparator();
157
+		}
158
+		// Add PayPal Buttons section.
159
+		if ($this->checkout_type !== 'ppcp') {
160
+			$this->add_subsections(
161
+				[
162
+					'paypal_commerce_pm_form' => $this->addPayPalCheckout(),
163
+				]
164
+			);
165
+		}
166
+		// Exclude the rest billing form fields if the payment type is express checkout.
167
+		if ($this->checkout_type === 'express_checkout') {
168
+			$this->exclude([
169
+				'address',
170
+				'address2',
171
+				'state',
172
+				'phone',
173
+				'city',
174
+				'country',
175
+				'zip',
176
+			]);
177
+			// Remove the Info subsection.
178
+			add_filter('FHEE__EE_Form_Section_Proper___construct__options_array', [$this, 'excludeInfoSubsection']);
179
+		}
180
+		$this->add_subsections(
181
+			[
182
+				'debug_content' => $this->addDebugContent($this->paypal_pmt),
183
+			]
184
+		);
185
+	}
186
+
187
+
188
+	/**
189
+	 * Additional actions and/or filters.
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function loadActionsAndFilters(): void
194
+	{
195
+		add_filter(
196
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
197
+			[__CLASS__, 'excludeBillingFormFields'],
198
+			10,
199
+			2
200
+		);
201
+	}
202
+
203
+
204
+	/**
205
+	 * Filter out billing form fields if pay button was used.
206
+	 *
207
+	 * @param EE_Billing_Info_Form $billing_form
208
+	 * @param EE_Payment_Method    $payment_method
209
+	 * @return EE_Billing_Info_Form
210
+	 */
211
+	public static function excludeBillingFormFields(
212
+		EE_Billing_Info_Form $billing_form,
213
+		EE_Payment_Method    $payment_method
214
+	): EE_Billing_Info_Form {
215
+		$request        = LoaderFactory::getShared(Request::class);
216
+		$request_params = $request->requestParams();
217
+		if (
218
+			// Only the PPC billing form.
219
+			$billing_form instanceof BillingForm
220
+			&& ! empty($request_params['process_form_submission'])
221
+			&& $request_params['process_form_submission'] === '1'
222
+			&& ! empty($request_params['eep_ppc_skip_form_validation'])
223
+		) {
224
+			// Hide card info fields.
225
+			$billing_form->exclude([
226
+				'pp_name_on_card',
227
+				'address',
228
+				'address2',
229
+				'state',
230
+				'phone',
231
+				'city',
232
+				'country',
233
+				'zip',
234
+			]);
235
+		}
236
+		return $billing_form;
237
+	}
238
+
239
+
240
+	/**
241
+	 * Add advanced card & debit card fields.
242
+	 *
243
+	 * @return void
244
+	 * @throws EE_Error|ReflectionException
245
+	 */
246
+	public function addAdvancedCardFields(): void
247
+	{
248
+		$pm_slug = $this->paypal_pmt->slug();
249
+		$this->add_subsections(
250
+			[
251
+				'pp_card_number'     => new EE_Form_Section_HTML(
252
+					EEH_HTML::label(
253
+						esc_html__('Card Number', 'event_espresso'),
254
+						"$pm_slug-card-number-lbl",
255
+						"$pm_slug-card-fields",
256
+						"",
257
+						'for="' . $pm_slug . '-card-number"'
258
+					) .
259
+					EEH_HTML::p(
260
+						"",
261
+						"$pm_slug-card-number",
262
+						"card_field $pm_slug-card-fields"
263
+					)
264
+				),
265
+				'pp_expiration_date' => new EE_Form_Section_HTML(
266
+					EEH_HTML::label(
267
+						esc_html__('Expiration Date', 'event_espresso'),
268
+						"$pm_slug-expiration-date-lbl",
269
+						"$pm_slug-card-fields",
270
+						"",
271
+						'for="' . $pm_slug . '-expiration-date"'
272
+					) .
273
+					EEH_HTML::p(
274
+						"",
275
+						"$pm_slug-expiration-date",
276
+						"card_field $pm_slug-card-fields"
277
+					)
278
+				),
279
+				'pp_card_cvv'        => new EE_Form_Section_HTML(
280
+					EEH_HTML::label(
281
+						esc_html__('CVV', 'event_espresso'),
282
+						"$pm_slug-cvv-lbl",
283
+						"$pm_slug-card-fields",
284
+						"",
285
+						'for="' . $pm_slug . '-cvv"'
286
+					) .
287
+					EEH_HTML::p(
288
+						"",
289
+						"$pm_slug-cvv",
290
+						"card_field $pm_slug-card-fields"
291
+					)
292
+				),
293
+				'pp_name_on_card'    => new EE_Text_Input(
294
+					[
295
+						'html_label_text' => esc_html__('Name On Card', 'event_espresso'),
296
+						'html_id'         => $pm_slug . '-card-holder-name',
297
+						'html_name'       => 'card-holder-name',
298
+						'html_class'      => '',
299
+						'required'        => true,
300
+					]
301
+				),
302
+			]
303
+		);
304
+		// Add the submit button at the end.
305
+		$this->add_subsections(
306
+			[
307
+				'pp_cc_submit' => new EE_Submit_Input(
308
+					[
309
+						'html_label_text' => esc_html__('Submit', 'event_espresso'),
310
+						'html_id'         => $pm_slug,
311
+						'html_class'      => 'eep-ppc-btn',
312
+					]
313
+				),
314
+			],
315
+			'phone',
316
+			false
317
+		);
318
+	}
319
+
320
+
321
+	/**
322
+	 * Add advanced card & debit card fields.
323
+	 *
324
+	 * @return void
325
+	 * @throws EE_Error|ReflectionException
326
+	 */
327
+	public function addTypesSeparator(): void
328
+	{
329
+		$this->add_subsections(
330
+			[
331
+				'pp_payment_types_separator' => new EE_Form_Section_HTML(
332
+					EEH_HTML::div(
333
+						EEH_HTML::div(
334
+							' ',
335
+							'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
336
+							'eep-ppc-separator-line eep-left-floating'
337
+						) .
338
+						EEH_HTML::div(
339
+							esc_html__(' or ', 'event_espresso'),
340
+							'eep-' . $this->paypal_pmt->slug() . '-separator-text',
341
+							'eep-ppc-separator-text1 eep-mid-floating'
342
+						) . EEH_HTML::div(
343
+							' ',
344
+							'eep-' . $this->paypal_pmt->slug() . '-payments-separator',
345
+							'eep-ppc-separator-line eep-right-floating'
346
+						),
347
+						'eep-ppc-separator-holder',
348
+						'eep-ppc-separator-holder'
349
+					)
350
+				),
351
+			]
352
+		);
353
+	}
354
+
355
+
356
+	/**
357
+	 * Exclude the info subsection from the PPC checkout form.
358
+	 *
359
+	 * @param array $options_array
360
+	 * @return array
361
+	 * @throws EE_Error
362
+	 * @throws ReflectionException
363
+	 */
364
+	public function excludeInfoSubsection(array $options_array): array
365
+	{
366
+		if (! empty($options_array['html_id'])
367
+			&& $options_array['html_id'] === 'spco-payment-method-info-' . $this->paypal_pmt->slug()
368
+		) {
369
+			if (! empty($options_array['subsections']) && isset($options_array['subsections']['info'])) {
370
+				unset($options_array['subsections']['info']);
371
+			}
372
+		}
373
+		return $options_array;
374
+	}
375
+
376
+
377
+	/**
378
+	 * Possibly adds debug content to PayPal commerce billing form.
379
+	 *
380
+	 * @param EE_Payment_Method $paypal_pm
381
+	 * @return EE_Form_Section_Base
382
+	 * @throws EE_Error|ReflectionException
383
+	 */
384
+	public function addDebugContent(EE_Payment_Method $paypal_pm): EE_Form_Section_Base
385
+	{
386
+		if ($paypal_pm->debug_mode()) {
387
+			return new EE_Form_Section_Proper(
388
+				[
389
+					'layout_strategy' => new EE_Template_Layout(
390
+						[
391
+							'layout_template_file' => $this->template_path . 'debugInfo.template.php',
392
+							'template_args'        => [],
393
+						]
394
+					),
395
+				]
396
+			);
397
+		}
398
+		return new EE_Form_Section_HTML();
399
+	}
400
+
401
+
402
+	/**
403
+	 * Add PayPal checkout buttons.
404
+	 *
405
+	 * @return EE_Form_Section_Proper
406
+	 * @throws EE_Error
407
+	 */
408
+	public function addPayPalCheckout(): EE_Form_Section_Proper
409
+	{
410
+		$template_args['pm_slug'] = $this->paypal_pmt->slug();
411
+		return new EE_Form_Section_Proper(
412
+			[
413
+				'layout_strategy' => new EE_Template_Layout(
414
+					[
415
+						'layout_template_file' => $this->template_path . 'paymentButtons.template.php',
416
+						'template_args'        => $template_args,
417
+					]
418
+				),
419
+			]
420
+		);
421
+	}
422
+
423
+
424
+	/**
425
+	 * Load scripts and localize data needed for this form.
426
+	 *
427
+	 * @param $tag
428
+	 * @param $handle
429
+	 * @return string
430
+	 */
431
+	public function addDataTagsToScript($tag, $handle): string
432
+	{
433
+		if ($handle === 'eea_paypal_commerce_js_lib') {
434
+			$bn_code  = PayPalExtraMetaManager::getPmOption($this->_pm_instance, Domain::META_KEY_BN_CODE);
435
+			$response = EED_PayPalCommerce::requestClientToken($this->paypal_pmt);
436
+			if (empty($response['client_token'])) {
437
+				return $tag;
438
+			}
439
+			$client_token = $response['client_token'];
440
+			$attributes   = " data-partner-attribution-id=\"$bn_code\" data-client-token=\"$client_token\"";
441
+			$tag          = str_replace('></script>', $attributes . '></script>', $tag);
442
+		}
443
+		return $tag;
444
+	}
445
+
446
+
447
+	/**
448
+	 * Load scripts and localize data needed for this form.
449
+	 *
450
+	 * @return void
451
+	 * @throws EE_Error
452
+	 * @throws ReflectionException
453
+	 * @throws Exception
454
+	 */
455
+	public function enqueue_js(): void
456
+	{
457
+		$third_party   = EED_PayPalCommerce::isThirdParty($this->_pm_instance);
458
+		$currency      = CurrencyManager::currencyCode();
459
+		$client_id_key = Domain::META_KEY_CLIENT_ID;
460
+		// Scripts.
461
+		$scripts_src = 'https://www.paypal.com/sdk/js?components=buttons,hosted-fields&intent=capture';
462
+		if ($third_party) {
463
+			$client_id_key = Domain::META_KEY_PARTNER_CLIENT_ID;
464
+			$merchant_id   = PayPalExtraMetaManager::getPmOption(
465
+				$this->_pm_instance,
466
+				Domain::META_KEY_SELLER_MERCHANT_ID
467
+			);
468
+			$scripts_src .= "&merchant-id=$merchant_id";
469
+		}
470
+		$client_id   = PayPalExtraMetaManager::getPmOption($this->_pm_instance, $client_id_key);
471
+		$scripts_src .= "&client-id=$client_id&currency=$currency";
472
+		wp_enqueue_script('eea_paypal_commerce_js_lib', $scripts_src, [], null);
473
+		wp_enqueue_script(
474
+			'eea_paypal_commerce_js',
475
+			EEP_PAYPAL_COMMERCE_URL . 'assets/js/paypal-commerce-payments.js',
476
+			['eea_paypal_commerce_js_lib'],
477
+			EVENT_ESPRESSO_VERSION,
478
+			true
479
+		);
480
+		// Styles.
481
+		wp_enqueue_style(
482
+			'eea_paypal_checkout_form_styles',
483
+			EEP_PAYPAL_COMMERCE_URL . 'assets' . DS . 'css' . DS . 'eea-paypal-checkout.css',
484
+			[],
485
+			EVENT_ESPRESSO_VERSION
486
+		);
487
+		// Localize the script with our transaction data.
488
+		$parameters = $this->localizeParameters();
489
+		wp_localize_script('eea_paypal_commerce_js', 'eeaPPCommerceParameters', $parameters);
490
+		parent::enqueue_js();
491
+	}
492
+
493
+
494
+	/**
495
+	 * Get PayPal order if already created for this transaction and saved.
496
+	 *
497
+	 * @param string $transaction_id
498
+	 * @return array
499
+	 */
500
+	public function getPpOrder(string $transaction_id): array
501
+	{
502
+		try {
503
+			$pp_order        = PayPalExtraMetaManager::getPmOption($this->paypal_pmt, Domain::META_KEY_LAST_ORDER);
504
+			$pp_order_txn_id = $pp_order['ee_txn_id'] ?? false;
505
+			if ($pp_order_txn_id !== $transaction_id) {
506
+				// Old order data, delete it.
507
+				PayPalExtraMetaManager::deletePmOption($this->paypal_pmt, Domain::META_KEY_LAST_ORDER);
508
+				return [];
509
+			}
510
+		} catch (Exception $exception) {
511
+			return [];
512
+		}
513
+		return (array) $pp_order;
514
+	}
515
+
516
+
517
+	/**
518
+	 * Form and return PayPal commerce parameters for script localization.
519
+	 *
520
+	 * @return array
521
+	 * @throws EE_Error
522
+	 * @throws ReflectionException
523
+	 * @throws Exception
524
+	 */
525
+	public function localizeParameters(): array
526
+	{
527
+		// Also tell the script about each instance of this PM.
528
+		$pm_versions            = [];
529
+		$active_payment_methods = EEM_Payment_Method::instance()->get_all_active(
530
+			EEM_Payment_Method::scope_cart,
531
+			[['PMD_slug' => ['LIKE', '%paypalcheckout%']]]
532
+		);
533
+		foreach ($active_payment_methods as $payment_method) {
534
+			$pm_versions[ $payment_method->slug() ] = [
535
+				'pm_slug' => $payment_method->slug(),
536
+			];
537
+		}
538
+		// Convert money for a display format.
539
+		$decimal_places = CurrencyManager::getDecimalPlaces();
540
+		$org_country    = isset(EE_Registry::instance()->CFG->organization)
541
+						  && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
542
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
543
+			: 'US';
544
+		$transaction_id = $this->transaction instanceof EE_Transaction ? $this->transaction->ID() : 0;
545
+		$currency_code  = CurrencyManager::currencyCode();
546
+		$paypal_order   = empty($transaction_id) ? [] : $this->getPpOrder($transaction_id);
547
+		$order_amount   = $paypal_order['purchase_units'][0]['payments']['captures'][0]['amount']['value'] ?? '';
548
+		return [
549
+			'pm_versions'            => $pm_versions,
550
+			'payment_currency'       => $currency_code,
551
+			'checkout_type'          => $this->checkout_type,
552
+			'currency_sign'          => EE_Registry::instance()->CFG->currency->sign,
553
+			'pp_order_id'            => $paypal_order['id'] ?? '',
554
+			'pp_order_status'        => $paypal_order['status'] ?? 'ORDER_STATUS_UNKNOWN',
555
+			'pp_order_amount'        => $order_amount,
556
+			'pp_order_nonce'         => wp_create_nonce(Domain::CAPTURE_ORDER_NONCE_NAME),
557
+			// The transaction ID is only used for logging errors.
558
+			'txn_id'                 => $transaction_id,
559
+			'org_country'            => $org_country,
560
+			'decimal_places'         => $decimal_places,
561
+			'site_name'              => get_bloginfo('name'),
562
+			'active_states'          => EED_PayPalCommerce::getActiveStates(),
563
+			'no_spco_error'          => esc_html__(
564
+				'It appears the SDK script was not loaded properly! Please refresh the page and try again or contact support.',
565
+				'event_espresso'
566
+			),
567
+			'no_pm_error'            => esc_html__(
568
+				'It appears that PayPal Commerce checkout JavaScript was not loaded properly! Please refresh the page and try again or contact support. PayPal Commerce payments can\'t be processed.',
569
+				'event_espresso'
570
+			),
571
+			'browser_not_supported'  => esc_html__(
572
+				'It appears that this browser is not supported by PayPal scripts. We apologize, but PayPal payments won\'t work in this browser version.',
573
+				'event_espresso'
574
+			),
575
+			'get_token_error'        => esc_html__(
576
+				'There was an error while trying to get the payment token. Please refresh the page and try again or contact support.',
577
+				'event_espresso'
578
+			),
579
+			'form_validation_notice' => esc_html__('Billing form information not valid.', 'event_espresso'),
580
+			'no_verification_token'  => esc_html__('Missing the Verification token.', 'event_espresso'),
581
+			'error_response'         => esc_html__('Got an error response (AJAX)', 'event_espresso'),
582
+			'payment_error'          => esc_html__(
583
+				'There was an error with this payment. See the logs for details.',
584
+				'event_espresso'
585
+			),
586
+			'no_order_id'            => esc_html__('No Order ID found.', 'event_espresso'),
587
+			'general_pp_error'       => esc_html__('PayPal form threw an error.', 'event_espresso'),
588
+			'hf_render_error'        => esc_html__('Hosted fields could not be rendered!', 'event_espresso'),
589
+			'pm_capture_error'       => esc_html__('Payment could not be captured!', 'event_espresso'),
590
+			'not_acdc_eligible'      => esc_html__('This merchant is not eligible for Advanced Card Fields checkout type.', 'event_espresso'),
591
+		];
592
+	}
593 593
 }
Please login to merge, or discard this patch.