Completed
Branch FET/9575/invisible-recaptcha (e4358d)
by
unknown
49:51 queued 37:56
created
single_page_checkout/templates/registration_page_wrapper.template.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@  discard block
 block discarded – undo
1 1
 <div id="ee-single-page-checkout-dv" class="">
2 2
 <?php
3
-if ( ! $empty_cart ) {
4
-	if ( apply_filters( 'FHEE__registration_page_wrapper_template__display_time_limit', false ) ) { ?>
3
+if ( ! $empty_cart) {
4
+	if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { ?>
5 5
 	<p id="spco-registration-time-limit-pg" class="spco-steps-pg ee-attention important-notice" style="display: none;">
6 6
 		<?php echo sprintf(
7 7
 			apply_filters(
8 8
 				'FHEE__registration_page_wrapper_template___time_limit',
9
-				__( 'You have %1$s to complete your registration.', 'event_espresso' )
9
+				__('You have %1$s to complete your registration.', 'event_espresso')
10 10
 			),
11
-			'<span id="spco-registration-time-limit-spn" class="spco-registration-time-limit-spn">' . $registration_time_limit . '</span>'
11
+			'<span id="spco-registration-time-limit-spn" class="spco-registration-time-limit-spn">'.$registration_time_limit.'</span>'
12 12
 		);
13 13
 		?>
14 14
 		<span id="spco-registration-expiration-spn" class="" style="display:none;"></span>
15 15
 	</p>
16 16
 <?php }
17
-	if ( ! $revisit && apply_filters( 'FHEE__registration_page_wrapper_template__steps_display', TRUE )) {
17
+	if ( ! $revisit && apply_filters('FHEE__registration_page_wrapper_template__steps_display', TRUE)) {
18 18
 ?>
19 19
 	<h2 id="spco-steps-big-hdr" class="spco-steps-big-hdr"><?php _e(' Steps', 'event_espresso'); ?></h2>
20 20
 
21 21
 	<div id="spco-steps-display-dv">
22 22
 	<?php
23 23
 		$step_nmbr = 1;
24
-		$total_steps = count( $reg_steps ) - 1;
25
-		foreach ( $reg_steps as $reg_step ) {
26
-			if ( $reg_step instanceof EE_SPCO_Reg_Step && $reg_step->slug() != 'finalize_registration' ) {
24
+		$total_steps = count($reg_steps) - 1;
25
+		foreach ($reg_steps as $reg_step) {
26
+			if ($reg_step instanceof EE_SPCO_Reg_Step && $reg_step->slug() != 'finalize_registration') {
27 27
 				$slug = $reg_step->slug();
28 28
 				$step_display_dv_class = $reg_step->is_current_step() ? 'active-step' : 'inactive-step';
29 29
 		?>
30 30
 		<div id="spco-step-<?php echo $slug; ?>-display-dv" class="spco-step-display-dv <?php echo $step_display_dv_class; ?> steps-<?php echo $total_steps; ?>">
31 31
 			<h4 id="spco-step-<?php echo $slug; ?>-display-hdr" class="spco-steps-display-hdr">
32
-				<span class="spco-step-big-nmbr"><?php echo $step_nmbr; ?></span>&nbsp;<span class="spco-step-name"><?php echo str_replace( '&nbsp;', '<br/>&nbsp;', $reg_step->name() ); ?></span>
32
+				<span class="spco-step-big-nmbr"><?php echo $step_nmbr; ?></span>&nbsp;<span class="spco-step-name"><?php echo str_replace('&nbsp;', '<br/>&nbsp;', $reg_step->name()); ?></span>
33 33
 			</h4>
34 34
 		</div>
35 35
 
36
-		<?php if ( $step_nmbr < $total_steps ) { ?>
36
+		<?php if ($step_nmbr < $total_steps) { ?>
37 37
 		<div class="spco-step-arrow-dv">&raquo;</div>
38 38
 		<?php
39 39
 				}
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
 	<?php
48 48
 	}
49 49
 
50
-	do_action( 'AHEE__SPCO__before_registration_steps' );
50
+	do_action('AHEE__SPCO__before_registration_steps');
51 51
 	$step_nmbr = 1;
52
-	foreach ( $reg_steps as $reg_step ) {
53
-		if ( $reg_step instanceof EE_SPCO_Reg_Step && $reg_step->slug() != 'finalize_registration' ) {
52
+	foreach ($reg_steps as $reg_step) {
53
+		if ($reg_step instanceof EE_SPCO_Reg_Step && $reg_step->slug() != 'finalize_registration') {
54 54
 			$slug = $reg_step->slug();
55
-			do_action( 'AHEE__' . $slug . '__reg_step_start', $reg_step );
55
+			do_action('AHEE__'.$slug.'__reg_step_start', $reg_step);
56 56
 			// todo: deprecate hook AHEE__registration_page_attendee_information__start
57 57
 	?>
58 58
 		<div id="spco-<?php echo $slug; ?>-dv" class="spco-step-dv <?php echo $reg_step->div_class(); ?>">
59 59
 			<?php echo $reg_step->display_reg_form(); ?>
60
-			<?php do_action( 'AHEE__SPCO_after_reg_step_form', $slug, $next_step ); ?>
60
+			<?php do_action('AHEE__SPCO_after_reg_step_form', $slug, $next_step); ?>
61 61
 		</div>
62 62
 			<?php $step_nmbr++;
63 63
 		}
64 64
 	}
65
-	do_action( 'AHEE__SPCO__after_registration_steps' );
65
+	do_action('AHEE__SPCO__after_registration_steps');
66 66
 
67 67
 } else {
68 68
 ?>
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	<?php echo $cookies_not_set_msg; ?>
72 72
 <?php
73 73
 }
74
-do_action( 'AHEE__SPCO__reg_form_footer' );
74
+do_action('AHEE__SPCO__reg_form_footer');
75 75
 ?>
76 76
 
77 77
 </div>
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     /**
604 604
      * returns any events attached to this attendee ($_Event property);
605 605
      *
606
-     * @return array
606
+     * @return EE_Base_Class[]
607 607
      * @throws EE_Error
608 608
      */
609 609
     public function events()
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
      * used to save the billing info
619 619
      *
620 620
      * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
-     * @return EE_Form_Section_Proper|null
621
+     * @return null|EE_Billing_Info_Form
622 622
      * @throws EE_Error
623 623
      */
624 624
     public function billing_info_for_payment_method($payment_method)
Please login to merge, or discard this patch.
Indentation   +730 added lines, -730 removed lines patch added patch discarded remove patch
@@ -27,734 +27,734 @@
 block discarded – undo
27 27
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
28 28
 {
29 29
 
30
-    /**
31
-     * Sets some dynamic defaults
32
-     *
33
-     * @param array  $fieldValues
34
-     * @param bool   $bydb
35
-     * @param string $timezone
36
-     * @param array  $date_formats
37
-     * @throws EE_Error
38
-     */
39
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40
-    {
41
-        if (! isset($fieldValues['ATT_full_name'])) {
42
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
43
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
-            $fieldValues['ATT_full_name'] = $fname . $lname;
45
-        }
46
-        if (! isset($fieldValues['ATT_slug'])) {
47
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49
-        }
50
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52
-        }
53
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
54
-    }
55
-
56
-
57
-    /**
58
-     * @param array  $props_n_values          incoming values
59
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
60
-     *                                        used.)
61
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
62
-     *                                        date_format and the second value is the time format
63
-     * @return EE_Attendee
64
-     * @throws EE_Error
65
-     */
66
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
67
-    {
68
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
69
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param array  $props_n_values  incoming values from the database
75
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
76
-     *                                the website will be used.
77
-     * @return EE_Attendee
78
-     */
79
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
80
-    {
81
-        return new self($props_n_values, true, $timezone);
82
-    }
83
-
84
-
85
-    /**
86
-     *        Set Attendee First Name
87
-     *
88
-     * @access        public
89
-     * @param string $fname
90
-     * @throws EE_Error
91
-     */
92
-    public function set_fname($fname = '')
93
-    {
94
-        $this->set('ATT_fname', $fname);
95
-    }
96
-
97
-
98
-    /**
99
-     *        Set Attendee Last Name
100
-     *
101
-     * @access        public
102
-     * @param string $lname
103
-     * @throws EE_Error
104
-     */
105
-    public function set_lname($lname = '')
106
-    {
107
-        $this->set('ATT_lname', $lname);
108
-    }
109
-
110
-
111
-    /**
112
-     *        Set Attendee Address
113
-     *
114
-     * @access        public
115
-     * @param string $address
116
-     * @throws EE_Error
117
-     */
118
-    public function set_address($address = '')
119
-    {
120
-        $this->set('ATT_address', $address);
121
-    }
122
-
123
-
124
-    /**
125
-     *        Set Attendee Address2
126
-     *
127
-     * @access        public
128
-     * @param        string $address2
129
-     * @throws EE_Error
130
-     */
131
-    public function set_address2($address2 = '')
132
-    {
133
-        $this->set('ATT_address2', $address2);
134
-    }
135
-
136
-
137
-    /**
138
-     *        Set Attendee City
139
-     *
140
-     * @access        public
141
-     * @param        string $city
142
-     * @throws EE_Error
143
-     */
144
-    public function set_city($city = '')
145
-    {
146
-        $this->set('ATT_city', $city);
147
-    }
148
-
149
-
150
-    /**
151
-     *        Set Attendee State ID
152
-     *
153
-     * @access        public
154
-     * @param        int $STA_ID
155
-     * @throws EE_Error
156
-     */
157
-    public function set_state($STA_ID = 0)
158
-    {
159
-        $this->set('STA_ID', $STA_ID);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Country ISO Code
165
-     *
166
-     * @access        public
167
-     * @param        string $CNT_ISO
168
-     * @throws EE_Error
169
-     */
170
-    public function set_country($CNT_ISO = '')
171
-    {
172
-        $this->set('CNT_ISO', $CNT_ISO);
173
-    }
174
-
175
-
176
-    /**
177
-     *        Set Attendee Zip/Postal Code
178
-     *
179
-     * @access        public
180
-     * @param        string $zip
181
-     * @throws EE_Error
182
-     */
183
-    public function set_zip($zip = '')
184
-    {
185
-        $this->set('ATT_zip', $zip);
186
-    }
187
-
188
-
189
-    /**
190
-     *        Set Attendee Email Address
191
-     *
192
-     * @access        public
193
-     * @param        string $email
194
-     * @throws EE_Error
195
-     */
196
-    public function set_email($email = '')
197
-    {
198
-        $this->set('ATT_email', $email);
199
-    }
200
-
201
-
202
-    /**
203
-     *        Set Attendee Phone
204
-     *
205
-     * @access        public
206
-     * @param        string $phone
207
-     * @throws EE_Error
208
-     */
209
-    public function set_phone($phone = '')
210
-    {
211
-        $this->set('ATT_phone', $phone);
212
-    }
213
-
214
-
215
-    /**
216
-     *        set deleted
217
-     *
218
-     * @access        public
219
-     * @param        bool $ATT_deleted
220
-     * @throws EE_Error
221
-     */
222
-    public function set_deleted($ATT_deleted = false)
223
-    {
224
-        $this->set('ATT_deleted', $ATT_deleted);
225
-    }
226
-
227
-
228
-    /**
229
-     * Returns the value for the post_author id saved with the cpt
230
-     *
231
-     * @since 4.5.0
232
-     * @return int
233
-     * @throws EE_Error
234
-     */
235
-    public function wp_user()
236
-    {
237
-        return $this->get('ATT_author');
238
-    }
239
-
240
-
241
-    /**
242
-     *        get Attendee First Name
243
-     *
244
-     * @access        public
245
-     * @return string
246
-     * @throws EE_Error
247
-     */
248
-    public function fname()
249
-    {
250
-        return $this->get('ATT_fname');
251
-    }
252
-
253
-
254
-    /**
255
-     * echoes out the attendee's first name
256
-     *
257
-     * @return void
258
-     * @throws EE_Error
259
-     */
260
-    public function e_full_name()
261
-    {
262
-        echo $this->full_name();
263
-    }
264
-
265
-
266
-    /**
267
-     * Returns the first and last name concatenated together with a space.
268
-     *
269
-     * @param bool $apply_html_entities
270
-     * @return string
271
-     * @throws EE_Error
272
-     */
273
-    public function full_name($apply_html_entities = false)
274
-    {
275
-        $full_name = array(
276
-            $this->fname(),
277
-            $this->lname(),
278
-        );
279
-        $full_name = array_filter($full_name);
280
-        $full_name = implode(' ', $full_name);
281
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
282
-    }
283
-
284
-
285
-    /**
286
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
287
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
288
-     * attendee.
289
-     *
290
-     * @param bool $apply_html_entities
291
-     * @return string
292
-     * @throws EE_Error
293
-     */
294
-    public function ATT_full_name($apply_html_entities = false)
295
-    {
296
-        return $apply_html_entities
297
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
298
-            : $this->get('ATT_full_name');
299
-    }
300
-
301
-
302
-    /**
303
-     *        get Attendee Last Name
304
-     *
305
-     * @access        public
306
-     * @return string
307
-     * @throws EE_Error
308
-     */
309
-    public function lname()
310
-    {
311
-        return $this->get('ATT_lname');
312
-    }
313
-
314
-
315
-    /**
316
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
317
-     *
318
-     * @return array numerically indexed, with each part of the address that is known.
319
-     * Eg, if the user only responded to state and country,
320
-     * it would be array(0=>'Alabama',1=>'USA')
321
-     * @return array
322
-     * @throws EE_Error
323
-     */
324
-    public function full_address_as_array()
325
-    {
326
-        $full_address_array     = array();
327
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328
-        foreach ($initial_address_fields as $address_field_name) {
329
-            $address_fields_value = $this->get($address_field_name);
330
-            if (! empty($address_fields_value)) {
331
-                $full_address_array[] = $address_fields_value;
332
-            }
333
-        }
334
-        //now handle state and country
335
-        $state_obj = $this->state_obj();
336
-        if ($state_obj instanceof EE_State) {
337
-            $full_address_array[] = $state_obj->name();
338
-        }
339
-        $country_obj = $this->country_obj();
340
-        if ($country_obj instanceof EE_Country) {
341
-            $full_address_array[] = $country_obj->name();
342
-        }
343
-        //lastly get the xip
344
-        $zip_value = $this->zip();
345
-        if (! empty($zip_value)) {
346
-            $full_address_array[] = $zip_value;
347
-        }
348
-        return $full_address_array;
349
-    }
350
-
351
-
352
-    /**
353
-     *        get Attendee Address
354
-     *
355
-     * @return string
356
-     * @throws EE_Error
357
-     */
358
-    public function address()
359
-    {
360
-        return $this->get('ATT_address');
361
-    }
362
-
363
-
364
-    /**
365
-     *        get Attendee Address2
366
-     *
367
-     * @return string
368
-     * @throws EE_Error
369
-     */
370
-    public function address2()
371
-    {
372
-        return $this->get('ATT_address2');
373
-    }
374
-
375
-
376
-    /**
377
-     *        get Attendee City
378
-     *
379
-     * @return string
380
-     * @throws EE_Error
381
-     */
382
-    public function city()
383
-    {
384
-        return $this->get('ATT_city');
385
-    }
386
-
387
-
388
-    /**
389
-     *        get Attendee State ID
390
-     *
391
-     * @return string
392
-     * @throws EE_Error
393
-     */
394
-    public function state_ID()
395
-    {
396
-        return $this->get('STA_ID');
397
-    }
398
-
399
-
400
-    /**
401
-     * @return string
402
-     * @throws EE_Error
403
-     */
404
-    public function state_abbrev()
405
-    {
406
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
407
-    }
408
-
409
-
410
-    /**
411
-     * Gets the state set to this attendee
412
-     *
413
-     * @return EE_State
414
-     * @throws EE_Error
415
-     */
416
-    public function state_obj()
417
-    {
418
-        return $this->get_first_related('State');
419
-    }
420
-
421
-
422
-    /**
423
-     * Returns the state's name, otherwise 'Unknown'
424
-     *
425
-     * @return string
426
-     * @throws EE_Error
427
-     */
428
-    public function state_name()
429
-    {
430
-        if ($this->state_obj()) {
431
-            return $this->state_obj()->name();
432
-        } else {
433
-            return '';
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     * either displays the state abbreviation or the state name, as determined
440
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
441
-     * defaults to abbreviation
442
-     *
443
-     * @return string
444
-     * @throws EE_Error
445
-     */
446
-    public function state()
447
-    {
448
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
449
-            return $this->state_abbrev();
450
-        }
451
-        return $this->state_name();
452
-    }
453
-
454
-
455
-    /**
456
-     *    get Attendee Country ISO Code
457
-     *
458
-     * @return string
459
-     * @throws EE_Error
460
-     */
461
-    public function country_ID()
462
-    {
463
-        return $this->get('CNT_ISO');
464
-    }
465
-
466
-
467
-    /**
468
-     * Gets country set for this attendee
469
-     *
470
-     * @return EE_Country
471
-     * @throws EE_Error
472
-     */
473
-    public function country_obj()
474
-    {
475
-        return $this->get_first_related('Country');
476
-    }
477
-
478
-
479
-    /**
480
-     * Returns the country's name if known, otherwise 'Unknown'
481
-     *
482
-     * @return string
483
-     * @throws EE_Error
484
-     */
485
-    public function country_name()
486
-    {
487
-        if ($this->country_obj()) {
488
-            return $this->country_obj()->name();
489
-        }
490
-        return '';
491
-    }
492
-
493
-
494
-    /**
495
-     * either displays the country ISO2 code or the country name, as determined
496
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
497
-     * defaults to abbreviation
498
-     *
499
-     * @return string
500
-     * @throws EE_Error
501
-     */
502
-    public function country()
503
-    {
504
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
505
-            return $this->country_ID();
506
-        }
507
-        return $this->country_name();
508
-    }
509
-
510
-
511
-    /**
512
-     *        get Attendee Zip/Postal Code
513
-     *
514
-     * @return string
515
-     * @throws EE_Error
516
-     */
517
-    public function zip()
518
-    {
519
-        return $this->get('ATT_zip');
520
-    }
521
-
522
-
523
-    /**
524
-     *        get Attendee Email Address
525
-     *
526
-     * @return string
527
-     * @throws EE_Error
528
-     */
529
-    public function email()
530
-    {
531
-        return $this->get('ATT_email');
532
-    }
533
-
534
-
535
-    /**
536
-     *        get Attendee Phone #
537
-     *
538
-     * @return string
539
-     * @throws EE_Error
540
-     */
541
-    public function phone()
542
-    {
543
-        return $this->get('ATT_phone');
544
-    }
545
-
546
-
547
-    /**
548
-     *    get deleted
549
-     *
550
-     * @return        bool
551
-     * @throws EE_Error
552
-     */
553
-    public function deleted()
554
-    {
555
-        return $this->get('ATT_deleted');
556
-    }
557
-
558
-
559
-    /**
560
-     * Gets registrations of this attendee
561
-     *
562
-     * @param array $query_params
563
-     * @return EE_Registration[]
564
-     * @throws EE_Error
565
-     */
566
-    public function get_registrations($query_params = array())
567
-    {
568
-        return $this->get_many_related('Registration', $query_params);
569
-    }
570
-
571
-
572
-    /**
573
-     * Gets the most recent registration of this attendee
574
-     *
575
-     * @return EE_Registration
576
-     * @throws EE_Error
577
-     */
578
-    public function get_most_recent_registration()
579
-    {
580
-        return $this->get_first_related(
581
-            'Registration',
582
-            array('order_by' => array('REG_date' => 'DESC'))
583
-        ); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
584
-    }
585
-
586
-
587
-    /**
588
-     * Gets the most recent registration for this attend at this event
589
-     *
590
-     * @param int $event_id
591
-     * @return EE_Registration
592
-     * @throws EE_Error
593
-     */
594
-    public function get_most_recent_registration_for_event($event_id)
595
-    {
596
-        return $this->get_first_related(
597
-            'Registration',
598
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
599
-        );
600
-    }
601
-
602
-
603
-    /**
604
-     * returns any events attached to this attendee ($_Event property);
605
-     *
606
-     * @return array
607
-     * @throws EE_Error
608
-     */
609
-    public function events()
610
-    {
611
-        return $this->get_many_related('Event');
612
-    }
613
-
614
-
615
-    /**
616
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
617
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
618
-     * used to save the billing info
619
-     *
620
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
-     * @return EE_Form_Section_Proper|null
622
-     * @throws EE_Error
623
-     */
624
-    public function billing_info_for_payment_method($payment_method)
625
-    {
626
-        $pm_type = $payment_method->type_obj();
627
-        if (! $pm_type instanceof EE_PMT_Base) {
628
-            return null;
629
-        }
630
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
-        if (! $billing_info) {
632
-            return null;
633
-        }
634
-        $billing_form = $pm_type->billing_form();
635
-        if ($billing_form instanceof EE_Form_Section_Proper) {
636
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
637
-        }
638
-        return $billing_form;
639
-    }
640
-
641
-
642
-    /**
643
-     * Gets the postmeta key that holds this attendee's billing info for the
644
-     * specified payment method
645
-     *
646
-     * @param EE_Payment_Method $payment_method
647
-     * @return string
648
-     * @throws EE_Error
649
-     */
650
-    public function get_billing_info_postmeta_name($payment_method)
651
-    {
652
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
653
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
654
-        }
655
-        return null;
656
-    }
657
-
658
-
659
-    /**
660
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
661
-     * retrieve it
662
-     *
663
-     * @param EE_Billing_Attendee_Info_Form $billing_form
664
-     * @param EE_Payment_Method             $payment_method
665
-     * @return boolean
666
-     * @throws EE_Error
667
-     */
668
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
669
-    {
670
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
671
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
672
-            return false;
673
-        }
674
-        $billing_form->clean_sensitive_data();
675
-        return update_post_meta(
676
-            $this->ID(),
677
-            $this->get_billing_info_postmeta_name($payment_method),
678
-            $billing_form->input_values(true)
679
-        );
680
-    }
681
-
682
-
683
-    /**
684
-     * Return the link to the admin details for the object.
685
-     *
686
-     * @return string
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     * @throws ReflectionException
692
-     */
693
-    public function get_admin_details_link()
694
-    {
695
-        return $this->get_admin_edit_link();
696
-    }
697
-
698
-
699
-    /**
700
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
701
-     *
702
-     * @return string
703
-     * @throws EE_Error
704
-     * @throws InvalidArgumentException
705
-     * @throws ReflectionException
706
-     * @throws InvalidDataTypeException
707
-     * @throws InvalidInterfaceException
708
-     */
709
-    public function get_admin_edit_link()
710
-    {
711
-        EE_Registry::instance()->load_helper('URL');
712
-        return EEH_URL::add_query_args_and_nonce(
713
-            array(
714
-                'page'   => 'espresso_registrations',
715
-                'action' => 'edit_attendee',
716
-                'post'   => $this->ID(),
717
-            ),
718
-            admin_url('admin.php')
719
-        );
720
-    }
721
-
722
-
723
-    /**
724
-     * Returns the link to a settings page for the object.
725
-     *
726
-     * @return string
727
-     * @throws EE_Error
728
-     * @throws InvalidArgumentException
729
-     * @throws InvalidDataTypeException
730
-     * @throws InvalidInterfaceException
731
-     * @throws ReflectionException
732
-     */
733
-    public function get_admin_settings_link()
734
-    {
735
-        return $this->get_admin_edit_link();
736
-    }
737
-
738
-
739
-    /**
740
-     * Returns the link to the "overview" for the object (typically the "list table" view).
741
-     *
742
-     * @return string
743
-     * @throws EE_Error
744
-     * @throws InvalidArgumentException
745
-     * @throws ReflectionException
746
-     * @throws InvalidDataTypeException
747
-     * @throws InvalidInterfaceException
748
-     */
749
-    public function get_admin_overview_link()
750
-    {
751
-        EE_Registry::instance()->load_helper('URL');
752
-        return EEH_URL::add_query_args_and_nonce(
753
-            array(
754
-                'page'   => 'espresso_registrations',
755
-                'action' => 'contact_list',
756
-            ),
757
-            admin_url('admin.php')
758
-        );
759
-    }
30
+	/**
31
+	 * Sets some dynamic defaults
32
+	 *
33
+	 * @param array  $fieldValues
34
+	 * @param bool   $bydb
35
+	 * @param string $timezone
36
+	 * @param array  $date_formats
37
+	 * @throws EE_Error
38
+	 */
39
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40
+	{
41
+		if (! isset($fieldValues['ATT_full_name'])) {
42
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
43
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
+			$fieldValues['ATT_full_name'] = $fname . $lname;
45
+		}
46
+		if (! isset($fieldValues['ATT_slug'])) {
47
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49
+		}
50
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52
+		}
53
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
54
+	}
55
+
56
+
57
+	/**
58
+	 * @param array  $props_n_values          incoming values
59
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
60
+	 *                                        used.)
61
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
62
+	 *                                        date_format and the second value is the time format
63
+	 * @return EE_Attendee
64
+	 * @throws EE_Error
65
+	 */
66
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
67
+	{
68
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
69
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param array  $props_n_values  incoming values from the database
75
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
76
+	 *                                the website will be used.
77
+	 * @return EE_Attendee
78
+	 */
79
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
80
+	{
81
+		return new self($props_n_values, true, $timezone);
82
+	}
83
+
84
+
85
+	/**
86
+	 *        Set Attendee First Name
87
+	 *
88
+	 * @access        public
89
+	 * @param string $fname
90
+	 * @throws EE_Error
91
+	 */
92
+	public function set_fname($fname = '')
93
+	{
94
+		$this->set('ATT_fname', $fname);
95
+	}
96
+
97
+
98
+	/**
99
+	 *        Set Attendee Last Name
100
+	 *
101
+	 * @access        public
102
+	 * @param string $lname
103
+	 * @throws EE_Error
104
+	 */
105
+	public function set_lname($lname = '')
106
+	{
107
+		$this->set('ATT_lname', $lname);
108
+	}
109
+
110
+
111
+	/**
112
+	 *        Set Attendee Address
113
+	 *
114
+	 * @access        public
115
+	 * @param string $address
116
+	 * @throws EE_Error
117
+	 */
118
+	public function set_address($address = '')
119
+	{
120
+		$this->set('ATT_address', $address);
121
+	}
122
+
123
+
124
+	/**
125
+	 *        Set Attendee Address2
126
+	 *
127
+	 * @access        public
128
+	 * @param        string $address2
129
+	 * @throws EE_Error
130
+	 */
131
+	public function set_address2($address2 = '')
132
+	{
133
+		$this->set('ATT_address2', $address2);
134
+	}
135
+
136
+
137
+	/**
138
+	 *        Set Attendee City
139
+	 *
140
+	 * @access        public
141
+	 * @param        string $city
142
+	 * @throws EE_Error
143
+	 */
144
+	public function set_city($city = '')
145
+	{
146
+		$this->set('ATT_city', $city);
147
+	}
148
+
149
+
150
+	/**
151
+	 *        Set Attendee State ID
152
+	 *
153
+	 * @access        public
154
+	 * @param        int $STA_ID
155
+	 * @throws EE_Error
156
+	 */
157
+	public function set_state($STA_ID = 0)
158
+	{
159
+		$this->set('STA_ID', $STA_ID);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Country ISO Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $CNT_ISO
168
+	 * @throws EE_Error
169
+	 */
170
+	public function set_country($CNT_ISO = '')
171
+	{
172
+		$this->set('CNT_ISO', $CNT_ISO);
173
+	}
174
+
175
+
176
+	/**
177
+	 *        Set Attendee Zip/Postal Code
178
+	 *
179
+	 * @access        public
180
+	 * @param        string $zip
181
+	 * @throws EE_Error
182
+	 */
183
+	public function set_zip($zip = '')
184
+	{
185
+		$this->set('ATT_zip', $zip);
186
+	}
187
+
188
+
189
+	/**
190
+	 *        Set Attendee Email Address
191
+	 *
192
+	 * @access        public
193
+	 * @param        string $email
194
+	 * @throws EE_Error
195
+	 */
196
+	public function set_email($email = '')
197
+	{
198
+		$this->set('ATT_email', $email);
199
+	}
200
+
201
+
202
+	/**
203
+	 *        Set Attendee Phone
204
+	 *
205
+	 * @access        public
206
+	 * @param        string $phone
207
+	 * @throws EE_Error
208
+	 */
209
+	public function set_phone($phone = '')
210
+	{
211
+		$this->set('ATT_phone', $phone);
212
+	}
213
+
214
+
215
+	/**
216
+	 *        set deleted
217
+	 *
218
+	 * @access        public
219
+	 * @param        bool $ATT_deleted
220
+	 * @throws EE_Error
221
+	 */
222
+	public function set_deleted($ATT_deleted = false)
223
+	{
224
+		$this->set('ATT_deleted', $ATT_deleted);
225
+	}
226
+
227
+
228
+	/**
229
+	 * Returns the value for the post_author id saved with the cpt
230
+	 *
231
+	 * @since 4.5.0
232
+	 * @return int
233
+	 * @throws EE_Error
234
+	 */
235
+	public function wp_user()
236
+	{
237
+		return $this->get('ATT_author');
238
+	}
239
+
240
+
241
+	/**
242
+	 *        get Attendee First Name
243
+	 *
244
+	 * @access        public
245
+	 * @return string
246
+	 * @throws EE_Error
247
+	 */
248
+	public function fname()
249
+	{
250
+		return $this->get('ATT_fname');
251
+	}
252
+
253
+
254
+	/**
255
+	 * echoes out the attendee's first name
256
+	 *
257
+	 * @return void
258
+	 * @throws EE_Error
259
+	 */
260
+	public function e_full_name()
261
+	{
262
+		echo $this->full_name();
263
+	}
264
+
265
+
266
+	/**
267
+	 * Returns the first and last name concatenated together with a space.
268
+	 *
269
+	 * @param bool $apply_html_entities
270
+	 * @return string
271
+	 * @throws EE_Error
272
+	 */
273
+	public function full_name($apply_html_entities = false)
274
+	{
275
+		$full_name = array(
276
+			$this->fname(),
277
+			$this->lname(),
278
+		);
279
+		$full_name = array_filter($full_name);
280
+		$full_name = implode(' ', $full_name);
281
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
282
+	}
283
+
284
+
285
+	/**
286
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
287
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
288
+	 * attendee.
289
+	 *
290
+	 * @param bool $apply_html_entities
291
+	 * @return string
292
+	 * @throws EE_Error
293
+	 */
294
+	public function ATT_full_name($apply_html_entities = false)
295
+	{
296
+		return $apply_html_entities
297
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
298
+			: $this->get('ATT_full_name');
299
+	}
300
+
301
+
302
+	/**
303
+	 *        get Attendee Last Name
304
+	 *
305
+	 * @access        public
306
+	 * @return string
307
+	 * @throws EE_Error
308
+	 */
309
+	public function lname()
310
+	{
311
+		return $this->get('ATT_lname');
312
+	}
313
+
314
+
315
+	/**
316
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
317
+	 *
318
+	 * @return array numerically indexed, with each part of the address that is known.
319
+	 * Eg, if the user only responded to state and country,
320
+	 * it would be array(0=>'Alabama',1=>'USA')
321
+	 * @return array
322
+	 * @throws EE_Error
323
+	 */
324
+	public function full_address_as_array()
325
+	{
326
+		$full_address_array     = array();
327
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328
+		foreach ($initial_address_fields as $address_field_name) {
329
+			$address_fields_value = $this->get($address_field_name);
330
+			if (! empty($address_fields_value)) {
331
+				$full_address_array[] = $address_fields_value;
332
+			}
333
+		}
334
+		//now handle state and country
335
+		$state_obj = $this->state_obj();
336
+		if ($state_obj instanceof EE_State) {
337
+			$full_address_array[] = $state_obj->name();
338
+		}
339
+		$country_obj = $this->country_obj();
340
+		if ($country_obj instanceof EE_Country) {
341
+			$full_address_array[] = $country_obj->name();
342
+		}
343
+		//lastly get the xip
344
+		$zip_value = $this->zip();
345
+		if (! empty($zip_value)) {
346
+			$full_address_array[] = $zip_value;
347
+		}
348
+		return $full_address_array;
349
+	}
350
+
351
+
352
+	/**
353
+	 *        get Attendee Address
354
+	 *
355
+	 * @return string
356
+	 * @throws EE_Error
357
+	 */
358
+	public function address()
359
+	{
360
+		return $this->get('ATT_address');
361
+	}
362
+
363
+
364
+	/**
365
+	 *        get Attendee Address2
366
+	 *
367
+	 * @return string
368
+	 * @throws EE_Error
369
+	 */
370
+	public function address2()
371
+	{
372
+		return $this->get('ATT_address2');
373
+	}
374
+
375
+
376
+	/**
377
+	 *        get Attendee City
378
+	 *
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 */
382
+	public function city()
383
+	{
384
+		return $this->get('ATT_city');
385
+	}
386
+
387
+
388
+	/**
389
+	 *        get Attendee State ID
390
+	 *
391
+	 * @return string
392
+	 * @throws EE_Error
393
+	 */
394
+	public function state_ID()
395
+	{
396
+		return $this->get('STA_ID');
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return string
402
+	 * @throws EE_Error
403
+	 */
404
+	public function state_abbrev()
405
+	{
406
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
407
+	}
408
+
409
+
410
+	/**
411
+	 * Gets the state set to this attendee
412
+	 *
413
+	 * @return EE_State
414
+	 * @throws EE_Error
415
+	 */
416
+	public function state_obj()
417
+	{
418
+		return $this->get_first_related('State');
419
+	}
420
+
421
+
422
+	/**
423
+	 * Returns the state's name, otherwise 'Unknown'
424
+	 *
425
+	 * @return string
426
+	 * @throws EE_Error
427
+	 */
428
+	public function state_name()
429
+	{
430
+		if ($this->state_obj()) {
431
+			return $this->state_obj()->name();
432
+		} else {
433
+			return '';
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 * either displays the state abbreviation or the state name, as determined
440
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
441
+	 * defaults to abbreviation
442
+	 *
443
+	 * @return string
444
+	 * @throws EE_Error
445
+	 */
446
+	public function state()
447
+	{
448
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
449
+			return $this->state_abbrev();
450
+		}
451
+		return $this->state_name();
452
+	}
453
+
454
+
455
+	/**
456
+	 *    get Attendee Country ISO Code
457
+	 *
458
+	 * @return string
459
+	 * @throws EE_Error
460
+	 */
461
+	public function country_ID()
462
+	{
463
+		return $this->get('CNT_ISO');
464
+	}
465
+
466
+
467
+	/**
468
+	 * Gets country set for this attendee
469
+	 *
470
+	 * @return EE_Country
471
+	 * @throws EE_Error
472
+	 */
473
+	public function country_obj()
474
+	{
475
+		return $this->get_first_related('Country');
476
+	}
477
+
478
+
479
+	/**
480
+	 * Returns the country's name if known, otherwise 'Unknown'
481
+	 *
482
+	 * @return string
483
+	 * @throws EE_Error
484
+	 */
485
+	public function country_name()
486
+	{
487
+		if ($this->country_obj()) {
488
+			return $this->country_obj()->name();
489
+		}
490
+		return '';
491
+	}
492
+
493
+
494
+	/**
495
+	 * either displays the country ISO2 code or the country name, as determined
496
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
497
+	 * defaults to abbreviation
498
+	 *
499
+	 * @return string
500
+	 * @throws EE_Error
501
+	 */
502
+	public function country()
503
+	{
504
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
505
+			return $this->country_ID();
506
+		}
507
+		return $this->country_name();
508
+	}
509
+
510
+
511
+	/**
512
+	 *        get Attendee Zip/Postal Code
513
+	 *
514
+	 * @return string
515
+	 * @throws EE_Error
516
+	 */
517
+	public function zip()
518
+	{
519
+		return $this->get('ATT_zip');
520
+	}
521
+
522
+
523
+	/**
524
+	 *        get Attendee Email Address
525
+	 *
526
+	 * @return string
527
+	 * @throws EE_Error
528
+	 */
529
+	public function email()
530
+	{
531
+		return $this->get('ATT_email');
532
+	}
533
+
534
+
535
+	/**
536
+	 *        get Attendee Phone #
537
+	 *
538
+	 * @return string
539
+	 * @throws EE_Error
540
+	 */
541
+	public function phone()
542
+	{
543
+		return $this->get('ATT_phone');
544
+	}
545
+
546
+
547
+	/**
548
+	 *    get deleted
549
+	 *
550
+	 * @return        bool
551
+	 * @throws EE_Error
552
+	 */
553
+	public function deleted()
554
+	{
555
+		return $this->get('ATT_deleted');
556
+	}
557
+
558
+
559
+	/**
560
+	 * Gets registrations of this attendee
561
+	 *
562
+	 * @param array $query_params
563
+	 * @return EE_Registration[]
564
+	 * @throws EE_Error
565
+	 */
566
+	public function get_registrations($query_params = array())
567
+	{
568
+		return $this->get_many_related('Registration', $query_params);
569
+	}
570
+
571
+
572
+	/**
573
+	 * Gets the most recent registration of this attendee
574
+	 *
575
+	 * @return EE_Registration
576
+	 * @throws EE_Error
577
+	 */
578
+	public function get_most_recent_registration()
579
+	{
580
+		return $this->get_first_related(
581
+			'Registration',
582
+			array('order_by' => array('REG_date' => 'DESC'))
583
+		); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
584
+	}
585
+
586
+
587
+	/**
588
+	 * Gets the most recent registration for this attend at this event
589
+	 *
590
+	 * @param int $event_id
591
+	 * @return EE_Registration
592
+	 * @throws EE_Error
593
+	 */
594
+	public function get_most_recent_registration_for_event($event_id)
595
+	{
596
+		return $this->get_first_related(
597
+			'Registration',
598
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
599
+		);
600
+	}
601
+
602
+
603
+	/**
604
+	 * returns any events attached to this attendee ($_Event property);
605
+	 *
606
+	 * @return array
607
+	 * @throws EE_Error
608
+	 */
609
+	public function events()
610
+	{
611
+		return $this->get_many_related('Event');
612
+	}
613
+
614
+
615
+	/**
616
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
617
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
618
+	 * used to save the billing info
619
+	 *
620
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
+	 * @return EE_Form_Section_Proper|null
622
+	 * @throws EE_Error
623
+	 */
624
+	public function billing_info_for_payment_method($payment_method)
625
+	{
626
+		$pm_type = $payment_method->type_obj();
627
+		if (! $pm_type instanceof EE_PMT_Base) {
628
+			return null;
629
+		}
630
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
+		if (! $billing_info) {
632
+			return null;
633
+		}
634
+		$billing_form = $pm_type->billing_form();
635
+		if ($billing_form instanceof EE_Form_Section_Proper) {
636
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
637
+		}
638
+		return $billing_form;
639
+	}
640
+
641
+
642
+	/**
643
+	 * Gets the postmeta key that holds this attendee's billing info for the
644
+	 * specified payment method
645
+	 *
646
+	 * @param EE_Payment_Method $payment_method
647
+	 * @return string
648
+	 * @throws EE_Error
649
+	 */
650
+	public function get_billing_info_postmeta_name($payment_method)
651
+	{
652
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
653
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
654
+		}
655
+		return null;
656
+	}
657
+
658
+
659
+	/**
660
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
661
+	 * retrieve it
662
+	 *
663
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
664
+	 * @param EE_Payment_Method             $payment_method
665
+	 * @return boolean
666
+	 * @throws EE_Error
667
+	 */
668
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
669
+	{
670
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
671
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
672
+			return false;
673
+		}
674
+		$billing_form->clean_sensitive_data();
675
+		return update_post_meta(
676
+			$this->ID(),
677
+			$this->get_billing_info_postmeta_name($payment_method),
678
+			$billing_form->input_values(true)
679
+		);
680
+	}
681
+
682
+
683
+	/**
684
+	 * Return the link to the admin details for the object.
685
+	 *
686
+	 * @return string
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 * @throws ReflectionException
692
+	 */
693
+	public function get_admin_details_link()
694
+	{
695
+		return $this->get_admin_edit_link();
696
+	}
697
+
698
+
699
+	/**
700
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
701
+	 *
702
+	 * @return string
703
+	 * @throws EE_Error
704
+	 * @throws InvalidArgumentException
705
+	 * @throws ReflectionException
706
+	 * @throws InvalidDataTypeException
707
+	 * @throws InvalidInterfaceException
708
+	 */
709
+	public function get_admin_edit_link()
710
+	{
711
+		EE_Registry::instance()->load_helper('URL');
712
+		return EEH_URL::add_query_args_and_nonce(
713
+			array(
714
+				'page'   => 'espresso_registrations',
715
+				'action' => 'edit_attendee',
716
+				'post'   => $this->ID(),
717
+			),
718
+			admin_url('admin.php')
719
+		);
720
+	}
721
+
722
+
723
+	/**
724
+	 * Returns the link to a settings page for the object.
725
+	 *
726
+	 * @return string
727
+	 * @throws EE_Error
728
+	 * @throws InvalidArgumentException
729
+	 * @throws InvalidDataTypeException
730
+	 * @throws InvalidInterfaceException
731
+	 * @throws ReflectionException
732
+	 */
733
+	public function get_admin_settings_link()
734
+	{
735
+		return $this->get_admin_edit_link();
736
+	}
737
+
738
+
739
+	/**
740
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
741
+	 *
742
+	 * @return string
743
+	 * @throws EE_Error
744
+	 * @throws InvalidArgumentException
745
+	 * @throws ReflectionException
746
+	 * @throws InvalidDataTypeException
747
+	 * @throws InvalidInterfaceException
748
+	 */
749
+	public function get_admin_overview_link()
750
+	{
751
+		EE_Registry::instance()->load_helper('URL');
752
+		return EEH_URL::add_query_args_and_nonce(
753
+			array(
754
+				'page'   => 'espresso_registrations',
755
+				'action' => 'contact_list',
756
+			),
757
+			admin_url('admin.php')
758
+		);
759
+	}
760 760
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
40 40
     {
41
-        if (! isset($fieldValues['ATT_full_name'])) {
42
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+        if ( ! isset($fieldValues['ATT_full_name'])) {
42
+            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
43 43
             $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
44
-            $fieldValues['ATT_full_name'] = $fname . $lname;
44
+            $fieldValues['ATT_full_name'] = $fname.$lname;
45 45
         }
46
-        if (! isset($fieldValues['ATT_slug'])) {
46
+        if ( ! isset($fieldValues['ATT_slug'])) {
47 47
             //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
48 48
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
49 49
         }
50
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
50
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
51 51
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
52 52
         }
53 53
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
328 328
         foreach ($initial_address_fields as $address_field_name) {
329 329
             $address_fields_value = $this->get($address_field_name);
330
-            if (! empty($address_fields_value)) {
330
+            if ( ! empty($address_fields_value)) {
331 331
                 $full_address_array[] = $address_fields_value;
332 332
             }
333 333
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
         }
343 343
         //lastly get the xip
344 344
         $zip_value = $this->zip();
345
-        if (! empty($zip_value)) {
345
+        if ( ! empty($zip_value)) {
346 346
             $full_address_array[] = $zip_value;
347 347
         }
348 348
         return $full_address_array;
@@ -624,11 +624,11 @@  discard block
 block discarded – undo
624 624
     public function billing_info_for_payment_method($payment_method)
625 625
     {
626 626
         $pm_type = $payment_method->type_obj();
627
-        if (! $pm_type instanceof EE_PMT_Base) {
627
+        if ( ! $pm_type instanceof EE_PMT_Base) {
628 628
             return null;
629 629
         }
630 630
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
631
-        if (! $billing_info) {
631
+        if ( ! $billing_info) {
632 632
             return null;
633 633
         }
634 634
         $billing_form = $pm_type->billing_form();
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
     public function get_billing_info_postmeta_name($payment_method)
651 651
     {
652 652
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
653
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
653
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
654 654
         }
655 655
         return null;
656 656
     }
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
      */
668 668
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
669 669
     {
670
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
670
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
671 671
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
672 672
             return false;
673 673
         }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * ATT_address column
304 304
      *
305 305
      * @param EE_Attendee $attendee
306
-     * @return mixed
306
+     * @return string
307 307
      * @throws EE_Error
308 308
      */
309 309
     public function column_ATT_address(EE_Attendee $attendee)
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * ATT_city column
317 317
      *
318 318
      * @param EE_Attendee $attendee
319
-     * @return mixed
319
+     * @return string
320 320
      * @throws EE_Error
321 321
      */
322 322
     public function column_ATT_city(EE_Attendee $attendee)
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * Phone Number column
370 370
      *
371 371
      * @param EE_Attendee $attendee
372
-     * @return mixed
372
+     * @return string
373 373
      * @throws EE_Error
374 374
      */
375 375
     public function column_ATT_phone(EE_Attendee $attendee)
Please login to merge, or discard this patch.
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -15,365 +15,365 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
17 17
 {
18
-    /**
19
-     * Initial setup of data (called by parent).
20
-     */
21
-    protected function _setup_data()
22
-    {
23
-        $this->_data = $this->_view !== 'trash'
24
-            ? $this->_admin_page->get_attendees($this->_per_page)
25
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
26
-        $this->_all_data_count = $this->_view !== 'trash'
27
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
28
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
29
-    }
30
-
31
-
32
-    /**
33
-     * Initial setup of properties.
34
-     */
35
-    protected function _set_properties()
36
-    {
37
-        $this->_wp_list_args = array(
38
-            'singular' => esc_html__('attendee', 'event_espresso'),
39
-            'plural'   => esc_html__('attendees', 'event_espresso'),
40
-            'ajax'     => true,
41
-            'screen'   => $this->_admin_page->get_current_screen()->id,
42
-        );
43
-
44
-        $this->_columns = array(
45
-            'cb'          => '<input type="checkbox" />', //Render a checkbox instead of text
46
-            'ATT_ID'      => esc_html__('ID', 'event_espresso'),
47
-            'ATT_fname'   => esc_html__('First Name', 'event_espresso'),
48
-            'ATT_lname'   => esc_html__('Last Name', 'event_espresso'),
49
-            'ATT_email'   => esc_html__('Email Address', 'event_espresso'),
50
-            'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
51
-            'ATT_phone'   => esc_html__('Phone', 'event_espresso'),
52
-            'ATT_address' => esc_html__('Address', 'event_espresso'),
53
-            'ATT_city'    => esc_html__('City', 'event_espresso'),
54
-            'STA_ID'      => esc_html__('State/Province', 'event_espresso'),
55
-            'CNT_ISO'     => esc_html__('Country', 'event_espresso'),
56
-        );
57
-
58
-        $this->_sortable_columns = array(
59
-            'ATT_ID'    => array('ATT_ID' => false),
60
-            'ATT_lname' => array('ATT_lname' => true), //true means its already sorted
61
-            'ATT_fname' => array('ATT_fname' => false),
62
-            'ATT_email' => array('ATT_email' => false),
63
-            'Registration_Count' => array('Registration_Count' => false),
64
-            'ATT_city'  => array('ATT_city' => false),
65
-            'STA_ID'    => array('STA_ID' => false),
66
-            'CNT_ISO'   => array('CNT_ISO' => false),
67
-        );
68
-
69
-        $this->_hidden_columns = array(
70
-            'ATT_phone',
71
-            'ATT_address',
72
-            'ATT_city',
73
-            'STA_ID',
74
-            'CNT_ISO'
75
-        );
76
-    }
77
-
78
-
79
-    /**
80
-     * Initial setup of filters
81
-     * @return array
82
-     */
83
-    protected function _get_table_filters()
84
-    {
85
-        return array();
86
-    }
87
-
88
-
89
-    /**
90
-     * Initial setup of counts for views
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidDataTypeException
93
-     * @throws InvalidInterfaceException
94
-     */
95
-    protected function _add_view_counts()
96
-    {
97
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
98
-        if (EE_Registry::instance()->CAP->current_user_can(
99
-            'ee_delete_contacts',
100
-            'espresso_registrations_delete_registration'
101
-        )) {
102
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     * Get count of attendees.
109
-     * @return int
110
-     * @throws EE_Error
111
-     * @throws InvalidArgumentException
112
-     * @throws InvalidDataTypeException
113
-     * @throws InvalidInterfaceException
114
-     */
115
-    protected function _get_attendees_count()
116
-    {
117
-        return EEM_Attendee::instance()->count();
118
-    }
119
-
120
-
121
-    /**
122
-     * Checkbox column
123
-     *
124
-     * @param EE_Attendee $attendee  Unable to typehint this method because overrides parent.
125
-     * @return string
126
-     * @throws EE_Error
127
-     */
128
-    public function column_cb($attendee)
129
-    {
130
-        if (! $attendee instanceof EE_Attendee) {
131
-            return '';
132
-        }
133
-        return sprintf(
134
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
-            $attendee->ID()
136
-        );
137
-    }
138
-
139
-
140
-    /**
141
-     * ATT_ID column
142
-     *
143
-     * @param EE_Attendee $attendee
144
-     * @return string
145
-     * @throws EE_Error
146
-     */
147
-    public function column_ATT_ID(EE_Attendee $attendee)
148
-    {
149
-        $content = $attendee->ID();
150
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
-        return $content;
153
-    }
154
-
155
-
156
-    /**
157
-     * ATT_lname column
158
-     *
159
-     * @param EE_Attendee $attendee
160
-     * @return string
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     * @throws EE_Error
165
-     */
166
-    public function column_ATT_lname(EE_Attendee $attendee)
167
-    {
168
-        // edit attendee link
169
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
-            array(
171
-                'action' => 'edit_attendee',
172
-                'post'   => $attendee->ID(),
173
-            ),
174
-            REG_ADMIN_URL
175
-        );
176
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
177
-            'ee_edit_contacts',
178
-            'espresso_registrations_edit_attendee'
179
-        )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
183
-            : $attendee->lname();
184
-        return $name_link;
185
-    }
186
-
187
-
188
-    /**
189
-     * ATT_fname column
190
-     *
191
-     * @param EE_Attendee $attendee
192
-     * @return string
193
-     * @throws InvalidArgumentException
194
-     * @throws InvalidDataTypeException
195
-     * @throws InvalidInterfaceException
196
-     * @throws EE_Error
197
-     */
198
-    public function column_ATT_fname(EE_Attendee $attendee)
199
-    {
200
-        //Build row actions
201
-        $actions = array();
202
-        // edit attendee link
203
-        if (EE_Registry::instance()->CAP->current_user_can(
204
-            'ee_edit_contacts',
205
-            'espresso_registrations_edit_attendee'
206
-        )) {
207
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
-                array(
209
-                    'action' => 'edit_attendee',
210
-                    'post'   => $attendee->ID(),
211
-                ),
212
-                REG_ADMIN_URL
213
-            );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
217
-        }
218
-
219
-        if ($this->_view === 'in_use') {
220
-            // trash attendee link
221
-            if (EE_Registry::instance()->CAP->current_user_can(
222
-                'ee_delete_contacts',
223
-                'espresso_registrations_trash_attendees'
224
-            )) {
225
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
-                    array(
227
-                        'action' => 'trash_attendee',
228
-                        'ATT_ID' => $attendee->ID(),
229
-                    ),
230
-                    REG_ADMIN_URL
231
-                );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
-            }
236
-        } else {
237
-            if (EE_Registry::instance()->CAP->current_user_can(
238
-                'ee_delete_contacts',
239
-                'espresso_registrations_restore_attendees'
240
-            )) {
241
-                // restore attendee link
242
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
243
-                    'action' => 'restore_attendees',
244
-                    'ATT_ID' => $attendee->ID(),
245
-                ), REG_ADMIN_URL);
246
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
247
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
248
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
249
-            }
250
-        }
251
-
252
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
253
-            'action' => 'edit_attendee',
254
-            'post'   => $attendee->ID(),
255
-        ), REG_ADMIN_URL);
256
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
257
-            'ee_edit_contacts',
258
-            'espresso_registrations_edit_attendee'
259
-        )
260
-            ? '<a href="' . $edit_lnk_url . '" title="'
261
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
262
-            : $attendee->fname();
263
-
264
-        //Return the name contents
265
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
266
-    }
267
-
268
-
269
-    /**
270
-     * Email Column
271
-     *
272
-     * @param EE_Attendee $attendee
273
-     * @return string
274
-     * @throws EE_Error
275
-     */
276
-    public function column_ATT_email(EE_Attendee $attendee)
277
-    {
278
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
279
-    }
280
-
281
-
282
-    /**
283
-     * Column displaying count of registrations attached to Attendee.
284
-     *
285
-     * @param EE_Attendee $attendee
286
-     * @return string
287
-     * @throws EE_Error
288
-     */
289
-    public function column_Registration_Count(EE_Attendee $attendee)
290
-    {
291
-        $link = EEH_URL::add_query_args_and_nonce(
292
-            array(
293
-                'action' => 'default',
294
-                'ATT_ID' => $attendee->ID()
295
-            ),
296
-            REG_ADMIN_URL
297
-        );
298
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
299
-    }
300
-
301
-
302
-    /**
303
-     * ATT_address column
304
-     *
305
-     * @param EE_Attendee $attendee
306
-     * @return mixed
307
-     * @throws EE_Error
308
-     */
309
-    public function column_ATT_address(EE_Attendee $attendee)
310
-    {
311
-        return $attendee->address();
312
-    }
313
-
314
-
315
-    /**
316
-     * ATT_city column
317
-     *
318
-     * @param EE_Attendee $attendee
319
-     * @return mixed
320
-     * @throws EE_Error
321
-     */
322
-    public function column_ATT_city(EE_Attendee $attendee)
323
-    {
324
-        return $attendee->city();
325
-    }
326
-
327
-
328
-    /**
329
-     * State Column
330
-     *
331
-     * @param EE_Attendee $attendee
332
-     * @return string
333
-     * @throws EE_Error
334
-     * @throws InvalidArgumentException
335
-     * @throws InvalidDataTypeException
336
-     * @throws InvalidInterfaceException
337
-     */
338
-    public function column_STA_ID(EE_Attendee $attendee)
339
-    {
340
-        $states = EEM_State::instance()->get_all_states();
341
-        $state = isset($states[$attendee->state_ID()])
342
-            ? $states[$attendee->state_ID()]->get('STA_name')
343
-            : $attendee->state_ID();
344
-        return ! is_numeric($state) ? $state : '';
345
-    }
346
-
347
-
348
-    /**
349
-     * Country Column
350
-     *
351
-     * @param EE_Attendee $attendee
352
-     * @return string
353
-     * @throws EE_Error
354
-     * @throws InvalidArgumentException
355
-     * @throws InvalidDataTypeException
356
-     * @throws InvalidInterfaceException
357
-     */
358
-    public function column_CNT_ISO(EE_Attendee $attendee)
359
-    {
360
-        $countries = EEM_Country::instance()->get_all_countries();
361
-        $country = isset($countries[$attendee->country_ID()])
362
-            ? $countries[$attendee->country_ID()]->get('CNT_name')
363
-            : $attendee->country_ID();
364
-        return ! is_numeric($country) ? $country : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * Phone Number column
370
-     *
371
-     * @param EE_Attendee $attendee
372
-     * @return mixed
373
-     * @throws EE_Error
374
-     */
375
-    public function column_ATT_phone(EE_Attendee $attendee)
376
-    {
377
-        return $attendee->phone();
378
-    }
18
+	/**
19
+	 * Initial setup of data (called by parent).
20
+	 */
21
+	protected function _setup_data()
22
+	{
23
+		$this->_data = $this->_view !== 'trash'
24
+			? $this->_admin_page->get_attendees($this->_per_page)
25
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
26
+		$this->_all_data_count = $this->_view !== 'trash'
27
+			? $this->_admin_page->get_attendees($this->_per_page, true)
28
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
29
+	}
30
+
31
+
32
+	/**
33
+	 * Initial setup of properties.
34
+	 */
35
+	protected function _set_properties()
36
+	{
37
+		$this->_wp_list_args = array(
38
+			'singular' => esc_html__('attendee', 'event_espresso'),
39
+			'plural'   => esc_html__('attendees', 'event_espresso'),
40
+			'ajax'     => true,
41
+			'screen'   => $this->_admin_page->get_current_screen()->id,
42
+		);
43
+
44
+		$this->_columns = array(
45
+			'cb'          => '<input type="checkbox" />', //Render a checkbox instead of text
46
+			'ATT_ID'      => esc_html__('ID', 'event_espresso'),
47
+			'ATT_fname'   => esc_html__('First Name', 'event_espresso'),
48
+			'ATT_lname'   => esc_html__('Last Name', 'event_espresso'),
49
+			'ATT_email'   => esc_html__('Email Address', 'event_espresso'),
50
+			'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
51
+			'ATT_phone'   => esc_html__('Phone', 'event_espresso'),
52
+			'ATT_address' => esc_html__('Address', 'event_espresso'),
53
+			'ATT_city'    => esc_html__('City', 'event_espresso'),
54
+			'STA_ID'      => esc_html__('State/Province', 'event_espresso'),
55
+			'CNT_ISO'     => esc_html__('Country', 'event_espresso'),
56
+		);
57
+
58
+		$this->_sortable_columns = array(
59
+			'ATT_ID'    => array('ATT_ID' => false),
60
+			'ATT_lname' => array('ATT_lname' => true), //true means its already sorted
61
+			'ATT_fname' => array('ATT_fname' => false),
62
+			'ATT_email' => array('ATT_email' => false),
63
+			'Registration_Count' => array('Registration_Count' => false),
64
+			'ATT_city'  => array('ATT_city' => false),
65
+			'STA_ID'    => array('STA_ID' => false),
66
+			'CNT_ISO'   => array('CNT_ISO' => false),
67
+		);
68
+
69
+		$this->_hidden_columns = array(
70
+			'ATT_phone',
71
+			'ATT_address',
72
+			'ATT_city',
73
+			'STA_ID',
74
+			'CNT_ISO'
75
+		);
76
+	}
77
+
78
+
79
+	/**
80
+	 * Initial setup of filters
81
+	 * @return array
82
+	 */
83
+	protected function _get_table_filters()
84
+	{
85
+		return array();
86
+	}
87
+
88
+
89
+	/**
90
+	 * Initial setup of counts for views
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidDataTypeException
93
+	 * @throws InvalidInterfaceException
94
+	 */
95
+	protected function _add_view_counts()
96
+	{
97
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
98
+		if (EE_Registry::instance()->CAP->current_user_can(
99
+			'ee_delete_contacts',
100
+			'espresso_registrations_delete_registration'
101
+		)) {
102
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 * Get count of attendees.
109
+	 * @return int
110
+	 * @throws EE_Error
111
+	 * @throws InvalidArgumentException
112
+	 * @throws InvalidDataTypeException
113
+	 * @throws InvalidInterfaceException
114
+	 */
115
+	protected function _get_attendees_count()
116
+	{
117
+		return EEM_Attendee::instance()->count();
118
+	}
119
+
120
+
121
+	/**
122
+	 * Checkbox column
123
+	 *
124
+	 * @param EE_Attendee $attendee  Unable to typehint this method because overrides parent.
125
+	 * @return string
126
+	 * @throws EE_Error
127
+	 */
128
+	public function column_cb($attendee)
129
+	{
130
+		if (! $attendee instanceof EE_Attendee) {
131
+			return '';
132
+		}
133
+		return sprintf(
134
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
+			$attendee->ID()
136
+		);
137
+	}
138
+
139
+
140
+	/**
141
+	 * ATT_ID column
142
+	 *
143
+	 * @param EE_Attendee $attendee
144
+	 * @return string
145
+	 * @throws EE_Error
146
+	 */
147
+	public function column_ATT_ID(EE_Attendee $attendee)
148
+	{
149
+		$content = $attendee->ID();
150
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
+		return $content;
153
+	}
154
+
155
+
156
+	/**
157
+	 * ATT_lname column
158
+	 *
159
+	 * @param EE_Attendee $attendee
160
+	 * @return string
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 * @throws EE_Error
165
+	 */
166
+	public function column_ATT_lname(EE_Attendee $attendee)
167
+	{
168
+		// edit attendee link
169
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
+			array(
171
+				'action' => 'edit_attendee',
172
+				'post'   => $attendee->ID(),
173
+			),
174
+			REG_ADMIN_URL
175
+		);
176
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
177
+			'ee_edit_contacts',
178
+			'espresso_registrations_edit_attendee'
179
+		)
180
+			? '<a href="' . $edit_lnk_url . '" title="'
181
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
+			  . $attendee->lname() . '</a>'
183
+			: $attendee->lname();
184
+		return $name_link;
185
+	}
186
+
187
+
188
+	/**
189
+	 * ATT_fname column
190
+	 *
191
+	 * @param EE_Attendee $attendee
192
+	 * @return string
193
+	 * @throws InvalidArgumentException
194
+	 * @throws InvalidDataTypeException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws EE_Error
197
+	 */
198
+	public function column_ATT_fname(EE_Attendee $attendee)
199
+	{
200
+		//Build row actions
201
+		$actions = array();
202
+		// edit attendee link
203
+		if (EE_Registry::instance()->CAP->current_user_can(
204
+			'ee_edit_contacts',
205
+			'espresso_registrations_edit_attendee'
206
+		)) {
207
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
+				array(
209
+					'action' => 'edit_attendee',
210
+					'post'   => $attendee->ID(),
211
+				),
212
+				REG_ADMIN_URL
213
+			);
214
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
217
+		}
218
+
219
+		if ($this->_view === 'in_use') {
220
+			// trash attendee link
221
+			if (EE_Registry::instance()->CAP->current_user_can(
222
+				'ee_delete_contacts',
223
+				'espresso_registrations_trash_attendees'
224
+			)) {
225
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
+					array(
227
+						'action' => 'trash_attendee',
228
+						'ATT_ID' => $attendee->ID(),
229
+					),
230
+					REG_ADMIN_URL
231
+				);
232
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
234
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
+			}
236
+		} else {
237
+			if (EE_Registry::instance()->CAP->current_user_can(
238
+				'ee_delete_contacts',
239
+				'espresso_registrations_restore_attendees'
240
+			)) {
241
+				// restore attendee link
242
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
243
+					'action' => 'restore_attendees',
244
+					'ATT_ID' => $attendee->ID(),
245
+				), REG_ADMIN_URL);
246
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
247
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
248
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
249
+			}
250
+		}
251
+
252
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
253
+			'action' => 'edit_attendee',
254
+			'post'   => $attendee->ID(),
255
+		), REG_ADMIN_URL);
256
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
257
+			'ee_edit_contacts',
258
+			'espresso_registrations_edit_attendee'
259
+		)
260
+			? '<a href="' . $edit_lnk_url . '" title="'
261
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
262
+			: $attendee->fname();
263
+
264
+		//Return the name contents
265
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
266
+	}
267
+
268
+
269
+	/**
270
+	 * Email Column
271
+	 *
272
+	 * @param EE_Attendee $attendee
273
+	 * @return string
274
+	 * @throws EE_Error
275
+	 */
276
+	public function column_ATT_email(EE_Attendee $attendee)
277
+	{
278
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
279
+	}
280
+
281
+
282
+	/**
283
+	 * Column displaying count of registrations attached to Attendee.
284
+	 *
285
+	 * @param EE_Attendee $attendee
286
+	 * @return string
287
+	 * @throws EE_Error
288
+	 */
289
+	public function column_Registration_Count(EE_Attendee $attendee)
290
+	{
291
+		$link = EEH_URL::add_query_args_and_nonce(
292
+			array(
293
+				'action' => 'default',
294
+				'ATT_ID' => $attendee->ID()
295
+			),
296
+			REG_ADMIN_URL
297
+		);
298
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
299
+	}
300
+
301
+
302
+	/**
303
+	 * ATT_address column
304
+	 *
305
+	 * @param EE_Attendee $attendee
306
+	 * @return mixed
307
+	 * @throws EE_Error
308
+	 */
309
+	public function column_ATT_address(EE_Attendee $attendee)
310
+	{
311
+		return $attendee->address();
312
+	}
313
+
314
+
315
+	/**
316
+	 * ATT_city column
317
+	 *
318
+	 * @param EE_Attendee $attendee
319
+	 * @return mixed
320
+	 * @throws EE_Error
321
+	 */
322
+	public function column_ATT_city(EE_Attendee $attendee)
323
+	{
324
+		return $attendee->city();
325
+	}
326
+
327
+
328
+	/**
329
+	 * State Column
330
+	 *
331
+	 * @param EE_Attendee $attendee
332
+	 * @return string
333
+	 * @throws EE_Error
334
+	 * @throws InvalidArgumentException
335
+	 * @throws InvalidDataTypeException
336
+	 * @throws InvalidInterfaceException
337
+	 */
338
+	public function column_STA_ID(EE_Attendee $attendee)
339
+	{
340
+		$states = EEM_State::instance()->get_all_states();
341
+		$state = isset($states[$attendee->state_ID()])
342
+			? $states[$attendee->state_ID()]->get('STA_name')
343
+			: $attendee->state_ID();
344
+		return ! is_numeric($state) ? $state : '';
345
+	}
346
+
347
+
348
+	/**
349
+	 * Country Column
350
+	 *
351
+	 * @param EE_Attendee $attendee
352
+	 * @return string
353
+	 * @throws EE_Error
354
+	 * @throws InvalidArgumentException
355
+	 * @throws InvalidDataTypeException
356
+	 * @throws InvalidInterfaceException
357
+	 */
358
+	public function column_CNT_ISO(EE_Attendee $attendee)
359
+	{
360
+		$countries = EEM_Country::instance()->get_all_countries();
361
+		$country = isset($countries[$attendee->country_ID()])
362
+			? $countries[$attendee->country_ID()]->get('CNT_name')
363
+			: $attendee->country_ID();
364
+		return ! is_numeric($country) ? $country : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * Phone Number column
370
+	 *
371
+	 * @param EE_Attendee $attendee
372
+	 * @return mixed
373
+	 * @throws EE_Error
374
+	 */
375
+	public function column_ATT_phone(EE_Attendee $attendee)
376
+	{
377
+		return $attendee->phone();
378
+	}
379 379
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function column_cb($attendee)
129 129
     {
130
-        if (! $attendee instanceof EE_Attendee) {
130
+        if ( ! $attendee instanceof EE_Attendee) {
131 131
             return '';
132 132
         }
133 133
         return sprintf(
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $content = $attendee->ID();
150 150
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
151
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
152 152
         return $content;
153 153
     }
154 154
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
             'ee_edit_contacts',
178 178
             'espresso_registrations_edit_attendee'
179 179
         )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
180
+            ? '<a href="'.$edit_lnk_url.'" title="'
181
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
182
+              . $attendee->lname().'</a>'
183 183
             : $attendee->lname();
184 184
         return $name_link;
185 185
     }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
                 ),
212 212
                 REG_ADMIN_URL
213 213
             );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
214
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
215
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
216
+                               . esc_html__('Edit', 'event_espresso').'</a>';
217 217
         }
218 218
 
219 219
         if ($this->_view === 'in_use') {
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                     ),
230 230
                     REG_ADMIN_URL
231 231
                 );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
232
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
233 233
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
234
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
235 235
             }
236 236
         } else {
237 237
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
                     'action' => 'restore_attendees',
244 244
                     'ATT_ID' => $attendee->ID(),
245 245
                 ), REG_ADMIN_URL);
246
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
247
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
248
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
246
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
247
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
248
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
249 249
             }
250 250
         }
251 251
 
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
             'ee_edit_contacts',
258 258
             'espresso_registrations_edit_attendee'
259 259
         )
260
-            ? '<a href="' . $edit_lnk_url . '" title="'
261
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
260
+            ? '<a href="'.$edit_lnk_url.'" title="'
261
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
262 262
             : $attendee->fname();
263 263
 
264 264
         //Return the name contents
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function column_ATT_email(EE_Attendee $attendee)
277 277
     {
278
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
278
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
279 279
     }
280 280
 
281 281
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             ),
296 296
             REG_ADMIN_URL
297 297
         );
298
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
298
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
299 299
     }
300 300
 
301 301
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3722 added lines, -3722 removed lines patch added patch discarded remove patch
@@ -30,2339 +30,2339 @@  discard block
 block discarded – undo
30 30
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
31 31
 {
32 32
 
33
-    /**
34
-     * @var EE_Registration
35
-     */
36
-    private $_registration;
37
-
38
-    /**
39
-     * @var EE_Event
40
-     */
41
-    private $_reg_event;
42
-
43
-    /**
44
-     * @var EE_Session
45
-     */
46
-    private $_session;
47
-
48
-    private static $_reg_status;
49
-
50
-    /**
51
-     * Form for displaying the custom questions for this registration.
52
-     * This gets used a few times throughout the request so its best to cache it
53
-     *
54
-     * @var EE_Registration_Custom_Questions_Form
55
-     */
56
-    protected $_reg_custom_questions_form = null;
57
-
58
-
59
-    /**
60
-     *        constructor
61
-     *
62
-     * @Constructor
63
-     * @access public
64
-     * @param bool $routing
65
-     * @return Registrations_Admin_Page
66
-     */
67
-    public function __construct($routing = true)
68
-    {
69
-        parent::__construct($routing);
70
-        add_action('wp_loaded', array($this, 'wp_loaded'));
71
-    }
72
-
73
-
74
-    public function wp_loaded()
75
-    {
76
-        // when adding a new registration...
77
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
78
-            EE_System::do_not_cache();
79
-            if (! isset($this->_req_data['processing_registration'])
80
-                 || absint($this->_req_data['processing_registration']) !== 1
81
-            ) {
82
-                // and it's NOT the attendee information reg step
83
-                // force cookie expiration by setting time to last week
84
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
85
-                // and update the global
86
-                $_COOKIE['ee_registration_added'] = 0;
87
-            }
88
-        }
89
-    }
90
-
91
-
92
-    protected function _init_page_props()
93
-    {
94
-        $this->page_slug        = REG_PG_SLUG;
95
-        $this->_admin_base_url  = REG_ADMIN_URL;
96
-        $this->_admin_base_path = REG_ADMIN;
97
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
98
-        $this->_cpt_routes      = array(
99
-            'add_new_attendee' => 'espresso_attendees',
100
-            'edit_attendee'    => 'espresso_attendees',
101
-            'insert_attendee'  => 'espresso_attendees',
102
-            'update_attendee'  => 'espresso_attendees',
103
-        );
104
-        $this->_cpt_model_names = array(
105
-            'add_new_attendee' => 'EEM_Attendee',
106
-            'edit_attendee'    => 'EEM_Attendee',
107
-        );
108
-        $this->_cpt_edit_routes = array(
109
-            'espresso_attendees' => 'edit_attendee',
110
-        );
111
-        $this->_pagenow_map     = array(
112
-            'add_new_attendee' => 'post-new.php',
113
-            'edit_attendee'    => 'post.php',
114
-            'trash'            => 'post.php',
115
-        );
116
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
117
-        //add filters so that the comment urls don't take users to a confusing 404 page
118
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
119
-    }
120
-
121
-
122
-    public function clear_comment_link($link, $comment, $args)
123
-    {
124
-        //gotta make sure this only happens on this route
125
-        $post_type = get_post_type($comment->comment_post_ID);
126
-        if ($post_type === 'espresso_attendees') {
127
-            return '#commentsdiv';
128
-        }
129
-        return $link;
130
-    }
131
-
132
-
133
-    protected function _ajax_hooks()
134
-    {
135
-        //todo: all hooks for registrations ajax goes in here
136
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
137
-    }
138
-
139
-
140
-    protected function _define_page_props()
141
-    {
142
-        $this->_admin_page_title = $this->page_label;
143
-        $this->_labels           = array(
144
-            'buttons'                      => array(
145
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
146
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
147
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
148
-                'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
149
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
150
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
151
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
152
-                'contact_list_export' => esc_html__("Export Data", "event_espresso"),
153
-            ),
154
-            'publishbox'                   => array(
155
-                'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
156
-                'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
157
-            ),
158
-            'hide_add_button_on_cpt_route' => array(
159
-                'edit_attendee' => true,
160
-            ),
161
-        );
162
-    }
163
-
164
-
165
-    /**
166
-     *        grab url requests and route them
167
-     *
168
-     * @access private
169
-     * @return void
170
-     */
171
-    public function _set_page_routes()
172
-    {
173
-        $this->_get_registration_status_array();
174
-        $reg_id             = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
-            ? $this->_req_data['_REG_ID'] : 0;
176
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
177
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
178
-            : $reg_id;
179
-        $att_id             = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
180
-            ? $this->_req_data['ATT_ID'] : 0;
181
-        $att_id             = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
182
-            ? $this->_req_data['post']
183
-            : $att_id;
184
-        $this->_page_routes = array(
185
-            'default'                            => array(
186
-                'func'       => '_registrations_overview_list_table',
187
-                'capability' => 'ee_read_registrations',
188
-            ),
189
-            'view_registration'                  => array(
190
-                'func'       => '_registration_details',
191
-                'capability' => 'ee_read_registration',
192
-                'obj_id'     => $reg_id,
193
-            ),
194
-            'edit_registration'                  => array(
195
-                'func'               => '_update_attendee_registration_form',
196
-                'noheader'           => true,
197
-                'headers_sent_route' => 'view_registration',
198
-                'capability'         => 'ee_edit_registration',
199
-                'obj_id'             => $reg_id,
200
-                '_REG_ID'            => $reg_id,
201
-            ),
202
-            'trash_registrations'                => array(
203
-                'func'       => '_trash_or_restore_registrations',
204
-                'args'       => array('trash' => true),
205
-                'noheader'   => true,
206
-                'capability' => 'ee_delete_registrations',
207
-            ),
208
-            'restore_registrations'              => array(
209
-                'func'       => '_trash_or_restore_registrations',
210
-                'args'       => array('trash' => false),
211
-                'noheader'   => true,
212
-                'capability' => 'ee_delete_registrations',
213
-            ),
214
-            'delete_registrations'               => array(
215
-                'func'       => '_delete_registrations',
216
-                'noheader'   => true,
217
-                'capability' => 'ee_delete_registrations',
218
-            ),
219
-            'new_registration'                   => array(
220
-                'func'       => 'new_registration',
221
-                'capability' => 'ee_edit_registrations',
222
-            ),
223
-            'process_reg_step'                   => array(
224
-                'func'       => 'process_reg_step',
225
-                'noheader'   => true,
226
-                'capability' => 'ee_edit_registrations',
227
-            ),
228
-            'redirect_to_txn'                    => array(
229
-                'func'       => 'redirect_to_txn',
230
-                'noheader'   => true,
231
-                'capability' => 'ee_edit_registrations',
232
-            ),
233
-            'change_reg_status'                  => array(
234
-                'func'       => '_change_reg_status',
235
-                'noheader'   => true,
236
-                'capability' => 'ee_edit_registration',
237
-                'obj_id'     => $reg_id,
238
-            ),
239
-            'approve_registration'               => array(
240
-                'func'       => 'approve_registration',
241
-                'noheader'   => true,
242
-                'capability' => 'ee_edit_registration',
243
-                'obj_id'     => $reg_id,
244
-            ),
245
-            'approve_and_notify_registration'    => array(
246
-                'func'       => 'approve_registration',
247
-                'noheader'   => true,
248
-                'args'       => array(true),
249
-                'capability' => 'ee_edit_registration',
250
-                'obj_id'     => $reg_id,
251
-            ),
252
-            'approve_registrations'               => array(
253
-                'func'       => 'bulk_action_on_registrations',
254
-                'noheader'   => true,
255
-                'capability' => 'ee_edit_registrations',
256
-                'args' => array('approve')
257
-            ),
258
-            'approve_and_notify_registrations'               => array(
259
-                'func'       => 'bulk_action_on_registrations',
260
-                'noheader'   => true,
261
-                'capability' => 'ee_edit_registrations',
262
-                'args' => array('approve', true)
263
-            ),
264
-            'decline_registration'               => array(
265
-                'func'       => 'decline_registration',
266
-                'noheader'   => true,
267
-                'capability' => 'ee_edit_registration',
268
-                'obj_id'     => $reg_id,
269
-            ),
270
-            'decline_and_notify_registration'    => array(
271
-                'func'       => 'decline_registration',
272
-                'noheader'   => true,
273
-                'args'       => array(true),
274
-                'capability' => 'ee_edit_registration',
275
-                'obj_id'     => $reg_id,
276
-            ),
277
-            'decline_registrations'               => array(
278
-                'func'       => 'bulk_action_on_registrations',
279
-                'noheader'   => true,
280
-                'capability' => 'ee_edit_registrations',
281
-                'args' => array('decline')
282
-            ),
283
-            'decline_and_notify_registrations'    => array(
284
-                'func'       => 'bulk_action_on_registrations',
285
-                'noheader'   => true,
286
-                'capability' => 'ee_edit_registrations',
287
-                'args' => array('decline', true)
288
-            ),
289
-            'pending_registration'               => array(
290
-                'func'       => 'pending_registration',
291
-                'noheader'   => true,
292
-                'capability' => 'ee_edit_registration',
293
-                'obj_id'     => $reg_id,
294
-            ),
295
-            'pending_and_notify_registration'    => array(
296
-                'func'       => 'pending_registration',
297
-                'noheader'   => true,
298
-                'args'       => array(true),
299
-                'capability' => 'ee_edit_registration',
300
-                'obj_id'     => $reg_id,
301
-            ),
302
-            'pending_registrations'               => array(
303
-                'func'       => 'bulk_action_on_registrations',
304
-                'noheader'   => true,
305
-                'capability' => 'ee_edit_registrations',
306
-                'args' => array('pending')
307
-            ),
308
-            'pending_and_notify_registrations'    => array(
309
-                'func'       => 'bulk_action_on_registrations',
310
-                'noheader'   => true,
311
-                'capability' => 'ee_edit_registrations',
312
-                'args' => array('pending', true)
313
-            ),
314
-            'no_approve_registration'            => array(
315
-                'func'       => 'not_approve_registration',
316
-                'noheader'   => true,
317
-                'capability' => 'ee_edit_registration',
318
-                'obj_id'     => $reg_id,
319
-            ),
320
-            'no_approve_and_notify_registration' => array(
321
-                'func'       => 'not_approve_registration',
322
-                'noheader'   => true,
323
-                'args'       => array(true),
324
-                'capability' => 'ee_edit_registration',
325
-                'obj_id'     => $reg_id,
326
-            ),
327
-            'no_approve_registrations'            => array(
328
-                'func'       => 'bulk_action_on_registrations',
329
-                'noheader'   => true,
330
-                'capability' => 'ee_edit_registrations',
331
-                'args' => array('not_approve')
332
-            ),
333
-            'no_approve_and_notify_registrations' => array(
334
-                'func'       => 'bulk_action_on_registrations',
335
-                'noheader'   => true,
336
-                'capability' => 'ee_edit_registrations',
337
-                'args' => array('not_approve', true)
338
-            ),
339
-            'cancel_registration'                => array(
340
-                'func'       => 'cancel_registration',
341
-                'noheader'   => true,
342
-                'capability' => 'ee_edit_registration',
343
-                'obj_id'     => $reg_id,
344
-            ),
345
-            'cancel_and_notify_registration'     => array(
346
-                'func'       => 'cancel_registration',
347
-                'noheader'   => true,
348
-                'args'       => array(true),
349
-                'capability' => 'ee_edit_registration',
350
-                'obj_id'     => $reg_id,
351
-            ),
352
-            'cancel_registrations'                => array(
353
-                'func'       => 'bulk_action_on_registrations',
354
-                'noheader'   => true,
355
-                'capability' => 'ee_edit_registrations',
356
-                'args' => array('cancel')
357
-            ),
358
-            'cancel_and_notify_registrations'     => array(
359
-                'func'       => 'bulk_action_on_registrations',
360
-                'noheader'   => true,
361
-                'capability' => 'ee_edit_registrations',
362
-                'args' => array('cancel', true)
363
-            ),
364
-            'wait_list_registration' => array(
365
-                'func'       => 'wait_list_registration',
366
-                'noheader'   => true,
367
-                'capability' => 'ee_edit_registration',
368
-                'obj_id'     => $reg_id,
369
-            ),
370
-            'wait_list_and_notify_registration' => array(
371
-                'func'       => 'wait_list_registration',
372
-                'noheader'   => true,
373
-                'args'       => array(true),
374
-                'capability' => 'ee_edit_registration',
375
-                'obj_id'     => $reg_id,
376
-            ),
377
-            'contact_list'                       => array(
378
-                'func'       => '_attendee_contact_list_table',
379
-                'capability' => 'ee_read_contacts',
380
-            ),
381
-            'add_new_attendee'                   => array(
382
-                'func' => '_create_new_cpt_item',
383
-                'args' => array(
384
-                    'new_attendee' => true,
385
-                    'capability'   => 'ee_edit_contacts',
386
-                ),
387
-            ),
388
-            'edit_attendee'                      => array(
389
-                'func'       => '_edit_cpt_item',
390
-                'capability' => 'ee_edit_contacts',
391
-                'obj_id'     => $att_id,
392
-            ),
393
-            'duplicate_attendee'                 => array(
394
-                'func'       => '_duplicate_attendee',
395
-                'noheader'   => true,
396
-                'capability' => 'ee_edit_contacts',
397
-                'obj_id'     => $att_id,
398
-            ),
399
-            'insert_attendee'                    => array(
400
-                'func'       => '_insert_or_update_attendee',
401
-                'args'       => array(
402
-                    'new_attendee' => true,
403
-                ),
404
-                'noheader'   => true,
405
-                'capability' => 'ee_edit_contacts',
406
-            ),
407
-            'update_attendee'                    => array(
408
-                'func'       => '_insert_or_update_attendee',
409
-                'args'       => array(
410
-                    'new_attendee' => false,
411
-                ),
412
-                'noheader'   => true,
413
-                'capability' => 'ee_edit_contacts',
414
-                'obj_id'     => $att_id,
415
-            ),
416
-            'trash_attendees' => array(
417
-                'func' => '_trash_or_restore_attendees',
418
-                'args' => array(
419
-                    'trash' => 'true'
420
-                ),
421
-                'noheader' => true,
422
-                'capability' => 'ee_delete_contacts'
423
-            ),
424
-            'trash_attendee'                    => array(
425
-                'func'       => '_trash_or_restore_attendees',
426
-                'args'       => array(
427
-                    'trash' => true,
428
-                ),
429
-                'noheader'   => true,
430
-                'capability' => 'ee_delete_contacts',
431
-                'obj_id'     => $att_id,
432
-            ),
433
-            'restore_attendees'                  => array(
434
-                'func'       => '_trash_or_restore_attendees',
435
-                'args'       => array(
436
-                    'trash' => false,
437
-                ),
438
-                'noheader'   => true,
439
-                'capability' => 'ee_delete_contacts',
440
-                'obj_id'     => $att_id,
441
-            ),
442
-            'resend_registration'                => array(
443
-                'func'       => '_resend_registration',
444
-                'noheader'   => true,
445
-                'capability' => 'ee_send_message',
446
-            ),
447
-            'registrations_report'               => array(
448
-                'func'       => '_registrations_report',
449
-                'noheader'   => true,
450
-                'capability' => 'ee_read_registrations',
451
-            ),
452
-            'contact_list_export'                => array(
453
-                'func'       => '_contact_list_export',
454
-                'noheader'   => true,
455
-                'capability' => 'export',
456
-            ),
457
-            'contact_list_report'                => array(
458
-                'func'       => '_contact_list_report',
459
-                'noheader'   => true,
460
-                'capability' => 'ee_read_contacts',
461
-            ),
462
-        );
463
-    }
464
-
465
-
466
-    protected function _set_page_config()
467
-    {
468
-        $this->_page_config = array(
469
-            'default'           => array(
470
-                'nav'           => array(
471
-                    'label' => esc_html__('Overview', 'event_espresso'),
472
-                    'order' => 5,
473
-                ),
474
-                'help_tabs'     => array(
475
-                    'registrations_overview_help_tab'                       => array(
476
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
477
-                        'filename' => 'registrations_overview',
478
-                    ),
479
-                    'registrations_overview_table_column_headings_help_tab' => array(
480
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
481
-                        'filename' => 'registrations_overview_table_column_headings',
482
-                    ),
483
-                    'registrations_overview_filters_help_tab'               => array(
484
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
485
-                        'filename' => 'registrations_overview_filters',
486
-                    ),
487
-                    'registrations_overview_views_help_tab'                 => array(
488
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
489
-                        'filename' => 'registrations_overview_views',
490
-                    ),
491
-                    'registrations_regoverview_other_help_tab'              => array(
492
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
493
-                        'filename' => 'registrations_overview_other',
494
-                    ),
495
-                ),
496
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
497
-                'qtips'         => array('Registration_List_Table_Tips'),
498
-                'list_table'    => 'EE_Registrations_List_Table',
499
-                'require_nonce' => false,
500
-            ),
501
-            'view_registration' => array(
502
-                'nav'           => array(
503
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
504
-                    'order'      => 15,
505
-                    'url'        => isset($this->_req_data['_REG_ID'])
506
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
507
-                        : $this->_admin_base_url,
508
-                    'persistent' => false,
509
-                ),
510
-                'help_tabs'     => array(
511
-                    'registrations_details_help_tab'                    => array(
512
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
513
-                        'filename' => 'registrations_details',
514
-                    ),
515
-                    'registrations_details_table_help_tab'              => array(
516
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
517
-                        'filename' => 'registrations_details_table',
518
-                    ),
519
-                    'registrations_details_form_answers_help_tab'       => array(
520
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
521
-                        'filename' => 'registrations_details_form_answers',
522
-                    ),
523
-                    'registrations_details_registrant_details_help_tab' => array(
524
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
525
-                        'filename' => 'registrations_details_registrant_details',
526
-                    ),
527
-                ),
528
-                'help_tour'     => array('Registration_Details_Help_Tour'),
529
-                'metaboxes'     => array_merge(
530
-                    $this->_default_espresso_metaboxes,
531
-                    array('_registration_details_metaboxes')
532
-                ),
533
-                'require_nonce' => false,
534
-            ),
535
-            'new_registration'  => array(
536
-                'nav'           => array(
537
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
538
-                    'url'        => '#',
539
-                    'order'      => 15,
540
-                    'persistent' => false,
541
-                ),
542
-                'metaboxes'     => $this->_default_espresso_metaboxes,
543
-                'labels'        => array(
544
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
545
-                ),
546
-                'require_nonce' => false,
547
-            ),
548
-            'add_new_attendee'  => array(
549
-                'nav'           => array(
550
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
551
-                    'order'      => 15,
552
-                    'persistent' => false,
553
-                ),
554
-                'metaboxes'     => array_merge(
555
-                    $this->_default_espresso_metaboxes,
556
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
557
-                ),
558
-                'require_nonce' => false,
559
-            ),
560
-            'edit_attendee'     => array(
561
-                'nav'           => array(
562
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
563
-                    'order'      => 15,
564
-                    'persistent' => false,
565
-                    'url'        => isset($this->_req_data['ATT_ID'])
566
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
567
-                        : $this->_admin_base_url,
568
-                ),
569
-                'metaboxes'     => array('attendee_editor_metaboxes'),
570
-                'require_nonce' => false,
571
-            ),
572
-            'contact_list'      => array(
573
-                'nav'           => array(
574
-                    'label' => esc_html__('Contact List', 'event_espresso'),
575
-                    'order' => 20,
576
-                ),
577
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
578
-                'help_tabs'     => array(
579
-                    'registrations_contact_list_help_tab'                       => array(
580
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
581
-                        'filename' => 'registrations_contact_list',
582
-                    ),
583
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
584
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
585
-                        'filename' => 'registrations_contact_list_table_column_headings',
586
-                    ),
587
-                    'registrations_contact_list_views_help_tab'                 => array(
588
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
589
-                        'filename' => 'registrations_contact_list_views',
590
-                    ),
591
-                    'registrations_contact_list_other_help_tab'                 => array(
592
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
593
-                        'filename' => 'registrations_contact_list_other',
594
-                    ),
595
-                ),
596
-                'help_tour'     => array('Contact_List_Help_Tour'),
597
-                'metaboxes'     => array(),
598
-                'require_nonce' => false,
599
-            ),
600
-            //override default cpt routes
601
-            'create_new'        => '',
602
-            'edit'              => '',
603
-        );
604
-    }
605
-
606
-
607
-    /**
608
-     * The below methods aren't used by this class currently
609
-     */
610
-    protected function _add_screen_options()
611
-    {
612
-    }
613
-
614
-
615
-    protected function _add_feature_pointers()
616
-    {
617
-    }
618
-
619
-
620
-    public function admin_init()
621
-    {
622
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
623
-            'click "Update Registration Questions" to save your changes',
624
-            'event_espresso'
625
-        );
626
-    }
627
-
628
-
629
-    public function admin_notices()
630
-    {
631
-    }
632
-
633
-
634
-    public function admin_footer_scripts()
635
-    {
636
-    }
637
-
638
-
639
-    /**
640
-     *        get list of registration statuses
641
-     *
642
-     * @access private
643
-     * @return void
644
-     * @throws EE_Error
645
-     */
646
-    private function _get_registration_status_array()
647
-    {
648
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
649
-    }
650
-
651
-
652
-    protected function _add_screen_options_default()
653
-    {
654
-        $this->_per_page_screen_option();
655
-    }
656
-
657
-
658
-    protected function _add_screen_options_contact_list()
659
-    {
660
-        $page_title              = $this->_admin_page_title;
661
-        $this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
662
-        $this->_per_page_screen_option();
663
-        $this->_admin_page_title = $page_title;
664
-    }
665
-
666
-
667
-    public function load_scripts_styles()
668
-    {
669
-        //style
670
-        wp_register_style(
671
-            'espresso_reg',
672
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
673
-            array('ee-admin-css'),
674
-            EVENT_ESPRESSO_VERSION
675
-        );
676
-        wp_enqueue_style('espresso_reg');
677
-        //script
678
-        wp_register_script(
679
-            'espresso_reg',
680
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
681
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
682
-            EVENT_ESPRESSO_VERSION,
683
-            true
684
-        );
685
-        wp_enqueue_script('espresso_reg');
686
-    }
687
-
688
-
689
-    public function load_scripts_styles_edit_attendee()
690
-    {
691
-        //stuff to only show up on our attendee edit details page.
692
-        $attendee_details_translations = array(
693
-            'att_publish_text' => sprintf(
694
-                esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
695
-                $this->_cpt_model_obj->get_datetime('ATT_created')
696
-            ),
697
-        );
698
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
699
-        wp_enqueue_script('jquery-validate');
700
-    }
701
-
702
-
703
-    public function load_scripts_styles_view_registration()
704
-    {
705
-        //styles
706
-        wp_enqueue_style('espresso-ui-theme');
707
-        //scripts
708
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
709
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
710
-    }
711
-
712
-
713
-    public function load_scripts_styles_contact_list()
714
-    {
715
-        wp_deregister_style('espresso_reg');
716
-        wp_register_style(
717
-            'espresso_att',
718
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
719
-            array('ee-admin-css'),
720
-            EVENT_ESPRESSO_VERSION
721
-        );
722
-        wp_enqueue_style('espresso_att');
723
-    }
724
-
725
-
726
-    public function load_scripts_styles_new_registration()
727
-    {
728
-        wp_register_script(
729
-            'ee-spco-for-admin',
730
-            REG_ASSETS_URL . 'spco_for_admin.js',
731
-            array('underscore', 'jquery'),
732
-            EVENT_ESPRESSO_VERSION,
733
-            true
734
-        );
735
-        wp_enqueue_script('ee-spco-for-admin');
736
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
737
-        EE_Form_Section_Proper::wp_enqueue_scripts();
738
-        EED_Ticket_Selector::load_tckt_slctr_assets();
739
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
740
-    }
741
-
742
-
743
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
744
-    {
745
-        add_filter('FHEE_load_EE_messages', '__return_true');
746
-    }
747
-
748
-
749
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
750
-    {
751
-        add_filter('FHEE_load_EE_messages', '__return_true');
752
-    }
753
-
754
-
755
-    protected function _set_list_table_views_default()
756
-    {
757
-        //for notification related bulk actions we need to make sure only active messengers have an option.
758
-        EED_Messages::set_autoloaders();
759
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
760
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
761
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
762
-        //key= bulk_action_slug, value= message type.
763
-        $match_array = array(
764
-            'approve_registrations'    => 'registration',
765
-            'decline_registrations'    => 'declined_registration',
766
-            'pending_registrations'    => 'pending_approval',
767
-            'no_approve_registrations' => 'not_approved_registration',
768
-            'cancel_registrations'     => 'cancelled_registration',
769
-        );
770
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
771
-            'ee_send_message',
772
-            'batch_send_messages'
773
-        );
774
-        /** setup reg status bulk actions **/
775
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
776
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
777
-                $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
778
-                    'Approve and Notify Registrations',
779
-                    'event_espresso'
780
-                );
781
-        }
782
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
783
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
784
-                $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
785
-                    'Decline and Notify Registrations',
786
-                    'event_espresso'
787
-                );
788
-        }
789
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
790
-            'Set Registrations to Pending Payment',
791
-            'event_espresso'
792
-        );
793
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
794
-                $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
795
-                    'Set Registrations to Pending Payment and Notify',
796
-                    'event_espresso'
797
-                );
798
-        }
799
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
800
-            'Set Registrations to Not Approved',
801
-            'event_espresso'
802
-        );
803
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
804
-                $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
805
-                    'Set Registrations to Not Approved and Notify',
806
-                    'event_espresso'
807
-                );
808
-        }
809
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
810
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
811
-                $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
812
-                    'Cancel Registrations and Notify',
813
-                    'event_espresso'
814
-                );
815
-        }
816
-        $def_reg_status_actions = apply_filters(
817
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
818
-            $def_reg_status_actions,
819
-            $active_mts,
820
-            $can_send
821
-        );
822
-
823
-        $this->_views = array(
824
-            'all'   => array(
825
-                'slug'        => 'all',
826
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
827
-                'count'       => 0,
828
-                'bulk_action' => array_merge($def_reg_status_actions, array(
829
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
830
-                )),
831
-            ),
832
-            'month' => array(
833
-                'slug'        => 'month',
834
-                'label'       => esc_html__('This Month', 'event_espresso'),
835
-                'count'       => 0,
836
-                'bulk_action' => array_merge($def_reg_status_actions, array(
837
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
838
-                )),
839
-            ),
840
-            'today' => array(
841
-                'slug'        => 'today',
842
-                'label'       => sprintf(
843
-                    esc_html__('Today - %s', 'event_espresso'),
844
-                    date('M d, Y', current_time('timestamp'))
845
-                ),
846
-                'count'       => 0,
847
-                'bulk_action' => array_merge($def_reg_status_actions, array(
848
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
849
-                )),
850
-            ),
851
-        );
852
-        if (EE_Registry::instance()->CAP->current_user_can(
853
-            'ee_delete_registrations',
854
-            'espresso_registrations_delete_registration'
855
-        )) {
856
-            $this->_views['incomplete'] = array(
857
-                'slug'        => 'incomplete',
858
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
859
-                'count'       => 0,
860
-                'bulk_action' => array(
861
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
862
-                ),
863
-            );
864
-            $this->_views['trash']      = array(
865
-                'slug'        => 'trash',
866
-                'label'       => esc_html__('Trash', 'event_espresso'),
867
-                'count'       => 0,
868
-                'bulk_action' => array(
869
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
870
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
871
-                ),
872
-            );
873
-        }
874
-    }
875
-
876
-
877
-    protected function _set_list_table_views_contact_list()
878
-    {
879
-        $this->_views = array(
880
-            'in_use' => array(
881
-                'slug'        => 'in_use',
882
-                'label'       => esc_html__('In Use', 'event_espresso'),
883
-                'count'       => 0,
884
-                'bulk_action' => array(
885
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
886
-                ),
887
-            ),
888
-        );
889
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
890
-            'espresso_registrations_trash_attendees')
891
-        ) {
892
-            $this->_views['trash'] = array(
893
-                'slug'        => 'trash',
894
-                'label'       => esc_html__('Trash', 'event_espresso'),
895
-                'count'       => 0,
896
-                'bulk_action' => array(
897
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
-                ),
899
-            );
900
-        }
901
-    }
902
-
903
-
904
-    protected function _registration_legend_items()
905
-    {
906
-        $fc_items = array(
907
-            'star-icon'        => array(
908
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
-            ),
911
-            'view_details'     => array(
912
-                'class' => 'dashicons dashicons-clipboard',
913
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
-            ),
915
-            'edit_attendee'    => array(
916
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
-            ),
919
-            'view_transaction' => array(
920
-                'class' => 'dashicons dashicons-cart',
921
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
-            ),
923
-            'view_invoice'     => array(
924
-                'class' => 'dashicons dashicons-media-spreadsheet',
925
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
-            ),
927
-        );
928
-        if (EE_Registry::instance()->CAP->current_user_can(
929
-            'ee_send_message',
930
-            'espresso_registrations_resend_registration'
931
-        )) {
932
-            $fc_items['resend_registration'] = array(
933
-                'class' => 'dashicons dashicons-email-alt',
934
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
-            );
936
-        } else {
937
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
-        }
939
-        if (EE_Registry::instance()->CAP->current_user_can(
940
-            'ee_read_global_messages',
941
-            'view_filtered_messages'
942
-        )) {
943
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
-                $fc_items['view_related_messages'] = array(
946
-                    'class' => $related_for_icon['css_class'],
947
-                    'desc'  => $related_for_icon['label'],
948
-                );
949
-            }
950
-        }
951
-        $sc_items = array(
952
-            'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
-                'desc'  => EEH_Template::pretty_status(
955
-                    EEM_Registration::status_id_approved,
956
-                    false,
957
-                    'sentence'
958
-                ),
959
-            ),
960
-            'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
-                'desc'  => EEH_Template::pretty_status(
963
-                    EEM_Registration::status_id_pending_payment,
964
-                    false,
965
-                    'sentence'
966
-                ),
967
-            ),
968
-            'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
-                'desc'  => EEH_Template::pretty_status(
971
-                    EEM_Registration::status_id_wait_list,
972
-                    false,
973
-                    'sentence'
974
-                ),
975
-            ),
976
-            'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
-                'desc'  => EEH_Template::pretty_status(
979
-                    EEM_Registration::status_id_incomplete,
980
-                    false,
981
-                    'sentence'
982
-                ),
983
-            ),
984
-            'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
-                'desc'  => EEH_Template::pretty_status(
987
-                    EEM_Registration::status_id_not_approved,
988
-                    false,
989
-                    'sentence'
990
-                ),
991
-            ),
992
-            'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
-                'desc'  => EEH_Template::pretty_status(
995
-                    EEM_Registration::status_id_declined,
996
-                    false,
997
-                    'sentence'
998
-                ),
999
-            ),
1000
-            'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
-                'desc'  => EEH_Template::pretty_status(
1003
-                    EEM_Registration::status_id_cancelled,
1004
-                    false,
1005
-                    'sentence'
1006
-                ),
1007
-            ),
1008
-        );
1009
-        return array_merge($fc_items, $sc_items);
1010
-    }
1011
-
1012
-
1013
-
1014
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1015
-    /**
1016
-     * @throws \EE_Error
1017
-     */
1018
-    protected function _registrations_overview_list_table()
1019
-    {
1020
-        $this->_template_args['admin_page_header'] = '';
1021
-        $EVT_ID                                    = ! empty($this->_req_data['event_id'])
1022
-            ? absint($this->_req_data['event_id'])
1023
-            : 0;
1024
-        $ATT_ID = !empty($this->_req_data['ATT_ID'])
1025
-            ? absint($this->_req_data['ATT_ID'])
1026
-            : 0;
1027
-        if ($ATT_ID) {
1028
-            $attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
-            if ($attendee instanceof EE_Attendee) {
1030
-                $this->_template_args['admin_page_header'] = sprintf(
1031
-                    esc_html__(
1032
-                        '%1$s Viewing registrations for %2$s%3$s',
1033
-                        'event_espresso'
1034
-                    ),
1035
-                    '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
-                        array(
1038
-                            'action' => 'edit_attendee',
1039
-                            'post' => $ATT_ID
1040
-                        ),
1041
-                        REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1043
-                    '</h3>'
1044
-                );
1045
-            }
1046
-        }
1047
-        if ($EVT_ID) {
1048
-            if (EE_Registry::instance()->CAP->current_user_can(
1049
-                'ee_edit_registrations',
1050
-                'espresso_registrations_new_registration',
1051
-                $EVT_ID
1052
-            )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
-                    'new_registration',
1055
-                    'add-registrant',
1056
-                    array('event_id' => $EVT_ID),
1057
-                    'add-new-h2'
1058
-                );
1059
-            }
1060
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
-            if ($event instanceof EE_Event) {
1062
-                $this->_template_args['admin_page_header'] = sprintf(
1063
-                    esc_html__(
1064
-                        '%s Viewing registrations for the event: %s%s',
1065
-                        'event_espresso'
1066
-                    ),
1067
-                    '<h3 style="line-height:1.5em;">',
1068
-                    '<br /><a href="'
1069
-                        . EE_Admin_Page::add_query_args_and_nonce(
1070
-                            array(
1071
-                                'action' => 'edit',
1072
-                                'post'   => $event->ID(),
1073
-                            ),
1074
-                            EVENTS_ADMIN_URL
1075
-                        )
1076
-                        . '">&nbsp;'
1077
-                        . $event->get('EVT_name')
1078
-                        . '&nbsp;</a>&nbsp;',
1079
-                    '</h3>'
1080
-                );
1081
-            }
1082
-            $DTT_ID   = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
-                $this->_template_args['admin_page_header'] = substr(
1086
-                    $this->_template_args['admin_page_header'],
1087
-                    0,
1088
-                    -5
1089
-                );
1090
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
-                $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
1095
-            }
1096
-        }
1097
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
-        $this->display_admin_list_table_page_with_no_sidebar();
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * This sets the _registration property for the registration details screen
1104
-     *
1105
-     * @access private
1106
-     * @return bool
1107
-     * @throws EE_Error
1108
-     * @throws InvalidArgumentException
1109
-     * @throws InvalidDataTypeException
1110
-     * @throws InvalidInterfaceException
1111
-     */
1112
-    private function _set_registration_object()
1113
-    {
1114
-        //get out if we've already set the object
1115
-        if ($this->_registration instanceof EE_Registration) {
1116
-            return true;
1117
-        }
1118
-        $REG    = EEM_Registration::instance();
1119
-        $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
-            return true;
1122
-        } else {
1123
-            $error_msg = sprintf(
1124
-                esc_html__(
1125
-                    'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
-                    'event_espresso'
1127
-                ),
1128
-                $REG_ID
1129
-            );
1130
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
-            $this->_registration = null;
1132
-            return false;
1133
-        }
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * Used to retrieve registrations for the list table.
1139
-     *
1140
-     * @param int  $per_page
1141
-     * @param bool $count
1142
-     * @param bool $this_month
1143
-     * @param bool $today
1144
-     * @return EE_Registration[]|int
1145
-     * @throws EE_Error
1146
-     * @throws InvalidArgumentException
1147
-     * @throws InvalidDataTypeException
1148
-     * @throws InvalidInterfaceException
1149
-     */
1150
-    public function get_registrations(
1151
-        $per_page = 10,
1152
-        $count = false,
1153
-        $this_month = false,
1154
-        $today = false
1155
-    ) {
1156
-        if ($this_month) {
1157
-            $this->_req_data['status'] = 'month';
1158
-        }
1159
-        if ($today) {
1160
-            $this->_req_data['status'] = 'today';
1161
-        }
1162
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
-        /**
1164
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1166
-         * @see EEM_Base::get_all()
1167
-         */
1168
-        $query_params['group_by'] = '';
1169
-
1170
-        return $count
1171
-            ? EEM_Registration::instance()->count($query_params)
1172
-            /** @type EE_Registration[] */
1173
-            : EEM_Registration::instance()->get_all($query_params);
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1179
-     * Note: this listens to values on the request for some of the query parameters.
1180
-     *
1181
-     * @param array $request
1182
-     * @param int   $per_page
1183
-     * @param bool  $count
1184
-     * @return array
1185
-     * @throws EE_Error
1186
-     */
1187
-    protected function _get_registration_query_parameters(
1188
-        $request = array(),
1189
-        $per_page = 10,
1190
-        $count = false
1191
-    ) {
1192
-
1193
-        $query_params = array(
1194
-            0                          => $this->_get_where_conditions_for_registrations_query(
1195
-                $request
1196
-            ),
1197
-            'caps'                     => EEM_Registration::caps_read_admin,
1198
-            'default_where_conditions' => 'this_model_only',
1199
-        );
1200
-        if (! $count) {
1201
-            $query_params = array_merge(
1202
-                $query_params,
1203
-                $this->_get_orderby_for_registrations_query(),
1204
-                $this->_get_limit($per_page)
1205
-            );
1206
-        }
1207
-
1208
-        return $query_params;
1209
-    }
1210
-
1211
-
1212
-    /**
1213
-     * This will add ATT_ID to the provided $where array for EE model query parameters.
1214
-     *
1215
-     * @param array $request usually the same as $this->_req_data but not necessarily
1216
-     * @return array
1217
-     */
1218
-    protected function addAttendeeIdToWhereConditions(array $request)
1219
-    {
1220
-        $where = array();
1221
-        if (! empty($request['ATT_ID'])) {
1222
-            $where['ATT_ID'] = absint($request['ATT_ID']);
1223
-        }
1224
-        return $where;
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * This will add EVT_ID to the provided $where array for EE model query parameters.
1230
-     *
1231
-     * @param array $request usually the same as $this->_req_data but not necessarily
1232
-     * @return array
1233
-     */
1234
-    protected function _add_event_id_to_where_conditions(array $request)
1235
-    {
1236
-        $where = array();
1237
-        if (! empty($request['event_id'])) {
1238
-            $where['EVT_ID'] = absint($request['event_id']);
1239
-        }
1240
-        return $where;
1241
-    }
1242
-
1243
-
1244
-    /**
1245
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
1246
-     *
1247
-     * @param array $request usually the same as $this->_req_data but not necessarily
1248
-     * @return array
1249
-     */
1250
-    protected function _add_category_id_to_where_conditions(array $request)
1251
-    {
1252
-        $where = array();
1253
-        if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) {
1254
-            $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1255
-        }
1256
-        return $where;
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1262
-     *
1263
-     * @param array $request usually the same as $this->_req_data but not necessarily
1264
-     * @return array
1265
-     */
1266
-    protected function _add_datetime_id_to_where_conditions(array $request)
1267
-    {
1268
-        $where = array();
1269
-        if (! empty($request['datetime_id'])) {
1270
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1271
-        }
1272
-        if (! empty($request['DTT_ID'])) {
1273
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1274
-        }
1275
-        return $where;
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     * Adds the correct registration status to the where conditions for the registrations query.
1281
-     *
1282
-     * @param array $request usually the same as $this->_req_data but not necessarily
1283
-     * @return array
1284
-     */
1285
-    protected function _add_registration_status_to_where_conditions(array $request)
1286
-    {
1287
-        $where = array();
1288
-        $view = EEH_Array::is_set($request, 'status', '');
1289
-        $registration_status = ! empty($request['_reg_status'])
1290
-            ? sanitize_text_field($request['_reg_status'])
1291
-            : '';
1292
-
1293
-        /*
33
+	/**
34
+	 * @var EE_Registration
35
+	 */
36
+	private $_registration;
37
+
38
+	/**
39
+	 * @var EE_Event
40
+	 */
41
+	private $_reg_event;
42
+
43
+	/**
44
+	 * @var EE_Session
45
+	 */
46
+	private $_session;
47
+
48
+	private static $_reg_status;
49
+
50
+	/**
51
+	 * Form for displaying the custom questions for this registration.
52
+	 * This gets used a few times throughout the request so its best to cache it
53
+	 *
54
+	 * @var EE_Registration_Custom_Questions_Form
55
+	 */
56
+	protected $_reg_custom_questions_form = null;
57
+
58
+
59
+	/**
60
+	 *        constructor
61
+	 *
62
+	 * @Constructor
63
+	 * @access public
64
+	 * @param bool $routing
65
+	 * @return Registrations_Admin_Page
66
+	 */
67
+	public function __construct($routing = true)
68
+	{
69
+		parent::__construct($routing);
70
+		add_action('wp_loaded', array($this, 'wp_loaded'));
71
+	}
72
+
73
+
74
+	public function wp_loaded()
75
+	{
76
+		// when adding a new registration...
77
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
78
+			EE_System::do_not_cache();
79
+			if (! isset($this->_req_data['processing_registration'])
80
+				 || absint($this->_req_data['processing_registration']) !== 1
81
+			) {
82
+				// and it's NOT the attendee information reg step
83
+				// force cookie expiration by setting time to last week
84
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
85
+				// and update the global
86
+				$_COOKIE['ee_registration_added'] = 0;
87
+			}
88
+		}
89
+	}
90
+
91
+
92
+	protected function _init_page_props()
93
+	{
94
+		$this->page_slug        = REG_PG_SLUG;
95
+		$this->_admin_base_url  = REG_ADMIN_URL;
96
+		$this->_admin_base_path = REG_ADMIN;
97
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
98
+		$this->_cpt_routes      = array(
99
+			'add_new_attendee' => 'espresso_attendees',
100
+			'edit_attendee'    => 'espresso_attendees',
101
+			'insert_attendee'  => 'espresso_attendees',
102
+			'update_attendee'  => 'espresso_attendees',
103
+		);
104
+		$this->_cpt_model_names = array(
105
+			'add_new_attendee' => 'EEM_Attendee',
106
+			'edit_attendee'    => 'EEM_Attendee',
107
+		);
108
+		$this->_cpt_edit_routes = array(
109
+			'espresso_attendees' => 'edit_attendee',
110
+		);
111
+		$this->_pagenow_map     = array(
112
+			'add_new_attendee' => 'post-new.php',
113
+			'edit_attendee'    => 'post.php',
114
+			'trash'            => 'post.php',
115
+		);
116
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
117
+		//add filters so that the comment urls don't take users to a confusing 404 page
118
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
119
+	}
120
+
121
+
122
+	public function clear_comment_link($link, $comment, $args)
123
+	{
124
+		//gotta make sure this only happens on this route
125
+		$post_type = get_post_type($comment->comment_post_ID);
126
+		if ($post_type === 'espresso_attendees') {
127
+			return '#commentsdiv';
128
+		}
129
+		return $link;
130
+	}
131
+
132
+
133
+	protected function _ajax_hooks()
134
+	{
135
+		//todo: all hooks for registrations ajax goes in here
136
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
137
+	}
138
+
139
+
140
+	protected function _define_page_props()
141
+	{
142
+		$this->_admin_page_title = $this->page_label;
143
+		$this->_labels           = array(
144
+			'buttons'                      => array(
145
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
146
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
147
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
148
+				'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
149
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
150
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
151
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
152
+				'contact_list_export' => esc_html__("Export Data", "event_espresso"),
153
+			),
154
+			'publishbox'                   => array(
155
+				'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
156
+				'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
157
+			),
158
+			'hide_add_button_on_cpt_route' => array(
159
+				'edit_attendee' => true,
160
+			),
161
+		);
162
+	}
163
+
164
+
165
+	/**
166
+	 *        grab url requests and route them
167
+	 *
168
+	 * @access private
169
+	 * @return void
170
+	 */
171
+	public function _set_page_routes()
172
+	{
173
+		$this->_get_registration_status_array();
174
+		$reg_id             = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
+			? $this->_req_data['_REG_ID'] : 0;
176
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
177
+			? $this->_req_data['reg_status_change_form']['REG_ID']
178
+			: $reg_id;
179
+		$att_id             = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
180
+			? $this->_req_data['ATT_ID'] : 0;
181
+		$att_id             = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
182
+			? $this->_req_data['post']
183
+			: $att_id;
184
+		$this->_page_routes = array(
185
+			'default'                            => array(
186
+				'func'       => '_registrations_overview_list_table',
187
+				'capability' => 'ee_read_registrations',
188
+			),
189
+			'view_registration'                  => array(
190
+				'func'       => '_registration_details',
191
+				'capability' => 'ee_read_registration',
192
+				'obj_id'     => $reg_id,
193
+			),
194
+			'edit_registration'                  => array(
195
+				'func'               => '_update_attendee_registration_form',
196
+				'noheader'           => true,
197
+				'headers_sent_route' => 'view_registration',
198
+				'capability'         => 'ee_edit_registration',
199
+				'obj_id'             => $reg_id,
200
+				'_REG_ID'            => $reg_id,
201
+			),
202
+			'trash_registrations'                => array(
203
+				'func'       => '_trash_or_restore_registrations',
204
+				'args'       => array('trash' => true),
205
+				'noheader'   => true,
206
+				'capability' => 'ee_delete_registrations',
207
+			),
208
+			'restore_registrations'              => array(
209
+				'func'       => '_trash_or_restore_registrations',
210
+				'args'       => array('trash' => false),
211
+				'noheader'   => true,
212
+				'capability' => 'ee_delete_registrations',
213
+			),
214
+			'delete_registrations'               => array(
215
+				'func'       => '_delete_registrations',
216
+				'noheader'   => true,
217
+				'capability' => 'ee_delete_registrations',
218
+			),
219
+			'new_registration'                   => array(
220
+				'func'       => 'new_registration',
221
+				'capability' => 'ee_edit_registrations',
222
+			),
223
+			'process_reg_step'                   => array(
224
+				'func'       => 'process_reg_step',
225
+				'noheader'   => true,
226
+				'capability' => 'ee_edit_registrations',
227
+			),
228
+			'redirect_to_txn'                    => array(
229
+				'func'       => 'redirect_to_txn',
230
+				'noheader'   => true,
231
+				'capability' => 'ee_edit_registrations',
232
+			),
233
+			'change_reg_status'                  => array(
234
+				'func'       => '_change_reg_status',
235
+				'noheader'   => true,
236
+				'capability' => 'ee_edit_registration',
237
+				'obj_id'     => $reg_id,
238
+			),
239
+			'approve_registration'               => array(
240
+				'func'       => 'approve_registration',
241
+				'noheader'   => true,
242
+				'capability' => 'ee_edit_registration',
243
+				'obj_id'     => $reg_id,
244
+			),
245
+			'approve_and_notify_registration'    => array(
246
+				'func'       => 'approve_registration',
247
+				'noheader'   => true,
248
+				'args'       => array(true),
249
+				'capability' => 'ee_edit_registration',
250
+				'obj_id'     => $reg_id,
251
+			),
252
+			'approve_registrations'               => array(
253
+				'func'       => 'bulk_action_on_registrations',
254
+				'noheader'   => true,
255
+				'capability' => 'ee_edit_registrations',
256
+				'args' => array('approve')
257
+			),
258
+			'approve_and_notify_registrations'               => array(
259
+				'func'       => 'bulk_action_on_registrations',
260
+				'noheader'   => true,
261
+				'capability' => 'ee_edit_registrations',
262
+				'args' => array('approve', true)
263
+			),
264
+			'decline_registration'               => array(
265
+				'func'       => 'decline_registration',
266
+				'noheader'   => true,
267
+				'capability' => 'ee_edit_registration',
268
+				'obj_id'     => $reg_id,
269
+			),
270
+			'decline_and_notify_registration'    => array(
271
+				'func'       => 'decline_registration',
272
+				'noheader'   => true,
273
+				'args'       => array(true),
274
+				'capability' => 'ee_edit_registration',
275
+				'obj_id'     => $reg_id,
276
+			),
277
+			'decline_registrations'               => array(
278
+				'func'       => 'bulk_action_on_registrations',
279
+				'noheader'   => true,
280
+				'capability' => 'ee_edit_registrations',
281
+				'args' => array('decline')
282
+			),
283
+			'decline_and_notify_registrations'    => array(
284
+				'func'       => 'bulk_action_on_registrations',
285
+				'noheader'   => true,
286
+				'capability' => 'ee_edit_registrations',
287
+				'args' => array('decline', true)
288
+			),
289
+			'pending_registration'               => array(
290
+				'func'       => 'pending_registration',
291
+				'noheader'   => true,
292
+				'capability' => 'ee_edit_registration',
293
+				'obj_id'     => $reg_id,
294
+			),
295
+			'pending_and_notify_registration'    => array(
296
+				'func'       => 'pending_registration',
297
+				'noheader'   => true,
298
+				'args'       => array(true),
299
+				'capability' => 'ee_edit_registration',
300
+				'obj_id'     => $reg_id,
301
+			),
302
+			'pending_registrations'               => array(
303
+				'func'       => 'bulk_action_on_registrations',
304
+				'noheader'   => true,
305
+				'capability' => 'ee_edit_registrations',
306
+				'args' => array('pending')
307
+			),
308
+			'pending_and_notify_registrations'    => array(
309
+				'func'       => 'bulk_action_on_registrations',
310
+				'noheader'   => true,
311
+				'capability' => 'ee_edit_registrations',
312
+				'args' => array('pending', true)
313
+			),
314
+			'no_approve_registration'            => array(
315
+				'func'       => 'not_approve_registration',
316
+				'noheader'   => true,
317
+				'capability' => 'ee_edit_registration',
318
+				'obj_id'     => $reg_id,
319
+			),
320
+			'no_approve_and_notify_registration' => array(
321
+				'func'       => 'not_approve_registration',
322
+				'noheader'   => true,
323
+				'args'       => array(true),
324
+				'capability' => 'ee_edit_registration',
325
+				'obj_id'     => $reg_id,
326
+			),
327
+			'no_approve_registrations'            => array(
328
+				'func'       => 'bulk_action_on_registrations',
329
+				'noheader'   => true,
330
+				'capability' => 'ee_edit_registrations',
331
+				'args' => array('not_approve')
332
+			),
333
+			'no_approve_and_notify_registrations' => array(
334
+				'func'       => 'bulk_action_on_registrations',
335
+				'noheader'   => true,
336
+				'capability' => 'ee_edit_registrations',
337
+				'args' => array('not_approve', true)
338
+			),
339
+			'cancel_registration'                => array(
340
+				'func'       => 'cancel_registration',
341
+				'noheader'   => true,
342
+				'capability' => 'ee_edit_registration',
343
+				'obj_id'     => $reg_id,
344
+			),
345
+			'cancel_and_notify_registration'     => array(
346
+				'func'       => 'cancel_registration',
347
+				'noheader'   => true,
348
+				'args'       => array(true),
349
+				'capability' => 'ee_edit_registration',
350
+				'obj_id'     => $reg_id,
351
+			),
352
+			'cancel_registrations'                => array(
353
+				'func'       => 'bulk_action_on_registrations',
354
+				'noheader'   => true,
355
+				'capability' => 'ee_edit_registrations',
356
+				'args' => array('cancel')
357
+			),
358
+			'cancel_and_notify_registrations'     => array(
359
+				'func'       => 'bulk_action_on_registrations',
360
+				'noheader'   => true,
361
+				'capability' => 'ee_edit_registrations',
362
+				'args' => array('cancel', true)
363
+			),
364
+			'wait_list_registration' => array(
365
+				'func'       => 'wait_list_registration',
366
+				'noheader'   => true,
367
+				'capability' => 'ee_edit_registration',
368
+				'obj_id'     => $reg_id,
369
+			),
370
+			'wait_list_and_notify_registration' => array(
371
+				'func'       => 'wait_list_registration',
372
+				'noheader'   => true,
373
+				'args'       => array(true),
374
+				'capability' => 'ee_edit_registration',
375
+				'obj_id'     => $reg_id,
376
+			),
377
+			'contact_list'                       => array(
378
+				'func'       => '_attendee_contact_list_table',
379
+				'capability' => 'ee_read_contacts',
380
+			),
381
+			'add_new_attendee'                   => array(
382
+				'func' => '_create_new_cpt_item',
383
+				'args' => array(
384
+					'new_attendee' => true,
385
+					'capability'   => 'ee_edit_contacts',
386
+				),
387
+			),
388
+			'edit_attendee'                      => array(
389
+				'func'       => '_edit_cpt_item',
390
+				'capability' => 'ee_edit_contacts',
391
+				'obj_id'     => $att_id,
392
+			),
393
+			'duplicate_attendee'                 => array(
394
+				'func'       => '_duplicate_attendee',
395
+				'noheader'   => true,
396
+				'capability' => 'ee_edit_contacts',
397
+				'obj_id'     => $att_id,
398
+			),
399
+			'insert_attendee'                    => array(
400
+				'func'       => '_insert_or_update_attendee',
401
+				'args'       => array(
402
+					'new_attendee' => true,
403
+				),
404
+				'noheader'   => true,
405
+				'capability' => 'ee_edit_contacts',
406
+			),
407
+			'update_attendee'                    => array(
408
+				'func'       => '_insert_or_update_attendee',
409
+				'args'       => array(
410
+					'new_attendee' => false,
411
+				),
412
+				'noheader'   => true,
413
+				'capability' => 'ee_edit_contacts',
414
+				'obj_id'     => $att_id,
415
+			),
416
+			'trash_attendees' => array(
417
+				'func' => '_trash_or_restore_attendees',
418
+				'args' => array(
419
+					'trash' => 'true'
420
+				),
421
+				'noheader' => true,
422
+				'capability' => 'ee_delete_contacts'
423
+			),
424
+			'trash_attendee'                    => array(
425
+				'func'       => '_trash_or_restore_attendees',
426
+				'args'       => array(
427
+					'trash' => true,
428
+				),
429
+				'noheader'   => true,
430
+				'capability' => 'ee_delete_contacts',
431
+				'obj_id'     => $att_id,
432
+			),
433
+			'restore_attendees'                  => array(
434
+				'func'       => '_trash_or_restore_attendees',
435
+				'args'       => array(
436
+					'trash' => false,
437
+				),
438
+				'noheader'   => true,
439
+				'capability' => 'ee_delete_contacts',
440
+				'obj_id'     => $att_id,
441
+			),
442
+			'resend_registration'                => array(
443
+				'func'       => '_resend_registration',
444
+				'noheader'   => true,
445
+				'capability' => 'ee_send_message',
446
+			),
447
+			'registrations_report'               => array(
448
+				'func'       => '_registrations_report',
449
+				'noheader'   => true,
450
+				'capability' => 'ee_read_registrations',
451
+			),
452
+			'contact_list_export'                => array(
453
+				'func'       => '_contact_list_export',
454
+				'noheader'   => true,
455
+				'capability' => 'export',
456
+			),
457
+			'contact_list_report'                => array(
458
+				'func'       => '_contact_list_report',
459
+				'noheader'   => true,
460
+				'capability' => 'ee_read_contacts',
461
+			),
462
+		);
463
+	}
464
+
465
+
466
+	protected function _set_page_config()
467
+	{
468
+		$this->_page_config = array(
469
+			'default'           => array(
470
+				'nav'           => array(
471
+					'label' => esc_html__('Overview', 'event_espresso'),
472
+					'order' => 5,
473
+				),
474
+				'help_tabs'     => array(
475
+					'registrations_overview_help_tab'                       => array(
476
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
477
+						'filename' => 'registrations_overview',
478
+					),
479
+					'registrations_overview_table_column_headings_help_tab' => array(
480
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
481
+						'filename' => 'registrations_overview_table_column_headings',
482
+					),
483
+					'registrations_overview_filters_help_tab'               => array(
484
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
485
+						'filename' => 'registrations_overview_filters',
486
+					),
487
+					'registrations_overview_views_help_tab'                 => array(
488
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
489
+						'filename' => 'registrations_overview_views',
490
+					),
491
+					'registrations_regoverview_other_help_tab'              => array(
492
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
493
+						'filename' => 'registrations_overview_other',
494
+					),
495
+				),
496
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
497
+				'qtips'         => array('Registration_List_Table_Tips'),
498
+				'list_table'    => 'EE_Registrations_List_Table',
499
+				'require_nonce' => false,
500
+			),
501
+			'view_registration' => array(
502
+				'nav'           => array(
503
+					'label'      => esc_html__('REG Details', 'event_espresso'),
504
+					'order'      => 15,
505
+					'url'        => isset($this->_req_data['_REG_ID'])
506
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
507
+						: $this->_admin_base_url,
508
+					'persistent' => false,
509
+				),
510
+				'help_tabs'     => array(
511
+					'registrations_details_help_tab'                    => array(
512
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
513
+						'filename' => 'registrations_details',
514
+					),
515
+					'registrations_details_table_help_tab'              => array(
516
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
517
+						'filename' => 'registrations_details_table',
518
+					),
519
+					'registrations_details_form_answers_help_tab'       => array(
520
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
521
+						'filename' => 'registrations_details_form_answers',
522
+					),
523
+					'registrations_details_registrant_details_help_tab' => array(
524
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
525
+						'filename' => 'registrations_details_registrant_details',
526
+					),
527
+				),
528
+				'help_tour'     => array('Registration_Details_Help_Tour'),
529
+				'metaboxes'     => array_merge(
530
+					$this->_default_espresso_metaboxes,
531
+					array('_registration_details_metaboxes')
532
+				),
533
+				'require_nonce' => false,
534
+			),
535
+			'new_registration'  => array(
536
+				'nav'           => array(
537
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
538
+					'url'        => '#',
539
+					'order'      => 15,
540
+					'persistent' => false,
541
+				),
542
+				'metaboxes'     => $this->_default_espresso_metaboxes,
543
+				'labels'        => array(
544
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
545
+				),
546
+				'require_nonce' => false,
547
+			),
548
+			'add_new_attendee'  => array(
549
+				'nav'           => array(
550
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
551
+					'order'      => 15,
552
+					'persistent' => false,
553
+				),
554
+				'metaboxes'     => array_merge(
555
+					$this->_default_espresso_metaboxes,
556
+					array('_publish_post_box', 'attendee_editor_metaboxes')
557
+				),
558
+				'require_nonce' => false,
559
+			),
560
+			'edit_attendee'     => array(
561
+				'nav'           => array(
562
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
563
+					'order'      => 15,
564
+					'persistent' => false,
565
+					'url'        => isset($this->_req_data['ATT_ID'])
566
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
567
+						: $this->_admin_base_url,
568
+				),
569
+				'metaboxes'     => array('attendee_editor_metaboxes'),
570
+				'require_nonce' => false,
571
+			),
572
+			'contact_list'      => array(
573
+				'nav'           => array(
574
+					'label' => esc_html__('Contact List', 'event_espresso'),
575
+					'order' => 20,
576
+				),
577
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
578
+				'help_tabs'     => array(
579
+					'registrations_contact_list_help_tab'                       => array(
580
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
581
+						'filename' => 'registrations_contact_list',
582
+					),
583
+					'registrations_contact-list_table_column_headings_help_tab' => array(
584
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
585
+						'filename' => 'registrations_contact_list_table_column_headings',
586
+					),
587
+					'registrations_contact_list_views_help_tab'                 => array(
588
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
589
+						'filename' => 'registrations_contact_list_views',
590
+					),
591
+					'registrations_contact_list_other_help_tab'                 => array(
592
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
593
+						'filename' => 'registrations_contact_list_other',
594
+					),
595
+				),
596
+				'help_tour'     => array('Contact_List_Help_Tour'),
597
+				'metaboxes'     => array(),
598
+				'require_nonce' => false,
599
+			),
600
+			//override default cpt routes
601
+			'create_new'        => '',
602
+			'edit'              => '',
603
+		);
604
+	}
605
+
606
+
607
+	/**
608
+	 * The below methods aren't used by this class currently
609
+	 */
610
+	protected function _add_screen_options()
611
+	{
612
+	}
613
+
614
+
615
+	protected function _add_feature_pointers()
616
+	{
617
+	}
618
+
619
+
620
+	public function admin_init()
621
+	{
622
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
623
+			'click "Update Registration Questions" to save your changes',
624
+			'event_espresso'
625
+		);
626
+	}
627
+
628
+
629
+	public function admin_notices()
630
+	{
631
+	}
632
+
633
+
634
+	public function admin_footer_scripts()
635
+	{
636
+	}
637
+
638
+
639
+	/**
640
+	 *        get list of registration statuses
641
+	 *
642
+	 * @access private
643
+	 * @return void
644
+	 * @throws EE_Error
645
+	 */
646
+	private function _get_registration_status_array()
647
+	{
648
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
649
+	}
650
+
651
+
652
+	protected function _add_screen_options_default()
653
+	{
654
+		$this->_per_page_screen_option();
655
+	}
656
+
657
+
658
+	protected function _add_screen_options_contact_list()
659
+	{
660
+		$page_title              = $this->_admin_page_title;
661
+		$this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
662
+		$this->_per_page_screen_option();
663
+		$this->_admin_page_title = $page_title;
664
+	}
665
+
666
+
667
+	public function load_scripts_styles()
668
+	{
669
+		//style
670
+		wp_register_style(
671
+			'espresso_reg',
672
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
673
+			array('ee-admin-css'),
674
+			EVENT_ESPRESSO_VERSION
675
+		);
676
+		wp_enqueue_style('espresso_reg');
677
+		//script
678
+		wp_register_script(
679
+			'espresso_reg',
680
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
681
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
682
+			EVENT_ESPRESSO_VERSION,
683
+			true
684
+		);
685
+		wp_enqueue_script('espresso_reg');
686
+	}
687
+
688
+
689
+	public function load_scripts_styles_edit_attendee()
690
+	{
691
+		//stuff to only show up on our attendee edit details page.
692
+		$attendee_details_translations = array(
693
+			'att_publish_text' => sprintf(
694
+				esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
695
+				$this->_cpt_model_obj->get_datetime('ATT_created')
696
+			),
697
+		);
698
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
699
+		wp_enqueue_script('jquery-validate');
700
+	}
701
+
702
+
703
+	public function load_scripts_styles_view_registration()
704
+	{
705
+		//styles
706
+		wp_enqueue_style('espresso-ui-theme');
707
+		//scripts
708
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
709
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
710
+	}
711
+
712
+
713
+	public function load_scripts_styles_contact_list()
714
+	{
715
+		wp_deregister_style('espresso_reg');
716
+		wp_register_style(
717
+			'espresso_att',
718
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
719
+			array('ee-admin-css'),
720
+			EVENT_ESPRESSO_VERSION
721
+		);
722
+		wp_enqueue_style('espresso_att');
723
+	}
724
+
725
+
726
+	public function load_scripts_styles_new_registration()
727
+	{
728
+		wp_register_script(
729
+			'ee-spco-for-admin',
730
+			REG_ASSETS_URL . 'spco_for_admin.js',
731
+			array('underscore', 'jquery'),
732
+			EVENT_ESPRESSO_VERSION,
733
+			true
734
+		);
735
+		wp_enqueue_script('ee-spco-for-admin');
736
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
737
+		EE_Form_Section_Proper::wp_enqueue_scripts();
738
+		EED_Ticket_Selector::load_tckt_slctr_assets();
739
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
740
+	}
741
+
742
+
743
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
744
+	{
745
+		add_filter('FHEE_load_EE_messages', '__return_true');
746
+	}
747
+
748
+
749
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
750
+	{
751
+		add_filter('FHEE_load_EE_messages', '__return_true');
752
+	}
753
+
754
+
755
+	protected function _set_list_table_views_default()
756
+	{
757
+		//for notification related bulk actions we need to make sure only active messengers have an option.
758
+		EED_Messages::set_autoloaders();
759
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
760
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
761
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
762
+		//key= bulk_action_slug, value= message type.
763
+		$match_array = array(
764
+			'approve_registrations'    => 'registration',
765
+			'decline_registrations'    => 'declined_registration',
766
+			'pending_registrations'    => 'pending_approval',
767
+			'no_approve_registrations' => 'not_approved_registration',
768
+			'cancel_registrations'     => 'cancelled_registration',
769
+		);
770
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
771
+			'ee_send_message',
772
+			'batch_send_messages'
773
+		);
774
+		/** setup reg status bulk actions **/
775
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
776
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
777
+				$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
778
+					'Approve and Notify Registrations',
779
+					'event_espresso'
780
+				);
781
+		}
782
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
783
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
784
+				$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
785
+					'Decline and Notify Registrations',
786
+					'event_espresso'
787
+				);
788
+		}
789
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
790
+			'Set Registrations to Pending Payment',
791
+			'event_espresso'
792
+		);
793
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
794
+				$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
795
+					'Set Registrations to Pending Payment and Notify',
796
+					'event_espresso'
797
+				);
798
+		}
799
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
800
+			'Set Registrations to Not Approved',
801
+			'event_espresso'
802
+		);
803
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
804
+				$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
805
+					'Set Registrations to Not Approved and Notify',
806
+					'event_espresso'
807
+				);
808
+		}
809
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
810
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
811
+				$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
812
+					'Cancel Registrations and Notify',
813
+					'event_espresso'
814
+				);
815
+		}
816
+		$def_reg_status_actions = apply_filters(
817
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
818
+			$def_reg_status_actions,
819
+			$active_mts,
820
+			$can_send
821
+		);
822
+
823
+		$this->_views = array(
824
+			'all'   => array(
825
+				'slug'        => 'all',
826
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
827
+				'count'       => 0,
828
+				'bulk_action' => array_merge($def_reg_status_actions, array(
829
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
830
+				)),
831
+			),
832
+			'month' => array(
833
+				'slug'        => 'month',
834
+				'label'       => esc_html__('This Month', 'event_espresso'),
835
+				'count'       => 0,
836
+				'bulk_action' => array_merge($def_reg_status_actions, array(
837
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
838
+				)),
839
+			),
840
+			'today' => array(
841
+				'slug'        => 'today',
842
+				'label'       => sprintf(
843
+					esc_html__('Today - %s', 'event_espresso'),
844
+					date('M d, Y', current_time('timestamp'))
845
+				),
846
+				'count'       => 0,
847
+				'bulk_action' => array_merge($def_reg_status_actions, array(
848
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
849
+				)),
850
+			),
851
+		);
852
+		if (EE_Registry::instance()->CAP->current_user_can(
853
+			'ee_delete_registrations',
854
+			'espresso_registrations_delete_registration'
855
+		)) {
856
+			$this->_views['incomplete'] = array(
857
+				'slug'        => 'incomplete',
858
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
859
+				'count'       => 0,
860
+				'bulk_action' => array(
861
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
862
+				),
863
+			);
864
+			$this->_views['trash']      = array(
865
+				'slug'        => 'trash',
866
+				'label'       => esc_html__('Trash', 'event_espresso'),
867
+				'count'       => 0,
868
+				'bulk_action' => array(
869
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
870
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
871
+				),
872
+			);
873
+		}
874
+	}
875
+
876
+
877
+	protected function _set_list_table_views_contact_list()
878
+	{
879
+		$this->_views = array(
880
+			'in_use' => array(
881
+				'slug'        => 'in_use',
882
+				'label'       => esc_html__('In Use', 'event_espresso'),
883
+				'count'       => 0,
884
+				'bulk_action' => array(
885
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
886
+				),
887
+			),
888
+		);
889
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
890
+			'espresso_registrations_trash_attendees')
891
+		) {
892
+			$this->_views['trash'] = array(
893
+				'slug'        => 'trash',
894
+				'label'       => esc_html__('Trash', 'event_espresso'),
895
+				'count'       => 0,
896
+				'bulk_action' => array(
897
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
+				),
899
+			);
900
+		}
901
+	}
902
+
903
+
904
+	protected function _registration_legend_items()
905
+	{
906
+		$fc_items = array(
907
+			'star-icon'        => array(
908
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
+			),
911
+			'view_details'     => array(
912
+				'class' => 'dashicons dashicons-clipboard',
913
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
+			),
915
+			'edit_attendee'    => array(
916
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
+			),
919
+			'view_transaction' => array(
920
+				'class' => 'dashicons dashicons-cart',
921
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
+			),
923
+			'view_invoice'     => array(
924
+				'class' => 'dashicons dashicons-media-spreadsheet',
925
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
+			),
927
+		);
928
+		if (EE_Registry::instance()->CAP->current_user_can(
929
+			'ee_send_message',
930
+			'espresso_registrations_resend_registration'
931
+		)) {
932
+			$fc_items['resend_registration'] = array(
933
+				'class' => 'dashicons dashicons-email-alt',
934
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
+			);
936
+		} else {
937
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
+		}
939
+		if (EE_Registry::instance()->CAP->current_user_can(
940
+			'ee_read_global_messages',
941
+			'view_filtered_messages'
942
+		)) {
943
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
+				$fc_items['view_related_messages'] = array(
946
+					'class' => $related_for_icon['css_class'],
947
+					'desc'  => $related_for_icon['label'],
948
+				);
949
+			}
950
+		}
951
+		$sc_items = array(
952
+			'approved_status'   => array(
953
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
+				'desc'  => EEH_Template::pretty_status(
955
+					EEM_Registration::status_id_approved,
956
+					false,
957
+					'sentence'
958
+				),
959
+			),
960
+			'pending_status'    => array(
961
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
+				'desc'  => EEH_Template::pretty_status(
963
+					EEM_Registration::status_id_pending_payment,
964
+					false,
965
+					'sentence'
966
+				),
967
+			),
968
+			'wait_list'         => array(
969
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
+				'desc'  => EEH_Template::pretty_status(
971
+					EEM_Registration::status_id_wait_list,
972
+					false,
973
+					'sentence'
974
+				),
975
+			),
976
+			'incomplete_status' => array(
977
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
+				'desc'  => EEH_Template::pretty_status(
979
+					EEM_Registration::status_id_incomplete,
980
+					false,
981
+					'sentence'
982
+				),
983
+			),
984
+			'not_approved'      => array(
985
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
+				'desc'  => EEH_Template::pretty_status(
987
+					EEM_Registration::status_id_not_approved,
988
+					false,
989
+					'sentence'
990
+				),
991
+			),
992
+			'declined_status'   => array(
993
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
+				'desc'  => EEH_Template::pretty_status(
995
+					EEM_Registration::status_id_declined,
996
+					false,
997
+					'sentence'
998
+				),
999
+			),
1000
+			'cancelled_status'  => array(
1001
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
+				'desc'  => EEH_Template::pretty_status(
1003
+					EEM_Registration::status_id_cancelled,
1004
+					false,
1005
+					'sentence'
1006
+				),
1007
+			),
1008
+		);
1009
+		return array_merge($fc_items, $sc_items);
1010
+	}
1011
+
1012
+
1013
+
1014
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1015
+	/**
1016
+	 * @throws \EE_Error
1017
+	 */
1018
+	protected function _registrations_overview_list_table()
1019
+	{
1020
+		$this->_template_args['admin_page_header'] = '';
1021
+		$EVT_ID                                    = ! empty($this->_req_data['event_id'])
1022
+			? absint($this->_req_data['event_id'])
1023
+			: 0;
1024
+		$ATT_ID = !empty($this->_req_data['ATT_ID'])
1025
+			? absint($this->_req_data['ATT_ID'])
1026
+			: 0;
1027
+		if ($ATT_ID) {
1028
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
+			if ($attendee instanceof EE_Attendee) {
1030
+				$this->_template_args['admin_page_header'] = sprintf(
1031
+					esc_html__(
1032
+						'%1$s Viewing registrations for %2$s%3$s',
1033
+						'event_espresso'
1034
+					),
1035
+					'<h3 style="line-height:1.5em;">',
1036
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
+						array(
1038
+							'action' => 'edit_attendee',
1039
+							'post' => $ATT_ID
1040
+						),
1041
+						REG_ADMIN_URL
1042
+					) . '">' . $attendee->full_name() . '</a>',
1043
+					'</h3>'
1044
+				);
1045
+			}
1046
+		}
1047
+		if ($EVT_ID) {
1048
+			if (EE_Registry::instance()->CAP->current_user_can(
1049
+				'ee_edit_registrations',
1050
+				'espresso_registrations_new_registration',
1051
+				$EVT_ID
1052
+			)) {
1053
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
+					'new_registration',
1055
+					'add-registrant',
1056
+					array('event_id' => $EVT_ID),
1057
+					'add-new-h2'
1058
+				);
1059
+			}
1060
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
+			if ($event instanceof EE_Event) {
1062
+				$this->_template_args['admin_page_header'] = sprintf(
1063
+					esc_html__(
1064
+						'%s Viewing registrations for the event: %s%s',
1065
+						'event_espresso'
1066
+					),
1067
+					'<h3 style="line-height:1.5em;">',
1068
+					'<br /><a href="'
1069
+						. EE_Admin_Page::add_query_args_and_nonce(
1070
+							array(
1071
+								'action' => 'edit',
1072
+								'post'   => $event->ID(),
1073
+							),
1074
+							EVENTS_ADMIN_URL
1075
+						)
1076
+						. '">&nbsp;'
1077
+						. $event->get('EVT_name')
1078
+						. '&nbsp;</a>&nbsp;',
1079
+					'</h3>'
1080
+				);
1081
+			}
1082
+			$DTT_ID   = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
+				$this->_template_args['admin_page_header'] = substr(
1086
+					$this->_template_args['admin_page_header'],
1087
+					0,
1088
+					-5
1089
+				);
1090
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
+				$this->_template_args['admin_page_header'] .= $datetime->name();
1093
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
1095
+			}
1096
+		}
1097
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
+		$this->display_admin_list_table_page_with_no_sidebar();
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * This sets the _registration property for the registration details screen
1104
+	 *
1105
+	 * @access private
1106
+	 * @return bool
1107
+	 * @throws EE_Error
1108
+	 * @throws InvalidArgumentException
1109
+	 * @throws InvalidDataTypeException
1110
+	 * @throws InvalidInterfaceException
1111
+	 */
1112
+	private function _set_registration_object()
1113
+	{
1114
+		//get out if we've already set the object
1115
+		if ($this->_registration instanceof EE_Registration) {
1116
+			return true;
1117
+		}
1118
+		$REG    = EEM_Registration::instance();
1119
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
+			return true;
1122
+		} else {
1123
+			$error_msg = sprintf(
1124
+				esc_html__(
1125
+					'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
+					'event_espresso'
1127
+				),
1128
+				$REG_ID
1129
+			);
1130
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
+			$this->_registration = null;
1132
+			return false;
1133
+		}
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * Used to retrieve registrations for the list table.
1139
+	 *
1140
+	 * @param int  $per_page
1141
+	 * @param bool $count
1142
+	 * @param bool $this_month
1143
+	 * @param bool $today
1144
+	 * @return EE_Registration[]|int
1145
+	 * @throws EE_Error
1146
+	 * @throws InvalidArgumentException
1147
+	 * @throws InvalidDataTypeException
1148
+	 * @throws InvalidInterfaceException
1149
+	 */
1150
+	public function get_registrations(
1151
+		$per_page = 10,
1152
+		$count = false,
1153
+		$this_month = false,
1154
+		$today = false
1155
+	) {
1156
+		if ($this_month) {
1157
+			$this->_req_data['status'] = 'month';
1158
+		}
1159
+		if ($today) {
1160
+			$this->_req_data['status'] = 'today';
1161
+		}
1162
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
+		/**
1164
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1166
+		 * @see EEM_Base::get_all()
1167
+		 */
1168
+		$query_params['group_by'] = '';
1169
+
1170
+		return $count
1171
+			? EEM_Registration::instance()->count($query_params)
1172
+			/** @type EE_Registration[] */
1173
+			: EEM_Registration::instance()->get_all($query_params);
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1179
+	 * Note: this listens to values on the request for some of the query parameters.
1180
+	 *
1181
+	 * @param array $request
1182
+	 * @param int   $per_page
1183
+	 * @param bool  $count
1184
+	 * @return array
1185
+	 * @throws EE_Error
1186
+	 */
1187
+	protected function _get_registration_query_parameters(
1188
+		$request = array(),
1189
+		$per_page = 10,
1190
+		$count = false
1191
+	) {
1192
+
1193
+		$query_params = array(
1194
+			0                          => $this->_get_where_conditions_for_registrations_query(
1195
+				$request
1196
+			),
1197
+			'caps'                     => EEM_Registration::caps_read_admin,
1198
+			'default_where_conditions' => 'this_model_only',
1199
+		);
1200
+		if (! $count) {
1201
+			$query_params = array_merge(
1202
+				$query_params,
1203
+				$this->_get_orderby_for_registrations_query(),
1204
+				$this->_get_limit($per_page)
1205
+			);
1206
+		}
1207
+
1208
+		return $query_params;
1209
+	}
1210
+
1211
+
1212
+	/**
1213
+	 * This will add ATT_ID to the provided $where array for EE model query parameters.
1214
+	 *
1215
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1216
+	 * @return array
1217
+	 */
1218
+	protected function addAttendeeIdToWhereConditions(array $request)
1219
+	{
1220
+		$where = array();
1221
+		if (! empty($request['ATT_ID'])) {
1222
+			$where['ATT_ID'] = absint($request['ATT_ID']);
1223
+		}
1224
+		return $where;
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * This will add EVT_ID to the provided $where array for EE model query parameters.
1230
+	 *
1231
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1232
+	 * @return array
1233
+	 */
1234
+	protected function _add_event_id_to_where_conditions(array $request)
1235
+	{
1236
+		$where = array();
1237
+		if (! empty($request['event_id'])) {
1238
+			$where['EVT_ID'] = absint($request['event_id']);
1239
+		}
1240
+		return $where;
1241
+	}
1242
+
1243
+
1244
+	/**
1245
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
1246
+	 *
1247
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1248
+	 * @return array
1249
+	 */
1250
+	protected function _add_category_id_to_where_conditions(array $request)
1251
+	{
1252
+		$where = array();
1253
+		if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) {
1254
+			$where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1255
+		}
1256
+		return $where;
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1262
+	 *
1263
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1264
+	 * @return array
1265
+	 */
1266
+	protected function _add_datetime_id_to_where_conditions(array $request)
1267
+	{
1268
+		$where = array();
1269
+		if (! empty($request['datetime_id'])) {
1270
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1271
+		}
1272
+		if (! empty($request['DTT_ID'])) {
1273
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1274
+		}
1275
+		return $where;
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 * Adds the correct registration status to the where conditions for the registrations query.
1281
+	 *
1282
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1283
+	 * @return array
1284
+	 */
1285
+	protected function _add_registration_status_to_where_conditions(array $request)
1286
+	{
1287
+		$where = array();
1288
+		$view = EEH_Array::is_set($request, 'status', '');
1289
+		$registration_status = ! empty($request['_reg_status'])
1290
+			? sanitize_text_field($request['_reg_status'])
1291
+			: '';
1292
+
1293
+		/*
1294 1294
          * If filtering by registration status, then we show registrations matching that status.
1295 1295
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1296 1296
          * UNLESS viewing trashed registrations.
1297 1297
          */
1298
-        if (! empty($registration_status)) {
1299
-            $where['STS_ID'] = $registration_status;
1300
-        } else {
1301
-            //make sure we exclude incomplete registrations, but only if not trashed.
1302
-            if ($view === 'trash') {
1303
-                $where['REG_deleted'] = true;
1304
-            } elseif ($view === 'incomplete') {
1305
-                $where['STS_ID'] = EEM_Registration::status_id_incomplete;
1306
-            } else {
1307
-                $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1308
-            }
1309
-        }
1310
-        return $where;
1311
-    }
1312
-
1313
-
1314
-    /**
1315
-     * Adds any provided date restraints to the where conditions for the registrations query.
1316
-     *
1317
-     * @param array $request usually the same as $this->_req_data but not necessarily
1318
-     * @return array
1319
-     * @throws EE_Error
1320
-     * @throws InvalidArgumentException
1321
-     * @throws InvalidDataTypeException
1322
-     * @throws InvalidInterfaceException
1323
-     */
1324
-    protected function _add_date_to_where_conditions(array $request)
1325
-    {
1326
-        $where = array();
1327
-        $view = EEH_Array::is_set($request, 'status', '');
1328
-        $month_range             = ! empty($request['month_range'])
1329
-            ? sanitize_text_field($request['month_range'])
1330
-            : '';
1331
-        $retrieve_for_today      = $view === 'today';
1332
-        $retrieve_for_this_month = $view === 'month';
1333
-
1334
-        if ($retrieve_for_today) {
1335
-            $now               = date('Y-m-d', current_time('timestamp'));
1336
-            $where['REG_date'] = array(
1337
-                'BETWEEN',
1338
-                array(
1339
-                    EEM_Registration::instance()->convert_datetime_for_query(
1340
-                        'REG_date',
1341
-                        $now . ' 00:00:00',
1342
-                        'Y-m-d H:i:s'
1343
-                    ),
1344
-                    EEM_Registration::instance()->convert_datetime_for_query(
1345
-                        'REG_date',
1346
-                        $now . ' 23:59:59',
1347
-                        'Y-m-d H:i:s'
1348
-                    ),
1349
-                ),
1350
-            );
1351
-        } elseif ($retrieve_for_this_month) {
1352
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
1353
-            $days_this_month        = date('t', current_time('timestamp'));
1354
-            $where['REG_date']      = array(
1355
-                'BETWEEN',
1356
-                array(
1357
-                    EEM_Registration::instance()->convert_datetime_for_query(
1358
-                        'REG_date',
1359
-                        $current_year_and_month . '-01 00:00:00',
1360
-                        'Y-m-d H:i:s'
1361
-                    ),
1362
-                    EEM_Registration::instance()->convert_datetime_for_query(
1363
-                        'REG_date',
1364
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1365
-                        'Y-m-d H:i:s'
1366
-                    ),
1367
-                ),
1368
-            );
1369
-        } elseif ($month_range) {
1370
-            $pieces          = explode(' ', $month_range, 3);
1371
-            $month_requested = ! empty($pieces[0])
1372
-                ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1373
-                : '';
1374
-            $year_requested  = ! empty($pieces[1])
1375
-                ? $pieces[1]
1376
-                : '';
1377
-            //if there is not a month or year then we can't go further
1378
-            if ($month_requested && $year_requested) {
1379
-                $days_in_month     = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1380
-                $where['REG_date'] = array(
1381
-                    'BETWEEN',
1382
-                    array(
1383
-                        EEM_Registration::instance()->convert_datetime_for_query(
1384
-                            'REG_date',
1385
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1386
-                            'Y-m-d H:i:s'
1387
-                        ),
1388
-                        EEM_Registration::instance()->convert_datetime_for_query(
1389
-                            'REG_date',
1390
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1391
-                            'Y-m-d H:i:s'
1392
-                        ),
1393
-                    ),
1394
-                );
1395
-            }
1396
-        }
1397
-        return $where;
1398
-    }
1399
-
1400
-
1401
-    /**
1402
-     * Adds any provided search restraints to the where conditions for the registrations query
1403
-     *
1404
-     * @param array $request usually the same as $this->_req_data but not necessarily
1405
-     * @return array
1406
-     */
1407
-    protected function _add_search_to_where_conditions(array $request)
1408
-    {
1409
-        $where = array();
1410
-        if (! empty($request['s'])) {
1411
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1412
-            $where['OR*search_conditions'] = array(
1413
-                'Event.EVT_name'                          => array('LIKE', $search_string),
1414
-                'Event.EVT_desc'                          => array('LIKE', $search_string),
1415
-                'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1416
-                'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1417
-                'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1418
-                'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1419
-                'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1420
-                'Attendee.ATT_email'                      => array('LIKE', $search_string),
1421
-                'Attendee.ATT_address'                    => array('LIKE', $search_string),
1422
-                'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1423
-                'Attendee.ATT_city'                       => array('LIKE', $search_string),
1424
-                'REG_final_price'                         => array('LIKE', $search_string),
1425
-                'REG_code'                                => array('LIKE', $search_string),
1426
-                'REG_count'                               => array('LIKE', $search_string),
1427
-                'REG_group_size'                          => array('LIKE', $search_string),
1428
-                'Ticket.TKT_name'                         => array('LIKE', $search_string),
1429
-                'Ticket.TKT_description'                  => array('LIKE', $search_string),
1430
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1431
-            );
1432
-        }
1433
-        return $where;
1434
-    }
1435
-
1436
-
1437
-    /**
1438
-     * Sets up the where conditions for the registrations query.
1439
-     *
1440
-     * @param array $request
1441
-     * @return array
1442
-     * @throws EE_Error
1443
-     */
1444
-    protected function _get_where_conditions_for_registrations_query($request)
1445
-    {
1446
-        return apply_filters(
1447
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1448
-            array_merge(
1449
-                $this->addAttendeeIdToWhereConditions($request),
1450
-                $this->_add_event_id_to_where_conditions($request),
1451
-                $this->_add_category_id_to_where_conditions($request),
1452
-                $this->_add_datetime_id_to_where_conditions($request),
1453
-                $this->_add_registration_status_to_where_conditions($request),
1454
-                $this->_add_date_to_where_conditions($request),
1455
-                $this->_add_search_to_where_conditions($request)
1456
-            ),
1457
-            $request
1458
-        );
1459
-    }
1460
-
1461
-
1462
-    /**
1463
-     * Sets up the orderby for the registrations query.
1464
-     *
1465
-     * @return array
1466
-     */
1467
-    protected function _get_orderby_for_registrations_query()
1468
-    {
1469
-        $orderby_field = ! empty($this->_req_data['orderby'])
1470
-            ? sanitize_text_field($this->_req_data['orderby'])
1471
-            : '';
1472
-        switch ($orderby_field) {
1473
-            case '_REG_ID':
1474
-                $orderby = array('REG_ID');
1475
-                break;
1476
-            case '_Reg_status':
1477
-                $orderby = array('STS_ID');
1478
-                break;
1479
-            case 'ATT_fname':
1480
-                $orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1481
-                break;
1482
-            case 'ATT_lname':
1483
-                $orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1484
-                break;
1485
-            case 'event_name':
1486
-                $orderby = array('Event.EVT_name');
1487
-                break;
1488
-            case 'DTT_EVT_start':
1489
-                $orderby = array('Event.Datetime.DTT_EVT_start');
1490
-                break;
1491
-            default: //'REG_date'
1492
-                $orderby = array('REG_date');
1493
-        }
1494
-
1495
-        //order
1496
-        $order = ! empty($this->_req_data['order'])
1497
-            ? sanitize_text_field($this->_req_data['order'])
1498
-            : 'DESC';
1499
-        $orderby = array_combine(
1500
-            $orderby,
1501
-            array_fill(0, count($orderby), $order)
1502
-        );
1503
-        //because there are many registrations with the same date, define
1504
-        //a secondary way to order them, otherwise MySQL seems to be a bit random
1505
-        if (empty($orderby['REG_ID'])) {
1506
-            $orderby['REG_ID'] = $order;
1507
-        }
1508
-        return array('order_by' => $orderby);
1509
-    }
1510
-
1511
-
1512
-    /**
1513
-     * Sets up the limit for the registrations query.
1514
-     *
1515
-     * @param $per_page
1516
-     * @return array
1517
-     */
1518
-    protected function _get_limit($per_page)
1519
-    {
1520
-        $current_page = ! empty($this->_req_data['paged'])
1521
-            ? absint($this->_req_data['paged'])
1522
-            : 1;
1523
-        $per_page     = ! empty($this->_req_data['perpage'])
1524
-            ? $this->_req_data['perpage']
1525
-            : $per_page;
1526
-
1527
-        //-1 means return all results so get out if that's set.
1528
-        if ((int)$per_page === -1) {
1529
-            return array();
1530
-        }
1531
-        $per_page = absint($per_page);
1532
-        $offset   = ($current_page - 1) * $per_page;
1533
-        return array('limit' => array($offset, $per_page));
1534
-    }
1535
-
1536
-
1537
-    public function get_registration_status_array()
1538
-    {
1539
-        return self::$_reg_status;
1540
-    }
1541
-
1542
-
1543
-
1544
-
1545
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1546
-    /**
1547
-     *        generates HTML for the View Registration Details Admin page
1548
-     *
1549
-     * @access protected
1550
-     * @return void
1551
-     * @throws DomainException
1552
-     * @throws EE_Error
1553
-     * @throws InvalidArgumentException
1554
-     * @throws InvalidDataTypeException
1555
-     * @throws InvalidInterfaceException
1556
-     * @throws EntityNotFoundException
1557
-     */
1558
-    protected function _registration_details()
1559
-    {
1560
-        $this->_template_args = array();
1561
-        $this->_set_registration_object();
1562
-        if (is_object($this->_registration)) {
1563
-            $transaction                                   = $this->_registration->transaction()
1564
-                ? $this->_registration->transaction()
1565
-                : EE_Transaction::new_instance();
1566
-            $this->_session                                = $transaction->session_data();
1567
-            $event_id                                      = $this->_registration->event_ID();
1568
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1569
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1570
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1571
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1572
-            $this->_template_args['grand_total']           = $transaction->total();
1573
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1574
-            // link back to overview
1575
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1576
-            $this->_template_args['registration']                = $this->_registration;
1577
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1578
-                array(
1579
-                    'action'   => 'default',
1580
-                    'event_id' => $event_id,
1581
-                ),
1582
-                REG_ADMIN_URL
1583
-            );
1584
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1585
-                array(
1586
-                    'action' => 'default',
1587
-                    'EVT_ID' => $event_id,
1588
-                    'page'   => 'espresso_transactions',
1589
-                ),
1590
-                admin_url('admin.php')
1591
-            );
1592
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1593
-                array(
1594
-                    'page'   => 'espresso_events',
1595
-                    'action' => 'edit',
1596
-                    'post'   => $event_id,
1597
-                ),
1598
-                admin_url('admin.php')
1599
-            );
1600
-            //next and previous links
1601
-            $next_reg                                      = $this->_registration->next(
1602
-                null,
1603
-                array(),
1604
-                'REG_ID'
1605
-            );
1606
-            $this->_template_args['next_registration']     = $next_reg
1607
-                ? $this->_next_link(
1608
-                    EE_Admin_Page::add_query_args_and_nonce(
1609
-                        array(
1610
-                            'action'  => 'view_registration',
1611
-                            '_REG_ID' => $next_reg['REG_ID'],
1612
-                        ),
1613
-                        REG_ADMIN_URL
1614
-                    ),
1615
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1616
-                )
1617
-                : '';
1618
-            $previous_reg                                  = $this->_registration->previous(
1619
-                null,
1620
-                array(),
1621
-                'REG_ID'
1622
-            );
1623
-            $this->_template_args['previous_registration'] = $previous_reg
1624
-                ? $this->_previous_link(
1625
-                    EE_Admin_Page::add_query_args_and_nonce(
1626
-                        array(
1627
-                            'action'  => 'view_registration',
1628
-                            '_REG_ID' => $previous_reg['REG_ID'],
1629
-                        ),
1630
-                        REG_ADMIN_URL
1631
-                    ),
1632
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1633
-                )
1634
-                : '';
1635
-            // grab header
1636
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1637
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1638
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1639
-                $template_path,
1640
-                $this->_template_args,
1641
-                true
1642
-            );
1643
-        } else {
1644
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1645
-        }
1646
-        // the details template wrapper
1647
-        $this->display_admin_page_with_sidebar();
1648
-    }
1649
-
1650
-
1651
-    protected function _registration_details_metaboxes()
1652
-    {
1653
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1654
-        $this->_set_registration_object();
1655
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1656
-        add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'),
1657
-            array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1658
-        add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'),
1659
-            array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1660
-        if ($attendee instanceof EE_Attendee
1661
-            && EE_Registry::instance()->CAP->current_user_can(
1662
-                'ee_edit_registration',
1663
-                'edit-reg-questions-mbox',
1664
-                $this->_registration->ID()
1665
-            )
1666
-        ) {
1667
-            add_meta_box(
1668
-                'edit-reg-questions-mbox',
1669
-                esc_html__('Registration Form Answers', 'event_espresso'),
1670
-                array($this, '_reg_questions_meta_box'),
1671
-                $this->wp_page_slug,
1672
-                'normal',
1673
-                'high'
1674
-            );
1675
-        }
1676
-        add_meta_box(
1677
-            'edit-reg-registrant-mbox',
1678
-            esc_html__('Contact Details', 'event_espresso'),
1679
-            array($this, '_reg_registrant_side_meta_box'),
1680
-            $this->wp_page_slug,
1681
-            'side',
1682
-            'high'
1683
-        );
1684
-        if ($this->_registration->group_size() > 1) {
1685
-            add_meta_box(
1686
-                'edit-reg-attendees-mbox',
1687
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1688
-                array($this, '_reg_attendees_meta_box'),
1689
-                $this->wp_page_slug,
1690
-                'normal',
1691
-                'high'
1692
-            );
1693
-        }
1694
-    }
1695
-
1696
-
1697
-    /**
1698
-     * set_reg_status_buttons_metabox
1699
-     *
1700
-     * @access protected
1701
-     * @return string
1702
-     * @throws \EE_Error
1703
-     */
1704
-    public function set_reg_status_buttons_metabox()
1705
-    {
1706
-        $this->_set_registration_object();
1707
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1708
-        echo $change_reg_status_form->form_open(
1709
-            self::add_query_args_and_nonce(
1710
-                array(
1711
-                    'action' => 'change_reg_status',
1712
-                ),
1713
-                REG_ADMIN_URL
1714
-            )
1715
-        );
1716
-        echo $change_reg_status_form->get_html();
1717
-        echo $change_reg_status_form->form_close();
1718
-    }
1719
-
1720
-
1721
-    /**
1722
-     * @return EE_Form_Section_Proper
1723
-     * @throws EE_Error
1724
-     * @throws InvalidArgumentException
1725
-     * @throws InvalidDataTypeException
1726
-     * @throws InvalidInterfaceException
1727
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1728
-     */
1729
-    protected function _generate_reg_status_change_form()
1730
-    {
1731
-        return new EE_Form_Section_Proper(array(
1732
-            'name'            => 'reg_status_change_form',
1733
-            'html_id'         => 'reg-status-change-form',
1734
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1735
-            'subsections'     => array(
1736
-                'return'             => new EE_Hidden_Input(array(
1737
-                    'name'    => 'return',
1738
-                    'default' => 'view_registration',
1739
-                )),
1740
-                'REG_ID'             => new EE_Hidden_Input(array(
1741
-                    'name'    => 'REG_ID',
1742
-                    'default' => $this->_registration->ID(),
1743
-                )),
1744
-                'current_status'     => new EE_Form_Section_HTML(
1745
-                    EEH_HTML::tr(
1746
-                        EEH_HTML::th(
1747
-                            EEH_HTML::label(
1748
-                                EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso')
1749
-                                )
1750
-                            )
1751
-                        )
1752
-                        . EEH_HTML::td(
1753
-                            EEH_HTML::strong(
1754
-                                $this->_registration->pretty_status(),
1755
-                                '',
1756
-                                'status-' . $this->_registration->status_ID(),
1757
-                                'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1758
-                            )
1759
-                        )
1760
-                    )
1761
-                ),
1762
-                'reg_status'         => new EE_Select_Input(
1763
-                    $this->_get_reg_statuses(),
1764
-                    array(
1765
-                        'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1766
-                        'default'         => $this->_registration->status_ID(),
1767
-                    )
1768
-                ),
1769
-                'send_notifications' => new EE_Yes_No_Input(
1770
-                    array(
1771
-                        'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1772
-                        'default'         => false,
1773
-                        'html_help_text'  => esc_html__(
1774
-                            'If set to "Yes", then the related messages will be sent to the registrant.',
1775
-                            'event_espresso'
1776
-                        ),
1777
-                    )
1778
-                ),
1779
-                'submit'             => new EE_Submit_Input(
1780
-                    array(
1781
-                        'html_class'      => 'button-primary',
1782
-                        'html_label_text' => '&nbsp;',
1783
-                        'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1784
-                    )
1785
-                ),
1786
-            ),
1787
-        ));
1788
-    }
1789
-
1790
-
1791
-    /**
1792
-     * Returns an array of all the buttons for the various statuses and switch status actions
1793
-     *
1794
-     * @return array
1795
-     * @throws EE_Error
1796
-     * @throws InvalidArgumentException
1797
-     * @throws InvalidDataTypeException
1798
-     * @throws InvalidInterfaceException
1799
-     * @throws EntityNotFoundException
1800
-     */
1801
-    protected function _get_reg_statuses()
1802
-    {
1803
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1804
-        unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1805
-        // get current reg status
1806
-        $current_status = $this->_registration->status_ID();
1807
-        // is registration for free event? This will determine whether to display the pending payment option
1808
-        if (
1809
-            $current_status !== EEM_Registration::status_id_pending_payment
1810
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1811
-        ) {
1812
-            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1813
-        }
1814
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1815
-    }
1816
-
1817
-
1818
-    /**
1819
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1820
-     *
1821
-     * @param bool $status REG status given for changing registrations to.
1822
-     * @param bool $notify Whether to send messages notifications or not.
1823
-     * @return array (array with reg_id(s) updated and whether update was successful.
1824
-     * @throws EE_Error
1825
-     * @throws InvalidArgumentException
1826
-     * @throws InvalidDataTypeException
1827
-     * @throws InvalidInterfaceException
1828
-     * @throws ReflectionException
1829
-     * @throws RuntimeException
1830
-     * @throws EntityNotFoundException
1831
-     */
1832
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1833
-    {
1834
-        if (isset($this->_req_data['reg_status_change_form'])) {
1835
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1836
-                ? (array)$this->_req_data['reg_status_change_form']['REG_ID']
1837
-                : array();
1838
-        } else {
1839
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1840
-                ? (array)$this->_req_data['_REG_ID']
1841
-                : array();
1842
-        }
1843
-        // sanitize $REG_IDs
1844
-        $REG_IDs = array_map('absint', $REG_IDs);
1845
-        // and remove empty entries
1846
-        $REG_IDs = array_filter($REG_IDs);
1847
-
1848
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1849
-
1850
-        /**
1851
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1852
-         * Currently this value is used downstream by the _process_resend_registration method.
1853
-         *
1854
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1855
-         * @param bool                     $status           The status registrations were changed to.
1856
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1857
-         * @param Registrations_Admin_Page $admin_page_object
1858
-         */
1859
-        $this->_req_data['_REG_ID'] = apply_filters(
1860
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1861
-            $result['REG_ID'],
1862
-            $status,
1863
-            $result['success'],
1864
-            $this
1865
-        );
1866
-
1867
-        //notify?
1868
-        if ($notify
1869
-            && $result['success']
1870
-            && ! empty($this->_req_data['_REG_ID'])
1871
-            && EE_Registry::instance()->CAP->current_user_can(
1872
-                'ee_send_message',
1873
-                'espresso_registrations_resend_registration'
1874
-            )
1875
-        ) {
1876
-            $this->_process_resend_registration();
1877
-        }
1878
-        return $result;
1879
-    }
1880
-
1881
-
1882
-    /**
1883
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1884
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1885
-     *
1886
-     * @param array  $REG_IDs
1887
-     * @param string $status
1888
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1889
-     *                        slug sent with setting the registration status.
1890
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1891
-     * @throws EE_Error
1892
-     * @throws InvalidArgumentException
1893
-     * @throws InvalidDataTypeException
1894
-     * @throws InvalidInterfaceException
1895
-     * @throws ReflectionException
1896
-     * @throws RuntimeException
1897
-     * @throws EntityNotFoundException
1898
-     */
1899
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1900
-    {
1901
-        $success = false;
1902
-        // typecast $REG_IDs
1903
-        $REG_IDs = (array)$REG_IDs;
1904
-        if ( ! empty($REG_IDs)) {
1905
-            $success = true;
1906
-            // set default status if none is passed
1907
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1908
-            $status_context = $notify
1909
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1910
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1911
-            //loop through REG_ID's and change status
1912
-            foreach ($REG_IDs as $REG_ID) {
1913
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1914
-                if ($registration instanceof EE_Registration) {
1915
-                    $registration->set_status(
1916
-                        $status,
1917
-                        false,
1918
-                        new Context(
1919
-                            $status_context,
1920
-                            esc_html__(
1921
-                                'Manually triggered status change on a Registration Admin Page route.',
1922
-                                'event_espresso'
1923
-                            )
1924
-                        )
1925
-                    );
1926
-                    $result = $registration->save();
1927
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1928
-                    $success = $result !== false ? $success : false;
1929
-                }
1930
-            }
1931
-        }
1932
-
1933
-        //return $success and processed registrations
1934
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1935
-    }
1936
-
1937
-
1938
-    /**
1939
-     * Common logic for setting up success message and redirecting to appropriate route
1940
-     *
1941
-     * @param  string $STS_ID status id for the registration changed to
1942
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1943
-     * @return void
1944
-     * @throws EE_Error
1945
-     */
1946
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1947
-    {
1948
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1949
-            : array('success' => false);
1950
-        $success = isset($result['success']) && $result['success'];
1951
-        //setup success message
1952
-        if ($success) {
1953
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1954
-                $msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'),
1955
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1956
-            } else {
1957
-                $msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'),
1958
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1959
-            }
1960
-            EE_Error::add_success($msg);
1961
-        } else {
1962
-            EE_Error::add_error(
1963
-                esc_html__(
1964
-                    'Something went wrong, and the status was not changed',
1965
-                    'event_espresso'
1966
-                ), __FILE__, __LINE__, __FUNCTION__
1967
-            );
1968
-        }
1969
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1970
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1971
-        } else {
1972
-            $route = array('action' => 'default');
1973
-        }
1974
-        //unset nonces
1975
-        foreach ($this->_req_data as $ref => $value) {
1976
-            if (strpos($ref, 'nonce') !== false) {
1977
-                unset($this->_req_data[$ref]);
1978
-                continue;
1979
-            }
1980
-            $value                 = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1981
-            $this->_req_data[$ref] = $value;
1982
-        }
1983
-        //merge request vars so that the reloaded list table contains any existing filter query params
1984
-        $route = array_merge($this->_req_data, $route);
1985
-        $this->_redirect_after_action($success, '', '', $route, true);
1986
-    }
1987
-
1988
-
1989
-    /**
1990
-     * incoming reg status change from reg details page.
1991
-     *
1992
-     * @return void
1993
-     */
1994
-    protected function _change_reg_status()
1995
-    {
1996
-        $this->_req_data['return'] = 'view_registration';
1997
-        //set notify based on whether the send notifications toggle is set or not
1998
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1999
-        //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2000
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2001
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2002
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2003
-            case EEM_Registration::status_id_approved :
2004
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
2005
-                $this->approve_registration($notify);
2006
-                break;
2007
-            case EEM_Registration::status_id_pending_payment :
2008
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
2009
-                $this->pending_registration($notify);
2010
-                break;
2011
-            case EEM_Registration::status_id_not_approved :
2012
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
2013
-                $this->not_approve_registration($notify);
2014
-                break;
2015
-            case EEM_Registration::status_id_declined :
2016
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
2017
-                $this->decline_registration($notify);
2018
-                break;
2019
-            case EEM_Registration::status_id_cancelled :
2020
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
2021
-                $this->cancel_registration($notify);
2022
-                break;
2023
-            case EEM_Registration::status_id_wait_list :
2024
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
2025
-                $this->wait_list_registration($notify);
2026
-                break;
2027
-            case EEM_Registration::status_id_incomplete :
2028
-            default :
2029
-                $result['success'] = false;
2030
-                unset($this->_req_data['return']);
2031
-                $this->_reg_status_change_return('', false);
2032
-                break;
2033
-        }
2034
-    }
2035
-
2036
-
2037
-    /**
2038
-     * Callback for bulk action routes.
2039
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2040
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
2041
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2042
-     * when an action is happening on just a single registration).
2043
-     * @param      $action
2044
-     * @param bool $notify
2045
-     */
2046
-    protected function bulk_action_on_registrations($action, $notify = false) {
2047
-        do_action(
2048
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2049
-            $this,
2050
-            $action,
2051
-            $notify
2052
-        );
2053
-        $method = $action . '_registration';
2054
-        if (method_exists($this, $method)) {
2055
-            $this->$method($notify);
2056
-        }
2057
-    }
2058
-
2059
-
2060
-    /**
2061
-     * approve_registration
2062
-     *
2063
-     * @access protected
2064
-     * @param bool $notify whether or not to notify the registrant about their approval.
2065
-     * @return void
2066
-     */
2067
-    protected function approve_registration($notify = false)
2068
-    {
2069
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2070
-    }
2071
-
2072
-
2073
-    /**
2074
-     *        decline_registration
2075
-     *
2076
-     * @access protected
2077
-     * @param bool $notify whether or not to notify the registrant about their status change.
2078
-     * @return void
2079
-     */
2080
-    protected function decline_registration($notify = false)
2081
-    {
2082
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2083
-    }
2084
-
2085
-
2086
-    /**
2087
-     *        cancel_registration
2088
-     *
2089
-     * @access protected
2090
-     * @param bool $notify whether or not to notify the registrant about their status change.
2091
-     * @return void
2092
-     */
2093
-    protected function cancel_registration($notify = false)
2094
-    {
2095
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2096
-    }
2097
-
2098
-
2099
-    /**
2100
-     *        not_approve_registration
2101
-     *
2102
-     * @access protected
2103
-     * @param bool $notify whether or not to notify the registrant about their status change.
2104
-     * @return void
2105
-     */
2106
-    protected function not_approve_registration($notify = false)
2107
-    {
2108
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2109
-    }
2110
-
2111
-
2112
-    /**
2113
-     *        decline_registration
2114
-     *
2115
-     * @access protected
2116
-     * @param bool $notify whether or not to notify the registrant about their status change.
2117
-     * @return void
2118
-     */
2119
-    protected function pending_registration($notify = false)
2120
-    {
2121
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2122
-    }
2123
-
2124
-
2125
-    /**
2126
-     * waitlist_registration
2127
-     *
2128
-     * @access protected
2129
-     * @param bool $notify whether or not to notify the registrant about their status change.
2130
-     * @return void
2131
-     */
2132
-    protected function wait_list_registration($notify = false)
2133
-    {
2134
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     *        generates HTML for the Registration main meta box
2140
-     *
2141
-     * @access public
2142
-     * @return void
2143
-     * @throws DomainException
2144
-     * @throws EE_Error
2145
-     * @throws InvalidArgumentException
2146
-     * @throws InvalidDataTypeException
2147
-     * @throws InvalidInterfaceException
2148
-     * @throws ReflectionException
2149
-     * @throws EntityNotFoundException
2150
-     */
2151
-    public function _reg_details_meta_box()
2152
-    {
2153
-        EEH_Autoloader::register_line_item_display_autoloaders();
2154
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2155
-        EE_Registry::instance()->load_helper('Line_Item');
2156
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2157
-            : EE_Transaction::new_instance();
2158
-        $this->_session = $transaction->session_data();
2159
-        $filters        = new EE_Line_Item_Filter_Collection();
2160
-        //$filters->add( new EE_Non_Zero_Line_Item_Filter() );
2161
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2162
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor($filters,
2163
-            $transaction->total_line_item());
2164
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2165
-        $line_item_display                       = new EE_Line_Item_Display('reg_admin_table',
2166
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
2167
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2168
-            $filtered_line_item_tree,
2169
-            array('EE_Registration' => $this->_registration)
2170
-        );
2171
-        $attendee                                = $this->_registration->attendee();
2172
-        if (EE_Registry::instance()->CAP->current_user_can(
2173
-            'ee_read_transaction',
2174
-            'espresso_transactions_view_transaction'
2175
-        )) {
2176
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2177
-                EE_Admin_Page::add_query_args_and_nonce(
2178
-                    array(
2179
-                        'action' => 'view_transaction',
2180
-                        'TXN_ID' => $transaction->ID(),
2181
-                    ),
2182
-                    TXN_ADMIN_URL
2183
-                ),
2184
-                esc_html__(' View Transaction', 'event_espresso'),
2185
-                'button secondary-button right',
2186
-                'dashicons dashicons-cart'
2187
-            );
2188
-        } else {
2189
-            $this->_template_args['view_transaction_button'] = '';
2190
-        }
2191
-        if ($attendee instanceof EE_Attendee
2192
-            && EE_Registry::instance()->CAP->current_user_can(
2193
-                'ee_send_message',
2194
-                'espresso_registrations_resend_registration'
2195
-            )
2196
-        ) {
2197
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2198
-                EE_Admin_Page::add_query_args_and_nonce(
2199
-                    array(
2200
-                        'action'      => 'resend_registration',
2201
-                        '_REG_ID'     => $this->_registration->ID(),
2202
-                        'redirect_to' => 'view_registration',
2203
-                    ),
2204
-                    REG_ADMIN_URL
2205
-                ),
2206
-                esc_html__(' Resend Registration', 'event_espresso'),
2207
-                'button secondary-button right',
2208
-                'dashicons dashicons-email-alt'
2209
-            );
2210
-        } else {
2211
-            $this->_template_args['resend_registration_button'] = '';
2212
-        }
2213
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2214
-        $payment                               = $transaction->get_first_related('Payment');
2215
-        $payment                               = ! $payment instanceof EE_Payment
2216
-            ? EE_Payment::new_instance()
2217
-            : $payment;
2218
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2219
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2220
-            ? EE_Payment_Method::new_instance()
2221
-            : $payment_method;
2222
-        $reg_details                           = array(
2223
-            'payment_method'       => $payment_method->name(),
2224
-            'response_msg'         => $payment->gateway_response(),
2225
-            'registration_id'      => $this->_registration->get('REG_code'),
2226
-            'registration_session' => $this->_registration->session_ID(),
2227
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2228
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2229
-        );
2230
-        if (isset($reg_details['registration_id'])) {
2231
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2232
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2233
-                'Registration ID',
2234
-                'event_espresso'
2235
-            );
2236
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2237
-        }
2238
-        if (isset($reg_details['payment_method'])) {
2239
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2240
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2241
-                'Most Recent Payment Method',
2242
-                'event_espresso'
2243
-            );
2244
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2245
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2246
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2247
-                'Payment method response',
2248
-                'event_espresso'
2249
-            );
2250
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2251
-        }
2252
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2253
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2254
-            'Registration Session',
2255
-            'event_espresso'
2256
-        );
2257
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2258
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2259
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2260
-            'Registration placed from IP',
2261
-            'event_espresso'
2262
-        );
2263
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2264
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2265
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__('Registrant User Agent',
2266
-            'event_espresso');
2267
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2268
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2269
-            array(
2270
-                'action'   => 'default',
2271
-                'event_id' => $this->_registration->event_ID(),
2272
-            ),
2273
-            REG_ADMIN_URL
2274
-        );
2275
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2276
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2277
-        $template_path                                                        =
2278
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2279
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2280
-    }
2281
-
2282
-
2283
-    /**
2284
-     * generates HTML for the Registration Questions meta box.
2285
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2286
-     * otherwise uses new forms system
2287
-     *
2288
-     * @access public
2289
-     * @return void
2290
-     * @throws DomainException
2291
-     * @throws EE_Error
2292
-     */
2293
-    public function _reg_questions_meta_box()
2294
-    {
2295
-        //allow someone to override this method entirely
2296
-        if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
2297
-            $this->_registration)) {
2298
-            $form                                              = $this->_get_reg_custom_questions_form(
2299
-                $this->_registration->ID()
2300
-            );
2301
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2302
-                ? $form->get_html_and_js()
2303
-                : '';
2304
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2305
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2306
-            $template_path                                     =
2307
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2308
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2309
-        }
2310
-    }
2311
-
2312
-
2313
-    /**
2314
-     * form_before_question_group
2315
-     *
2316
-     * @deprecated    as of 4.8.32.rc.000
2317
-     * @access        public
2318
-     * @param        string $output
2319
-     * @return        string
2320
-     */
2321
-    public function form_before_question_group($output)
2322
-    {
2323
-        EE_Error::doing_it_wrong(
2324
-            __CLASS__ . '::' . __FUNCTION__,
2325
-            esc_html__(
2326
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2327
-                'event_espresso'
2328
-            ),
2329
-            '4.8.32.rc.000'
2330
-        );
2331
-        return '
1298
+		if (! empty($registration_status)) {
1299
+			$where['STS_ID'] = $registration_status;
1300
+		} else {
1301
+			//make sure we exclude incomplete registrations, but only if not trashed.
1302
+			if ($view === 'trash') {
1303
+				$where['REG_deleted'] = true;
1304
+			} elseif ($view === 'incomplete') {
1305
+				$where['STS_ID'] = EEM_Registration::status_id_incomplete;
1306
+			} else {
1307
+				$where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1308
+			}
1309
+		}
1310
+		return $where;
1311
+	}
1312
+
1313
+
1314
+	/**
1315
+	 * Adds any provided date restraints to the where conditions for the registrations query.
1316
+	 *
1317
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1318
+	 * @return array
1319
+	 * @throws EE_Error
1320
+	 * @throws InvalidArgumentException
1321
+	 * @throws InvalidDataTypeException
1322
+	 * @throws InvalidInterfaceException
1323
+	 */
1324
+	protected function _add_date_to_where_conditions(array $request)
1325
+	{
1326
+		$where = array();
1327
+		$view = EEH_Array::is_set($request, 'status', '');
1328
+		$month_range             = ! empty($request['month_range'])
1329
+			? sanitize_text_field($request['month_range'])
1330
+			: '';
1331
+		$retrieve_for_today      = $view === 'today';
1332
+		$retrieve_for_this_month = $view === 'month';
1333
+
1334
+		if ($retrieve_for_today) {
1335
+			$now               = date('Y-m-d', current_time('timestamp'));
1336
+			$where['REG_date'] = array(
1337
+				'BETWEEN',
1338
+				array(
1339
+					EEM_Registration::instance()->convert_datetime_for_query(
1340
+						'REG_date',
1341
+						$now . ' 00:00:00',
1342
+						'Y-m-d H:i:s'
1343
+					),
1344
+					EEM_Registration::instance()->convert_datetime_for_query(
1345
+						'REG_date',
1346
+						$now . ' 23:59:59',
1347
+						'Y-m-d H:i:s'
1348
+					),
1349
+				),
1350
+			);
1351
+		} elseif ($retrieve_for_this_month) {
1352
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
1353
+			$days_this_month        = date('t', current_time('timestamp'));
1354
+			$where['REG_date']      = array(
1355
+				'BETWEEN',
1356
+				array(
1357
+					EEM_Registration::instance()->convert_datetime_for_query(
1358
+						'REG_date',
1359
+						$current_year_and_month . '-01 00:00:00',
1360
+						'Y-m-d H:i:s'
1361
+					),
1362
+					EEM_Registration::instance()->convert_datetime_for_query(
1363
+						'REG_date',
1364
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1365
+						'Y-m-d H:i:s'
1366
+					),
1367
+				),
1368
+			);
1369
+		} elseif ($month_range) {
1370
+			$pieces          = explode(' ', $month_range, 3);
1371
+			$month_requested = ! empty($pieces[0])
1372
+				? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1373
+				: '';
1374
+			$year_requested  = ! empty($pieces[1])
1375
+				? $pieces[1]
1376
+				: '';
1377
+			//if there is not a month or year then we can't go further
1378
+			if ($month_requested && $year_requested) {
1379
+				$days_in_month     = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1380
+				$where['REG_date'] = array(
1381
+					'BETWEEN',
1382
+					array(
1383
+						EEM_Registration::instance()->convert_datetime_for_query(
1384
+							'REG_date',
1385
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
1386
+							'Y-m-d H:i:s'
1387
+						),
1388
+						EEM_Registration::instance()->convert_datetime_for_query(
1389
+							'REG_date',
1390
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1391
+							'Y-m-d H:i:s'
1392
+						),
1393
+					),
1394
+				);
1395
+			}
1396
+		}
1397
+		return $where;
1398
+	}
1399
+
1400
+
1401
+	/**
1402
+	 * Adds any provided search restraints to the where conditions for the registrations query
1403
+	 *
1404
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1405
+	 * @return array
1406
+	 */
1407
+	protected function _add_search_to_where_conditions(array $request)
1408
+	{
1409
+		$where = array();
1410
+		if (! empty($request['s'])) {
1411
+			$search_string = '%' . sanitize_text_field($request['s']) . '%';
1412
+			$where['OR*search_conditions'] = array(
1413
+				'Event.EVT_name'                          => array('LIKE', $search_string),
1414
+				'Event.EVT_desc'                          => array('LIKE', $search_string),
1415
+				'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1416
+				'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1417
+				'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1418
+				'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1419
+				'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1420
+				'Attendee.ATT_email'                      => array('LIKE', $search_string),
1421
+				'Attendee.ATT_address'                    => array('LIKE', $search_string),
1422
+				'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1423
+				'Attendee.ATT_city'                       => array('LIKE', $search_string),
1424
+				'REG_final_price'                         => array('LIKE', $search_string),
1425
+				'REG_code'                                => array('LIKE', $search_string),
1426
+				'REG_count'                               => array('LIKE', $search_string),
1427
+				'REG_group_size'                          => array('LIKE', $search_string),
1428
+				'Ticket.TKT_name'                         => array('LIKE', $search_string),
1429
+				'Ticket.TKT_description'                  => array('LIKE', $search_string),
1430
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1431
+			);
1432
+		}
1433
+		return $where;
1434
+	}
1435
+
1436
+
1437
+	/**
1438
+	 * Sets up the where conditions for the registrations query.
1439
+	 *
1440
+	 * @param array $request
1441
+	 * @return array
1442
+	 * @throws EE_Error
1443
+	 */
1444
+	protected function _get_where_conditions_for_registrations_query($request)
1445
+	{
1446
+		return apply_filters(
1447
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1448
+			array_merge(
1449
+				$this->addAttendeeIdToWhereConditions($request),
1450
+				$this->_add_event_id_to_where_conditions($request),
1451
+				$this->_add_category_id_to_where_conditions($request),
1452
+				$this->_add_datetime_id_to_where_conditions($request),
1453
+				$this->_add_registration_status_to_where_conditions($request),
1454
+				$this->_add_date_to_where_conditions($request),
1455
+				$this->_add_search_to_where_conditions($request)
1456
+			),
1457
+			$request
1458
+		);
1459
+	}
1460
+
1461
+
1462
+	/**
1463
+	 * Sets up the orderby for the registrations query.
1464
+	 *
1465
+	 * @return array
1466
+	 */
1467
+	protected function _get_orderby_for_registrations_query()
1468
+	{
1469
+		$orderby_field = ! empty($this->_req_data['orderby'])
1470
+			? sanitize_text_field($this->_req_data['orderby'])
1471
+			: '';
1472
+		switch ($orderby_field) {
1473
+			case '_REG_ID':
1474
+				$orderby = array('REG_ID');
1475
+				break;
1476
+			case '_Reg_status':
1477
+				$orderby = array('STS_ID');
1478
+				break;
1479
+			case 'ATT_fname':
1480
+				$orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1481
+				break;
1482
+			case 'ATT_lname':
1483
+				$orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1484
+				break;
1485
+			case 'event_name':
1486
+				$orderby = array('Event.EVT_name');
1487
+				break;
1488
+			case 'DTT_EVT_start':
1489
+				$orderby = array('Event.Datetime.DTT_EVT_start');
1490
+				break;
1491
+			default: //'REG_date'
1492
+				$orderby = array('REG_date');
1493
+		}
1494
+
1495
+		//order
1496
+		$order = ! empty($this->_req_data['order'])
1497
+			? sanitize_text_field($this->_req_data['order'])
1498
+			: 'DESC';
1499
+		$orderby = array_combine(
1500
+			$orderby,
1501
+			array_fill(0, count($orderby), $order)
1502
+		);
1503
+		//because there are many registrations with the same date, define
1504
+		//a secondary way to order them, otherwise MySQL seems to be a bit random
1505
+		if (empty($orderby['REG_ID'])) {
1506
+			$orderby['REG_ID'] = $order;
1507
+		}
1508
+		return array('order_by' => $orderby);
1509
+	}
1510
+
1511
+
1512
+	/**
1513
+	 * Sets up the limit for the registrations query.
1514
+	 *
1515
+	 * @param $per_page
1516
+	 * @return array
1517
+	 */
1518
+	protected function _get_limit($per_page)
1519
+	{
1520
+		$current_page = ! empty($this->_req_data['paged'])
1521
+			? absint($this->_req_data['paged'])
1522
+			: 1;
1523
+		$per_page     = ! empty($this->_req_data['perpage'])
1524
+			? $this->_req_data['perpage']
1525
+			: $per_page;
1526
+
1527
+		//-1 means return all results so get out if that's set.
1528
+		if ((int)$per_page === -1) {
1529
+			return array();
1530
+		}
1531
+		$per_page = absint($per_page);
1532
+		$offset   = ($current_page - 1) * $per_page;
1533
+		return array('limit' => array($offset, $per_page));
1534
+	}
1535
+
1536
+
1537
+	public function get_registration_status_array()
1538
+	{
1539
+		return self::$_reg_status;
1540
+	}
1541
+
1542
+
1543
+
1544
+
1545
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1546
+	/**
1547
+	 *        generates HTML for the View Registration Details Admin page
1548
+	 *
1549
+	 * @access protected
1550
+	 * @return void
1551
+	 * @throws DomainException
1552
+	 * @throws EE_Error
1553
+	 * @throws InvalidArgumentException
1554
+	 * @throws InvalidDataTypeException
1555
+	 * @throws InvalidInterfaceException
1556
+	 * @throws EntityNotFoundException
1557
+	 */
1558
+	protected function _registration_details()
1559
+	{
1560
+		$this->_template_args = array();
1561
+		$this->_set_registration_object();
1562
+		if (is_object($this->_registration)) {
1563
+			$transaction                                   = $this->_registration->transaction()
1564
+				? $this->_registration->transaction()
1565
+				: EE_Transaction::new_instance();
1566
+			$this->_session                                = $transaction->session_data();
1567
+			$event_id                                      = $this->_registration->event_ID();
1568
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1569
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1570
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1571
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1572
+			$this->_template_args['grand_total']           = $transaction->total();
1573
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1574
+			// link back to overview
1575
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1576
+			$this->_template_args['registration']                = $this->_registration;
1577
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1578
+				array(
1579
+					'action'   => 'default',
1580
+					'event_id' => $event_id,
1581
+				),
1582
+				REG_ADMIN_URL
1583
+			);
1584
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1585
+				array(
1586
+					'action' => 'default',
1587
+					'EVT_ID' => $event_id,
1588
+					'page'   => 'espresso_transactions',
1589
+				),
1590
+				admin_url('admin.php')
1591
+			);
1592
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1593
+				array(
1594
+					'page'   => 'espresso_events',
1595
+					'action' => 'edit',
1596
+					'post'   => $event_id,
1597
+				),
1598
+				admin_url('admin.php')
1599
+			);
1600
+			//next and previous links
1601
+			$next_reg                                      = $this->_registration->next(
1602
+				null,
1603
+				array(),
1604
+				'REG_ID'
1605
+			);
1606
+			$this->_template_args['next_registration']     = $next_reg
1607
+				? $this->_next_link(
1608
+					EE_Admin_Page::add_query_args_and_nonce(
1609
+						array(
1610
+							'action'  => 'view_registration',
1611
+							'_REG_ID' => $next_reg['REG_ID'],
1612
+						),
1613
+						REG_ADMIN_URL
1614
+					),
1615
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1616
+				)
1617
+				: '';
1618
+			$previous_reg                                  = $this->_registration->previous(
1619
+				null,
1620
+				array(),
1621
+				'REG_ID'
1622
+			);
1623
+			$this->_template_args['previous_registration'] = $previous_reg
1624
+				? $this->_previous_link(
1625
+					EE_Admin_Page::add_query_args_and_nonce(
1626
+						array(
1627
+							'action'  => 'view_registration',
1628
+							'_REG_ID' => $previous_reg['REG_ID'],
1629
+						),
1630
+						REG_ADMIN_URL
1631
+					),
1632
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1633
+				)
1634
+				: '';
1635
+			// grab header
1636
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1637
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1638
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1639
+				$template_path,
1640
+				$this->_template_args,
1641
+				true
1642
+			);
1643
+		} else {
1644
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1645
+		}
1646
+		// the details template wrapper
1647
+		$this->display_admin_page_with_sidebar();
1648
+	}
1649
+
1650
+
1651
+	protected function _registration_details_metaboxes()
1652
+	{
1653
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1654
+		$this->_set_registration_object();
1655
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1656
+		add_meta_box('edit-reg-status-mbox', esc_html__('Registration Status', 'event_espresso'),
1657
+			array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1658
+		add_meta_box('edit-reg-details-mbox', esc_html__('Registration Details', 'event_espresso'),
1659
+			array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1660
+		if ($attendee instanceof EE_Attendee
1661
+			&& EE_Registry::instance()->CAP->current_user_can(
1662
+				'ee_edit_registration',
1663
+				'edit-reg-questions-mbox',
1664
+				$this->_registration->ID()
1665
+			)
1666
+		) {
1667
+			add_meta_box(
1668
+				'edit-reg-questions-mbox',
1669
+				esc_html__('Registration Form Answers', 'event_espresso'),
1670
+				array($this, '_reg_questions_meta_box'),
1671
+				$this->wp_page_slug,
1672
+				'normal',
1673
+				'high'
1674
+			);
1675
+		}
1676
+		add_meta_box(
1677
+			'edit-reg-registrant-mbox',
1678
+			esc_html__('Contact Details', 'event_espresso'),
1679
+			array($this, '_reg_registrant_side_meta_box'),
1680
+			$this->wp_page_slug,
1681
+			'side',
1682
+			'high'
1683
+		);
1684
+		if ($this->_registration->group_size() > 1) {
1685
+			add_meta_box(
1686
+				'edit-reg-attendees-mbox',
1687
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1688
+				array($this, '_reg_attendees_meta_box'),
1689
+				$this->wp_page_slug,
1690
+				'normal',
1691
+				'high'
1692
+			);
1693
+		}
1694
+	}
1695
+
1696
+
1697
+	/**
1698
+	 * set_reg_status_buttons_metabox
1699
+	 *
1700
+	 * @access protected
1701
+	 * @return string
1702
+	 * @throws \EE_Error
1703
+	 */
1704
+	public function set_reg_status_buttons_metabox()
1705
+	{
1706
+		$this->_set_registration_object();
1707
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1708
+		echo $change_reg_status_form->form_open(
1709
+			self::add_query_args_and_nonce(
1710
+				array(
1711
+					'action' => 'change_reg_status',
1712
+				),
1713
+				REG_ADMIN_URL
1714
+			)
1715
+		);
1716
+		echo $change_reg_status_form->get_html();
1717
+		echo $change_reg_status_form->form_close();
1718
+	}
1719
+
1720
+
1721
+	/**
1722
+	 * @return EE_Form_Section_Proper
1723
+	 * @throws EE_Error
1724
+	 * @throws InvalidArgumentException
1725
+	 * @throws InvalidDataTypeException
1726
+	 * @throws InvalidInterfaceException
1727
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1728
+	 */
1729
+	protected function _generate_reg_status_change_form()
1730
+	{
1731
+		return new EE_Form_Section_Proper(array(
1732
+			'name'            => 'reg_status_change_form',
1733
+			'html_id'         => 'reg-status-change-form',
1734
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1735
+			'subsections'     => array(
1736
+				'return'             => new EE_Hidden_Input(array(
1737
+					'name'    => 'return',
1738
+					'default' => 'view_registration',
1739
+				)),
1740
+				'REG_ID'             => new EE_Hidden_Input(array(
1741
+					'name'    => 'REG_ID',
1742
+					'default' => $this->_registration->ID(),
1743
+				)),
1744
+				'current_status'     => new EE_Form_Section_HTML(
1745
+					EEH_HTML::tr(
1746
+						EEH_HTML::th(
1747
+							EEH_HTML::label(
1748
+								EEH_HTML::strong(esc_html__('Current Registration Status', 'event_espresso')
1749
+								)
1750
+							)
1751
+						)
1752
+						. EEH_HTML::td(
1753
+							EEH_HTML::strong(
1754
+								$this->_registration->pretty_status(),
1755
+								'',
1756
+								'status-' . $this->_registration->status_ID(),
1757
+								'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1758
+							)
1759
+						)
1760
+					)
1761
+				),
1762
+				'reg_status'         => new EE_Select_Input(
1763
+					$this->_get_reg_statuses(),
1764
+					array(
1765
+						'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1766
+						'default'         => $this->_registration->status_ID(),
1767
+					)
1768
+				),
1769
+				'send_notifications' => new EE_Yes_No_Input(
1770
+					array(
1771
+						'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1772
+						'default'         => false,
1773
+						'html_help_text'  => esc_html__(
1774
+							'If set to "Yes", then the related messages will be sent to the registrant.',
1775
+							'event_espresso'
1776
+						),
1777
+					)
1778
+				),
1779
+				'submit'             => new EE_Submit_Input(
1780
+					array(
1781
+						'html_class'      => 'button-primary',
1782
+						'html_label_text' => '&nbsp;',
1783
+						'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1784
+					)
1785
+				),
1786
+			),
1787
+		));
1788
+	}
1789
+
1790
+
1791
+	/**
1792
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1793
+	 *
1794
+	 * @return array
1795
+	 * @throws EE_Error
1796
+	 * @throws InvalidArgumentException
1797
+	 * @throws InvalidDataTypeException
1798
+	 * @throws InvalidInterfaceException
1799
+	 * @throws EntityNotFoundException
1800
+	 */
1801
+	protected function _get_reg_statuses()
1802
+	{
1803
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1804
+		unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1805
+		// get current reg status
1806
+		$current_status = $this->_registration->status_ID();
1807
+		// is registration for free event? This will determine whether to display the pending payment option
1808
+		if (
1809
+			$current_status !== EEM_Registration::status_id_pending_payment
1810
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1811
+		) {
1812
+			unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1813
+		}
1814
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1815
+	}
1816
+
1817
+
1818
+	/**
1819
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1820
+	 *
1821
+	 * @param bool $status REG status given for changing registrations to.
1822
+	 * @param bool $notify Whether to send messages notifications or not.
1823
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1824
+	 * @throws EE_Error
1825
+	 * @throws InvalidArgumentException
1826
+	 * @throws InvalidDataTypeException
1827
+	 * @throws InvalidInterfaceException
1828
+	 * @throws ReflectionException
1829
+	 * @throws RuntimeException
1830
+	 * @throws EntityNotFoundException
1831
+	 */
1832
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1833
+	{
1834
+		if (isset($this->_req_data['reg_status_change_form'])) {
1835
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1836
+				? (array)$this->_req_data['reg_status_change_form']['REG_ID']
1837
+				: array();
1838
+		} else {
1839
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1840
+				? (array)$this->_req_data['_REG_ID']
1841
+				: array();
1842
+		}
1843
+		// sanitize $REG_IDs
1844
+		$REG_IDs = array_map('absint', $REG_IDs);
1845
+		// and remove empty entries
1846
+		$REG_IDs = array_filter($REG_IDs);
1847
+
1848
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1849
+
1850
+		/**
1851
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1852
+		 * Currently this value is used downstream by the _process_resend_registration method.
1853
+		 *
1854
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1855
+		 * @param bool                     $status           The status registrations were changed to.
1856
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1857
+		 * @param Registrations_Admin_Page $admin_page_object
1858
+		 */
1859
+		$this->_req_data['_REG_ID'] = apply_filters(
1860
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1861
+			$result['REG_ID'],
1862
+			$status,
1863
+			$result['success'],
1864
+			$this
1865
+		);
1866
+
1867
+		//notify?
1868
+		if ($notify
1869
+			&& $result['success']
1870
+			&& ! empty($this->_req_data['_REG_ID'])
1871
+			&& EE_Registry::instance()->CAP->current_user_can(
1872
+				'ee_send_message',
1873
+				'espresso_registrations_resend_registration'
1874
+			)
1875
+		) {
1876
+			$this->_process_resend_registration();
1877
+		}
1878
+		return $result;
1879
+	}
1880
+
1881
+
1882
+	/**
1883
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1884
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1885
+	 *
1886
+	 * @param array  $REG_IDs
1887
+	 * @param string $status
1888
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1889
+	 *                        slug sent with setting the registration status.
1890
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1891
+	 * @throws EE_Error
1892
+	 * @throws InvalidArgumentException
1893
+	 * @throws InvalidDataTypeException
1894
+	 * @throws InvalidInterfaceException
1895
+	 * @throws ReflectionException
1896
+	 * @throws RuntimeException
1897
+	 * @throws EntityNotFoundException
1898
+	 */
1899
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1900
+	{
1901
+		$success = false;
1902
+		// typecast $REG_IDs
1903
+		$REG_IDs = (array)$REG_IDs;
1904
+		if ( ! empty($REG_IDs)) {
1905
+			$success = true;
1906
+			// set default status if none is passed
1907
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1908
+			$status_context = $notify
1909
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1910
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1911
+			//loop through REG_ID's and change status
1912
+			foreach ($REG_IDs as $REG_ID) {
1913
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1914
+				if ($registration instanceof EE_Registration) {
1915
+					$registration->set_status(
1916
+						$status,
1917
+						false,
1918
+						new Context(
1919
+							$status_context,
1920
+							esc_html__(
1921
+								'Manually triggered status change on a Registration Admin Page route.',
1922
+								'event_espresso'
1923
+							)
1924
+						)
1925
+					);
1926
+					$result = $registration->save();
1927
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1928
+					$success = $result !== false ? $success : false;
1929
+				}
1930
+			}
1931
+		}
1932
+
1933
+		//return $success and processed registrations
1934
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1935
+	}
1936
+
1937
+
1938
+	/**
1939
+	 * Common logic for setting up success message and redirecting to appropriate route
1940
+	 *
1941
+	 * @param  string $STS_ID status id for the registration changed to
1942
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1943
+	 * @return void
1944
+	 * @throws EE_Error
1945
+	 */
1946
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1947
+	{
1948
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1949
+			: array('success' => false);
1950
+		$success = isset($result['success']) && $result['success'];
1951
+		//setup success message
1952
+		if ($success) {
1953
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1954
+				$msg = sprintf(esc_html__('Registration status has been set to %s', 'event_espresso'),
1955
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1956
+			} else {
1957
+				$msg = sprintf(esc_html__('Registrations have been set to %s.', 'event_espresso'),
1958
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1959
+			}
1960
+			EE_Error::add_success($msg);
1961
+		} else {
1962
+			EE_Error::add_error(
1963
+				esc_html__(
1964
+					'Something went wrong, and the status was not changed',
1965
+					'event_espresso'
1966
+				), __FILE__, __LINE__, __FUNCTION__
1967
+			);
1968
+		}
1969
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1970
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1971
+		} else {
1972
+			$route = array('action' => 'default');
1973
+		}
1974
+		//unset nonces
1975
+		foreach ($this->_req_data as $ref => $value) {
1976
+			if (strpos($ref, 'nonce') !== false) {
1977
+				unset($this->_req_data[$ref]);
1978
+				continue;
1979
+			}
1980
+			$value                 = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1981
+			$this->_req_data[$ref] = $value;
1982
+		}
1983
+		//merge request vars so that the reloaded list table contains any existing filter query params
1984
+		$route = array_merge($this->_req_data, $route);
1985
+		$this->_redirect_after_action($success, '', '', $route, true);
1986
+	}
1987
+
1988
+
1989
+	/**
1990
+	 * incoming reg status change from reg details page.
1991
+	 *
1992
+	 * @return void
1993
+	 */
1994
+	protected function _change_reg_status()
1995
+	{
1996
+		$this->_req_data['return'] = 'view_registration';
1997
+		//set notify based on whether the send notifications toggle is set or not
1998
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1999
+		//$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2000
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2001
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2002
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2003
+			case EEM_Registration::status_id_approved :
2004
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
2005
+				$this->approve_registration($notify);
2006
+				break;
2007
+			case EEM_Registration::status_id_pending_payment :
2008
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
2009
+				$this->pending_registration($notify);
2010
+				break;
2011
+			case EEM_Registration::status_id_not_approved :
2012
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
2013
+				$this->not_approve_registration($notify);
2014
+				break;
2015
+			case EEM_Registration::status_id_declined :
2016
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
2017
+				$this->decline_registration($notify);
2018
+				break;
2019
+			case EEM_Registration::status_id_cancelled :
2020
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
2021
+				$this->cancel_registration($notify);
2022
+				break;
2023
+			case EEM_Registration::status_id_wait_list :
2024
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
2025
+				$this->wait_list_registration($notify);
2026
+				break;
2027
+			case EEM_Registration::status_id_incomplete :
2028
+			default :
2029
+				$result['success'] = false;
2030
+				unset($this->_req_data['return']);
2031
+				$this->_reg_status_change_return('', false);
2032
+				break;
2033
+		}
2034
+	}
2035
+
2036
+
2037
+	/**
2038
+	 * Callback for bulk action routes.
2039
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2040
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
2041
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2042
+	 * when an action is happening on just a single registration).
2043
+	 * @param      $action
2044
+	 * @param bool $notify
2045
+	 */
2046
+	protected function bulk_action_on_registrations($action, $notify = false) {
2047
+		do_action(
2048
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2049
+			$this,
2050
+			$action,
2051
+			$notify
2052
+		);
2053
+		$method = $action . '_registration';
2054
+		if (method_exists($this, $method)) {
2055
+			$this->$method($notify);
2056
+		}
2057
+	}
2058
+
2059
+
2060
+	/**
2061
+	 * approve_registration
2062
+	 *
2063
+	 * @access protected
2064
+	 * @param bool $notify whether or not to notify the registrant about their approval.
2065
+	 * @return void
2066
+	 */
2067
+	protected function approve_registration($notify = false)
2068
+	{
2069
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2070
+	}
2071
+
2072
+
2073
+	/**
2074
+	 *        decline_registration
2075
+	 *
2076
+	 * @access protected
2077
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2078
+	 * @return void
2079
+	 */
2080
+	protected function decline_registration($notify = false)
2081
+	{
2082
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2083
+	}
2084
+
2085
+
2086
+	/**
2087
+	 *        cancel_registration
2088
+	 *
2089
+	 * @access protected
2090
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2091
+	 * @return void
2092
+	 */
2093
+	protected function cancel_registration($notify = false)
2094
+	{
2095
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2096
+	}
2097
+
2098
+
2099
+	/**
2100
+	 *        not_approve_registration
2101
+	 *
2102
+	 * @access protected
2103
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2104
+	 * @return void
2105
+	 */
2106
+	protected function not_approve_registration($notify = false)
2107
+	{
2108
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2109
+	}
2110
+
2111
+
2112
+	/**
2113
+	 *        decline_registration
2114
+	 *
2115
+	 * @access protected
2116
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2117
+	 * @return void
2118
+	 */
2119
+	protected function pending_registration($notify = false)
2120
+	{
2121
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2122
+	}
2123
+
2124
+
2125
+	/**
2126
+	 * waitlist_registration
2127
+	 *
2128
+	 * @access protected
2129
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2130
+	 * @return void
2131
+	 */
2132
+	protected function wait_list_registration($notify = false)
2133
+	{
2134
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 *        generates HTML for the Registration main meta box
2140
+	 *
2141
+	 * @access public
2142
+	 * @return void
2143
+	 * @throws DomainException
2144
+	 * @throws EE_Error
2145
+	 * @throws InvalidArgumentException
2146
+	 * @throws InvalidDataTypeException
2147
+	 * @throws InvalidInterfaceException
2148
+	 * @throws ReflectionException
2149
+	 * @throws EntityNotFoundException
2150
+	 */
2151
+	public function _reg_details_meta_box()
2152
+	{
2153
+		EEH_Autoloader::register_line_item_display_autoloaders();
2154
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2155
+		EE_Registry::instance()->load_helper('Line_Item');
2156
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2157
+			: EE_Transaction::new_instance();
2158
+		$this->_session = $transaction->session_data();
2159
+		$filters        = new EE_Line_Item_Filter_Collection();
2160
+		//$filters->add( new EE_Non_Zero_Line_Item_Filter() );
2161
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2162
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor($filters,
2163
+			$transaction->total_line_item());
2164
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2165
+		$line_item_display                       = new EE_Line_Item_Display('reg_admin_table',
2166
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
2167
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2168
+			$filtered_line_item_tree,
2169
+			array('EE_Registration' => $this->_registration)
2170
+		);
2171
+		$attendee                                = $this->_registration->attendee();
2172
+		if (EE_Registry::instance()->CAP->current_user_can(
2173
+			'ee_read_transaction',
2174
+			'espresso_transactions_view_transaction'
2175
+		)) {
2176
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2177
+				EE_Admin_Page::add_query_args_and_nonce(
2178
+					array(
2179
+						'action' => 'view_transaction',
2180
+						'TXN_ID' => $transaction->ID(),
2181
+					),
2182
+					TXN_ADMIN_URL
2183
+				),
2184
+				esc_html__(' View Transaction', 'event_espresso'),
2185
+				'button secondary-button right',
2186
+				'dashicons dashicons-cart'
2187
+			);
2188
+		} else {
2189
+			$this->_template_args['view_transaction_button'] = '';
2190
+		}
2191
+		if ($attendee instanceof EE_Attendee
2192
+			&& EE_Registry::instance()->CAP->current_user_can(
2193
+				'ee_send_message',
2194
+				'espresso_registrations_resend_registration'
2195
+			)
2196
+		) {
2197
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2198
+				EE_Admin_Page::add_query_args_and_nonce(
2199
+					array(
2200
+						'action'      => 'resend_registration',
2201
+						'_REG_ID'     => $this->_registration->ID(),
2202
+						'redirect_to' => 'view_registration',
2203
+					),
2204
+					REG_ADMIN_URL
2205
+				),
2206
+				esc_html__(' Resend Registration', 'event_espresso'),
2207
+				'button secondary-button right',
2208
+				'dashicons dashicons-email-alt'
2209
+			);
2210
+		} else {
2211
+			$this->_template_args['resend_registration_button'] = '';
2212
+		}
2213
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2214
+		$payment                               = $transaction->get_first_related('Payment');
2215
+		$payment                               = ! $payment instanceof EE_Payment
2216
+			? EE_Payment::new_instance()
2217
+			: $payment;
2218
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2219
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2220
+			? EE_Payment_Method::new_instance()
2221
+			: $payment_method;
2222
+		$reg_details                           = array(
2223
+			'payment_method'       => $payment_method->name(),
2224
+			'response_msg'         => $payment->gateway_response(),
2225
+			'registration_id'      => $this->_registration->get('REG_code'),
2226
+			'registration_session' => $this->_registration->session_ID(),
2227
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2228
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2229
+		);
2230
+		if (isset($reg_details['registration_id'])) {
2231
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2232
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2233
+				'Registration ID',
2234
+				'event_espresso'
2235
+			);
2236
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2237
+		}
2238
+		if (isset($reg_details['payment_method'])) {
2239
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2240
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2241
+				'Most Recent Payment Method',
2242
+				'event_espresso'
2243
+			);
2244
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2245
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2246
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2247
+				'Payment method response',
2248
+				'event_espresso'
2249
+			);
2250
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2251
+		}
2252
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2253
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2254
+			'Registration Session',
2255
+			'event_espresso'
2256
+		);
2257
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2258
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2259
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2260
+			'Registration placed from IP',
2261
+			'event_espresso'
2262
+		);
2263
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2264
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2265
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__('Registrant User Agent',
2266
+			'event_espresso');
2267
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2268
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2269
+			array(
2270
+				'action'   => 'default',
2271
+				'event_id' => $this->_registration->event_ID(),
2272
+			),
2273
+			REG_ADMIN_URL
2274
+		);
2275
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2276
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2277
+		$template_path                                                        =
2278
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2279
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2280
+	}
2281
+
2282
+
2283
+	/**
2284
+	 * generates HTML for the Registration Questions meta box.
2285
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2286
+	 * otherwise uses new forms system
2287
+	 *
2288
+	 * @access public
2289
+	 * @return void
2290
+	 * @throws DomainException
2291
+	 * @throws EE_Error
2292
+	 */
2293
+	public function _reg_questions_meta_box()
2294
+	{
2295
+		//allow someone to override this method entirely
2296
+		if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
2297
+			$this->_registration)) {
2298
+			$form                                              = $this->_get_reg_custom_questions_form(
2299
+				$this->_registration->ID()
2300
+			);
2301
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2302
+				? $form->get_html_and_js()
2303
+				: '';
2304
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2305
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2306
+			$template_path                                     =
2307
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2308
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2309
+		}
2310
+	}
2311
+
2312
+
2313
+	/**
2314
+	 * form_before_question_group
2315
+	 *
2316
+	 * @deprecated    as of 4.8.32.rc.000
2317
+	 * @access        public
2318
+	 * @param        string $output
2319
+	 * @return        string
2320
+	 */
2321
+	public function form_before_question_group($output)
2322
+	{
2323
+		EE_Error::doing_it_wrong(
2324
+			__CLASS__ . '::' . __FUNCTION__,
2325
+			esc_html__(
2326
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2327
+				'event_espresso'
2328
+			),
2329
+			'4.8.32.rc.000'
2330
+		);
2331
+		return '
2332 2332
 	<table class="form-table ee-width-100">
2333 2333
 		<tbody>
2334 2334
 			';
2335
-    }
2336
-
2337
-
2338
-    /**
2339
-     * form_after_question_group
2340
-     *
2341
-     * @deprecated    as of 4.8.32.rc.000
2342
-     * @access        public
2343
-     * @param        string $output
2344
-     * @return        string
2345
-     */
2346
-    public function form_after_question_group($output)
2347
-    {
2348
-        EE_Error::doing_it_wrong(
2349
-            __CLASS__ . '::' . __FUNCTION__,
2350
-            esc_html__(
2351
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2352
-                'event_espresso'
2353
-            ),
2354
-            '4.8.32.rc.000'
2355
-        );
2356
-        return '
2335
+	}
2336
+
2337
+
2338
+	/**
2339
+	 * form_after_question_group
2340
+	 *
2341
+	 * @deprecated    as of 4.8.32.rc.000
2342
+	 * @access        public
2343
+	 * @param        string $output
2344
+	 * @return        string
2345
+	 */
2346
+	public function form_after_question_group($output)
2347
+	{
2348
+		EE_Error::doing_it_wrong(
2349
+			__CLASS__ . '::' . __FUNCTION__,
2350
+			esc_html__(
2351
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2352
+				'event_espresso'
2353
+			),
2354
+			'4.8.32.rc.000'
2355
+		);
2356
+		return '
2357 2357
 			<tr class="hide-if-no-js">
2358 2358
 				<th> </th>
2359 2359
 				<td class="reg-admin-edit-attendee-question-td">
2360 2360
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2361
-               . esc_attr__('click to edit question', 'event_espresso')
2362
-               . '">
2361
+			   . esc_attr__('click to edit question', 'event_espresso')
2362
+			   . '">
2363 2363
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2364
-               . esc_html__('edit the above question group', 'event_espresso')
2365
-               . '</span>
2364
+			   . esc_html__('edit the above question group', 'event_espresso')
2365
+			   . '</span>
2366 2366
 						<div class="dashicons dashicons-edit"></div>
2367 2367
 					</a>
2368 2368
 				</td>
@@ -2370,579 +2370,579 @@  discard block
 block discarded – undo
2370 2370
 		</tbody>
2371 2371
 	</table>
2372 2372
 ';
2373
-    }
2374
-
2375
-
2376
-    /**
2377
-     * form_form_field_label_wrap
2378
-     *
2379
-     * @deprecated    as of 4.8.32.rc.000
2380
-     * @access        public
2381
-     * @param        string $label
2382
-     * @return        string
2383
-     */
2384
-    public function form_form_field_label_wrap($label)
2385
-    {
2386
-        EE_Error::doing_it_wrong(
2387
-            __CLASS__ . '::' . __FUNCTION__,
2388
-            esc_html__(
2389
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2390
-                'event_espresso'
2391
-            ),
2392
-            '4.8.32.rc.000'
2393
-        );
2394
-        return '
2373
+	}
2374
+
2375
+
2376
+	/**
2377
+	 * form_form_field_label_wrap
2378
+	 *
2379
+	 * @deprecated    as of 4.8.32.rc.000
2380
+	 * @access        public
2381
+	 * @param        string $label
2382
+	 * @return        string
2383
+	 */
2384
+	public function form_form_field_label_wrap($label)
2385
+	{
2386
+		EE_Error::doing_it_wrong(
2387
+			__CLASS__ . '::' . __FUNCTION__,
2388
+			esc_html__(
2389
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2390
+				'event_espresso'
2391
+			),
2392
+			'4.8.32.rc.000'
2393
+		);
2394
+		return '
2395 2395
 			<tr>
2396 2396
 				<th>
2397 2397
 					' . $label . '
2398 2398
 				</th>';
2399
-    }
2400
-
2401
-
2402
-    /**
2403
-     * form_form_field_input__wrap
2404
-     *
2405
-     * @deprecated    as of 4.8.32.rc.000
2406
-     * @access        public
2407
-     * @param        string $input
2408
-     * @return        string
2409
-     */
2410
-    public function form_form_field_input__wrap($input)
2411
-    {
2412
-        EE_Error::doing_it_wrong(
2413
-            __CLASS__ . '::' . __FUNCTION__,
2414
-            esc_html__(
2415
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2416
-                'event_espresso'
2417
-            ),
2418
-            '4.8.32.rc.000'
2419
-        );
2420
-        return '
2399
+	}
2400
+
2401
+
2402
+	/**
2403
+	 * form_form_field_input__wrap
2404
+	 *
2405
+	 * @deprecated    as of 4.8.32.rc.000
2406
+	 * @access        public
2407
+	 * @param        string $input
2408
+	 * @return        string
2409
+	 */
2410
+	public function form_form_field_input__wrap($input)
2411
+	{
2412
+		EE_Error::doing_it_wrong(
2413
+			__CLASS__ . '::' . __FUNCTION__,
2414
+			esc_html__(
2415
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2416
+				'event_espresso'
2417
+			),
2418
+			'4.8.32.rc.000'
2419
+		);
2420
+		return '
2421 2421
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2422 2422
 					' . $input . '
2423 2423
 				</td>
2424 2424
 			</tr>';
2425
-    }
2426
-
2427
-
2428
-    /**
2429
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2430
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2431
-     * to display the page
2432
-     *
2433
-     * @access protected
2434
-     * @return void
2435
-     * @throws EE_Error
2436
-     */
2437
-    protected function _update_attendee_registration_form()
2438
-    {
2439
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2440
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2441
-            $REG_ID  = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2442
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2443
-            if ($success) {
2444
-                $what  = esc_html__('Registration Form', 'event_espresso');
2445
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2446
-                    : array('action' => 'default');
2447
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2448
-            }
2449
-        }
2450
-    }
2451
-
2452
-
2453
-    /**
2454
-     * Gets the form for saving registrations custom questions (if done
2455
-     * previously retrieves the cached form object, which may have validation errors in it)
2456
-     *
2457
-     * @param int $REG_ID
2458
-     * @return EE_Registration_Custom_Questions_Form
2459
-     * @throws EE_Error
2460
-     * @throws InvalidArgumentException
2461
-     * @throws InvalidDataTypeException
2462
-     * @throws InvalidInterfaceException
2463
-     */
2464
-    protected function _get_reg_custom_questions_form($REG_ID)
2465
-    {
2466
-        if ( ! $this->_reg_custom_questions_form) {
2467
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2468
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2469
-                EEM_Registration::instance()->get_one_by_ID($REG_ID)
2470
-            );
2471
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2472
-        }
2473
-        return $this->_reg_custom_questions_form;
2474
-    }
2475
-
2476
-
2477
-    /**
2478
-     * Saves
2479
-     *
2480
-     * @access private
2481
-     * @param bool $REG_ID
2482
-     * @return bool
2483
-     * @throws EE_Error
2484
-     * @throws InvalidArgumentException
2485
-     * @throws InvalidDataTypeException
2486
-     * @throws InvalidInterfaceException
2487
-     */
2488
-    private function _save_reg_custom_questions_form($REG_ID = false)
2489
-    {
2490
-        if ( ! $REG_ID) {
2491
-            EE_Error::add_error(
2492
-                esc_html__(
2493
-                    'An error occurred. No registration ID was received.', 'event_espresso'),
2494
-                __FILE__, __FUNCTION__, __LINE__
2495
-            );
2496
-        }
2497
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2498
-        $form->receive_form_submission($this->_req_data);
2499
-        $success = false;
2500
-        if ($form->is_valid()) {
2501
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2502
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2503
-                    $where_conditions    = array(
2504
-                        'QST_ID' => $question_id,
2505
-                        'REG_ID' => $REG_ID,
2506
-                    );
2507
-                    $possibly_new_values = array(
2508
-                        'ANS_value' => $input->normalized_value(),
2509
-                    );
2510
-                    $answer              = EEM_Answer::instance()->get_one(array($where_conditions));
2511
-                    if ($answer instanceof EE_Answer) {
2512
-                        $success = $answer->save($possibly_new_values);
2513
-                    } else {
2514
-                        //insert it then
2515
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2516
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2517
-                        $success     = $answer->save();
2518
-                    }
2519
-                }
2520
-            }
2521
-        } else {
2522
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2523
-        }
2524
-        return $success;
2525
-    }
2526
-
2527
-
2528
-    /**
2529
-     *        generates HTML for the Registration main meta box
2530
-     *
2531
-     * @access public
2532
-     * @return void
2533
-     * @throws DomainException
2534
-     * @throws EE_Error
2535
-     * @throws InvalidArgumentException
2536
-     * @throws InvalidDataTypeException
2537
-     * @throws InvalidInterfaceException
2538
-     */
2539
-    public function _reg_attendees_meta_box()
2540
-    {
2541
-        $REG = EEM_Registration::instance();
2542
-        //get all other registrations on this transaction, and cache
2543
-        //the attendees for them so we don't have to run another query using force_join
2544
-        $registrations                           = $REG->get_all(array(
2545
-            array(
2546
-                'TXN_ID' => $this->_registration->transaction_ID(),
2547
-                'REG_ID' => array('!=', $this->_registration->ID()),
2548
-            ),
2549
-            'force_join' => array('Attendee'),
2550
-        ));
2551
-        $this->_template_args['attendees']       = array();
2552
-        $this->_template_args['attendee_notice'] = '';
2553
-        if (empty($registrations)
2554
-            || (is_array($registrations)
2555
-                && ! EEH_Array::get_one_item_from_array($registrations))
2556
-        ) {
2557
-            EE_Error::add_error(
2558
-                esc_html__(
2559
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2560
-                    'event_espresso'
2561
-                ), __FILE__, __FUNCTION__, __LINE__
2562
-            );
2563
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2564
-        } else {
2565
-            $att_nmbr = 1;
2566
-            foreach ($registrations as $registration) {
2567
-                /* @var $registration EE_Registration */
2568
-                $attendee                                                    = $registration->attendee()
2569
-                    ? $registration->attendee()
2570
-                    : EEM_Attendee::instance()
2571
-                                  ->create_default_object();
2572
-                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2573
-                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2574
-                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2575
-                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2576
-                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2577
-                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2578
-                    ', ',
2579
-                    $attendee->full_address_as_array()
2580
-                );
2581
-                $this->_template_args['attendees'][$att_nmbr]['att_link']    = self::add_query_args_and_nonce(
2582
-                    array(
2583
-                        'action' => 'edit_attendee',
2584
-                        'post'   => $attendee->ID(),
2585
-                    ),
2586
-                    REG_ADMIN_URL
2587
-                );
2588
-                $this->_template_args['attendees'][$att_nmbr]['event_name']  = $registration->event_obj()->name();
2589
-                $att_nmbr++;
2590
-            }
2591
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2592
-        }
2593
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2594
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2595
-    }
2596
-
2597
-
2598
-    /**
2599
-     *        generates HTML for the Edit Registration side meta box
2600
-     *
2601
-     * @access public
2602
-     * @return void
2603
-     * @throws DomainException
2604
-     * @throws EE_Error
2605
-     * @throws InvalidArgumentException
2606
-     * @throws InvalidDataTypeException
2607
-     * @throws InvalidInterfaceException
2608
-     */
2609
-    public function _reg_registrant_side_meta_box()
2610
-    {
2611
-        /*@var $attendee EE_Attendee */
2612
-        $att_check = $this->_registration->attendee();
2613
-        $attendee  = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2614
-        //now let's determine if this is not the primary registration.  If it isn't then we set the
2615
-        //primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2616
-        //primary registration object (that way we know if we need to show create button or not)
2617
-        if ( ! $this->_registration->is_primary_registrant()) {
2618
-            $primary_registration = $this->_registration->get_primary_registration();
2619
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2620
-                : null;
2621
-            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2622
-                //in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2623
-                //custom attendee object so let's not worry about the primary reg.
2624
-                $primary_registration = null;
2625
-            }
2626
-        } else {
2627
-            $primary_registration = null;
2628
-        }
2629
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2630
-        $this->_template_args['fname']             = $attendee->fname();
2631
-        $this->_template_args['lname']             = $attendee->lname();
2632
-        $this->_template_args['email']             = $attendee->email();
2633
-        $this->_template_args['phone']             = $attendee->phone();
2634
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2635
-        //edit link
2636
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(array(
2637
-            'action' => 'edit_attendee',
2638
-            'post'   => $attendee->ID(),
2639
-        ), REG_ADMIN_URL);
2640
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2641
-        //create link
2642
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2643
-            ? EE_Admin_Page::add_query_args_and_nonce(array(
2644
-                'action'  => 'duplicate_attendee',
2645
-                '_REG_ID' => $this->_registration->ID(),
2646
-            ), REG_ADMIN_URL) : '';
2647
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2648
-        $this->_template_args['att_check']    = $att_check;
2649
-        $template_path                        = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2650
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2651
-    }
2652
-
2653
-
2654
-    /**
2655
-     * trash or restore registrations
2656
-     *
2657
-     * @param  boolean $trash whether to archive or restore
2658
-     * @return void
2659
-     * @throws EE_Error
2660
-     * @throws InvalidArgumentException
2661
-     * @throws InvalidDataTypeException
2662
-     * @throws InvalidInterfaceException
2663
-     * @throws RuntimeException
2664
-     * @access protected
2665
-     */
2666
-    protected function _trash_or_restore_registrations($trash = true)
2667
-    {
2668
-        //if empty _REG_ID then get out because there's nothing to do
2669
-        if (empty($this->_req_data['_REG_ID'])) {
2670
-            EE_Error::add_error(
2671
-                sprintf(
2672
-                    esc_html__(
2673
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2674
-                        'event_espresso'
2675
-                    ),
2676
-                    $trash ? 'trash' : 'restore'
2677
-                ),
2678
-                __FILE__, __LINE__, __FUNCTION__
2679
-            );
2680
-            $this->_redirect_after_action(false, '', '', array(), true);
2681
-        }
2682
-        $success = 0;
2683
-        $overwrite_msgs = false;
2684
-        //Checkboxes
2685
-        if ( ! is_array($this->_req_data['_REG_ID'])) {
2686
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2687
-        }
2688
-        $reg_count = count($this->_req_data['_REG_ID']);
2689
-        // cycle thru checkboxes
2690
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2691
-            /** @var EE_Registration $REG */
2692
-            $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2693
-            $payments = $REG->registration_payments();
2694
-            if (! empty($payments)) {
2695
-                $name = $REG->attendee() instanceof EE_Attendee
2696
-                    ? $REG->attendee()->full_name()
2697
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2698
-                $overwrite_msgs = true;
2699
-                EE_Error::add_error(
2700
-                    sprintf(
2701
-                        esc_html__(
2702
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2703
-                            'event_espresso'
2704
-                        ),
2705
-                        $name
2706
-                    ),
2707
-                    __FILE__, __FUNCTION__, __LINE__
2708
-                );
2709
-                //can't trash this registration because it has payments.
2710
-                continue;
2711
-            }
2712
-            $updated = $trash ? $REG->delete() : $REG->restore();
2713
-            if ($updated) {
2714
-                $success++;
2715
-            }
2716
-        }
2717
-        $this->_redirect_after_action(
2718
-            $success === $reg_count, // were ALL registrations affected?
2719
-            $success > 1
2720
-                ? esc_html__('Registrations', 'event_espresso')
2721
-                : esc_html__('Registration', 'event_espresso'),
2722
-            $trash
2723
-                ? esc_html__('moved to the trash', 'event_espresso')
2724
-                : esc_html__('restored', 'event_espresso'),
2725
-            array('action' => 'default'),
2726
-            $overwrite_msgs
2727
-        );
2728
-    }
2729
-
2730
-
2731
-    /**
2732
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2733
-     * registration but also.
2734
-     * 1. Removing relations to EE_Attendee
2735
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2736
-     * ALSO trashed.
2737
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2738
-     * 4. Removing relationships between all tickets and the related registrations
2739
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2740
-     * 6. Deleting permanently any related Checkins.
2741
-     *
2742
-     * @return void
2743
-     * @throws EE_Error
2744
-     * @throws InvalidArgumentException
2745
-     * @throws InvalidDataTypeException
2746
-     * @throws InvalidInterfaceException
2747
-     */
2748
-    protected function _delete_registrations()
2749
-    {
2750
-        $REG_MDL = EEM_Registration::instance();
2751
-        $success = 1;
2752
-        //Checkboxes
2753
-        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2754
-            // if array has more than one element than success message should be plural
2755
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2756
-            // cycle thru checkboxes
2757
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2758
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2759
-                if ( ! $REG instanceof EE_Registration) {
2760
-                    continue;
2761
-                }
2762
-                $deleted = $this->_delete_registration($REG);
2763
-                if ( ! $deleted) {
2764
-                    $success = 0;
2765
-                }
2766
-            }
2767
-        } else {
2768
-            // grab single id and delete
2769
-            $REG_ID  = $this->_req_data['_REG_ID'];
2770
-            $REG     = $REG_MDL->get_one_by_ID($REG_ID);
2771
-            $deleted = $this->_delete_registration($REG);
2772
-            if ( ! $deleted) {
2773
-                $success = 0;
2774
-            }
2775
-        }
2776
-        $what        = $success > 1
2777
-            ? esc_html__('Registrations', 'event_espresso')
2778
-            : esc_html__('Registration', 'event_espresso');
2779
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2780
-        $this->_redirect_after_action(
2781
-            $success,
2782
-            $what,
2783
-            $action_desc,
2784
-            array('action' => 'default'),
2785
-            true
2786
-        );
2787
-    }
2788
-
2789
-
2790
-    /**
2791
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2792
-     * models get affected.
2793
-     *
2794
-     * @param  EE_Registration $REG registration to be deleted permenantly
2795
-     * @return bool true = successful deletion, false = fail.
2796
-     * @throws EE_Error
2797
-     */
2798
-    protected function _delete_registration(EE_Registration $REG)
2799
-    {
2800
-        //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2801
-        //registrations on the transaction that are NOT trashed.
2802
-        $TXN         = $REG->get_first_related('Transaction');
2803
-        $REGS        = $TXN->get_many_related('Registration');
2804
-        $all_trashed = true;
2805
-        foreach ($REGS as $registration) {
2806
-            if ( ! $registration->get('REG_deleted')) {
2807
-                $all_trashed = false;
2808
-            }
2809
-        }
2810
-        if ( ! $all_trashed) {
2811
-            EE_Error::add_error(
2812
-                esc_html__(
2813
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2814
-                    'event_espresso'
2815
-                ),
2816
-                __FILE__, __FUNCTION__, __LINE__
2817
-            );
2818
-            return false;
2819
-        }
2820
-        //k made it here so that means we can delete all the related transactions and their answers (but let's do them
2821
-        //separately from THIS one).
2822
-        foreach ($REGS as $registration) {
2823
-            //delete related answers
2824
-            $registration->delete_related_permanently('Answer');
2825
-            //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2826
-            $attendee = $registration->get_first_related('Attendee');
2827
-            if ($attendee instanceof EE_Attendee) {
2828
-                $registration->_remove_relation_to($attendee, 'Attendee');
2829
-            }
2830
-            //now remove relationships to tickets on this registration.
2831
-            $registration->_remove_relations('Ticket');
2832
-            //now delete permanently the checkins related to this registration.
2833
-            $registration->delete_related_permanently('Checkin');
2834
-            if ($registration->ID() === $REG->ID()) {
2835
-                continue;
2836
-            } //we don't want to delete permanently the existing registration just yet.
2837
-            //remove relation to transaction for these registrations if NOT the existing registrations
2838
-            $registration->_remove_relations('Transaction');
2839
-            //delete permanently any related messages.
2840
-            $registration->delete_related_permanently('Message');
2841
-            //now delete this registration permanently
2842
-            $registration->delete_permanently();
2843
-        }
2844
-        //now all related registrations on the transaction are handled.  So let's just handle this registration itself
2845
-        // (the transaction and line items should be all that's left).
2846
-        // delete the line items related to the transaction for this registration.
2847
-        $TXN->delete_related_permanently('Line_Item');
2848
-        //we need to remove all the relationships on the transaction
2849
-        $TXN->delete_related_permanently('Payment');
2850
-        $TXN->delete_related_permanently('Extra_Meta');
2851
-        $TXN->delete_related_permanently('Message');
2852
-        //now we can delete this REG permanently (and the transaction of course)
2853
-        $REG->delete_related_permanently('Transaction');
2854
-        return $REG->delete_permanently();
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     *    generates HTML for the Register New Attendee Admin page
2860
-     *
2861
-     * @access private
2862
-     * @throws DomainException
2863
-     * @throws EE_Error
2864
-     */
2865
-    public function new_registration()
2866
-    {
2867
-        if ( ! $this->_set_reg_event()) {
2868
-            throw new EE_Error(
2869
-                esc_html__(
2870
-                    'Unable to continue with registering because there is no Event ID in the request',
2871
-                    'event_espresso'
2872
-                )
2873
-            );
2874
-        }
2875
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2876
-        // gotta start with a clean slate if we're not coming here via ajax
2877
-        if ( ! defined('DOING_AJAX')
2878
-             && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2879
-        ) {
2880
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2881
-        }
2882
-        $this->_template_args['event_name'] = '';
2883
-        // event name
2884
-        if ($this->_reg_event) {
2885
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2886
-            $edit_event_url                     = self::add_query_args_and_nonce(array(
2887
-                'action' => 'edit',
2888
-                'post'   => $this->_reg_event->ID(),
2889
-            ), EVENTS_ADMIN_URL);
2890
-            $edit_event_lnk                     = '<a href="'
2891
-                                                  . $edit_event_url
2892
-                                                  . '" title="'
2893
-                                                  . esc_attr__('Edit ', 'event_espresso')
2894
-                                                  . $this->_reg_event->name()
2895
-                                                  . '">'
2896
-                                                  . esc_html__('Edit Event', 'event_espresso')
2897
-                                                  . '</a>';
2898
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2899
-                                                   . $edit_event_lnk
2900
-                                                   . '</span>';
2901
-        }
2902
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2903
-        if (defined('DOING_AJAX')) {
2904
-            $this->_return_json();
2905
-        }
2906
-        // grab header
2907
-        $template_path                              =
2908
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2909
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2910
-            $this->_template_args, true);
2911
-        //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2912
-        // the details template wrapper
2913
-        $this->display_admin_page_with_sidebar();
2914
-    }
2915
-
2916
-
2917
-    /**
2918
-     * This returns the content for a registration step
2919
-     *
2920
-     * @access protected
2921
-     * @return string html
2922
-     * @throws DomainException
2923
-     * @throws EE_Error
2924
-     * @throws InvalidArgumentException
2925
-     * @throws InvalidDataTypeException
2926
-     * @throws InvalidInterfaceException
2927
-     */
2928
-    protected function _get_registration_step_content()
2929
-    {
2930
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2931
-            $warning_msg = sprintf(
2932
-                esc_html__(
2933
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2934
-                    'event_espresso'
2935
-                ),
2936
-                '<br />',
2937
-                '<h3 class="important-notice">',
2938
-                '</h3>',
2939
-                '<div class="float-right">',
2940
-                '<span id="redirect_timer" class="important-notice">30</span>',
2941
-                '</div>',
2942
-                '<b>',
2943
-                '</b>'
2944
-            );
2945
-            return '
2425
+	}
2426
+
2427
+
2428
+	/**
2429
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2430
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2431
+	 * to display the page
2432
+	 *
2433
+	 * @access protected
2434
+	 * @return void
2435
+	 * @throws EE_Error
2436
+	 */
2437
+	protected function _update_attendee_registration_form()
2438
+	{
2439
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2440
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2441
+			$REG_ID  = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2442
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2443
+			if ($success) {
2444
+				$what  = esc_html__('Registration Form', 'event_espresso');
2445
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2446
+					: array('action' => 'default');
2447
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2448
+			}
2449
+		}
2450
+	}
2451
+
2452
+
2453
+	/**
2454
+	 * Gets the form for saving registrations custom questions (if done
2455
+	 * previously retrieves the cached form object, which may have validation errors in it)
2456
+	 *
2457
+	 * @param int $REG_ID
2458
+	 * @return EE_Registration_Custom_Questions_Form
2459
+	 * @throws EE_Error
2460
+	 * @throws InvalidArgumentException
2461
+	 * @throws InvalidDataTypeException
2462
+	 * @throws InvalidInterfaceException
2463
+	 */
2464
+	protected function _get_reg_custom_questions_form($REG_ID)
2465
+	{
2466
+		if ( ! $this->_reg_custom_questions_form) {
2467
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2468
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2469
+				EEM_Registration::instance()->get_one_by_ID($REG_ID)
2470
+			);
2471
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2472
+		}
2473
+		return $this->_reg_custom_questions_form;
2474
+	}
2475
+
2476
+
2477
+	/**
2478
+	 * Saves
2479
+	 *
2480
+	 * @access private
2481
+	 * @param bool $REG_ID
2482
+	 * @return bool
2483
+	 * @throws EE_Error
2484
+	 * @throws InvalidArgumentException
2485
+	 * @throws InvalidDataTypeException
2486
+	 * @throws InvalidInterfaceException
2487
+	 */
2488
+	private function _save_reg_custom_questions_form($REG_ID = false)
2489
+	{
2490
+		if ( ! $REG_ID) {
2491
+			EE_Error::add_error(
2492
+				esc_html__(
2493
+					'An error occurred. No registration ID was received.', 'event_espresso'),
2494
+				__FILE__, __FUNCTION__, __LINE__
2495
+			);
2496
+		}
2497
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2498
+		$form->receive_form_submission($this->_req_data);
2499
+		$success = false;
2500
+		if ($form->is_valid()) {
2501
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2502
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2503
+					$where_conditions    = array(
2504
+						'QST_ID' => $question_id,
2505
+						'REG_ID' => $REG_ID,
2506
+					);
2507
+					$possibly_new_values = array(
2508
+						'ANS_value' => $input->normalized_value(),
2509
+					);
2510
+					$answer              = EEM_Answer::instance()->get_one(array($where_conditions));
2511
+					if ($answer instanceof EE_Answer) {
2512
+						$success = $answer->save($possibly_new_values);
2513
+					} else {
2514
+						//insert it then
2515
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2516
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2517
+						$success     = $answer->save();
2518
+					}
2519
+				}
2520
+			}
2521
+		} else {
2522
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2523
+		}
2524
+		return $success;
2525
+	}
2526
+
2527
+
2528
+	/**
2529
+	 *        generates HTML for the Registration main meta box
2530
+	 *
2531
+	 * @access public
2532
+	 * @return void
2533
+	 * @throws DomainException
2534
+	 * @throws EE_Error
2535
+	 * @throws InvalidArgumentException
2536
+	 * @throws InvalidDataTypeException
2537
+	 * @throws InvalidInterfaceException
2538
+	 */
2539
+	public function _reg_attendees_meta_box()
2540
+	{
2541
+		$REG = EEM_Registration::instance();
2542
+		//get all other registrations on this transaction, and cache
2543
+		//the attendees for them so we don't have to run another query using force_join
2544
+		$registrations                           = $REG->get_all(array(
2545
+			array(
2546
+				'TXN_ID' => $this->_registration->transaction_ID(),
2547
+				'REG_ID' => array('!=', $this->_registration->ID()),
2548
+			),
2549
+			'force_join' => array('Attendee'),
2550
+		));
2551
+		$this->_template_args['attendees']       = array();
2552
+		$this->_template_args['attendee_notice'] = '';
2553
+		if (empty($registrations)
2554
+			|| (is_array($registrations)
2555
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2556
+		) {
2557
+			EE_Error::add_error(
2558
+				esc_html__(
2559
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2560
+					'event_espresso'
2561
+				), __FILE__, __FUNCTION__, __LINE__
2562
+			);
2563
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2564
+		} else {
2565
+			$att_nmbr = 1;
2566
+			foreach ($registrations as $registration) {
2567
+				/* @var $registration EE_Registration */
2568
+				$attendee                                                    = $registration->attendee()
2569
+					? $registration->attendee()
2570
+					: EEM_Attendee::instance()
2571
+								  ->create_default_object();
2572
+				$this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2573
+				$this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2574
+				$this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2575
+				$this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2576
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2577
+				$this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2578
+					', ',
2579
+					$attendee->full_address_as_array()
2580
+				);
2581
+				$this->_template_args['attendees'][$att_nmbr]['att_link']    = self::add_query_args_and_nonce(
2582
+					array(
2583
+						'action' => 'edit_attendee',
2584
+						'post'   => $attendee->ID(),
2585
+					),
2586
+					REG_ADMIN_URL
2587
+				);
2588
+				$this->_template_args['attendees'][$att_nmbr]['event_name']  = $registration->event_obj()->name();
2589
+				$att_nmbr++;
2590
+			}
2591
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2592
+		}
2593
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2594
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2595
+	}
2596
+
2597
+
2598
+	/**
2599
+	 *        generates HTML for the Edit Registration side meta box
2600
+	 *
2601
+	 * @access public
2602
+	 * @return void
2603
+	 * @throws DomainException
2604
+	 * @throws EE_Error
2605
+	 * @throws InvalidArgumentException
2606
+	 * @throws InvalidDataTypeException
2607
+	 * @throws InvalidInterfaceException
2608
+	 */
2609
+	public function _reg_registrant_side_meta_box()
2610
+	{
2611
+		/*@var $attendee EE_Attendee */
2612
+		$att_check = $this->_registration->attendee();
2613
+		$attendee  = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2614
+		//now let's determine if this is not the primary registration.  If it isn't then we set the
2615
+		//primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2616
+		//primary registration object (that way we know if we need to show create button or not)
2617
+		if ( ! $this->_registration->is_primary_registrant()) {
2618
+			$primary_registration = $this->_registration->get_primary_registration();
2619
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2620
+				: null;
2621
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2622
+				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2623
+				//custom attendee object so let's not worry about the primary reg.
2624
+				$primary_registration = null;
2625
+			}
2626
+		} else {
2627
+			$primary_registration = null;
2628
+		}
2629
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2630
+		$this->_template_args['fname']             = $attendee->fname();
2631
+		$this->_template_args['lname']             = $attendee->lname();
2632
+		$this->_template_args['email']             = $attendee->email();
2633
+		$this->_template_args['phone']             = $attendee->phone();
2634
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2635
+		//edit link
2636
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(array(
2637
+			'action' => 'edit_attendee',
2638
+			'post'   => $attendee->ID(),
2639
+		), REG_ADMIN_URL);
2640
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2641
+		//create link
2642
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2643
+			? EE_Admin_Page::add_query_args_and_nonce(array(
2644
+				'action'  => 'duplicate_attendee',
2645
+				'_REG_ID' => $this->_registration->ID(),
2646
+			), REG_ADMIN_URL) : '';
2647
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2648
+		$this->_template_args['att_check']    = $att_check;
2649
+		$template_path                        = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2650
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2651
+	}
2652
+
2653
+
2654
+	/**
2655
+	 * trash or restore registrations
2656
+	 *
2657
+	 * @param  boolean $trash whether to archive or restore
2658
+	 * @return void
2659
+	 * @throws EE_Error
2660
+	 * @throws InvalidArgumentException
2661
+	 * @throws InvalidDataTypeException
2662
+	 * @throws InvalidInterfaceException
2663
+	 * @throws RuntimeException
2664
+	 * @access protected
2665
+	 */
2666
+	protected function _trash_or_restore_registrations($trash = true)
2667
+	{
2668
+		//if empty _REG_ID then get out because there's nothing to do
2669
+		if (empty($this->_req_data['_REG_ID'])) {
2670
+			EE_Error::add_error(
2671
+				sprintf(
2672
+					esc_html__(
2673
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2674
+						'event_espresso'
2675
+					),
2676
+					$trash ? 'trash' : 'restore'
2677
+				),
2678
+				__FILE__, __LINE__, __FUNCTION__
2679
+			);
2680
+			$this->_redirect_after_action(false, '', '', array(), true);
2681
+		}
2682
+		$success = 0;
2683
+		$overwrite_msgs = false;
2684
+		//Checkboxes
2685
+		if ( ! is_array($this->_req_data['_REG_ID'])) {
2686
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2687
+		}
2688
+		$reg_count = count($this->_req_data['_REG_ID']);
2689
+		// cycle thru checkboxes
2690
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2691
+			/** @var EE_Registration $REG */
2692
+			$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2693
+			$payments = $REG->registration_payments();
2694
+			if (! empty($payments)) {
2695
+				$name = $REG->attendee() instanceof EE_Attendee
2696
+					? $REG->attendee()->full_name()
2697
+					: esc_html__('Unknown Attendee', 'event_espresso');
2698
+				$overwrite_msgs = true;
2699
+				EE_Error::add_error(
2700
+					sprintf(
2701
+						esc_html__(
2702
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2703
+							'event_espresso'
2704
+						),
2705
+						$name
2706
+					),
2707
+					__FILE__, __FUNCTION__, __LINE__
2708
+				);
2709
+				//can't trash this registration because it has payments.
2710
+				continue;
2711
+			}
2712
+			$updated = $trash ? $REG->delete() : $REG->restore();
2713
+			if ($updated) {
2714
+				$success++;
2715
+			}
2716
+		}
2717
+		$this->_redirect_after_action(
2718
+			$success === $reg_count, // were ALL registrations affected?
2719
+			$success > 1
2720
+				? esc_html__('Registrations', 'event_espresso')
2721
+				: esc_html__('Registration', 'event_espresso'),
2722
+			$trash
2723
+				? esc_html__('moved to the trash', 'event_espresso')
2724
+				: esc_html__('restored', 'event_espresso'),
2725
+			array('action' => 'default'),
2726
+			$overwrite_msgs
2727
+		);
2728
+	}
2729
+
2730
+
2731
+	/**
2732
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2733
+	 * registration but also.
2734
+	 * 1. Removing relations to EE_Attendee
2735
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2736
+	 * ALSO trashed.
2737
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2738
+	 * 4. Removing relationships between all tickets and the related registrations
2739
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2740
+	 * 6. Deleting permanently any related Checkins.
2741
+	 *
2742
+	 * @return void
2743
+	 * @throws EE_Error
2744
+	 * @throws InvalidArgumentException
2745
+	 * @throws InvalidDataTypeException
2746
+	 * @throws InvalidInterfaceException
2747
+	 */
2748
+	protected function _delete_registrations()
2749
+	{
2750
+		$REG_MDL = EEM_Registration::instance();
2751
+		$success = 1;
2752
+		//Checkboxes
2753
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2754
+			// if array has more than one element than success message should be plural
2755
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2756
+			// cycle thru checkboxes
2757
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2758
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2759
+				if ( ! $REG instanceof EE_Registration) {
2760
+					continue;
2761
+				}
2762
+				$deleted = $this->_delete_registration($REG);
2763
+				if ( ! $deleted) {
2764
+					$success = 0;
2765
+				}
2766
+			}
2767
+		} else {
2768
+			// grab single id and delete
2769
+			$REG_ID  = $this->_req_data['_REG_ID'];
2770
+			$REG     = $REG_MDL->get_one_by_ID($REG_ID);
2771
+			$deleted = $this->_delete_registration($REG);
2772
+			if ( ! $deleted) {
2773
+				$success = 0;
2774
+			}
2775
+		}
2776
+		$what        = $success > 1
2777
+			? esc_html__('Registrations', 'event_espresso')
2778
+			: esc_html__('Registration', 'event_espresso');
2779
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2780
+		$this->_redirect_after_action(
2781
+			$success,
2782
+			$what,
2783
+			$action_desc,
2784
+			array('action' => 'default'),
2785
+			true
2786
+		);
2787
+	}
2788
+
2789
+
2790
+	/**
2791
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2792
+	 * models get affected.
2793
+	 *
2794
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2795
+	 * @return bool true = successful deletion, false = fail.
2796
+	 * @throws EE_Error
2797
+	 */
2798
+	protected function _delete_registration(EE_Registration $REG)
2799
+	{
2800
+		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2801
+		//registrations on the transaction that are NOT trashed.
2802
+		$TXN         = $REG->get_first_related('Transaction');
2803
+		$REGS        = $TXN->get_many_related('Registration');
2804
+		$all_trashed = true;
2805
+		foreach ($REGS as $registration) {
2806
+			if ( ! $registration->get('REG_deleted')) {
2807
+				$all_trashed = false;
2808
+			}
2809
+		}
2810
+		if ( ! $all_trashed) {
2811
+			EE_Error::add_error(
2812
+				esc_html__(
2813
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2814
+					'event_espresso'
2815
+				),
2816
+				__FILE__, __FUNCTION__, __LINE__
2817
+			);
2818
+			return false;
2819
+		}
2820
+		//k made it here so that means we can delete all the related transactions and their answers (but let's do them
2821
+		//separately from THIS one).
2822
+		foreach ($REGS as $registration) {
2823
+			//delete related answers
2824
+			$registration->delete_related_permanently('Answer');
2825
+			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2826
+			$attendee = $registration->get_first_related('Attendee');
2827
+			if ($attendee instanceof EE_Attendee) {
2828
+				$registration->_remove_relation_to($attendee, 'Attendee');
2829
+			}
2830
+			//now remove relationships to tickets on this registration.
2831
+			$registration->_remove_relations('Ticket');
2832
+			//now delete permanently the checkins related to this registration.
2833
+			$registration->delete_related_permanently('Checkin');
2834
+			if ($registration->ID() === $REG->ID()) {
2835
+				continue;
2836
+			} //we don't want to delete permanently the existing registration just yet.
2837
+			//remove relation to transaction for these registrations if NOT the existing registrations
2838
+			$registration->_remove_relations('Transaction');
2839
+			//delete permanently any related messages.
2840
+			$registration->delete_related_permanently('Message');
2841
+			//now delete this registration permanently
2842
+			$registration->delete_permanently();
2843
+		}
2844
+		//now all related registrations on the transaction are handled.  So let's just handle this registration itself
2845
+		// (the transaction and line items should be all that's left).
2846
+		// delete the line items related to the transaction for this registration.
2847
+		$TXN->delete_related_permanently('Line_Item');
2848
+		//we need to remove all the relationships on the transaction
2849
+		$TXN->delete_related_permanently('Payment');
2850
+		$TXN->delete_related_permanently('Extra_Meta');
2851
+		$TXN->delete_related_permanently('Message');
2852
+		//now we can delete this REG permanently (and the transaction of course)
2853
+		$REG->delete_related_permanently('Transaction');
2854
+		return $REG->delete_permanently();
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 *    generates HTML for the Register New Attendee Admin page
2860
+	 *
2861
+	 * @access private
2862
+	 * @throws DomainException
2863
+	 * @throws EE_Error
2864
+	 */
2865
+	public function new_registration()
2866
+	{
2867
+		if ( ! $this->_set_reg_event()) {
2868
+			throw new EE_Error(
2869
+				esc_html__(
2870
+					'Unable to continue with registering because there is no Event ID in the request',
2871
+					'event_espresso'
2872
+				)
2873
+			);
2874
+		}
2875
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2876
+		// gotta start with a clean slate if we're not coming here via ajax
2877
+		if ( ! defined('DOING_AJAX')
2878
+			 && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2879
+		) {
2880
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2881
+		}
2882
+		$this->_template_args['event_name'] = '';
2883
+		// event name
2884
+		if ($this->_reg_event) {
2885
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2886
+			$edit_event_url                     = self::add_query_args_and_nonce(array(
2887
+				'action' => 'edit',
2888
+				'post'   => $this->_reg_event->ID(),
2889
+			), EVENTS_ADMIN_URL);
2890
+			$edit_event_lnk                     = '<a href="'
2891
+												  . $edit_event_url
2892
+												  . '" title="'
2893
+												  . esc_attr__('Edit ', 'event_espresso')
2894
+												  . $this->_reg_event->name()
2895
+												  . '">'
2896
+												  . esc_html__('Edit Event', 'event_espresso')
2897
+												  . '</a>';
2898
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2899
+												   . $edit_event_lnk
2900
+												   . '</span>';
2901
+		}
2902
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2903
+		if (defined('DOING_AJAX')) {
2904
+			$this->_return_json();
2905
+		}
2906
+		// grab header
2907
+		$template_path                              =
2908
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2909
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2910
+			$this->_template_args, true);
2911
+		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2912
+		// the details template wrapper
2913
+		$this->display_admin_page_with_sidebar();
2914
+	}
2915
+
2916
+
2917
+	/**
2918
+	 * This returns the content for a registration step
2919
+	 *
2920
+	 * @access protected
2921
+	 * @return string html
2922
+	 * @throws DomainException
2923
+	 * @throws EE_Error
2924
+	 * @throws InvalidArgumentException
2925
+	 * @throws InvalidDataTypeException
2926
+	 * @throws InvalidInterfaceException
2927
+	 */
2928
+	protected function _get_registration_step_content()
2929
+	{
2930
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2931
+			$warning_msg = sprintf(
2932
+				esc_html__(
2933
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2934
+					'event_espresso'
2935
+				),
2936
+				'<br />',
2937
+				'<h3 class="important-notice">',
2938
+				'</h3>',
2939
+				'<div class="float-right">',
2940
+				'<span id="redirect_timer" class="important-notice">30</span>',
2941
+				'</div>',
2942
+				'<b>',
2943
+				'</b>'
2944
+			);
2945
+			return '
2946 2946
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2947 2947
 	<script >
2948 2948
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2955,841 +2955,841 @@  discard block
 block discarded – undo
2955 2955
 	        }
2956 2956
 	    }, 800 );
2957 2957
 	</script >';
2958
-        }
2959
-        $template_args = array(
2960
-            'title'                    => '',
2961
-            'content'                  => '',
2962
-            'step_button_text'         => '',
2963
-            'show_notification_toggle' => false,
2964
-        );
2965
-        //to indicate we're processing a new registration
2966
-        $hidden_fields = array(
2967
-            'processing_registration' => array(
2968
-                'type'  => 'hidden',
2969
-                'value' => 0,
2970
-            ),
2971
-            'event_id'                => array(
2972
-                'type'  => 'hidden',
2973
-                'value' => $this->_reg_event->ID(),
2974
-            ),
2975
-        );
2976
-        //if the cart is empty then we know we're at step one so we'll display ticket selector
2977
-        $cart = EE_Registry::instance()->SSN->cart();
2978
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2979
-        switch ($step) {
2980
-            case 'ticket' :
2981
-                $hidden_fields['processing_registration']['value'] = 1;
2982
-                $template_args['title']                            = esc_html__(
2983
-                    'Step One: Select the Ticket for this registration',
2984
-                    'event_espresso'
2985
-                );
2986
-                $template_args['content']                          =
2987
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2988
-                $template_args['step_button_text']                 = esc_html__(
2989
-                    'Add Tickets and Continue to Registrant Details',
2990
-                    'event_espresso'
2991
-                );
2992
-                $template_args['show_notification_toggle']         = false;
2993
-                break;
2994
-            case 'questions' :
2995
-                $hidden_fields['processing_registration']['value'] = 2;
2996
-                $template_args['title']                            = esc_html__(
2997
-                    'Step Two: Add Registrant Details for this Registration',
2998
-                    'event_espresso'
2999
-                );
3000
-                //in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3001
-                // properly by the first process_reg_step run.
3002
-                $template_args['content']                  =
3003
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
3004
-                $template_args['step_button_text']         = esc_html__(
3005
-                    'Save Registration and Continue to Details',
3006
-                    'event_espresso'
3007
-                );
3008
-                $template_args['show_notification_toggle'] = true;
3009
-                break;
3010
-        }
3011
-        //we come back to the process_registration_step route.
3012
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3013
-        return EEH_Template::display_template(
3014
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3015
-            $template_args,
3016
-            true
3017
-        );
3018
-    }
3019
-
3020
-
3021
-    /**
3022
-     *        set_reg_event
3023
-     *
3024
-     * @access private
3025
-     * @return bool
3026
-     * @throws EE_Error
3027
-     * @throws InvalidArgumentException
3028
-     * @throws InvalidDataTypeException
3029
-     * @throws InvalidInterfaceException
3030
-     */
3031
-    private function _set_reg_event()
3032
-    {
3033
-        if (is_object($this->_reg_event)) {
3034
-            return true;
3035
-        }
3036
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3037
-        if ( ! $EVT_ID) {
3038
-            return false;
3039
-        }
3040
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3041
-        return true;
3042
-    }
3043
-
3044
-
3045
-    /**
3046
-     * process_reg_step
3047
-     *
3048
-     * @access        public
3049
-     * @return string
3050
-     * @throws DomainException
3051
-     * @throws EE_Error
3052
-     * @throws InvalidArgumentException
3053
-     * @throws InvalidDataTypeException
3054
-     * @throws InvalidInterfaceException
3055
-     * @throws ReflectionException
3056
-     * @throws RuntimeException
3057
-     */
3058
-    public function process_reg_step()
3059
-    {
3060
-        EE_System::do_not_cache();
3061
-        $this->_set_reg_event();
3062
-        EE_Registry::instance()->REQ->set_espresso_page(true);
3063
-        EE_Registry::instance()->REQ->set('uts', time());
3064
-        //what step are we on?
3065
-        $cart = EE_Registry::instance()->SSN->cart();
3066
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3067
-        //if doing ajax then we need to verify the nonce
3068
-        if (defined('DOING_AJAX')) {
3069
-            $nonce = isset($this->_req_data[$this->_req_nonce])
3070
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
3071
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3072
-        }
3073
-        switch ($step) {
3074
-            case 'ticket' :
3075
-                //process ticket selection
3076
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3077
-                if ($success) {
3078
-                    EE_Error::add_success(
3079
-                        esc_html__(
3080
-                            'Tickets Selected. Now complete the registration.',
3081
-                            'event_espresso'
3082
-                        )
3083
-                    );
3084
-                } else {
3085
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3086
-                }
3087
-                if (defined('DOING_AJAX')) {
3088
-                    $this->new_registration(); //display next step
3089
-                } else {
3090
-                    $query_args = array(
3091
-                        'action'                  => 'new_registration',
3092
-                        'processing_registration' => 1,
3093
-                        'event_id'                => $this->_reg_event->ID(),
3094
-                        'uts'                     => time(),
3095
-                    );
3096
-                    $this->_redirect_after_action(
3097
-                        false,
3098
-                        '',
3099
-                        '',
3100
-                        $query_args,
3101
-                        true
3102
-                    );
3103
-                }
3104
-                break;
3105
-            case 'questions' :
3106
-                if (! isset(
3107
-                    $this->_req_data['txn_reg_status_change'],
3108
-                    $this->_req_data['txn_reg_status_change']['send_notifications'])
3109
-                ) {
3110
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3111
-                }
3112
-                //process registration
3113
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3114
-                if ($cart instanceof EE_Cart) {
3115
-                    $grand_total = $cart->get_cart_grand_total();
3116
-                    if ($grand_total instanceof EE_Line_Item) {
3117
-                        $grand_total->save_this_and_descendants_to_txn();
3118
-                    }
3119
-                }
3120
-                if ( ! $transaction instanceof EE_Transaction) {
3121
-                    $query_args = array(
3122
-                        'action'                  => 'new_registration',
3123
-                        'processing_registration' => 2,
3124
-                        'event_id'                => $this->_reg_event->ID(),
3125
-                        'uts'                     => time(),
3126
-                    );
3127
-                    if (defined('DOING_AJAX')) {
3128
-                        //display registration form again because there are errors (maybe validation?)
3129
-                        $this->new_registration();
3130
-                        return;
3131
-                    } else {
3132
-                        $this->_redirect_after_action(
3133
-                            false,
3134
-                            '',
3135
-                            '',
3136
-                            $query_args,
3137
-                            true
3138
-                        );
3139
-                        return;
3140
-                    }
3141
-                }
3142
-                // maybe update status, and make sure to save transaction if not done already
3143
-                if ( ! $transaction->update_status_based_on_total_paid()) {
3144
-                    $transaction->save();
3145
-                }
3146
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3147
-                $this->_req_data = array();
3148
-                $query_args      = array(
3149
-                    'action'        => 'redirect_to_txn',
3150
-                    'TXN_ID'        => $transaction->ID(),
3151
-                    'EVT_ID'        => $this->_reg_event->ID(),
3152
-                    'event_name'    => urlencode($this->_reg_event->name()),
3153
-                    'redirect_from' => 'new_registration',
3154
-                );
3155
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3156
-                break;
3157
-        }
3158
-        //what are you looking here for?  Should be nothing to do at this point.
3159
-    }
3160
-
3161
-
3162
-    /**
3163
-     * redirect_to_txn
3164
-     *
3165
-     * @access public
3166
-     * @return void
3167
-     * @throws EE_Error
3168
-     * @throws InvalidArgumentException
3169
-     * @throws InvalidDataTypeException
3170
-     * @throws InvalidInterfaceException
3171
-     */
3172
-    public function redirect_to_txn()
3173
-    {
3174
-        EE_System::do_not_cache();
3175
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3176
-        $query_args = array(
3177
-            'action' => 'view_transaction',
3178
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3179
-            'page'   => 'espresso_transactions',
3180
-        );
3181
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3182
-            $query_args['EVT_ID']        = $this->_req_data['EVT_ID'];
3183
-            $query_args['event_name']    = urlencode($this->_req_data['event_name']);
3184
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3185
-        }
3186
-        EE_Error::add_success(
3187
-            esc_html__(
3188
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3189
-                'event_espresso'
3190
-            )
3191
-        );
3192
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3193
-    }
3194
-
3195
-
3196
-    /**
3197
-     *        generates HTML for the Attendee Contact List
3198
-     *
3199
-     * @access protected
3200
-     * @return void
3201
-     */
3202
-    protected function _attendee_contact_list_table()
3203
-    {
3204
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3205
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3206
-        $this->display_admin_list_table_page_with_no_sidebar();
3207
-    }
3208
-
3209
-
3210
-    /**
3211
-     *        get_attendees
3212
-     *
3213
-     * @param      $per_page
3214
-     * @param bool $count whether to return count or data.
3215
-     * @param bool $trash
3216
-     * @return array
3217
-     * @throws EE_Error
3218
-     * @throws InvalidArgumentException
3219
-     * @throws InvalidDataTypeException
3220
-     * @throws InvalidInterfaceException
3221
-     * @access public
3222
-     */
3223
-    public function get_attendees($per_page, $count = false, $trash = false)
3224
-    {
3225
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3226
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3227
-        $ATT_MDL                    = EEM_Attendee::instance();
3228
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3229
-        switch ($this->_req_data['orderby']) {
3230
-            case 'ATT_ID':
3231
-                $orderby = 'ATT_ID';
3232
-                break;
3233
-            case 'ATT_fname':
3234
-                $orderby = 'ATT_fname';
3235
-                break;
3236
-            case 'ATT_email':
3237
-                $orderby = 'ATT_email';
3238
-                break;
3239
-            case 'ATT_city':
3240
-                $orderby = 'ATT_city';
3241
-                break;
3242
-            case 'STA_ID':
3243
-                $orderby = 'STA_ID';
3244
-                break;
3245
-            case 'CNT_ID':
3246
-                $orderby = 'CNT_ID';
3247
-                break;
3248
-            case 'Registration_Count':
3249
-                $orderby = 'Registration_Count';
3250
-                break;
3251
-            default:
3252
-                $orderby = 'ATT_lname';
3253
-        }
3254
-        $sort         = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3255
-            ? $this->_req_data['order']
3256
-            : 'ASC';
3257
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3258
-            ? $this->_req_data['paged']
3259
-            : 1;
3260
-        $per_page     = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3261
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3262
-            ? $this->_req_data['perpage']
3263
-            : $per_page;
3264
-        $_where       = array();
3265
-        if ( ! empty($this->_req_data['s'])) {
3266
-            $sstr         = '%' . $this->_req_data['s'] . '%';
3267
-            $_where['OR'] = array(
3268
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3269
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3270
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3271
-                'ATT_fname'                         => array('LIKE', $sstr),
3272
-                'ATT_lname'                         => array('LIKE', $sstr),
3273
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3274
-                'ATT_email'                         => array('LIKE', $sstr),
3275
-                'ATT_address'                       => array('LIKE', $sstr),
3276
-                'ATT_address2'                      => array('LIKE', $sstr),
3277
-                'ATT_city'                          => array('LIKE', $sstr),
3278
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3279
-                'State.STA_name'                    => array('LIKE', $sstr),
3280
-                'ATT_phone'                         => array('LIKE', $sstr),
3281
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3282
-                'Registration.REG_code'             => array('LIKE', $sstr),
3283
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3284
-            );
3285
-        }
3286
-        $offset = ($current_page - 1) * $per_page;
3287
-        $limit  = $count ? null : array($offset, $per_page);
3288
-        $query_args = array(
3289
-            $_where,
3290
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3291
-            'limit' => $limit
3292
-        );
3293
-        if (! $count) {
3294
-            $query_args['order_by'] = array($orderby => $sort);
3295
-        }
3296
-        if ($trash) {
3297
-            $query_args[0]['status'] = array('!=', 'publish');
3298
-            $all_attendees    = $count
3299
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3300
-                : $ATT_MDL->get_all($query_args);
3301
-        } else {
3302
-            $query_args[0]['status'] = array('IN', array('publish'));
3303
-            $all_attendees    = $count
3304
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3305
-                : $ATT_MDL->get_all($query_args);
3306
-        }
3307
-        return $all_attendees;
3308
-    }
3309
-
3310
-
3311
-    /**
3312
-     * This is just taking care of resending the registration confirmation
3313
-     *
3314
-     * @access protected
3315
-     * @return void
3316
-     */
3317
-    protected function _resend_registration()
3318
-    {
3319
-        $this->_process_resend_registration();
3320
-        $query_args = isset($this->_req_data['redirect_to'])
3321
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3322
-            : array('action' => 'default');
3323
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3324
-    }
3325
-
3326
-    /**
3327
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3328
-     * to use when selecting registrations
3329
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3330
-     *                                                     the query parameters from the request
3331
-     * @return void ends the request with a redirect or download
3332
-     */
3333
-    public function _registrations_report_base( $method_name_for_getting_query_params )
3334
-    {
3335
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3336
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
3337
-                array(
3338
-                    'page'        => 'espresso_batch',
3339
-                    'batch'       => 'file',
3340
-                    'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3341
-                    'filters'     => urlencode(
3342
-                        serialize(
3343
-                            call_user_func(
3344
-                                array( $this, $method_name_for_getting_query_params ),
3345
-                                EEH_Array::is_set(
3346
-                                    $this->_req_data,
3347
-                                    'filters',
3348
-                                    array()
3349
-                                )
3350
-                            )
3351
-                        )
3352
-                ),
3353
-                'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3354
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3355
-                'return_url'  => urlencode($this->_req_data['return_url']),
3356
-            )));
3357
-        } else {
3358
-            $new_request_args = array(
3359
-                'export' => 'report',
3360
-                'action' => 'registrations_report_for_event',
3361
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3362
-            );
3363
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3364
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3365
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3366
-                $EE_Export = EE_Export::instance($this->_req_data);
3367
-                $EE_Export->export();
3368
-            }
3369
-        }
3370
-    }
3371
-
3372
-
3373
-
3374
-    /**
3375
-     * Creates a registration report using only query parameters in the request
3376
-     * @return void
3377
-     */
3378
-    public function _registrations_report()
3379
-    {
3380
-        $this->_registrations_report_base('_get_registration_query_parameters');
3381
-    }
3382
-
3383
-
3384
-    public function _contact_list_export()
3385
-    {
3386
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3387
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3388
-            $EE_Export = EE_Export::instance($this->_req_data);
3389
-            $EE_Export->export_attendees();
3390
-        }
3391
-    }
3392
-
3393
-
3394
-    public function _contact_list_report()
3395
-    {
3396
-        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3397
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
3398
-                'page'        => 'espresso_batch',
3399
-                'batch'       => 'file',
3400
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3401
-                'return_url'  => urlencode($this->_req_data['return_url']),
3402
-            )));
3403
-        } else {
3404
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3405
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3406
-                $EE_Export = EE_Export::instance($this->_req_data);
3407
-                $EE_Export->report_attendees();
3408
-            }
3409
-        }
3410
-    }
3411
-
3412
-
3413
-
3414
-
3415
-
3416
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3417
-    /**
3418
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3419
-     *
3420
-     * @return void
3421
-     * @throws EE_Error
3422
-     * @throws InvalidArgumentException
3423
-     * @throws InvalidDataTypeException
3424
-     * @throws InvalidInterfaceException
3425
-     */
3426
-    protected function _duplicate_attendee()
3427
-    {
3428
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3429
-        //verify we have necessary info
3430
-        if (empty($this->_req_data['_REG_ID'])) {
3431
-            EE_Error::add_error(
3432
-                esc_html__(
3433
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3434
-                    'event_espresso'
3435
-                ), __FILE__, __LINE__, __FUNCTION__
3436
-            );
3437
-            $query_args = array('action' => $action);
3438
-            $this->_redirect_after_action('', '', '', $query_args, true);
3439
-        }
3440
-        //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3441
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3442
-        $attendee     = $registration->attendee();
3443
-        //remove relation of existing attendee on registration
3444
-        $registration->_remove_relation_to($attendee, 'Attendee');
3445
-        //new attendee
3446
-        $new_attendee = clone $attendee;
3447
-        $new_attendee->set('ATT_ID', 0);
3448
-        $new_attendee->save();
3449
-        //add new attendee to reg
3450
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3451
-        EE_Error::add_success(
3452
-            esc_html__(
3453
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3454
-                'event_espresso'
3455
-            )
3456
-        );
3457
-        //redirect to edit page for attendee
3458
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3459
-        $this->_redirect_after_action('', '', '', $query_args, true);
3460
-    }
3461
-
3462
-
3463
-    /**
3464
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3465
-     * @param int      $post_id
3466
-     * @param WP_POST $post
3467
-     * @throws DomainException
3468
-     * @throws EE_Error
3469
-     * @throws InvalidArgumentException
3470
-     * @throws InvalidDataTypeException
3471
-     * @throws InvalidInterfaceException
3472
-     * @throws LogicException
3473
-     * @throws InvalidFormSubmissionException
3474
-     */
3475
-    protected function _insert_update_cpt_item($post_id, $post)
3476
-    {
3477
-        $success  = true;
3478
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3479
-            ? EEM_Attendee::instance()->get_one_by_ID($post_id)
3480
-            : null;
3481
-        //for attendee updates
3482
-        if ($attendee instanceof EE_Attendee) {
3483
-            //note we should only be UPDATING attendees at this point.
3484
-            $updated_fields = array(
3485
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3486
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3487
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3488
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3489
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3490
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3491
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3492
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3493
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3494
-            );
3495
-            foreach ($updated_fields as $field => $value) {
3496
-                $attendee->set($field, $value);
3497
-            }
3498
-
3499
-            //process contact details metabox form handler (which will also save the attendee)
3500
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3501
-            $success = $contact_details_form->process($this->_req_data);
3502
-
3503
-            $attendee_update_callbacks = apply_filters(
3504
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3505
-                array()
3506
-            );
3507
-            foreach ($attendee_update_callbacks as $a_callback) {
3508
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3509
-                    throw new EE_Error(
3510
-                        sprintf(
3511
-                            esc_html__(
3512
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3513
-                                'event_espresso'
3514
-                            ),
3515
-                            $a_callback
3516
-                        )
3517
-                    );
3518
-                }
3519
-            }
3520
-        }
3521
-
3522
-        if ($success === false) {
3523
-            EE_Error::add_error(
3524
-                esc_html__(
3525
-                    'Something went wrong with updating the meta table data for the registration.',
3526
-                    'event_espresso'
3527
-                ),
3528
-                __FILE__, __FUNCTION__, __LINE__
3529
-            );
3530
-        }
3531
-    }
3532
-
3533
-
3534
-    public function trash_cpt_item($post_id)
3535
-    {
3536
-    }
3537
-
3538
-
3539
-    public function delete_cpt_item($post_id)
3540
-    {
3541
-    }
3542
-
3543
-
3544
-    public function restore_cpt_item($post_id)
3545
-    {
3546
-    }
3547
-
3548
-
3549
-    protected function _restore_cpt_item($post_id, $revision_id)
3550
-    {
3551
-    }
3552
-
3553
-
3554
-    public function attendee_editor_metaboxes()
3555
-    {
3556
-        $this->verify_cpt_object();
3557
-        remove_meta_box(
3558
-            'postexcerpt',
3559
-            esc_html__('Excerpt', 'event_espresso'),
3560
-            'post_excerpt_meta_box',
3561
-            $this->_cpt_routes[$this->_req_action],
3562
-            'normal',
3563
-            'core'
3564
-        );
3565
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
3566
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3567
-            add_meta_box(
3568
-                'postexcerpt',
3569
-                esc_html__('Short Biography', 'event_espresso'),
3570
-                'post_excerpt_meta_box',
3571
-                $this->_cpt_routes[$this->_req_action],
3572
-                'normal'
3573
-            );
3574
-        }
3575
-        if (post_type_supports('espresso_attendees', 'comments')) {
3576
-            add_meta_box(
3577
-                'commentsdiv',
3578
-                esc_html__('Notes on the Contact', 'event_espresso'),
3579
-                'post_comment_meta_box',
3580
-                $this->_cpt_routes[$this->_req_action],
3581
-                'normal',
3582
-                'core'
3583
-            );
3584
-        }
3585
-        add_meta_box(
3586
-            'attendee_contact_info',
3587
-            esc_html__('Contact Info', 'event_espresso'),
3588
-            array($this, 'attendee_contact_info'),
3589
-            $this->_cpt_routes[$this->_req_action],
3590
-            'side',
3591
-            'core'
3592
-        );
3593
-        add_meta_box(
3594
-            'attendee_details_address',
3595
-            esc_html__('Address Details', 'event_espresso'),
3596
-            array($this, 'attendee_address_details'),
3597
-            $this->_cpt_routes[$this->_req_action],
3598
-            'normal',
3599
-            'core'
3600
-        );
3601
-        add_meta_box(
3602
-            'attendee_registrations',
3603
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3604
-            array($this, 'attendee_registrations_meta_box'),
3605
-            $this->_cpt_routes[$this->_req_action],
3606
-            'normal',
3607
-            'high'
3608
-        );
3609
-    }
3610
-
3611
-
3612
-    /**
3613
-     * Metabox for attendee contact info
3614
-     *
3615
-     * @param  WP_Post $post wp post object
3616
-     * @return string attendee contact info ( and form )
3617
-     * @throws EE_Error
3618
-     * @throws InvalidArgumentException
3619
-     * @throws InvalidDataTypeException
3620
-     * @throws InvalidInterfaceException
3621
-     * @throws LogicException
3622
-     * @throws DomainException
3623
-     */
3624
-    public function attendee_contact_info($post)
3625
-    {
3626
-        //get attendee object ( should already have it )
3627
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3628
-        $form->enqueueStylesAndScripts();
3629
-        echo $form->display();
3630
-    }
3631
-
3632
-
3633
-    /**
3634
-     * Return form handler for the contact details metabox
3635
-     *
3636
-     * @param EE_Attendee $attendee
3637
-     * @return AttendeeContactDetailsMetaboxFormHandler
3638
-     * @throws DomainException
3639
-     * @throws InvalidArgumentException
3640
-     * @throws InvalidDataTypeException
3641
-     * @throws InvalidInterfaceException
3642
-     */
3643
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3644
-    {
3645
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3646
-    }
3647
-
3648
-
3649
-    /**
3650
-     * Metabox for attendee details
3651
-     *
3652
-     * @param  WP_Post $post wp post object
3653
-     * @throws DomainException
3654
-     */
3655
-    public function attendee_address_details($post)
3656
-    {
3657
-        //get attendee object (should already have it)
3658
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3659
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3660
-            new EE_Question_Form_Input(
3661
-                EE_Question::new_instance(
3662
-                    array(
3663
-                        'QST_ID'           => 0,
3664
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3665
-                        'QST_system'       => 'admin-state',
3666
-                    )
3667
-                ),
3668
-                EE_Answer::new_instance(
3669
-                    array(
3670
-                        'ANS_ID'    => 0,
3671
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3672
-                    )
3673
-                ),
3674
-                array(
3675
-                    'input_id'       => 'STA_ID',
3676
-                    'input_name'     => 'STA_ID',
3677
-                    'input_prefix'   => '',
3678
-                    'append_qstn_id' => false,
3679
-                )
3680
-            )
3681
-        );
3682
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3683
-            new EE_Question_Form_Input(
3684
-                EE_Question::new_instance(
3685
-                    array(
3686
-                        'QST_ID'           => 0,
3687
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3688
-                        'QST_system'       => 'admin-country',
3689
-                    )
3690
-                ),
3691
-                EE_Answer::new_instance(
3692
-                    array(
3693
-                        'ANS_ID'    => 0,
3694
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3695
-                    )
3696
-                ),
3697
-                array(
3698
-                    'input_id'       => 'CNT_ISO',
3699
-                    'input_name'     => 'CNT_ISO',
3700
-                    'input_prefix'   => '',
3701
-                    'append_qstn_id' => false,
3702
-                )
3703
-            )
3704
-        );
3705
-        $template                             =
3706
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3707
-        EEH_Template::display_template($template, $this->_template_args);
3708
-    }
3709
-
3710
-
3711
-    /**
3712
-     *        _attendee_details
3713
-     *
3714
-     * @access protected
3715
-     * @param $post
3716
-     * @return void
3717
-     * @throws DomainException
3718
-     * @throws EE_Error
3719
-     */
3720
-    public function attendee_registrations_meta_box($post)
3721
-    {
3722
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3723
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3724
-        $template                              =
3725
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3726
-        EEH_Template::display_template($template, $this->_template_args);
3727
-    }
3728
-
3729
-
3730
-    /**
3731
-     * add in the form fields for the attendee edit
3732
-     *
3733
-     * @param  WP_Post $post wp post object
3734
-     * @return string html for new form.
3735
-     * @throws DomainException
3736
-     */
3737
-    public function after_title_form_fields($post)
3738
-    {
3739
-        if ($post->post_type == 'espresso_attendees') {
3740
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3741
-            $template_args['attendee'] = $this->_cpt_model_obj;
3742
-            EEH_Template::display_template($template, $template_args);
3743
-        }
3744
-    }
3745
-
3746
-
3747
-    /**
3748
-     *        _trash_or_restore_attendee
3749
-     *
3750
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3751
-     * @return void
3752
-     * @throws EE_Error
3753
-     * @throws InvalidArgumentException
3754
-     * @throws InvalidDataTypeException
3755
-     * @throws InvalidInterfaceException
3756
-     * @access protected
3757
-     */
3758
-    protected function _trash_or_restore_attendees($trash = true)
3759
-    {
3760
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3761
-        $ATT_MDL = EEM_Attendee::instance();
3762
-        $success = 1;
3763
-        //Checkboxes
3764
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3765
-            // if array has more than one element than success message should be plural
3766
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3767
-            // cycle thru checkboxes
3768
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3769
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3770
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3771
-                if ( ! $updated) {
3772
-                    $success = 0;
3773
-                }
3774
-            }
3775
-        } else {
3776
-            // grab single id and delete
3777
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3778
-            //get attendee
3779
-            $att     = $ATT_MDL->get_one_by_ID($ATT_ID);
3780
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3781
-            $updated = $att->save();
3782
-            if ( ! $updated) {
3783
-                $success = 0;
3784
-            }
3785
-        }
3786
-        $what        = $success > 1
3787
-            ? esc_html__('Contacts', 'event_espresso')
3788
-            : esc_html__('Contact', 'event_espresso');
3789
-        $action_desc = $trash
3790
-            ? esc_html__('moved to the trash', 'event_espresso')
3791
-            : esc_html__('restored', 'event_espresso');
3792
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3793
-    }
2958
+		}
2959
+		$template_args = array(
2960
+			'title'                    => '',
2961
+			'content'                  => '',
2962
+			'step_button_text'         => '',
2963
+			'show_notification_toggle' => false,
2964
+		);
2965
+		//to indicate we're processing a new registration
2966
+		$hidden_fields = array(
2967
+			'processing_registration' => array(
2968
+				'type'  => 'hidden',
2969
+				'value' => 0,
2970
+			),
2971
+			'event_id'                => array(
2972
+				'type'  => 'hidden',
2973
+				'value' => $this->_reg_event->ID(),
2974
+			),
2975
+		);
2976
+		//if the cart is empty then we know we're at step one so we'll display ticket selector
2977
+		$cart = EE_Registry::instance()->SSN->cart();
2978
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2979
+		switch ($step) {
2980
+			case 'ticket' :
2981
+				$hidden_fields['processing_registration']['value'] = 1;
2982
+				$template_args['title']                            = esc_html__(
2983
+					'Step One: Select the Ticket for this registration',
2984
+					'event_espresso'
2985
+				);
2986
+				$template_args['content']                          =
2987
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2988
+				$template_args['step_button_text']                 = esc_html__(
2989
+					'Add Tickets and Continue to Registrant Details',
2990
+					'event_espresso'
2991
+				);
2992
+				$template_args['show_notification_toggle']         = false;
2993
+				break;
2994
+			case 'questions' :
2995
+				$hidden_fields['processing_registration']['value'] = 2;
2996
+				$template_args['title']                            = esc_html__(
2997
+					'Step Two: Add Registrant Details for this Registration',
2998
+					'event_espresso'
2999
+				);
3000
+				//in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3001
+				// properly by the first process_reg_step run.
3002
+				$template_args['content']                  =
3003
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
3004
+				$template_args['step_button_text']         = esc_html__(
3005
+					'Save Registration and Continue to Details',
3006
+					'event_espresso'
3007
+				);
3008
+				$template_args['show_notification_toggle'] = true;
3009
+				break;
3010
+		}
3011
+		//we come back to the process_registration_step route.
3012
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3013
+		return EEH_Template::display_template(
3014
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3015
+			$template_args,
3016
+			true
3017
+		);
3018
+	}
3019
+
3020
+
3021
+	/**
3022
+	 *        set_reg_event
3023
+	 *
3024
+	 * @access private
3025
+	 * @return bool
3026
+	 * @throws EE_Error
3027
+	 * @throws InvalidArgumentException
3028
+	 * @throws InvalidDataTypeException
3029
+	 * @throws InvalidInterfaceException
3030
+	 */
3031
+	private function _set_reg_event()
3032
+	{
3033
+		if (is_object($this->_reg_event)) {
3034
+			return true;
3035
+		}
3036
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3037
+		if ( ! $EVT_ID) {
3038
+			return false;
3039
+		}
3040
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3041
+		return true;
3042
+	}
3043
+
3044
+
3045
+	/**
3046
+	 * process_reg_step
3047
+	 *
3048
+	 * @access        public
3049
+	 * @return string
3050
+	 * @throws DomainException
3051
+	 * @throws EE_Error
3052
+	 * @throws InvalidArgumentException
3053
+	 * @throws InvalidDataTypeException
3054
+	 * @throws InvalidInterfaceException
3055
+	 * @throws ReflectionException
3056
+	 * @throws RuntimeException
3057
+	 */
3058
+	public function process_reg_step()
3059
+	{
3060
+		EE_System::do_not_cache();
3061
+		$this->_set_reg_event();
3062
+		EE_Registry::instance()->REQ->set_espresso_page(true);
3063
+		EE_Registry::instance()->REQ->set('uts', time());
3064
+		//what step are we on?
3065
+		$cart = EE_Registry::instance()->SSN->cart();
3066
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3067
+		//if doing ajax then we need to verify the nonce
3068
+		if (defined('DOING_AJAX')) {
3069
+			$nonce = isset($this->_req_data[$this->_req_nonce])
3070
+				? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
3071
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3072
+		}
3073
+		switch ($step) {
3074
+			case 'ticket' :
3075
+				//process ticket selection
3076
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3077
+				if ($success) {
3078
+					EE_Error::add_success(
3079
+						esc_html__(
3080
+							'Tickets Selected. Now complete the registration.',
3081
+							'event_espresso'
3082
+						)
3083
+					);
3084
+				} else {
3085
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3086
+				}
3087
+				if (defined('DOING_AJAX')) {
3088
+					$this->new_registration(); //display next step
3089
+				} else {
3090
+					$query_args = array(
3091
+						'action'                  => 'new_registration',
3092
+						'processing_registration' => 1,
3093
+						'event_id'                => $this->_reg_event->ID(),
3094
+						'uts'                     => time(),
3095
+					);
3096
+					$this->_redirect_after_action(
3097
+						false,
3098
+						'',
3099
+						'',
3100
+						$query_args,
3101
+						true
3102
+					);
3103
+				}
3104
+				break;
3105
+			case 'questions' :
3106
+				if (! isset(
3107
+					$this->_req_data['txn_reg_status_change'],
3108
+					$this->_req_data['txn_reg_status_change']['send_notifications'])
3109
+				) {
3110
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3111
+				}
3112
+				//process registration
3113
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3114
+				if ($cart instanceof EE_Cart) {
3115
+					$grand_total = $cart->get_cart_grand_total();
3116
+					if ($grand_total instanceof EE_Line_Item) {
3117
+						$grand_total->save_this_and_descendants_to_txn();
3118
+					}
3119
+				}
3120
+				if ( ! $transaction instanceof EE_Transaction) {
3121
+					$query_args = array(
3122
+						'action'                  => 'new_registration',
3123
+						'processing_registration' => 2,
3124
+						'event_id'                => $this->_reg_event->ID(),
3125
+						'uts'                     => time(),
3126
+					);
3127
+					if (defined('DOING_AJAX')) {
3128
+						//display registration form again because there are errors (maybe validation?)
3129
+						$this->new_registration();
3130
+						return;
3131
+					} else {
3132
+						$this->_redirect_after_action(
3133
+							false,
3134
+							'',
3135
+							'',
3136
+							$query_args,
3137
+							true
3138
+						);
3139
+						return;
3140
+					}
3141
+				}
3142
+				// maybe update status, and make sure to save transaction if not done already
3143
+				if ( ! $transaction->update_status_based_on_total_paid()) {
3144
+					$transaction->save();
3145
+				}
3146
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3147
+				$this->_req_data = array();
3148
+				$query_args      = array(
3149
+					'action'        => 'redirect_to_txn',
3150
+					'TXN_ID'        => $transaction->ID(),
3151
+					'EVT_ID'        => $this->_reg_event->ID(),
3152
+					'event_name'    => urlencode($this->_reg_event->name()),
3153
+					'redirect_from' => 'new_registration',
3154
+				);
3155
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3156
+				break;
3157
+		}
3158
+		//what are you looking here for?  Should be nothing to do at this point.
3159
+	}
3160
+
3161
+
3162
+	/**
3163
+	 * redirect_to_txn
3164
+	 *
3165
+	 * @access public
3166
+	 * @return void
3167
+	 * @throws EE_Error
3168
+	 * @throws InvalidArgumentException
3169
+	 * @throws InvalidDataTypeException
3170
+	 * @throws InvalidInterfaceException
3171
+	 */
3172
+	public function redirect_to_txn()
3173
+	{
3174
+		EE_System::do_not_cache();
3175
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3176
+		$query_args = array(
3177
+			'action' => 'view_transaction',
3178
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3179
+			'page'   => 'espresso_transactions',
3180
+		);
3181
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3182
+			$query_args['EVT_ID']        = $this->_req_data['EVT_ID'];
3183
+			$query_args['event_name']    = urlencode($this->_req_data['event_name']);
3184
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3185
+		}
3186
+		EE_Error::add_success(
3187
+			esc_html__(
3188
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3189
+				'event_espresso'
3190
+			)
3191
+		);
3192
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3193
+	}
3194
+
3195
+
3196
+	/**
3197
+	 *        generates HTML for the Attendee Contact List
3198
+	 *
3199
+	 * @access protected
3200
+	 * @return void
3201
+	 */
3202
+	protected function _attendee_contact_list_table()
3203
+	{
3204
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3205
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3206
+		$this->display_admin_list_table_page_with_no_sidebar();
3207
+	}
3208
+
3209
+
3210
+	/**
3211
+	 *        get_attendees
3212
+	 *
3213
+	 * @param      $per_page
3214
+	 * @param bool $count whether to return count or data.
3215
+	 * @param bool $trash
3216
+	 * @return array
3217
+	 * @throws EE_Error
3218
+	 * @throws InvalidArgumentException
3219
+	 * @throws InvalidDataTypeException
3220
+	 * @throws InvalidInterfaceException
3221
+	 * @access public
3222
+	 */
3223
+	public function get_attendees($per_page, $count = false, $trash = false)
3224
+	{
3225
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3226
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3227
+		$ATT_MDL                    = EEM_Attendee::instance();
3228
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3229
+		switch ($this->_req_data['orderby']) {
3230
+			case 'ATT_ID':
3231
+				$orderby = 'ATT_ID';
3232
+				break;
3233
+			case 'ATT_fname':
3234
+				$orderby = 'ATT_fname';
3235
+				break;
3236
+			case 'ATT_email':
3237
+				$orderby = 'ATT_email';
3238
+				break;
3239
+			case 'ATT_city':
3240
+				$orderby = 'ATT_city';
3241
+				break;
3242
+			case 'STA_ID':
3243
+				$orderby = 'STA_ID';
3244
+				break;
3245
+			case 'CNT_ID':
3246
+				$orderby = 'CNT_ID';
3247
+				break;
3248
+			case 'Registration_Count':
3249
+				$orderby = 'Registration_Count';
3250
+				break;
3251
+			default:
3252
+				$orderby = 'ATT_lname';
3253
+		}
3254
+		$sort         = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3255
+			? $this->_req_data['order']
3256
+			: 'ASC';
3257
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3258
+			? $this->_req_data['paged']
3259
+			: 1;
3260
+		$per_page     = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3261
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3262
+			? $this->_req_data['perpage']
3263
+			: $per_page;
3264
+		$_where       = array();
3265
+		if ( ! empty($this->_req_data['s'])) {
3266
+			$sstr         = '%' . $this->_req_data['s'] . '%';
3267
+			$_where['OR'] = array(
3268
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3269
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3270
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3271
+				'ATT_fname'                         => array('LIKE', $sstr),
3272
+				'ATT_lname'                         => array('LIKE', $sstr),
3273
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3274
+				'ATT_email'                         => array('LIKE', $sstr),
3275
+				'ATT_address'                       => array('LIKE', $sstr),
3276
+				'ATT_address2'                      => array('LIKE', $sstr),
3277
+				'ATT_city'                          => array('LIKE', $sstr),
3278
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3279
+				'State.STA_name'                    => array('LIKE', $sstr),
3280
+				'ATT_phone'                         => array('LIKE', $sstr),
3281
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3282
+				'Registration.REG_code'             => array('LIKE', $sstr),
3283
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3284
+			);
3285
+		}
3286
+		$offset = ($current_page - 1) * $per_page;
3287
+		$limit  = $count ? null : array($offset, $per_page);
3288
+		$query_args = array(
3289
+			$_where,
3290
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3291
+			'limit' => $limit
3292
+		);
3293
+		if (! $count) {
3294
+			$query_args['order_by'] = array($orderby => $sort);
3295
+		}
3296
+		if ($trash) {
3297
+			$query_args[0]['status'] = array('!=', 'publish');
3298
+			$all_attendees    = $count
3299
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3300
+				: $ATT_MDL->get_all($query_args);
3301
+		} else {
3302
+			$query_args[0]['status'] = array('IN', array('publish'));
3303
+			$all_attendees    = $count
3304
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3305
+				: $ATT_MDL->get_all($query_args);
3306
+		}
3307
+		return $all_attendees;
3308
+	}
3309
+
3310
+
3311
+	/**
3312
+	 * This is just taking care of resending the registration confirmation
3313
+	 *
3314
+	 * @access protected
3315
+	 * @return void
3316
+	 */
3317
+	protected function _resend_registration()
3318
+	{
3319
+		$this->_process_resend_registration();
3320
+		$query_args = isset($this->_req_data['redirect_to'])
3321
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3322
+			: array('action' => 'default');
3323
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3324
+	}
3325
+
3326
+	/**
3327
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3328
+	 * to use when selecting registrations
3329
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3330
+	 *                                                     the query parameters from the request
3331
+	 * @return void ends the request with a redirect or download
3332
+	 */
3333
+	public function _registrations_report_base( $method_name_for_getting_query_params )
3334
+	{
3335
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3336
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
3337
+				array(
3338
+					'page'        => 'espresso_batch',
3339
+					'batch'       => 'file',
3340
+					'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3341
+					'filters'     => urlencode(
3342
+						serialize(
3343
+							call_user_func(
3344
+								array( $this, $method_name_for_getting_query_params ),
3345
+								EEH_Array::is_set(
3346
+									$this->_req_data,
3347
+									'filters',
3348
+									array()
3349
+								)
3350
+							)
3351
+						)
3352
+				),
3353
+				'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3354
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3355
+				'return_url'  => urlencode($this->_req_data['return_url']),
3356
+			)));
3357
+		} else {
3358
+			$new_request_args = array(
3359
+				'export' => 'report',
3360
+				'action' => 'registrations_report_for_event',
3361
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3362
+			);
3363
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3364
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3365
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3366
+				$EE_Export = EE_Export::instance($this->_req_data);
3367
+				$EE_Export->export();
3368
+			}
3369
+		}
3370
+	}
3371
+
3372
+
3373
+
3374
+	/**
3375
+	 * Creates a registration report using only query parameters in the request
3376
+	 * @return void
3377
+	 */
3378
+	public function _registrations_report()
3379
+	{
3380
+		$this->_registrations_report_base('_get_registration_query_parameters');
3381
+	}
3382
+
3383
+
3384
+	public function _contact_list_export()
3385
+	{
3386
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3387
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3388
+			$EE_Export = EE_Export::instance($this->_req_data);
3389
+			$EE_Export->export_attendees();
3390
+		}
3391
+	}
3392
+
3393
+
3394
+	public function _contact_list_report()
3395
+	{
3396
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3397
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
3398
+				'page'        => 'espresso_batch',
3399
+				'batch'       => 'file',
3400
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3401
+				'return_url'  => urlencode($this->_req_data['return_url']),
3402
+			)));
3403
+		} else {
3404
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3405
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3406
+				$EE_Export = EE_Export::instance($this->_req_data);
3407
+				$EE_Export->report_attendees();
3408
+			}
3409
+		}
3410
+	}
3411
+
3412
+
3413
+
3414
+
3415
+
3416
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3417
+	/**
3418
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3419
+	 *
3420
+	 * @return void
3421
+	 * @throws EE_Error
3422
+	 * @throws InvalidArgumentException
3423
+	 * @throws InvalidDataTypeException
3424
+	 * @throws InvalidInterfaceException
3425
+	 */
3426
+	protected function _duplicate_attendee()
3427
+	{
3428
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3429
+		//verify we have necessary info
3430
+		if (empty($this->_req_data['_REG_ID'])) {
3431
+			EE_Error::add_error(
3432
+				esc_html__(
3433
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3434
+					'event_espresso'
3435
+				), __FILE__, __LINE__, __FUNCTION__
3436
+			);
3437
+			$query_args = array('action' => $action);
3438
+			$this->_redirect_after_action('', '', '', $query_args, true);
3439
+		}
3440
+		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3441
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3442
+		$attendee     = $registration->attendee();
3443
+		//remove relation of existing attendee on registration
3444
+		$registration->_remove_relation_to($attendee, 'Attendee');
3445
+		//new attendee
3446
+		$new_attendee = clone $attendee;
3447
+		$new_attendee->set('ATT_ID', 0);
3448
+		$new_attendee->save();
3449
+		//add new attendee to reg
3450
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3451
+		EE_Error::add_success(
3452
+			esc_html__(
3453
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3454
+				'event_espresso'
3455
+			)
3456
+		);
3457
+		//redirect to edit page for attendee
3458
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3459
+		$this->_redirect_after_action('', '', '', $query_args, true);
3460
+	}
3461
+
3462
+
3463
+	/**
3464
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3465
+	 * @param int      $post_id
3466
+	 * @param WP_POST $post
3467
+	 * @throws DomainException
3468
+	 * @throws EE_Error
3469
+	 * @throws InvalidArgumentException
3470
+	 * @throws InvalidDataTypeException
3471
+	 * @throws InvalidInterfaceException
3472
+	 * @throws LogicException
3473
+	 * @throws InvalidFormSubmissionException
3474
+	 */
3475
+	protected function _insert_update_cpt_item($post_id, $post)
3476
+	{
3477
+		$success  = true;
3478
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3479
+			? EEM_Attendee::instance()->get_one_by_ID($post_id)
3480
+			: null;
3481
+		//for attendee updates
3482
+		if ($attendee instanceof EE_Attendee) {
3483
+			//note we should only be UPDATING attendees at this point.
3484
+			$updated_fields = array(
3485
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3486
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3487
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3488
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3489
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3490
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3491
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3492
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3493
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3494
+			);
3495
+			foreach ($updated_fields as $field => $value) {
3496
+				$attendee->set($field, $value);
3497
+			}
3498
+
3499
+			//process contact details metabox form handler (which will also save the attendee)
3500
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3501
+			$success = $contact_details_form->process($this->_req_data);
3502
+
3503
+			$attendee_update_callbacks = apply_filters(
3504
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3505
+				array()
3506
+			);
3507
+			foreach ($attendee_update_callbacks as $a_callback) {
3508
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3509
+					throw new EE_Error(
3510
+						sprintf(
3511
+							esc_html__(
3512
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3513
+								'event_espresso'
3514
+							),
3515
+							$a_callback
3516
+						)
3517
+					);
3518
+				}
3519
+			}
3520
+		}
3521
+
3522
+		if ($success === false) {
3523
+			EE_Error::add_error(
3524
+				esc_html__(
3525
+					'Something went wrong with updating the meta table data for the registration.',
3526
+					'event_espresso'
3527
+				),
3528
+				__FILE__, __FUNCTION__, __LINE__
3529
+			);
3530
+		}
3531
+	}
3532
+
3533
+
3534
+	public function trash_cpt_item($post_id)
3535
+	{
3536
+	}
3537
+
3538
+
3539
+	public function delete_cpt_item($post_id)
3540
+	{
3541
+	}
3542
+
3543
+
3544
+	public function restore_cpt_item($post_id)
3545
+	{
3546
+	}
3547
+
3548
+
3549
+	protected function _restore_cpt_item($post_id, $revision_id)
3550
+	{
3551
+	}
3552
+
3553
+
3554
+	public function attendee_editor_metaboxes()
3555
+	{
3556
+		$this->verify_cpt_object();
3557
+		remove_meta_box(
3558
+			'postexcerpt',
3559
+			esc_html__('Excerpt', 'event_espresso'),
3560
+			'post_excerpt_meta_box',
3561
+			$this->_cpt_routes[$this->_req_action],
3562
+			'normal',
3563
+			'core'
3564
+		);
3565
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
3566
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3567
+			add_meta_box(
3568
+				'postexcerpt',
3569
+				esc_html__('Short Biography', 'event_espresso'),
3570
+				'post_excerpt_meta_box',
3571
+				$this->_cpt_routes[$this->_req_action],
3572
+				'normal'
3573
+			);
3574
+		}
3575
+		if (post_type_supports('espresso_attendees', 'comments')) {
3576
+			add_meta_box(
3577
+				'commentsdiv',
3578
+				esc_html__('Notes on the Contact', 'event_espresso'),
3579
+				'post_comment_meta_box',
3580
+				$this->_cpt_routes[$this->_req_action],
3581
+				'normal',
3582
+				'core'
3583
+			);
3584
+		}
3585
+		add_meta_box(
3586
+			'attendee_contact_info',
3587
+			esc_html__('Contact Info', 'event_espresso'),
3588
+			array($this, 'attendee_contact_info'),
3589
+			$this->_cpt_routes[$this->_req_action],
3590
+			'side',
3591
+			'core'
3592
+		);
3593
+		add_meta_box(
3594
+			'attendee_details_address',
3595
+			esc_html__('Address Details', 'event_espresso'),
3596
+			array($this, 'attendee_address_details'),
3597
+			$this->_cpt_routes[$this->_req_action],
3598
+			'normal',
3599
+			'core'
3600
+		);
3601
+		add_meta_box(
3602
+			'attendee_registrations',
3603
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3604
+			array($this, 'attendee_registrations_meta_box'),
3605
+			$this->_cpt_routes[$this->_req_action],
3606
+			'normal',
3607
+			'high'
3608
+		);
3609
+	}
3610
+
3611
+
3612
+	/**
3613
+	 * Metabox for attendee contact info
3614
+	 *
3615
+	 * @param  WP_Post $post wp post object
3616
+	 * @return string attendee contact info ( and form )
3617
+	 * @throws EE_Error
3618
+	 * @throws InvalidArgumentException
3619
+	 * @throws InvalidDataTypeException
3620
+	 * @throws InvalidInterfaceException
3621
+	 * @throws LogicException
3622
+	 * @throws DomainException
3623
+	 */
3624
+	public function attendee_contact_info($post)
3625
+	{
3626
+		//get attendee object ( should already have it )
3627
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3628
+		$form->enqueueStylesAndScripts();
3629
+		echo $form->display();
3630
+	}
3631
+
3632
+
3633
+	/**
3634
+	 * Return form handler for the contact details metabox
3635
+	 *
3636
+	 * @param EE_Attendee $attendee
3637
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3638
+	 * @throws DomainException
3639
+	 * @throws InvalidArgumentException
3640
+	 * @throws InvalidDataTypeException
3641
+	 * @throws InvalidInterfaceException
3642
+	 */
3643
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3644
+	{
3645
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3646
+	}
3647
+
3648
+
3649
+	/**
3650
+	 * Metabox for attendee details
3651
+	 *
3652
+	 * @param  WP_Post $post wp post object
3653
+	 * @throws DomainException
3654
+	 */
3655
+	public function attendee_address_details($post)
3656
+	{
3657
+		//get attendee object (should already have it)
3658
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3659
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3660
+			new EE_Question_Form_Input(
3661
+				EE_Question::new_instance(
3662
+					array(
3663
+						'QST_ID'           => 0,
3664
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3665
+						'QST_system'       => 'admin-state',
3666
+					)
3667
+				),
3668
+				EE_Answer::new_instance(
3669
+					array(
3670
+						'ANS_ID'    => 0,
3671
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3672
+					)
3673
+				),
3674
+				array(
3675
+					'input_id'       => 'STA_ID',
3676
+					'input_name'     => 'STA_ID',
3677
+					'input_prefix'   => '',
3678
+					'append_qstn_id' => false,
3679
+				)
3680
+			)
3681
+		);
3682
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3683
+			new EE_Question_Form_Input(
3684
+				EE_Question::new_instance(
3685
+					array(
3686
+						'QST_ID'           => 0,
3687
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3688
+						'QST_system'       => 'admin-country',
3689
+					)
3690
+				),
3691
+				EE_Answer::new_instance(
3692
+					array(
3693
+						'ANS_ID'    => 0,
3694
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3695
+					)
3696
+				),
3697
+				array(
3698
+					'input_id'       => 'CNT_ISO',
3699
+					'input_name'     => 'CNT_ISO',
3700
+					'input_prefix'   => '',
3701
+					'append_qstn_id' => false,
3702
+				)
3703
+			)
3704
+		);
3705
+		$template                             =
3706
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3707
+		EEH_Template::display_template($template, $this->_template_args);
3708
+	}
3709
+
3710
+
3711
+	/**
3712
+	 *        _attendee_details
3713
+	 *
3714
+	 * @access protected
3715
+	 * @param $post
3716
+	 * @return void
3717
+	 * @throws DomainException
3718
+	 * @throws EE_Error
3719
+	 */
3720
+	public function attendee_registrations_meta_box($post)
3721
+	{
3722
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3723
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3724
+		$template                              =
3725
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3726
+		EEH_Template::display_template($template, $this->_template_args);
3727
+	}
3728
+
3729
+
3730
+	/**
3731
+	 * add in the form fields for the attendee edit
3732
+	 *
3733
+	 * @param  WP_Post $post wp post object
3734
+	 * @return string html for new form.
3735
+	 * @throws DomainException
3736
+	 */
3737
+	public function after_title_form_fields($post)
3738
+	{
3739
+		if ($post->post_type == 'espresso_attendees') {
3740
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3741
+			$template_args['attendee'] = $this->_cpt_model_obj;
3742
+			EEH_Template::display_template($template, $template_args);
3743
+		}
3744
+	}
3745
+
3746
+
3747
+	/**
3748
+	 *        _trash_or_restore_attendee
3749
+	 *
3750
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3751
+	 * @return void
3752
+	 * @throws EE_Error
3753
+	 * @throws InvalidArgumentException
3754
+	 * @throws InvalidDataTypeException
3755
+	 * @throws InvalidInterfaceException
3756
+	 * @access protected
3757
+	 */
3758
+	protected function _trash_or_restore_attendees($trash = true)
3759
+	{
3760
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3761
+		$ATT_MDL = EEM_Attendee::instance();
3762
+		$success = 1;
3763
+		//Checkboxes
3764
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3765
+			// if array has more than one element than success message should be plural
3766
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3767
+			// cycle thru checkboxes
3768
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3769
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3770
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3771
+				if ( ! $updated) {
3772
+					$success = 0;
3773
+				}
3774
+			}
3775
+		} else {
3776
+			// grab single id and delete
3777
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3778
+			//get attendee
3779
+			$att     = $ATT_MDL->get_one_by_ID($ATT_ID);
3780
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3781
+			$updated = $att->save();
3782
+			if ( ! $updated) {
3783
+				$success = 0;
3784
+			}
3785
+		}
3786
+		$what        = $success > 1
3787
+			? esc_html__('Contacts', 'event_espresso')
3788
+			: esc_html__('Contact', 'event_espresso');
3789
+		$action_desc = $trash
3790
+			? esc_html__('moved to the trash', 'event_espresso')
3791
+			: esc_html__('restored', 'event_espresso');
3792
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3793
+	}
3794 3794
 
3795 3795
 }
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         // when adding a new registration...
77 77
         if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
78 78
             EE_System::do_not_cache();
79
-            if (! isset($this->_req_data['processing_registration'])
79
+            if ( ! isset($this->_req_data['processing_registration'])
80 80
                  || absint($this->_req_data['processing_registration']) !== 1
81 81
             ) {
82 82
                 // and it's NOT the attendee information reg step
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     public function _set_page_routes()
172 172
     {
173 173
         $this->_get_registration_status_array();
174
-        $reg_id             = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
174
+        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175 175
             ? $this->_req_data['_REG_ID'] : 0;
176 176
         $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
177 177
             ? $this->_req_data['reg_status_change_form']['REG_ID']
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
         //style
670 670
         wp_register_style(
671 671
             'espresso_reg',
672
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
672
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
673 673
             array('ee-admin-css'),
674 674
             EVENT_ESPRESSO_VERSION
675 675
         );
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
         //script
678 678
         wp_register_script(
679 679
             'espresso_reg',
680
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
680
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
681 681
             array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
682 682
             EVENT_ESPRESSO_VERSION,
683 683
             true
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
         wp_deregister_style('espresso_reg');
716 716
         wp_register_style(
717 717
             'espresso_att',
718
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
718
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
719 719
             array('ee-admin-css'),
720 720
             EVENT_ESPRESSO_VERSION
721 721
         );
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
     {
728 728
         wp_register_script(
729 729
             'ee-spco-for-admin',
730
-            REG_ASSETS_URL . 'spco_for_admin.js',
730
+            REG_ASSETS_URL.'spco_for_admin.js',
731 731
             array('underscore', 'jquery'),
732 732
             EVENT_ESPRESSO_VERSION,
733 733
             true
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
862 862
                 ),
863 863
             );
864
-            $this->_views['trash']      = array(
864
+            $this->_views['trash'] = array(
865 865
                 'slug'        => 'trash',
866 866
                 'label'       => esc_html__('Trash', 'event_espresso'),
867 867
                 'count'       => 0,
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
         }
951 951
         $sc_items = array(
952 952
             'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
953
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
954 954
                 'desc'  => EEH_Template::pretty_status(
955 955
                     EEM_Registration::status_id_approved,
956 956
                     false,
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
                 ),
959 959
             ),
960 960
             'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
961
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
962 962
                 'desc'  => EEH_Template::pretty_status(
963 963
                     EEM_Registration::status_id_pending_payment,
964 964
                     false,
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 ),
967 967
             ),
968 968
             'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
969
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
970 970
                 'desc'  => EEH_Template::pretty_status(
971 971
                     EEM_Registration::status_id_wait_list,
972 972
                     false,
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
                 ),
975 975
             ),
976 976
             'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
977
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
978 978
                 'desc'  => EEH_Template::pretty_status(
979 979
                     EEM_Registration::status_id_incomplete,
980 980
                     false,
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
                 ),
983 983
             ),
984 984
             'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
985
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
986 986
                 'desc'  => EEH_Template::pretty_status(
987 987
                     EEM_Registration::status_id_not_approved,
988 988
                     false,
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
                 ),
991 991
             ),
992 992
             'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
993
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
994 994
                 'desc'  => EEH_Template::pretty_status(
995 995
                     EEM_Registration::status_id_declined,
996 996
                     false,
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
                 ),
999 999
             ),
1000 1000
             'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1001
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1002 1002
                 'desc'  => EEH_Template::pretty_status(
1003 1003
                     EEM_Registration::status_id_cancelled,
1004 1004
                     false,
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
         $EVT_ID                                    = ! empty($this->_req_data['event_id'])
1022 1022
             ? absint($this->_req_data['event_id'])
1023 1023
             : 0;
1024
-        $ATT_ID = !empty($this->_req_data['ATT_ID'])
1024
+        $ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025 1025
             ? absint($this->_req_data['ATT_ID'])
1026 1026
             : 0;
1027 1027
         if ($ATT_ID) {
@@ -1033,13 +1033,13 @@  discard block
 block discarded – undo
1033 1033
                         'event_espresso'
1034 1034
                     ),
1035 1035
                     '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1036
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
1037 1037
                         array(
1038 1038
                             'action' => 'edit_attendee',
1039 1039
                             'post' => $ATT_ID
1040 1040
                         ),
1041 1041
                         REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1042
+                    ).'">'.$attendee->full_name().'</a>',
1043 1043
                     '</h3>'
1044 1044
                 );
1045 1045
             }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
                 'espresso_registrations_new_registration',
1051 1051
                 $EVT_ID
1052 1052
             )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1053
+                $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1054 1054
                     'new_registration',
1055 1055
                     'add-registrant',
1056 1056
                     array('event_id' => $EVT_ID),
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
                 $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091 1091
                 $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092 1092
                 $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1093
+                $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )';
1094 1094
                 $this->_template_args['admin_page_header'] .= '</span></h3>';
1095 1095
             }
1096 1096
         }
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
             'caps'                     => EEM_Registration::caps_read_admin,
1198 1198
             'default_where_conditions' => 'this_model_only',
1199 1199
         );
1200
-        if (! $count) {
1200
+        if ( ! $count) {
1201 1201
             $query_params = array_merge(
1202 1202
                 $query_params,
1203 1203
                 $this->_get_orderby_for_registrations_query(),
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
     protected function addAttendeeIdToWhereConditions(array $request)
1219 1219
     {
1220 1220
         $where = array();
1221
-        if (! empty($request['ATT_ID'])) {
1221
+        if ( ! empty($request['ATT_ID'])) {
1222 1222
             $where['ATT_ID'] = absint($request['ATT_ID']);
1223 1223
         }
1224 1224
         return $where;
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
     protected function _add_event_id_to_where_conditions(array $request)
1235 1235
     {
1236 1236
         $where = array();
1237
-        if (! empty($request['event_id'])) {
1237
+        if ( ! empty($request['event_id'])) {
1238 1238
             $where['EVT_ID'] = absint($request['event_id']);
1239 1239
         }
1240 1240
         return $where;
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
     protected function _add_category_id_to_where_conditions(array $request)
1251 1251
     {
1252 1252
         $where = array();
1253
-        if (! empty($request['EVT_CAT']) && (int)$request['EVT_CAT'] !== -1) {
1253
+        if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1254 1254
             $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1255 1255
         }
1256 1256
         return $where;
@@ -1266,10 +1266,10 @@  discard block
 block discarded – undo
1266 1266
     protected function _add_datetime_id_to_where_conditions(array $request)
1267 1267
     {
1268 1268
         $where = array();
1269
-        if (! empty($request['datetime_id'])) {
1269
+        if ( ! empty($request['datetime_id'])) {
1270 1270
             $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1271 1271
         }
1272
-        if (! empty($request['DTT_ID'])) {
1272
+        if ( ! empty($request['DTT_ID'])) {
1273 1273
             $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1274 1274
         }
1275 1275
         return $where;
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1296 1296
          * UNLESS viewing trashed registrations.
1297 1297
          */
1298
-        if (! empty($registration_status)) {
1298
+        if ( ! empty($registration_status)) {
1299 1299
             $where['STS_ID'] = $registration_status;
1300 1300
         } else {
1301 1301
             //make sure we exclude incomplete registrations, but only if not trashed.
@@ -1338,12 +1338,12 @@  discard block
 block discarded – undo
1338 1338
                 array(
1339 1339
                     EEM_Registration::instance()->convert_datetime_for_query(
1340 1340
                         'REG_date',
1341
-                        $now . ' 00:00:00',
1341
+                        $now.' 00:00:00',
1342 1342
                         'Y-m-d H:i:s'
1343 1343
                     ),
1344 1344
                     EEM_Registration::instance()->convert_datetime_for_query(
1345 1345
                         'REG_date',
1346
-                        $now . ' 23:59:59',
1346
+                        $now.' 23:59:59',
1347 1347
                         'Y-m-d H:i:s'
1348 1348
                     ),
1349 1349
                 ),
@@ -1356,12 +1356,12 @@  discard block
 block discarded – undo
1356 1356
                 array(
1357 1357
                     EEM_Registration::instance()->convert_datetime_for_query(
1358 1358
                         'REG_date',
1359
-                        $current_year_and_month . '-01 00:00:00',
1359
+                        $current_year_and_month.'-01 00:00:00',
1360 1360
                         'Y-m-d H:i:s'
1361 1361
                     ),
1362 1362
                     EEM_Registration::instance()->convert_datetime_for_query(
1363 1363
                         'REG_date',
1364
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1364
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
1365 1365
                         'Y-m-d H:i:s'
1366 1366
                     ),
1367 1367
                 ),
@@ -1376,18 +1376,18 @@  discard block
 block discarded – undo
1376 1376
                 : '';
1377 1377
             //if there is not a month or year then we can't go further
1378 1378
             if ($month_requested && $year_requested) {
1379
-                $days_in_month     = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1379
+                $days_in_month     = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
1380 1380
                 $where['REG_date'] = array(
1381 1381
                     'BETWEEN',
1382 1382
                     array(
1383 1383
                         EEM_Registration::instance()->convert_datetime_for_query(
1384 1384
                             'REG_date',
1385
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1385
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
1386 1386
                             'Y-m-d H:i:s'
1387 1387
                         ),
1388 1388
                         EEM_Registration::instance()->convert_datetime_for_query(
1389 1389
                             'REG_date',
1390
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1390
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
1391 1391
                             'Y-m-d H:i:s'
1392 1392
                         ),
1393 1393
                     ),
@@ -1407,8 +1407,8 @@  discard block
 block discarded – undo
1407 1407
     protected function _add_search_to_where_conditions(array $request)
1408 1408
     {
1409 1409
         $where = array();
1410
-        if (! empty($request['s'])) {
1411
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1410
+        if ( ! empty($request['s'])) {
1411
+            $search_string = '%'.sanitize_text_field($request['s']).'%';
1412 1412
             $where['OR*search_conditions'] = array(
1413 1413
                 'Event.EVT_name'                          => array('LIKE', $search_string),
1414 1414
                 'Event.EVT_desc'                          => array('LIKE', $search_string),
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
             : $per_page;
1526 1526
 
1527 1527
         //-1 means return all results so get out if that's set.
1528
-        if ((int)$per_page === -1) {
1528
+        if ((int) $per_page === -1) {
1529 1529
             return array();
1530 1530
         }
1531 1531
         $per_page = absint($per_page);
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
                 ),
1582 1582
                 REG_ADMIN_URL
1583 1583
             );
1584
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1584
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1585 1585
                 array(
1586 1586
                     'action' => 'default',
1587 1587
                     'EVT_ID' => $event_id,
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
                 ),
1590 1590
                 admin_url('admin.php')
1591 1591
             );
1592
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1592
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1593 1593
                 array(
1594 1594
                     'page'   => 'espresso_events',
1595 1595
                     'action' => 'edit',
@@ -1598,12 +1598,12 @@  discard block
 block discarded – undo
1598 1598
                 admin_url('admin.php')
1599 1599
             );
1600 1600
             //next and previous links
1601
-            $next_reg                                      = $this->_registration->next(
1601
+            $next_reg = $this->_registration->next(
1602 1602
                 null,
1603 1603
                 array(),
1604 1604
                 'REG_ID'
1605 1605
             );
1606
-            $this->_template_args['next_registration']     = $next_reg
1606
+            $this->_template_args['next_registration'] = $next_reg
1607 1607
                 ? $this->_next_link(
1608 1608
                     EE_Admin_Page::add_query_args_and_nonce(
1609 1609
                         array(
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1616 1616
                 )
1617 1617
                 : '';
1618
-            $previous_reg                                  = $this->_registration->previous(
1618
+            $previous_reg = $this->_registration->previous(
1619 1619
                 null,
1620 1620
                 array(),
1621 1621
                 'REG_ID'
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
                 )
1634 1634
                 : '';
1635 1635
             // grab header
1636
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1636
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1637 1637
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1638 1638
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1639 1639
                 $template_path,
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
                             EEH_HTML::strong(
1754 1754
                                 $this->_registration->pretty_status(),
1755 1755
                                 '',
1756
-                                'status-' . $this->_registration->status_ID(),
1756
+                                'status-'.$this->_registration->status_ID(),
1757 1757
                                 'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1758 1758
                             )
1759 1759
                         )
@@ -1833,11 +1833,11 @@  discard block
 block discarded – undo
1833 1833
     {
1834 1834
         if (isset($this->_req_data['reg_status_change_form'])) {
1835 1835
             $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1836
-                ? (array)$this->_req_data['reg_status_change_form']['REG_ID']
1836
+                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1837 1837
                 : array();
1838 1838
         } else {
1839 1839
             $REG_IDs = isset($this->_req_data['_REG_ID'])
1840
-                ? (array)$this->_req_data['_REG_ID']
1840
+                ? (array) $this->_req_data['_REG_ID']
1841 1841
                 : array();
1842 1842
         }
1843 1843
         // sanitize $REG_IDs
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
     {
1901 1901
         $success = false;
1902 1902
         // typecast $REG_IDs
1903
-        $REG_IDs = (array)$REG_IDs;
1903
+        $REG_IDs = (array) $REG_IDs;
1904 1904
         if ( ! empty($REG_IDs)) {
1905 1905
             $success = true;
1906 1906
             // set default status if none is passed
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
             $action,
2051 2051
             $notify
2052 2052
         );
2053
-        $method = $action . '_registration';
2053
+        $method = $action.'_registration';
2054 2054
         if (method_exists($this, $method)) {
2055 2055
             $this->$method($notify);
2056 2056
         }
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
             $filtered_line_item_tree,
2169 2169
             array('EE_Registration' => $this->_registration)
2170 2170
         );
2171
-        $attendee                                = $this->_registration->attendee();
2171
+        $attendee = $this->_registration->attendee();
2172 2172
         if (EE_Registry::instance()->CAP->current_user_can(
2173 2173
             'ee_read_transaction',
2174 2174
             'espresso_transactions_view_transaction'
@@ -2247,7 +2247,7 @@  discard block
 block discarded – undo
2247 2247
                 'Payment method response',
2248 2248
                 'event_espresso'
2249 2249
             );
2250
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2250
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2251 2251
         }
2252 2252
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2253 2253
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2275,7 +2275,7 @@  discard block
 block discarded – undo
2275 2275
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2276 2276
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2277 2277
         $template_path                                                        =
2278
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2278
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2279 2279
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2280 2280
     }
2281 2281
 
@@ -2304,7 +2304,7 @@  discard block
 block discarded – undo
2304 2304
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2305 2305
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2306 2306
             $template_path                                     =
2307
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2307
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2308 2308
             echo EEH_Template::display_template($template_path, $this->_template_args, true);
2309 2309
         }
2310 2310
     }
@@ -2321,7 +2321,7 @@  discard block
 block discarded – undo
2321 2321
     public function form_before_question_group($output)
2322 2322
     {
2323 2323
         EE_Error::doing_it_wrong(
2324
-            __CLASS__ . '::' . __FUNCTION__,
2324
+            __CLASS__.'::'.__FUNCTION__,
2325 2325
             esc_html__(
2326 2326
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2327 2327
                 'event_espresso'
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
     public function form_after_question_group($output)
2347 2347
     {
2348 2348
         EE_Error::doing_it_wrong(
2349
-            __CLASS__ . '::' . __FUNCTION__,
2349
+            __CLASS__.'::'.__FUNCTION__,
2350 2350
             esc_html__(
2351 2351
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2352 2352
                 'event_espresso'
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
     public function form_form_field_label_wrap($label)
2385 2385
     {
2386 2386
         EE_Error::doing_it_wrong(
2387
-            __CLASS__ . '::' . __FUNCTION__,
2387
+            __CLASS__.'::'.__FUNCTION__,
2388 2388
             esc_html__(
2389 2389
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2390 2390
                 'event_espresso'
@@ -2394,7 +2394,7 @@  discard block
 block discarded – undo
2394 2394
         return '
2395 2395
 			<tr>
2396 2396
 				<th>
2397
-					' . $label . '
2397
+					' . $label.'
2398 2398
 				</th>';
2399 2399
     }
2400 2400
 
@@ -2410,7 +2410,7 @@  discard block
 block discarded – undo
2410 2410
     public function form_form_field_input__wrap($input)
2411 2411
     {
2412 2412
         EE_Error::doing_it_wrong(
2413
-            __CLASS__ . '::' . __FUNCTION__,
2413
+            __CLASS__.'::'.__FUNCTION__,
2414 2414
             esc_html__(
2415 2415
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2416 2416
                 'event_espresso'
@@ -2419,7 +2419,7 @@  discard block
 block discarded – undo
2419 2419
         );
2420 2420
         return '
2421 2421
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2422
-					' . $input . '
2422
+					' . $input.'
2423 2423
 				</td>
2424 2424
 			</tr>';
2425 2425
     }
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
     protected function _get_reg_custom_questions_form($REG_ID)
2465 2465
     {
2466 2466
         if ( ! $this->_reg_custom_questions_form) {
2467
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2467
+            require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php');
2468 2468
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2469 2469
                 EEM_Registration::instance()->get_one_by_ID($REG_ID)
2470 2470
             );
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
         if ($form->is_valid()) {
2501 2501
             foreach ($form->subforms() as $question_group_id => $question_group_form) {
2502 2502
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2503
-                    $where_conditions    = array(
2503
+                    $where_conditions = array(
2504 2504
                         'QST_ID' => $question_id,
2505 2505
                         'REG_ID' => $REG_ID,
2506 2506
                     );
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
         $REG = EEM_Registration::instance();
2542 2542
         //get all other registrations on this transaction, and cache
2543 2543
         //the attendees for them so we don't have to run another query using force_join
2544
-        $registrations                           = $REG->get_all(array(
2544
+        $registrations = $REG->get_all(array(
2545 2545
             array(
2546 2546
                 'TXN_ID' => $this->_registration->transaction_ID(),
2547 2547
                 'REG_ID' => array('!=', $this->_registration->ID()),
@@ -2565,7 +2565,7 @@  discard block
 block discarded – undo
2565 2565
             $att_nmbr = 1;
2566 2566
             foreach ($registrations as $registration) {
2567 2567
                 /* @var $registration EE_Registration */
2568
-                $attendee                                                    = $registration->attendee()
2568
+                $attendee = $registration->attendee()
2569 2569
                     ? $registration->attendee()
2570 2570
                     : EEM_Attendee::instance()
2571 2571
                                   ->create_default_object();
@@ -2578,19 +2578,19 @@  discard block
 block discarded – undo
2578 2578
                     ', ',
2579 2579
                     $attendee->full_address_as_array()
2580 2580
                 );
2581
-                $this->_template_args['attendees'][$att_nmbr]['att_link']    = self::add_query_args_and_nonce(
2581
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2582 2582
                     array(
2583 2583
                         'action' => 'edit_attendee',
2584 2584
                         'post'   => $attendee->ID(),
2585 2585
                     ),
2586 2586
                     REG_ADMIN_URL
2587 2587
                 );
2588
-                $this->_template_args['attendees'][$att_nmbr]['event_name']  = $registration->event_obj()->name();
2588
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
2589 2589
                 $att_nmbr++;
2590 2590
             }
2591 2591
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2592 2592
         }
2593
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2593
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2594 2594
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2595 2595
     }
2596 2596
 
@@ -2633,20 +2633,20 @@  discard block
 block discarded – undo
2633 2633
         $this->_template_args['phone']             = $attendee->phone();
2634 2634
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2635 2635
         //edit link
2636
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(array(
2636
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
2637 2637
             'action' => 'edit_attendee',
2638 2638
             'post'   => $attendee->ID(),
2639 2639
         ), REG_ADMIN_URL);
2640 2640
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2641 2641
         //create link
2642
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2642
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2643 2643
             ? EE_Admin_Page::add_query_args_and_nonce(array(
2644 2644
                 'action'  => 'duplicate_attendee',
2645 2645
                 '_REG_ID' => $this->_registration->ID(),
2646 2646
             ), REG_ADMIN_URL) : '';
2647 2647
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2648 2648
         $this->_template_args['att_check']    = $att_check;
2649
-        $template_path                        = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2649
+        $template_path                        = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2650 2650
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2651 2651
     }
2652 2652
 
@@ -2691,7 +2691,7 @@  discard block
 block discarded – undo
2691 2691
             /** @var EE_Registration $REG */
2692 2692
             $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2693 2693
             $payments = $REG->registration_payments();
2694
-            if (! empty($payments)) {
2694
+            if ( ! empty($payments)) {
2695 2695
                 $name = $REG->attendee() instanceof EE_Attendee
2696 2696
                     ? $REG->attendee()->full_name()
2697 2697
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
                 'action' => 'edit',
2888 2888
                 'post'   => $this->_reg_event->ID(),
2889 2889
             ), EVENTS_ADMIN_URL);
2890
-            $edit_event_lnk                     = '<a href="'
2890
+            $edit_event_lnk = '<a href="'
2891 2891
                                                   . $edit_event_url
2892 2892
                                                   . '" title="'
2893 2893
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
         }
2906 2906
         // grab header
2907 2907
         $template_path                              =
2908
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2908
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2909 2909
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2910 2910
             $this->_template_args, true);
2911 2911
         //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
                 '</b>'
2944 2944
             );
2945 2945
             return '
2946
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2946
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2947 2947
 	<script >
2948 2948
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2949 2949
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -3011,7 +3011,7 @@  discard block
 block discarded – undo
3011 3011
         //we come back to the process_registration_step route.
3012 3012
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3013 3013
         return EEH_Template::display_template(
3014
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3014
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
3015 3015
             $template_args,
3016 3016
             true
3017 3017
         );
@@ -3033,7 +3033,7 @@  discard block
 block discarded – undo
3033 3033
         if (is_object($this->_reg_event)) {
3034 3034
             return true;
3035 3035
         }
3036
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3036
+        $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3037 3037
         if ( ! $EVT_ID) {
3038 3038
             return false;
3039 3039
         }
@@ -3103,7 +3103,7 @@  discard block
 block discarded – undo
3103 3103
                 }
3104 3104
                 break;
3105 3105
             case 'questions' :
3106
-                if (! isset(
3106
+                if ( ! isset(
3107 3107
                     $this->_req_data['txn_reg_status_change'],
3108 3108
                     $this->_req_data['txn_reg_status_change']['send_notifications'])
3109 3109
                 ) {
@@ -3223,7 +3223,7 @@  discard block
 block discarded – undo
3223 3223
     public function get_attendees($per_page, $count = false, $trash = false)
3224 3224
     {
3225 3225
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3226
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3226
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3227 3227
         $ATT_MDL                    = EEM_Attendee::instance();
3228 3228
         $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3229 3229
         switch ($this->_req_data['orderby']) {
@@ -3263,7 +3263,7 @@  discard block
 block discarded – undo
3263 3263
             : $per_page;
3264 3264
         $_where       = array();
3265 3265
         if ( ! empty($this->_req_data['s'])) {
3266
-            $sstr         = '%' . $this->_req_data['s'] . '%';
3266
+            $sstr         = '%'.$this->_req_data['s'].'%';
3267 3267
             $_where['OR'] = array(
3268 3268
                 'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3269 3269
                 'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
@@ -3290,17 +3290,17 @@  discard block
 block discarded – undo
3290 3290
             'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3291 3291
             'limit' => $limit
3292 3292
         );
3293
-        if (! $count) {
3293
+        if ( ! $count) {
3294 3294
             $query_args['order_by'] = array($orderby => $sort);
3295 3295
         }
3296 3296
         if ($trash) {
3297 3297
             $query_args[0]['status'] = array('!=', 'publish');
3298
-            $all_attendees    = $count
3298
+            $all_attendees = $count
3299 3299
                 ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3300 3300
                 : $ATT_MDL->get_all($query_args);
3301 3301
         } else {
3302 3302
             $query_args[0]['status'] = array('IN', array('publish'));
3303
-            $all_attendees    = $count
3303
+            $all_attendees = $count
3304 3304
                 ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3305 3305
                 : $ATT_MDL->get_all($query_args);
3306 3306
         }
@@ -3330,9 +3330,9 @@  discard block
 block discarded – undo
3330 3330
      *                                                     the query parameters from the request
3331 3331
      * @return void ends the request with a redirect or download
3332 3332
      */
3333
-    public function _registrations_report_base( $method_name_for_getting_query_params )
3333
+    public function _registrations_report_base($method_name_for_getting_query_params)
3334 3334
     {
3335
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3335
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3336 3336
             wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
3337 3337
                 array(
3338 3338
                     'page'        => 'espresso_batch',
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
                     'filters'     => urlencode(
3342 3342
                         serialize(
3343 3343
                             call_user_func(
3344
-                                array( $this, $method_name_for_getting_query_params ),
3344
+                                array($this, $method_name_for_getting_query_params),
3345 3345
                                 EEH_Array::is_set(
3346 3346
                                     $this->_req_data,
3347 3347
                                     'filters',
@@ -3361,8 +3361,8 @@  discard block
 block discarded – undo
3361 3361
                 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3362 3362
             );
3363 3363
             $this->_req_data = array_merge($this->_req_data, $new_request_args);
3364
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3365
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3364
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3365
+                require_once(EE_CLASSES.'EE_Export.class.php');
3366 3366
                 $EE_Export = EE_Export::instance($this->_req_data);
3367 3367
                 $EE_Export->export();
3368 3368
             }
@@ -3383,8 +3383,8 @@  discard block
 block discarded – undo
3383 3383
 
3384 3384
     public function _contact_list_export()
3385 3385
     {
3386
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3387
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3386
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3387
+            require_once(EE_CLASSES.'EE_Export.class.php');
3388 3388
             $EE_Export = EE_Export::instance($this->_req_data);
3389 3389
             $EE_Export->export_attendees();
3390 3390
         }
@@ -3401,8 +3401,8 @@  discard block
 block discarded – undo
3401 3401
                 'return_url'  => urlencode($this->_req_data['return_url']),
3402 3402
             )));
3403 3403
         } else {
3404
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3405
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3404
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3405
+                require_once(EE_CLASSES.'EE_Export.class.php');
3406 3406
                 $EE_Export = EE_Export::instance($this->_req_data);
3407 3407
                 $EE_Export->report_attendees();
3408 3408
             }
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
             $updated_fields = array(
3485 3485
                 'ATT_fname'     => $this->_req_data['ATT_fname'],
3486 3486
                 'ATT_lname'     => $this->_req_data['ATT_lname'],
3487
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3487
+                'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
3488 3488
                 'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3489 3489
                 'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3490 3490
                 'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
@@ -3702,8 +3702,8 @@  discard block
 block discarded – undo
3702 3702
                 )
3703 3703
             )
3704 3704
         );
3705
-        $template                             =
3706
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3705
+        $template =
3706
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3707 3707
         EEH_Template::display_template($template, $this->_template_args);
3708 3708
     }
3709 3709
 
@@ -3722,7 +3722,7 @@  discard block
 block discarded – undo
3722 3722
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3723 3723
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3724 3724
         $template                              =
3725
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3725
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3726 3726
         EEH_Template::display_template($template, $this->_template_args);
3727 3727
     }
3728 3728
 
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
     public function after_title_form_fields($post)
3738 3738
     {
3739 3739
         if ($post->post_type == 'espresso_attendees') {
3740
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3740
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3741 3741
             $template_args['attendee'] = $this->_cpt_model_obj;
3742 3742
             EEH_Template::display_template($template, $template_args);
3743 3743
         }
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/content-espresso_events-venues.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@
 block discarded – undo
1 1
 <?php
2 2
 //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' &nbsp; <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>';
3 3
 if (
4
-	( is_single() && espresso_display_venue_in_event_details() )
5
-	|| ( is_archive() && espresso_display_venue_in_event_list() )
4
+	(is_single() && espresso_display_venue_in_event_details())
5
+	|| (is_archive() && espresso_display_venue_in_event_list())
6 6
 ) :
7 7
 	global $post;
8
-	do_action( 'AHEE_event_details_before_venue_details', $post );
9
-	$venue_name = espresso_venue_name( 0, 'details', FALSE );
10
-	if ( empty( $venue_name ) && espresso_is_venue_private() ) {
11
-		do_action( 'AHEE_event_details_after_venue_details', $post );
8
+	do_action('AHEE_event_details_before_venue_details', $post);
9
+	$venue_name = espresso_venue_name(0, 'details', FALSE);
10
+	if (empty($venue_name) && espresso_is_venue_private()) {
11
+		do_action('AHEE_event_details_after_venue_details', $post);
12 12
 		return '';
13 13
 	}
14 14
 ?>
15 15
 
16 16
 <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>">
17
-	<h4><strong><?php _e( 'Venue:', 'event_espresso' ); ?></strong>&nbsp;&nbsp; <strong> <?php echo $venue_name; ?></strong></h4>
17
+	<h4><strong><?php _e('Venue:', 'event_espresso'); ?></strong>&nbsp;&nbsp; <strong> <?php echo $venue_name; ?></strong></h4>
18 18
 	<p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p>
19
-<?php  if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?>
19
+<?php  if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?>
20 20
 	<p>
21
-		<span class="small-text"><strong><?php _e( 'Venue Phone:', 'event_espresso' ); ?></strong></span> <?php echo $venue_phone; ?>
21
+		<span class="small-text"><strong><?php _e('Venue Phone:', 'event_espresso'); ?></strong></span> <?php echo $venue_phone; ?>
22 22
 	</p>
23
-<?php endif;  ?>
24
-<?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?>
23
+<?php endif; ?>
24
+<?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?>
25 25
 	<p>
26
-		<span class="small-text"><strong><?php _e( 'Venue Website:', 'event_espresso' ); ?></strong></span> <?php echo $venue_website; ?>
26
+		<span class="small-text"><strong><?php _e('Venue Website:', 'event_espresso'); ?></strong></span> <?php echo $venue_website; ?>
27 27
 	</p>
28 28
 <?php endif; ?>
29
-<?php  if ( espresso_venue_has_address( $post->ID )) : ?>
30
-	<strong><span class="dashicons dashicons-location-alt"></span><?php _e( 'Address:', 'event_espresso' ); ?></strong>
31
-	<?php espresso_venue_address( 'inline' ); ?>
32
-	<?php espresso_venue_gmap( $post->ID ); ?>
29
+<?php  if (espresso_venue_has_address($post->ID)) : ?>
30
+	<strong><span class="dashicons dashicons-location-alt"></span><?php _e('Address:', 'event_espresso'); ?></strong>
31
+	<?php espresso_venue_address('inline'); ?>
32
+	<?php espresso_venue_gmap($post->ID); ?>
33 33
 	<div class="clear"><br/></div>
34
-<?php endif;  ?>
34
+<?php endif; ?>
35 35
 
36
-	<?php $VNU_ID = espresso_venue_id( $post->ID ); ?>
37
-	<?php if ( is_single() ) : ?>
38
-		<?php $venue_description = espresso_venue_description( $VNU_ID, FALSE ); ?>
39
-		<?php if ( $venue_description ) : ?>
36
+	<?php $VNU_ID = espresso_venue_id($post->ID); ?>
37
+	<?php if (is_single()) : ?>
38
+		<?php $venue_description = espresso_venue_description($VNU_ID, FALSE); ?>
39
+		<?php if ($venue_description) : ?>
40 40
 	<p>
41
-		<strong><?php _e( 'Description:', 'event_espresso' ); ?></strong><br/>
42
-		<?php echo do_shortcode( $venue_description ); ?>
41
+		<strong><?php _e('Description:', 'event_espresso'); ?></strong><br/>
42
+		<?php echo do_shortcode($venue_description); ?>
43 43
 	</p>
44
-		<?php endif;  ?>
44
+		<?php endif; ?>
45 45
 	<?php else : ?>
46
-		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?>
47
-		<?php if ( $venue_excerpt ) : ?>
46
+		<?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?>
47
+		<?php if ($venue_excerpt) : ?>
48 48
 	<p>
49
-		<strong><?php _e( 'Description:', 'event_espresso' ); ?></strong><br/>
49
+		<strong><?php _e('Description:', 'event_espresso'); ?></strong><br/>
50 50
 		<?php echo $venue_excerpt; ?>
51 51
 	</p>
52
-			<?php endif;  ?>
53
-		<?php endif;  ?>
52
+			<?php endif; ?>
53
+		<?php endif; ?>
54 54
 </div>
55 55
 <!-- .espresso-venue-dv -->
56 56
 <?php
57
-do_action( 'AHEE_event_details_after_venue_details', $post );
57
+do_action('AHEE_event_details_after_venue_details', $post);
58 58
 else :
59
-	if ( espresso_venue_is_password_protected() ) :
59
+	if (espresso_venue_is_password_protected()) :
60 60
 ?>
61 61
 	<div class="espresso-venue-dv  espresso-password-protected-venue-dv" >
62 62
 		<h3 class="event-venues-h3 ee-event-h3">
63
-			<?php _e( 'Location', 'event_espresso' );?>
63
+			<?php _e('Location', 'event_espresso'); ?>
64 64
 		</h3>
65 65
 		<?php echo espresso_password_protected_venue_form(); ?>
66 66
 	</div>
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Indentation   +1083 added lines, -1083 removed lines patch added patch discarded remove patch
@@ -25,1144 +25,1144 @@
 block discarded – undo
25 25
 {
26 26
 
27 27
 
28
-    /**
29
-     * possibly truncated version of the EE core version string
30
-     *
31
-     * @var string
32
-     */
33
-    protected static $_core_version = '';
28
+	/**
29
+	 * possibly truncated version of the EE core version string
30
+	 *
31
+	 * @var string
32
+	 */
33
+	protected static $_core_version = '';
34 34
 
35
-    /**
36
-     * Holds values for registered addons
37
-     *
38
-     * @var array
39
-     */
40
-    protected static $_settings = array();
35
+	/**
36
+	 * Holds values for registered addons
37
+	 *
38
+	 * @var array
39
+	 */
40
+	protected static $_settings = array();
41 41
 
42
-    /**
43
-     * @var  array $_incompatible_addons keys are addon SLUGS
44
-     * (first argument passed to EE_Register_Addon::register()), keys are
45
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
46
-     * Generally this should be used sparingly, as we don't want to muddle up
47
-     * EE core with knowledge of ALL the addons out there.
48
-     * If you want NO versions of an addon to run with a certain version of core,
49
-     * it's usually best to define the addon's "min_core_version" as part of its call
50
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
51
-     * minimum plugin version.
52
-     * @access    protected
53
-     */
54
-    protected static $_incompatible_addons = array(
55
-        'Multi_Event_Registration' => '2.0.11.rc.002',
56
-        'Promotions'               => '1.0.0.rc.084',
57
-    );
42
+	/**
43
+	 * @var  array $_incompatible_addons keys are addon SLUGS
44
+	 * (first argument passed to EE_Register_Addon::register()), keys are
45
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
46
+	 * Generally this should be used sparingly, as we don't want to muddle up
47
+	 * EE core with knowledge of ALL the addons out there.
48
+	 * If you want NO versions of an addon to run with a certain version of core,
49
+	 * it's usually best to define the addon's "min_core_version" as part of its call
50
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
51
+	 * minimum plugin version.
52
+	 * @access    protected
53
+	 */
54
+	protected static $_incompatible_addons = array(
55
+		'Multi_Event_Registration' => '2.0.11.rc.002',
56
+		'Promotions'               => '1.0.0.rc.084',
57
+	);
58 58
 
59 59
 
60
-    /**
61
-     * We should always be comparing core to a version like '4.3.0.rc.000',
62
-     * not just '4.3.0'.
63
-     * So if the addon developer doesn't provide that full version string,
64
-     * fill in the blanks for them
65
-     *
66
-     * @param string $min_core_version
67
-     * @return string always like '4.3.0.rc.000'
68
-     */
69
-    protected static function _effective_version($min_core_version)
70
-    {
71
-        // versions: 4 . 3 . 1 . p . 123
72
-        // offsets:    0 . 1 . 2 . 3 . 4
73
-        $version_parts = explode('.', $min_core_version);
74
-        //check they specified the micro version (after 2nd period)
75
-        if (! isset($version_parts[2])) {
76
-            $version_parts[2] = '0';
77
-        }
78
-        //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
79
-        //soon we can assume that's 'rc', but this current version is 'alpha'
80
-        if (! isset($version_parts[3])) {
81
-            $version_parts[3] = 'dev';
82
-        }
83
-        if (! isset($version_parts[4])) {
84
-            $version_parts[4] = '000';
85
-        }
86
-        return implode('.', $version_parts);
87
-    }
60
+	/**
61
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
62
+	 * not just '4.3.0'.
63
+	 * So if the addon developer doesn't provide that full version string,
64
+	 * fill in the blanks for them
65
+	 *
66
+	 * @param string $min_core_version
67
+	 * @return string always like '4.3.0.rc.000'
68
+	 */
69
+	protected static function _effective_version($min_core_version)
70
+	{
71
+		// versions: 4 . 3 . 1 . p . 123
72
+		// offsets:    0 . 1 . 2 . 3 . 4
73
+		$version_parts = explode('.', $min_core_version);
74
+		//check they specified the micro version (after 2nd period)
75
+		if (! isset($version_parts[2])) {
76
+			$version_parts[2] = '0';
77
+		}
78
+		//if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
79
+		//soon we can assume that's 'rc', but this current version is 'alpha'
80
+		if (! isset($version_parts[3])) {
81
+			$version_parts[3] = 'dev';
82
+		}
83
+		if (! isset($version_parts[4])) {
84
+			$version_parts[4] = '000';
85
+		}
86
+		return implode('.', $version_parts);
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * Returns whether or not the min core version requirement of the addon is met
92
-     *
93
-     * @param string $min_core_version    the minimum core version required by the addon
94
-     * @param string $actual_core_version the actual core version, optional
95
-     * @return boolean
96
-     */
97
-    public static function _meets_min_core_version_requirement(
98
-        $min_core_version,
99
-        $actual_core_version = EVENT_ESPRESSO_VERSION
100
-    ) {
101
-        return version_compare(
102
-            self::_effective_version($actual_core_version),
103
-            self::_effective_version($min_core_version),
104
-            '>='
105
-        );
106
-    }
90
+	/**
91
+	 * Returns whether or not the min core version requirement of the addon is met
92
+	 *
93
+	 * @param string $min_core_version    the minimum core version required by the addon
94
+	 * @param string $actual_core_version the actual core version, optional
95
+	 * @return boolean
96
+	 */
97
+	public static function _meets_min_core_version_requirement(
98
+		$min_core_version,
99
+		$actual_core_version = EVENT_ESPRESSO_VERSION
100
+	) {
101
+		return version_compare(
102
+			self::_effective_version($actual_core_version),
103
+			self::_effective_version($min_core_version),
104
+			'>='
105
+		);
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * Method for registering new EE_Addons.
111
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
112
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
113
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
114
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
115
-     * 'activate_plugin', it registers the addon still, but its components are not registered
116
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
117
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
118
-     * (so that we can detect that the addon has activated on the subsequent request)
119
-     *
120
-     * @since    4.3.0
121
-     * @param string                  $addon_name                       the EE_Addon's name. Required.
122
-     * @param  array                  $setup_args                       {
123
-     *                                                                  An array of arguments provided for registering the
124
-     *                                                                  message type.
125
-     * @type  string                  $class_name                       the addon's main file name.
126
-     *                                                                  If left blank, generated from the addon name,
127
-     *                                                                  changes something like "calendar" to "EE_Calendar"
128
-     * @type string                   $min_core_version                 the minimum version of EE Core that the
129
-     *                                                                  addon will work with. eg "4.8.1.rc.084"
130
-     * @type string                   $version                          the "software" version for the addon. eg
131
-     *                                                                  "1.0.0.p" for a first stable release, or
132
-     *                                                                  "1.0.0.rc.043" for a version in progress
133
-     * @type string                   $main_file_path                   the full server path to the main file
134
-     *                                                                  loaded directly by WP
135
-     * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
-     *                                                                  for the addon's Domain class
137
-     *                                                                  (see EventEspresso\core\domain\Domain)
138
-     * @type string                   $admin_path                       full server path to the folder where the
139
-     *                                                                  addon\'s admin files reside
140
-     * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
-     *                                                                  first invoked, can be used for hooking into
142
-     *                                                                  any admin page
143
-     * @type string                   $config_section                   the section name for this addon's
144
-     *                                                                  configuration settings section
145
-     *                                                                  (defaults to "addons")
146
-     * @type string                   $config_class                     the class name for this addon's
147
-     *                                                                  configuration settings object
148
-     * @type string                   $config_name                      the class name for this addon's
149
-     *                                                                  configuration settings object
150
-     * @type string                   $autoloader_paths                 an array of class names and the full server
151
-     *                                                                  paths to those files. Required.
152
-     * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
-     *                                                                  folders containing classes that might be
154
-     *                                                                  invoked by the addon
155
-     * @type string                   $dms_paths                        an array of full server paths to folders that
156
-     *                                                                  contain data migration scripts. Required.
157
-     * @type string                   $module_paths                     an array of full server paths to any
158
-     *                                                                  EED_Modules used by the addon
159
-     * @type string                   $shortcode_paths                  an array of full server paths to folders
160
-     *                                                                  that contain EES_Shortcodes
161
-     * @type string                   $widget_paths                     an array of full server paths to folders
162
-     *                                                                  that contain WP_Widgets
163
-     * @type string                   $pue_options
164
-     * @type array                    $capabilities                     an array indexed by role name
165
-     *                                                                  (i.e administrator,author ) and the values
166
-     *                                                                  are an array of caps to add to the role.
167
-     *                                                                  'administrator' => array(
168
-     *                                                                  'read_addon',
169
-     *                                                                  'edit_addon',
170
-     *                                                                  etc.
171
-     *                                                                  ).
172
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
173
-     *                                                                  for any addons that need to register any
174
-     *                                                                  special meta mapped capabilities.  Should
175
-     *                                                                  be indexed where the key is the
176
-     *                                                                  EE_Meta_Capability_Map class name and the
177
-     *                                                                  values are the arguments sent to the class.
178
-     * @type array                    $model_paths                      array of folders containing DB models
179
-     * @see      EE_Register_Model
180
-     * @type array                    $class_paths                      array of folders containing DB classes
181
-     * @see      EE_Register_Model
182
-     * @type array                    $model_extension_paths            array of folders containing DB model
183
-     *                                                                  extensions
184
-     * @see      EE_Register_Model_Extension
185
-     * @type array                    $class_extension_paths            array of folders containing DB class
186
-     *                                                                  extensions
187
-     * @see      EE_Register_Model_Extension
188
-     * @type array message_types {
189
-     *                                                                  An array of message types with the key as
190
-     *                                                                  the message type name and the values as
191
-     *                                                                  below:
192
-     * @type string                   $mtfilename                       The filename of the message type being
193
-     *                                                                  registered. This will be the main
194
-     *                                                                  EE_{Message Type Name}_message_type class.
195
-     *                                                                  (eg. EE_Declined_Registration_message_type.class.php)
196
-     *                                                                  Required.
197
-     * @type array                    $autoloadpaths                    An array of paths to add to the messages
198
-     *                                                                  autoloader for the new message type.
199
-     *                                                                  Required.
200
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
201
-     *                                                                  type should activate with. Each value in
202
-     *                                                                  the
203
-     *                                                                  array
204
-     *                                                                  should match the name property of a
205
-     *                                                                  EE_messenger. Optional.
206
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
207
-     *                                                                  type should validate with. Each value in
208
-     *                                                                  the
209
-     *                                                                  array
210
-     *                                                                  should match the name property of an
211
-     *                                                                  EE_messenger.
212
-     *                                                                  Optional.
213
-     *                                                                  }
214
-     * @type array                    $custom_post_types
215
-     * @type array                    $custom_taxonomies
216
-     * @type array                    $payment_method_paths             each element is the folder containing the
217
-     *                                                                  EE_PMT_Base child class
218
-     *                                                                  (eg,
219
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
220
-     *                                                                  which contains the files
221
-     *                                                                  EE_PMT_Payomatic.pm.php)
222
-     * @type array                    $default_terms
223
-     * @type array                    $namespace                        {
224
-     *                                                                  An array with two items for registering the
225
-     *                                                                  addon's namespace. (If, for some reason, you
226
-     *                                                                  require additional namespaces,
227
-     *                                                                  use EventEspresso\core\Psr4Autoloader::addNamespace()
228
-     *                                                                  directly)
229
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
230
-     * @type string                   $FQNS                             the namespace prefix
231
-     * @type string                   $DIR                              a base directory for class files in the
232
-     *                                                                  namespace.
233
-     *                                                                  }
234
-     *                                                                  }
235
-     * @return void
236
-     * @throws DomainException
237
-     * @throws EE_Error
238
-     * @throws InvalidArgumentException
239
-     * @throws ReflectionException
240
-     * @throws InvalidDataTypeException
241
-     * @throws InvalidInterfaceException
242
-     */
243
-    public static function register($addon_name = '', $setup_args = array())
244
-    {
245
-        // required fields MUST be present, so let's make sure they are.
246
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
247
-        // get class name for addon
248
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
249
-        //setup $_settings array from incoming values.
250
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
251
-        // setup PUE
252
-        EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
253
-        // does this addon work with this version of core or WordPress ?
254
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
255
-            return;
256
-        }
257
-        // register namespaces
258
-        EE_Register_Addon::_setup_namespaces($addon_settings);
259
-        // check if this is an activation request
260
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
261
-            // dont bother setting up the rest of the addon atm
262
-            return;
263
-        }
264
-        // we need cars
265
-        EE_Register_Addon::_setup_autoloaders($addon_name);
266
-        // register new models and extensions
267
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
268
-        // setup DMS
269
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
270
-        // if config_class is present let's register config.
271
-        EE_Register_Addon::_register_config($addon_name);
272
-        // register admin pages
273
-        EE_Register_Addon::_register_admin_pages($addon_name);
274
-        // add to list of modules to be registered
275
-        EE_Register_Addon::_register_modules($addon_name);
276
-        // add to list of shortcodes to be registered
277
-        EE_Register_Addon::_register_shortcodes($addon_name);
278
-        // add to list of widgets to be registered
279
-        EE_Register_Addon::_register_widgets($addon_name);
280
-        // register capability related stuff.
281
-        EE_Register_Addon::_register_capabilities($addon_name);
282
-        // any message type to register?
283
-        EE_Register_Addon::_register_message_types($addon_name);
284
-        // any custom post type/ custom capabilities or default terms to register
285
-        EE_Register_Addon::_register_custom_post_types($addon_name);
286
-        // and any payment methods
287
-        EE_Register_Addon::_register_payment_methods($addon_name);
288
-        // load and instantiate main addon class
289
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
290
-        //delay calling after_registration hook on each addon until after all add-ons have been registered.
291
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
292
-    }
109
+	/**
110
+	 * Method for registering new EE_Addons.
111
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
112
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
113
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
114
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
115
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
116
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
117
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
118
+	 * (so that we can detect that the addon has activated on the subsequent request)
119
+	 *
120
+	 * @since    4.3.0
121
+	 * @param string                  $addon_name                       the EE_Addon's name. Required.
122
+	 * @param  array                  $setup_args                       {
123
+	 *                                                                  An array of arguments provided for registering the
124
+	 *                                                                  message type.
125
+	 * @type  string                  $class_name                       the addon's main file name.
126
+	 *                                                                  If left blank, generated from the addon name,
127
+	 *                                                                  changes something like "calendar" to "EE_Calendar"
128
+	 * @type string                   $min_core_version                 the minimum version of EE Core that the
129
+	 *                                                                  addon will work with. eg "4.8.1.rc.084"
130
+	 * @type string                   $version                          the "software" version for the addon. eg
131
+	 *                                                                  "1.0.0.p" for a first stable release, or
132
+	 *                                                                  "1.0.0.rc.043" for a version in progress
133
+	 * @type string                   $main_file_path                   the full server path to the main file
134
+	 *                                                                  loaded directly by WP
135
+	 * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
+	 *                                                                  for the addon's Domain class
137
+	 *                                                                  (see EventEspresso\core\domain\Domain)
138
+	 * @type string                   $admin_path                       full server path to the folder where the
139
+	 *                                                                  addon\'s admin files reside
140
+	 * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
+	 *                                                                  first invoked, can be used for hooking into
142
+	 *                                                                  any admin page
143
+	 * @type string                   $config_section                   the section name for this addon's
144
+	 *                                                                  configuration settings section
145
+	 *                                                                  (defaults to "addons")
146
+	 * @type string                   $config_class                     the class name for this addon's
147
+	 *                                                                  configuration settings object
148
+	 * @type string                   $config_name                      the class name for this addon's
149
+	 *                                                                  configuration settings object
150
+	 * @type string                   $autoloader_paths                 an array of class names and the full server
151
+	 *                                                                  paths to those files. Required.
152
+	 * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
+	 *                                                                  folders containing classes that might be
154
+	 *                                                                  invoked by the addon
155
+	 * @type string                   $dms_paths                        an array of full server paths to folders that
156
+	 *                                                                  contain data migration scripts. Required.
157
+	 * @type string                   $module_paths                     an array of full server paths to any
158
+	 *                                                                  EED_Modules used by the addon
159
+	 * @type string                   $shortcode_paths                  an array of full server paths to folders
160
+	 *                                                                  that contain EES_Shortcodes
161
+	 * @type string                   $widget_paths                     an array of full server paths to folders
162
+	 *                                                                  that contain WP_Widgets
163
+	 * @type string                   $pue_options
164
+	 * @type array                    $capabilities                     an array indexed by role name
165
+	 *                                                                  (i.e administrator,author ) and the values
166
+	 *                                                                  are an array of caps to add to the role.
167
+	 *                                                                  'administrator' => array(
168
+	 *                                                                  'read_addon',
169
+	 *                                                                  'edit_addon',
170
+	 *                                                                  etc.
171
+	 *                                                                  ).
172
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
173
+	 *                                                                  for any addons that need to register any
174
+	 *                                                                  special meta mapped capabilities.  Should
175
+	 *                                                                  be indexed where the key is the
176
+	 *                                                                  EE_Meta_Capability_Map class name and the
177
+	 *                                                                  values are the arguments sent to the class.
178
+	 * @type array                    $model_paths                      array of folders containing DB models
179
+	 * @see      EE_Register_Model
180
+	 * @type array                    $class_paths                      array of folders containing DB classes
181
+	 * @see      EE_Register_Model
182
+	 * @type array                    $model_extension_paths            array of folders containing DB model
183
+	 *                                                                  extensions
184
+	 * @see      EE_Register_Model_Extension
185
+	 * @type array                    $class_extension_paths            array of folders containing DB class
186
+	 *                                                                  extensions
187
+	 * @see      EE_Register_Model_Extension
188
+	 * @type array message_types {
189
+	 *                                                                  An array of message types with the key as
190
+	 *                                                                  the message type name and the values as
191
+	 *                                                                  below:
192
+	 * @type string                   $mtfilename                       The filename of the message type being
193
+	 *                                                                  registered. This will be the main
194
+	 *                                                                  EE_{Message Type Name}_message_type class.
195
+	 *                                                                  (eg. EE_Declined_Registration_message_type.class.php)
196
+	 *                                                                  Required.
197
+	 * @type array                    $autoloadpaths                    An array of paths to add to the messages
198
+	 *                                                                  autoloader for the new message type.
199
+	 *                                                                  Required.
200
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
201
+	 *                                                                  type should activate with. Each value in
202
+	 *                                                                  the
203
+	 *                                                                  array
204
+	 *                                                                  should match the name property of a
205
+	 *                                                                  EE_messenger. Optional.
206
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
207
+	 *                                                                  type should validate with. Each value in
208
+	 *                                                                  the
209
+	 *                                                                  array
210
+	 *                                                                  should match the name property of an
211
+	 *                                                                  EE_messenger.
212
+	 *                                                                  Optional.
213
+	 *                                                                  }
214
+	 * @type array                    $custom_post_types
215
+	 * @type array                    $custom_taxonomies
216
+	 * @type array                    $payment_method_paths             each element is the folder containing the
217
+	 *                                                                  EE_PMT_Base child class
218
+	 *                                                                  (eg,
219
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
220
+	 *                                                                  which contains the files
221
+	 *                                                                  EE_PMT_Payomatic.pm.php)
222
+	 * @type array                    $default_terms
223
+	 * @type array                    $namespace                        {
224
+	 *                                                                  An array with two items for registering the
225
+	 *                                                                  addon's namespace. (If, for some reason, you
226
+	 *                                                                  require additional namespaces,
227
+	 *                                                                  use EventEspresso\core\Psr4Autoloader::addNamespace()
228
+	 *                                                                  directly)
229
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
230
+	 * @type string                   $FQNS                             the namespace prefix
231
+	 * @type string                   $DIR                              a base directory for class files in the
232
+	 *                                                                  namespace.
233
+	 *                                                                  }
234
+	 *                                                                  }
235
+	 * @return void
236
+	 * @throws DomainException
237
+	 * @throws EE_Error
238
+	 * @throws InvalidArgumentException
239
+	 * @throws ReflectionException
240
+	 * @throws InvalidDataTypeException
241
+	 * @throws InvalidInterfaceException
242
+	 */
243
+	public static function register($addon_name = '', $setup_args = array())
244
+	{
245
+		// required fields MUST be present, so let's make sure they are.
246
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
247
+		// get class name for addon
248
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
249
+		//setup $_settings array from incoming values.
250
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
251
+		// setup PUE
252
+		EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
253
+		// does this addon work with this version of core or WordPress ?
254
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
255
+			return;
256
+		}
257
+		// register namespaces
258
+		EE_Register_Addon::_setup_namespaces($addon_settings);
259
+		// check if this is an activation request
260
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
261
+			// dont bother setting up the rest of the addon atm
262
+			return;
263
+		}
264
+		// we need cars
265
+		EE_Register_Addon::_setup_autoloaders($addon_name);
266
+		// register new models and extensions
267
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
268
+		// setup DMS
269
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
270
+		// if config_class is present let's register config.
271
+		EE_Register_Addon::_register_config($addon_name);
272
+		// register admin pages
273
+		EE_Register_Addon::_register_admin_pages($addon_name);
274
+		// add to list of modules to be registered
275
+		EE_Register_Addon::_register_modules($addon_name);
276
+		// add to list of shortcodes to be registered
277
+		EE_Register_Addon::_register_shortcodes($addon_name);
278
+		// add to list of widgets to be registered
279
+		EE_Register_Addon::_register_widgets($addon_name);
280
+		// register capability related stuff.
281
+		EE_Register_Addon::_register_capabilities($addon_name);
282
+		// any message type to register?
283
+		EE_Register_Addon::_register_message_types($addon_name);
284
+		// any custom post type/ custom capabilities or default terms to register
285
+		EE_Register_Addon::_register_custom_post_types($addon_name);
286
+		// and any payment methods
287
+		EE_Register_Addon::_register_payment_methods($addon_name);
288
+		// load and instantiate main addon class
289
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
290
+		//delay calling after_registration hook on each addon until after all add-ons have been registered.
291
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
292
+	}
293 293
 
294 294
 
295
-    /**
296
-     * @param string $addon_name
297
-     * @param array  $setup_args
298
-     * @return void
299
-     * @throws EE_Error
300
-     */
301
-    private static function _verify_parameters($addon_name, array $setup_args)
302
-    {
303
-        // required fields MUST be present, so let's make sure they are.
304
-        if (empty($addon_name) || ! is_array($setup_args)) {
305
-            throw new EE_Error(
306
-                __(
307
-                    'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
308
-                    'event_espresso'
309
-                )
310
-            );
311
-        }
312
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
313
-            throw new EE_Error(
314
-                sprintf(
315
-                    __(
316
-                        'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
317
-                        'event_espresso'
318
-                    ),
319
-                    implode(',', array_keys($setup_args))
320
-                )
321
-            );
322
-        }
323
-        // check that addon has not already been registered with that name
324
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
325
-            throw new EE_Error(
326
-                sprintf(
327
-                    __(
328
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
329
-                        'event_espresso'
330
-                    ),
331
-                    $addon_name
332
-                )
333
-            );
334
-        }
335
-    }
295
+	/**
296
+	 * @param string $addon_name
297
+	 * @param array  $setup_args
298
+	 * @return void
299
+	 * @throws EE_Error
300
+	 */
301
+	private static function _verify_parameters($addon_name, array $setup_args)
302
+	{
303
+		// required fields MUST be present, so let's make sure they are.
304
+		if (empty($addon_name) || ! is_array($setup_args)) {
305
+			throw new EE_Error(
306
+				__(
307
+					'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
308
+					'event_espresso'
309
+				)
310
+			);
311
+		}
312
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
313
+			throw new EE_Error(
314
+				sprintf(
315
+					__(
316
+						'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
317
+						'event_espresso'
318
+					),
319
+					implode(',', array_keys($setup_args))
320
+				)
321
+			);
322
+		}
323
+		// check that addon has not already been registered with that name
324
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
325
+			throw new EE_Error(
326
+				sprintf(
327
+					__(
328
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
329
+						'event_espresso'
330
+					),
331
+					$addon_name
332
+				)
333
+			);
334
+		}
335
+	}
336 336
 
337 337
 
338
-    /**
339
-     * @param string $addon_name
340
-     * @param array  $setup_args
341
-     * @return string
342
-     */
343
-    private static function _parse_class_name($addon_name, array $setup_args)
344
-    {
345
-        if (empty($setup_args['class_name'])) {
346
-            // generate one by first separating name with spaces
347
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
348
-            //capitalize, then replace spaces with underscores
349
-            $class_name = str_replace(' ', '_', ucwords($class_name));
350
-        } else {
351
-            $class_name = $setup_args['class_name'];
352
-        }
353
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
354
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
355
-            ? $class_name
356
-            : 'EE_' . $class_name;
357
-    }
338
+	/**
339
+	 * @param string $addon_name
340
+	 * @param array  $setup_args
341
+	 * @return string
342
+	 */
343
+	private static function _parse_class_name($addon_name, array $setup_args)
344
+	{
345
+		if (empty($setup_args['class_name'])) {
346
+			// generate one by first separating name with spaces
347
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
348
+			//capitalize, then replace spaces with underscores
349
+			$class_name = str_replace(' ', '_', ucwords($class_name));
350
+		} else {
351
+			$class_name = $setup_args['class_name'];
352
+		}
353
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
354
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
355
+			? $class_name
356
+			: 'EE_' . $class_name;
357
+	}
358 358
 
359 359
 
360
-    /**
361
-     * @param string $class_name
362
-     * @param array  $setup_args
363
-     * @return array
364
-     */
365
-    private static function _get_addon_settings($class_name, array $setup_args)
366
-    {
367
-        //setup $_settings array from incoming values.
368
-        $addon_settings = array(
369
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
370
-            'class_name'            => $class_name,
371
-            // the addon slug for use in URLs, etc
372
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
373
-                ? (string) $setup_args['plugin_slug']
374
-                : '',
375
-            // page slug to be used when generating the "Settings" link on the WP plugin page
376
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
377
-                ? (string) $setup_args['plugin_action_slug']
378
-                : '',
379
-            // the "software" version for the addon
380
-            'version'               => isset($setup_args['version'])
381
-                ? (string) $setup_args['version']
382
-                : '',
383
-            // the minimum version of EE Core that the addon will work with
384
-            'min_core_version'      => isset($setup_args['min_core_version'])
385
-                ? (string) $setup_args['min_core_version']
386
-                : '',
387
-            // the minimum version of WordPress that the addon will work with
388
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
389
-                ? (string) $setup_args['min_wp_version']
390
-                : EE_MIN_WP_VER_REQUIRED,
391
-            // full server path to main file (file loaded directly by WP)
392
-            'main_file_path'        => isset($setup_args['main_file_path'])
393
-                ? (string) $setup_args['main_file_path']
394
-                : '',
395
-            // Fully Qualified Class Name for the addon's Domain class
396
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
397
-                ? (string) $setup_args['domain_fqcn']
398
-                : '',
399
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
400
-            'admin_path'            => isset($setup_args['admin_path'])
401
-                ? (string) $setup_args['admin_path'] : '',
402
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
403
-            'admin_callback'        => isset($setup_args['admin_callback'])
404
-                ? (string) $setup_args['admin_callback']
405
-                : '',
406
-            // the section name for this addon's configuration settings section (defaults to "addons")
407
-            'config_section'        => isset($setup_args['config_section'])
408
-                ? (string) $setup_args['config_section']
409
-                : 'addons',
410
-            // the class name for this addon's configuration settings object
411
-            'config_class'          => isset($setup_args['config_class'])
412
-                ? (string) $setup_args['config_class'] : '',
413
-            //the name given to the config for this addons' configuration settings object (optional)
414
-            'config_name'           => isset($setup_args['config_name'])
415
-                ? (string) $setup_args['config_name'] : '',
416
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
417
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
418
-                ? (array) $setup_args['autoloader_paths']
419
-                : array(),
420
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
421
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
422
-                ? (array) $setup_args['autoloader_folders']
423
-                : array(),
424
-            // array of full server paths to any EE_DMS data migration scripts used by the addon
425
-            'dms_paths'             => isset($setup_args['dms_paths'])
426
-                ? (array) $setup_args['dms_paths']
427
-                : array(),
428
-            // array of full server paths to any EED_Modules used by the addon
429
-            'module_paths'          => isset($setup_args['module_paths'])
430
-                ? (array) $setup_args['module_paths']
431
-                : array(),
432
-            // array of full server paths to any EES_Shortcodes used by the addon
433
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
434
-                ? (array) $setup_args['shortcode_paths']
435
-                : array(),
436
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
437
-                ? (array) $setup_args['shortcode_fqcns']
438
-                : array(),
439
-            // array of full server paths to any WP_Widgets used by the addon
440
-            'widget_paths'          => isset($setup_args['widget_paths'])
441
-                ? (array) $setup_args['widget_paths']
442
-                : array(),
443
-            // array of PUE options used by the addon
444
-            'pue_options'           => isset($setup_args['pue_options'])
445
-                ? (array) $setup_args['pue_options']
446
-                : array(),
447
-            'message_types'         => isset($setup_args['message_types'])
448
-                ? (array) $setup_args['message_types']
449
-                : array(),
450
-            'capabilities'          => isset($setup_args['capabilities'])
451
-                ? (array) $setup_args['capabilities']
452
-                : array(),
453
-            'capability_maps'       => isset($setup_args['capability_maps'])
454
-                ? (array) $setup_args['capability_maps']
455
-                : array(),
456
-            'model_paths'           => isset($setup_args['model_paths'])
457
-                ? (array) $setup_args['model_paths']
458
-                : array(),
459
-            'class_paths'           => isset($setup_args['class_paths'])
460
-                ? (array) $setup_args['class_paths']
461
-                : array(),
462
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
463
-                ? (array) $setup_args['model_extension_paths']
464
-                : array(),
465
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
466
-                ? (array) $setup_args['class_extension_paths']
467
-                : array(),
468
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
469
-                ? (array) $setup_args['custom_post_types']
470
-                : array(),
471
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
472
-                ? (array) $setup_args['custom_taxonomies']
473
-                : array(),
474
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
475
-                ? (array) $setup_args['payment_method_paths']
476
-                : array(),
477
-            'default_terms'         => isset($setup_args['default_terms'])
478
-                ? (array) $setup_args['default_terms']
479
-                : array(),
480
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
481
-            // that can be used for adding upgrading/marketing info
482
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
483
-                ? $setup_args['plugins_page_row']
484
-                : '',
485
-            'namespace'             => isset(
486
-                $setup_args['namespace']['FQNS'],
487
-                $setup_args['namespace']['DIR']
488
-            )
489
-                ? (array) $setup_args['namespace']
490
-                : array(),
491
-        );
492
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
493
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
494
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
495
-                                                && ! empty($addon_settings['admin_path'])
496
-            ? $addon_settings['plugin_slug']
497
-            : $addon_settings['plugin_action_slug'];
498
-        // full server path to main file (file loaded directly by WP)
499
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
500
-        return $addon_settings;
501
-    }
360
+	/**
361
+	 * @param string $class_name
362
+	 * @param array  $setup_args
363
+	 * @return array
364
+	 */
365
+	private static function _get_addon_settings($class_name, array $setup_args)
366
+	{
367
+		//setup $_settings array from incoming values.
368
+		$addon_settings = array(
369
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
370
+			'class_name'            => $class_name,
371
+			// the addon slug for use in URLs, etc
372
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
373
+				? (string) $setup_args['plugin_slug']
374
+				: '',
375
+			// page slug to be used when generating the "Settings" link on the WP plugin page
376
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
377
+				? (string) $setup_args['plugin_action_slug']
378
+				: '',
379
+			// the "software" version for the addon
380
+			'version'               => isset($setup_args['version'])
381
+				? (string) $setup_args['version']
382
+				: '',
383
+			// the minimum version of EE Core that the addon will work with
384
+			'min_core_version'      => isset($setup_args['min_core_version'])
385
+				? (string) $setup_args['min_core_version']
386
+				: '',
387
+			// the minimum version of WordPress that the addon will work with
388
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
389
+				? (string) $setup_args['min_wp_version']
390
+				: EE_MIN_WP_VER_REQUIRED,
391
+			// full server path to main file (file loaded directly by WP)
392
+			'main_file_path'        => isset($setup_args['main_file_path'])
393
+				? (string) $setup_args['main_file_path']
394
+				: '',
395
+			// Fully Qualified Class Name for the addon's Domain class
396
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
397
+				? (string) $setup_args['domain_fqcn']
398
+				: '',
399
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
400
+			'admin_path'            => isset($setup_args['admin_path'])
401
+				? (string) $setup_args['admin_path'] : '',
402
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
403
+			'admin_callback'        => isset($setup_args['admin_callback'])
404
+				? (string) $setup_args['admin_callback']
405
+				: '',
406
+			// the section name for this addon's configuration settings section (defaults to "addons")
407
+			'config_section'        => isset($setup_args['config_section'])
408
+				? (string) $setup_args['config_section']
409
+				: 'addons',
410
+			// the class name for this addon's configuration settings object
411
+			'config_class'          => isset($setup_args['config_class'])
412
+				? (string) $setup_args['config_class'] : '',
413
+			//the name given to the config for this addons' configuration settings object (optional)
414
+			'config_name'           => isset($setup_args['config_name'])
415
+				? (string) $setup_args['config_name'] : '',
416
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
417
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
418
+				? (array) $setup_args['autoloader_paths']
419
+				: array(),
420
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
421
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
422
+				? (array) $setup_args['autoloader_folders']
423
+				: array(),
424
+			// array of full server paths to any EE_DMS data migration scripts used by the addon
425
+			'dms_paths'             => isset($setup_args['dms_paths'])
426
+				? (array) $setup_args['dms_paths']
427
+				: array(),
428
+			// array of full server paths to any EED_Modules used by the addon
429
+			'module_paths'          => isset($setup_args['module_paths'])
430
+				? (array) $setup_args['module_paths']
431
+				: array(),
432
+			// array of full server paths to any EES_Shortcodes used by the addon
433
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
434
+				? (array) $setup_args['shortcode_paths']
435
+				: array(),
436
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
437
+				? (array) $setup_args['shortcode_fqcns']
438
+				: array(),
439
+			// array of full server paths to any WP_Widgets used by the addon
440
+			'widget_paths'          => isset($setup_args['widget_paths'])
441
+				? (array) $setup_args['widget_paths']
442
+				: array(),
443
+			// array of PUE options used by the addon
444
+			'pue_options'           => isset($setup_args['pue_options'])
445
+				? (array) $setup_args['pue_options']
446
+				: array(),
447
+			'message_types'         => isset($setup_args['message_types'])
448
+				? (array) $setup_args['message_types']
449
+				: array(),
450
+			'capabilities'          => isset($setup_args['capabilities'])
451
+				? (array) $setup_args['capabilities']
452
+				: array(),
453
+			'capability_maps'       => isset($setup_args['capability_maps'])
454
+				? (array) $setup_args['capability_maps']
455
+				: array(),
456
+			'model_paths'           => isset($setup_args['model_paths'])
457
+				? (array) $setup_args['model_paths']
458
+				: array(),
459
+			'class_paths'           => isset($setup_args['class_paths'])
460
+				? (array) $setup_args['class_paths']
461
+				: array(),
462
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
463
+				? (array) $setup_args['model_extension_paths']
464
+				: array(),
465
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
466
+				? (array) $setup_args['class_extension_paths']
467
+				: array(),
468
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
469
+				? (array) $setup_args['custom_post_types']
470
+				: array(),
471
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
472
+				? (array) $setup_args['custom_taxonomies']
473
+				: array(),
474
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
475
+				? (array) $setup_args['payment_method_paths']
476
+				: array(),
477
+			'default_terms'         => isset($setup_args['default_terms'])
478
+				? (array) $setup_args['default_terms']
479
+				: array(),
480
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
481
+			// that can be used for adding upgrading/marketing info
482
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
483
+				? $setup_args['plugins_page_row']
484
+				: '',
485
+			'namespace'             => isset(
486
+				$setup_args['namespace']['FQNS'],
487
+				$setup_args['namespace']['DIR']
488
+			)
489
+				? (array) $setup_args['namespace']
490
+				: array(),
491
+		);
492
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
493
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
494
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
495
+												&& ! empty($addon_settings['admin_path'])
496
+			? $addon_settings['plugin_slug']
497
+			: $addon_settings['plugin_action_slug'];
498
+		// full server path to main file (file loaded directly by WP)
499
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
500
+		return $addon_settings;
501
+	}
502 502
 
503 503
 
504
-    /**
505
-     * @param string $addon_name
506
-     * @param array  $addon_settings
507
-     * @return boolean
508
-     */
509
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
510
-    {
511
-        global $wp_version;
512
-        $incompatibility_message = '';
513
-        //check whether this addon version is compatible with EE core
514
-        if (
515
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
516
-            && ! self::_meets_min_core_version_requirement(
517
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
518
-                $addon_settings['version']
519
-            )
520
-        ) {
521
-            $incompatibility_message = sprintf(
522
-                __(
523
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
524
-                ),
525
-                $addon_name,
526
-                '<br />',
527
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
528
-                '<span style="font-weight: bold; color: #D54E21;">',
529
-                '</span><br />'
530
-            );
531
-        } elseif (
532
-        ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
533
-        ) {
534
-            $incompatibility_message = sprintf(
535
-                __(
536
-                    '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
537
-                    'event_espresso'
538
-                ),
539
-                $addon_name,
540
-                self::_effective_version($addon_settings['min_core_version']),
541
-                self::_effective_version(espresso_version()),
542
-                '<br />',
543
-                '<span style="font-weight: bold; color: #D54E21;">',
544
-                '</span><br />'
545
-            );
546
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
547
-            $incompatibility_message = sprintf(
548
-                __(
549
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
550
-                    'event_espresso'
551
-                ),
552
-                $addon_name,
553
-                $addon_settings['min_wp_version'],
554
-                '<br />',
555
-                '<span style="font-weight: bold; color: #D54E21;">',
556
-                '</span><br />'
557
-            );
558
-        }
559
-        if (! empty($incompatibility_message)) {
560
-            // remove 'activate' from the REQUEST
561
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
562
-            unset($_GET['activate'], $_REQUEST['activate']);
563
-            if (current_user_can('activate_plugins')) {
564
-                // show an error message indicating the plugin didn't activate properly
565
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
566
-            }
567
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
568
-            return false;
569
-        }
570
-        // addon IS compatible
571
-        return true;
572
-    }
504
+	/**
505
+	 * @param string $addon_name
506
+	 * @param array  $addon_settings
507
+	 * @return boolean
508
+	 */
509
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
510
+	{
511
+		global $wp_version;
512
+		$incompatibility_message = '';
513
+		//check whether this addon version is compatible with EE core
514
+		if (
515
+			isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
516
+			&& ! self::_meets_min_core_version_requirement(
517
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
518
+				$addon_settings['version']
519
+			)
520
+		) {
521
+			$incompatibility_message = sprintf(
522
+				__(
523
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
524
+				),
525
+				$addon_name,
526
+				'<br />',
527
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
528
+				'<span style="font-weight: bold; color: #D54E21;">',
529
+				'</span><br />'
530
+			);
531
+		} elseif (
532
+		! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
533
+		) {
534
+			$incompatibility_message = sprintf(
535
+				__(
536
+					'%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
537
+					'event_espresso'
538
+				),
539
+				$addon_name,
540
+				self::_effective_version($addon_settings['min_core_version']),
541
+				self::_effective_version(espresso_version()),
542
+				'<br />',
543
+				'<span style="font-weight: bold; color: #D54E21;">',
544
+				'</span><br />'
545
+			);
546
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
547
+			$incompatibility_message = sprintf(
548
+				__(
549
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
550
+					'event_espresso'
551
+				),
552
+				$addon_name,
553
+				$addon_settings['min_wp_version'],
554
+				'<br />',
555
+				'<span style="font-weight: bold; color: #D54E21;">',
556
+				'</span><br />'
557
+			);
558
+		}
559
+		if (! empty($incompatibility_message)) {
560
+			// remove 'activate' from the REQUEST
561
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
562
+			unset($_GET['activate'], $_REQUEST['activate']);
563
+			if (current_user_can('activate_plugins')) {
564
+				// show an error message indicating the plugin didn't activate properly
565
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
566
+			}
567
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
568
+			return false;
569
+		}
570
+		// addon IS compatible
571
+		return true;
572
+	}
573 573
 
574 574
 
575
-    /**
576
-     * if plugin update engine is being used for auto-updates,
577
-     * then let's set that up now before going any further so that ALL addons can be updated
578
-     * (not needed if PUE is not being used)
579
-     *
580
-     * @param string $addon_name
581
-     * @param string $class_name
582
-     * @param array  $setup_args
583
-     * @return void
584
-     */
585
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
586
-    {
587
-        if (! empty($setup_args['pue_options'])) {
588
-            self::$_settings[ $addon_name ]['pue_options'] = array(
589
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
590
-                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
591
-                    : 'espresso_' . strtolower($class_name),
592
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
593
-                    ? (string) $setup_args['pue_options']['plugin_basename']
594
-                    : plugin_basename($setup_args['main_file_path']),
595
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
596
-                    ? (string) $setup_args['pue_options']['checkPeriod']
597
-                    : '24',
598
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
599
-                    ? (string) $setup_args['pue_options']['use_wp_update']
600
-                    : false,
601
-            );
602
-            add_action(
603
-                'AHEE__EE_System__brew_espresso__after_pue_init',
604
-                array('EE_Register_Addon', 'load_pue_update')
605
-            );
606
-        }
607
-    }
575
+	/**
576
+	 * if plugin update engine is being used for auto-updates,
577
+	 * then let's set that up now before going any further so that ALL addons can be updated
578
+	 * (not needed if PUE is not being used)
579
+	 *
580
+	 * @param string $addon_name
581
+	 * @param string $class_name
582
+	 * @param array  $setup_args
583
+	 * @return void
584
+	 */
585
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
586
+	{
587
+		if (! empty($setup_args['pue_options'])) {
588
+			self::$_settings[ $addon_name ]['pue_options'] = array(
589
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
590
+					? (string) $setup_args['pue_options']['pue_plugin_slug']
591
+					: 'espresso_' . strtolower($class_name),
592
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
593
+					? (string) $setup_args['pue_options']['plugin_basename']
594
+					: plugin_basename($setup_args['main_file_path']),
595
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
596
+					? (string) $setup_args['pue_options']['checkPeriod']
597
+					: '24',
598
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
599
+					? (string) $setup_args['pue_options']['use_wp_update']
600
+					: false,
601
+			);
602
+			add_action(
603
+				'AHEE__EE_System__brew_espresso__after_pue_init',
604
+				array('EE_Register_Addon', 'load_pue_update')
605
+			);
606
+		}
607
+	}
608 608
 
609 609
 
610
-    /**
611
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
612
-     *
613
-     * @param array $addon_settings
614
-     * @return void
615
-     */
616
-    private static function _setup_namespaces(array $addon_settings)
617
-    {
618
-        //
619
-        if (
620
-        isset(
621
-            $addon_settings['namespace']['FQNS'],
622
-            $addon_settings['namespace']['DIR']
623
-        )
624
-        ) {
625
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
626
-                $addon_settings['namespace']['FQNS'],
627
-                $addon_settings['namespace']['DIR']
628
-            );
629
-        }
630
-    }
610
+	/**
611
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
612
+	 *
613
+	 * @param array $addon_settings
614
+	 * @return void
615
+	 */
616
+	private static function _setup_namespaces(array $addon_settings)
617
+	{
618
+		//
619
+		if (
620
+		isset(
621
+			$addon_settings['namespace']['FQNS'],
622
+			$addon_settings['namespace']['DIR']
623
+		)
624
+		) {
625
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
626
+				$addon_settings['namespace']['FQNS'],
627
+				$addon_settings['namespace']['DIR']
628
+			);
629
+		}
630
+	}
631 631
 
632 632
 
633
-    /**
634
-     * @param string $addon_name
635
-     * @param array  $addon_settings
636
-     * @return bool
637
-     * @throws EE_Error
638
-     * @throws InvalidArgumentException
639
-     * @throws ReflectionException
640
-     * @throws InvalidDataTypeException
641
-     * @throws InvalidInterfaceException
642
-     */
643
-    private static function _addon_activation($addon_name, array $addon_settings)
644
-    {
645
-        // this is an activation request
646
-        if (did_action('activate_plugin')) {
647
-            //to find if THIS is the addon that was activated, just check if we have already registered it or not
648
-            //(as the newly-activated addon wasn't around the first time addons were registered).
649
-            //Note: the presence of pue_options in the addon registration options will initialize the $_settings
650
-            //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
651
-            if (! isset(self::$_settings[ $addon_name ])
652
-                || (isset(self::$_settings[ $addon_name ])
653
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
654
-                )
655
-            ) {
656
-                self::$_settings[ $addon_name ] = $addon_settings;
657
-                $addon                          = self::_load_and_init_addon_class($addon_name);
658
-                $addon->set_activation_indicator_option();
659
-                // dont bother setting up the rest of the addon.
660
-                // we know it was just activated and the request will end soon
661
-            }
662
-            return true;
663
-        }
664
-        // make sure this was called in the right place!
665
-        if (
666
-            ! did_action('AHEE__EE_System__load_espresso_addons')
667
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
668
-        ) {
669
-            EE_Error::doing_it_wrong(
670
-                __METHOD__,
671
-                sprintf(
672
-                    __(
673
-                        'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
674
-                        'event_espresso'
675
-                    ),
676
-                    $addon_name
677
-                ),
678
-                '4.3.0'
679
-            );
680
-        }
681
-        // make sure addon settings are set correctly without overwriting anything existing
682
-        if (isset(self::$_settings[ $addon_name ])) {
683
-            self::$_settings[ $addon_name ] += $addon_settings;
684
-        } else {
685
-            self::$_settings[ $addon_name ] = $addon_settings;
686
-        }
687
-        return false;
688
-    }
633
+	/**
634
+	 * @param string $addon_name
635
+	 * @param array  $addon_settings
636
+	 * @return bool
637
+	 * @throws EE_Error
638
+	 * @throws InvalidArgumentException
639
+	 * @throws ReflectionException
640
+	 * @throws InvalidDataTypeException
641
+	 * @throws InvalidInterfaceException
642
+	 */
643
+	private static function _addon_activation($addon_name, array $addon_settings)
644
+	{
645
+		// this is an activation request
646
+		if (did_action('activate_plugin')) {
647
+			//to find if THIS is the addon that was activated, just check if we have already registered it or not
648
+			//(as the newly-activated addon wasn't around the first time addons were registered).
649
+			//Note: the presence of pue_options in the addon registration options will initialize the $_settings
650
+			//property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
651
+			if (! isset(self::$_settings[ $addon_name ])
652
+				|| (isset(self::$_settings[ $addon_name ])
653
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
654
+				)
655
+			) {
656
+				self::$_settings[ $addon_name ] = $addon_settings;
657
+				$addon                          = self::_load_and_init_addon_class($addon_name);
658
+				$addon->set_activation_indicator_option();
659
+				// dont bother setting up the rest of the addon.
660
+				// we know it was just activated and the request will end soon
661
+			}
662
+			return true;
663
+		}
664
+		// make sure this was called in the right place!
665
+		if (
666
+			! did_action('AHEE__EE_System__load_espresso_addons')
667
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
668
+		) {
669
+			EE_Error::doing_it_wrong(
670
+				__METHOD__,
671
+				sprintf(
672
+					__(
673
+						'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
674
+						'event_espresso'
675
+					),
676
+					$addon_name
677
+				),
678
+				'4.3.0'
679
+			);
680
+		}
681
+		// make sure addon settings are set correctly without overwriting anything existing
682
+		if (isset(self::$_settings[ $addon_name ])) {
683
+			self::$_settings[ $addon_name ] += $addon_settings;
684
+		} else {
685
+			self::$_settings[ $addon_name ] = $addon_settings;
686
+		}
687
+		return false;
688
+	}
689 689
 
690 690
 
691
-    /**
692
-     * @param string $addon_name
693
-     * @return void
694
-     * @throws EE_Error
695
-     */
696
-    private static function _setup_autoloaders($addon_name)
697
-    {
698
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
699
-            // setup autoloader for single file
700
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
701
-        }
702
-        // setup autoloaders for folders
703
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
705
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706
-            }
707
-        }
708
-    }
691
+	/**
692
+	 * @param string $addon_name
693
+	 * @return void
694
+	 * @throws EE_Error
695
+	 */
696
+	private static function _setup_autoloaders($addon_name)
697
+	{
698
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
699
+			// setup autoloader for single file
700
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
701
+		}
702
+		// setup autoloaders for folders
703
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
705
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706
+			}
707
+		}
708
+	}
709 709
 
710 710
 
711
-    /**
712
-     * register new models and extensions
713
-     *
714
-     * @param string $addon_name
715
-     * @return void
716
-     * @throws EE_Error
717
-     */
718
-    private static function _register_models_and_extensions($addon_name)
719
-    {
720
-        // register new models
721
-        if (
722
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
723
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
724
-        ) {
725
-            EE_Register_Model::register(
726
-                $addon_name,
727
-                array(
728
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
730
-                )
731
-            );
732
-        }
733
-        // register model extensions
734
-        if (
735
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
737
-        ) {
738
-            EE_Register_Model_Extensions::register(
739
-                $addon_name,
740
-                array(
741
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
743
-                )
744
-            );
745
-        }
746
-    }
711
+	/**
712
+	 * register new models and extensions
713
+	 *
714
+	 * @param string $addon_name
715
+	 * @return void
716
+	 * @throws EE_Error
717
+	 */
718
+	private static function _register_models_and_extensions($addon_name)
719
+	{
720
+		// register new models
721
+		if (
722
+			! empty(self::$_settings[ $addon_name ]['model_paths'])
723
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
724
+		) {
725
+			EE_Register_Model::register(
726
+				$addon_name,
727
+				array(
728
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
730
+				)
731
+			);
732
+		}
733
+		// register model extensions
734
+		if (
735
+			! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
737
+		) {
738
+			EE_Register_Model_Extensions::register(
739
+				$addon_name,
740
+				array(
741
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
743
+				)
744
+			);
745
+		}
746
+	}
747 747
 
748 748
 
749
-    /**
750
-     * @param string $addon_name
751
-     * @return void
752
-     * @throws EE_Error
753
-     */
754
-    private static function _register_data_migration_scripts($addon_name)
755
-    {
756
-        // setup DMS
757
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
758
-            EE_Register_Data_Migration_Scripts::register(
759
-                $addon_name,
760
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
761
-            );
762
-        }
763
-    }
749
+	/**
750
+	 * @param string $addon_name
751
+	 * @return void
752
+	 * @throws EE_Error
753
+	 */
754
+	private static function _register_data_migration_scripts($addon_name)
755
+	{
756
+		// setup DMS
757
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
758
+			EE_Register_Data_Migration_Scripts::register(
759
+				$addon_name,
760
+				array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
761
+			);
762
+		}
763
+	}
764 764
 
765 765
 
766
-    /**
767
-     * @param string $addon_name
768
-     * @return void
769
-     * @throws EE_Error
770
-     */
771
-    private static function _register_config($addon_name)
772
-    {
773
-        // if config_class is present let's register config.
774
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
775
-            EE_Register_Config::register(
776
-                self::$_settings[ $addon_name ]['config_class'],
777
-                array(
778
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
780
-                )
781
-            );
782
-        }
783
-    }
766
+	/**
767
+	 * @param string $addon_name
768
+	 * @return void
769
+	 * @throws EE_Error
770
+	 */
771
+	private static function _register_config($addon_name)
772
+	{
773
+		// if config_class is present let's register config.
774
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
775
+			EE_Register_Config::register(
776
+				self::$_settings[ $addon_name ]['config_class'],
777
+				array(
778
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
780
+				)
781
+			);
782
+		}
783
+	}
784 784
 
785 785
 
786
-    /**
787
-     * @param string $addon_name
788
-     * @return void
789
-     * @throws EE_Error
790
-     */
791
-    private static function _register_admin_pages($addon_name)
792
-    {
793
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
794
-            EE_Register_Admin_Page::register(
795
-                $addon_name,
796
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
797
-            );
798
-        }
799
-    }
786
+	/**
787
+	 * @param string $addon_name
788
+	 * @return void
789
+	 * @throws EE_Error
790
+	 */
791
+	private static function _register_admin_pages($addon_name)
792
+	{
793
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
794
+			EE_Register_Admin_Page::register(
795
+				$addon_name,
796
+				array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
797
+			);
798
+		}
799
+	}
800 800
 
801 801
 
802
-    /**
803
-     * @param string $addon_name
804
-     * @return void
805
-     * @throws EE_Error
806
-     */
807
-    private static function _register_modules($addon_name)
808
-    {
809
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
810
-            EE_Register_Module::register(
811
-                $addon_name,
812
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
813
-            );
814
-        }
815
-    }
802
+	/**
803
+	 * @param string $addon_name
804
+	 * @return void
805
+	 * @throws EE_Error
806
+	 */
807
+	private static function _register_modules($addon_name)
808
+	{
809
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
810
+			EE_Register_Module::register(
811
+				$addon_name,
812
+				array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
813
+			);
814
+		}
815
+	}
816 816
 
817 817
 
818
-    /**
819
-     * @param string $addon_name
820
-     * @return void
821
-     * @throws EE_Error
822
-     */
823
-    private static function _register_shortcodes($addon_name)
824
-    {
825
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
826
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
827
-        ) {
828
-            EE_Register_Shortcode::register(
829
-                $addon_name,
830
-                array(
831
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
832
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
833
-                        : array(),
834
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
835
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
836
-                        : array(),
837
-                )
838
-            );
839
-        }
840
-    }
818
+	/**
819
+	 * @param string $addon_name
820
+	 * @return void
821
+	 * @throws EE_Error
822
+	 */
823
+	private static function _register_shortcodes($addon_name)
824
+	{
825
+		if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
826
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
827
+		) {
828
+			EE_Register_Shortcode::register(
829
+				$addon_name,
830
+				array(
831
+					'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
832
+						? self::$_settings[ $addon_name ]['shortcode_paths']
833
+						: array(),
834
+					'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
835
+						? self::$_settings[ $addon_name ]['shortcode_fqcns']
836
+						: array(),
837
+				)
838
+			);
839
+		}
840
+	}
841 841
 
842 842
 
843
-    /**
844
-     * @param string $addon_name
845
-     * @return void
846
-     * @throws EE_Error
847
-     */
848
-    private static function _register_widgets($addon_name)
849
-    {
850
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
851
-            EE_Register_Widget::register(
852
-                $addon_name,
853
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
854
-            );
855
-        }
856
-    }
843
+	/**
844
+	 * @param string $addon_name
845
+	 * @return void
846
+	 * @throws EE_Error
847
+	 */
848
+	private static function _register_widgets($addon_name)
849
+	{
850
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
851
+			EE_Register_Widget::register(
852
+				$addon_name,
853
+				array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
854
+			);
855
+		}
856
+	}
857 857
 
858 858
 
859
-    /**
860
-     * @param string $addon_name
861
-     * @return void
862
-     * @throws EE_Error
863
-     */
864
-    private static function _register_capabilities($addon_name)
865
-    {
866
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
867
-            EE_Register_Capabilities::register(
868
-                $addon_name,
869
-                array(
870
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
871
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
872
-                )
873
-            );
874
-        }
875
-    }
859
+	/**
860
+	 * @param string $addon_name
861
+	 * @return void
862
+	 * @throws EE_Error
863
+	 */
864
+	private static function _register_capabilities($addon_name)
865
+	{
866
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
867
+			EE_Register_Capabilities::register(
868
+				$addon_name,
869
+				array(
870
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
871
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
872
+				)
873
+			);
874
+		}
875
+	}
876 876
 
877 877
 
878
-    /**
879
-     * @param string $addon_name
880
-     * @return void
881
-     * @throws EE_Error
882
-     */
883
-    private static function _register_message_types($addon_name)
884
-    {
885
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
886
-            add_action(
887
-                'EE_Brewing_Regular___messages_caf',
888
-                array('EE_Register_Addon', 'register_message_types')
889
-            );
890
-        }
891
-    }
878
+	/**
879
+	 * @param string $addon_name
880
+	 * @return void
881
+	 * @throws EE_Error
882
+	 */
883
+	private static function _register_message_types($addon_name)
884
+	{
885
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
886
+			add_action(
887
+				'EE_Brewing_Regular___messages_caf',
888
+				array('EE_Register_Addon', 'register_message_types')
889
+			);
890
+		}
891
+	}
892 892
 
893 893
 
894
-    /**
895
-     * @param string $addon_name
896
-     * @return void
897
-     * @throws EE_Error
898
-     */
899
-    private static function _register_custom_post_types($addon_name)
900
-    {
901
-        if (
902
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
903
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
904
-        ) {
905
-            EE_Register_CPT::register(
906
-                $addon_name,
907
-                array(
908
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
909
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
910
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
911
-                )
912
-            );
913
-        }
914
-    }
894
+	/**
895
+	 * @param string $addon_name
896
+	 * @return void
897
+	 * @throws EE_Error
898
+	 */
899
+	private static function _register_custom_post_types($addon_name)
900
+	{
901
+		if (
902
+			! empty(self::$_settings[ $addon_name ]['custom_post_types'])
903
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
904
+		) {
905
+			EE_Register_CPT::register(
906
+				$addon_name,
907
+				array(
908
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
909
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
910
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
911
+				)
912
+			);
913
+		}
914
+	}
915 915
 
916 916
 
917
-    /**
918
-     * @param string $addon_name
919
-     * @return void
920
-     * @throws InvalidArgumentException
921
-     * @throws InvalidInterfaceException
922
-     * @throws InvalidDataTypeException
923
-     * @throws DomainException
924
-     * @throws EE_Error
925
-     */
926
-    private static function _register_payment_methods($addon_name)
927
-    {
928
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
929
-            EE_Register_Payment_Method::register(
930
-                $addon_name,
931
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
932
-            );
933
-        }
934
-    }
917
+	/**
918
+	 * @param string $addon_name
919
+	 * @return void
920
+	 * @throws InvalidArgumentException
921
+	 * @throws InvalidInterfaceException
922
+	 * @throws InvalidDataTypeException
923
+	 * @throws DomainException
924
+	 * @throws EE_Error
925
+	 */
926
+	private static function _register_payment_methods($addon_name)
927
+	{
928
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
929
+			EE_Register_Payment_Method::register(
930
+				$addon_name,
931
+				array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
932
+			);
933
+		}
934
+	}
935 935
 
936 936
 
937
-    /**
938
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
939
-     *
940
-     * @param string $addon_name
941
-     * @return EE_Addon
942
-     * @throws InvalidArgumentException
943
-     * @throws InvalidInterfaceException
944
-     * @throws InvalidDataTypeException
945
-     * @throws ReflectionException
946
-     * @throws EE_Error
947
-     */
948
-    private static function _load_and_init_addon_class($addon_name)
949
-    {
950
-        $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
951
-        $addon = $loader->getShared(
952
-            self::$_settings[ $addon_name ]['class_name'],
953
-            array('EE_Registry::create(addon)' => true)
954
-        );
955
-        // setter inject dep map if required
956
-        if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){
957
-            $addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
958
-        }
959
-        // setter inject domain if required
960
-        if(
961
-            $addon instanceof RequiresDomainInterface
962
-            && self::$_settings[ $addon_name ]['domain_fqcn'] !== ''
963
-            && $addon->domain() === null
964
-        ){
965
-            $addon->setDomain(
966
-                $loader->getShared(
967
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
968
-                    array(
969
-                        self::$_settings[ $addon_name ]['main_file_path'],
970
-                        self::$_settings[ $addon_name ]['version']
971
-                    )
972
-                )
973
-            );
974
-        }
937
+	/**
938
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
939
+	 *
940
+	 * @param string $addon_name
941
+	 * @return EE_Addon
942
+	 * @throws InvalidArgumentException
943
+	 * @throws InvalidInterfaceException
944
+	 * @throws InvalidDataTypeException
945
+	 * @throws ReflectionException
946
+	 * @throws EE_Error
947
+	 */
948
+	private static function _load_and_init_addon_class($addon_name)
949
+	{
950
+		$loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
951
+		$addon = $loader->getShared(
952
+			self::$_settings[ $addon_name ]['class_name'],
953
+			array('EE_Registry::create(addon)' => true)
954
+		);
955
+		// setter inject dep map if required
956
+		if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){
957
+			$addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
958
+		}
959
+		// setter inject domain if required
960
+		if(
961
+			$addon instanceof RequiresDomainInterface
962
+			&& self::$_settings[ $addon_name ]['domain_fqcn'] !== ''
963
+			&& $addon->domain() === null
964
+		){
965
+			$addon->setDomain(
966
+				$loader->getShared(
967
+					self::$_settings[ $addon_name ]['domain_fqcn'],
968
+					array(
969
+						self::$_settings[ $addon_name ]['main_file_path'],
970
+						self::$_settings[ $addon_name ]['version']
971
+					)
972
+				)
973
+			);
974
+		}
975 975
 
976
-        $addon->set_name($addon_name);
977
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
978
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
979
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
980
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
981
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
982
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
983
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
984
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
985
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
986
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
987
-        //unfortunately this can't be hooked in upon construction, because we don't have
988
-        //the plugin mainfile's path upon construction.
989
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
990
-        // call any additional admin_callback functions during load_admin_controller hook
991
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
992
-            add_action(
993
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
994
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
995
-            );
996
-        }
997
-        return $addon;
998
-    }
976
+		$addon->set_name($addon_name);
977
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
978
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
979
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
980
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
981
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
982
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
983
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
984
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
985
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
986
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
987
+		//unfortunately this can't be hooked in upon construction, because we don't have
988
+		//the plugin mainfile's path upon construction.
989
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
990
+		// call any additional admin_callback functions during load_admin_controller hook
991
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
992
+			add_action(
993
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
994
+				array($addon, self::$_settings[ $addon_name ]['admin_callback'])
995
+			);
996
+		}
997
+		return $addon;
998
+	}
999 999
 
1000 1000
 
1001
-    /**
1002
-     *    load_pue_update - Update notifications
1003
-     *
1004
-     * @return void
1005
-     * @throws InvalidArgumentException
1006
-     * @throws InvalidDataTypeException
1007
-     * @throws InvalidInterfaceException
1008
-     */
1009
-    public static function load_pue_update()
1010
-    {
1011
-        // load PUE client
1012
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1013
-        // cycle thru settings
1014
-        foreach (self::$_settings as $settings) {
1015
-            if (! empty($settings['pue_options'])) {
1016
-                // initiate the class and start the plugin update engine!
1017
-                new PluginUpdateEngineChecker(
1018
-                // host file URL
1019
-                    'https://eventespresso.com',
1020
-                    // plugin slug(s)
1021
-                    array(
1022
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1023
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1024
-                    ),
1025
-                    // options
1026
-                    array(
1027
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1028
-                        'lang_domain'       => 'event_espresso',
1029
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1030
-                        'option_key'        => 'site_license_key',
1031
-                        'options_page_slug' => 'event_espresso',
1032
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1033
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1034
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1035
-                    )
1036
-                );
1037
-            }
1038
-        }
1039
-    }
1001
+	/**
1002
+	 *    load_pue_update - Update notifications
1003
+	 *
1004
+	 * @return void
1005
+	 * @throws InvalidArgumentException
1006
+	 * @throws InvalidDataTypeException
1007
+	 * @throws InvalidInterfaceException
1008
+	 */
1009
+	public static function load_pue_update()
1010
+	{
1011
+		// load PUE client
1012
+		require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1013
+		// cycle thru settings
1014
+		foreach (self::$_settings as $settings) {
1015
+			if (! empty($settings['pue_options'])) {
1016
+				// initiate the class and start the plugin update engine!
1017
+				new PluginUpdateEngineChecker(
1018
+				// host file URL
1019
+					'https://eventespresso.com',
1020
+					// plugin slug(s)
1021
+					array(
1022
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1023
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1024
+					),
1025
+					// options
1026
+					array(
1027
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1028
+						'lang_domain'       => 'event_espresso',
1029
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1030
+						'option_key'        => 'site_license_key',
1031
+						'options_page_slug' => 'event_espresso',
1032
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1033
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1034
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1035
+					)
1036
+				);
1037
+			}
1038
+		}
1039
+	}
1040 1040
 
1041 1041
 
1042
-    /**
1043
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1044
-     *
1045
-     * @since 4.4.0
1046
-     * @return void
1047
-     * @throws EE_Error
1048
-     */
1049
-    public static function register_message_types()
1050
-    {
1051
-        foreach (self::$_settings as $addon_name => $settings) {
1052
-            if (! empty($settings['message_types'])) {
1053
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1054
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1055
-                }
1056
-            }
1057
-        }
1058
-    }
1042
+	/**
1043
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1044
+	 *
1045
+	 * @since 4.4.0
1046
+	 * @return void
1047
+	 * @throws EE_Error
1048
+	 */
1049
+	public static function register_message_types()
1050
+	{
1051
+		foreach (self::$_settings as $addon_name => $settings) {
1052
+			if (! empty($settings['message_types'])) {
1053
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1054
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1055
+				}
1056
+			}
1057
+		}
1058
+	}
1059 1059
 
1060 1060
 
1061
-    /**
1062
-     * This deregisters an addon that was previously registered with a specific addon_name.
1063
-     *
1064
-     * @since    4.3.0
1065
-     * @param string $addon_name the name for the addon that was previously registered
1066
-     * @throws DomainException
1067
-     * @throws EE_Error
1068
-     * @throws InvalidArgumentException
1069
-     * @throws InvalidDataTypeException
1070
-     * @throws InvalidInterfaceException
1071
-     */
1072
-    public static function deregister($addon_name = null)
1073
-    {
1074
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1075
-            try {
1076
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1077
-                $class_name = self::$_settings[$addon_name]['class_name'];
1078
-                if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1079
-                    // setup DMS
1080
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1081
-                }
1082
-                if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1083
-                    // register admin page
1084
-                    EE_Register_Admin_Page::deregister($addon_name);
1085
-                }
1086
-                if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1087
-                    // add to list of modules to be registered
1088
-                    EE_Register_Module::deregister($addon_name);
1089
-                }
1090
-                if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1091
-                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1092
-                ) {
1093
-                    // add to list of shortcodes to be registered
1094
-                    EE_Register_Shortcode::deregister($addon_name);
1095
-                }
1096
-                if (! empty(self::$_settings[$addon_name]['config_class'])) {
1097
-                    // if config_class present let's register config.
1098
-                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1099
-                }
1100
-                if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1101
-                    // add to list of widgets to be registered
1102
-                    EE_Register_Widget::deregister($addon_name);
1103
-                }
1104
-                if (! empty(self::$_settings[$addon_name]['model_paths'])
1105
-                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1106
-                ) {
1107
-                    // add to list of shortcodes to be registered
1108
-                    EE_Register_Model::deregister($addon_name);
1109
-                }
1110
-                if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1111
-                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1112
-                ) {
1113
-                    // add to list of shortcodes to be registered
1114
-                    EE_Register_Model_Extensions::deregister($addon_name);
1115
-                }
1116
-                if (! empty(self::$_settings[$addon_name]['message_types'])) {
1117
-                    foreach (
1118
-                        (array)self::$_settings[$addon_name]['message_types'] as $message_type =>
1119
-                        $message_type_settings
1120
-                    ) {
1121
-                        EE_Register_Message_Type::deregister($message_type);
1122
-                    }
1123
-                }
1124
-                //deregister capabilities for addon
1125
-                if (
1126
-                    ! empty(self::$_settings[$addon_name]['capabilities'])
1127
-                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1128
-                ) {
1129
-                    EE_Register_Capabilities::deregister($addon_name);
1130
-                }
1131
-                //deregister custom_post_types for addon
1132
-                if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1133
-                    EE_Register_CPT::deregister($addon_name);
1134
-                }
1135
-                if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1136
-                    EE_Register_Payment_Method::deregister($addon_name);
1137
-                }
1138
-                $addon = EE_Registry::instance()->getAddon($class_name);
1139
-                if ($addon instanceof EE_Addon) {
1140
-                    remove_action(
1141
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1142
-                        array($addon, 'deactivation')
1143
-                    );
1144
-                    remove_action(
1145
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1146
-                        array($addon, 'initialize_db_if_no_migrations_required')
1147
-                    );
1148
-                    //remove `after_registration` call
1149
-                    remove_action(
1150
-                        'AHEE__EE_System__load_espresso_addons__complete',
1151
-                        array($addon, 'after_registration'),
1152
-                        999
1153
-                    );
1154
-                }
1155
-                EE_Registry::instance()->removeAddon($class_name);
1156
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1157
-                //the add-on was not yet registered in the registry, so RegistryContainer::__get() throws this exception.
1158
-                //also no need to worry about this or log it, it's ok to deregister an add-on before its registered in the registry
1159
-            } catch (Exception $e) {
1160
-                new ExceptionLogger($e);
1161
-             }
1162
-            unset(self::$_settings[ $addon_name ]);
1163
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1164
-        }
1165
-    }
1061
+	/**
1062
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1063
+	 *
1064
+	 * @since    4.3.0
1065
+	 * @param string $addon_name the name for the addon that was previously registered
1066
+	 * @throws DomainException
1067
+	 * @throws EE_Error
1068
+	 * @throws InvalidArgumentException
1069
+	 * @throws InvalidDataTypeException
1070
+	 * @throws InvalidInterfaceException
1071
+	 */
1072
+	public static function deregister($addon_name = null)
1073
+	{
1074
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1075
+			try {
1076
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1077
+				$class_name = self::$_settings[$addon_name]['class_name'];
1078
+				if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1079
+					// setup DMS
1080
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1081
+				}
1082
+				if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1083
+					// register admin page
1084
+					EE_Register_Admin_Page::deregister($addon_name);
1085
+				}
1086
+				if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1087
+					// add to list of modules to be registered
1088
+					EE_Register_Module::deregister($addon_name);
1089
+				}
1090
+				if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1091
+					|| ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1092
+				) {
1093
+					// add to list of shortcodes to be registered
1094
+					EE_Register_Shortcode::deregister($addon_name);
1095
+				}
1096
+				if (! empty(self::$_settings[$addon_name]['config_class'])) {
1097
+					// if config_class present let's register config.
1098
+					EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1099
+				}
1100
+				if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1101
+					// add to list of widgets to be registered
1102
+					EE_Register_Widget::deregister($addon_name);
1103
+				}
1104
+				if (! empty(self::$_settings[$addon_name]['model_paths'])
1105
+					|| ! empty(self::$_settings[$addon_name]['class_paths'])
1106
+				) {
1107
+					// add to list of shortcodes to be registered
1108
+					EE_Register_Model::deregister($addon_name);
1109
+				}
1110
+				if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1111
+					|| ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1112
+				) {
1113
+					// add to list of shortcodes to be registered
1114
+					EE_Register_Model_Extensions::deregister($addon_name);
1115
+				}
1116
+				if (! empty(self::$_settings[$addon_name]['message_types'])) {
1117
+					foreach (
1118
+						(array)self::$_settings[$addon_name]['message_types'] as $message_type =>
1119
+						$message_type_settings
1120
+					) {
1121
+						EE_Register_Message_Type::deregister($message_type);
1122
+					}
1123
+				}
1124
+				//deregister capabilities for addon
1125
+				if (
1126
+					! empty(self::$_settings[$addon_name]['capabilities'])
1127
+					|| ! empty(self::$_settings[$addon_name]['capability_maps'])
1128
+				) {
1129
+					EE_Register_Capabilities::deregister($addon_name);
1130
+				}
1131
+				//deregister custom_post_types for addon
1132
+				if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1133
+					EE_Register_CPT::deregister($addon_name);
1134
+				}
1135
+				if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1136
+					EE_Register_Payment_Method::deregister($addon_name);
1137
+				}
1138
+				$addon = EE_Registry::instance()->getAddon($class_name);
1139
+				if ($addon instanceof EE_Addon) {
1140
+					remove_action(
1141
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1142
+						array($addon, 'deactivation')
1143
+					);
1144
+					remove_action(
1145
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1146
+						array($addon, 'initialize_db_if_no_migrations_required')
1147
+					);
1148
+					//remove `after_registration` call
1149
+					remove_action(
1150
+						'AHEE__EE_System__load_espresso_addons__complete',
1151
+						array($addon, 'after_registration'),
1152
+						999
1153
+					);
1154
+				}
1155
+				EE_Registry::instance()->removeAddon($class_name);
1156
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1157
+				//the add-on was not yet registered in the registry, so RegistryContainer::__get() throws this exception.
1158
+				//also no need to worry about this or log it, it's ok to deregister an add-on before its registered in the registry
1159
+			} catch (Exception $e) {
1160
+				new ExceptionLogger($e);
1161
+			 }
1162
+			unset(self::$_settings[ $addon_name ]);
1163
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1164
+		}
1165
+	}
1166 1166
 
1167 1167
 
1168 1168
 }
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
         // offsets:    0 . 1 . 2 . 3 . 4
73 73
         $version_parts = explode('.', $min_core_version);
74 74
         //check they specified the micro version (after 2nd period)
75
-        if (! isset($version_parts[2])) {
75
+        if ( ! isset($version_parts[2])) {
76 76
             $version_parts[2] = '0';
77 77
         }
78 78
         //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
79 79
         //soon we can assume that's 'rc', but this current version is 'alpha'
80
-        if (! isset($version_parts[3])) {
80
+        if ( ! isset($version_parts[3])) {
81 81
             $version_parts[3] = 'dev';
82 82
         }
83
-        if (! isset($version_parts[4])) {
83
+        if ( ! isset($version_parts[4])) {
84 84
             $version_parts[4] = '000';
85 85
         }
86 86
         return implode('.', $version_parts);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         // setup PUE
252 252
         EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
253 253
         // does this addon work with this version of core or WordPress ?
254
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
254
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
255 255
             return;
256 256
         }
257 257
         // register namespaces
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                 )
310 310
             );
311 311
         }
312
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
312
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
313 313
             throw new EE_Error(
314 314
                 sprintf(
315 315
                     __(
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
             );
322 322
         }
323 323
         // check that addon has not already been registered with that name
324
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
324
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
325 325
             throw new EE_Error(
326 326
                 sprintf(
327 327
                     __(
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
354 354
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
355 355
             ? $class_name
356
-            : 'EE_' . $class_name;
356
+            : 'EE_'.$class_name;
357 357
     }
358 358
 
359 359
 
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
         $incompatibility_message = '';
513 513
         //check whether this addon version is compatible with EE core
514 514
         if (
515
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
515
+            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
516 516
             && ! self::_meets_min_core_version_requirement(
517
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
517
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
518 518
                 $addon_settings['version']
519 519
             )
520 520
         ) {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 ),
525 525
                 $addon_name,
526 526
                 '<br />',
527
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
527
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
528 528
                 '<span style="font-weight: bold; color: #D54E21;">',
529 529
                 '</span><br />'
530 530
             );
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                 '</span><br />'
557 557
             );
558 558
         }
559
-        if (! empty($incompatibility_message)) {
559
+        if ( ! empty($incompatibility_message)) {
560 560
             // remove 'activate' from the REQUEST
561 561
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
562 562
             unset($_GET['activate'], $_REQUEST['activate']);
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
      */
585 585
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
586 586
     {
587
-        if (! empty($setup_args['pue_options'])) {
588
-            self::$_settings[ $addon_name ]['pue_options'] = array(
587
+        if ( ! empty($setup_args['pue_options'])) {
588
+            self::$_settings[$addon_name]['pue_options'] = array(
589 589
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
590 590
                     ? (string) $setup_args['pue_options']['pue_plugin_slug']
591
-                    : 'espresso_' . strtolower($class_name),
591
+                    : 'espresso_'.strtolower($class_name),
592 592
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
593 593
                     ? (string) $setup_args['pue_options']['plugin_basename']
594 594
                     : plugin_basename($setup_args['main_file_path']),
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
             //(as the newly-activated addon wasn't around the first time addons were registered).
649 649
             //Note: the presence of pue_options in the addon registration options will initialize the $_settings
650 650
             //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
651
-            if (! isset(self::$_settings[ $addon_name ])
652
-                || (isset(self::$_settings[ $addon_name ])
653
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
651
+            if ( ! isset(self::$_settings[$addon_name])
652
+                || (isset(self::$_settings[$addon_name])
653
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
654 654
                 )
655 655
             ) {
656
-                self::$_settings[ $addon_name ] = $addon_settings;
656
+                self::$_settings[$addon_name] = $addon_settings;
657 657
                 $addon                          = self::_load_and_init_addon_class($addon_name);
658 658
                 $addon->set_activation_indicator_option();
659 659
                 // dont bother setting up the rest of the addon.
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
             );
680 680
         }
681 681
         // make sure addon settings are set correctly without overwriting anything existing
682
-        if (isset(self::$_settings[ $addon_name ])) {
683
-            self::$_settings[ $addon_name ] += $addon_settings;
682
+        if (isset(self::$_settings[$addon_name])) {
683
+            self::$_settings[$addon_name] += $addon_settings;
684 684
         } else {
685
-            self::$_settings[ $addon_name ] = $addon_settings;
685
+            self::$_settings[$addon_name] = $addon_settings;
686 686
         }
687 687
         return false;
688 688
     }
@@ -695,13 +695,13 @@  discard block
 block discarded – undo
695 695
      */
696 696
     private static function _setup_autoloaders($addon_name)
697 697
     {
698
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
698
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
699 699
             // setup autoloader for single file
700
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
700
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
701 701
         }
702 702
         // setup autoloaders for folders
703
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
703
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
704
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
705 705
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706 706
             }
707 707
         }
@@ -719,27 +719,27 @@  discard block
 block discarded – undo
719 719
     {
720 720
         // register new models
721 721
         if (
722
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
723
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
722
+            ! empty(self::$_settings[$addon_name]['model_paths'])
723
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
724 724
         ) {
725 725
             EE_Register_Model::register(
726 726
                 $addon_name,
727 727
                 array(
728
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
728
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
729
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
730 730
                 )
731 731
             );
732 732
         }
733 733
         // register model extensions
734 734
         if (
735
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
735
+            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
736
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
737 737
         ) {
738 738
             EE_Register_Model_Extensions::register(
739 739
                 $addon_name,
740 740
                 array(
741
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
741
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
742
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
743 743
                 )
744 744
             );
745 745
         }
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
     private static function _register_data_migration_scripts($addon_name)
755 755
     {
756 756
         // setup DMS
757
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
757
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
758 758
             EE_Register_Data_Migration_Scripts::register(
759 759
                 $addon_name,
760
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
760
+                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
761 761
             );
762 762
         }
763 763
     }
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
     private static function _register_config($addon_name)
772 772
     {
773 773
         // if config_class is present let's register config.
774
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
774
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
775 775
             EE_Register_Config::register(
776
-                self::$_settings[ $addon_name ]['config_class'],
776
+                self::$_settings[$addon_name]['config_class'],
777 777
                 array(
778
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
778
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
779
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
780 780
                 )
781 781
             );
782 782
         }
@@ -790,10 +790,10 @@  discard block
 block discarded – undo
790 790
      */
791 791
     private static function _register_admin_pages($addon_name)
792 792
     {
793
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
793
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
794 794
             EE_Register_Admin_Page::register(
795 795
                 $addon_name,
796
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
796
+                array('page_path' => self::$_settings[$addon_name]['admin_path'])
797 797
             );
798 798
         }
799 799
     }
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
      */
807 807
     private static function _register_modules($addon_name)
808 808
     {
809
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
809
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
810 810
             EE_Register_Module::register(
811 811
                 $addon_name,
812
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
812
+                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
813 813
             );
814 814
         }
815 815
     }
@@ -822,17 +822,17 @@  discard block
 block discarded – undo
822 822
      */
823 823
     private static function _register_shortcodes($addon_name)
824 824
     {
825
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
826
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
825
+        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
826
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
827 827
         ) {
828 828
             EE_Register_Shortcode::register(
829 829
                 $addon_name,
830 830
                 array(
831
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
832
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
831
+                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
832
+                        ? self::$_settings[$addon_name]['shortcode_paths']
833 833
                         : array(),
834
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
835
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
834
+                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
835
+                        ? self::$_settings[$addon_name]['shortcode_fqcns']
836 836
                         : array(),
837 837
                 )
838 838
             );
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
      */
848 848
     private static function _register_widgets($addon_name)
849 849
     {
850
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
850
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
851 851
             EE_Register_Widget::register(
852 852
                 $addon_name,
853
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
853
+                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
854 854
             );
855 855
         }
856 856
     }
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
      */
864 864
     private static function _register_capabilities($addon_name)
865 865
     {
866
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
866
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
867 867
             EE_Register_Capabilities::register(
868 868
                 $addon_name,
869 869
                 array(
870
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
871
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
870
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
871
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
872 872
                 )
873 873
             );
874 874
         }
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
      */
883 883
     private static function _register_message_types($addon_name)
884 884
     {
885
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
885
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
886 886
             add_action(
887 887
                 'EE_Brewing_Regular___messages_caf',
888 888
                 array('EE_Register_Addon', 'register_message_types')
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
     private static function _register_custom_post_types($addon_name)
900 900
     {
901 901
         if (
902
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
903
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
902
+            ! empty(self::$_settings[$addon_name]['custom_post_types'])
903
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
904 904
         ) {
905 905
             EE_Register_CPT::register(
906 906
                 $addon_name,
907 907
                 array(
908
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
909
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
910
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
908
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
909
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
910
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
911 911
                 )
912 912
             );
913 913
         }
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
      */
926 926
     private static function _register_payment_methods($addon_name)
927 927
     {
928
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
928
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
929 929
             EE_Register_Payment_Method::register(
930 930
                 $addon_name,
931
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
931
+                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
932 932
             );
933 933
         }
934 934
     }
@@ -949,49 +949,49 @@  discard block
 block discarded – undo
949 949
     {
950 950
         $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
951 951
         $addon = $loader->getShared(
952
-            self::$_settings[ $addon_name ]['class_name'],
952
+            self::$_settings[$addon_name]['class_name'],
953 953
             array('EE_Registry::create(addon)' => true)
954 954
         );
955 955
         // setter inject dep map if required
956
-        if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){
956
+        if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) {
957 957
             $addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
958 958
         }
959 959
         // setter inject domain if required
960
-        if(
960
+        if (
961 961
             $addon instanceof RequiresDomainInterface
962
-            && self::$_settings[ $addon_name ]['domain_fqcn'] !== ''
962
+            && self::$_settings[$addon_name]['domain_fqcn'] !== ''
963 963
             && $addon->domain() === null
964
-        ){
964
+        ) {
965 965
             $addon->setDomain(
966 966
                 $loader->getShared(
967
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
967
+                    self::$_settings[$addon_name]['domain_fqcn'],
968 968
                     array(
969
-                        self::$_settings[ $addon_name ]['main_file_path'],
970
-                        self::$_settings[ $addon_name ]['version']
969
+                        self::$_settings[$addon_name]['main_file_path'],
970
+                        self::$_settings[$addon_name]['version']
971 971
                     )
972 972
                 )
973 973
             );
974 974
         }
975 975
 
976 976
         $addon->set_name($addon_name);
977
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
978
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
979
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
980
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
981
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
982
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
983
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
984
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
985
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
986
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
977
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
978
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
979
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
980
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
981
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
982
+        $addon->set_version(self::$_settings[$addon_name]['version']);
983
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
984
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
985
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
986
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
987 987
         //unfortunately this can't be hooked in upon construction, because we don't have
988 988
         //the plugin mainfile's path upon construction.
989 989
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
990 990
         // call any additional admin_callback functions during load_admin_controller hook
991
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
991
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
992 992
             add_action(
993 993
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
994
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
994
+                array($addon, self::$_settings[$addon_name]['admin_callback'])
995 995
             );
996 996
         }
997 997
         return $addon;
@@ -1009,10 +1009,10 @@  discard block
 block discarded – undo
1009 1009
     public static function load_pue_update()
1010 1010
     {
1011 1011
         // load PUE client
1012
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1012
+        require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php';
1013 1013
         // cycle thru settings
1014 1014
         foreach (self::$_settings as $settings) {
1015
-            if (! empty($settings['pue_options'])) {
1015
+            if ( ! empty($settings['pue_options'])) {
1016 1016
                 // initiate the class and start the plugin update engine!
1017 1017
                 new PluginUpdateEngineChecker(
1018 1018
                 // host file URL
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
                     // plugin slug(s)
1021 1021
                     array(
1022 1022
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1023
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1023
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
1024 1024
                     ),
1025 1025
                     // options
1026 1026
                     array(
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
     public static function register_message_types()
1050 1050
     {
1051 1051
         foreach (self::$_settings as $addon_name => $settings) {
1052
-            if (! empty($settings['message_types'])) {
1052
+            if ( ! empty($settings['message_types'])) {
1053 1053
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1054 1054
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1055 1055
                 }
@@ -1071,51 +1071,51 @@  discard block
 block discarded – undo
1071 1071
      */
1072 1072
     public static function deregister($addon_name = null)
1073 1073
     {
1074
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1074
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1075 1075
             try {
1076 1076
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1077 1077
                 $class_name = self::$_settings[$addon_name]['class_name'];
1078
-                if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1078
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1079 1079
                     // setup DMS
1080 1080
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1081 1081
                 }
1082
-                if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1082
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1083 1083
                     // register admin page
1084 1084
                     EE_Register_Admin_Page::deregister($addon_name);
1085 1085
                 }
1086
-                if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1086
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1087 1087
                     // add to list of modules to be registered
1088 1088
                     EE_Register_Module::deregister($addon_name);
1089 1089
                 }
1090
-                if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1090
+                if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1091 1091
                     || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1092 1092
                 ) {
1093 1093
                     // add to list of shortcodes to be registered
1094 1094
                     EE_Register_Shortcode::deregister($addon_name);
1095 1095
                 }
1096
-                if (! empty(self::$_settings[$addon_name]['config_class'])) {
1096
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1097 1097
                     // if config_class present let's register config.
1098 1098
                     EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1099 1099
                 }
1100
-                if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1100
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1101 1101
                     // add to list of widgets to be registered
1102 1102
                     EE_Register_Widget::deregister($addon_name);
1103 1103
                 }
1104
-                if (! empty(self::$_settings[$addon_name]['model_paths'])
1104
+                if ( ! empty(self::$_settings[$addon_name]['model_paths'])
1105 1105
                     || ! empty(self::$_settings[$addon_name]['class_paths'])
1106 1106
                 ) {
1107 1107
                     // add to list of shortcodes to be registered
1108 1108
                     EE_Register_Model::deregister($addon_name);
1109 1109
                 }
1110
-                if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1110
+                if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1111 1111
                     || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1112 1112
                 ) {
1113 1113
                     // add to list of shortcodes to be registered
1114 1114
                     EE_Register_Model_Extensions::deregister($addon_name);
1115 1115
                 }
1116
-                if (! empty(self::$_settings[$addon_name]['message_types'])) {
1116
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1117 1117
                     foreach (
1118
-                        (array)self::$_settings[$addon_name]['message_types'] as $message_type =>
1118
+                        (array) self::$_settings[$addon_name]['message_types'] as $message_type =>
1119 1119
                         $message_type_settings
1120 1120
                     ) {
1121 1121
                         EE_Register_Message_Type::deregister($message_type);
@@ -1129,16 +1129,16 @@  discard block
 block discarded – undo
1129 1129
                     EE_Register_Capabilities::deregister($addon_name);
1130 1130
                 }
1131 1131
                 //deregister custom_post_types for addon
1132
-                if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1132
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1133 1133
                     EE_Register_CPT::deregister($addon_name);
1134 1134
                 }
1135
-                if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1135
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1136 1136
                     EE_Register_Payment_Method::deregister($addon_name);
1137 1137
                 }
1138 1138
                 $addon = EE_Registry::instance()->getAddon($class_name);
1139 1139
                 if ($addon instanceof EE_Addon) {
1140 1140
                     remove_action(
1141
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1141
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1142 1142
                         array($addon, 'deactivation')
1143 1143
                     );
1144 1144
                     remove_action(
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
             } catch (Exception $e) {
1160 1160
                 new ExceptionLogger($e);
1161 1161
              }
1162
-            unset(self::$_settings[ $addon_name ]);
1162
+            unset(self::$_settings[$addon_name]);
1163 1163
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1164 1164
         }
1165 1165
     }
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 1 patch
Indentation   +1859 added lines, -1859 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidEntityException;
6 6
 
7 7
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -20,1864 +20,1864 @@  discard block
 block discarded – undo
20 20
 class EED_Single_Page_Checkout extends EED_Module
21 21
 {
22 22
 
23
-    /**
24
-     * $_initialized - has the SPCO controller already been initialized ?
25
-     *
26
-     * @access private
27
-     * @var bool $_initialized
28
-     */
29
-    private static $_initialized = false;
30
-
31
-
32
-    /**
33
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
-     *
35
-     * @access private
36
-     * @var bool $_valid_checkout
37
-     */
38
-    private static $_checkout_verified = true;
39
-
40
-    /**
41
-     *    $_reg_steps_array - holds initial array of reg steps
42
-     *
43
-     * @access private
44
-     * @var array $_reg_steps_array
45
-     */
46
-    private static $_reg_steps_array = array();
47
-
48
-    /**
49
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
-     *
51
-     * @access public
52
-     * @var EE_Checkout $checkout
53
-     */
54
-    public $checkout;
55
-
56
-
57
-
58
-    /**
59
-     * @return EED_Module|EED_Single_Page_Checkout
60
-     */
61
-    public static function instance()
62
-    {
63
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
-        return parent::get_instance(__CLASS__);
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return EE_CART
71
-     */
72
-    public function cart()
73
-    {
74
-        return $this->checkout->cart;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return EE_Transaction
81
-     */
82
-    public function transaction()
83
-    {
84
-        return $this->checkout->transaction;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     *    set_hooks - for hooking into EE Core, other modules, etc
91
-     *
92
-     * @access    public
93
-     * @return    void
94
-     * @throws EE_Error
95
-     */
96
-    public static function set_hooks()
97
-    {
98
-        EED_Single_Page_Checkout::set_definitions();
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
-     *
106
-     * @access    public
107
-     * @return    void
108
-     * @throws EE_Error
109
-     */
110
-    public static function set_hooks_admin()
111
-    {
112
-        EED_Single_Page_Checkout::set_definitions();
113
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
-            return;
115
-        }
116
-        // going to start an output buffer in case anything gets accidentally output
117
-        // that might disrupt our JSON response
118
-        ob_start();
119
-        EED_Single_Page_Checkout::load_request_handler();
120
-        EED_Single_Page_Checkout::load_reg_steps();
121
-        // set ajax hooks
122
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *    process ajax request
134
-     *
135
-     * @param string $ajax_action
136
-     * @throws EE_Error
137
-     */
138
-    public static function process_ajax_request($ajax_action)
139
-    {
140
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
141
-        EED_Single_Page_Checkout::instance()->_initialize();
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     *    ajax display registration step
148
-     *
149
-     * @throws EE_Error
150
-     */
151
-    public static function display_reg_step()
152
-    {
153
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     *    ajax process registration step
160
-     *
161
-     * @throws EE_Error
162
-     */
163
-    public static function process_reg_step()
164
-    {
165
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     *    ajax process registration step
172
-     *
173
-     * @throws EE_Error
174
-     */
175
-    public static function update_reg_step()
176
-    {
177
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     *   update_checkout
184
-     *
185
-     * @access public
186
-     * @return void
187
-     * @throws EE_Error
188
-     */
189
-    public static function update_checkout()
190
-    {
191
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     *    load_request_handler
198
-     *
199
-     * @access    public
200
-     * @return    void
201
-     */
202
-    public static function load_request_handler()
203
-    {
204
-        // load core Request_Handler class
205
-        if (EE_Registry::instance()->REQ !== null) {
206
-            EE_Registry::instance()->load_core('Request_Handler');
207
-        }
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     *    set_definitions
214
-     *
215
-     * @access    public
216
-     * @return    void
217
-     * @throws EE_Error
218
-     */
219
-    public static function set_definitions()
220
-    {
221
-        if(defined('SPCO_BASE_PATH')) {
222
-            return;
223
-        }
224
-        define(
225
-            'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
-        );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
-            __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
237
-                'event_espresso'),
238
-            '<h4 class="important-notice">',
239
-            '</h4>',
240
-            '<br />',
241
-            '<p>',
242
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
-            '">',
244
-            '</a>',
245
-            '</p>'
246
-        );
247
-    }
248
-
249
-
250
-
251
-    /**
252
-     * load_reg_steps
253
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
-     *
255
-     * @access    private
256
-     * @throws EE_Error
257
-     */
258
-    public static function load_reg_steps()
259
-    {
260
-        static $reg_steps_loaded = false;
261
-        if ($reg_steps_loaded) {
262
-            return;
263
-        }
264
-        // filter list of reg_steps
265
-        $reg_steps_to_load = (array)apply_filters(
266
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
-            EED_Single_Page_Checkout::get_reg_steps()
268
-        );
269
-        // sort by key (order)
270
-        ksort($reg_steps_to_load);
271
-        // loop through folders
272
-        foreach ($reg_steps_to_load as $order => $reg_step) {
273
-            // we need a
274
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
-                // copy over to the reg_steps_array
276
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
-                // register custom key route for each reg step
278
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
-                EE_Config::register_route(
280
-                    $reg_step['slug'],
281
-                    'EED_Single_Page_Checkout',
282
-                    'run',
283
-                    'step'
284
-                );
285
-                // add AJAX or other hooks
286
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
-                    // setup autoloaders if necessary
288
-                    if ( ! class_exists($reg_step['class_name'])) {
289
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
-                            $reg_step['file_path'],
291
-                            true
292
-                        );
293
-                    }
294
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
-                    }
297
-                }
298
-            }
299
-        }
300
-        $reg_steps_loaded = true;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     *    get_reg_steps
307
-     *
308
-     * @access    public
309
-     * @return    array
310
-     */
311
-    public static function get_reg_steps()
312
-    {
313
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
-        if (empty($reg_steps)) {
315
-            $reg_steps = array(
316
-                10  => array(
317
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
-                    'slug'       => 'attendee_information',
320
-                    'has_hooks'  => false,
321
-                ),
322
-                20  => array(
323
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
-                    'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
-                    'slug'       => 'registration_confirmation',
326
-                    'has_hooks'  => false,
327
-                ),
328
-                30  => array(
329
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
-                    'slug'       => 'payment_options',
332
-                    'has_hooks'  => true,
333
-                ),
334
-                999 => array(
335
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
-                    'slug'       => 'finalize_registration',
338
-                    'has_hooks'  => false,
339
-                ),
340
-            );
341
-        }
342
-        return $reg_steps;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     *    registration_checkout_for_admin
349
-     *
350
-     * @access    public
351
-     * @return    string
352
-     * @throws EE_Error
353
-     */
354
-    public static function registration_checkout_for_admin()
355
-    {
356
-        EED_Single_Page_Checkout::load_request_handler();
357
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
360
-        EED_Single_Page_Checkout::instance()->_initialize();
361
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
-        return EE_Registry::instance()->REQ->get_output();
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * process_registration_from_admin
369
-     *
370
-     * @access public
371
-     * @return \EE_Transaction
372
-     * @throws EE_Error
373
-     */
374
-    public static function process_registration_from_admin()
375
-    {
376
-        EED_Single_Page_Checkout::load_request_handler();
377
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
380
-        EED_Single_Page_Checkout::instance()->_initialize();
381
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
-                if ($final_reg_step->process_reg_step()) {
386
-                    $final_reg_step->set_completed();
387
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
-                }
390
-            }
391
-        }
392
-        return null;
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     *    run
399
-     *
400
-     * @access    public
401
-     * @param WP_Query $WP_Query
402
-     * @return    void
403
-     * @throws EE_Error
404
-     */
405
-    public function run($WP_Query)
406
-    {
407
-        if (
408
-            $WP_Query instanceof WP_Query
409
-            && $WP_Query->is_main_query()
410
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
-            && $this->_is_reg_checkout()
412
-        ) {
413
-            $this->_initialize();
414
-        }
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * determines whether current url matches reg page url
421
-     *
422
-     * @return bool
423
-     */
424
-    protected function _is_reg_checkout()
425
-    {
426
-        // get current permalink for reg page without any extra query args
427
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
-        // get request URI for current request, but without the scheme or host
429
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
-        $current_request_uri = html_entity_decode($current_request_uri);
431
-        // get array of query args from the current request URI
432
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
433
-        // grab page id if it is set
434
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
-        // and remove the page id from the query args (we will re-add it later)
436
-        unset($query_args['page_id']);
437
-        // now strip all query args from current request URI
438
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
-        // and re-add the page id if it was set
440
-        if ($page_id) {
441
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
-        }
443
-        // remove slashes and ?
444
-        $current_request_uri = trim($current_request_uri, '?/');
445
-        // is current request URI part of the known full reg page URL ?
446
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     * @param WP_Query $wp_query
453
-     * @return    void
454
-     * @throws EE_Error
455
-     */
456
-    public static function init($wp_query)
457
-    {
458
-        EED_Single_Page_Checkout::instance()->run($wp_query);
459
-    }
460
-
461
-
462
-
463
-    /**
464
-     *    _initialize - initial module setup
465
-     *
466
-     * @access    private
467
-     * @throws EE_Error
468
-     * @return    void
469
-     */
470
-    private function _initialize()
471
-    {
472
-        // ensure SPCO doesn't run twice
473
-        if (EED_Single_Page_Checkout::$_initialized) {
474
-            return;
475
-        }
476
-        try {
477
-            EED_Single_Page_Checkout::load_reg_steps();
478
-            $this->_verify_session();
479
-            // setup the EE_Checkout object
480
-            $this->checkout = $this->_initialize_checkout();
481
-            // filter checkout
482
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
-            // get the $_GET
484
-            $this->_get_request_vars();
485
-            if ($this->_block_bots()) {
486
-                return;
487
-            }
488
-            // filter continue_reg
489
-            $this->checkout->continue_reg = apply_filters(
490
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
-                true,
492
-                $this->checkout
493
-            );
494
-            // load the reg steps array
495
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
496
-                EED_Single_Page_Checkout::$_initialized = true;
497
-                return;
498
-            }
499
-            // set the current step
500
-            $this->checkout->set_current_step($this->checkout->step);
501
-            // and the next step
502
-            $this->checkout->set_next_step();
503
-            // verify that everything has been setup correctly
504
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
-                EED_Single_Page_Checkout::$_initialized = true;
506
-                return;
507
-            }
508
-            // lock the transaction
509
-            $this->checkout->transaction->lock();
510
-            // make sure all of our cached objects are added to their respective model entity mappers
511
-            $this->checkout->refresh_all_entities();
512
-            // set amount owing
513
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
-            // initialize each reg step, which gives them the chance to potentially alter the process
515
-            $this->_initialize_reg_steps();
516
-            // DEBUG LOG
517
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
-            // get reg form
519
-            if( ! $this->_check_form_submission()) {
520
-                EED_Single_Page_Checkout::$_initialized = true;
521
-                return;
522
-            }
523
-            // checkout the action!!!
524
-            $this->_process_form_action();
525
-            // add some style and make it dance
526
-            $this->add_styles_and_scripts();
527
-            // kk... SPCO has successfully run
528
-            EED_Single_Page_Checkout::$_initialized = true;
529
-            // set no cache headers and constants
530
-            EE_System::do_not_cache();
531
-            // add anchor
532
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
-            // remove transaction lock
534
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
-        } catch (Exception $e) {
536
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
-        }
538
-    }
539
-
540
-
541
-
542
-    /**
543
-     *    _verify_session
544
-     * checks that the session is valid and not expired
545
-     *
546
-     * @access    private
547
-     * @throws EE_Error
548
-     */
549
-    private function _verify_session()
550
-    {
551
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
-        }
554
-        $clear_session_requested = filter_var(
555
-            EE_Registry::instance()->REQ->get('clear_session', false),
556
-            FILTER_VALIDATE_BOOLEAN
557
-        );
558
-        // is session still valid ?
559
-        if ($clear_session_requested
560
-            || ( EE_Registry::instance()->SSN->expired()
561
-              && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
562
-            )
563
-        ) {
564
-            $this->checkout = new EE_Checkout();
565
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
566
-            // EE_Registry::instance()->SSN->reset_cart();
567
-            // EE_Registry::instance()->SSN->reset_checkout();
568
-            // EE_Registry::instance()->SSN->reset_transaction();
569
-            if (! $clear_session_requested) {
570
-                EE_Error::add_attention(
571
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
572
-                    __FILE__, __FUNCTION__, __LINE__
573
-                );
574
-            }
575
-            // EE_Registry::instance()->SSN->reset_expired();
576
-        }
577
-    }
578
-
579
-
580
-
581
-    /**
582
-     *    _initialize_checkout
583
-     * loads and instantiates EE_Checkout
584
-     *
585
-     * @access    private
586
-     * @throws EE_Error
587
-     * @return EE_Checkout
588
-     */
589
-    private function _initialize_checkout()
590
-    {
591
-        // look in session for existing checkout
592
-        /** @type EE_Checkout $checkout */
593
-        $checkout = EE_Registry::instance()->SSN->checkout();
594
-        // verify
595
-        if ( ! $checkout instanceof EE_Checkout) {
596
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
597
-            $checkout = EE_Registry::instance()->load_file(
598
-                SPCO_INC_PATH,
599
-                'EE_Checkout',
600
-                'class', array(),
601
-                false
602
-            );
603
-        } else {
604
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
605
-                $this->unlock_transaction();
606
-                wp_safe_redirect($checkout->redirect_url);
607
-                exit();
608
-            }
609
-        }
610
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
611
-        // verify again
612
-        if ( ! $checkout instanceof EE_Checkout) {
613
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
614
-        }
615
-        // reset anything that needs a clean slate for each request
616
-        $checkout->reset_for_current_request();
617
-        return $checkout;
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     *    _get_request_vars
624
-     *
625
-     * @access    private
626
-     * @return    void
627
-     * @throws EE_Error
628
-     */
629
-    private function _get_request_vars()
630
-    {
631
-        // load classes
632
-        EED_Single_Page_Checkout::load_request_handler();
633
-        //make sure this request is marked as belonging to EE
634
-        EE_Registry::instance()->REQ->set_espresso_page(true);
635
-        // which step is being requested ?
636
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
637
-        // which step is being edited ?
638
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
639
-        // and what we're doing on the current step
640
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
641
-        // timestamp
642
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
643
-        // returning to edit ?
644
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
645
-        // add reg url link to registration query params
646
-        if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
647
-            $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
648
-        }
649
-        // or some other kind of revisit ?
650
-        $this->checkout->revisit = filter_var(
651
-            EE_Registry::instance()->REQ->get('revisit', false),
652
-            FILTER_VALIDATE_BOOLEAN
653
-        );
654
-        // and whether or not to generate a reg form for this request
655
-        $this->checkout->generate_reg_form = filter_var(
656
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
657
-            FILTER_VALIDATE_BOOLEAN
658
-        );
659
-        // and whether or not to process a reg form submission for this request
660
-        $this->checkout->process_form_submission = filter_var(
661
-            EE_Registry::instance()->REQ->get(
662
-                'process_form_submission',
663
-                $this->checkout->action === 'process_reg_step'
664
-            ),
665
-            FILTER_VALIDATE_BOOLEAN
666
-        );
667
-        $this->checkout->process_form_submission = filter_var(
668
-            $this->checkout->action !== 'display_spco_reg_step'
669
-                ? $this->checkout->process_form_submission
670
-                : false,
671
-            FILTER_VALIDATE_BOOLEAN
672
-        );
673
-        // $this->_display_request_vars();
674
-    }
675
-
676
-
677
-
678
-    /**
679
-     *  _display_request_vars
680
-     *
681
-     * @access    protected
682
-     * @return    void
683
-     */
684
-    protected function _display_request_vars()
685
-    {
686
-        if ( ! WP_DEBUG) {
687
-            return;
688
-        }
689
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
690
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
691
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
692
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
693
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
694
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
695
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
696
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
697
-    }
698
-
699
-
700
-
701
-    /**
702
-     * _block_bots
703
-     * checks that the incoming request has either of the following set:
704
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
705
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
706
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
707
-     * then where you coming from man?
708
-     *
709
-     * @return boolean
710
-     */
711
-    private function _block_bots()
712
-    {
713
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
714
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
715
-            return true;
716
-        }
717
-        return false;
718
-    }
719
-
720
-
721
-
722
-    /**
723
-     *    _get_first_step
724
-     *  gets slug for first step in $_reg_steps_array
725
-     *
726
-     * @access    private
727
-     * @throws EE_Error
728
-     * @return    string
729
-     */
730
-    private function _get_first_step()
731
-    {
732
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
733
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     *    _load_and_instantiate_reg_steps
740
-     *  instantiates each reg step based on the loaded reg_steps array
741
-     *
742
-     * @access    private
743
-     * @throws EE_Error
744
-     * @return    bool
745
-     */
746
-    private function _load_and_instantiate_reg_steps()
747
-    {
748
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
749
-        // have reg_steps already been instantiated ?
750
-        if (
751
-            empty($this->checkout->reg_steps)
752
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
753
-        ) {
754
-            // if not, then loop through raw reg steps array
755
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
756
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
757
-                    return false;
758
-                }
759
-            }
760
-            EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
761
-            EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
762
-            // skip the registration_confirmation page ?
763
-            if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
764
-                // just remove it from the reg steps array
765
-                $this->checkout->remove_reg_step('registration_confirmation', false);
766
-            } else if (
767
-                isset($this->checkout->reg_steps['registration_confirmation'])
768
-                && EE_Registry::instance()->CFG->registration->reg_confirmation_last
769
-            ) {
770
-                // set the order to something big like 100
771
-                $this->checkout->set_reg_step_order('registration_confirmation', 100);
772
-            }
773
-            // filter the array for good luck
774
-            $this->checkout->reg_steps = apply_filters(
775
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
776
-                $this->checkout->reg_steps
777
-            );
778
-            // finally re-sort based on the reg step class order properties
779
-            $this->checkout->sort_reg_steps();
780
-        } else {
781
-            foreach ($this->checkout->reg_steps as $reg_step) {
782
-                // set all current step stati to FALSE
783
-                $reg_step->set_is_current_step(false);
784
-            }
785
-        }
786
-        if (empty($this->checkout->reg_steps)) {
787
-            EE_Error::add_error(
788
-                __('No Reg Steps were loaded..', 'event_espresso'),
789
-                __FILE__, __FUNCTION__, __LINE__
790
-            );
791
-            return false;
792
-        }
793
-        // make reg step details available to JS
794
-        $this->checkout->set_reg_step_JSON_info();
795
-        return true;
796
-    }
797
-
798
-
799
-
800
-    /**
801
-     *     _load_and_instantiate_reg_step
802
-     *
803
-     * @access    private
804
-     * @param array $reg_step
805
-     * @param int   $order
806
-     * @return bool
807
-     */
808
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
809
-    {
810
-        // we need a file_path, class_name, and slug to add a reg step
811
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
812
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
813
-            if (
814
-                $this->checkout->reg_url_link
815
-                && $this->checkout->step !== $reg_step['slug']
816
-                && $reg_step['slug'] !== 'finalize_registration'
817
-                // normally at this point we would NOT load the reg step, but this filter can change that
818
-                && apply_filters(
819
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
820
-                    true,
821
-                    $reg_step,
822
-                    $this->checkout
823
-                )
824
-            ) {
825
-                return true;
826
-            }
827
-            // instantiate step class using file path and class name
828
-            $reg_step_obj = EE_Registry::instance()->load_file(
829
-                $reg_step['file_path'],
830
-                $reg_step['class_name'],
831
-                'class',
832
-                $this->checkout,
833
-                false
834
-            );
835
-            // did we gets the goods ?
836
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
837
-                // set reg step order based on config
838
-                $reg_step_obj->set_order($order);
839
-                // add instantiated reg step object to the master reg steps array
840
-                $this->checkout->add_reg_step($reg_step_obj);
841
-            } else {
842
-                EE_Error::add_error(
843
-                    __('The current step could not be set.', 'event_espresso'),
844
-                    __FILE__, __FUNCTION__, __LINE__
845
-                );
846
-                return false;
847
-            }
848
-        } else {
849
-            if (WP_DEBUG) {
850
-                EE_Error::add_error(
851
-                    sprintf(
852
-                        __(
853
-                            'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
854
-                            'event_espresso'
855
-                        ),
856
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
857
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
858
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
859
-                        '<ul>',
860
-                        '<li>',
861
-                        '</li>',
862
-                        '</ul>'
863
-                    ),
864
-                    __FILE__, __FUNCTION__, __LINE__
865
-                );
866
-            }
867
-            return false;
868
-        }
869
-        return true;
870
-    }
871
-
872
-
873
-    /**
874
-     * _verify_transaction_and_get_registrations
875
-     *
876
-     * @access private
877
-     * @return bool
878
-     * @throws InvalidDataTypeException
879
-     * @throws InvalidEntityException
880
-     * @throws EE_Error
881
-     */
882
-    private function _verify_transaction_and_get_registrations()
883
-    {
884
-        // was there already a valid transaction in the checkout from the session ?
885
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
886
-            // get transaction from db or session
887
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
888
-                ? $this->_get_transaction_and_cart_for_previous_visit()
889
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
890
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
891
-                EE_Error::add_error(
892
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
893
-                        'event_espresso'),
894
-                    __FILE__, __FUNCTION__, __LINE__
895
-                );
896
-                $this->checkout->transaction = EE_Transaction::new_instance();
897
-                // add some style and make it dance
898
-                $this->add_styles_and_scripts();
899
-                EED_Single_Page_Checkout::$_initialized = true;
900
-                return false;
901
-            }
902
-            // and the registrations for the transaction
903
-            $this->_get_registrations($this->checkout->transaction);
904
-        }
905
-        return true;
906
-    }
907
-
908
-
909
-
910
-    /**
911
-     * _get_transaction_and_cart_for_previous_visit
912
-     *
913
-     * @access private
914
-     * @return mixed EE_Transaction|NULL
915
-     */
916
-    private function _get_transaction_and_cart_for_previous_visit()
917
-    {
918
-        /** @var $TXN_model EEM_Transaction */
919
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
920
-        // because the reg_url_link is present in the request,
921
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
922
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
923
-        // verify transaction
924
-        if ($transaction instanceof EE_Transaction) {
925
-            // and get the cart that was used for that transaction
926
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
927
-            return $transaction;
928
-        }
929
-        EE_Error::add_error(
930
-            __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
931
-            __FILE__, __FUNCTION__, __LINE__
932
-        );
933
-        return null;
934
-
935
-    }
936
-
937
-
938
-
939
-    /**
940
-     * _get_cart_for_transaction
941
-     *
942
-     * @access private
943
-     * @param EE_Transaction $transaction
944
-     * @return EE_Cart
945
-     */
946
-    private function _get_cart_for_transaction($transaction)
947
-    {
948
-        return $this->checkout->get_cart_for_transaction($transaction);
949
-    }
950
-
951
-
952
-
953
-    /**
954
-     * get_cart_for_transaction
955
-     *
956
-     * @access public
957
-     * @param EE_Transaction $transaction
958
-     * @return EE_Cart
959
-     */
960
-    public function get_cart_for_transaction(EE_Transaction $transaction)
961
-    {
962
-        return $this->checkout->get_cart_for_transaction($transaction);
963
-    }
964
-
965
-
966
-
967
-    /**
968
-     * _get_transaction_and_cart_for_current_session
969
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
970
-     *
971
-     * @access private
972
-     * @return EE_Transaction
973
-     * @throws EE_Error
974
-     */
975
-    private function _get_cart_for_current_session_and_setup_new_transaction()
976
-    {
977
-        //  if there's no transaction, then this is the FIRST visit to SPCO
978
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
979
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
980
-        // and then create a new transaction
981
-        $transaction = $this->_initialize_transaction();
982
-        // verify transaction
983
-        if ($transaction instanceof EE_Transaction) {
984
-            // save it so that we have an ID for other objects to use
985
-            $transaction->save();
986
-            // and save TXN data to the cart
987
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
988
-        } else {
989
-            EE_Error::add_error(
990
-                __('A Valid Transaction could not be initialized.', 'event_espresso'),
991
-                __FILE__, __FUNCTION__, __LINE__
992
-            );
993
-        }
994
-        return $transaction;
995
-    }
996
-
997
-
998
-
999
-    /**
1000
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
1001
-     *
1002
-     * @access private
1003
-     * @return mixed EE_Transaction|NULL
1004
-     */
1005
-    private function _initialize_transaction()
1006
-    {
1007
-        try {
1008
-            // ensure cart totals have been calculated
1009
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
1010
-            // grab the cart grand total
1011
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
1012
-            // create new TXN
1013
-            $transaction = EE_Transaction::new_instance(
1014
-                array(
1015
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1016
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1017
-                    'TXN_paid'      => 0,
1018
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
1019
-                )
1020
-            );
1021
-            // save it so that we have an ID for other objects to use
1022
-            $transaction->save();
1023
-            // set cron job for following up on TXNs after their session has expired
1024
-            EE_Cron_Tasks::schedule_expired_transaction_check(
1025
-                EE_Registry::instance()->SSN->expiration() + 1,
1026
-                $transaction->ID()
1027
-            );
1028
-            return $transaction;
1029
-        } catch (Exception $e) {
1030
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1031
-        }
1032
-        return null;
1033
-    }
1034
-
1035
-
1036
-    /**
1037
-     * _get_registrations
1038
-     *
1039
-     * @access private
1040
-     * @param EE_Transaction $transaction
1041
-     * @return void
1042
-     * @throws InvalidDataTypeException
1043
-     * @throws InvalidEntityException
1044
-     * @throws EE_Error
1045
-     */
1046
-    private function _get_registrations(EE_Transaction $transaction)
1047
-    {
1048
-        // first step: grab the registrants  { : o
1049
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1050
-        $this->checkout->total_ticket_count = count($registrations);
1051
-        // verify registrations have been set
1052
-        if (empty($registrations)) {
1053
-            // if no cached registrations, then check the db
1054
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1055
-            // still nothing ? well as long as this isn't a revisit
1056
-            if (empty($registrations) && ! $this->checkout->revisit) {
1057
-                // generate new registrations from scratch
1058
-                $registrations = $this->_initialize_registrations($transaction);
1059
-            }
1060
-        }
1061
-        // sort by their original registration order
1062
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1063
-        // then loop thru the array
1064
-        foreach ($registrations as $registration) {
1065
-            // verify each registration
1066
-            if ($registration instanceof EE_Registration) {
1067
-                // we display all attendee info for the primary registrant
1068
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1069
-                    && $registration->is_primary_registrant()
1070
-                ) {
1071
-                    $this->checkout->primary_revisit = true;
1072
-                    break;
1073
-                }
1074
-                if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1075
-                    // but hide info if it doesn't belong to you
1076
-                    $transaction->clear_cache('Registration', $registration->ID());
1077
-                    $this->checkout->total_ticket_count--;
1078
-                }
1079
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1080
-            }
1081
-        }
1082
-    }
1083
-
1084
-
1085
-    /**
1086
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1087
-     *
1088
-     * @access private
1089
-     * @param EE_Transaction $transaction
1090
-     * @return    array
1091
-     * @throws InvalidDataTypeException
1092
-     * @throws InvalidEntityException
1093
-     * @throws EE_Error
1094
-     */
1095
-    private function _initialize_registrations(EE_Transaction $transaction)
1096
-    {
1097
-        $att_nmbr = 0;
1098
-        $registrations = array();
1099
-        if ($transaction instanceof EE_Transaction) {
1100
-            /** @type EE_Registration_Processor $registration_processor */
1101
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1102
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1103
-            // now let's add the cart items to the $transaction
1104
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1105
-                //do the following for each ticket of this type they selected
1106
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1107
-                    $att_nmbr++;
1108
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1109
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1110
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1111
-                        array(
1112
-                            $transaction,
1113
-                            $line_item,
1114
-                            $att_nmbr,
1115
-                            $this->checkout->total_ticket_count,
1116
-                        )
1117
-                    );
1118
-                    // override capabilities for frontend registrations
1119
-                    if ( ! is_admin()) {
1120
-                        $CreateRegistrationCommand->setCapCheck(
1121
-                            new PublicCapabilities('', 'create_new_registration')
1122
-                        );
1123
-                    }
1124
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1125
-                    if ( ! $registration instanceof EE_Registration) {
1126
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1127
-                    }
1128
-                    $registrations[ $registration->ID() ] = $registration;
1129
-                }
1130
-            }
1131
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1132
-        }
1133
-        return $registrations;
1134
-    }
1135
-
1136
-
1137
-
1138
-    /**
1139
-     * sorts registrations by REG_count
1140
-     *
1141
-     * @access public
1142
-     * @param EE_Registration $reg_A
1143
-     * @param EE_Registration $reg_B
1144
-     * @return int
1145
-     */
1146
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1147
-    {
1148
-        // this shouldn't ever happen within the same TXN, but oh well
1149
-        if ($reg_A->count() === $reg_B->count()) {
1150
-            return 0;
1151
-        }
1152
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1153
-    }
1154
-
1155
-
1156
-
1157
-    /**
1158
-     *    _final_verifications
1159
-     * just makes sure that everything is set up correctly before proceeding
1160
-     *
1161
-     * @access    private
1162
-     * @return    bool
1163
-     * @throws EE_Error
1164
-     */
1165
-    private function _final_verifications()
1166
-    {
1167
-        // filter checkout
1168
-        $this->checkout = apply_filters(
1169
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1170
-            $this->checkout
1171
-        );
1172
-        //verify that current step is still set correctly
1173
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1174
-            EE_Error::add_error(
1175
-                __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1176
-                __FILE__,
1177
-                __FUNCTION__,
1178
-                __LINE__
1179
-            );
1180
-            return false;
1181
-        }
1182
-        // if returning to SPCO, then verify that primary registrant is set
1183
-        if ( ! empty($this->checkout->reg_url_link)) {
1184
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1185
-            if ( ! $valid_registrant instanceof EE_Registration) {
1186
-                EE_Error::add_error(
1187
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1188
-                    __FILE__,
1189
-                    __FUNCTION__,
1190
-                    __LINE__
1191
-                );
1192
-                return false;
1193
-            }
1194
-            $valid_registrant = null;
1195
-            foreach (
1196
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1197
-            ) {
1198
-                if (
1199
-                    $registration instanceof EE_Registration
1200
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1201
-                ) {
1202
-                    $valid_registrant = $registration;
1203
-                }
1204
-            }
1205
-            if ( ! $valid_registrant instanceof EE_Registration) {
1206
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1207
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1208
-                    // clear the session, mark the checkout as unverified, and try again
1209
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1210
-                    EED_Single_Page_Checkout::$_initialized = false;
1211
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1212
-                    $this->_initialize();
1213
-                    EE_Error::reset_notices();
1214
-                    return false;
1215
-                }
1216
-                EE_Error::add_error(
1217
-                    __(
1218
-                        'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1219
-                        'event_espresso'
1220
-                    ),
1221
-                    __FILE__,
1222
-                    __FUNCTION__,
1223
-                    __LINE__
1224
-                );
1225
-                return false;
1226
-            }
1227
-        }
1228
-        // now that things have been kinda sufficiently verified,
1229
-        // let's add the checkout to the session so that it's available to other systems
1230
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1231
-        return true;
1232
-    }
1233
-
1234
-
1235
-
1236
-    /**
1237
-     *    _initialize_reg_steps
1238
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1239
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1240
-     *
1241
-     * @access    private
1242
-     * @param bool $reinitializing
1243
-     * @throws EE_Error
1244
-     */
1245
-    private function _initialize_reg_steps($reinitializing = false)
1246
-    {
1247
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1248
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1249
-        foreach ($this->checkout->reg_steps as $reg_step) {
1250
-            if ( ! $reg_step->initialize_reg_step()) {
1251
-                // if not initialized then maybe this step is being removed...
1252
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1253
-                    // if it was the current step, then we need to start over here
1254
-                    $this->_initialize_reg_steps(true);
1255
-                    return;
1256
-                }
1257
-                continue;
1258
-            }
1259
-            // add css and JS for current step
1260
-            $reg_step->enqueue_styles_and_scripts();
1261
-            // i18n
1262
-            $reg_step->translate_js_strings();
1263
-            if ($reg_step->is_current_step()) {
1264
-                // the text that appears on the reg step form submit button
1265
-                $reg_step->set_submit_button_text();
1266
-            }
1267
-        }
1268
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1269
-        do_action(
1270
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1271
-            $this->checkout->current_step
1272
-        );
1273
-    }
1274
-
1275
-
1276
-
1277
-    /**
1278
-     * _check_form_submission
1279
-     *
1280
-     * @access private
1281
-     * @return boolean
1282
-     */
1283
-    private function _check_form_submission()
1284
-    {
1285
-        //does this request require the reg form to be generated ?
1286
-        if ($this->checkout->generate_reg_form) {
1287
-            // ever heard that song by Blue Rodeo ?
1288
-            try {
1289
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1290
-                // if not displaying a form, then check for form submission
1291
-                if (
1292
-                    $this->checkout->process_form_submission
1293
-                    && $this->checkout->current_step->reg_form->was_submitted()
1294
-                ) {
1295
-                    // clear out any old data in case this step is being run again
1296
-                    $this->checkout->current_step->set_valid_data(array());
1297
-                    // capture submitted form data
1298
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1299
-                        apply_filters(
1300
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1301
-                            EE_Registry::instance()->REQ->params(),
1302
-                            $this->checkout
1303
-                        )
1304
-                    );
1305
-                    // validate submitted form data
1306
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1307
-                        // thou shall not pass !!!
1308
-                        $this->checkout->continue_reg = false;
1309
-                        // any form validation errors?
1310
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1311
-                            $submission_error_messages = array();
1312
-                            // bad, bad, bad registrant
1313
-                            foreach (
1314
-                                $this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1315
-                                as $validation_error
1316
-                            ) {
1317
-                                if ($validation_error instanceof EE_Validation_Error) {
1318
-                                    $submission_error_messages[] = sprintf(
1319
-                                        __('%s : %s', 'event_espresso'),
1320
-                                        $validation_error->get_form_section()->html_label_text(),
1321
-                                        $validation_error->getMessage()
1322
-                                    );
1323
-                                }
1324
-                            }
1325
-                            EE_Error::add_error(
1326
-                                implode('<br />', $submission_error_messages),
1327
-                                __FILE__, __FUNCTION__, __LINE__
1328
-                            );
1329
-                        }
1330
-                        // well not really... what will happen is
1331
-                        // we'll just get redirected back to redo the current step
1332
-                        $this->go_to_next_step();
1333
-                        return false;
1334
-                    }
1335
-                }
1336
-            } catch (EE_Error $e) {
1337
-                $e->get_error();
1338
-            }
1339
-        }
1340
-        return true;
1341
-    }
1342
-
1343
-
1344
-
1345
-    /**
1346
-     * _process_action
1347
-     *
1348
-     * @access private
1349
-     * @return void
1350
-     * @throws EE_Error
1351
-     */
1352
-    private function _process_form_action()
1353
-    {
1354
-        // what cha wanna do?
1355
-        switch ($this->checkout->action) {
1356
-            // AJAX next step reg form
1357
-            case 'display_spco_reg_step' :
1358
-                $this->checkout->redirect = false;
1359
-                if (EE_Registry::instance()->REQ->ajax) {
1360
-                    $this->checkout->json_response->set_reg_step_html(
1361
-                        $this->checkout->current_step->display_reg_form()
1362
-                    );
1363
-                }
1364
-                break;
1365
-            default :
1366
-                // meh... do one of those other steps first
1367
-                if (
1368
-                    ! empty($this->checkout->action)
1369
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1370
-                ) {
1371
-                    // dynamically creates hook point like:
1372
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1373
-                    do_action(
1374
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1375
-                        $this->checkout->current_step
1376
-                    );
1377
-                    // call action on current step
1378
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1379
-                        // good registrant, you get to proceed
1380
-                        if (
1381
-                            $this->checkout->current_step->success_message() !== ''
1382
-                            && apply_filters(
1383
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1384
-                                false
1385
-                            )
1386
-                        ) {
1387
-                            EE_Error::add_success(
1388
-                                $this->checkout->current_step->success_message()
1389
-                                . '<br />' . $this->checkout->next_step->_instructions()
1390
-                            );
1391
-                        }
1392
-                        // pack it up, pack it in...
1393
-                        $this->_setup_redirect();
1394
-                    }
1395
-                    // dynamically creates hook point like:
1396
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1397
-                    do_action(
1398
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1399
-                        $this->checkout->current_step
1400
-                    );
1401
-                } else {
1402
-                    EE_Error::add_error(
1403
-                        sprintf(
1404
-                            __(
1405
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1406
-                                'event_espresso'
1407
-                            ),
1408
-                            $this->checkout->action,
1409
-                            $this->checkout->current_step->name()
1410
-                        ),
1411
-                        __FILE__,
1412
-                        __FUNCTION__,
1413
-                        __LINE__
1414
-                    );
1415
-                }
1416
-            // end default
1417
-        }
1418
-        // store our progress so far
1419
-        $this->checkout->stash_transaction_and_checkout();
1420
-        // advance to the next step! If you pass GO, collect $200
1421
-        $this->go_to_next_step();
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *        add_styles_and_scripts
1428
-     *
1429
-     * @access        public
1430
-     * @return        void
1431
-     */
1432
-    public function add_styles_and_scripts()
1433
-    {
1434
-        // i18n
1435
-        $this->translate_js_strings();
1436
-        if ($this->checkout->admin_request) {
1437
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1438
-        } else {
1439
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1440
-        }
1441
-    }
1442
-
1443
-
1444
-
1445
-    /**
1446
-     *        translate_js_strings
1447
-     *
1448
-     * @access        public
1449
-     * @return        void
1450
-     */
1451
-    public function translate_js_strings()
1452
-    {
1453
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1454
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1455
-        EE_Registry::$i18n_js_strings['server_error'] = __(
1456
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1457
-            'event_espresso'
1458
-        );
1459
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1460
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1461
-            'event_espresso'
1462
-        );
1463
-        EE_Registry::$i18n_js_strings['validation_error'] = __(
1464
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1465
-            'event_espresso'
1466
-        );
1467
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1468
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1469
-            'event_espresso'
1470
-        );
1471
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1472
-            'This registration step could not be completed. Please refresh the page and try again.',
1473
-            'event_espresso'
1474
-        );
1475
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1476
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1477
-            'event_espresso'
1478
-        );
1479
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1480
-            __(
1481
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1482
-                'event_espresso'
1483
-            ),
1484
-            '<br/>',
1485
-            '<br/>'
1486
-        );
1487
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1488
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1489
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1490
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1491
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1492
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1493
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1494
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1495
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1496
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1497
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1498
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1499
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1500
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1501
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1502
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1503
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1504
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1505
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1506
-            __(
1507
-                '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1508
-                'event_espresso'
1509
-            ),
1510
-            '<h4 class="important-notice">',
1511
-            '</h4>',
1512
-            '<br />',
1513
-            '<p>',
1514
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1515
-            '">',
1516
-            '</a>',
1517
-            '</p>'
1518
-        );
1519
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1520
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1521
-            true
1522
-        );
1523
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1524
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1525
-        );
1526
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1527
-            'M d, Y H:i:s',
1528
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1529
-        );
1530
-    }
1531
-
1532
-
1533
-
1534
-    /**
1535
-     *    enqueue_styles_and_scripts
1536
-     *
1537
-     * @access        public
1538
-     * @return        void
1539
-     * @throws EE_Error
1540
-     */
1541
-    public function enqueue_styles_and_scripts()
1542
-    {
1543
-        // load css
1544
-        wp_register_style(
1545
-            'single_page_checkout',
1546
-            SPCO_CSS_URL . 'single_page_checkout.css',
1547
-            array('espresso_default'),
1548
-            EVENT_ESPRESSO_VERSION
1549
-        );
1550
-        wp_enqueue_style('single_page_checkout');
1551
-        // load JS
1552
-        wp_register_script(
1553
-            'jquery_plugin',
1554
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1555
-            array('jquery'),
1556
-            '1.0.1',
1557
-            true
1558
-        );
1559
-        wp_register_script(
1560
-            'jquery_countdown',
1561
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1562
-            array('jquery_plugin'),
1563
-            '2.0.2',
1564
-            true
1565
-        );
1566
-        wp_register_script(
1567
-            'single_page_checkout',
1568
-            SPCO_JS_URL . 'single_page_checkout.js',
1569
-            array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1570
-            EVENT_ESPRESSO_VERSION,
1571
-            true
1572
-        );
1573
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1574
-            $this->checkout->registration_form->enqueue_js();
1575
-        }
1576
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1577
-            $this->checkout->current_step->reg_form->enqueue_js();
1578
-        }
1579
-        wp_enqueue_script('single_page_checkout');
1580
-        /**
1581
-         * global action hook for enqueueing styles and scripts with
1582
-         * spco calls.
1583
-         */
1584
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1585
-        /**
1586
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1587
-         * The hook will end up being something like:
1588
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1589
-         */
1590
-        do_action(
1591
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1592
-            $this
1593
-        );
1594
-    }
1595
-
1596
-
1597
-
1598
-    /**
1599
-     *    display the Registration Single Page Checkout Form
1600
-     *
1601
-     * @access    private
1602
-     * @return    void
1603
-     * @throws EE_Error
1604
-     */
1605
-    private function _display_spco_reg_form()
1606
-    {
1607
-        // if registering via the admin, just display the reg form for the current step
1608
-        if ($this->checkout->admin_request) {
1609
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1610
-        } else {
1611
-            // add powered by EE msg
1612
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1613
-            $empty_cart = count(
1614
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1615
-            ) < 1;
1616
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1617
-            $cookies_not_set_msg = '';
1618
-            if ($empty_cart) {
1619
-                $cookies_not_set_msg = apply_filters(
1620
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1621
-                    sprintf(
1622
-                        __(
1623
-                            '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1624
-                            'event_espresso'
1625
-                        ),
1626
-                        '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1627
-                        '</div>',
1628
-                        '<h6 class="important-notice">',
1629
-                        '</h6>',
1630
-                        '<p>',
1631
-                        '</p>',
1632
-                        '<br />',
1633
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1634
-                        '</a>'
1635
-                    )
1636
-                );
1637
-            }
1638
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1639
-                array(
1640
-                    'name'            => 'single-page-checkout',
1641
-                    'html_id'         => 'ee-single-page-checkout-dv',
1642
-                    'layout_strategy' =>
1643
-                        new EE_Template_Layout(
1644
-                            array(
1645
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1646
-                                'template_args'        => array(
1647
-                                    'empty_cart'              => $empty_cart,
1648
-                                    'revisit'                 => $this->checkout->revisit,
1649
-                                    'reg_steps'               => $this->checkout->reg_steps,
1650
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1651
-                                        ? $this->checkout->next_step->slug()
1652
-                                        : '',
1653
-                                    'empty_msg'               => apply_filters(
1654
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1655
-                                        sprintf(
1656
-                                            __(
1657
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1658
-                                                'event_espresso'
1659
-                                            ),
1660
-                                            '<a href="'
1661
-                                            . get_post_type_archive_link('espresso_events')
1662
-                                            . '" title="',
1663
-                                            '">',
1664
-                                            '</a>'
1665
-                                        )
1666
-                                    ),
1667
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1668
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1669
-                                    'session_expiration'      => gmdate(
1670
-                                        'M d, Y H:i:s',
1671
-                                        EE_Registry::instance()->SSN->expiration()
1672
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1673
-                                    ),
1674
-                                ),
1675
-                            )
1676
-                        ),
1677
-                )
1678
-            );
1679
-            // load template and add to output sent that gets filtered into the_content()
1680
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1681
-        }
1682
-    }
1683
-
1684
-
1685
-
1686
-    /**
1687
-     *    add_extra_finalize_registration_inputs
1688
-     *
1689
-     * @access    public
1690
-     * @param $next_step
1691
-     * @internal  param string $label
1692
-     * @return void
1693
-     */
1694
-    public function add_extra_finalize_registration_inputs($next_step)
1695
-    {
1696
-        if ($next_step === 'finalize_registration') {
1697
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1698
-        }
1699
-    }
1700
-
1701
-
1702
-
1703
-    /**
1704
-     *    display_registration_footer
1705
-     *
1706
-     * @access    public
1707
-     * @return    string
1708
-     */
1709
-    public static function display_registration_footer()
1710
-    {
1711
-        if (
1712
-        apply_filters(
1713
-            'FHEE__EE_Front__Controller__show_reg_footer',
1714
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1715
-        )
1716
-        ) {
1717
-            add_filter(
1718
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1719
-                function ($url) {
1720
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1721
-                }
1722
-            );
1723
-            echo apply_filters(
1724
-                'FHEE__EE_Front_Controller__display_registration_footer',
1725
-                \EEH_Template::powered_by_event_espresso(
1726
-                    '',
1727
-                    'espresso-registration-footer-dv',
1728
-                    array('utm_content' => 'registration_checkout')
1729
-                )
1730
-            );
1731
-        }
1732
-        return '';
1733
-    }
1734
-
1735
-
1736
-
1737
-    /**
1738
-     *    unlock_transaction
1739
-     *
1740
-     * @access    public
1741
-     * @return    void
1742
-     * @throws EE_Error
1743
-     */
1744
-    public function unlock_transaction()
1745
-    {
1746
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1747
-            $this->checkout->transaction->unlock();
1748
-        }
1749
-    }
1750
-
1751
-
1752
-
1753
-    /**
1754
-     *        _setup_redirect
1755
-     *
1756
-     * @access    private
1757
-     * @return void
1758
-     */
1759
-    private function _setup_redirect()
1760
-    {
1761
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1762
-            $this->checkout->redirect = true;
1763
-            if (empty($this->checkout->redirect_url)) {
1764
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1765
-            }
1766
-            $this->checkout->redirect_url = apply_filters(
1767
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1768
-                $this->checkout->redirect_url,
1769
-                $this->checkout
1770
-            );
1771
-        }
1772
-    }
1773
-
1774
-
1775
-
1776
-    /**
1777
-     *   handle ajax message responses and redirects
1778
-     *
1779
-     * @access public
1780
-     * @return void
1781
-     * @throws EE_Error
1782
-     */
1783
-    public function go_to_next_step()
1784
-    {
1785
-        if (EE_Registry::instance()->REQ->ajax) {
1786
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1787
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1788
-        }
1789
-        $this->unlock_transaction();
1790
-        // just return for these conditions
1791
-        if (
1792
-            $this->checkout->admin_request
1793
-            || $this->checkout->action === 'redirect_form'
1794
-            || $this->checkout->action === 'update_checkout'
1795
-        ) {
1796
-            return;
1797
-        }
1798
-        // AJAX response
1799
-        $this->_handle_json_response();
1800
-        // redirect to next step or the Thank You page
1801
-        $this->_handle_html_redirects();
1802
-        // hmmm... must be something wrong, so let's just display the form again !
1803
-        $this->_display_spco_reg_form();
1804
-    }
1805
-
1806
-
1807
-
1808
-    /**
1809
-     *   _handle_json_response
1810
-     *
1811
-     * @access protected
1812
-     * @return void
1813
-     */
1814
-    protected function _handle_json_response()
1815
-    {
1816
-        // if this is an ajax request
1817
-        if (EE_Registry::instance()->REQ->ajax) {
1818
-            // DEBUG LOG
1819
-            //$this->checkout->log(
1820
-            //	__CLASS__, __FUNCTION__, __LINE__,
1821
-            //	array(
1822
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1823
-            //		'redirect'                   => $this->checkout->redirect,
1824
-            //		'continue_reg'               => $this->checkout->continue_reg,
1825
-            //	)
1826
-            //);
1827
-            $this->checkout->json_response->set_registration_time_limit(
1828
-                $this->checkout->get_registration_time_limit()
1829
-            );
1830
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1831
-            // just send the ajax (
1832
-            $json_response = apply_filters(
1833
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1834
-                $this->checkout->json_response
1835
-            );
1836
-            echo $json_response;
1837
-            exit();
1838
-        }
1839
-    }
1840
-
1841
-
1842
-
1843
-    /**
1844
-     *   _handle_redirects
1845
-     *
1846
-     * @access protected
1847
-     * @return void
1848
-     */
1849
-    protected function _handle_html_redirects()
1850
-    {
1851
-        // going somewhere ?
1852
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1853
-            // store notices in a transient
1854
-            EE_Error::get_notices(false, true, true);
1855
-            // DEBUG LOG
1856
-            //$this->checkout->log(
1857
-            //	__CLASS__, __FUNCTION__, __LINE__,
1858
-            //	array(
1859
-            //		'headers_sent' => headers_sent(),
1860
-            //		'redirect_url'     => $this->checkout->redirect_url,
1861
-            //		'headers_list'    => headers_list(),
1862
-            //	)
1863
-            //);
1864
-            wp_safe_redirect($this->checkout->redirect_url);
1865
-            exit();
1866
-        }
1867
-    }
1868
-
1869
-
1870
-
1871
-    /**
1872
-     *   set_checkout_anchor
1873
-     *
1874
-     * @access public
1875
-     * @return void
1876
-     */
1877
-    public function set_checkout_anchor()
1878
-    {
1879
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1880
-    }
23
+	/**
24
+	 * $_initialized - has the SPCO controller already been initialized ?
25
+	 *
26
+	 * @access private
27
+	 * @var bool $_initialized
28
+	 */
29
+	private static $_initialized = false;
30
+
31
+
32
+	/**
33
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
+	 *
35
+	 * @access private
36
+	 * @var bool $_valid_checkout
37
+	 */
38
+	private static $_checkout_verified = true;
39
+
40
+	/**
41
+	 *    $_reg_steps_array - holds initial array of reg steps
42
+	 *
43
+	 * @access private
44
+	 * @var array $_reg_steps_array
45
+	 */
46
+	private static $_reg_steps_array = array();
47
+
48
+	/**
49
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
+	 *
51
+	 * @access public
52
+	 * @var EE_Checkout $checkout
53
+	 */
54
+	public $checkout;
55
+
56
+
57
+
58
+	/**
59
+	 * @return EED_Module|EED_Single_Page_Checkout
60
+	 */
61
+	public static function instance()
62
+	{
63
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
+		return parent::get_instance(__CLASS__);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return EE_CART
71
+	 */
72
+	public function cart()
73
+	{
74
+		return $this->checkout->cart;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return EE_Transaction
81
+	 */
82
+	public function transaction()
83
+	{
84
+		return $this->checkout->transaction;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 *    set_hooks - for hooking into EE Core, other modules, etc
91
+	 *
92
+	 * @access    public
93
+	 * @return    void
94
+	 * @throws EE_Error
95
+	 */
96
+	public static function set_hooks()
97
+	{
98
+		EED_Single_Page_Checkout::set_definitions();
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
+	 *
106
+	 * @access    public
107
+	 * @return    void
108
+	 * @throws EE_Error
109
+	 */
110
+	public static function set_hooks_admin()
111
+	{
112
+		EED_Single_Page_Checkout::set_definitions();
113
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
+			return;
115
+		}
116
+		// going to start an output buffer in case anything gets accidentally output
117
+		// that might disrupt our JSON response
118
+		ob_start();
119
+		EED_Single_Page_Checkout::load_request_handler();
120
+		EED_Single_Page_Checkout::load_reg_steps();
121
+		// set ajax hooks
122
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *    process ajax request
134
+	 *
135
+	 * @param string $ajax_action
136
+	 * @throws EE_Error
137
+	 */
138
+	public static function process_ajax_request($ajax_action)
139
+	{
140
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
141
+		EED_Single_Page_Checkout::instance()->_initialize();
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 *    ajax display registration step
148
+	 *
149
+	 * @throws EE_Error
150
+	 */
151
+	public static function display_reg_step()
152
+	{
153
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 *    ajax process registration step
160
+	 *
161
+	 * @throws EE_Error
162
+	 */
163
+	public static function process_reg_step()
164
+	{
165
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 *    ajax process registration step
172
+	 *
173
+	 * @throws EE_Error
174
+	 */
175
+	public static function update_reg_step()
176
+	{
177
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 *   update_checkout
184
+	 *
185
+	 * @access public
186
+	 * @return void
187
+	 * @throws EE_Error
188
+	 */
189
+	public static function update_checkout()
190
+	{
191
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 *    load_request_handler
198
+	 *
199
+	 * @access    public
200
+	 * @return    void
201
+	 */
202
+	public static function load_request_handler()
203
+	{
204
+		// load core Request_Handler class
205
+		if (EE_Registry::instance()->REQ !== null) {
206
+			EE_Registry::instance()->load_core('Request_Handler');
207
+		}
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 *    set_definitions
214
+	 *
215
+	 * @access    public
216
+	 * @return    void
217
+	 * @throws EE_Error
218
+	 */
219
+	public static function set_definitions()
220
+	{
221
+		if(defined('SPCO_BASE_PATH')) {
222
+			return;
223
+		}
224
+		define(
225
+			'SPCO_BASE_PATH',
226
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
+		);
228
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
+			__('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
237
+				'event_espresso'),
238
+			'<h4 class="important-notice">',
239
+			'</h4>',
240
+			'<br />',
241
+			'<p>',
242
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
+			'">',
244
+			'</a>',
245
+			'</p>'
246
+		);
247
+	}
248
+
249
+
250
+
251
+	/**
252
+	 * load_reg_steps
253
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
+	 *
255
+	 * @access    private
256
+	 * @throws EE_Error
257
+	 */
258
+	public static function load_reg_steps()
259
+	{
260
+		static $reg_steps_loaded = false;
261
+		if ($reg_steps_loaded) {
262
+			return;
263
+		}
264
+		// filter list of reg_steps
265
+		$reg_steps_to_load = (array)apply_filters(
266
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
+			EED_Single_Page_Checkout::get_reg_steps()
268
+		);
269
+		// sort by key (order)
270
+		ksort($reg_steps_to_load);
271
+		// loop through folders
272
+		foreach ($reg_steps_to_load as $order => $reg_step) {
273
+			// we need a
274
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
+				// copy over to the reg_steps_array
276
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
+				// register custom key route for each reg step
278
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
+				EE_Config::register_route(
280
+					$reg_step['slug'],
281
+					'EED_Single_Page_Checkout',
282
+					'run',
283
+					'step'
284
+				);
285
+				// add AJAX or other hooks
286
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
+					// setup autoloaders if necessary
288
+					if ( ! class_exists($reg_step['class_name'])) {
289
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
+							$reg_step['file_path'],
291
+							true
292
+						);
293
+					}
294
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
+					}
297
+				}
298
+			}
299
+		}
300
+		$reg_steps_loaded = true;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 *    get_reg_steps
307
+	 *
308
+	 * @access    public
309
+	 * @return    array
310
+	 */
311
+	public static function get_reg_steps()
312
+	{
313
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
+		if (empty($reg_steps)) {
315
+			$reg_steps = array(
316
+				10  => array(
317
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
+					'slug'       => 'attendee_information',
320
+					'has_hooks'  => false,
321
+				),
322
+				20  => array(
323
+					'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
+					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
+					'slug'       => 'registration_confirmation',
326
+					'has_hooks'  => false,
327
+				),
328
+				30  => array(
329
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
+					'slug'       => 'payment_options',
332
+					'has_hooks'  => true,
333
+				),
334
+				999 => array(
335
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
+					'slug'       => 'finalize_registration',
338
+					'has_hooks'  => false,
339
+				),
340
+			);
341
+		}
342
+		return $reg_steps;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 *    registration_checkout_for_admin
349
+	 *
350
+	 * @access    public
351
+	 * @return    string
352
+	 * @throws EE_Error
353
+	 */
354
+	public static function registration_checkout_for_admin()
355
+	{
356
+		EED_Single_Page_Checkout::load_request_handler();
357
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
360
+		EED_Single_Page_Checkout::instance()->_initialize();
361
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
+		return EE_Registry::instance()->REQ->get_output();
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * process_registration_from_admin
369
+	 *
370
+	 * @access public
371
+	 * @return \EE_Transaction
372
+	 * @throws EE_Error
373
+	 */
374
+	public static function process_registration_from_admin()
375
+	{
376
+		EED_Single_Page_Checkout::load_request_handler();
377
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
380
+		EED_Single_Page_Checkout::instance()->_initialize();
381
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
+				if ($final_reg_step->process_reg_step()) {
386
+					$final_reg_step->set_completed();
387
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
+				}
390
+			}
391
+		}
392
+		return null;
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 *    run
399
+	 *
400
+	 * @access    public
401
+	 * @param WP_Query $WP_Query
402
+	 * @return    void
403
+	 * @throws EE_Error
404
+	 */
405
+	public function run($WP_Query)
406
+	{
407
+		if (
408
+			$WP_Query instanceof WP_Query
409
+			&& $WP_Query->is_main_query()
410
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
+			&& $this->_is_reg_checkout()
412
+		) {
413
+			$this->_initialize();
414
+		}
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * determines whether current url matches reg page url
421
+	 *
422
+	 * @return bool
423
+	 */
424
+	protected function _is_reg_checkout()
425
+	{
426
+		// get current permalink for reg page without any extra query args
427
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
+		// get request URI for current request, but without the scheme or host
429
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
+		$current_request_uri = html_entity_decode($current_request_uri);
431
+		// get array of query args from the current request URI
432
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
433
+		// grab page id if it is set
434
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
+		// and remove the page id from the query args (we will re-add it later)
436
+		unset($query_args['page_id']);
437
+		// now strip all query args from current request URI
438
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
+		// and re-add the page id if it was set
440
+		if ($page_id) {
441
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
+		}
443
+		// remove slashes and ?
444
+		$current_request_uri = trim($current_request_uri, '?/');
445
+		// is current request URI part of the known full reg page URL ?
446
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 * @param WP_Query $wp_query
453
+	 * @return    void
454
+	 * @throws EE_Error
455
+	 */
456
+	public static function init($wp_query)
457
+	{
458
+		EED_Single_Page_Checkout::instance()->run($wp_query);
459
+	}
460
+
461
+
462
+
463
+	/**
464
+	 *    _initialize - initial module setup
465
+	 *
466
+	 * @access    private
467
+	 * @throws EE_Error
468
+	 * @return    void
469
+	 */
470
+	private function _initialize()
471
+	{
472
+		// ensure SPCO doesn't run twice
473
+		if (EED_Single_Page_Checkout::$_initialized) {
474
+			return;
475
+		}
476
+		try {
477
+			EED_Single_Page_Checkout::load_reg_steps();
478
+			$this->_verify_session();
479
+			// setup the EE_Checkout object
480
+			$this->checkout = $this->_initialize_checkout();
481
+			// filter checkout
482
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
+			// get the $_GET
484
+			$this->_get_request_vars();
485
+			if ($this->_block_bots()) {
486
+				return;
487
+			}
488
+			// filter continue_reg
489
+			$this->checkout->continue_reg = apply_filters(
490
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
+				true,
492
+				$this->checkout
493
+			);
494
+			// load the reg steps array
495
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
496
+				EED_Single_Page_Checkout::$_initialized = true;
497
+				return;
498
+			}
499
+			// set the current step
500
+			$this->checkout->set_current_step($this->checkout->step);
501
+			// and the next step
502
+			$this->checkout->set_next_step();
503
+			// verify that everything has been setup correctly
504
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
+				EED_Single_Page_Checkout::$_initialized = true;
506
+				return;
507
+			}
508
+			// lock the transaction
509
+			$this->checkout->transaction->lock();
510
+			// make sure all of our cached objects are added to their respective model entity mappers
511
+			$this->checkout->refresh_all_entities();
512
+			// set amount owing
513
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
+			// initialize each reg step, which gives them the chance to potentially alter the process
515
+			$this->_initialize_reg_steps();
516
+			// DEBUG LOG
517
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
+			// get reg form
519
+			if( ! $this->_check_form_submission()) {
520
+				EED_Single_Page_Checkout::$_initialized = true;
521
+				return;
522
+			}
523
+			// checkout the action!!!
524
+			$this->_process_form_action();
525
+			// add some style and make it dance
526
+			$this->add_styles_and_scripts();
527
+			// kk... SPCO has successfully run
528
+			EED_Single_Page_Checkout::$_initialized = true;
529
+			// set no cache headers and constants
530
+			EE_System::do_not_cache();
531
+			// add anchor
532
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
+			// remove transaction lock
534
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
+		} catch (Exception $e) {
536
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
+		}
538
+	}
539
+
540
+
541
+
542
+	/**
543
+	 *    _verify_session
544
+	 * checks that the session is valid and not expired
545
+	 *
546
+	 * @access    private
547
+	 * @throws EE_Error
548
+	 */
549
+	private function _verify_session()
550
+	{
551
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
+		}
554
+		$clear_session_requested = filter_var(
555
+			EE_Registry::instance()->REQ->get('clear_session', false),
556
+			FILTER_VALIDATE_BOOLEAN
557
+		);
558
+		// is session still valid ?
559
+		if ($clear_session_requested
560
+			|| ( EE_Registry::instance()->SSN->expired()
561
+			  && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
562
+			)
563
+		) {
564
+			$this->checkout = new EE_Checkout();
565
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
566
+			// EE_Registry::instance()->SSN->reset_cart();
567
+			// EE_Registry::instance()->SSN->reset_checkout();
568
+			// EE_Registry::instance()->SSN->reset_transaction();
569
+			if (! $clear_session_requested) {
570
+				EE_Error::add_attention(
571
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
572
+					__FILE__, __FUNCTION__, __LINE__
573
+				);
574
+			}
575
+			// EE_Registry::instance()->SSN->reset_expired();
576
+		}
577
+	}
578
+
579
+
580
+
581
+	/**
582
+	 *    _initialize_checkout
583
+	 * loads and instantiates EE_Checkout
584
+	 *
585
+	 * @access    private
586
+	 * @throws EE_Error
587
+	 * @return EE_Checkout
588
+	 */
589
+	private function _initialize_checkout()
590
+	{
591
+		// look in session for existing checkout
592
+		/** @type EE_Checkout $checkout */
593
+		$checkout = EE_Registry::instance()->SSN->checkout();
594
+		// verify
595
+		if ( ! $checkout instanceof EE_Checkout) {
596
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
597
+			$checkout = EE_Registry::instance()->load_file(
598
+				SPCO_INC_PATH,
599
+				'EE_Checkout',
600
+				'class', array(),
601
+				false
602
+			);
603
+		} else {
604
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
605
+				$this->unlock_transaction();
606
+				wp_safe_redirect($checkout->redirect_url);
607
+				exit();
608
+			}
609
+		}
610
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
611
+		// verify again
612
+		if ( ! $checkout instanceof EE_Checkout) {
613
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
614
+		}
615
+		// reset anything that needs a clean slate for each request
616
+		$checkout->reset_for_current_request();
617
+		return $checkout;
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 *    _get_request_vars
624
+	 *
625
+	 * @access    private
626
+	 * @return    void
627
+	 * @throws EE_Error
628
+	 */
629
+	private function _get_request_vars()
630
+	{
631
+		// load classes
632
+		EED_Single_Page_Checkout::load_request_handler();
633
+		//make sure this request is marked as belonging to EE
634
+		EE_Registry::instance()->REQ->set_espresso_page(true);
635
+		// which step is being requested ?
636
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
637
+		// which step is being edited ?
638
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
639
+		// and what we're doing on the current step
640
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
641
+		// timestamp
642
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
643
+		// returning to edit ?
644
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
645
+		// add reg url link to registration query params
646
+		if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
647
+			$this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
648
+		}
649
+		// or some other kind of revisit ?
650
+		$this->checkout->revisit = filter_var(
651
+			EE_Registry::instance()->REQ->get('revisit', false),
652
+			FILTER_VALIDATE_BOOLEAN
653
+		);
654
+		// and whether or not to generate a reg form for this request
655
+		$this->checkout->generate_reg_form = filter_var(
656
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
657
+			FILTER_VALIDATE_BOOLEAN
658
+		);
659
+		// and whether or not to process a reg form submission for this request
660
+		$this->checkout->process_form_submission = filter_var(
661
+			EE_Registry::instance()->REQ->get(
662
+				'process_form_submission',
663
+				$this->checkout->action === 'process_reg_step'
664
+			),
665
+			FILTER_VALIDATE_BOOLEAN
666
+		);
667
+		$this->checkout->process_form_submission = filter_var(
668
+			$this->checkout->action !== 'display_spco_reg_step'
669
+				? $this->checkout->process_form_submission
670
+				: false,
671
+			FILTER_VALIDATE_BOOLEAN
672
+		);
673
+		// $this->_display_request_vars();
674
+	}
675
+
676
+
677
+
678
+	/**
679
+	 *  _display_request_vars
680
+	 *
681
+	 * @access    protected
682
+	 * @return    void
683
+	 */
684
+	protected function _display_request_vars()
685
+	{
686
+		if ( ! WP_DEBUG) {
687
+			return;
688
+		}
689
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
690
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
691
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
692
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
693
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
694
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
695
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
696
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
697
+	}
698
+
699
+
700
+
701
+	/**
702
+	 * _block_bots
703
+	 * checks that the incoming request has either of the following set:
704
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
705
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
706
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
707
+	 * then where you coming from man?
708
+	 *
709
+	 * @return boolean
710
+	 */
711
+	private function _block_bots()
712
+	{
713
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
714
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
715
+			return true;
716
+		}
717
+		return false;
718
+	}
719
+
720
+
721
+
722
+	/**
723
+	 *    _get_first_step
724
+	 *  gets slug for first step in $_reg_steps_array
725
+	 *
726
+	 * @access    private
727
+	 * @throws EE_Error
728
+	 * @return    string
729
+	 */
730
+	private function _get_first_step()
731
+	{
732
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
733
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 *    _load_and_instantiate_reg_steps
740
+	 *  instantiates each reg step based on the loaded reg_steps array
741
+	 *
742
+	 * @access    private
743
+	 * @throws EE_Error
744
+	 * @return    bool
745
+	 */
746
+	private function _load_and_instantiate_reg_steps()
747
+	{
748
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
749
+		// have reg_steps already been instantiated ?
750
+		if (
751
+			empty($this->checkout->reg_steps)
752
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
753
+		) {
754
+			// if not, then loop through raw reg steps array
755
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
756
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
757
+					return false;
758
+				}
759
+			}
760
+			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
761
+			EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
762
+			// skip the registration_confirmation page ?
763
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
764
+				// just remove it from the reg steps array
765
+				$this->checkout->remove_reg_step('registration_confirmation', false);
766
+			} else if (
767
+				isset($this->checkout->reg_steps['registration_confirmation'])
768
+				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
769
+			) {
770
+				// set the order to something big like 100
771
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
772
+			}
773
+			// filter the array for good luck
774
+			$this->checkout->reg_steps = apply_filters(
775
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
776
+				$this->checkout->reg_steps
777
+			);
778
+			// finally re-sort based on the reg step class order properties
779
+			$this->checkout->sort_reg_steps();
780
+		} else {
781
+			foreach ($this->checkout->reg_steps as $reg_step) {
782
+				// set all current step stati to FALSE
783
+				$reg_step->set_is_current_step(false);
784
+			}
785
+		}
786
+		if (empty($this->checkout->reg_steps)) {
787
+			EE_Error::add_error(
788
+				__('No Reg Steps were loaded..', 'event_espresso'),
789
+				__FILE__, __FUNCTION__, __LINE__
790
+			);
791
+			return false;
792
+		}
793
+		// make reg step details available to JS
794
+		$this->checkout->set_reg_step_JSON_info();
795
+		return true;
796
+	}
797
+
798
+
799
+
800
+	/**
801
+	 *     _load_and_instantiate_reg_step
802
+	 *
803
+	 * @access    private
804
+	 * @param array $reg_step
805
+	 * @param int   $order
806
+	 * @return bool
807
+	 */
808
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
809
+	{
810
+		// we need a file_path, class_name, and slug to add a reg step
811
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
812
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
813
+			if (
814
+				$this->checkout->reg_url_link
815
+				&& $this->checkout->step !== $reg_step['slug']
816
+				&& $reg_step['slug'] !== 'finalize_registration'
817
+				// normally at this point we would NOT load the reg step, but this filter can change that
818
+				&& apply_filters(
819
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
820
+					true,
821
+					$reg_step,
822
+					$this->checkout
823
+				)
824
+			) {
825
+				return true;
826
+			}
827
+			// instantiate step class using file path and class name
828
+			$reg_step_obj = EE_Registry::instance()->load_file(
829
+				$reg_step['file_path'],
830
+				$reg_step['class_name'],
831
+				'class',
832
+				$this->checkout,
833
+				false
834
+			);
835
+			// did we gets the goods ?
836
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
837
+				// set reg step order based on config
838
+				$reg_step_obj->set_order($order);
839
+				// add instantiated reg step object to the master reg steps array
840
+				$this->checkout->add_reg_step($reg_step_obj);
841
+			} else {
842
+				EE_Error::add_error(
843
+					__('The current step could not be set.', 'event_espresso'),
844
+					__FILE__, __FUNCTION__, __LINE__
845
+				);
846
+				return false;
847
+			}
848
+		} else {
849
+			if (WP_DEBUG) {
850
+				EE_Error::add_error(
851
+					sprintf(
852
+						__(
853
+							'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
854
+							'event_espresso'
855
+						),
856
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
857
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
858
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
859
+						'<ul>',
860
+						'<li>',
861
+						'</li>',
862
+						'</ul>'
863
+					),
864
+					__FILE__, __FUNCTION__, __LINE__
865
+				);
866
+			}
867
+			return false;
868
+		}
869
+		return true;
870
+	}
871
+
872
+
873
+	/**
874
+	 * _verify_transaction_and_get_registrations
875
+	 *
876
+	 * @access private
877
+	 * @return bool
878
+	 * @throws InvalidDataTypeException
879
+	 * @throws InvalidEntityException
880
+	 * @throws EE_Error
881
+	 */
882
+	private function _verify_transaction_and_get_registrations()
883
+	{
884
+		// was there already a valid transaction in the checkout from the session ?
885
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
886
+			// get transaction from db or session
887
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
888
+				? $this->_get_transaction_and_cart_for_previous_visit()
889
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
890
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
891
+				EE_Error::add_error(
892
+					__('Your Registration and Transaction information could not be retrieved from the db.',
893
+						'event_espresso'),
894
+					__FILE__, __FUNCTION__, __LINE__
895
+				);
896
+				$this->checkout->transaction = EE_Transaction::new_instance();
897
+				// add some style and make it dance
898
+				$this->add_styles_and_scripts();
899
+				EED_Single_Page_Checkout::$_initialized = true;
900
+				return false;
901
+			}
902
+			// and the registrations for the transaction
903
+			$this->_get_registrations($this->checkout->transaction);
904
+		}
905
+		return true;
906
+	}
907
+
908
+
909
+
910
+	/**
911
+	 * _get_transaction_and_cart_for_previous_visit
912
+	 *
913
+	 * @access private
914
+	 * @return mixed EE_Transaction|NULL
915
+	 */
916
+	private function _get_transaction_and_cart_for_previous_visit()
917
+	{
918
+		/** @var $TXN_model EEM_Transaction */
919
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
920
+		// because the reg_url_link is present in the request,
921
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
922
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
923
+		// verify transaction
924
+		if ($transaction instanceof EE_Transaction) {
925
+			// and get the cart that was used for that transaction
926
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
927
+			return $transaction;
928
+		}
929
+		EE_Error::add_error(
930
+			__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
931
+			__FILE__, __FUNCTION__, __LINE__
932
+		);
933
+		return null;
934
+
935
+	}
936
+
937
+
938
+
939
+	/**
940
+	 * _get_cart_for_transaction
941
+	 *
942
+	 * @access private
943
+	 * @param EE_Transaction $transaction
944
+	 * @return EE_Cart
945
+	 */
946
+	private function _get_cart_for_transaction($transaction)
947
+	{
948
+		return $this->checkout->get_cart_for_transaction($transaction);
949
+	}
950
+
951
+
952
+
953
+	/**
954
+	 * get_cart_for_transaction
955
+	 *
956
+	 * @access public
957
+	 * @param EE_Transaction $transaction
958
+	 * @return EE_Cart
959
+	 */
960
+	public function get_cart_for_transaction(EE_Transaction $transaction)
961
+	{
962
+		return $this->checkout->get_cart_for_transaction($transaction);
963
+	}
964
+
965
+
966
+
967
+	/**
968
+	 * _get_transaction_and_cart_for_current_session
969
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
970
+	 *
971
+	 * @access private
972
+	 * @return EE_Transaction
973
+	 * @throws EE_Error
974
+	 */
975
+	private function _get_cart_for_current_session_and_setup_new_transaction()
976
+	{
977
+		//  if there's no transaction, then this is the FIRST visit to SPCO
978
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
979
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
980
+		// and then create a new transaction
981
+		$transaction = $this->_initialize_transaction();
982
+		// verify transaction
983
+		if ($transaction instanceof EE_Transaction) {
984
+			// save it so that we have an ID for other objects to use
985
+			$transaction->save();
986
+			// and save TXN data to the cart
987
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
988
+		} else {
989
+			EE_Error::add_error(
990
+				__('A Valid Transaction could not be initialized.', 'event_espresso'),
991
+				__FILE__, __FUNCTION__, __LINE__
992
+			);
993
+		}
994
+		return $transaction;
995
+	}
996
+
997
+
998
+
999
+	/**
1000
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
1001
+	 *
1002
+	 * @access private
1003
+	 * @return mixed EE_Transaction|NULL
1004
+	 */
1005
+	private function _initialize_transaction()
1006
+	{
1007
+		try {
1008
+			// ensure cart totals have been calculated
1009
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
1010
+			// grab the cart grand total
1011
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
1012
+			// create new TXN
1013
+			$transaction = EE_Transaction::new_instance(
1014
+				array(
1015
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1016
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1017
+					'TXN_paid'      => 0,
1018
+					'STS_ID'        => EEM_Transaction::failed_status_code,
1019
+				)
1020
+			);
1021
+			// save it so that we have an ID for other objects to use
1022
+			$transaction->save();
1023
+			// set cron job for following up on TXNs after their session has expired
1024
+			EE_Cron_Tasks::schedule_expired_transaction_check(
1025
+				EE_Registry::instance()->SSN->expiration() + 1,
1026
+				$transaction->ID()
1027
+			);
1028
+			return $transaction;
1029
+		} catch (Exception $e) {
1030
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1031
+		}
1032
+		return null;
1033
+	}
1034
+
1035
+
1036
+	/**
1037
+	 * _get_registrations
1038
+	 *
1039
+	 * @access private
1040
+	 * @param EE_Transaction $transaction
1041
+	 * @return void
1042
+	 * @throws InvalidDataTypeException
1043
+	 * @throws InvalidEntityException
1044
+	 * @throws EE_Error
1045
+	 */
1046
+	private function _get_registrations(EE_Transaction $transaction)
1047
+	{
1048
+		// first step: grab the registrants  { : o
1049
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1050
+		$this->checkout->total_ticket_count = count($registrations);
1051
+		// verify registrations have been set
1052
+		if (empty($registrations)) {
1053
+			// if no cached registrations, then check the db
1054
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1055
+			// still nothing ? well as long as this isn't a revisit
1056
+			if (empty($registrations) && ! $this->checkout->revisit) {
1057
+				// generate new registrations from scratch
1058
+				$registrations = $this->_initialize_registrations($transaction);
1059
+			}
1060
+		}
1061
+		// sort by their original registration order
1062
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1063
+		// then loop thru the array
1064
+		foreach ($registrations as $registration) {
1065
+			// verify each registration
1066
+			if ($registration instanceof EE_Registration) {
1067
+				// we display all attendee info for the primary registrant
1068
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1069
+					&& $registration->is_primary_registrant()
1070
+				) {
1071
+					$this->checkout->primary_revisit = true;
1072
+					break;
1073
+				}
1074
+				if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1075
+					// but hide info if it doesn't belong to you
1076
+					$transaction->clear_cache('Registration', $registration->ID());
1077
+					$this->checkout->total_ticket_count--;
1078
+				}
1079
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1080
+			}
1081
+		}
1082
+	}
1083
+
1084
+
1085
+	/**
1086
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1087
+	 *
1088
+	 * @access private
1089
+	 * @param EE_Transaction $transaction
1090
+	 * @return    array
1091
+	 * @throws InvalidDataTypeException
1092
+	 * @throws InvalidEntityException
1093
+	 * @throws EE_Error
1094
+	 */
1095
+	private function _initialize_registrations(EE_Transaction $transaction)
1096
+	{
1097
+		$att_nmbr = 0;
1098
+		$registrations = array();
1099
+		if ($transaction instanceof EE_Transaction) {
1100
+			/** @type EE_Registration_Processor $registration_processor */
1101
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1102
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1103
+			// now let's add the cart items to the $transaction
1104
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1105
+				//do the following for each ticket of this type they selected
1106
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1107
+					$att_nmbr++;
1108
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1109
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1110
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1111
+						array(
1112
+							$transaction,
1113
+							$line_item,
1114
+							$att_nmbr,
1115
+							$this->checkout->total_ticket_count,
1116
+						)
1117
+					);
1118
+					// override capabilities for frontend registrations
1119
+					if ( ! is_admin()) {
1120
+						$CreateRegistrationCommand->setCapCheck(
1121
+							new PublicCapabilities('', 'create_new_registration')
1122
+						);
1123
+					}
1124
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1125
+					if ( ! $registration instanceof EE_Registration) {
1126
+						throw new InvalidEntityException($registration, 'EE_Registration');
1127
+					}
1128
+					$registrations[ $registration->ID() ] = $registration;
1129
+				}
1130
+			}
1131
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1132
+		}
1133
+		return $registrations;
1134
+	}
1135
+
1136
+
1137
+
1138
+	/**
1139
+	 * sorts registrations by REG_count
1140
+	 *
1141
+	 * @access public
1142
+	 * @param EE_Registration $reg_A
1143
+	 * @param EE_Registration $reg_B
1144
+	 * @return int
1145
+	 */
1146
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1147
+	{
1148
+		// this shouldn't ever happen within the same TXN, but oh well
1149
+		if ($reg_A->count() === $reg_B->count()) {
1150
+			return 0;
1151
+		}
1152
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1153
+	}
1154
+
1155
+
1156
+
1157
+	/**
1158
+	 *    _final_verifications
1159
+	 * just makes sure that everything is set up correctly before proceeding
1160
+	 *
1161
+	 * @access    private
1162
+	 * @return    bool
1163
+	 * @throws EE_Error
1164
+	 */
1165
+	private function _final_verifications()
1166
+	{
1167
+		// filter checkout
1168
+		$this->checkout = apply_filters(
1169
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1170
+			$this->checkout
1171
+		);
1172
+		//verify that current step is still set correctly
1173
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1174
+			EE_Error::add_error(
1175
+				__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1176
+				__FILE__,
1177
+				__FUNCTION__,
1178
+				__LINE__
1179
+			);
1180
+			return false;
1181
+		}
1182
+		// if returning to SPCO, then verify that primary registrant is set
1183
+		if ( ! empty($this->checkout->reg_url_link)) {
1184
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1185
+			if ( ! $valid_registrant instanceof EE_Registration) {
1186
+				EE_Error::add_error(
1187
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1188
+					__FILE__,
1189
+					__FUNCTION__,
1190
+					__LINE__
1191
+				);
1192
+				return false;
1193
+			}
1194
+			$valid_registrant = null;
1195
+			foreach (
1196
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1197
+			) {
1198
+				if (
1199
+					$registration instanceof EE_Registration
1200
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1201
+				) {
1202
+					$valid_registrant = $registration;
1203
+				}
1204
+			}
1205
+			if ( ! $valid_registrant instanceof EE_Registration) {
1206
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1207
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1208
+					// clear the session, mark the checkout as unverified, and try again
1209
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1210
+					EED_Single_Page_Checkout::$_initialized = false;
1211
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1212
+					$this->_initialize();
1213
+					EE_Error::reset_notices();
1214
+					return false;
1215
+				}
1216
+				EE_Error::add_error(
1217
+					__(
1218
+						'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1219
+						'event_espresso'
1220
+					),
1221
+					__FILE__,
1222
+					__FUNCTION__,
1223
+					__LINE__
1224
+				);
1225
+				return false;
1226
+			}
1227
+		}
1228
+		// now that things have been kinda sufficiently verified,
1229
+		// let's add the checkout to the session so that it's available to other systems
1230
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1231
+		return true;
1232
+	}
1233
+
1234
+
1235
+
1236
+	/**
1237
+	 *    _initialize_reg_steps
1238
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1239
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1240
+	 *
1241
+	 * @access    private
1242
+	 * @param bool $reinitializing
1243
+	 * @throws EE_Error
1244
+	 */
1245
+	private function _initialize_reg_steps($reinitializing = false)
1246
+	{
1247
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1248
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1249
+		foreach ($this->checkout->reg_steps as $reg_step) {
1250
+			if ( ! $reg_step->initialize_reg_step()) {
1251
+				// if not initialized then maybe this step is being removed...
1252
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1253
+					// if it was the current step, then we need to start over here
1254
+					$this->_initialize_reg_steps(true);
1255
+					return;
1256
+				}
1257
+				continue;
1258
+			}
1259
+			// add css and JS for current step
1260
+			$reg_step->enqueue_styles_and_scripts();
1261
+			// i18n
1262
+			$reg_step->translate_js_strings();
1263
+			if ($reg_step->is_current_step()) {
1264
+				// the text that appears on the reg step form submit button
1265
+				$reg_step->set_submit_button_text();
1266
+			}
1267
+		}
1268
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1269
+		do_action(
1270
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1271
+			$this->checkout->current_step
1272
+		);
1273
+	}
1274
+
1275
+
1276
+
1277
+	/**
1278
+	 * _check_form_submission
1279
+	 *
1280
+	 * @access private
1281
+	 * @return boolean
1282
+	 */
1283
+	private function _check_form_submission()
1284
+	{
1285
+		//does this request require the reg form to be generated ?
1286
+		if ($this->checkout->generate_reg_form) {
1287
+			// ever heard that song by Blue Rodeo ?
1288
+			try {
1289
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1290
+				// if not displaying a form, then check for form submission
1291
+				if (
1292
+					$this->checkout->process_form_submission
1293
+					&& $this->checkout->current_step->reg_form->was_submitted()
1294
+				) {
1295
+					// clear out any old data in case this step is being run again
1296
+					$this->checkout->current_step->set_valid_data(array());
1297
+					// capture submitted form data
1298
+					$this->checkout->current_step->reg_form->receive_form_submission(
1299
+						apply_filters(
1300
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1301
+							EE_Registry::instance()->REQ->params(),
1302
+							$this->checkout
1303
+						)
1304
+					);
1305
+					// validate submitted form data
1306
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1307
+						// thou shall not pass !!!
1308
+						$this->checkout->continue_reg = false;
1309
+						// any form validation errors?
1310
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1311
+							$submission_error_messages = array();
1312
+							// bad, bad, bad registrant
1313
+							foreach (
1314
+								$this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1315
+								as $validation_error
1316
+							) {
1317
+								if ($validation_error instanceof EE_Validation_Error) {
1318
+									$submission_error_messages[] = sprintf(
1319
+										__('%s : %s', 'event_espresso'),
1320
+										$validation_error->get_form_section()->html_label_text(),
1321
+										$validation_error->getMessage()
1322
+									);
1323
+								}
1324
+							}
1325
+							EE_Error::add_error(
1326
+								implode('<br />', $submission_error_messages),
1327
+								__FILE__, __FUNCTION__, __LINE__
1328
+							);
1329
+						}
1330
+						// well not really... what will happen is
1331
+						// we'll just get redirected back to redo the current step
1332
+						$this->go_to_next_step();
1333
+						return false;
1334
+					}
1335
+				}
1336
+			} catch (EE_Error $e) {
1337
+				$e->get_error();
1338
+			}
1339
+		}
1340
+		return true;
1341
+	}
1342
+
1343
+
1344
+
1345
+	/**
1346
+	 * _process_action
1347
+	 *
1348
+	 * @access private
1349
+	 * @return void
1350
+	 * @throws EE_Error
1351
+	 */
1352
+	private function _process_form_action()
1353
+	{
1354
+		// what cha wanna do?
1355
+		switch ($this->checkout->action) {
1356
+			// AJAX next step reg form
1357
+			case 'display_spco_reg_step' :
1358
+				$this->checkout->redirect = false;
1359
+				if (EE_Registry::instance()->REQ->ajax) {
1360
+					$this->checkout->json_response->set_reg_step_html(
1361
+						$this->checkout->current_step->display_reg_form()
1362
+					);
1363
+				}
1364
+				break;
1365
+			default :
1366
+				// meh... do one of those other steps first
1367
+				if (
1368
+					! empty($this->checkout->action)
1369
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1370
+				) {
1371
+					// dynamically creates hook point like:
1372
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1373
+					do_action(
1374
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1375
+						$this->checkout->current_step
1376
+					);
1377
+					// call action on current step
1378
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1379
+						// good registrant, you get to proceed
1380
+						if (
1381
+							$this->checkout->current_step->success_message() !== ''
1382
+							&& apply_filters(
1383
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1384
+								false
1385
+							)
1386
+						) {
1387
+							EE_Error::add_success(
1388
+								$this->checkout->current_step->success_message()
1389
+								. '<br />' . $this->checkout->next_step->_instructions()
1390
+							);
1391
+						}
1392
+						// pack it up, pack it in...
1393
+						$this->_setup_redirect();
1394
+					}
1395
+					// dynamically creates hook point like:
1396
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1397
+					do_action(
1398
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1399
+						$this->checkout->current_step
1400
+					);
1401
+				} else {
1402
+					EE_Error::add_error(
1403
+						sprintf(
1404
+							__(
1405
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1406
+								'event_espresso'
1407
+							),
1408
+							$this->checkout->action,
1409
+							$this->checkout->current_step->name()
1410
+						),
1411
+						__FILE__,
1412
+						__FUNCTION__,
1413
+						__LINE__
1414
+					);
1415
+				}
1416
+			// end default
1417
+		}
1418
+		// store our progress so far
1419
+		$this->checkout->stash_transaction_and_checkout();
1420
+		// advance to the next step! If you pass GO, collect $200
1421
+		$this->go_to_next_step();
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *        add_styles_and_scripts
1428
+	 *
1429
+	 * @access        public
1430
+	 * @return        void
1431
+	 */
1432
+	public function add_styles_and_scripts()
1433
+	{
1434
+		// i18n
1435
+		$this->translate_js_strings();
1436
+		if ($this->checkout->admin_request) {
1437
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1438
+		} else {
1439
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1440
+		}
1441
+	}
1442
+
1443
+
1444
+
1445
+	/**
1446
+	 *        translate_js_strings
1447
+	 *
1448
+	 * @access        public
1449
+	 * @return        void
1450
+	 */
1451
+	public function translate_js_strings()
1452
+	{
1453
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1454
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1455
+		EE_Registry::$i18n_js_strings['server_error'] = __(
1456
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1457
+			'event_espresso'
1458
+		);
1459
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1460
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1461
+			'event_espresso'
1462
+		);
1463
+		EE_Registry::$i18n_js_strings['validation_error'] = __(
1464
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1465
+			'event_espresso'
1466
+		);
1467
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1468
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1469
+			'event_espresso'
1470
+		);
1471
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1472
+			'This registration step could not be completed. Please refresh the page and try again.',
1473
+			'event_espresso'
1474
+		);
1475
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1476
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1477
+			'event_espresso'
1478
+		);
1479
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1480
+			__(
1481
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1482
+				'event_espresso'
1483
+			),
1484
+			'<br/>',
1485
+			'<br/>'
1486
+		);
1487
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1488
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1489
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1490
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1491
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1492
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1493
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1494
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1495
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1496
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1497
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1498
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1499
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1500
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1501
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1502
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1503
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1504
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1505
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1506
+			__(
1507
+				'%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1508
+				'event_espresso'
1509
+			),
1510
+			'<h4 class="important-notice">',
1511
+			'</h4>',
1512
+			'<br />',
1513
+			'<p>',
1514
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1515
+			'">',
1516
+			'</a>',
1517
+			'</p>'
1518
+		);
1519
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1520
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1521
+			true
1522
+		);
1523
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1524
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1525
+		);
1526
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1527
+			'M d, Y H:i:s',
1528
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1529
+		);
1530
+	}
1531
+
1532
+
1533
+
1534
+	/**
1535
+	 *    enqueue_styles_and_scripts
1536
+	 *
1537
+	 * @access        public
1538
+	 * @return        void
1539
+	 * @throws EE_Error
1540
+	 */
1541
+	public function enqueue_styles_and_scripts()
1542
+	{
1543
+		// load css
1544
+		wp_register_style(
1545
+			'single_page_checkout',
1546
+			SPCO_CSS_URL . 'single_page_checkout.css',
1547
+			array('espresso_default'),
1548
+			EVENT_ESPRESSO_VERSION
1549
+		);
1550
+		wp_enqueue_style('single_page_checkout');
1551
+		// load JS
1552
+		wp_register_script(
1553
+			'jquery_plugin',
1554
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1555
+			array('jquery'),
1556
+			'1.0.1',
1557
+			true
1558
+		);
1559
+		wp_register_script(
1560
+			'jquery_countdown',
1561
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1562
+			array('jquery_plugin'),
1563
+			'2.0.2',
1564
+			true
1565
+		);
1566
+		wp_register_script(
1567
+			'single_page_checkout',
1568
+			SPCO_JS_URL . 'single_page_checkout.js',
1569
+			array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1570
+			EVENT_ESPRESSO_VERSION,
1571
+			true
1572
+		);
1573
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1574
+			$this->checkout->registration_form->enqueue_js();
1575
+		}
1576
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1577
+			$this->checkout->current_step->reg_form->enqueue_js();
1578
+		}
1579
+		wp_enqueue_script('single_page_checkout');
1580
+		/**
1581
+		 * global action hook for enqueueing styles and scripts with
1582
+		 * spco calls.
1583
+		 */
1584
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1585
+		/**
1586
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1587
+		 * The hook will end up being something like:
1588
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1589
+		 */
1590
+		do_action(
1591
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1592
+			$this
1593
+		);
1594
+	}
1595
+
1596
+
1597
+
1598
+	/**
1599
+	 *    display the Registration Single Page Checkout Form
1600
+	 *
1601
+	 * @access    private
1602
+	 * @return    void
1603
+	 * @throws EE_Error
1604
+	 */
1605
+	private function _display_spco_reg_form()
1606
+	{
1607
+		// if registering via the admin, just display the reg form for the current step
1608
+		if ($this->checkout->admin_request) {
1609
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1610
+		} else {
1611
+			// add powered by EE msg
1612
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1613
+			$empty_cart = count(
1614
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1615
+			) < 1;
1616
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1617
+			$cookies_not_set_msg = '';
1618
+			if ($empty_cart) {
1619
+				$cookies_not_set_msg = apply_filters(
1620
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1621
+					sprintf(
1622
+						__(
1623
+							'%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1624
+							'event_espresso'
1625
+						),
1626
+						'<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1627
+						'</div>',
1628
+						'<h6 class="important-notice">',
1629
+						'</h6>',
1630
+						'<p>',
1631
+						'</p>',
1632
+						'<br />',
1633
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1634
+						'</a>'
1635
+					)
1636
+				);
1637
+			}
1638
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1639
+				array(
1640
+					'name'            => 'single-page-checkout',
1641
+					'html_id'         => 'ee-single-page-checkout-dv',
1642
+					'layout_strategy' =>
1643
+						new EE_Template_Layout(
1644
+							array(
1645
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1646
+								'template_args'        => array(
1647
+									'empty_cart'              => $empty_cart,
1648
+									'revisit'                 => $this->checkout->revisit,
1649
+									'reg_steps'               => $this->checkout->reg_steps,
1650
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1651
+										? $this->checkout->next_step->slug()
1652
+										: '',
1653
+									'empty_msg'               => apply_filters(
1654
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1655
+										sprintf(
1656
+											__(
1657
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1658
+												'event_espresso'
1659
+											),
1660
+											'<a href="'
1661
+											. get_post_type_archive_link('espresso_events')
1662
+											. '" title="',
1663
+											'">',
1664
+											'</a>'
1665
+										)
1666
+									),
1667
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1668
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1669
+									'session_expiration'      => gmdate(
1670
+										'M d, Y H:i:s',
1671
+										EE_Registry::instance()->SSN->expiration()
1672
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1673
+									),
1674
+								),
1675
+							)
1676
+						),
1677
+				)
1678
+			);
1679
+			// load template and add to output sent that gets filtered into the_content()
1680
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1681
+		}
1682
+	}
1683
+
1684
+
1685
+
1686
+	/**
1687
+	 *    add_extra_finalize_registration_inputs
1688
+	 *
1689
+	 * @access    public
1690
+	 * @param $next_step
1691
+	 * @internal  param string $label
1692
+	 * @return void
1693
+	 */
1694
+	public function add_extra_finalize_registration_inputs($next_step)
1695
+	{
1696
+		if ($next_step === 'finalize_registration') {
1697
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1698
+		}
1699
+	}
1700
+
1701
+
1702
+
1703
+	/**
1704
+	 *    display_registration_footer
1705
+	 *
1706
+	 * @access    public
1707
+	 * @return    string
1708
+	 */
1709
+	public static function display_registration_footer()
1710
+	{
1711
+		if (
1712
+		apply_filters(
1713
+			'FHEE__EE_Front__Controller__show_reg_footer',
1714
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1715
+		)
1716
+		) {
1717
+			add_filter(
1718
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1719
+				function ($url) {
1720
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1721
+				}
1722
+			);
1723
+			echo apply_filters(
1724
+				'FHEE__EE_Front_Controller__display_registration_footer',
1725
+				\EEH_Template::powered_by_event_espresso(
1726
+					'',
1727
+					'espresso-registration-footer-dv',
1728
+					array('utm_content' => 'registration_checkout')
1729
+				)
1730
+			);
1731
+		}
1732
+		return '';
1733
+	}
1734
+
1735
+
1736
+
1737
+	/**
1738
+	 *    unlock_transaction
1739
+	 *
1740
+	 * @access    public
1741
+	 * @return    void
1742
+	 * @throws EE_Error
1743
+	 */
1744
+	public function unlock_transaction()
1745
+	{
1746
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1747
+			$this->checkout->transaction->unlock();
1748
+		}
1749
+	}
1750
+
1751
+
1752
+
1753
+	/**
1754
+	 *        _setup_redirect
1755
+	 *
1756
+	 * @access    private
1757
+	 * @return void
1758
+	 */
1759
+	private function _setup_redirect()
1760
+	{
1761
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1762
+			$this->checkout->redirect = true;
1763
+			if (empty($this->checkout->redirect_url)) {
1764
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1765
+			}
1766
+			$this->checkout->redirect_url = apply_filters(
1767
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1768
+				$this->checkout->redirect_url,
1769
+				$this->checkout
1770
+			);
1771
+		}
1772
+	}
1773
+
1774
+
1775
+
1776
+	/**
1777
+	 *   handle ajax message responses and redirects
1778
+	 *
1779
+	 * @access public
1780
+	 * @return void
1781
+	 * @throws EE_Error
1782
+	 */
1783
+	public function go_to_next_step()
1784
+	{
1785
+		if (EE_Registry::instance()->REQ->ajax) {
1786
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1787
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1788
+		}
1789
+		$this->unlock_transaction();
1790
+		// just return for these conditions
1791
+		if (
1792
+			$this->checkout->admin_request
1793
+			|| $this->checkout->action === 'redirect_form'
1794
+			|| $this->checkout->action === 'update_checkout'
1795
+		) {
1796
+			return;
1797
+		}
1798
+		// AJAX response
1799
+		$this->_handle_json_response();
1800
+		// redirect to next step or the Thank You page
1801
+		$this->_handle_html_redirects();
1802
+		// hmmm... must be something wrong, so let's just display the form again !
1803
+		$this->_display_spco_reg_form();
1804
+	}
1805
+
1806
+
1807
+
1808
+	/**
1809
+	 *   _handle_json_response
1810
+	 *
1811
+	 * @access protected
1812
+	 * @return void
1813
+	 */
1814
+	protected function _handle_json_response()
1815
+	{
1816
+		// if this is an ajax request
1817
+		if (EE_Registry::instance()->REQ->ajax) {
1818
+			// DEBUG LOG
1819
+			//$this->checkout->log(
1820
+			//	__CLASS__, __FUNCTION__, __LINE__,
1821
+			//	array(
1822
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1823
+			//		'redirect'                   => $this->checkout->redirect,
1824
+			//		'continue_reg'               => $this->checkout->continue_reg,
1825
+			//	)
1826
+			//);
1827
+			$this->checkout->json_response->set_registration_time_limit(
1828
+				$this->checkout->get_registration_time_limit()
1829
+			);
1830
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1831
+			// just send the ajax (
1832
+			$json_response = apply_filters(
1833
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1834
+				$this->checkout->json_response
1835
+			);
1836
+			echo $json_response;
1837
+			exit();
1838
+		}
1839
+	}
1840
+
1841
+
1842
+
1843
+	/**
1844
+	 *   _handle_redirects
1845
+	 *
1846
+	 * @access protected
1847
+	 * @return void
1848
+	 */
1849
+	protected function _handle_html_redirects()
1850
+	{
1851
+		// going somewhere ?
1852
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1853
+			// store notices in a transient
1854
+			EE_Error::get_notices(false, true, true);
1855
+			// DEBUG LOG
1856
+			//$this->checkout->log(
1857
+			//	__CLASS__, __FUNCTION__, __LINE__,
1858
+			//	array(
1859
+			//		'headers_sent' => headers_sent(),
1860
+			//		'redirect_url'     => $this->checkout->redirect_url,
1861
+			//		'headers_list'    => headers_list(),
1862
+			//	)
1863
+			//);
1864
+			wp_safe_redirect($this->checkout->redirect_url);
1865
+			exit();
1866
+		}
1867
+	}
1868
+
1869
+
1870
+
1871
+	/**
1872
+	 *   set_checkout_anchor
1873
+	 *
1874
+	 * @access public
1875
+	 * @return void
1876
+	 */
1877
+	public function set_checkout_anchor()
1878
+	{
1879
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1880
+	}
1881 1881
 
1882 1882
 
1883 1883
 
Please login to merge, or discard this patch.
core/helpers/EEH_Venue_View.helper.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
 	 * @param bool $password_check
46 46
 	 * @return \EE_Venue|null
47 47
 	 */
48
-	public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true ) {
49
-		$VNU_ID = absint( $VNU_ID );
48
+	public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true) {
49
+		$VNU_ID = absint($VNU_ID);
50 50
 		// do we already have the Venue you are looking for?
51
-		if ( EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
51
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
52 52
 			//If the Venue ID matches $VNU_ID, return the venue.
53
-			if( EEH_Venue_View::$_venue->ID() === $VNU_ID ) {
54
-				return EEH_Venue_View::_get_venue( $privacy_check );
53
+			if (EEH_Venue_View::$_venue->ID() === $VNU_ID) {
54
+				return EEH_Venue_View::_get_venue($privacy_check);
55 55
 			}
56 56
 			//If the Venue ID does not match, try pulling a venue using $VNU_ID.
57
-			$venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
58
-			if( $venue instanceof EE_Venue ) {
57
+			$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
58
+			if ($venue instanceof EE_Venue) {
59 59
 				EEH_Venue_View::$_venue = $venue;
60
-				return EEH_Venue_View::_get_venue( $privacy_check );
60
+				return EEH_Venue_View::_get_venue($privacy_check);
61 61
 			}
62 62
 		}
63 63
 		// international newspaper?
64 64
 		global $post;
65
-		if ( $post instanceof WP_Post ) {
66
-			switch ( $post->post_type ) {
65
+		if ($post instanceof WP_Post) {
66
+			switch ($post->post_type) {
67 67
 				// if this is being called from an EE_Venue post,
68 68
 				// and the EE_Venue post corresponds to the EE_Venue that is being asked for,
69 69
 				// then we can try to just grab the attached EE_Venue object
@@ -71,31 +71,31 @@  discard block
 block discarded – undo
71 71
 					// the post already contains the related EE_Venue object AND one of the following is TRUE:
72 72
 					// the requested Venue ID matches the post ID OR...
73 73
 					// there was no specific Venue ID requested
74
-					if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
74
+					if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) {
75 75
 						// use existing related EE_Venue object
76
-						EEH_Venue_View::$_venue =  $post->EE_Venue;
77
-					} else if ( $VNU_ID ) {
76
+						EEH_Venue_View::$_venue = $post->EE_Venue;
77
+					} else if ($VNU_ID) {
78 78
 						// there WAS a specific Venue ID requested, but it's NOT the current post object
79
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
79
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
80 80
 					} else {
81 81
 						// no specific Venue ID requested, so use post ID to generate EE_Venue object
82
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID );
82
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
83 83
 					}
84 84
 				break;
85 85
 
86 86
 				case 'espresso_events':
87
-					if ( $look_in_event ) {
87
+					if ($look_in_event) {
88 88
 						// grab the events related venues
89 89
 						$venues = EEH_Venue_View::get_event_venues();
90 90
 						// make sure the result is an array
91
-						$venues = is_array( $venues ) ? $venues : array();
91
+						$venues = is_array($venues) ? $venues : array();
92 92
 						// do we have an ID for a specific venue?
93
-						if ( $VNU_ID ) {
93
+						if ($VNU_ID) {
94 94
 							// loop thru the related venues
95
-							foreach( $venues as $venue ) {
96
-								if ( $venue instanceof EE_Venue ) {
95
+							foreach ($venues as $venue) {
96
+								if ($venue instanceof EE_Venue) {
97 97
 									// until we find the venue we're looking for
98
-									if ( $venue->ID() == $VNU_ID ) {
98
+									if ($venue->ID() == $VNU_ID) {
99 99
 										EEH_Venue_View::$_venue = $venue;
100 100
 										break;
101 101
 									}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 						// then the global post is an events post and this function was called with no argument
106 106
 						} else {
107 107
 							// just grab the first related event venue
108
-							EEH_Venue_View::$_venue = reset( $venues );
108
+							EEH_Venue_View::$_venue = reset($venues);
109 109
 						}
110 110
 					}
111 111
 				break;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 			}
114 114
 		}
115 115
 		// now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
116
-		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
116
+		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
117 117
 			// sigh... pull it from the db
118
-			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
118
+			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
119 119
 		}
120
-		return EEH_Venue_View::_get_venue( $privacy_check, $password_check );
120
+		return EEH_Venue_View::_get_venue($privacy_check, $password_check);
121 121
 	}
122 122
 
123 123
 
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 * @param bool $password_check
131 131
 	 * @return 	EE_Venue
132 132
 	 */
133
-	protected static function _get_venue( $privacy_check = true, $password_check = true ) {
133
+	protected static function _get_venue($privacy_check = true, $password_check = true) {
134 134
 		// check for private venues.
135 135
 		if (
136 136
 			EEH_Venue_View::$_venue instanceof EE_Venue
137 137
 			&& EEH_Venue_View::$_venue->status() == 'private'
138 138
 			&& $privacy_check
139
-			&& ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' )
139
+			&& ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')
140 140
 		) {
141 141
 			return null;
142 142
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if (
145 145
 			EEH_Venue_View::$_venue instanceof EE_Venue
146 146
 			&& $password_check
147
-			&& post_password_required( EEH_Venue_View::$_venue->ID() )
147
+			&& post_password_required(EEH_Venue_View::$_venue->ID())
148 148
 		) {
149 149
 			return null;
150 150
 		}
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public static function get_event_venues() {
163 163
 		global $post;
164
-		if ( $post->post_type == 'espresso_events' ) {
165
-			if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) {
164
+		if ($post->post_type == 'espresso_events') {
165
+			if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
166 166
 				return $post->EE_Event->venues();
167 167
 			}
168 168
 		}
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return bool|null
184 184
 	 */
185
-	public static function is_venue_private( $VNU_ID = false ) {
186
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true );
187
-		if ( ! $venue instanceof EE_Venue ) {
185
+	public static function is_venue_private($VNU_ID = false) {
186
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
187
+		if ( ! $venue instanceof EE_Venue) {
188 188
 			return null;
189 189
 		}
190 190
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
200 200
 	 * @return bool
201 201
 	 */
202
-	public static function is_venue_password_protected( $VNU_ID = false ) {
203
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
202
+	public static function is_venue_password_protected($VNU_ID = false) {
203
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
204 204
 		if (
205 205
 			$venue instanceof EE_Venue
206
-			&& post_password_required( $venue->ID() )
206
+			&& post_password_required($venue->ID())
207 207
 		) {
208 208
 			return true;
209 209
 		}
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string
222 222
 	 */
223
-	public static function password_protected_venue_form( $VNU_ID = false ) {
224
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
223
+	public static function password_protected_venue_form($VNU_ID = false) {
224
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
225 225
 		if (
226 226
 			$venue instanceof EE_Venue
227
-			&& post_password_required( $venue->ID() )
227
+			&& post_password_required($venue->ID())
228 228
 		) {
229
-			return get_the_password_form( $venue->ID() );
229
+			return get_the_password_form($venue->ID());
230 230
 		}
231 231
 		return '';
232 232
 	}
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 * @param int $VNU_ID
241 241
 	 * @return string
242 242
 	 */
243
-	public static function venue_description( $VNU_ID = 0 ) {
244
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
245
-		if ( $venue instanceof EE_Venue ) {
243
+	public static function venue_description($VNU_ID = 0) {
244
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
245
+		if ($venue instanceof EE_Venue) {
246 246
 			return$venue->description();
247 247
 		}
248 248
 		return '';
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 	 * @param int $VNU_ID
258 258
 	 * @return string
259 259
 	 */
260
-	public static function venue_excerpt( $VNU_ID = 0 ) {
261
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
262
-		if ( $venue instanceof EE_Venue ) {
260
+	public static function venue_excerpt($VNU_ID = 0) {
261
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
262
+		if ($venue instanceof EE_Venue) {
263 263
 			$excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description();
264
-			$venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '&hellip;' );
265
-			return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : '';
264
+			$venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'&hellip;');
265
+			return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : '';
266 266
 		}
267 267
 		return '';
268 268
 	}
@@ -277,22 +277,22 @@  discard block
 block discarded – undo
277 277
 	 * @param bool $hide_uncategorized
278 278
 	 * @return string
279 279
 	 */
280
-	public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) {
280
+	public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) {
281 281
 		$category_links = array();
282
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
283
-		if ( $venue instanceof EE_Venue ) {
282
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
283
+		if ($venue instanceof EE_Venue) {
284 284
 			// get category terms
285
-			if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) {
285
+			if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
286 286
 				// loop thru terms and create links
287
-				foreach ( $venue_categories as $term ) {
288
-					$url = get_term_link( $term, 'espresso_venue_categories' );
289
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
290
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> ';
287
+				foreach ($venue_categories as $term) {
288
+					$url = get_term_link($term, 'espresso_venue_categories');
289
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
290
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> ';
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 		}
295
-		return implode( ', ', $category_links );
295
+		return implode(', ', $category_links);
296 296
 	}
297 297
 
298 298
 
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * @param bool $add_wrapper
308 308
 	 * @return string
309 309
 	 */
310
-	public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) {
311
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
312
-		if ( $venue instanceof EE_Venue ) {
313
-			return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper );
310
+	public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) {
311
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
312
+		if ($venue instanceof EE_Venue) {
313
+			return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
314 314
 		}
315 315
 		return '';
316 316
 	}
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param int $VNU_ID
325 325
 	 * @return bool|string
326 326
 	 */
327
-	public static function venue_has_address( $VNU_ID = 0 ) {
328
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
329
-		if ( $venue instanceof EE_Venue ) {
330
-			return EEH_Address::format( $venue, 'inline', FALSE, FALSE );
327
+	public static function venue_has_address($VNU_ID = 0) {
328
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
329
+		if ($venue instanceof EE_Venue) {
330
+			return EEH_Address::format($venue, 'inline', FALSE, FALSE);
331 331
 		}
332 332
 		return false;
333 333
 	}
@@ -342,30 +342,30 @@  discard block
 block discarded – undo
342 342
 	 * @param int $VNU_ID
343 343
 	 * @return string
344 344
 	 */
345
-	public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) {
346
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
347
-		if ( $venue instanceof EE_Venue ) {
345
+	public static function venue_name($link_to = 'details', $VNU_ID = 0) {
346
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
347
+		if ($venue instanceof EE_Venue) {
348 348
 			$venue_name = apply_filters(
349 349
 				'FHEE__EEH_Venue__venue_name__append_private_venue_name',
350 350
 				EEH_Venue_View::is_venue_private()
351
-					? EEH_Venue_View::$_venue->name() . "&nbsp;" . __( '(Private)', 'event_espresso' )
351
+					? EEH_Venue_View::$_venue->name()."&nbsp;".__('(Private)', 'event_espresso')
352 352
 					: EEH_Venue_View::$_venue->name(),
353 353
 				EEH_Venue_View::$_venue
354 354
 			);
355
-			$venue_name = EEH_Schema::name( $venue_name );
355
+			$venue_name = EEH_Schema::name($venue_name);
356 356
 
357 357
 			//if venue is trashed then ignore the "link to" setting because the venue is trashed.
358
-			if ( $venue->get('status') == 'trash' ) {
358
+			if ($venue->get('status') == 'trash') {
359 359
 				$link_to = '';
360 360
 			}
361
-			switch( $link_to ) {
361
+			switch ($link_to) {
362 362
 
363 363
 				case 'details' :
364
-					return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name );
364
+					return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
365 365
 				break;
366 366
 
367 367
 				case 'website' :
368
-					return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name );
368
+					return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
369 369
 				break;
370 370
 
371 371
 				default :
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 	 * @param    string $text
386 386
 	 * @return string
387 387
 	 */
388
-	public static function venue_details_link( $VNU_ID = 0, $text = '' ) {
389
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
390
-		if ( $venue instanceof EE_Venue ) {
391
-			return EEH_Schema::url( get_permalink( $venue->ID() ), $text );
388
+	public static function venue_details_link($VNU_ID = 0, $text = '') {
389
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
390
+		if ($venue instanceof EE_Venue) {
391
+			return EEH_Schema::url(get_permalink($venue->ID()), $text);
392 392
 		}
393 393
 		return '';
394 394
 	}
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 	 * @param    string $text
404 404
 	 * @return string
405 405
 	 */
406
-	public static function venue_website_link( $VNU_ID = 0, $text = '' ) {
407
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
408
-		if ( $venue instanceof EE_Venue ) {
406
+	public static function venue_website_link($VNU_ID = 0, $text = '') {
407
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
408
+		if ($venue instanceof EE_Venue) {
409 409
 			$url = $venue->venue_url();
410
-			$text = ! empty( $text ) ? $text : $url;
411
-			return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : '';
410
+			$text = ! empty($text) ? $text : $url;
411
+			return ! empty($url) ? EEH_Schema::url($url, $text) : '';
412 412
 		}
413 413
 		return '';
414 414
 	}
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 	 * @param int $VNU_ID
423 423
 	 * @return string
424 424
 	 */
425
-	public static function venue_phone( $VNU_ID = 0) {
426
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
427
-		if ( $venue instanceof EE_Venue ) {
428
-			return EEH_Schema::telephone( $venue->phone() );
425
+	public static function venue_phone($VNU_ID = 0) {
426
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
427
+		if ($venue instanceof EE_Venue) {
428
+			return EEH_Schema::telephone($venue->phone());
429 429
 		}
430 430
 		return '';
431 431
 	}
@@ -441,48 +441,48 @@  discard block
 block discarded – undo
441 441
 	 * @param    array $gmap map options
442 442
 	 * @return string
443 443
 	 */
444
-	public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) {
444
+	public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) {
445 445
 
446
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
447
-		if ( $venue instanceof EE_Venue ) {
446
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
447
+		if ($venue instanceof EE_Venue) {
448 448
 			// check for global espresso_events post and use it's ID if no map_ID is set
449 449
 			global $post;
450
-			$map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
450
+			$map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
451 451
 			// grab map settings
452 452
 			$map_cfg = EE_Registry::instance()->CFG->map_settings;
453 453
 			// are maps enabled ?
454
-			if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) {
454
+			if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
455 455
 
456 456
 				$details_page = is_single();
457 457
 				$options = array();
458
-				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
458
+				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
459 459
 
460
-				$options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE );
460
+				$options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE);
461 461
 
462 462
 				$options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
463
-				$options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width'];
463
+				$options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
464 464
 
465 465
 				$options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
466
-				$options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height'];
466
+				$options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
467 467
 
468 468
 				$options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
469
-				$options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
469
+				$options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
470 470
 
471 471
 				$options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
472
-				$options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];;
472
+				$options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ;
473 473
 
474 474
 				$options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
475
-				$options['ee_map_nav_size'] =  isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
475
+				$options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
476 476
 
477 477
 				$options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
478
-				$options['ee_map_type_control'] =  isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
478
+				$options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
479 479
 
480 480
 				$options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
481
-				$options['ee_map_align'] =  isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align'];
481
+				$options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align'];
482 482
 
483
-				$options['ee_static_url'] =  isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link();
483
+				$options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
484 484
 
485
-				return EEH_Maps::google_map( $options );
485
+				return EEH_Maps::google_map($options);
486 486
 
487 487
 			}
488 488
 		}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 * @param array $atts like EEH_Maps::google_map_link
498 498
 	 * @return string
499 499
 	 */
500
-	public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){
500
+	public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) {
501 501
 		$state = $venue->state_obj();
502 502
 		$country = $venue->country_obj();
503 503
 		$atts = shortcode_atts(
@@ -528,23 +528,23 @@  discard block
 block discarded – undo
528 528
 	 * @param string $after
529 529
 	 * @return string
530 530
 	 */
531
-	public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) {
532
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
533
-		if ( $venue instanceof EE_Venue ) {
531
+	public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') {
532
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
533
+		if ($venue instanceof EE_Venue) {
534 534
 			// can the user edit this post ?
535
-			if ( current_user_can( 'edit_post', $venue->ID() )) {
535
+			if (current_user_can('edit_post', $venue->ID())) {
536 536
 				// set link text
537
-				$link = ! empty( $link ) ? $link : __('edit this venue');
537
+				$link = ! empty($link) ? $link : __('edit this venue');
538 538
 				// generate nonce
539
-				$nonce = wp_create_nonce( 'edit_nonce' );
539
+				$nonce = wp_create_nonce('edit_nonce');
540 540
 				// generate url to venue editor for this venue
541
-				$url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) );
541
+				$url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php'));
542 542
 				// get edit CPT text
543
-				$post_type_obj = get_post_type_object( 'espresso_venues' );
543
+				$post_type_obj = get_post_type_object('espresso_venues');
544 544
 				// build final link html
545
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
545
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
546 546
 				// put it all together
547
-				return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after;
547
+				return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after;
548 548
 			}
549 549
 		}
550 550
 		return '';
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -38,216 +38,216 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        '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.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'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.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            '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.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'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.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.58.rc.006');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.58.rc.006');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118
-        /**
119
-         *    espresso_load_error_handling
120
-         *    this function loads EE's class for handling exceptions and errors
121
-         */
122
-        function espresso_load_error_handling()
123
-        {
124
-            static $error_handling_loaded = false;
125
-            if ($error_handling_loaded) {
126
-                return;
127
-            }
128
-            // load debugging tools
129
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
130
-                require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
131
-                \EEH_Debug_Tools::instance();
132
-            }
133
-            // load error handling
134
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
135
-                require_once EE_CORE . 'EE_Error.core.php';
136
-            } else {
137
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
138
-            }
139
-            $error_handling_loaded = true;
140
-        }
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118
+		/**
119
+		 *    espresso_load_error_handling
120
+		 *    this function loads EE's class for handling exceptions and errors
121
+		 */
122
+		function espresso_load_error_handling()
123
+		{
124
+			static $error_handling_loaded = false;
125
+			if ($error_handling_loaded) {
126
+				return;
127
+			}
128
+			// load debugging tools
129
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
130
+				require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
131
+				\EEH_Debug_Tools::instance();
132
+			}
133
+			// load error handling
134
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
135
+				require_once EE_CORE . 'EE_Error.core.php';
136
+			} else {
137
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
138
+			}
139
+			$error_handling_loaded = true;
140
+		}
141 141
 
142
-        /**
143
-         *    espresso_load_required
144
-         *    given a class name and path, this function will load that file or throw an exception
145
-         *
146
-         * @param    string $classname
147
-         * @param    string $full_path_to_file
148
-         * @throws    EE_Error
149
-         */
150
-        function espresso_load_required($classname, $full_path_to_file)
151
-        {
152
-            if (is_readable($full_path_to_file)) {
153
-                require_once $full_path_to_file;
154
-            } else {
155
-                throw new \EE_Error (
156
-                    sprintf(
157
-                        esc_html__(
158
-                            'The %s class file could not be located or is not readable due to file permissions.',
159
-                            'event_espresso'
160
-                        ),
161
-                        $classname
162
-                    )
163
-                );
164
-            }
165
-        }
142
+		/**
143
+		 *    espresso_load_required
144
+		 *    given a class name and path, this function will load that file or throw an exception
145
+		 *
146
+		 * @param    string $classname
147
+		 * @param    string $full_path_to_file
148
+		 * @throws    EE_Error
149
+		 */
150
+		function espresso_load_required($classname, $full_path_to_file)
151
+		{
152
+			if (is_readable($full_path_to_file)) {
153
+				require_once $full_path_to_file;
154
+			} else {
155
+				throw new \EE_Error (
156
+					sprintf(
157
+						esc_html__(
158
+							'The %s class file could not be located or is not readable due to file permissions.',
159
+							'event_espresso'
160
+						),
161
+						$classname
162
+					)
163
+				);
164
+			}
165
+		}
166 166
 
167
-        /**
168
-         * @since 4.9.27
169
-         * @throws \EE_Error
170
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
171
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
172
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
173
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
174
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
175
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
177
-         * @throws \OutOfBoundsException
178
-         */
179
-        function bootstrap_espresso()
180
-        {
181
-            require_once __DIR__ . '/core/espresso_definitions.php';
182
-            try {
183
-                espresso_load_error_handling();
184
-                espresso_load_required(
185
-                    'EEH_Base',
186
-                    EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
187
-                );
188
-                espresso_load_required(
189
-                    'EEH_File',
190
-                    EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
191
-                );
192
-                espresso_load_required(
193
-                    'EEH_File',
194
-                    EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
195
-                );
196
-                espresso_load_required(
197
-                    'EEH_Array',
198
-                    EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
199
-                );
200
-                // instantiate and configure PSR4 autoloader
201
-                espresso_load_required(
202
-                    'Psr4Autoloader',
203
-                    EE_CORE . 'Psr4Autoloader.php'
204
-                );
205
-                espresso_load_required(
206
-                    'EE_Psr4AutoloaderInit',
207
-                    EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
208
-                );
209
-                $AutoloaderInit = new EE_Psr4AutoloaderInit();
210
-                $AutoloaderInit->initializeAutoloader();
211
-                espresso_load_required(
212
-                    'EE_Request',
213
-                    EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
214
-                );
215
-                espresso_load_required(
216
-                    'EE_Response',
217
-                    EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
218
-                );
219
-                espresso_load_required(
220
-                    'EE_Bootstrap',
221
-                    EE_CORE . 'EE_Bootstrap.core.php'
222
-                );
223
-                // bootstrap EE and the request stack
224
-                new EE_Bootstrap(
225
-                    new EE_Request($_GET, $_POST, $_COOKIE),
226
-                    new EE_Response()
227
-                );
228
-            } catch (Exception $e) {
229
-                require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
230
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
231
-            }
232
-        }
233
-        bootstrap_espresso();
234
-    }
167
+		/**
168
+		 * @since 4.9.27
169
+		 * @throws \EE_Error
170
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
171
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
175
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
177
+		 * @throws \OutOfBoundsException
178
+		 */
179
+		function bootstrap_espresso()
180
+		{
181
+			require_once __DIR__ . '/core/espresso_definitions.php';
182
+			try {
183
+				espresso_load_error_handling();
184
+				espresso_load_required(
185
+					'EEH_Base',
186
+					EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
187
+				);
188
+				espresso_load_required(
189
+					'EEH_File',
190
+					EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
191
+				);
192
+				espresso_load_required(
193
+					'EEH_File',
194
+					EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
195
+				);
196
+				espresso_load_required(
197
+					'EEH_Array',
198
+					EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
199
+				);
200
+				// instantiate and configure PSR4 autoloader
201
+				espresso_load_required(
202
+					'Psr4Autoloader',
203
+					EE_CORE . 'Psr4Autoloader.php'
204
+				);
205
+				espresso_load_required(
206
+					'EE_Psr4AutoloaderInit',
207
+					EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
208
+				);
209
+				$AutoloaderInit = new EE_Psr4AutoloaderInit();
210
+				$AutoloaderInit->initializeAutoloader();
211
+				espresso_load_required(
212
+					'EE_Request',
213
+					EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
214
+				);
215
+				espresso_load_required(
216
+					'EE_Response',
217
+					EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
218
+				);
219
+				espresso_load_required(
220
+					'EE_Bootstrap',
221
+					EE_CORE . 'EE_Bootstrap.core.php'
222
+				);
223
+				// bootstrap EE and the request stack
224
+				new EE_Bootstrap(
225
+					new EE_Request($_GET, $_POST, $_COOKIE),
226
+					new EE_Response()
227
+				);
228
+			} catch (Exception $e) {
229
+				require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
230
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
231
+			}
232
+		}
233
+		bootstrap_espresso();
234
+	}
235 235
 }
236 236
 if (! function_exists('espresso_deactivate_plugin')) {
237
-    /**
238
-     *    deactivate_plugin
239
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
240
-     *
241
-     * @access public
242
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
243
-     * @return    void
244
-     */
245
-    function espresso_deactivate_plugin($plugin_basename = '')
246
-    {
247
-        if (! function_exists('deactivate_plugins')) {
248
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
249
-        }
250
-        unset($_GET['activate'], $_REQUEST['activate']);
251
-        deactivate_plugins($plugin_basename);
252
-    }
237
+	/**
238
+	 *    deactivate_plugin
239
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
240
+	 *
241
+	 * @access public
242
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
243
+	 * @return    void
244
+	 */
245
+	function espresso_deactivate_plugin($plugin_basename = '')
246
+	{
247
+		if (! function_exists('deactivate_plugins')) {
248
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
249
+		}
250
+		unset($_GET['activate'], $_REQUEST['activate']);
251
+		deactivate_plugins($plugin_basename);
252
+	}
253 253
 }
Please login to merge, or discard this patch.