Completed
Pull Request — master (#1136)
by Darren
70:11 queued 43:12
created
public/Espresso_Arabica_2014/content-espresso_events-venues.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,8 +40,11 @@  discard block
 block discarded – undo
40 40
 		<?php echo do_shortcode( $venue_description ); ?>
41 41
 	</p>
42 42
 		<?php endif;  ?>
43
-	<?php else : ?>
44
-		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?>
43
+	<?php else {
44
+	: ?>
45
+		<?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE );
46
+}
47
+?>
45 48
 		<?php if ( $venue_excerpt ) : ?>
46 49
 	<p>
47 50
 		<strong><?php _e( 'Description:', 'event_espresso' ); ?></strong><br/>
@@ -53,12 +56,15 @@  discard block
 block discarded – undo
53 56
 <!-- .espresso-venue-dv -->
54 57
 <?php
55 58
 do_action( 'AHEE_event_details_after_venue_details', $post );
56
-else :
59
+else {
60
+	:
57 61
 	if ( espresso_venue_is_password_protected() ) :
58 62
 ?>
59 63
 	<div class="espresso-venue-dv  espresso-password-protected-venue-dv" >
60 64
 		<h3 class="event-venues-h3 ee-event-h3">
61
-			<?php _e( 'Location', 'event_espresso' );?>
65
+			<?php _e( 'Location', 'event_espresso' );
66
+}
67
+?>
62 68
 		</h3>
63 69
 		<?php echo espresso_password_protected_venue_form(); ?>
64 70
 	</div>
Please login to merge, or discard this 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/domain/services/capabilities/PublicCapabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function capability()
27
-    {
28
-        return '';
29
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function capability()
27
+	{
28
+		return '';
29
+	}
30 30
 
31 31
 
32 32
 }
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/invoice_functions.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
  * @param $class_file
9 9
  * @return array
10 10
  */
11
-function espresso_invoice_template_files( $class_file) {
11
+function espresso_invoice_template_files($class_file) {
12 12
 	// read our template dir and build an array of files
13
-	$dhandle = opendir(dirname($class_file) . '/lib/templates/css/'); //If the template files have been moved to the uploads folder
13
+	$dhandle = opendir(dirname($class_file).'/lib/templates/css/'); //If the template files have been moved to the uploads folder
14 14
 	//} else return FALSE;
15 15
 
16 16
 	$files = array();
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
  * @param string $selected
51 51
  * @return string
52 52
  */
53
-function espresso_invoice_is_selected( $input_item, $selected='') {
54
-	if ( $input_item === $selected ) {
53
+function espresso_invoice_is_selected($input_item, $selected = '') {
54
+	if ($input_item === $selected) {
55 55
 		return 'selected="selected"';
56 56
 	} else {
57 57
 		return '';
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@
 block discarded – undo
418 418
      * In this case, we delete the temporary file
419 419
      *
420 420
      * @param JobParameters $job_parameters
421
-     * @return boolean
421
+     * @return JobStepResponse
422 422
      */
423 423
     public function cleanup_job(JobParameters $job_parameters)
424 424
     {
Please login to merge, or discard this patch.
Indentation   +504 added lines, -504 removed lines patch added patch discarded remove patch
@@ -31,524 +31,524 @@
 block discarded – undo
31 31
  */
32 32
 class RegistrationsReport extends JobHandlerFile
33 33
 {
34
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
36
-    /**
37
-     * Performs any necessary setup for starting the job. This is also a good
38
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
39
-     * when continue_job will be called
40
-     *
41
-     * @param JobParameters $job_parameters
42
-     * @throws BatchRequestException
43
-     * @return JobStepResponse
44
-     */
45
-    public function create_job(JobParameters $job_parameters)
46
-    {
47
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
48
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
49
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
50
-        }
51
-        $filepath = $this->create_file_from_job_with_name(
52
-            $job_parameters->job_id(),
53
-            $this->get_filename($event_id)
54
-        );
55
-        $job_parameters->add_extra_data('filepath', $filepath);
56
-        if ($job_parameters->request_datum('use_filters', false)) {
57
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
58
-        } else {
59
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
60
-                array(
61
-                    'OR'                 => array(
62
-                        // don't include registrations from failed or abandoned transactions...
63
-                        'Transaction.STS_ID' => array(
64
-                            'NOT IN',
65
-                            array(
66
-                                EEM_Transaction::failed_status_code,
67
-                                EEM_Transaction::abandoned_status_code,
68
-                            ),
69
-                        ),
70
-                        // unless the registration is approved, in which case include it regardless of transaction status
71
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
72
-                    ),
73
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
74
-                ),
75
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
76
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
77
-                'caps'       => \EEM_Base::caps_read_admin,
78
-            ), $event_id);
79
-            if ($event_id) {
80
-                $query_params[0]['EVT_ID'] = $event_id;
81
-            } else {
82
-                $query_params['force_join'][] = 'Event';
83
-            }
84
-        }
85
-        if (! isset($query_params['force_join'])) {
86
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
87
-        }
88
-        $job_parameters->add_extra_data('query_params', $query_params);
89
-        $question_labels = $this->_get_question_labels($query_params);
90
-        $job_parameters->add_extra_data('question_labels', $question_labels);
91
-        $job_parameters->set_job_size(
92
-            \EEM_Registration::instance()->count(
93
-                array_diff_key(
94
-                    $query_params,
95
-                    array_flip(
96
-                        array('limit')
97
-                    )
98
-                )
99
-            )
100
-        );
101
-        // we should also set the header columns
102
-        $csv_data_for_row = $this->get_csv_data_for(
103
-            $event_id,
104
-            0,
105
-            1,
106
-            $job_parameters->extra_datum('question_labels'),
107
-            $job_parameters->extra_datum('query_params')
108
-        );
109
-        EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
110
-        // if we actually processed a row there, record it
111
-        if ($job_parameters->job_size()) {
112
-            $job_parameters->mark_processed(1);
113
-        }
114
-        return new JobStepResponse(
115
-            $job_parameters,
116
-            __('Registrations report started successfully...', 'event_espresso')
117
-        );
118
-    }
34
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
36
+	/**
37
+	 * Performs any necessary setup for starting the job. This is also a good
38
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
39
+	 * when continue_job will be called
40
+	 *
41
+	 * @param JobParameters $job_parameters
42
+	 * @throws BatchRequestException
43
+	 * @return JobStepResponse
44
+	 */
45
+	public function create_job(JobParameters $job_parameters)
46
+	{
47
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
48
+		if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
49
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
50
+		}
51
+		$filepath = $this->create_file_from_job_with_name(
52
+			$job_parameters->job_id(),
53
+			$this->get_filename($event_id)
54
+		);
55
+		$job_parameters->add_extra_data('filepath', $filepath);
56
+		if ($job_parameters->request_datum('use_filters', false)) {
57
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
58
+		} else {
59
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
60
+				array(
61
+					'OR'                 => array(
62
+						// don't include registrations from failed or abandoned transactions...
63
+						'Transaction.STS_ID' => array(
64
+							'NOT IN',
65
+							array(
66
+								EEM_Transaction::failed_status_code,
67
+								EEM_Transaction::abandoned_status_code,
68
+							),
69
+						),
70
+						// unless the registration is approved, in which case include it regardless of transaction status
71
+						'STS_ID'             => \EEM_Registration::status_id_approved,
72
+					),
73
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
74
+				),
75
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
76
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
77
+				'caps'       => \EEM_Base::caps_read_admin,
78
+			), $event_id);
79
+			if ($event_id) {
80
+				$query_params[0]['EVT_ID'] = $event_id;
81
+			} else {
82
+				$query_params['force_join'][] = 'Event';
83
+			}
84
+		}
85
+		if (! isset($query_params['force_join'])) {
86
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
87
+		}
88
+		$job_parameters->add_extra_data('query_params', $query_params);
89
+		$question_labels = $this->_get_question_labels($query_params);
90
+		$job_parameters->add_extra_data('question_labels', $question_labels);
91
+		$job_parameters->set_job_size(
92
+			\EEM_Registration::instance()->count(
93
+				array_diff_key(
94
+					$query_params,
95
+					array_flip(
96
+						array('limit')
97
+					)
98
+				)
99
+			)
100
+		);
101
+		// we should also set the header columns
102
+		$csv_data_for_row = $this->get_csv_data_for(
103
+			$event_id,
104
+			0,
105
+			1,
106
+			$job_parameters->extra_datum('question_labels'),
107
+			$job_parameters->extra_datum('query_params')
108
+		);
109
+		EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
110
+		// if we actually processed a row there, record it
111
+		if ($job_parameters->job_size()) {
112
+			$job_parameters->mark_processed(1);
113
+		}
114
+		return new JobStepResponse(
115
+			$job_parameters,
116
+			__('Registrations report started successfully...', 'event_espresso')
117
+		);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Gets the filename
123
-     *
124
-     * @return string
125
-     */
126
-    protected function get_filename()
127
-    {
128
-        return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
129
-    }
121
+	/**
122
+	 * Gets the filename
123
+	 *
124
+	 * @return string
125
+	 */
126
+	protected function get_filename()
127
+	{
128
+		return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * Gets the questions which are to be used for this report, so they
134
-     * can be remembered for later
135
-     *
136
-     * @param array $registration_query_params
137
-     * @return array question admin labels to be used for this report
138
-     */
139
-    protected function _get_question_labels($registration_query_params)
140
-    {
141
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
142
-        $question_query_params = array();
143
-        if ($where !== null) {
144
-            $question_query_params = array(
145
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
146
-            );
147
-        }
148
-        $question_query_params[0]['QST_system'] = array(
149
-            'NOT_IN',
150
-            array_keys(EEM_Attendee::instance()->system_question_to_attendee_field_mapping()),
151
-        );
152
-        if (apply_filters(
153
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
154
-            false,
155
-            $registration_query_params
156
-        )) {
157
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
158
-        }
159
-        $question_query_params['group_by'] = array('QST_ID');
160
-        return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
161
-    }
132
+	/**
133
+	 * Gets the questions which are to be used for this report, so they
134
+	 * can be remembered for later
135
+	 *
136
+	 * @param array $registration_query_params
137
+	 * @return array question admin labels to be used for this report
138
+	 */
139
+	protected function _get_question_labels($registration_query_params)
140
+	{
141
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
142
+		$question_query_params = array();
143
+		if ($where !== null) {
144
+			$question_query_params = array(
145
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
146
+			);
147
+		}
148
+		$question_query_params[0]['QST_system'] = array(
149
+			'NOT_IN',
150
+			array_keys(EEM_Attendee::instance()->system_question_to_attendee_field_mapping()),
151
+		);
152
+		if (apply_filters(
153
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
154
+			false,
155
+			$registration_query_params
156
+		)) {
157
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
158
+		}
159
+		$question_query_params['group_by'] = array('QST_ID');
160
+		return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * Takes where params meant for registrations and changes them to work for questions
166
-     *
167
-     * @param array $reg_where_params
168
-     * @return array
169
-     */
170
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
171
-    {
172
-        $question_where_params = array();
173
-        foreach ($reg_where_params as $key => $val) {
174
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
175
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
176
-            } else {
177
-                // it's a normal where condition
178
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
179
-            }
180
-        }
181
-        return $question_where_params;
182
-    }
164
+	/**
165
+	 * Takes where params meant for registrations and changes them to work for questions
166
+	 *
167
+	 * @param array $reg_where_params
168
+	 * @return array
169
+	 */
170
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
171
+	{
172
+		$question_where_params = array();
173
+		foreach ($reg_where_params as $key => $val) {
174
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
175
+				$question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
176
+			} else {
177
+				// it's a normal where condition
178
+				$question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
179
+			}
180
+		}
181
+		return $question_where_params;
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * Performs another step of the job
187
-     *
188
-     * @param JobParameters $job_parameters
189
-     * @param int           $batch_size
190
-     * @return JobStepResponse
191
-     * @throws \EE_Error
192
-     */
193
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
194
-    {
195
-        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
196
-            $csv_data = $this->get_csv_data_for(
197
-                $job_parameters->request_datum('EVT_ID', '0'),
198
-                $job_parameters->units_processed(),
199
-                $batch_size,
200
-                $job_parameters->extra_datum('question_labels'),
201
-                $job_parameters->extra_datum('query_params')
202
-            );
203
-            EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
204
-            $units_processed = count($csv_data);
205
-        } else {
206
-            $csv_data = array();
207
-            $units_processed = 0;
208
-        }
209
-        $job_parameters->mark_processed($units_processed);
210
-        $extra_response_data = array(
211
-            'file_url' => '',
212
-        );
213
-        if ($units_processed < $batch_size) {
214
-            $job_parameters->set_status(JobParameters::status_complete);
215
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
216
-        }
185
+	/**
186
+	 * Performs another step of the job
187
+	 *
188
+	 * @param JobParameters $job_parameters
189
+	 * @param int           $batch_size
190
+	 * @return JobStepResponse
191
+	 * @throws \EE_Error
192
+	 */
193
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
194
+	{
195
+		if ($job_parameters->units_processed() < $job_parameters->job_size()) {
196
+			$csv_data = $this->get_csv_data_for(
197
+				$job_parameters->request_datum('EVT_ID', '0'),
198
+				$job_parameters->units_processed(),
199
+				$batch_size,
200
+				$job_parameters->extra_datum('question_labels'),
201
+				$job_parameters->extra_datum('query_params')
202
+			);
203
+			EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
204
+			$units_processed = count($csv_data);
205
+		} else {
206
+			$csv_data = array();
207
+			$units_processed = 0;
208
+		}
209
+		$job_parameters->mark_processed($units_processed);
210
+		$extra_response_data = array(
211
+			'file_url' => '',
212
+		);
213
+		if ($units_processed < $batch_size) {
214
+			$job_parameters->set_status(JobParameters::status_complete);
215
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
216
+		}
217 217
 
218
-        return new JobStepResponse(
219
-            $job_parameters,
220
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
221
-            $extra_response_data
222
-        );
223
-    }
218
+		return new JobStepResponse(
219
+			$job_parameters,
220
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
221
+			$extra_response_data
222
+		);
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * Gets the csv data for a batch of registrations
228
-     *
229
-     * @param int|null $event_id
230
-     * @param int $offset
231
-     * @param int $limit
232
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
233
-     * @param array $query_params for using where querying the model
234
-     * @return array top-level keys are numeric, next-level keys are column headers
235
-     * @throws \EE_Error
236
-     */
237
-    public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
238
-    {
239
-        $reg_fields_to_include = array(
240
-            'TXN_ID',
241
-            'ATT_ID',
242
-            'REG_ID',
243
-            'REG_date',
244
-            'REG_code',
245
-            'REG_count',
246
-            'REG_final_price',
247
-        );
248
-        $att_fields_to_include = array(
249
-            'ATT_fname',
250
-            'ATT_lname',
251
-            'ATT_email',
252
-            'ATT_address',
253
-            'ATT_address2',
254
-            'ATT_city',
255
-            'STA_ID',
256
-            'CNT_ISO',
257
-            'ATT_zip',
258
-            'ATT_phone',
259
-        );
260
-        $registrations_csv_ready_array = array();
261
-        $reg_model = EE_Registry::instance()->load_model('Registration');
262
-        $query_params['limit'] = array($offset, $limit);
263
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
264
-        $registration_ids = array();
265
-        foreach ($registration_rows as $reg_row) {
266
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
267
-        }
268
-        foreach ($registration_rows as $reg_row) {
269
-            if (is_array($reg_row)) {
270
-                $reg_csv_array = array();
271
-                if (! $event_id) {
272
-                    // get the event's name and Id
273
-                    $reg_csv_array[ (string) __('Event', 'event_espresso') ] = sprintf(
274
-                        /* translators: 1: event name, 2: event ID */
275
-                        __('%1$s (%2$s)', 'event_espresso'),
276
-                        EEH_Export::prepare_value_from_db_for_display(
277
-                            EEM_Event::instance(),
278
-                            'EVT_name',
279
-                            $reg_row['Event_CPT.post_title']
280
-                        ),
281
-                        $reg_row['Event_CPT.ID']
282
-                    );
283
-                }
284
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
285
-                /*@var $reg_row EE_Registration */
286
-                foreach ($reg_fields_to_include as $field_name) {
287
-                    $field = $reg_model->field_settings_for($field_name);
288
-                    if ($field_name == 'REG_final_price') {
289
-                        $value = EEH_Export::prepare_value_from_db_for_display(
290
-                            $reg_model,
291
-                            $field_name,
292
-                            $reg_row['Registration.REG_final_price'],
293
-                            'localized_float'
294
-                        );
295
-                    } elseif ($field_name == 'REG_count') {
296
-                        $value = sprintf(
297
-                            /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */
298
-                            __('%1$s of %2$s', 'event_espresso'),
299
-                            EEH_Export::prepare_value_from_db_for_display(
300
-                                $reg_model,
301
-                                'REG_count',
302
-                                $reg_row['Registration.REG_count']
303
-                            ),
304
-                            EEH_Export::prepare_value_from_db_for_display(
305
-                                $reg_model,
306
-                                'REG_group_size',
307
-                                $reg_row['Registration.REG_group_size']
308
-                            )
309
-                        );
310
-                    } elseif ($field_name == 'REG_date') {
311
-                        $value = EEH_Export::prepare_value_from_db_for_display(
312
-                            $reg_model,
313
-                            $field_name,
314
-                            $reg_row['Registration.REG_date'],
315
-                            'no_html'
316
-                        );
317
-                    } else {
318
-                        $value = EEH_Export::prepare_value_from_db_for_display(
319
-                            $reg_model,
320
-                            $field_name,
321
-                            $reg_row[ $field->get_qualified_column() ]
322
-                        );
323
-                    }
324
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value;
325
-                    if ($field_name == 'REG_final_price') {
326
-                        // add a column named Currency after the final price
327
-                        $reg_csv_array[ (string) __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
328
-                    }
329
-                }
330
-                // get pretty status
331
-                $stati = EEM_Status::instance()->localized_status(
332
-                    array(
333
-                        $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
334
-                        $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
335
-                    ),
336
-                    false,
337
-                    'sentence'
338
-                );
339
-                $reg_csv_array[ (string) __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
340
-                // get pretty transaction status
341
-                $reg_csv_array[ (string) __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
342
-                $reg_csv_array[ (string) __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
343
-                    ? EEH_Export::prepare_value_from_db_for_display(
344
-                        EEM_Transaction::instance(),
345
-                        'TXN_total',
346
-                        $reg_row['TransactionTable.TXN_total'],
347
-                        'localized_float'
348
-                    ) : '0.00';
349
-                $reg_csv_array[ (string) __('Amount Paid', 'event_espresso') ] = $is_primary_reg
350
-                    ? EEH_Export::prepare_value_from_db_for_display(
351
-                        EEM_Transaction::instance(),
352
-                        'TXN_paid',
353
-                        $reg_row['TransactionTable.TXN_paid'],
354
-                        'localized_float'
355
-                    ) : '0.00';
356
-                $payment_methods = array();
357
-                $gateway_txn_ids_etc = array();
358
-                $payment_times = array();
359
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
360
-                    $payments_info = EEM_Payment::instance()->get_all_wpdb_results(
361
-                        array(
362
-                            array(
363
-                                'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
364
-                                'STS_ID' => EEM_Payment::status_id_approved,
365
-                            ),
366
-                            'force_join' => array('Payment_Method'),
367
-                        ),
368
-                        ARRAY_A,
369
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
370
-                    );
371
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
372
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
373
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
374
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
375
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
376
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
377
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
378
-                    }
379
-                }
380
-                $reg_csv_array[ (string) __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
381
-                $reg_csv_array[ (string) __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
382
-                $reg_csv_array[ (string) __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
383
-                    ',',
384
-                    $gateway_txn_ids_etc
385
-                );
386
-                // get whether or not the user has checked in
387
-                $reg_csv_array[ (string) __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
388
-                    $reg_row['Registration.REG_ID'],
389
-                    'Checkin'
390
-                );
391
-                // get ticket of registration and its price
392
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
393
-                if ($reg_row['Ticket.TKT_ID']) {
394
-                    $ticket_name = EEH_Export::prepare_value_from_db_for_display(
395
-                        $ticket_model,
396
-                        'TKT_name',
397
-                        $reg_row['Ticket.TKT_name']
398
-                    );
399
-                    $datetimes_strings = array();
400
-                    foreach (EEM_Datetime::instance()->get_all_wpdb_results(
401
-                        array(
402
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
403
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
404
-                            'default_where_conditions' => 'none',
405
-                        )
406
-                    ) as $datetime) {
407
-                        $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
408
-                            EEM_Datetime::instance(),
409
-                            'DTT_EVT_start',
410
-                            $datetime['Datetime.DTT_EVT_start']
411
-                        );
412
-                    }
413
-                } else {
414
-                    $ticket_name = __('Unknown', 'event_espresso');
415
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
416
-                }
417
-                $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
418
-                $reg_csv_array[ (string) __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
419
-                // get datetime(s) of registration
420
-                // add attendee columns
421
-                foreach ($att_fields_to_include as $att_field_name) {
422
-                    $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
423
-                    if ($reg_row['Attendee_CPT.ID']) {
424
-                        if ($att_field_name == 'STA_ID') {
425
-                            $value = EEM_State::instance()->get_var(
426
-                                array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
427
-                                'STA_name'
428
-                            );
429
-                        } elseif ($att_field_name == 'CNT_ISO') {
430
-                            $value = EEM_Country::instance()->get_var(
431
-                                array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
432
-                                'CNT_name'
433
-                            );
434
-                        } else {
435
-                            $value = EEH_Export::prepare_value_from_db_for_display(
436
-                                EEM_Attendee::instance(),
437
-                                $att_field_name,
438
-                                $reg_row[ $field_obj->get_qualified_column() ]
439
-                            );
440
-                        }
441
-                    } else {
442
-                        $value = '';
443
-                    }
444
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value;
445
-                }
446
-                // make sure each registration has the same questions in the same order
447
-                foreach ($question_labels as $question_label) {
448
-                    if (! isset($reg_csv_array[ $question_label ])) {
449
-                        $reg_csv_array[ $question_label ] = null;
450
-                    }
451
-                }
452
-                $answers = EEM_Answer::instance()->get_all_wpdb_results(array(
453
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
454
-                    'force_join' => array('Question'),
455
-                ));
456
-                // now fill out the questions THEY answered
457
-                foreach ($answers as $answer_row) {
458
-                    if ($answer_row['Question.QST_ID']) {
459
-                        $question_label = EEH_Export::prepare_value_from_db_for_display(
460
-                            EEM_Question::instance(),
461
-                            'QST_admin_label',
462
-                            $answer_row['Question.QST_admin_label']
463
-                        );
464
-                    } else {
465
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
466
-                    }
467
-                    if (isset($answer_row['Question.QST_type'])
468
-                        && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
469
-                    ) {
470
-                        $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
471
-                            $answer_row['Answer.ANS_value']
472
-                        );
473
-                    } else {
474
-                        // this isn't for html, so don't show html entities
475
-                        $reg_csv_array[ $question_label ] = html_entity_decode(
476
-                            EEH_Export::prepare_value_from_db_for_display(
477
-                                EEM_Answer::instance(),
478
-                                'ANS_value',
479
-                                $answer_row['Answer.ANS_value']
480
-                            )
481
-                        );
482
-                    }
483
-                }
226
+	/**
227
+	 * Gets the csv data for a batch of registrations
228
+	 *
229
+	 * @param int|null $event_id
230
+	 * @param int $offset
231
+	 * @param int $limit
232
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
233
+	 * @param array $query_params for using where querying the model
234
+	 * @return array top-level keys are numeric, next-level keys are column headers
235
+	 * @throws \EE_Error
236
+	 */
237
+	public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
238
+	{
239
+		$reg_fields_to_include = array(
240
+			'TXN_ID',
241
+			'ATT_ID',
242
+			'REG_ID',
243
+			'REG_date',
244
+			'REG_code',
245
+			'REG_count',
246
+			'REG_final_price',
247
+		);
248
+		$att_fields_to_include = array(
249
+			'ATT_fname',
250
+			'ATT_lname',
251
+			'ATT_email',
252
+			'ATT_address',
253
+			'ATT_address2',
254
+			'ATT_city',
255
+			'STA_ID',
256
+			'CNT_ISO',
257
+			'ATT_zip',
258
+			'ATT_phone',
259
+		);
260
+		$registrations_csv_ready_array = array();
261
+		$reg_model = EE_Registry::instance()->load_model('Registration');
262
+		$query_params['limit'] = array($offset, $limit);
263
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
264
+		$registration_ids = array();
265
+		foreach ($registration_rows as $reg_row) {
266
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
267
+		}
268
+		foreach ($registration_rows as $reg_row) {
269
+			if (is_array($reg_row)) {
270
+				$reg_csv_array = array();
271
+				if (! $event_id) {
272
+					// get the event's name and Id
273
+					$reg_csv_array[ (string) __('Event', 'event_espresso') ] = sprintf(
274
+						/* translators: 1: event name, 2: event ID */
275
+						__('%1$s (%2$s)', 'event_espresso'),
276
+						EEH_Export::prepare_value_from_db_for_display(
277
+							EEM_Event::instance(),
278
+							'EVT_name',
279
+							$reg_row['Event_CPT.post_title']
280
+						),
281
+						$reg_row['Event_CPT.ID']
282
+					);
283
+				}
284
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
285
+				/*@var $reg_row EE_Registration */
286
+				foreach ($reg_fields_to_include as $field_name) {
287
+					$field = $reg_model->field_settings_for($field_name);
288
+					if ($field_name == 'REG_final_price') {
289
+						$value = EEH_Export::prepare_value_from_db_for_display(
290
+							$reg_model,
291
+							$field_name,
292
+							$reg_row['Registration.REG_final_price'],
293
+							'localized_float'
294
+						);
295
+					} elseif ($field_name == 'REG_count') {
296
+						$value = sprintf(
297
+							/* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */
298
+							__('%1$s of %2$s', 'event_espresso'),
299
+							EEH_Export::prepare_value_from_db_for_display(
300
+								$reg_model,
301
+								'REG_count',
302
+								$reg_row['Registration.REG_count']
303
+							),
304
+							EEH_Export::prepare_value_from_db_for_display(
305
+								$reg_model,
306
+								'REG_group_size',
307
+								$reg_row['Registration.REG_group_size']
308
+							)
309
+						);
310
+					} elseif ($field_name == 'REG_date') {
311
+						$value = EEH_Export::prepare_value_from_db_for_display(
312
+							$reg_model,
313
+							$field_name,
314
+							$reg_row['Registration.REG_date'],
315
+							'no_html'
316
+						);
317
+					} else {
318
+						$value = EEH_Export::prepare_value_from_db_for_display(
319
+							$reg_model,
320
+							$field_name,
321
+							$reg_row[ $field->get_qualified_column() ]
322
+						);
323
+					}
324
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value;
325
+					if ($field_name == 'REG_final_price') {
326
+						// add a column named Currency after the final price
327
+						$reg_csv_array[ (string) __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
328
+					}
329
+				}
330
+				// get pretty status
331
+				$stati = EEM_Status::instance()->localized_status(
332
+					array(
333
+						$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
334
+						$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
335
+					),
336
+					false,
337
+					'sentence'
338
+				);
339
+				$reg_csv_array[ (string) __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
340
+				// get pretty transaction status
341
+				$reg_csv_array[ (string) __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
342
+				$reg_csv_array[ (string) __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
343
+					? EEH_Export::prepare_value_from_db_for_display(
344
+						EEM_Transaction::instance(),
345
+						'TXN_total',
346
+						$reg_row['TransactionTable.TXN_total'],
347
+						'localized_float'
348
+					) : '0.00';
349
+				$reg_csv_array[ (string) __('Amount Paid', 'event_espresso') ] = $is_primary_reg
350
+					? EEH_Export::prepare_value_from_db_for_display(
351
+						EEM_Transaction::instance(),
352
+						'TXN_paid',
353
+						$reg_row['TransactionTable.TXN_paid'],
354
+						'localized_float'
355
+					) : '0.00';
356
+				$payment_methods = array();
357
+				$gateway_txn_ids_etc = array();
358
+				$payment_times = array();
359
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
360
+					$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
361
+						array(
362
+							array(
363
+								'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
364
+								'STS_ID' => EEM_Payment::status_id_approved,
365
+							),
366
+							'force_join' => array('Payment_Method'),
367
+						),
368
+						ARRAY_A,
369
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
370
+					);
371
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
372
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
373
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
374
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
375
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
376
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
377
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
378
+					}
379
+				}
380
+				$reg_csv_array[ (string) __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
381
+				$reg_csv_array[ (string) __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
382
+				$reg_csv_array[ (string) __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
383
+					',',
384
+					$gateway_txn_ids_etc
385
+				);
386
+				// get whether or not the user has checked in
387
+				$reg_csv_array[ (string) __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
388
+					$reg_row['Registration.REG_ID'],
389
+					'Checkin'
390
+				);
391
+				// get ticket of registration and its price
392
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
393
+				if ($reg_row['Ticket.TKT_ID']) {
394
+					$ticket_name = EEH_Export::prepare_value_from_db_for_display(
395
+						$ticket_model,
396
+						'TKT_name',
397
+						$reg_row['Ticket.TKT_name']
398
+					);
399
+					$datetimes_strings = array();
400
+					foreach (EEM_Datetime::instance()->get_all_wpdb_results(
401
+						array(
402
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
403
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
404
+							'default_where_conditions' => 'none',
405
+						)
406
+					) as $datetime) {
407
+						$datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
408
+							EEM_Datetime::instance(),
409
+							'DTT_EVT_start',
410
+							$datetime['Datetime.DTT_EVT_start']
411
+						);
412
+					}
413
+				} else {
414
+					$ticket_name = __('Unknown', 'event_espresso');
415
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
416
+				}
417
+				$reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
418
+				$reg_csv_array[ (string) __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
419
+				// get datetime(s) of registration
420
+				// add attendee columns
421
+				foreach ($att_fields_to_include as $att_field_name) {
422
+					$field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
423
+					if ($reg_row['Attendee_CPT.ID']) {
424
+						if ($att_field_name == 'STA_ID') {
425
+							$value = EEM_State::instance()->get_var(
426
+								array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
427
+								'STA_name'
428
+							);
429
+						} elseif ($att_field_name == 'CNT_ISO') {
430
+							$value = EEM_Country::instance()->get_var(
431
+								array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
432
+								'CNT_name'
433
+							);
434
+						} else {
435
+							$value = EEH_Export::prepare_value_from_db_for_display(
436
+								EEM_Attendee::instance(),
437
+								$att_field_name,
438
+								$reg_row[ $field_obj->get_qualified_column() ]
439
+							);
440
+						}
441
+					} else {
442
+						$value = '';
443
+					}
444
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value;
445
+				}
446
+				// make sure each registration has the same questions in the same order
447
+				foreach ($question_labels as $question_label) {
448
+					if (! isset($reg_csv_array[ $question_label ])) {
449
+						$reg_csv_array[ $question_label ] = null;
450
+					}
451
+				}
452
+				$answers = EEM_Answer::instance()->get_all_wpdb_results(array(
453
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
454
+					'force_join' => array('Question'),
455
+				));
456
+				// now fill out the questions THEY answered
457
+				foreach ($answers as $answer_row) {
458
+					if ($answer_row['Question.QST_ID']) {
459
+						$question_label = EEH_Export::prepare_value_from_db_for_display(
460
+							EEM_Question::instance(),
461
+							'QST_admin_label',
462
+							$answer_row['Question.QST_admin_label']
463
+						);
464
+					} else {
465
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
466
+					}
467
+					if (isset($answer_row['Question.QST_type'])
468
+						&& $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
469
+					) {
470
+						$reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
471
+							$answer_row['Answer.ANS_value']
472
+						);
473
+					} else {
474
+						// this isn't for html, so don't show html entities
475
+						$reg_csv_array[ $question_label ] = html_entity_decode(
476
+							EEH_Export::prepare_value_from_db_for_display(
477
+								EEM_Answer::instance(),
478
+								'ANS_value',
479
+								$answer_row['Answer.ANS_value']
480
+							)
481
+						);
482
+					}
483
+				}
484 484
 
485
-                /**
486
-                 * Filter to change the contents of each row of the registrations report CSV file.
487
-                 * This can be used to add or remote columns from the CSV file, or change their values.
488
-                 * Note when using: all rows in the CSV should have the same columns.
489
-                 * @param array $reg_csv_array keys are the column names, values are their cell values
490
-                 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
491
-                 */
492
-                $registrations_csv_ready_array[] = apply_filters(
493
-                    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
494
-                    $reg_csv_array,
495
-                    $reg_row
496
-                );
497
-            }
498
-        }
499
-        // if we couldn't export anything, we want to at least show the column headers
500
-        if (empty($registrations_csv_ready_array)) {
501
-            $reg_csv_array = array();
502
-            $model_and_fields_to_include = array(
503
-                'Registration' => $reg_fields_to_include,
504
-                'Attendee'     => $att_fields_to_include,
505
-            );
506
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
507
-                $model = EE_Registry::instance()->load_model($model_name);
508
-                foreach ($field_list as $field_name) {
509
-                    $field = $model->field_settings_for($field_name);
510
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
511
-                }
512
-            }
513
-            $registrations_csv_ready_array[] = $reg_csv_array;
514
-        }
515
-        return $registrations_csv_ready_array;
516
-    }
485
+				/**
486
+				 * Filter to change the contents of each row of the registrations report CSV file.
487
+				 * This can be used to add or remote columns from the CSV file, or change their values.
488
+				 * Note when using: all rows in the CSV should have the same columns.
489
+				 * @param array $reg_csv_array keys are the column names, values are their cell values
490
+				 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
491
+				 */
492
+				$registrations_csv_ready_array[] = apply_filters(
493
+					'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
494
+					$reg_csv_array,
495
+					$reg_row
496
+				);
497
+			}
498
+		}
499
+		// if we couldn't export anything, we want to at least show the column headers
500
+		if (empty($registrations_csv_ready_array)) {
501
+			$reg_csv_array = array();
502
+			$model_and_fields_to_include = array(
503
+				'Registration' => $reg_fields_to_include,
504
+				'Attendee'     => $att_fields_to_include,
505
+			);
506
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
507
+				$model = EE_Registry::instance()->load_model($model_name);
508
+				foreach ($field_list as $field_name) {
509
+					$field = $model->field_settings_for($field_name);
510
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
511
+				}
512
+			}
513
+			$registrations_csv_ready_array[] = $reg_csv_array;
514
+		}
515
+		return $registrations_csv_ready_array;
516
+	}
517 517
 
518 518
 
519
-    /**
520
-     * Counts total unit to process
521
-     *
522
-     * @deprecated since 4.9.19
523
-     * @param int|array $event_id
524
-     * @return int
525
-     */
526
-    public function count_units_to_process($event_id)
527
-    {
528
-        // use the legacy filter
529
-        if ($event_id) {
530
-            $query_params[0]['EVT_ID'] = $event_id;
531
-        } else {
532
-            $query_params['force_join'][] = 'Event';
533
-        }
534
-        return \EEM_Registration::instance()->count($query_params);
535
-    }
519
+	/**
520
+	 * Counts total unit to process
521
+	 *
522
+	 * @deprecated since 4.9.19
523
+	 * @param int|array $event_id
524
+	 * @return int
525
+	 */
526
+	public function count_units_to_process($event_id)
527
+	{
528
+		// use the legacy filter
529
+		if ($event_id) {
530
+			$query_params[0]['EVT_ID'] = $event_id;
531
+		} else {
532
+			$query_params['force_join'][] = 'Event';
533
+		}
534
+		return \EEM_Registration::instance()->count($query_params);
535
+	}
536 536
 
537 537
 
538
-    /**
539
-     * Performs any clean-up logic when we know the job is completed.
540
-     * In this case, we delete the temporary file
541
-     *
542
-     * @param JobParameters $job_parameters
543
-     * @return boolean
544
-     */
545
-    public function cleanup_job(JobParameters $job_parameters)
546
-    {
547
-        $this->_file_helper->delete(
548
-            \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
549
-            true,
550
-            'd'
551
-        );
552
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
553
-    }
538
+	/**
539
+	 * Performs any clean-up logic when we know the job is completed.
540
+	 * In this case, we delete the temporary file
541
+	 *
542
+	 * @param JobParameters $job_parameters
543
+	 * @return boolean
544
+	 */
545
+	public function cleanup_job(JobParameters $job_parameters)
546
+	{
547
+		$this->_file_helper->delete(
548
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
549
+			true,
550
+			'd'
551
+		);
552
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
553
+	}
554 554
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     public function create_job(JobParameters $job_parameters)
46 46
     {
47 47
         $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
48
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
48
+        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
49 49
             throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
50 50
         }
51 51
         $filepath = $this->create_file_from_job_with_name(
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 $query_params['force_join'][] = 'Event';
83 83
             }
84 84
         }
85
-        if (! isset($query_params['force_join'])) {
85
+        if ( ! isset($query_params['force_join'])) {
86 86
             $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
87 87
         }
88 88
         $job_parameters->add_extra_data('query_params', $query_params);
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
         $question_where_params = array();
173 173
         foreach ($reg_where_params as $key => $val) {
174 174
             if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
175
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
175
+                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
176 176
             } else {
177 177
                 // it's a normal where condition
178
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
178
+                $question_where_params['Question_Group.Event.Registration.'.$key] = $val;
179 179
             }
180 180
         }
181 181
         return $question_where_params;
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
         foreach ($registration_rows as $reg_row) {
269 269
             if (is_array($reg_row)) {
270 270
                 $reg_csv_array = array();
271
-                if (! $event_id) {
271
+                if ( ! $event_id) {
272 272
                     // get the event's name and Id
273
-                    $reg_csv_array[ (string) __('Event', 'event_espresso') ] = sprintf(
273
+                    $reg_csv_array[(string) __('Event', 'event_espresso')] = sprintf(
274 274
                         /* translators: 1: event name, 2: event ID */
275 275
                         __('%1$s (%2$s)', 'event_espresso'),
276 276
                         EEH_Export::prepare_value_from_db_for_display(
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
                         $value = EEH_Export::prepare_value_from_db_for_display(
319 319
                             $reg_model,
320 320
                             $field_name,
321
-                            $reg_row[ $field->get_qualified_column() ]
321
+                            $reg_row[$field->get_qualified_column()]
322 322
                         );
323 323
                     }
324
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value;
324
+                    $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = $value;
325 325
                     if ($field_name == 'REG_final_price') {
326 326
                         // add a column named Currency after the final price
327
-                        $reg_csv_array[ (string) __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
327
+                        $reg_csv_array[(string) __("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
328 328
                     }
329 329
                 }
330 330
                 // get pretty status
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
                     false,
337 337
                     'sentence'
338 338
                 );
339
-                $reg_csv_array[ (string) __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
339
+                $reg_csv_array[(string) __("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
340 340
                 // get pretty transaction status
341
-                $reg_csv_array[ (string) __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
342
-                $reg_csv_array[ (string) __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
341
+                $reg_csv_array[(string) __("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
342
+                $reg_csv_array[(string) __('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
343 343
                     ? EEH_Export::prepare_value_from_db_for_display(
344 344
                         EEM_Transaction::instance(),
345 345
                         'TXN_total',
346 346
                         $reg_row['TransactionTable.TXN_total'],
347 347
                         'localized_float'
348 348
                     ) : '0.00';
349
-                $reg_csv_array[ (string) __('Amount Paid', 'event_espresso') ] = $is_primary_reg
349
+                $reg_csv_array[(string) __('Amount Paid', 'event_espresso')] = $is_primary_reg
350 350
                     ? EEH_Export::prepare_value_from_db_for_display(
351 351
                         EEM_Transaction::instance(),
352 352
                         'TXN_paid',
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
                             ? $payment_method_and_gateway_txn_id['payment_time'] : '';
378 378
                     }
379 379
                 }
380
-                $reg_csv_array[ (string) __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
381
-                $reg_csv_array[ (string) __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
382
-                $reg_csv_array[ (string) __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
380
+                $reg_csv_array[(string) __('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
381
+                $reg_csv_array[(string) __('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
382
+                $reg_csv_array[(string) __('Gateway Transaction ID(s)', 'event_espresso')] = implode(
383 383
                     ',',
384 384
                     $gateway_txn_ids_etc
385 385
                 );
386 386
                 // get whether or not the user has checked in
387
-                $reg_csv_array[ (string) __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
387
+                $reg_csv_array[(string) __("Check-Ins", "event_espresso")] = $reg_model->count_related(
388 388
                     $reg_row['Registration.REG_ID'],
389 389
                     'Checkin'
390 390
                 );
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
                     $ticket_name = __('Unknown', 'event_espresso');
415 415
                     $datetimes_strings = array(__('Unknown', 'event_espresso'));
416 416
                 }
417
-                $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
418
-                $reg_csv_array[ (string) __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
417
+                $reg_csv_array[(string) $ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
418
+                $reg_csv_array[(string) __("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
419 419
                 // get datetime(s) of registration
420 420
                 // add attendee columns
421 421
                 foreach ($att_fields_to_include as $att_field_name) {
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
                             $value = EEH_Export::prepare_value_from_db_for_display(
436 436
                                 EEM_Attendee::instance(),
437 437
                                 $att_field_name,
438
-                                $reg_row[ $field_obj->get_qualified_column() ]
438
+                                $reg_row[$field_obj->get_qualified_column()]
439 439
                             );
440 440
                         }
441 441
                     } else {
442 442
                         $value = '';
443 443
                     }
444
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value;
444
+                    $reg_csv_array[EEH_Export::get_column_name_for_field($field_obj)] = $value;
445 445
                 }
446 446
                 // make sure each registration has the same questions in the same order
447 447
                 foreach ($question_labels as $question_label) {
448
-                    if (! isset($reg_csv_array[ $question_label ])) {
449
-                        $reg_csv_array[ $question_label ] = null;
448
+                    if ( ! isset($reg_csv_array[$question_label])) {
449
+                        $reg_csv_array[$question_label] = null;
450 450
                     }
451 451
                 }
452 452
                 $answers = EEM_Answer::instance()->get_all_wpdb_results(array(
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
                     if (isset($answer_row['Question.QST_type'])
468 468
                         && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
469 469
                     ) {
470
-                        $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
470
+                        $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID(
471 471
                             $answer_row['Answer.ANS_value']
472 472
                         );
473 473
                     } else {
474 474
                         // this isn't for html, so don't show html entities
475
-                        $reg_csv_array[ $question_label ] = html_entity_decode(
475
+                        $reg_csv_array[$question_label] = html_entity_decode(
476 476
                             EEH_Export::prepare_value_from_db_for_display(
477 477
                                 EEM_Answer::instance(),
478 478
                                 'ANS_value',
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                 $model = EE_Registry::instance()->load_model($model_name);
508 508
                 foreach ($field_list as $field_name) {
509 509
                     $field = $model->field_settings_for($field_name);
510
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
510
+                    $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = null;
511 511
                 }
512 512
             }
513 513
             $registrations_csv_ready_array[] = $reg_csv_array;
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
      *    _get_table_filters
228 228
      *
229 229
      * @access protected
230
-     * @return array
230
+     * @return string[]
231 231
      */
232 232
     protected function _get_table_filters()
233 233
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,4 @@
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\EntityNotFoundException;
2
-
3 2
 use EventEspresso\core\exceptions\InvalidDataTypeException;
4 3
 use EventEspresso\core\exceptions\InvalidInterfaceException;
5 4
 
Please login to merge, or discard this patch.
Indentation   +965 added lines, -965 removed lines patch added patch discarded remove patch
@@ -24,1046 +24,1046 @@
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    private $_status;
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $_status;
31 31
 
32 32
 
33
-    /**
34
-     * An array of transaction details for the related transaction to the registration being processed.
35
-     * This is set via the _set_related_details method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_transaction_details = array();
33
+	/**
34
+	 * An array of transaction details for the related transaction to the registration being processed.
35
+	 * This is set via the _set_related_details method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_transaction_details = array();
40 40
 
41 41
 
42
-    /**
43
-     * An array of event details for the related event to the registration being processed.
44
-     * This is set via the _set_related_details method.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $_event_details = array();
42
+	/**
43
+	 * An array of event details for the related event to the registration being processed.
44
+	 * This is set via the _set_related_details method.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $_event_details = array();
49 49
 
50 50
 
51
-    /**
52
-     * @param \Registrations_Admin_Page $admin_page
53
-     */
54
-    public function __construct(Registrations_Admin_Page $admin_page)
55
-    {
56
-        if (! empty($_GET['event_id'])) {
57
-            $extra_query_args = array();
58
-            foreach ($admin_page->get_views() as $key => $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
60
-            }
61
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
-        }
63
-        parent::__construct($admin_page);
64
-        $this->_status = $this->_admin_page->get_registration_status_array();
65
-    }
51
+	/**
52
+	 * @param \Registrations_Admin_Page $admin_page
53
+	 */
54
+	public function __construct(Registrations_Admin_Page $admin_page)
55
+	{
56
+		if (! empty($_GET['event_id'])) {
57
+			$extra_query_args = array();
58
+			foreach ($admin_page->get_views() as $key => $view_details) {
59
+				$extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
60
+			}
61
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
+		}
63
+		parent::__construct($admin_page);
64
+		$this->_status = $this->_admin_page->get_registration_status_array();
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     *    _setup_data
70
-     *
71
-     * @access protected
72
-     * @return void
73
-     */
74
-    protected function _setup_data()
75
-    {
76
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
77
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
78
-    }
68
+	/**
69
+	 *    _setup_data
70
+	 *
71
+	 * @access protected
72
+	 * @return void
73
+	 */
74
+	protected function _setup_data()
75
+	{
76
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
77
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     *    _set_properties
83
-     *
84
-     * @access protected
85
-     * @return void
86
-     */
87
-    protected function _set_properties()
88
-    {
89
-        $this->_wp_list_args = array(
90
-            'singular' => __('registration', 'event_espresso'),
91
-            'plural'   => __('registrations', 'event_espresso'),
92
-            'ajax'     => true,
93
-            'screen'   => $this->_admin_page->get_current_screen()->id,
94
-        );
95
-        $ID_column_name = __('ID', 'event_espresso');
96
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
97
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
98
-        $ID_column_name .= '</span> ';
99
-        if (isset($_GET['event_id'])) {
100
-            $this->_columns = array(
101
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
102
-                '_REG_ID'          => $ID_column_name,
103
-                'ATT_fname'        => __('Name', 'event_espresso'),
104
-                'ATT_email'        => __('Email', 'event_espresso'),
105
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
106
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
107
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
108
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
109
-                'TXN_paid'         => __('Paid', 'event_espresso'),
110
-                'actions'          => __('Actions', 'event_espresso'),
111
-            );
112
-            $this->_bottom_buttons = array(
113
-                'report' => array(
114
-                    'route'         => 'registrations_report',
115
-                    'extra_request' => array(
116
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
117
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
118
-                    ),
119
-                ),
120
-            );
121
-        } else {
122
-            $this->_columns = array(
123
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
124
-                '_REG_ID'          => $ID_column_name,
125
-                'ATT_fname'        => __('Name', 'event_espresso'),
126
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
127
-                'event_name'       => __('Event', 'event_espresso'),
128
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
129
-                '_REG_final_price' => __('Price', 'event_espresso'),
130
-                '_REG_paid'        => __('Paid', 'event_espresso'),
131
-                'actions'          => __('Actions', 'event_espresso'),
132
-            );
133
-            $this->_bottom_buttons = array(
134
-                'report_all' => array(
135
-                    'route'         => 'registrations_report',
136
-                    'extra_request' => array(
137
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
138
-                    ),
139
-                ),
140
-            );
141
-        }
142
-        $this->_bottom_buttons['report_filtered'] = array(
143
-            'route'         => 'registrations_report',
144
-            'extra_request' => array(
145
-                'use_filters' => true,
146
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
147
-            ),
148
-        );
149
-        $filters = array_diff_key(
150
-            $this->_req_data,
151
-            array_flip(
152
-                array(
153
-                    'page',
154
-                    'action',
155
-                    'default_nonce',
156
-                )
157
-            )
158
-        );
159
-        if (!empty($filters)) {
160
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161
-        }
162
-        $this->_primary_column = '_REG_ID';
163
-        $this->_sortable_columns = array(
164
-            '_REG_date'     => array('_REG_date' => true),   // true means its already sorted
165
-            /**
166
-             * Allows users to change the default sort if they wish.
167
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
168
-             * name.
169
-             */
170
-            'ATT_fname'     => array(
171
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
172
-                true,
173
-                $this,
174
-            )
175
-                ? array('ATT_lname' => false)
176
-                : array('ATT_fname' => false),
177
-            'event_name'    => array('event_name' => false),
178
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
179
-            '_REG_ID'       => array('_REG_ID' => false),
180
-        );
181
-        $this->_hidden_columns = array();
182
-    }
81
+	/**
82
+	 *    _set_properties
83
+	 *
84
+	 * @access protected
85
+	 * @return void
86
+	 */
87
+	protected function _set_properties()
88
+	{
89
+		$this->_wp_list_args = array(
90
+			'singular' => __('registration', 'event_espresso'),
91
+			'plural'   => __('registrations', 'event_espresso'),
92
+			'ajax'     => true,
93
+			'screen'   => $this->_admin_page->get_current_screen()->id,
94
+		);
95
+		$ID_column_name = __('ID', 'event_espresso');
96
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
97
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
98
+		$ID_column_name .= '</span> ';
99
+		if (isset($_GET['event_id'])) {
100
+			$this->_columns = array(
101
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
102
+				'_REG_ID'          => $ID_column_name,
103
+				'ATT_fname'        => __('Name', 'event_espresso'),
104
+				'ATT_email'        => __('Email', 'event_espresso'),
105
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
106
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
107
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
108
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
109
+				'TXN_paid'         => __('Paid', 'event_espresso'),
110
+				'actions'          => __('Actions', 'event_espresso'),
111
+			);
112
+			$this->_bottom_buttons = array(
113
+				'report' => array(
114
+					'route'         => 'registrations_report',
115
+					'extra_request' => array(
116
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
117
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
118
+					),
119
+				),
120
+			);
121
+		} else {
122
+			$this->_columns = array(
123
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
124
+				'_REG_ID'          => $ID_column_name,
125
+				'ATT_fname'        => __('Name', 'event_espresso'),
126
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
127
+				'event_name'       => __('Event', 'event_espresso'),
128
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
129
+				'_REG_final_price' => __('Price', 'event_espresso'),
130
+				'_REG_paid'        => __('Paid', 'event_espresso'),
131
+				'actions'          => __('Actions', 'event_espresso'),
132
+			);
133
+			$this->_bottom_buttons = array(
134
+				'report_all' => array(
135
+					'route'         => 'registrations_report',
136
+					'extra_request' => array(
137
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
138
+					),
139
+				),
140
+			);
141
+		}
142
+		$this->_bottom_buttons['report_filtered'] = array(
143
+			'route'         => 'registrations_report',
144
+			'extra_request' => array(
145
+				'use_filters' => true,
146
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
147
+			),
148
+		);
149
+		$filters = array_diff_key(
150
+			$this->_req_data,
151
+			array_flip(
152
+				array(
153
+					'page',
154
+					'action',
155
+					'default_nonce',
156
+				)
157
+			)
158
+		);
159
+		if (!empty($filters)) {
160
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161
+		}
162
+		$this->_primary_column = '_REG_ID';
163
+		$this->_sortable_columns = array(
164
+			'_REG_date'     => array('_REG_date' => true),   // true means its already sorted
165
+			/**
166
+			 * Allows users to change the default sort if they wish.
167
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
168
+			 * name.
169
+			 */
170
+			'ATT_fname'     => array(
171
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
172
+				true,
173
+				$this,
174
+			)
175
+				? array('ATT_lname' => false)
176
+				: array('ATT_fname' => false),
177
+			'event_name'    => array('event_name' => false),
178
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
179
+			'_REG_ID'       => array('_REG_ID' => false),
180
+		);
181
+		$this->_hidden_columns = array();
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * This simply sets up the row class for the table rows.
187
-     * Allows for easier overriding of child methods for setting up sorting.
188
-     *
189
-     * @param  EE_Registration $item the current item
190
-     * @return string
191
-     */
192
-    protected function _get_row_class($item)
193
-    {
194
-        $class = parent::_get_row_class($item);
195
-        // add status class
196
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
197
-        if ($this->_has_checkbox_column) {
198
-            $class .= ' has-checkbox-column';
199
-        }
200
-        return $class;
201
-    }
185
+	/**
186
+	 * This simply sets up the row class for the table rows.
187
+	 * Allows for easier overriding of child methods for setting up sorting.
188
+	 *
189
+	 * @param  EE_Registration $item the current item
190
+	 * @return string
191
+	 */
192
+	protected function _get_row_class($item)
193
+	{
194
+		$class = parent::_get_row_class($item);
195
+		// add status class
196
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
197
+		if ($this->_has_checkbox_column) {
198
+			$class .= ' has-checkbox-column';
199
+		}
200
+		return $class;
201
+	}
202 202
 
203 203
 
204
-    /**
205
-     * Set the $_transaction_details property if not set yet.
206
-     *
207
-     * @param EE_Registration $registration
208
-     * @throws EE_Error
209
-     * @throws InvalidArgumentException
210
-     * @throws ReflectionException
211
-     * @throws InvalidDataTypeException
212
-     * @throws InvalidInterfaceException
213
-     */
214
-    protected function _set_related_details(EE_Registration $registration)
215
-    {
216
-        $transaction = $registration->get_first_related('Transaction');
217
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
218
-            : EEM_Transaction::failed_status_code;
219
-        $this->_transaction_details = array(
220
-            'transaction' => $transaction,
221
-            'status'      => $status,
222
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
223
-            'title_attr'  => sprintf(
224
-                __('View Transaction Details (%s)', 'event_espresso'),
225
-                EEH_Template::pretty_status($status, false, 'sentence')
226
-            ),
227
-        );
228
-        try {
229
-            $event = $registration->event();
230
-        } catch (EntityNotFoundException $e) {
231
-            $event = null;
232
-        }
233
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
234
-        $this->_event_details = array(
235
-            'event'      => $event,
236
-            'status'     => $status,
237
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
238
-            'title_attr' => sprintf(
239
-                __('Edit Event (%s)', 'event_espresso'),
240
-                EEH_Template::pretty_status($status, false, 'sentence')
241
-            ),
242
-        );
243
-    }
204
+	/**
205
+	 * Set the $_transaction_details property if not set yet.
206
+	 *
207
+	 * @param EE_Registration $registration
208
+	 * @throws EE_Error
209
+	 * @throws InvalidArgumentException
210
+	 * @throws ReflectionException
211
+	 * @throws InvalidDataTypeException
212
+	 * @throws InvalidInterfaceException
213
+	 */
214
+	protected function _set_related_details(EE_Registration $registration)
215
+	{
216
+		$transaction = $registration->get_first_related('Transaction');
217
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
218
+			: EEM_Transaction::failed_status_code;
219
+		$this->_transaction_details = array(
220
+			'transaction' => $transaction,
221
+			'status'      => $status,
222
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
223
+			'title_attr'  => sprintf(
224
+				__('View Transaction Details (%s)', 'event_espresso'),
225
+				EEH_Template::pretty_status($status, false, 'sentence')
226
+			),
227
+		);
228
+		try {
229
+			$event = $registration->event();
230
+		} catch (EntityNotFoundException $e) {
231
+			$event = null;
232
+		}
233
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
234
+		$this->_event_details = array(
235
+			'event'      => $event,
236
+			'status'     => $status,
237
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
238
+			'title_attr' => sprintf(
239
+				__('Edit Event (%s)', 'event_espresso'),
240
+				EEH_Template::pretty_status($status, false, 'sentence')
241
+			),
242
+		);
243
+	}
244 244
 
245 245
 
246
-    /**
247
-     *    _get_table_filters
248
-     *
249
-     * @access protected
250
-     * @return array
251
-     */
252
-    protected function _get_table_filters()
253
-    {
254
-        $filters = array();
255
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
-        // methods.
257
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
258
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
259
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
260
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
261
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
262
-        $status = array();
263
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
264
-        foreach ($this->_status as $key => $value) {
265
-            $status[] = array('id' => $key, 'text' => $value);
266
-        }
267
-        if ($this->_view !== 'incomplete') {
268
-            $filters[] = EEH_Form_Fields::select_input(
269
-                '_reg_status',
270
-                $status,
271
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
272
-                    : ''
273
-            );
274
-        }
275
-        if (isset($this->_req_data['event_id'])) {
276
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
277
-        }
278
-        return $filters;
279
-    }
246
+	/**
247
+	 *    _get_table_filters
248
+	 *
249
+	 * @access protected
250
+	 * @return array
251
+	 */
252
+	protected function _get_table_filters()
253
+	{
254
+		$filters = array();
255
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
+		// methods.
257
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
258
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
259
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
260
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
261
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
262
+		$status = array();
263
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
264
+		foreach ($this->_status as $key => $value) {
265
+			$status[] = array('id' => $key, 'text' => $value);
266
+		}
267
+		if ($this->_view !== 'incomplete') {
268
+			$filters[] = EEH_Form_Fields::select_input(
269
+				'_reg_status',
270
+				$status,
271
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
272
+					: ''
273
+			);
274
+		}
275
+		if (isset($this->_req_data['event_id'])) {
276
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
277
+		}
278
+		return $filters;
279
+	}
280 280
 
281 281
 
282
-    /**
283
-     *    _add_view_counts
284
-     *
285
-     * @access protected
286
-     * @return void
287
-     * @throws EE_Error
288
-     * @throws InvalidArgumentException
289
-     * @throws InvalidDataTypeException
290
-     * @throws InvalidInterfaceException
291
-     */
292
-    protected function _add_view_counts()
293
-    {
294
-        $this->_views['all']['count'] = $this->_total_registrations();
295
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
296
-        $this->_views['today']['count'] = $this->_total_registrations_today();
297
-        if (EE_Registry::instance()->CAP->current_user_can(
298
-            'ee_delete_registrations',
299
-            'espresso_registrations_trash_registrations'
300
-        )) {
301
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
302
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
303
-        }
304
-    }
282
+	/**
283
+	 *    _add_view_counts
284
+	 *
285
+	 * @access protected
286
+	 * @return void
287
+	 * @throws EE_Error
288
+	 * @throws InvalidArgumentException
289
+	 * @throws InvalidDataTypeException
290
+	 * @throws InvalidInterfaceException
291
+	 */
292
+	protected function _add_view_counts()
293
+	{
294
+		$this->_views['all']['count'] = $this->_total_registrations();
295
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
296
+		$this->_views['today']['count'] = $this->_total_registrations_today();
297
+		if (EE_Registry::instance()->CAP->current_user_can(
298
+			'ee_delete_registrations',
299
+			'espresso_registrations_trash_registrations'
300
+		)) {
301
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
302
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
303
+		}
304
+	}
305 305
 
306 306
 
307
-    /**
308
-     * _total_registrations
309
-     *
310
-     * @access protected
311
-     * @param string $view
312
-     * @return int
313
-     * @throws EE_Error
314
-     * @throws InvalidArgumentException
315
-     * @throws InvalidDataTypeException
316
-     * @throws InvalidInterfaceException
317
-     */
318
-    protected function _total_registrations($view = '')
319
-    {
320
-        $_where = array();
321
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
322
-        if ($EVT_ID) {
323
-            $_where['EVT_ID'] = $EVT_ID;
324
-        }
325
-        switch ($view) {
326
-            case 'trash':
327
-                return EEM_Registration::instance()->count_deleted(array($_where));
328
-                break;
329
-            case 'incomplete':
330
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
331
-                break;
332
-            default:
333
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
334
-        }
335
-        return EEM_Registration::instance()->count(array($_where));
336
-    }
307
+	/**
308
+	 * _total_registrations
309
+	 *
310
+	 * @access protected
311
+	 * @param string $view
312
+	 * @return int
313
+	 * @throws EE_Error
314
+	 * @throws InvalidArgumentException
315
+	 * @throws InvalidDataTypeException
316
+	 * @throws InvalidInterfaceException
317
+	 */
318
+	protected function _total_registrations($view = '')
319
+	{
320
+		$_where = array();
321
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
322
+		if ($EVT_ID) {
323
+			$_where['EVT_ID'] = $EVT_ID;
324
+		}
325
+		switch ($view) {
326
+			case 'trash':
327
+				return EEM_Registration::instance()->count_deleted(array($_where));
328
+				break;
329
+			case 'incomplete':
330
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
331
+				break;
332
+			default:
333
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
334
+		}
335
+		return EEM_Registration::instance()->count(array($_where));
336
+	}
337 337
 
338 338
 
339
-    /**
340
-     * _total_registrations_this_month
341
-     *
342
-     * @access protected
343
-     * @return int
344
-     * @throws EE_Error
345
-     * @throws InvalidArgumentException
346
-     * @throws InvalidDataTypeException
347
-     * @throws InvalidInterfaceException
348
-     */
349
-    protected function _total_registrations_this_month()
350
-    {
351
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
352
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
353
-        $this_year_r = date('Y', current_time('timestamp'));
354
-        $time_start = ' 00:00:00';
355
-        $time_end = ' 23:59:59';
356
-        $this_month_r = date('m', current_time('timestamp'));
357
-        $days_this_month = date('t', current_time('timestamp'));
358
-        // setup date query.
359
-        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360
-            'REG_date',
361
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
362
-            'Y-m-d H:i:s'
363
-        );
364
-        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
365
-            'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
367
-            'Y-m-d H:i:s'
368
-        );
369
-        $_where['REG_date'] = array(
370
-            'BETWEEN',
371
-            array(
372
-                $beginning_string,
373
-                $end_string,
374
-            ),
375
-        );
376
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
377
-        return EEM_Registration::instance()->count(array($_where));
378
-    }
339
+	/**
340
+	 * _total_registrations_this_month
341
+	 *
342
+	 * @access protected
343
+	 * @return int
344
+	 * @throws EE_Error
345
+	 * @throws InvalidArgumentException
346
+	 * @throws InvalidDataTypeException
347
+	 * @throws InvalidInterfaceException
348
+	 */
349
+	protected function _total_registrations_this_month()
350
+	{
351
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
352
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
353
+		$this_year_r = date('Y', current_time('timestamp'));
354
+		$time_start = ' 00:00:00';
355
+		$time_end = ' 23:59:59';
356
+		$this_month_r = date('m', current_time('timestamp'));
357
+		$days_this_month = date('t', current_time('timestamp'));
358
+		// setup date query.
359
+		$beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360
+			'REG_date',
361
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
362
+			'Y-m-d H:i:s'
363
+		);
364
+		$end_string = EEM_Registration::instance()->convert_datetime_for_query(
365
+			'REG_date',
366
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
367
+			'Y-m-d H:i:s'
368
+		);
369
+		$_where['REG_date'] = array(
370
+			'BETWEEN',
371
+			array(
372
+				$beginning_string,
373
+				$end_string,
374
+			),
375
+		);
376
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
377
+		return EEM_Registration::instance()->count(array($_where));
378
+	}
379 379
 
380 380
 
381
-    /**
382
-     * _total_registrations_today
383
-     *
384
-     * @access protected
385
-     * @return int
386
-     * @throws EE_Error
387
-     * @throws InvalidArgumentException
388
-     * @throws InvalidDataTypeException
389
-     * @throws InvalidInterfaceException
390
-     */
391
-    protected function _total_registrations_today()
392
-    {
393
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
394
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
395
-        $current_date = date('Y-m-d', current_time('timestamp'));
396
-        $time_start = ' 00:00:00';
397
-        $time_end = ' 23:59:59';
398
-        $_where['REG_date'] = array(
399
-            'BETWEEN',
400
-            array(
401
-                EEM_Registration::instance()->convert_datetime_for_query(
402
-                    'REG_date',
403
-                    $current_date . $time_start,
404
-                    'Y-m-d H:i:s'
405
-                ),
406
-                EEM_Registration::instance()->convert_datetime_for_query(
407
-                    'REG_date',
408
-                    $current_date . $time_end,
409
-                    'Y-m-d H:i:s'
410
-                ),
411
-            ),
412
-        );
413
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
414
-        return EEM_Registration::instance()->count(array($_where));
415
-    }
381
+	/**
382
+	 * _total_registrations_today
383
+	 *
384
+	 * @access protected
385
+	 * @return int
386
+	 * @throws EE_Error
387
+	 * @throws InvalidArgumentException
388
+	 * @throws InvalidDataTypeException
389
+	 * @throws InvalidInterfaceException
390
+	 */
391
+	protected function _total_registrations_today()
392
+	{
393
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
394
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
395
+		$current_date = date('Y-m-d', current_time('timestamp'));
396
+		$time_start = ' 00:00:00';
397
+		$time_end = ' 23:59:59';
398
+		$_where['REG_date'] = array(
399
+			'BETWEEN',
400
+			array(
401
+				EEM_Registration::instance()->convert_datetime_for_query(
402
+					'REG_date',
403
+					$current_date . $time_start,
404
+					'Y-m-d H:i:s'
405
+				),
406
+				EEM_Registration::instance()->convert_datetime_for_query(
407
+					'REG_date',
408
+					$current_date . $time_end,
409
+					'Y-m-d H:i:s'
410
+				),
411
+			),
412
+		);
413
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
414
+		return EEM_Registration::instance()->count(array($_where));
415
+	}
416 416
 
417 417
 
418
-    /**
419
-     * column_cb
420
-     *
421
-     * @access public
422
-     * @param \EE_Registration $item
423
-     * @return string
424
-     * @throws EE_Error
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidDataTypeException
427
-     * @throws InvalidInterfaceException
428
-     * @throws ReflectionException
429
-     */
430
-    public function column_cb($item)
431
-    {
432
-        /** checkbox/lock **/
433
-        $transaction = $item->get_first_related('Transaction');
434
-        $payment_count = $transaction instanceof EE_Transaction
435
-            ? $transaction->count_related('Payment')
436
-            : 0;
437
-        return $payment_count > 0
438
-               || ! EE_Registry::instance()->CAP->current_user_can(
439
-                   'ee_edit_registration',
440
-                   'registration_list_table_checkbox_input',
441
-                   $item->ID()
442
-               )
443
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
444
-              . '<span class="ee-lock-icon"></span>'
445
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
446
-    }
418
+	/**
419
+	 * column_cb
420
+	 *
421
+	 * @access public
422
+	 * @param \EE_Registration $item
423
+	 * @return string
424
+	 * @throws EE_Error
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidDataTypeException
427
+	 * @throws InvalidInterfaceException
428
+	 * @throws ReflectionException
429
+	 */
430
+	public function column_cb($item)
431
+	{
432
+		/** checkbox/lock **/
433
+		$transaction = $item->get_first_related('Transaction');
434
+		$payment_count = $transaction instanceof EE_Transaction
435
+			? $transaction->count_related('Payment')
436
+			: 0;
437
+		return $payment_count > 0
438
+			   || ! EE_Registry::instance()->CAP->current_user_can(
439
+				   'ee_edit_registration',
440
+				   'registration_list_table_checkbox_input',
441
+				   $item->ID()
442
+			   )
443
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
444
+			  . '<span class="ee-lock-icon"></span>'
445
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
446
+	}
447 447
 
448 448
 
449
-    /**
450
-     * column__REG_ID
451
-     *
452
-     * @access public
453
-     * @param \EE_Registration $item
454
-     * @return string
455
-     * @throws EE_Error
456
-     * @throws InvalidArgumentException
457
-     * @throws InvalidDataTypeException
458
-     * @throws InvalidInterfaceException
459
-     * @throws ReflectionException
460
-     */
461
-    public function column__REG_ID(EE_Registration $item)
462
-    {
463
-        $attendee = $item->attendee();
464
-        $content = $item->ID();
465
-        $content .= '<div class="show-on-mobile-view-only">';
466
-        $content .= '<br>';
467
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470
-        $content .= '</div>';
471
-        return $content;
472
-    }
449
+	/**
450
+	 * column__REG_ID
451
+	 *
452
+	 * @access public
453
+	 * @param \EE_Registration $item
454
+	 * @return string
455
+	 * @throws EE_Error
456
+	 * @throws InvalidArgumentException
457
+	 * @throws InvalidDataTypeException
458
+	 * @throws InvalidInterfaceException
459
+	 * @throws ReflectionException
460
+	 */
461
+	public function column__REG_ID(EE_Registration $item)
462
+	{
463
+		$attendee = $item->attendee();
464
+		$content = $item->ID();
465
+		$content .= '<div class="show-on-mobile-view-only">';
466
+		$content .= '<br>';
467
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470
+		$content .= '</div>';
471
+		return $content;
472
+	}
473 473
 
474 474
 
475
-    /**
476
-     * column__REG_date
477
-     *
478
-     * @access public
479
-     * @param \EE_Registration $item
480
-     * @return string
481
-     * @throws EE_Error
482
-     * @throws InvalidArgumentException
483
-     * @throws InvalidDataTypeException
484
-     * @throws InvalidInterfaceException
485
-     * @throws ReflectionException
486
-     */
487
-    public function column__REG_date(EE_Registration $item)
488
-    {
489
-        $this->_set_related_details($item);
490
-        // Build row actions
491
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
492
-            array(
493
-                'action' => 'view_transaction',
494
-                'TXN_ID' => $this->_transaction_details['id'],
495
-            ),
496
-            TXN_ADMIN_URL
497
-        );
498
-        $view_link = EE_Registry::instance()->CAP->current_user_can(
499
-            'ee_read_transaction',
500
-            'espresso_transactions_view_transaction'
501
-        )
502
-            ? '<a class="ee-status-color-'
503
-              . $this->_transaction_details['status']
504
-              . '" href="'
505
-              . $view_lnk_url
506
-              . '" title="'
507
-              . esc_attr($this->_transaction_details['title_attr'])
508
-              . '">'
509
-              . $item->get_i18n_datetime('REG_date')
510
-              . '</a>' : $item->get_i18n_datetime('REG_date');
511
-        $view_link .= '<br><span class="ee-status-text-small">'
512
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
513
-                      . '</span>';
514
-        return $view_link;
515
-    }
475
+	/**
476
+	 * column__REG_date
477
+	 *
478
+	 * @access public
479
+	 * @param \EE_Registration $item
480
+	 * @return string
481
+	 * @throws EE_Error
482
+	 * @throws InvalidArgumentException
483
+	 * @throws InvalidDataTypeException
484
+	 * @throws InvalidInterfaceException
485
+	 * @throws ReflectionException
486
+	 */
487
+	public function column__REG_date(EE_Registration $item)
488
+	{
489
+		$this->_set_related_details($item);
490
+		// Build row actions
491
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
492
+			array(
493
+				'action' => 'view_transaction',
494
+				'TXN_ID' => $this->_transaction_details['id'],
495
+			),
496
+			TXN_ADMIN_URL
497
+		);
498
+		$view_link = EE_Registry::instance()->CAP->current_user_can(
499
+			'ee_read_transaction',
500
+			'espresso_transactions_view_transaction'
501
+		)
502
+			? '<a class="ee-status-color-'
503
+			  . $this->_transaction_details['status']
504
+			  . '" href="'
505
+			  . $view_lnk_url
506
+			  . '" title="'
507
+			  . esc_attr($this->_transaction_details['title_attr'])
508
+			  . '">'
509
+			  . $item->get_i18n_datetime('REG_date')
510
+			  . '</a>' : $item->get_i18n_datetime('REG_date');
511
+		$view_link .= '<br><span class="ee-status-text-small">'
512
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
513
+					  . '</span>';
514
+		return $view_link;
515
+	}
516 516
 
517 517
 
518
-    /**
519
-     * column_event_name
520
-     *
521
-     * @access public
522
-     * @param \EE_Registration $item
523
-     * @return string
524
-     * @throws EE_Error
525
-     * @throws InvalidArgumentException
526
-     * @throws InvalidDataTypeException
527
-     * @throws InvalidInterfaceException
528
-     * @throws ReflectionException
529
-     */
530
-    public function column_event_name(EE_Registration $item)
531
-    {
532
-        $this->_set_related_details($item);
533
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
534
-        $EVT_ID = $item->event_ID();
535
-        $event_name = $item->event_name();
536
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
537
-        $event_name = wp_trim_words($event_name, 30, '...');
538
-        if ($EVT_ID) {
539
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
540
-                array('action' => 'edit', 'post' => $EVT_ID),
541
-                EVENTS_ADMIN_URL
542
-            );
543
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
544
-                ? '<a class="ee-status-color-'
545
-                  . $this->_event_details['status']
546
-                  . '" href="'
547
-                  . $edit_event_url
548
-                  . '" title="'
549
-                  . esc_attr($this->_event_details['title_attr'])
550
-                  . '">'
551
-                  . $event_name
552
-                  . '</a>' : $event_name;
553
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
555
-            $actions['event_filter'] .= sprintf(
556
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557
-                $event_name
558
-            );
559
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
560
-        } else {
561
-            $edit_event = $event_name;
562
-            $actions['event_filter'] = '';
563
-        }
564
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
565
-    }
518
+	/**
519
+	 * column_event_name
520
+	 *
521
+	 * @access public
522
+	 * @param \EE_Registration $item
523
+	 * @return string
524
+	 * @throws EE_Error
525
+	 * @throws InvalidArgumentException
526
+	 * @throws InvalidDataTypeException
527
+	 * @throws InvalidInterfaceException
528
+	 * @throws ReflectionException
529
+	 */
530
+	public function column_event_name(EE_Registration $item)
531
+	{
532
+		$this->_set_related_details($item);
533
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
534
+		$EVT_ID = $item->event_ID();
535
+		$event_name = $item->event_name();
536
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
537
+		$event_name = wp_trim_words($event_name, 30, '...');
538
+		if ($EVT_ID) {
539
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
540
+				array('action' => 'edit', 'post' => $EVT_ID),
541
+				EVENTS_ADMIN_URL
542
+			);
543
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
544
+				? '<a class="ee-status-color-'
545
+				  . $this->_event_details['status']
546
+				  . '" href="'
547
+				  . $edit_event_url
548
+				  . '" title="'
549
+				  . esc_attr($this->_event_details['title_attr'])
550
+				  . '">'
551
+				  . $event_name
552
+				  . '</a>' : $event_name;
553
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
555
+			$actions['event_filter'] .= sprintf(
556
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557
+				$event_name
558
+			);
559
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
560
+		} else {
561
+			$edit_event = $event_name;
562
+			$actions['event_filter'] = '';
563
+		}
564
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
565
+	}
566 566
 
567 567
 
568
-    /**
569
-     * column_DTT_EVT_start
570
-     *
571
-     * @access public
572
-     * @param \EE_Registration $item
573
-     * @return string
574
-     * @throws EE_Error
575
-     * @throws InvalidArgumentException
576
-     * @throws InvalidDataTypeException
577
-     * @throws InvalidInterfaceException
578
-     * @throws ReflectionException
579
-     */
580
-    public function column_DTT_EVT_start(EE_Registration $item)
581
-    {
582
-        $datetime_strings = array();
583
-        $ticket = $item->ticket(true);
584
-        if ($ticket instanceof EE_Ticket) {
585
-            $remove_defaults = array('default_where_conditions' => 'none');
586
-            $datetimes = $ticket->datetimes($remove_defaults);
587
-            foreach ($datetimes as $datetime) {
588
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
589
-            }
590
-            return $this->generateDisplayForDatetimes($datetime_strings);
591
-        }
592
-        return __('There is no ticket on this registration', 'event_espresso');
593
-    }
568
+	/**
569
+	 * column_DTT_EVT_start
570
+	 *
571
+	 * @access public
572
+	 * @param \EE_Registration $item
573
+	 * @return string
574
+	 * @throws EE_Error
575
+	 * @throws InvalidArgumentException
576
+	 * @throws InvalidDataTypeException
577
+	 * @throws InvalidInterfaceException
578
+	 * @throws ReflectionException
579
+	 */
580
+	public function column_DTT_EVT_start(EE_Registration $item)
581
+	{
582
+		$datetime_strings = array();
583
+		$ticket = $item->ticket(true);
584
+		if ($ticket instanceof EE_Ticket) {
585
+			$remove_defaults = array('default_where_conditions' => 'none');
586
+			$datetimes = $ticket->datetimes($remove_defaults);
587
+			foreach ($datetimes as $datetime) {
588
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
589
+			}
590
+			return $this->generateDisplayForDatetimes($datetime_strings);
591
+		}
592
+		return __('There is no ticket on this registration', 'event_espresso');
593
+	}
594 594
 
595 595
 
596
-    /**
597
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
598
-     *
599
-     * @param array $datetime_strings
600
-     * @return string
601
-     */
602
-    public function generateDisplayForDateTimes(array $datetime_strings)
603
-    {
604
-        $content = '<div class="ee-registration-event-datetimes-container">';
605
-        $expand_toggle = count($datetime_strings) > 1
606
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
607
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608
-            : '';
609
-        // get first item for initial visibility
610
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
611
-        $content .= $expand_toggle;
612
-        if ($datetime_strings) {
613
-            $content .= '<div style="clear:both"></div>';
614
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
615
-            $content .= implode("<br />", $datetime_strings);
616
-            $content .= '</div>';
617
-        }
618
-        $content .= '</div>';
619
-        return $content;
620
-    }
596
+	/**
597
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
598
+	 *
599
+	 * @param array $datetime_strings
600
+	 * @return string
601
+	 */
602
+	public function generateDisplayForDateTimes(array $datetime_strings)
603
+	{
604
+		$content = '<div class="ee-registration-event-datetimes-container">';
605
+		$expand_toggle = count($datetime_strings) > 1
606
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
607
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608
+			: '';
609
+		// get first item for initial visibility
610
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
611
+		$content .= $expand_toggle;
612
+		if ($datetime_strings) {
613
+			$content .= '<div style="clear:both"></div>';
614
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
615
+			$content .= implode("<br />", $datetime_strings);
616
+			$content .= '</div>';
617
+		}
618
+		$content .= '</div>';
619
+		return $content;
620
+	}
621 621
 
622 622
 
623
-    /**
624
-     * column_ATT_fname
625
-     *
626
-     * @access public
627
-     * @param \EE_Registration $item
628
-     * @return string
629
-     * @throws EE_Error
630
-     * @throws InvalidArgumentException
631
-     * @throws InvalidDataTypeException
632
-     * @throws InvalidInterfaceException
633
-     * @throws ReflectionException
634
-     */
635
-    public function column_ATT_fname(EE_Registration $item)
636
-    {
637
-        $attendee = $item->attendee();
638
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
639
-            array(
640
-                'action'  => 'view_registration',
641
-                '_REG_ID' => $item->ID(),
642
-            ),
643
-            REG_ADMIN_URL
644
-        );
645
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
646
-        $link = EE_Registry::instance()->CAP->current_user_can(
647
-            'ee_read_registration',
648
-            'espresso_registrations_view_registration',
649
-            $item->ID()
650
-        )
651
-            ? '<a href="'
652
-              . $edit_lnk_url
653
-              . '" title="'
654
-              . esc_attr__('View Registration Details', 'event_espresso')
655
-              . '">'
656
-              . $attendee_name
657
-              . '</a>' : $attendee_name;
658
-        $link .= $item->count() === 1
659
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
660
-        $t = $item->get_first_related('Transaction');
661
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662
-        // append group count to name
663
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664
-        // append reg_code
665
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666
-        // reg status text for accessibility
667
-        $link .= '<br><span class="ee-status-text-small">'
668
-                 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
669
-                 . '</span>';
670
-        $action = [ '_REG_ID' => $item->ID() ];
671
-        if (isset($this->_req_data['event_id'])) {
672
-            $action['event_id'] = $item->event_ID();
673
-        }
674
-        // trash/restore/delete actions
675
-        $actions = array();
676
-        if ($this->_view !== 'trash'
677
-            && $payment_count === 0
678
-            && EE_Registry::instance()->CAP->current_user_can(
679
-                'ee_delete_registration',
680
-                'espresso_registrations_trash_registrations',
681
-                $item->ID()
682
-            )) {
683
-            $action['action'] = 'trash_registrations';
684
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
685
-                $action,
686
-                REG_ADMIN_URL
687
-            );
688
-            $actions['trash'] = '<a href="'
689
-                                . $trash_lnk_url
690
-                                . '" title="'
691
-                                . esc_attr__('Trash Registration', 'event_espresso')
692
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
693
-        } elseif ($this->_view === 'trash') {
694
-            // restore registration link
695
-            if (EE_Registry::instance()->CAP->current_user_can(
696
-                'ee_delete_registration',
697
-                'espresso_registrations_restore_registrations',
698
-                $item->ID()
699
-            )) {
700
-                $action['action'] = 'restore_registrations';
701
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
702
-                    $action,
703
-                    REG_ADMIN_URL
704
-                );
705
-                $actions['restore'] = '<a href="'
706
-                                      . $restore_lnk_url
707
-                                      . '" title="'
708
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
-                                      . __('Restore', 'event_espresso') . '</a>';
710
-            }
711
-            if (EE_Registry::instance()->CAP->current_user_can(
712
-                'ee_delete_registration',
713
-                'espresso_registrations_ee_delete_registrations',
714
-                $item->ID()
715
-            )) {
716
-                $action['action'] = 'delete_registrations';
717
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
718
-                    $action,
719
-                    REG_ADMIN_URL
720
-                );
721
-                $actions['delete'] = '<a href="'
722
-                                     . $delete_lnk_url
723
-                                     . '" title="'
724
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
725
-                                     . '">'
726
-                                     . __('Delete', 'event_espresso')
727
-                                     . '</a>';
728
-            }
729
-        }
730
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
731
-    }
623
+	/**
624
+	 * column_ATT_fname
625
+	 *
626
+	 * @access public
627
+	 * @param \EE_Registration $item
628
+	 * @return string
629
+	 * @throws EE_Error
630
+	 * @throws InvalidArgumentException
631
+	 * @throws InvalidDataTypeException
632
+	 * @throws InvalidInterfaceException
633
+	 * @throws ReflectionException
634
+	 */
635
+	public function column_ATT_fname(EE_Registration $item)
636
+	{
637
+		$attendee = $item->attendee();
638
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
639
+			array(
640
+				'action'  => 'view_registration',
641
+				'_REG_ID' => $item->ID(),
642
+			),
643
+			REG_ADMIN_URL
644
+		);
645
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
646
+		$link = EE_Registry::instance()->CAP->current_user_can(
647
+			'ee_read_registration',
648
+			'espresso_registrations_view_registration',
649
+			$item->ID()
650
+		)
651
+			? '<a href="'
652
+			  . $edit_lnk_url
653
+			  . '" title="'
654
+			  . esc_attr__('View Registration Details', 'event_espresso')
655
+			  . '">'
656
+			  . $attendee_name
657
+			  . '</a>' : $attendee_name;
658
+		$link .= $item->count() === 1
659
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
660
+		$t = $item->get_first_related('Transaction');
661
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662
+		// append group count to name
663
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664
+		// append reg_code
665
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666
+		// reg status text for accessibility
667
+		$link .= '<br><span class="ee-status-text-small">'
668
+				 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
669
+				 . '</span>';
670
+		$action = [ '_REG_ID' => $item->ID() ];
671
+		if (isset($this->_req_data['event_id'])) {
672
+			$action['event_id'] = $item->event_ID();
673
+		}
674
+		// trash/restore/delete actions
675
+		$actions = array();
676
+		if ($this->_view !== 'trash'
677
+			&& $payment_count === 0
678
+			&& EE_Registry::instance()->CAP->current_user_can(
679
+				'ee_delete_registration',
680
+				'espresso_registrations_trash_registrations',
681
+				$item->ID()
682
+			)) {
683
+			$action['action'] = 'trash_registrations';
684
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
685
+				$action,
686
+				REG_ADMIN_URL
687
+			);
688
+			$actions['trash'] = '<a href="'
689
+								. $trash_lnk_url
690
+								. '" title="'
691
+								. esc_attr__('Trash Registration', 'event_espresso')
692
+								. '">' . __('Trash', 'event_espresso') . '</a>';
693
+		} elseif ($this->_view === 'trash') {
694
+			// restore registration link
695
+			if (EE_Registry::instance()->CAP->current_user_can(
696
+				'ee_delete_registration',
697
+				'espresso_registrations_restore_registrations',
698
+				$item->ID()
699
+			)) {
700
+				$action['action'] = 'restore_registrations';
701
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
702
+					$action,
703
+					REG_ADMIN_URL
704
+				);
705
+				$actions['restore'] = '<a href="'
706
+									  . $restore_lnk_url
707
+									  . '" title="'
708
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
+									  . __('Restore', 'event_espresso') . '</a>';
710
+			}
711
+			if (EE_Registry::instance()->CAP->current_user_can(
712
+				'ee_delete_registration',
713
+				'espresso_registrations_ee_delete_registrations',
714
+				$item->ID()
715
+			)) {
716
+				$action['action'] = 'delete_registrations';
717
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
718
+					$action,
719
+					REG_ADMIN_URL
720
+				);
721
+				$actions['delete'] = '<a href="'
722
+									 . $delete_lnk_url
723
+									 . '" title="'
724
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
725
+									 . '">'
726
+									 . __('Delete', 'event_espresso')
727
+									 . '</a>';
728
+			}
729
+		}
730
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
731
+	}
732 732
 
733 733
 
734
-    /**
735
-     * column_ATT_email
736
-     *
737
-     * @access public
738
-     * @param \EE_Registration $item
739
-     * @return string
740
-     * @throws EE_Error
741
-     * @throws InvalidArgumentException
742
-     * @throws InvalidDataTypeException
743
-     * @throws InvalidInterfaceException
744
-     * @throws ReflectionException
745
-     */
746
-    public function column_ATT_email(EE_Registration $item)
747
-    {
748
-        $attendee = $item->get_first_related('Attendee');
749
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
750
-            : $attendee->email();
751
-    }
734
+	/**
735
+	 * column_ATT_email
736
+	 *
737
+	 * @access public
738
+	 * @param \EE_Registration $item
739
+	 * @return string
740
+	 * @throws EE_Error
741
+	 * @throws InvalidArgumentException
742
+	 * @throws InvalidDataTypeException
743
+	 * @throws InvalidInterfaceException
744
+	 * @throws ReflectionException
745
+	 */
746
+	public function column_ATT_email(EE_Registration $item)
747
+	{
748
+		$attendee = $item->get_first_related('Attendee');
749
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
750
+			: $attendee->email();
751
+	}
752 752
 
753 753
 
754
-    /**
755
-     * column__REG_count
756
-     *
757
-     * @access public
758
-     * @param \EE_Registration $item
759
-     * @return string
760
-     */
761
-    public function column__REG_count(EE_Registration $item)
762
-    {
763
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
764
-    }
754
+	/**
755
+	 * column__REG_count
756
+	 *
757
+	 * @access public
758
+	 * @param \EE_Registration $item
759
+	 * @return string
760
+	 */
761
+	public function column__REG_count(EE_Registration $item)
762
+	{
763
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
764
+	}
765 765
 
766 766
 
767
-    /**
768
-     * column_PRC_amount
769
-     *
770
-     * @access public
771
-     * @param \EE_Registration $item
772
-     * @return string
773
-     * @throws EE_Error
774
-     */
775
-    public function column_PRC_amount(EE_Registration $item)
776
-    {
777
-        $ticket = $item->ticket();
778
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
779
-                                                                              . $ticket->name()
780
-                                                                              . '</span><br />' : '';
781
-        if ($item->final_price() > 0) {
782
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
783
-        } else {
784
-            // free event
785
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
786
-                        . __('free', 'event_espresso')
787
-                        . '</span>';
788
-        }
789
-        return $content;
790
-    }
767
+	/**
768
+	 * column_PRC_amount
769
+	 *
770
+	 * @access public
771
+	 * @param \EE_Registration $item
772
+	 * @return string
773
+	 * @throws EE_Error
774
+	 */
775
+	public function column_PRC_amount(EE_Registration $item)
776
+	{
777
+		$ticket = $item->ticket();
778
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
779
+																			  . $ticket->name()
780
+																			  . '</span><br />' : '';
781
+		if ($item->final_price() > 0) {
782
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
783
+		} else {
784
+			// free event
785
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
786
+						. __('free', 'event_espresso')
787
+						. '</span>';
788
+		}
789
+		return $content;
790
+	}
791 791
 
792 792
 
793
-    /**
794
-     * column__REG_final_price
795
-     *
796
-     * @access public
797
-     * @param \EE_Registration $item
798
-     * @return string
799
-     * @throws EE_Error
800
-     */
801
-    public function column__REG_final_price(EE_Registration $item)
802
-    {
803
-        $ticket = $item->ticket();
804
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
805
-            ? ''
806
-            : '<span class="TKT_name">'
807
-              . $ticket->name()
808
-              . '</span><br />';
809
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
810
-        return $content;
811
-    }
793
+	/**
794
+	 * column__REG_final_price
795
+	 *
796
+	 * @access public
797
+	 * @param \EE_Registration $item
798
+	 * @return string
799
+	 * @throws EE_Error
800
+	 */
801
+	public function column__REG_final_price(EE_Registration $item)
802
+	{
803
+		$ticket = $item->ticket();
804
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
805
+			? ''
806
+			: '<span class="TKT_name">'
807
+			  . $ticket->name()
808
+			  . '</span><br />';
809
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
810
+		return $content;
811
+	}
812 812
 
813 813
 
814
-    /**
815
-     * column__REG_paid
816
-     *
817
-     * @access public
818
-     * @param \EE_Registration $item
819
-     * @return string
820
-     * @throws EE_Error
821
-     */
822
-    public function column__REG_paid(EE_Registration $item)
823
-    {
824
-        $payment_method = $item->payment_method();
825
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
826
-            : __('Unknown', 'event_espresso');
827
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
828
-        if ($item->paid() > 0) {
829
-            $content .= '<br><span class="ee-status-text-small">'
830
-                        . sprintf(
831
-                            __('...via %s', 'event_espresso'),
832
-                            $payment_method_name
833
-                        )
834
-                        . '</span>';
835
-        }
836
-        return $content;
837
-    }
814
+	/**
815
+	 * column__REG_paid
816
+	 *
817
+	 * @access public
818
+	 * @param \EE_Registration $item
819
+	 * @return string
820
+	 * @throws EE_Error
821
+	 */
822
+	public function column__REG_paid(EE_Registration $item)
823
+	{
824
+		$payment_method = $item->payment_method();
825
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
826
+			: __('Unknown', 'event_espresso');
827
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
828
+		if ($item->paid() > 0) {
829
+			$content .= '<br><span class="ee-status-text-small">'
830
+						. sprintf(
831
+							__('...via %s', 'event_espresso'),
832
+							$payment_method_name
833
+						)
834
+						. '</span>';
835
+		}
836
+		return $content;
837
+	}
838 838
 
839 839
 
840
-    /**
841
-     * column_TXN_total
842
-     *
843
-     * @access public
844
-     * @param \EE_Registration $item
845
-     * @return string
846
-     * @throws EE_Error
847
-     * @throws EntityNotFoundException
848
-     * @throws InvalidArgumentException
849
-     * @throws InvalidDataTypeException
850
-     * @throws InvalidInterfaceException
851
-     */
852
-    public function column_TXN_total(EE_Registration $item)
853
-    {
854
-        if ($item->transaction()) {
855
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
856
-                array(
857
-                    'action' => 'view_transaction',
858
-                    'TXN_ID' => $item->transaction_ID(),
859
-                ),
860
-                TXN_ADMIN_URL
861
-            );
862
-            return EE_Registry::instance()->CAP->current_user_can(
863
-                'ee_read_transaction',
864
-                'espresso_transactions_view_transaction',
865
-                $item->transaction_ID()
866
-            )
867
-                ? '<span class="reg-pad-rght"><a class="status-'
868
-                  . $item->transaction()->status_ID()
869
-                  . '" href="'
870
-                  . $view_txn_lnk_url
871
-                  . '"  title="'
872
-                  . esc_attr__('View Transaction', 'event_espresso')
873
-                  . '">'
874
-                  . $item->transaction()->pretty_total()
875
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
876
-        } else {
877
-            return __("None", "event_espresso");
878
-        }
879
-    }
840
+	/**
841
+	 * column_TXN_total
842
+	 *
843
+	 * @access public
844
+	 * @param \EE_Registration $item
845
+	 * @return string
846
+	 * @throws EE_Error
847
+	 * @throws EntityNotFoundException
848
+	 * @throws InvalidArgumentException
849
+	 * @throws InvalidDataTypeException
850
+	 * @throws InvalidInterfaceException
851
+	 */
852
+	public function column_TXN_total(EE_Registration $item)
853
+	{
854
+		if ($item->transaction()) {
855
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
856
+				array(
857
+					'action' => 'view_transaction',
858
+					'TXN_ID' => $item->transaction_ID(),
859
+				),
860
+				TXN_ADMIN_URL
861
+			);
862
+			return EE_Registry::instance()->CAP->current_user_can(
863
+				'ee_read_transaction',
864
+				'espresso_transactions_view_transaction',
865
+				$item->transaction_ID()
866
+			)
867
+				? '<span class="reg-pad-rght"><a class="status-'
868
+				  . $item->transaction()->status_ID()
869
+				  . '" href="'
870
+				  . $view_txn_lnk_url
871
+				  . '"  title="'
872
+				  . esc_attr__('View Transaction', 'event_espresso')
873
+				  . '">'
874
+				  . $item->transaction()->pretty_total()
875
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
876
+		} else {
877
+			return __("None", "event_espresso");
878
+		}
879
+	}
880 880
 
881 881
 
882
-    /**
883
-     * column_TXN_paid
884
-     *
885
-     * @access public
886
-     * @param \EE_Registration $item
887
-     * @return string
888
-     * @throws EE_Error
889
-     * @throws EntityNotFoundException
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     */
894
-    public function column_TXN_paid(EE_Registration $item)
895
-    {
896
-        if ($item->count() === 1) {
897
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
898
-            if ($transaction->paid() >= $transaction->total()) {
899
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
900
-            } else {
901
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
902
-                    array(
903
-                        'action' => 'view_transaction',
904
-                        'TXN_ID' => $item->transaction_ID(),
905
-                    ),
906
-                    TXN_ADMIN_URL
907
-                );
908
-                return EE_Registry::instance()->CAP->current_user_can(
909
-                    'ee_read_transaction',
910
-                    'espresso_transactions_view_transaction',
911
-                    $item->transaction_ID()
912
-                )
913
-                    ? '<span class="reg-pad-rght"><a class="status-'
914
-                      . $transaction->status_ID()
915
-                      . '" href="'
916
-                      . $view_txn_lnk_url
917
-                      . '"  title="'
918
-                      . esc_attr__('View Transaction', 'event_espresso')
919
-                      . '">'
920
-                      . $item->transaction()->pretty_paid()
921
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
922
-            }
923
-        }
924
-        return '&nbsp;';
925
-    }
882
+	/**
883
+	 * column_TXN_paid
884
+	 *
885
+	 * @access public
886
+	 * @param \EE_Registration $item
887
+	 * @return string
888
+	 * @throws EE_Error
889
+	 * @throws EntityNotFoundException
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 */
894
+	public function column_TXN_paid(EE_Registration $item)
895
+	{
896
+		if ($item->count() === 1) {
897
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
898
+			if ($transaction->paid() >= $transaction->total()) {
899
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
900
+			} else {
901
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
902
+					array(
903
+						'action' => 'view_transaction',
904
+						'TXN_ID' => $item->transaction_ID(),
905
+					),
906
+					TXN_ADMIN_URL
907
+				);
908
+				return EE_Registry::instance()->CAP->current_user_can(
909
+					'ee_read_transaction',
910
+					'espresso_transactions_view_transaction',
911
+					$item->transaction_ID()
912
+				)
913
+					? '<span class="reg-pad-rght"><a class="status-'
914
+					  . $transaction->status_ID()
915
+					  . '" href="'
916
+					  . $view_txn_lnk_url
917
+					  . '"  title="'
918
+					  . esc_attr__('View Transaction', 'event_espresso')
919
+					  . '">'
920
+					  . $item->transaction()->pretty_paid()
921
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
922
+			}
923
+		}
924
+		return '&nbsp;';
925
+	}
926 926
 
927 927
 
928
-    /**
929
-     * column_actions
930
-     *
931
-     * @access public
932
-     * @param \EE_Registration $item
933
-     * @return string
934
-     * @throws EE_Error
935
-     * @throws InvalidArgumentException
936
-     * @throws InvalidDataTypeException
937
-     * @throws InvalidInterfaceException
938
-     * @throws ReflectionException
939
-     */
940
-    public function column_actions(EE_Registration $item)
941
-    {
942
-        $actions = array();
943
-        $attendee = $item->attendee();
944
-        $this->_set_related_details($item);
945
-        // Build row actions
946
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
947
-            array(
948
-                'action'  => 'view_registration',
949
-                '_REG_ID' => $item->ID(),
950
-            ),
951
-            REG_ADMIN_URL
952
-        );
953
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
954
-            array(
955
-                'action' => 'edit_attendee',
956
-                'post'   => $item->attendee_ID(),
957
-            ),
958
-            REG_ADMIN_URL
959
-        );
960
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
961
-        // $resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
962
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
963
-            array(
964
-                'action'  => 'resend_registration',
965
-                '_REG_ID' => $item->ID(),
966
-            ),
967
-            REG_ADMIN_URL,
968
-            true
969
-        );
970
-        // Build row actions
971
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
972
-            'ee_read_registration',
973
-            'espresso_registrations_view_registration',
974
-            $item->ID()
975
-        ) ? '<li><a href="'
976
-            . $view_lnk_url
977
-            . '" title="'
978
-            . esc_attr__('View Registration Details', 'event_espresso')
979
-            . '" class="tiny-text">
928
+	/**
929
+	 * column_actions
930
+	 *
931
+	 * @access public
932
+	 * @param \EE_Registration $item
933
+	 * @return string
934
+	 * @throws EE_Error
935
+	 * @throws InvalidArgumentException
936
+	 * @throws InvalidDataTypeException
937
+	 * @throws InvalidInterfaceException
938
+	 * @throws ReflectionException
939
+	 */
940
+	public function column_actions(EE_Registration $item)
941
+	{
942
+		$actions = array();
943
+		$attendee = $item->attendee();
944
+		$this->_set_related_details($item);
945
+		// Build row actions
946
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
947
+			array(
948
+				'action'  => 'view_registration',
949
+				'_REG_ID' => $item->ID(),
950
+			),
951
+			REG_ADMIN_URL
952
+		);
953
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
954
+			array(
955
+				'action' => 'edit_attendee',
956
+				'post'   => $item->attendee_ID(),
957
+			),
958
+			REG_ADMIN_URL
959
+		);
960
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
961
+		// $resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
962
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
963
+			array(
964
+				'action'  => 'resend_registration',
965
+				'_REG_ID' => $item->ID(),
966
+			),
967
+			REG_ADMIN_URL,
968
+			true
969
+		);
970
+		// Build row actions
971
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
972
+			'ee_read_registration',
973
+			'espresso_registrations_view_registration',
974
+			$item->ID()
975
+		) ? '<li><a href="'
976
+			. $view_lnk_url
977
+			. '" title="'
978
+			. esc_attr__('View Registration Details', 'event_espresso')
979
+			. '" class="tiny-text">
980 980
 				<div class="dashicons dashicons-clipboard"></div>
981 981
 			</a>
982 982
 			</li>'
983
-            : '';
984
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
985
-            'ee_edit_contacts',
986
-            'espresso_registrations_edit_attendee'
987
-        )
988
-                               && $attendee instanceof EE_Attendee
989
-            ? '
983
+			: '';
984
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
985
+			'ee_edit_contacts',
986
+			'espresso_registrations_edit_attendee'
987
+		)
988
+							   && $attendee instanceof EE_Attendee
989
+			? '
990 990
 			<li>
991 991
 			<a href="' . $edit_lnk_url . '" title="'
992
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
992
+			  . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
993 993
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
994 994
 			</a>
995 995
 			</li>' : '';
996
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
997
-                                     && EE_Registry::instance()->CAP->current_user_can(
998
-                                         'ee_send_message',
999
-                                         'espresso_registrations_resend_registration',
1000
-                                         $item->ID()
1001
-                                     )
1002
-            ? '
996
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
997
+									 && EE_Registry::instance()->CAP->current_user_can(
998
+										 'ee_send_message',
999
+										 'espresso_registrations_resend_registration',
1000
+										 $item->ID()
1001
+									 )
1002
+			? '
1003 1003
 			<li>
1004 1004
 			<a href="'
1005
-              . $resend_reg_lnk_url
1006
-              . '" title="'
1007
-              . esc_attr__('Resend Registration Details', 'event_espresso')
1008
-              . '" class="tiny-text">
1005
+			  . $resend_reg_lnk_url
1006
+			  . '" title="'
1007
+			  . esc_attr__('Resend Registration Details', 'event_espresso')
1008
+			  . '" class="tiny-text">
1009 1009
 				<div class="dashicons dashicons-email-alt"></div>
1010 1010
 			</a>
1011 1011
 			</li>' : '';
1012
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
1013
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1014
-            array(
1015
-                'action' => 'view_transaction',
1016
-                'TXN_ID' => $this->_transaction_details['id'],
1017
-            ),
1018
-            TXN_ADMIN_URL
1019
-        );
1020
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
1021
-            'ee_read_transaction',
1022
-            'espresso_transactions_view_transaction',
1023
-            $this->_transaction_details['id']
1024
-        )
1025
-            ? '
1012
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
1013
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1014
+			array(
1015
+				'action' => 'view_transaction',
1016
+				'TXN_ID' => $this->_transaction_details['id'],
1017
+			),
1018
+			TXN_ADMIN_URL
1019
+		);
1020
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
1021
+			'ee_read_transaction',
1022
+			'espresso_transactions_view_transaction',
1023
+			$this->_transaction_details['id']
1024
+		)
1025
+			? '
1026 1026
 			<li>
1027 1027
 			<a class="ee-status-color-'
1028
-              . $this->_transaction_details['status']
1029
-              . ' tiny-text" href="'
1030
-              . $view_txn_lnk_url
1031
-              . '"  title="'
1032
-              . $this->_transaction_details['title_attr']
1033
-              . '">
1028
+			  . $this->_transaction_details['status']
1029
+			  . ' tiny-text" href="'
1030
+			  . $view_txn_lnk_url
1031
+			  . '"  title="'
1032
+			  . $this->_transaction_details['title_attr']
1033
+			  . '">
1034 1034
 				<div class="dashicons dashicons-cart"></div>
1035 1035
 			</a>
1036 1036
 			</li>' : '';
1037
-        // invoice link
1038
-        $actions['dl_invoice_lnk'] = '';
1039
-        $dl_invoice_lnk_url = $item->invoice_url();
1040
-        // only show invoice link if message type is active.
1041
-        if ($attendee instanceof EE_Attendee
1042
-            && $item->is_primary_registrant()
1043
-            && EEH_MSG_Template::is_mt_active('invoice')
1044
-        ) {
1045
-            $actions['dl_invoice_lnk'] = '
1037
+		// invoice link
1038
+		$actions['dl_invoice_lnk'] = '';
1039
+		$dl_invoice_lnk_url = $item->invoice_url();
1040
+		// only show invoice link if message type is active.
1041
+		if ($attendee instanceof EE_Attendee
1042
+			&& $item->is_primary_registrant()
1043
+			&& EEH_MSG_Template::is_mt_active('invoice')
1044
+		) {
1045
+			$actions['dl_invoice_lnk'] = '
1046 1046
 		<li>
1047 1047
 			<a title="'
1048
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
1049
-                                         . '" target="_blank" href="'
1050
-                                         . $dl_invoice_lnk_url
1051
-                                         . '" class="tiny-text">
1048
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
1049
+										 . '" target="_blank" href="'
1050
+										 . $dl_invoice_lnk_url
1051
+										 . '" class="tiny-text">
1052 1052
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1053 1053
 			</a>
1054 1054
 		</li>';
1055
-        }
1056
-        $actions['filtered_messages_link'] = '';
1057
-        // message list table link (filtered by REG_ID
1058
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1059
-            $actions['filtered_messages_link'] = '<li>'
1060
-                                                 . EEH_MSG_Template::get_message_action_link(
1061
-                                                     'see_notifications_for',
1062
-                                                     null,
1063
-                                                     array('_REG_ID' => $item->ID())
1064
-                                                 ) . '</li>';
1065
-        }
1066
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1067
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1068
-    }
1055
+		}
1056
+		$actions['filtered_messages_link'] = '';
1057
+		// message list table link (filtered by REG_ID
1058
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1059
+			$actions['filtered_messages_link'] = '<li>'
1060
+												 . EEH_MSG_Template::get_message_action_link(
1061
+													 'see_notifications_for',
1062
+													 null,
1063
+													 array('_REG_ID' => $item->ID())
1064
+												 ) . '</li>';
1065
+		}
1066
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1067
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1068
+	}
1069 1069
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function __construct(Registrations_Admin_Page $admin_page)
55 55
     {
56
-        if (! empty($_GET['event_id'])) {
56
+        if ( ! empty($_GET['event_id'])) {
57 57
             $extra_query_args = array();
58 58
             foreach ($admin_page->get_views() as $key => $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
59
+                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
60 60
             }
61 61
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62 62
         }
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
                 )
157 157
             )
158 158
         );
159
-        if (!empty($filters)) {
159
+        if ( ! empty($filters)) {
160 160
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161 161
         }
162 162
         $this->_primary_column = '_REG_ID';
163 163
         $this->_sortable_columns = array(
164
-            '_REG_date'     => array('_REG_date' => true),   // true means its already sorted
164
+            '_REG_date'     => array('_REG_date' => true), // true means its already sorted
165 165
             /**
166 166
              * Allows users to change the default sort if they wish.
167 167
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     {
194 194
         $class = parent::_get_row_class($item);
195 195
         // add status class
196
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
196
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
197 197
         if ($this->_has_checkbox_column) {
198 198
             $class .= ' has-checkbox-column';
199 199
         }
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         // setup date query.
359 359
         $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360 360
             'REG_date',
361
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
361
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
362 362
             'Y-m-d H:i:s'
363 363
         );
364 364
         $end_string = EEM_Registration::instance()->convert_datetime_for_query(
365 365
             'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
366
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
367 367
             'Y-m-d H:i:s'
368 368
         );
369 369
         $_where['REG_date'] = array(
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
             array(
401 401
                 EEM_Registration::instance()->convert_datetime_for_query(
402 402
                     'REG_date',
403
-                    $current_date . $time_start,
403
+                    $current_date.$time_start,
404 404
                     'Y-m-d H:i:s'
405 405
                 ),
406 406
                 EEM_Registration::instance()->convert_datetime_for_query(
407 407
                     'REG_date',
408
-                    $current_date . $time_end,
408
+                    $current_date.$time_end,
409 409
                     'Y-m-d H:i:s'
410 410
                 ),
411 411
             ),
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
         $content .= '<div class="show-on-mobile-view-only">';
466 466
         $content .= '<br>';
467 467
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
468
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470 470
         $content .= '</div>';
471 471
         return $content;
472 472
     }
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
                   . $event_name
552 552
                   . '</a>' : $event_name;
553 553
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
554
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
555 555
             $actions['event_filter'] .= sprintf(
556 556
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557 557
                 $event_name
558 558
             );
559
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
559
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
560 560
         } else {
561 561
             $edit_event = $event_name;
562 562
             $actions['event_filter'] = '';
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
     {
604 604
         $content = '<div class="ee-registration-event-datetimes-container">';
605 605
         $expand_toggle = count($datetime_strings) > 1
606
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
606
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
607 607
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608 608
             : '';
609 609
         // get first item for initial visibility
610
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
610
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
611 611
         $content .= $expand_toggle;
612 612
         if ($datetime_strings) {
613 613
             $content .= '<div style="clear:both"></div>';
@@ -660,14 +660,14 @@  discard block
 block discarded – undo
660 660
         $t = $item->get_first_related('Transaction');
661 661
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662 662
         // append group count to name
663
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
663
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664 664
         // append reg_code
665
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
665
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666 666
         // reg status text for accessibility
667 667
         $link .= '<br><span class="ee-status-text-small">'
668 668
                  . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
669 669
                  . '</span>';
670
-        $action = [ '_REG_ID' => $item->ID() ];
670
+        $action = ['_REG_ID' => $item->ID()];
671 671
         if (isset($this->_req_data['event_id'])) {
672 672
             $action['event_id'] = $item->event_ID();
673 673
         }
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
                                 . $trash_lnk_url
690 690
                                 . '" title="'
691 691
                                 . esc_attr__('Trash Registration', 'event_espresso')
692
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
692
+                                . '">'.__('Trash', 'event_espresso').'</a>';
693 693
         } elseif ($this->_view === 'trash') {
694 694
             // restore registration link
695 695
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -705,8 +705,8 @@  discard block
 block discarded – undo
705 705
                 $actions['restore'] = '<a href="'
706 706
                                       . $restore_lnk_url
707 707
                                       . '" title="'
708
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
-                                      . __('Restore', 'event_espresso') . '</a>';
708
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
709
+                                      . __('Restore', 'event_espresso').'</a>';
710 710
             }
711 711
             if (EE_Registry::instance()->CAP->current_user_can(
712 712
                 'ee_delete_registration',
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
                                                                               . $ticket->name()
780 780
                                                                               . '</span><br />' : '';
781 781
         if ($item->final_price() > 0) {
782
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
782
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
783 783
         } else {
784 784
             // free event
785 785
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
             : '<span class="TKT_name">'
807 807
               . $ticket->name()
808 808
               . '</span><br />';
809
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
809
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
810 810
         return $content;
811 811
     }
812 812
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
         $payment_method = $item->payment_method();
825 825
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
826 826
             : __('Unknown', 'event_espresso');
827
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
827
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
828 828
         if ($item->paid() > 0) {
829 829
             $content .= '<br><span class="ee-status-text-small">'
830 830
                         . sprintf(
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
                   . esc_attr__('View Transaction', 'event_espresso')
873 873
                   . '">'
874 874
                   . $item->transaction()->pretty_total()
875
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
875
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
876 876
         } else {
877 877
             return __("None", "event_espresso");
878 878
         }
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                       . esc_attr__('View Transaction', 'event_espresso')
919 919
                       . '">'
920 920
                       . $item->transaction()->pretty_paid()
921
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
921
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
922 922
             }
923 923
         }
924 924
         return '&nbsp;';
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
                                && $attendee instanceof EE_Attendee
989 989
             ? '
990 990
 			<li>
991
-			<a href="' . $edit_lnk_url . '" title="'
992
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
991
+			<a href="' . $edit_lnk_url.'" title="'
992
+              . esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
993 993
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
994 994
 			</a>
995 995
 			</li>' : '';
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
                                                      'see_notifications_for',
1062 1062
                                                      null,
1063 1063
                                                      array('_REG_ID' => $item->ID())
1064
-                                                 ) . '</li>';
1064
+                                                 ).'</li>';
1065 1065
         }
1066 1066
         $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1067 1067
         return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
Please login to merge, or discard this patch.
core/EE_Capabilities.core.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      * @since                        4.5.0
806 806
      *
807 807
      * @param string $meta_cap   What meta capability is this mapping.
808
-     * @param array  $map_values array {
808
+     * @param string[]  $map_values array {
809 809
      *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
810 810
      *                           capabilities that don't get mapped to.
811 811
      *
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
      * @since 4.6.x
881 881
      *
882 882
      * @param $caps
883
-     * @param $cap
884
-     * @param $user_id
883
+     * @param string $cap
884
+     * @param integer $user_id
885 885
      * @param $args
886 886
      *
887 887
      * @return array
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
      *
199 199
      * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200 200
      *
201
-     * @return int
201
+     * @return string
202 202
      */
203 203
     private function _revenue_per_event_report($period = '-1 month')
204 204
     {
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -16,239 +16,239 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * This is used to hold the reports template data which is setup early in the request.
21
-     *
22
-     * @type array
23
-     */
24
-    protected $_reports_template_data = array();
25
-
26
-    /**
27
-     * @Constructor
28
-     * @access public
29
-     *
30
-     * @param bool $routing
31
-     *
32
-     * @return \Extend_Transactions_Admin_Page
33
-     */
34
-    public function __construct($routing = true)
35
-    {
36
-        parent::__construct($routing);
37
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
38
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
39
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
40
-    }
41
-
42
-
43
-    /**
44
-     *    _extend_page_config
45
-     *
46
-     * @access protected
47
-     * @return void
48
-     */
49
-    protected function _extend_page_config()
50
-    {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
52
-
53
-        $new_page_routes = array(
54
-            'reports' => array(
55
-                'func'       => '_transaction_reports',
56
-                'capability' => 'ee_read_transactions',
57
-            ),
58
-        );
59
-
60
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
61
-
62
-        $new_page_config = array(
63
-            'reports' => array(
64
-                'nav'           => array(
65
-                    'label' => __('Reports', 'event_espresso'),
66
-                    'order' => 20,
67
-                ),
68
-                'help_tabs'     => array(
69
-                    'transactions_reports_help_tab' => array(
70
-                        'title'    => __('Transaction Reports', 'event_espresso'),
71
-                        'filename' => 'transactions_reports',
72
-                    ),
73
-                ),
74
-                /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
75
-                'require_nonce' => false,
76
-            ),
77
-        );
78
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
79
-    }
80
-
81
-
82
-    /**
83
-     *    load_scripts_styles_reports
84
-     *
85
-     * @access public
86
-     * @return void
87
-     */
88
-    public function load_scripts_styles_reports()
89
-    {
90
-        wp_register_script(
91
-            'ee-txn-reports-js',
92
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
93
-            array('google-charts'),
94
-            EVENT_ESPRESSO_VERSION,
95
-            true
96
-        );
97
-        wp_enqueue_script('ee-txn-reports-js');
98
-        $this->_transaction_reports_js_setup();
99
-        EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
100
-    }
101
-
102
-
103
-    /**
104
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
105
-     * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
106
-     */
107
-    protected function _transaction_reports_js_setup()
108
-    {
109
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
110
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
111
-    }
112
-
113
-
114
-    /**
115
-     * _transaction_reports
116
-     *    generates Business Reports regarding Transactions
117
-     *
118
-     * @return void
119
-     */
120
-    protected function _transaction_reports()
121
-    {
122
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
123
-        $this->_admin_page_title = __('Transactions', 'event_espresso');
124
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
125
-            $template_path,
126
-            $this->_reports_template_data,
127
-            true
128
-        );
129
-
130
-        // the final template wrapper
131
-        $this->display_admin_page_with_no_sidebar();
132
-    }
133
-
134
-
135
-    /**
136
-     * _revenue_per_day_report
137
-     * generates Business Report showing Total Revenue per Day.
138
-     *
139
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
140
-     *
141
-     * @return string
142
-     */
143
-    private function _revenue_per_day_report($period = '-1 month')
144
-    {
145
-
146
-        $report_ID = 'txn-admin-revenue-per-day-report-dv';
147
-
148
-        $TXN = EEM_Transaction::instance();
149
-
150
-        $results = $TXN->get_revenue_per_day_report($period);
151
-        $results = (array) $results;
152
-        $revenue = array();
153
-        $subtitle = '';
154
-
155
-        if ($results) {
156
-            $revenue[] = array(
157
-                __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
158
-                __('Total Revenue', 'event_espresso'),
159
-            );
160
-            foreach ($results as $result) {
161
-                $revenue[] = array($result->txnDate, (float) $result->revenue);
162
-            }
163
-
164
-            // setup the date range.
165
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
166
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
167
-            $subtitle = sprintf(
168
-                _x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
169
-                $beginning_date->format('Y-m-d'),
170
-                $ending_date->format('Y-m-d')
171
-            );
172
-        }
173
-
174
-        $report_title = esc_html__('Total Revenue per Day', 'event_espresso');
175
-
176
-        $report_params = array(
177
-            'title'     => $report_title,
178
-            'subtitle'  => $subtitle,
179
-            'id'        => $report_ID,
180
-            'revenue'   => $revenue,
181
-            'noResults' => empty($revenue) || count($revenue) === 1,
182
-            'noTxnMsg'  => sprintf(
183
-                __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
184
-                '<h2>' . $report_title . '</h2><p>',
185
-                '</p>'
186
-            ),
187
-        );
188
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
189
-
190
-        return $report_ID;
191
-    }
192
-
193
-
194
-    /**
195
-     * _revenue_per_event_report
196
-     * generates Business Report showing total revenue per event.
197
-     *
198
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
199
-     *
200
-     * @return int
201
-     */
202
-    private function _revenue_per_event_report($period = '-1 month')
203
-    {
204
-
205
-        $report_ID = 'txn-admin-revenue-per-event-report-dv';
206
-
207
-        $TXN = EEM_Transaction::instance();
208
-        $results = $TXN->get_revenue_per_event_report($period);
209
-        $results = (array) $results;
210
-        $revenue = array();
211
-        $subtitle = '';
212
-
213
-        if ($results) {
214
-            $revenue[] = array(
215
-                __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
216
-                __('Total Revenue', 'event_espresso'),
217
-            );
218
-            foreach ($results as $result) {
219
-                if ($result->revenue > 1) {
220
-                    $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
221
-                    $event_name = wp_trim_words($event_name, 5, '...');
222
-                    $revenue[] = array($event_name, (float) $result->revenue);
223
-                }
224
-            }
225
-
226
-            // setup the date range.
227
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
228
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
-            $subtitle = sprintf(
230
-                _x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
231
-                $beginning_date->format('Y-m-d'),
232
-                $ending_date->format('Y-m-d')
233
-            );
234
-        }
235
-
236
-        $report_title = esc_html__('Total Revenue per Event', 'event_espresso');
237
-
238
-        $report_params = array(
239
-            'title'     => $report_title,
240
-            'subtitle'  => $subtitle,
241
-            'id'        => $report_ID,
242
-            'revenue'   => $revenue,
243
-            'noResults' => empty($revenue),
244
-            'noTxnMsg'  => sprintf(
245
-                __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
246
-                '<h2>' . $report_title . '</h2><p>',
247
-                '</p>'
248
-            ),
249
-        );
250
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
251
-
252
-        return $report_ID;
253
-    }
19
+	/**
20
+	 * This is used to hold the reports template data which is setup early in the request.
21
+	 *
22
+	 * @type array
23
+	 */
24
+	protected $_reports_template_data = array();
25
+
26
+	/**
27
+	 * @Constructor
28
+	 * @access public
29
+	 *
30
+	 * @param bool $routing
31
+	 *
32
+	 * @return \Extend_Transactions_Admin_Page
33
+	 */
34
+	public function __construct($routing = true)
35
+	{
36
+		parent::__construct($routing);
37
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
38
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
39
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
40
+	}
41
+
42
+
43
+	/**
44
+	 *    _extend_page_config
45
+	 *
46
+	 * @access protected
47
+	 * @return void
48
+	 */
49
+	protected function _extend_page_config()
50
+	{
51
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
52
+
53
+		$new_page_routes = array(
54
+			'reports' => array(
55
+				'func'       => '_transaction_reports',
56
+				'capability' => 'ee_read_transactions',
57
+			),
58
+		);
59
+
60
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
61
+
62
+		$new_page_config = array(
63
+			'reports' => array(
64
+				'nav'           => array(
65
+					'label' => __('Reports', 'event_espresso'),
66
+					'order' => 20,
67
+				),
68
+				'help_tabs'     => array(
69
+					'transactions_reports_help_tab' => array(
70
+						'title'    => __('Transaction Reports', 'event_espresso'),
71
+						'filename' => 'transactions_reports',
72
+					),
73
+				),
74
+				/*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
75
+				'require_nonce' => false,
76
+			),
77
+		);
78
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
79
+	}
80
+
81
+
82
+	/**
83
+	 *    load_scripts_styles_reports
84
+	 *
85
+	 * @access public
86
+	 * @return void
87
+	 */
88
+	public function load_scripts_styles_reports()
89
+	{
90
+		wp_register_script(
91
+			'ee-txn-reports-js',
92
+			TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
93
+			array('google-charts'),
94
+			EVENT_ESPRESSO_VERSION,
95
+			true
96
+		);
97
+		wp_enqueue_script('ee-txn-reports-js');
98
+		$this->_transaction_reports_js_setup();
99
+		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
100
+	}
101
+
102
+
103
+	/**
104
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
105
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
106
+	 */
107
+	protected function _transaction_reports_js_setup()
108
+	{
109
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
110
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
111
+	}
112
+
113
+
114
+	/**
115
+	 * _transaction_reports
116
+	 *    generates Business Reports regarding Transactions
117
+	 *
118
+	 * @return void
119
+	 */
120
+	protected function _transaction_reports()
121
+	{
122
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
123
+		$this->_admin_page_title = __('Transactions', 'event_espresso');
124
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
125
+			$template_path,
126
+			$this->_reports_template_data,
127
+			true
128
+		);
129
+
130
+		// the final template wrapper
131
+		$this->display_admin_page_with_no_sidebar();
132
+	}
133
+
134
+
135
+	/**
136
+	 * _revenue_per_day_report
137
+	 * generates Business Report showing Total Revenue per Day.
138
+	 *
139
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
140
+	 *
141
+	 * @return string
142
+	 */
143
+	private function _revenue_per_day_report($period = '-1 month')
144
+	{
145
+
146
+		$report_ID = 'txn-admin-revenue-per-day-report-dv';
147
+
148
+		$TXN = EEM_Transaction::instance();
149
+
150
+		$results = $TXN->get_revenue_per_day_report($period);
151
+		$results = (array) $results;
152
+		$revenue = array();
153
+		$subtitle = '';
154
+
155
+		if ($results) {
156
+			$revenue[] = array(
157
+				__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
158
+				__('Total Revenue', 'event_espresso'),
159
+			);
160
+			foreach ($results as $result) {
161
+				$revenue[] = array($result->txnDate, (float) $result->revenue);
162
+			}
163
+
164
+			// setup the date range.
165
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
166
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
167
+			$subtitle = sprintf(
168
+				_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
169
+				$beginning_date->format('Y-m-d'),
170
+				$ending_date->format('Y-m-d')
171
+			);
172
+		}
173
+
174
+		$report_title = esc_html__('Total Revenue per Day', 'event_espresso');
175
+
176
+		$report_params = array(
177
+			'title'     => $report_title,
178
+			'subtitle'  => $subtitle,
179
+			'id'        => $report_ID,
180
+			'revenue'   => $revenue,
181
+			'noResults' => empty($revenue) || count($revenue) === 1,
182
+			'noTxnMsg'  => sprintf(
183
+				__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
184
+				'<h2>' . $report_title . '</h2><p>',
185
+				'</p>'
186
+			),
187
+		);
188
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
189
+
190
+		return $report_ID;
191
+	}
192
+
193
+
194
+	/**
195
+	 * _revenue_per_event_report
196
+	 * generates Business Report showing total revenue per event.
197
+	 *
198
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
199
+	 *
200
+	 * @return int
201
+	 */
202
+	private function _revenue_per_event_report($period = '-1 month')
203
+	{
204
+
205
+		$report_ID = 'txn-admin-revenue-per-event-report-dv';
206
+
207
+		$TXN = EEM_Transaction::instance();
208
+		$results = $TXN->get_revenue_per_event_report($period);
209
+		$results = (array) $results;
210
+		$revenue = array();
211
+		$subtitle = '';
212
+
213
+		if ($results) {
214
+			$revenue[] = array(
215
+				__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
216
+				__('Total Revenue', 'event_espresso'),
217
+			);
218
+			foreach ($results as $result) {
219
+				if ($result->revenue > 1) {
220
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
221
+					$event_name = wp_trim_words($event_name, 5, '...');
222
+					$revenue[] = array($event_name, (float) $result->revenue);
223
+				}
224
+			}
225
+
226
+			// setup the date range.
227
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
228
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
+			$subtitle = sprintf(
230
+				_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
231
+				$beginning_date->format('Y-m-d'),
232
+				$ending_date->format('Y-m-d')
233
+			);
234
+		}
235
+
236
+		$report_title = esc_html__('Total Revenue per Event', 'event_espresso');
237
+
238
+		$report_params = array(
239
+			'title'     => $report_title,
240
+			'subtitle'  => $subtitle,
241
+			'id'        => $report_ID,
242
+			'revenue'   => $revenue,
243
+			'noResults' => empty($revenue),
244
+			'noTxnMsg'  => sprintf(
245
+				__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
246
+				'<h2>' . $report_title . '</h2><p>',
247
+				'</p>'
248
+			),
249
+		);
250
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
251
+
252
+		return $report_ID;
253
+	}
254 254
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
     public function __construct($routing = true)
35 35
     {
36 36
         parent::__construct($routing);
37
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
38
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
39
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
37
+        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/');
38
+        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/');
39
+        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/');
40 40
     }
41 41
 
42 42
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function _extend_page_config()
50 50
     {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
51
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions';
52 52
 
53 53
         $new_page_routes = array(
54 54
             'reports' => array(
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         wp_register_script(
91 91
             'ee-txn-reports-js',
92
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
92
+            TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js',
93 93
             array('google-charts'),
94 94
             EVENT_ESPRESSO_VERSION,
95 95
             true
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function _transaction_reports()
121 121
     {
122
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
122
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
123 123
         $this->_admin_page_title = __('Transactions', 'event_espresso');
124 124
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
125 125
             $template_path,
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             }
163 163
 
164 164
             // setup the date range.
165
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
165
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
166 166
             $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
167 167
             $subtitle = sprintf(
168 168
                 _x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             'noResults' => empty($revenue) || count($revenue) === 1,
182 182
             'noTxnMsg'  => sprintf(
183 183
                 __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
184
-                '<h2>' . $report_title . '</h2><p>',
184
+                '<h2>'.$report_title.'</h2><p>',
185 185
                 '</p>'
186 186
             ),
187 187
         );
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             }
225 225
 
226 226
             // setup the date range.
227
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
227
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
228 228
             $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229 229
             $subtitle = sprintf(
230 230
                 _x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             'noResults' => empty($revenue),
244 244
             'noTxnMsg'  => sprintf(
245 245
                 __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
246
-                '<h2>' . $report_title . '</h2><p>',
246
+                '<h2>'.$report_title.'</h2><p>',
247 247
                 '</p>'
248 248
             ),
249 249
         );
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @param  array $dir_ref original array of paths
93 93
      *
94
-     * @return array           appended paths
94
+     * @return string[]           appended paths
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      * @param EE_Question[]  $questions        An array of questions indexed by answer id.
702 702
      * @param EE_Answer[]    $answers          An array of answer objects
703 703
      * @param string         $template         Template content to be parsed.
704
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
704
+     * @param string[]          $valid_shortcodes Valid shortcodes for the template being parsed.
705 705
      * @param array          $extra_data       Extra data that might be used when parsing the template.
706 706
      */
707 707
     protected function _parse_question_list_for_primary_or_recipient_registration(
Please login to merge, or discard this patch.
Indentation   +799 added lines, -799 removed lines patch added patch discarded remove patch
@@ -13,803 +13,803 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * constructor.
18
-     */
19
-    public function __construct()
20
-    {
21
-        $this->_caf_hooks();
22
-    }
23
-
24
-
25
-    /**
26
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
27
-     *
28
-     * @since 4.3.2
29
-     *
30
-     * @return void
31
-     */
32
-    private function _caf_hooks()
33
-    {
34
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
35
-        add_filter(
36
-            'FHEE__EE_Email_messenger__get_validator_config',
37
-            array($this, 'email_messenger_validator_config'),
38
-            5,
39
-            2
40
-        );
41
-        add_filter(
42
-            'FHEE__EE_Email_messenger__get_template_fields',
43
-            array($this, 'email_messenger_template_fields'),
44
-            5,
45
-            2
46
-        );
47
-        add_filter(
48
-            'FHEE__EE_Html_messenger__get_template_fields',
49
-            array($this, 'html_messenger_template_fields'),
50
-            5,
51
-            2
52
-        );
53
-        add_filter(
54
-            'FHEE__EE_Html_messenger__get_validator_config',
55
-            array($this, 'html_messenger_validator_config'),
56
-            5,
57
-            2
58
-        );
59
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
60
-        add_filter(
61
-            'FHEE__EE_Pdf_messenger__get_validator_config',
62
-            array($this, 'pdf_messenger_validator_config'),
63
-            5,
64
-            2
65
-        );
66
-        add_filter(
67
-            'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
68
-            array($this, 'new_default_templates'),
69
-            5,
70
-            7
71
-        );
72
-        add_filter(
73
-            'FHEE__EE_Messages_Base__get_valid_shortcodes',
74
-            array($this, 'message_types_valid_shortcodes'),
75
-            5,
76
-            2
77
-        );
78
-
79
-        // shortcode parsers
80
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
81
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
82
-        add_filter(
83
-            'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
84
-            array($this, 'additional_recipient_details_shortcodes'),
85
-            5,
86
-            2
87
-        );
88
-        add_filter(
89
-            'FHEE__EE_Recipient_List_Shortcodes__parser_after',
90
-            array($this, 'additional_recipient_details_parser'),
91
-            5,
92
-            5
93
-        );
94
-        add_filter(
95
-            'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
96
-            array($this, 'additional_primary_registration_details_shortcodes'),
97
-            5,
98
-            2
99
-        );
100
-        add_filter(
101
-            'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
102
-            array($this, 'additional_primary_registration_details_parser'),
103
-            5,
104
-            5
105
-        );
106
-
107
-        /**
108
-         * @since 4.2.0
109
-         */
110
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
111
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
112
-
113
-        /**
114
-         * @since 4.3.0
115
-         */
116
-        // eat our own dog food!
117
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
118
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
119
-        do_action('EE_Brewing_Regular___messages_caf');
120
-    }
121
-
122
-
123
-    /**
124
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
125
-     * messages system.
126
-     *
127
-     * @param  array $dir_ref original array of paths
128
-     *
129
-     * @return array           appended paths
130
-     */
131
-    public function messages_autoload_paths($dir_ref)
132
-    {
133
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
134
-
135
-        return $dir_ref;
136
-    }
137
-
138
-
139
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
140
-    {
141
-        $validator_config['attendee_list'] = array(
142
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
143
-            'required'   => array('[ATTENDEE_LIST]'),
144
-        );
145
-        $validator_config['question_list'] = array(
146
-            'shortcodes' => array('question'),
147
-            'required'   => array('[QUESTION_LIST]'),
148
-        );
149
-
150
-        return $validator_config;
151
-    }
152
-
153
-
154
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
155
-    {
156
-        $validator_config['attendee_list'] = array(
157
-            'shortcodes' => array('attendee', 'question_list'),
158
-            'required'   => array('[ATTENDEE_LIST]'),
159
-        );
160
-        $validator_config['question_list'] = array(
161
-            'shortcodes' => array('question'),
162
-            'required'   => array('[QUESTION_LIST]'),
163
-        );
164
-
165
-        return $validator_config;
166
-    }
167
-
168
-
169
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
170
-    {
171
-        $validator_config['attendee_list'] = array(
172
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
173
-            'required'   => array('[ATTENDEE_LIST]'),
174
-        );
175
-        $validator_config['question_list'] = array(
176
-            'shortcodes' => array('question'),
177
-            'required'   => array('[QUESTION_LIST]'),
178
-        );
179
-
180
-        return $validator_config;
181
-    }
182
-
183
-
184
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
185
-    {
186
-        $template_fields['extra']['content']['question_list'] = array(
187
-            'input'               => 'textarea',
188
-            'label'               => '[QUESTION_LIST]',
189
-            'type'                => 'string',
190
-            'required'            => true,
191
-            'validation'          => true,
192
-            'format'              => '%s',
193
-            'css_class'           => 'large-text',
194
-            'rows'                => '5',
195
-            'shortcodes_required' => array('[QUESTION_LIST]'),
196
-        );
197
-
198
-        return $template_fields;
199
-    }
200
-
201
-
202
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
203
-    {
204
-        $template_fields['extra']['content']['question_list'] = array(
205
-            'input'               => 'textarea',
206
-            'label'               => '[QUESTION_LIST]',
207
-            'type'                => 'string',
208
-            'required'            => true,
209
-            'validation'          => true,
210
-            'format'              => '%s',
211
-            'css_class'           => 'large-text',
212
-            'rows'                => '5',
213
-            'shortcodes_required' => array('[QUESTION_LIST]'),
214
-        );
215
-
216
-        return $template_fields;
217
-    }
218
-
219
-
220
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
221
-    {
222
-        $template_fields['extra']['content']['question_list'] = array(
223
-            'input'               => 'textarea',
224
-            'label'               => '[QUESTION_LIST]',
225
-            'type'                => 'string',
226
-            'required'            => true,
227
-            'validation'          => true,
228
-            'format'              => '%s',
229
-            'css_class'           => 'large-text',
230
-            'rows'                => '5',
231
-            'shortcodes_required' => array('[QUESTION_LIST]'),
232
-        );
233
-
234
-        return $template_fields;
235
-    }
236
-
237
-
238
-    public function new_default_templates(
239
-        $contents,
240
-        $actual_path,
241
-        EE_messenger $messenger,
242
-        EE_message_type $message_type,
243
-        $field,
244
-        $context,
245
-        EE_Messages_Template_Pack $template_pack
246
-    ) {
247
-
248
-        // we're only modifying templates for the default template pack
249
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250
-            return $contents;
251
-        }
252
-
253
-        // the template file name we're replacing contents for.
254
-        $template_file_prefix = $field . '_' . $context;
255
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
256
-
257
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
258
-
259
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
260
-            switch ($template_file_prefix) {
261
-                case 'question_list_admin':
262
-                case 'question_list_attendee':
263
-                case 'question_list_primary_attendee':
264
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
267
-
268
-                case 'attendee_list_primary_attendee':
269
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-
273
-                case 'attendee_list_admin':
274
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
275
-                    $contents = EEH_Template::display_template(
276
-                        $path,
277
-                        array(),
278
-                        true
279
-                    );
280
-                    break;
281
-
282
-                case 'attendee_list_attendee':
283
-                    $contents = '';
284
-                    break;
285
-
286
-                case 'event_list_attendee':
287
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
288
-                    $contents = EEH_Template::display_template($path, array(), true);
289
-                    break;
290
-            }
291
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292
-            switch ($template_file_prefix) {
293
-                case 'content_attendee':
294
-                    $path = $base_path . $msg_prefix . 'content.template.php';
295
-                    $contents = EEH_Template::display_template($path, array(), true);
296
-                    break;
297
-
298
-                case 'newsletter_content_attendee':
299
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
300
-                    $contents = EEH_Template::display_template($path, array(), true);
301
-                    break;
302
-
303
-                case 'newsletter_subject_attendee':
304
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
305
-                    $contents = EEH_Template::display_template($path, array(), true);
306
-                    break;
307
-            }
308
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309
-            switch ($template_file_prefix) {
310
-                case 'attendee_list_purchaser':
311
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
312
-                    $contents = EEH_Template::display_template($path, array(), true);
313
-                    break;
314
-            }
315
-        }
316
-
317
-        return $contents;
318
-    }
319
-
320
-
321
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
322
-    {
323
-        // make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
324
-        $include_with = array(
325
-            'registration',
326
-            'cancelled_registration',
327
-            'declined_registration',
328
-            'not_approved_registration',
329
-            'payment_declined',
330
-            'payment_failed',
331
-            'payment_cancelled',
332
-            'payment',
333
-            'payment_reminder',
334
-            'pending_approval',
335
-            'registration_summary',
336
-            'invoice',
337
-            'receipt',
338
-        );
339
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340
-            $contexts = array_keys($msg->get_contexts());
341
-            foreach ($contexts as $context) {
342
-                $valid_shortcodes[ $context ][] = 'question_list';
343
-                $valid_shortcodes[ $context ][] = 'question';
344
-            }
345
-        }
346
-
347
-        return $valid_shortcodes;
348
-    }
349
-
350
-
351
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
352
-    {
353
-        $shortcodes['[ANSWER_*]'] = __(
354
-            'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
355
-            'event_espresso'
356
-        );
357
-
358
-        return $shortcodes;
359
-    }
360
-
361
-
362
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
363
-    {
364
-
365
-        if (strpos($shortcode, '[ANSWER_*') === false
366
-            || ! isset($extra_data['data']->questions)
367
-            || ! isset($extra_data['data']->registrations)
368
-        ) {
369
-            return $parsed;
370
-        }
371
-
372
-        // let's get the question from the code.
373
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
-        $shortcode = trim(str_replace(']', '', $shortcode));
375
-
376
-        $registration = $data instanceof EE_Registration ? $data : null;
377
-        $registration = ! $registration instanceof EE_Registration && is_array(
378
-            $extra_data
379
-        ) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
-
381
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
-            $extra_data
384
-        ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
-
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
-            return $parsed;
388
-        }
389
-
390
-        // now let's figure out which question has this text.
391
-        foreach ($aee->questions as $ansid => $question) {
392
-            if ($question instanceof EE_Question
393
-                && trim($question->display_text()) == trim($shortcode)
394
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
395
-            ) {
396
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
397
-                    'ANS_value',
398
-                    'no_wpautop'
399
-                );
400
-            }
401
-        }
402
-
403
-        // nothing!
404
-        return $parsed;
405
-    }
406
-
407
-
408
-    /**
409
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
410
-     *
411
-     * @since  4.2
412
-     *
413
-     * @param  array                  $shortcodes         array of shortcodes and
414
-     *                                                    descriptions
415
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
416
-     *
417
-     * @return array                                        array of shortcodes and
418
-     *                                                        descriptions
419
-     */
420
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
421
-    {
422
-        $shortcodes['[DTT_NAME]'] = __(
423
-            'This will be parsed to the Title given for a Datetime',
424
-            'event_espresso'
425
-        );
426
-        $shortcodes['[DTT_DESCRIPTION]'] = __(
427
-            'This will be parsed to the description for a Datetime',
428
-            'event_espresso'
429
-        );
430
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __(
431
-            'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
432
-            'event_espresso'
433
-        );
434
-
435
-        return $shortcodes;
436
-    }
437
-
438
-
439
-    /**
440
-     * Callback for additional shortcodes parser filter used for adding parser for new
441
-     * Datetime shortcodes
442
-     *
443
-     * @since  4.2
444
-     *
445
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
446
-     * @param  string                 $shortcode  The shortcode being parsed.
447
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
448
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
449
-     *                                            Parser.
450
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
451
-     *
452
-     * @return string                   The new parsed string.
453
-     */
454
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455
-    {
456
-
457
-        if (! $data instanceof EE_Datetime) {
458
-            return ''; // get out because we can only parse with the datetime object.
459
-        }
460
-
461
-        switch ($shortcode) {
462
-            case '[DTT_NAME]':
463
-                return $data->name();
464
-                break;
465
-            case '[DTT_DESCRIPTION]':
466
-                return $data->description();
467
-                break;
468
-            case '[DTT_NAME_OR_DATES]':
469
-                return $data->get_dtt_display_name(true);
470
-                break;
471
-            default:
472
-                return $parsed;
473
-                break;
474
-        }
475
-    }
476
-
477
-
478
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
479
-    {
480
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __(
481
-            'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
482
-            'event_espresso'
483
-        );
484
-
485
-        return $shortcodes;
486
-    }
487
-
488
-
489
-    /**
490
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
491
-     *
492
-     * @param string         $parsed           The original parsed content for the shortcode
493
-     * @param string         $shortcode        The shortcode being parsed
494
-     * @param array          $data             The shortcode parser data array
495
-     * @param array          $extra_data       The shortcode parser extra data array
496
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
497
-     *
498
-     * @return string
499
-     */
500
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
501
-    {
502
-
503
-        if (array($data) && ! isset($data['data'])) {
504
-            return $parsed;
505
-        }
506
-
507
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509
-
510
-        if (! $recipient instanceof EE_Messages_Addressee) {
511
-            return $parsed;
512
-        }
513
-
514
-        switch ($shortcode) {
515
-            case '[RECIPIENT_QUESTION_LIST]':
516
-                $att = $recipient->att_obj;
517
-                $registrations_on_attendee = $att instanceof EE_Attendee
518
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
519
-                    : array();
520
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521
-                $answers = array();
522
-
523
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
524
-                    ? $data['template']['question_list']
525
-                    : $extra_data['template']['question_list'];
526
-                $valid_shortcodes = array('question');
527
-
528
-                // if the context is main_content then get all answers for all registrations on this attendee
529
-                if ($data['data'] instanceof EE_Messages_Addressee) {
530
-                    foreach ($registrations_on_attendee as $reg) {
531
-                        if ($reg instanceof EE_Registration) {
532
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
534
-                                : array();
535
-                            foreach ($anss as $ans) {
536
-                                if ($ans instanceof EE_Answer) {
537
-                                    $answers[ $ans->ID() ] = $ans;
538
-                                }
539
-                            }
540
-                        }
541
-                    }
542
-                }
543
-
544
-                // if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
545
-                if ($data['data'] instanceof EE_Event) {
546
-                    $event = $data['data'];
547
-                    foreach ($registrations_on_attendee as $reg) {
548
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
551
-                                : array();
552
-                            foreach ($anss as $ans) {
553
-                                if ($ans instanceof EE_Answer) {
554
-                                    $answers[ $ans->ID() ] = $ans;
555
-                                }
556
-                            }
557
-                        }
558
-                    }
559
-                }
560
-
561
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
562
-
563
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564
-                // object on it.
565
-                if (! isset($extra_data['data'])) {
566
-                    $extra_data['data'] = $recipient;
567
-                }
568
-
569
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
570
-                    $shortcode_parser,
571
-                    $questions,
572
-                    $answers,
573
-                    $template,
574
-                    $valid_shortcodes,
575
-                    $extra_data
576
-                );
577
-                break;
578
-
579
-            default:
580
-                return $parsed;
581
-                break;
582
-        }
583
-    }
584
-
585
-
586
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
587
-    {
588
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __(
589
-            'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
590
-            'event_espresso'
591
-        );
592
-
593
-        return $shortcodes;
594
-    }
595
-
596
-
597
-    /**
598
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
599
-     *
600
-     * @param string         $parsed           The original parsed content for the shortcode
601
-     * @param string         $shortcode        The shortcode being parsed
602
-     * @param array          $data             The shortcode parser data array
603
-     * @param array          $extra_data       The shortcode parser extra data array
604
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
605
-     *
606
-     * @return string
607
-     */
608
-    public function additional_primary_registration_details_parser(
609
-        $parsed,
610
-        $shortcode,
611
-        $data,
612
-        $extra_data,
613
-        $shortcode_parser
614
-    ) {
615
-        if (array($data) && ! isset($data['data'])) {
616
-            return $parsed;
617
-        }
618
-
619
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621
-
622
-        if (! $recipient instanceof EE_Messages_Addressee) {
623
-            return $parsed;
624
-        }
625
-
626
-        switch ($shortcode) {
627
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629
-                    return '';
630
-                }
631
-                $registration = $recipient->primary_reg_obj;
632
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
634
-                    : array();
635
-                if (empty($answers)) {
636
-                    return '';
637
-                }
638
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
639
-                    ? $data['template']['question_list']
640
-                    : $extra_data['template']['question_list'];
641
-                $valid_shortcodes = array('question');
642
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
643
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
644
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645
-                // object on it.
646
-                if (! isset($extra_data['data'])) {
647
-                    $extra_data['data'] = $recipient;
648
-                }
649
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
650
-                    $shortcode_parser,
651
-                    $questions,
652
-                    $answers,
653
-                    $template,
654
-                    $valid_shortcodes,
655
-                    $extra_data
656
-                );
657
-                break;
658
-
659
-            default:
660
-                return $parsed;
661
-                break;
662
-        }
663
-    }
664
-
665
-
666
-    /**
667
-     * Takes care of registering the  message types that are only available in caffeinated EE.
668
-     *
669
-     * @since   4.3.2
670
-     *
671
-     * @return  void
672
-     */
673
-    public function register_caf_message_types()
674
-    {
675
-        // register newsletter message type
676
-        $setup_args = array(
677
-            'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678
-            'autoloadpaths'                                    => array(
679
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
680
-            ),
681
-            'messengers_to_activate_with'                      => array('email'),
682
-            'messengers_to_validate_with'                      => array('email'),
683
-            'messengers_supporting_default_template_pack_with' => array('email'),
684
-        );
685
-        EE_Register_Message_Type::register('newsletter', $setup_args);
686
-
687
-        // register payment reminder message type
688
-        $setup_args = array(
689
-            'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
691
-            'messengers_to_activate_with'                      => array('email'),
692
-            'messengers_to_validate_with'                      => array('email'),
693
-            'messengers_supporting_default_template_pack_with' => array('email'),
694
-        );
695
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
696
-
697
-        // register payment declined message type
698
-        $setup_args = array(
699
-            'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
701
-            'messengers_to_activate_with'                      => array('email'),
702
-            'messengers_to_validate_with'                      => array('email'),
703
-            'messengers_supporting_default_template_pack_with' => array('email'),
704
-        );
705
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
706
-
707
-        // register registration declined message type
708
-        $setup_args = array(
709
-            'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
711
-            'messengers_to_activate_with'                      => array('email'),
712
-            'messengers_to_validate_with'                      => array('email'),
713
-            'messengers_supporting_default_template_pack_with' => array('email'),
714
-        );
715
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
716
-
717
-        // register registration cancelled message type
718
-        $setup_args = array(
719
-            'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
721
-            'messengers_to_activate_with'                      => array('email'),
722
-            'messengers_to_validate_with'                      => array('email'),
723
-            'messengers_supporting_default_template_pack_with' => array('email'),
724
-        );
725
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
726
-
727
-
728
-        // register payment failed message type
729
-        $setup_args = array(
730
-            'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
732
-            'messengers_to_activate_with'                      => array('email'),
733
-            'messengers_to_validate_with'                      => array('email'),
734
-            'messengers_supporting_default_template_pack_with' => array('email'),
735
-        );
736
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
737
-
738
-        // register payment declined message type
739
-        $setup_args = array(
740
-            'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
742
-            'messengers_to_activate_with'                      => array('email'),
743
-            'messengers_to_validate_with'                      => array('email'),
744
-            'messengers_supporting_default_template_pack_with' => array('email'),
745
-        );
746
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
747
-    }
748
-
749
-
750
-    /**
751
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
752
-     *
753
-     * @since   4.3.2
754
-     *
755
-     * @return void
756
-     */
757
-    public function register_caf_shortcodes()
758
-    {
759
-        $setup_args = array(
760
-            'autoloadpaths'                 => array(
761
-                EE_CAF_LIBRARIES . 'shortcodes/',
762
-            ),
763
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
765
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
766
-        );
767
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
768
-    }
769
-
770
-
771
-    /**
772
-     * Parses a question list shortcode using given data and template
773
-     *
774
-     * @param \EE_Shortcodes $shortcode_parser
775
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
776
-     * @param EE_Answer[]    $answers          An array of answer objects
777
-     * @param string         $template         Template content to be parsed.
778
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
779
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
780
-     */
781
-    protected function _parse_question_list_for_primary_or_recipient_registration(
782
-        $shortcode_parser,
783
-        $questions,
784
-        $answers,
785
-        $template,
786
-        $valid_shortcodes,
787
-        $extra_data
788
-    ) {
789
-        $question_list = '';
790
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
791
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
792
-        foreach ($answers as $answer) {
793
-            if ($answer instanceof EE_Answer) {
794
-                // first see if the question is in our $questions array. If not then try to get from answer object.
795
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
796
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
-                if (! $question instanceof EE_Question
798
-                    || (
799
-                        $question instanceof EE_Question
800
-                        && $question->admin_only()
801
-                    )
802
-                ) {
803
-                    continue;
804
-                }
805
-                $question_list .= $shortcode_helper->parse_question_list_template(
806
-                    $template,
807
-                    $answer,
808
-                    $valid_shortcodes,
809
-                    $extra_data
810
-                );
811
-            }
812
-        }
813
-        return $question_list;
814
-    }
16
+	/**
17
+	 * constructor.
18
+	 */
19
+	public function __construct()
20
+	{
21
+		$this->_caf_hooks();
22
+	}
23
+
24
+
25
+	/**
26
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
27
+	 *
28
+	 * @since 4.3.2
29
+	 *
30
+	 * @return void
31
+	 */
32
+	private function _caf_hooks()
33
+	{
34
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
35
+		add_filter(
36
+			'FHEE__EE_Email_messenger__get_validator_config',
37
+			array($this, 'email_messenger_validator_config'),
38
+			5,
39
+			2
40
+		);
41
+		add_filter(
42
+			'FHEE__EE_Email_messenger__get_template_fields',
43
+			array($this, 'email_messenger_template_fields'),
44
+			5,
45
+			2
46
+		);
47
+		add_filter(
48
+			'FHEE__EE_Html_messenger__get_template_fields',
49
+			array($this, 'html_messenger_template_fields'),
50
+			5,
51
+			2
52
+		);
53
+		add_filter(
54
+			'FHEE__EE_Html_messenger__get_validator_config',
55
+			array($this, 'html_messenger_validator_config'),
56
+			5,
57
+			2
58
+		);
59
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
60
+		add_filter(
61
+			'FHEE__EE_Pdf_messenger__get_validator_config',
62
+			array($this, 'pdf_messenger_validator_config'),
63
+			5,
64
+			2
65
+		);
66
+		add_filter(
67
+			'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
68
+			array($this, 'new_default_templates'),
69
+			5,
70
+			7
71
+		);
72
+		add_filter(
73
+			'FHEE__EE_Messages_Base__get_valid_shortcodes',
74
+			array($this, 'message_types_valid_shortcodes'),
75
+			5,
76
+			2
77
+		);
78
+
79
+		// shortcode parsers
80
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
81
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
82
+		add_filter(
83
+			'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
84
+			array($this, 'additional_recipient_details_shortcodes'),
85
+			5,
86
+			2
87
+		);
88
+		add_filter(
89
+			'FHEE__EE_Recipient_List_Shortcodes__parser_after',
90
+			array($this, 'additional_recipient_details_parser'),
91
+			5,
92
+			5
93
+		);
94
+		add_filter(
95
+			'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
96
+			array($this, 'additional_primary_registration_details_shortcodes'),
97
+			5,
98
+			2
99
+		);
100
+		add_filter(
101
+			'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
102
+			array($this, 'additional_primary_registration_details_parser'),
103
+			5,
104
+			5
105
+		);
106
+
107
+		/**
108
+		 * @since 4.2.0
109
+		 */
110
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
111
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
112
+
113
+		/**
114
+		 * @since 4.3.0
115
+		 */
116
+		// eat our own dog food!
117
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
118
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
119
+		do_action('EE_Brewing_Regular___messages_caf');
120
+	}
121
+
122
+
123
+	/**
124
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
125
+	 * messages system.
126
+	 *
127
+	 * @param  array $dir_ref original array of paths
128
+	 *
129
+	 * @return array           appended paths
130
+	 */
131
+	public function messages_autoload_paths($dir_ref)
132
+	{
133
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
134
+
135
+		return $dir_ref;
136
+	}
137
+
138
+
139
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
140
+	{
141
+		$validator_config['attendee_list'] = array(
142
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
143
+			'required'   => array('[ATTENDEE_LIST]'),
144
+		);
145
+		$validator_config['question_list'] = array(
146
+			'shortcodes' => array('question'),
147
+			'required'   => array('[QUESTION_LIST]'),
148
+		);
149
+
150
+		return $validator_config;
151
+	}
152
+
153
+
154
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
155
+	{
156
+		$validator_config['attendee_list'] = array(
157
+			'shortcodes' => array('attendee', 'question_list'),
158
+			'required'   => array('[ATTENDEE_LIST]'),
159
+		);
160
+		$validator_config['question_list'] = array(
161
+			'shortcodes' => array('question'),
162
+			'required'   => array('[QUESTION_LIST]'),
163
+		);
164
+
165
+		return $validator_config;
166
+	}
167
+
168
+
169
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
170
+	{
171
+		$validator_config['attendee_list'] = array(
172
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
173
+			'required'   => array('[ATTENDEE_LIST]'),
174
+		);
175
+		$validator_config['question_list'] = array(
176
+			'shortcodes' => array('question'),
177
+			'required'   => array('[QUESTION_LIST]'),
178
+		);
179
+
180
+		return $validator_config;
181
+	}
182
+
183
+
184
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
185
+	{
186
+		$template_fields['extra']['content']['question_list'] = array(
187
+			'input'               => 'textarea',
188
+			'label'               => '[QUESTION_LIST]',
189
+			'type'                => 'string',
190
+			'required'            => true,
191
+			'validation'          => true,
192
+			'format'              => '%s',
193
+			'css_class'           => 'large-text',
194
+			'rows'                => '5',
195
+			'shortcodes_required' => array('[QUESTION_LIST]'),
196
+		);
197
+
198
+		return $template_fields;
199
+	}
200
+
201
+
202
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
203
+	{
204
+		$template_fields['extra']['content']['question_list'] = array(
205
+			'input'               => 'textarea',
206
+			'label'               => '[QUESTION_LIST]',
207
+			'type'                => 'string',
208
+			'required'            => true,
209
+			'validation'          => true,
210
+			'format'              => '%s',
211
+			'css_class'           => 'large-text',
212
+			'rows'                => '5',
213
+			'shortcodes_required' => array('[QUESTION_LIST]'),
214
+		);
215
+
216
+		return $template_fields;
217
+	}
218
+
219
+
220
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
221
+	{
222
+		$template_fields['extra']['content']['question_list'] = array(
223
+			'input'               => 'textarea',
224
+			'label'               => '[QUESTION_LIST]',
225
+			'type'                => 'string',
226
+			'required'            => true,
227
+			'validation'          => true,
228
+			'format'              => '%s',
229
+			'css_class'           => 'large-text',
230
+			'rows'                => '5',
231
+			'shortcodes_required' => array('[QUESTION_LIST]'),
232
+		);
233
+
234
+		return $template_fields;
235
+	}
236
+
237
+
238
+	public function new_default_templates(
239
+		$contents,
240
+		$actual_path,
241
+		EE_messenger $messenger,
242
+		EE_message_type $message_type,
243
+		$field,
244
+		$context,
245
+		EE_Messages_Template_Pack $template_pack
246
+	) {
247
+
248
+		// we're only modifying templates for the default template pack
249
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250
+			return $contents;
251
+		}
252
+
253
+		// the template file name we're replacing contents for.
254
+		$template_file_prefix = $field . '_' . $context;
255
+		$msg_prefix = $messenger->name . '_' . $message_type->name . '_';
256
+
257
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
258
+
259
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
260
+			switch ($template_file_prefix) {
261
+				case 'question_list_admin':
262
+				case 'question_list_attendee':
263
+				case 'question_list_primary_attendee':
264
+					$path = $base_path . $msg_prefix . 'question_list.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267
+
268
+				case 'attendee_list_primary_attendee':
269
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+
273
+				case 'attendee_list_admin':
274
+					$path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
275
+					$contents = EEH_Template::display_template(
276
+						$path,
277
+						array(),
278
+						true
279
+					);
280
+					break;
281
+
282
+				case 'attendee_list_attendee':
283
+					$contents = '';
284
+					break;
285
+
286
+				case 'event_list_attendee':
287
+					$path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
288
+					$contents = EEH_Template::display_template($path, array(), true);
289
+					break;
290
+			}
291
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292
+			switch ($template_file_prefix) {
293
+				case 'content_attendee':
294
+					$path = $base_path . $msg_prefix . 'content.template.php';
295
+					$contents = EEH_Template::display_template($path, array(), true);
296
+					break;
297
+
298
+				case 'newsletter_content_attendee':
299
+					$path = $base_path . $msg_prefix . 'newsletter_content.template.php';
300
+					$contents = EEH_Template::display_template($path, array(), true);
301
+					break;
302
+
303
+				case 'newsletter_subject_attendee':
304
+					$path = $base_path . $msg_prefix . 'subject.template.php';
305
+					$contents = EEH_Template::display_template($path, array(), true);
306
+					break;
307
+			}
308
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309
+			switch ($template_file_prefix) {
310
+				case 'attendee_list_purchaser':
311
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
312
+					$contents = EEH_Template::display_template($path, array(), true);
313
+					break;
314
+			}
315
+		}
316
+
317
+		return $contents;
318
+	}
319
+
320
+
321
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
322
+	{
323
+		// make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
324
+		$include_with = array(
325
+			'registration',
326
+			'cancelled_registration',
327
+			'declined_registration',
328
+			'not_approved_registration',
329
+			'payment_declined',
330
+			'payment_failed',
331
+			'payment_cancelled',
332
+			'payment',
333
+			'payment_reminder',
334
+			'pending_approval',
335
+			'registration_summary',
336
+			'invoice',
337
+			'receipt',
338
+		);
339
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340
+			$contexts = array_keys($msg->get_contexts());
341
+			foreach ($contexts as $context) {
342
+				$valid_shortcodes[ $context ][] = 'question_list';
343
+				$valid_shortcodes[ $context ][] = 'question';
344
+			}
345
+		}
346
+
347
+		return $valid_shortcodes;
348
+	}
349
+
350
+
351
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
352
+	{
353
+		$shortcodes['[ANSWER_*]'] = __(
354
+			'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
355
+			'event_espresso'
356
+		);
357
+
358
+		return $shortcodes;
359
+	}
360
+
361
+
362
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
363
+	{
364
+
365
+		if (strpos($shortcode, '[ANSWER_*') === false
366
+			|| ! isset($extra_data['data']->questions)
367
+			|| ! isset($extra_data['data']->registrations)
368
+		) {
369
+			return $parsed;
370
+		}
371
+
372
+		// let's get the question from the code.
373
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
+		$shortcode = trim(str_replace(']', '', $shortcode));
375
+
376
+		$registration = $data instanceof EE_Registration ? $data : null;
377
+		$registration = ! $registration instanceof EE_Registration && is_array(
378
+			$extra_data
379
+		) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
+
381
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
+			$extra_data
384
+		) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
+
386
+		if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
+			return $parsed;
388
+		}
389
+
390
+		// now let's figure out which question has this text.
391
+		foreach ($aee->questions as $ansid => $question) {
392
+			if ($question instanceof EE_Question
393
+				&& trim($question->display_text()) == trim($shortcode)
394
+				&& isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
395
+			) {
396
+				return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
397
+					'ANS_value',
398
+					'no_wpautop'
399
+				);
400
+			}
401
+		}
402
+
403
+		// nothing!
404
+		return $parsed;
405
+	}
406
+
407
+
408
+	/**
409
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
410
+	 *
411
+	 * @since  4.2
412
+	 *
413
+	 * @param  array                  $shortcodes         array of shortcodes and
414
+	 *                                                    descriptions
415
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
416
+	 *
417
+	 * @return array                                        array of shortcodes and
418
+	 *                                                        descriptions
419
+	 */
420
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
421
+	{
422
+		$shortcodes['[DTT_NAME]'] = __(
423
+			'This will be parsed to the Title given for a Datetime',
424
+			'event_espresso'
425
+		);
426
+		$shortcodes['[DTT_DESCRIPTION]'] = __(
427
+			'This will be parsed to the description for a Datetime',
428
+			'event_espresso'
429
+		);
430
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __(
431
+			'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
432
+			'event_espresso'
433
+		);
434
+
435
+		return $shortcodes;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Callback for additional shortcodes parser filter used for adding parser for new
441
+	 * Datetime shortcodes
442
+	 *
443
+	 * @since  4.2
444
+	 *
445
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
446
+	 * @param  string                 $shortcode  The shortcode being parsed.
447
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
448
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
449
+	 *                                            Parser.
450
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
451
+	 *
452
+	 * @return string                   The new parsed string.
453
+	 */
454
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455
+	{
456
+
457
+		if (! $data instanceof EE_Datetime) {
458
+			return ''; // get out because we can only parse with the datetime object.
459
+		}
460
+
461
+		switch ($shortcode) {
462
+			case '[DTT_NAME]':
463
+				return $data->name();
464
+				break;
465
+			case '[DTT_DESCRIPTION]':
466
+				return $data->description();
467
+				break;
468
+			case '[DTT_NAME_OR_DATES]':
469
+				return $data->get_dtt_display_name(true);
470
+				break;
471
+			default:
472
+				return $parsed;
473
+				break;
474
+		}
475
+	}
476
+
477
+
478
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
479
+	{
480
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __(
481
+			'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
482
+			'event_espresso'
483
+		);
484
+
485
+		return $shortcodes;
486
+	}
487
+
488
+
489
+	/**
490
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
491
+	 *
492
+	 * @param string         $parsed           The original parsed content for the shortcode
493
+	 * @param string         $shortcode        The shortcode being parsed
494
+	 * @param array          $data             The shortcode parser data array
495
+	 * @param array          $extra_data       The shortcode parser extra data array
496
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
501
+	{
502
+
503
+		if (array($data) && ! isset($data['data'])) {
504
+			return $parsed;
505
+		}
506
+
507
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509
+
510
+		if (! $recipient instanceof EE_Messages_Addressee) {
511
+			return $parsed;
512
+		}
513
+
514
+		switch ($shortcode) {
515
+			case '[RECIPIENT_QUESTION_LIST]':
516
+				$att = $recipient->att_obj;
517
+				$registrations_on_attendee = $att instanceof EE_Attendee
518
+					? $recipient->attendees[ $att->ID() ]['reg_objs']
519
+					: array();
520
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521
+				$answers = array();
522
+
523
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
524
+					? $data['template']['question_list']
525
+					: $extra_data['template']['question_list'];
526
+				$valid_shortcodes = array('question');
527
+
528
+				// if the context is main_content then get all answers for all registrations on this attendee
529
+				if ($data['data'] instanceof EE_Messages_Addressee) {
530
+					foreach ($registrations_on_attendee as $reg) {
531
+						if ($reg instanceof EE_Registration) {
532
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
534
+								: array();
535
+							foreach ($anss as $ans) {
536
+								if ($ans instanceof EE_Answer) {
537
+									$answers[ $ans->ID() ] = $ans;
538
+								}
539
+							}
540
+						}
541
+					}
542
+				}
543
+
544
+				// if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
545
+				if ($data['data'] instanceof EE_Event) {
546
+					$event = $data['data'];
547
+					foreach ($registrations_on_attendee as $reg) {
548
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
551
+								: array();
552
+							foreach ($anss as $ans) {
553
+								if ($ans instanceof EE_Answer) {
554
+									$answers[ $ans->ID() ] = $ans;
555
+								}
556
+							}
557
+						}
558
+					}
559
+				}
560
+
561
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
562
+
563
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564
+				// object on it.
565
+				if (! isset($extra_data['data'])) {
566
+					$extra_data['data'] = $recipient;
567
+				}
568
+
569
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
570
+					$shortcode_parser,
571
+					$questions,
572
+					$answers,
573
+					$template,
574
+					$valid_shortcodes,
575
+					$extra_data
576
+				);
577
+				break;
578
+
579
+			default:
580
+				return $parsed;
581
+				break;
582
+		}
583
+	}
584
+
585
+
586
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
587
+	{
588
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __(
589
+			'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
590
+			'event_espresso'
591
+		);
592
+
593
+		return $shortcodes;
594
+	}
595
+
596
+
597
+	/**
598
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
599
+	 *
600
+	 * @param string         $parsed           The original parsed content for the shortcode
601
+	 * @param string         $shortcode        The shortcode being parsed
602
+	 * @param array          $data             The shortcode parser data array
603
+	 * @param array          $extra_data       The shortcode parser extra data array
604
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
605
+	 *
606
+	 * @return string
607
+	 */
608
+	public function additional_primary_registration_details_parser(
609
+		$parsed,
610
+		$shortcode,
611
+		$data,
612
+		$extra_data,
613
+		$shortcode_parser
614
+	) {
615
+		if (array($data) && ! isset($data['data'])) {
616
+			return $parsed;
617
+		}
618
+
619
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621
+
622
+		if (! $recipient instanceof EE_Messages_Addressee) {
623
+			return $parsed;
624
+		}
625
+
626
+		switch ($shortcode) {
627
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
+				if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629
+					return '';
630
+				}
631
+				$registration = $recipient->primary_reg_obj;
632
+				$answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
+					? $recipient->registrations[ $registration->ID() ]['ans_objs']
634
+					: array();
635
+				if (empty($answers)) {
636
+					return '';
637
+				}
638
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
639
+					? $data['template']['question_list']
640
+					: $extra_data['template']['question_list'];
641
+				$valid_shortcodes = array('question');
642
+				$answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
643
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
644
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645
+				// object on it.
646
+				if (! isset($extra_data['data'])) {
647
+					$extra_data['data'] = $recipient;
648
+				}
649
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
650
+					$shortcode_parser,
651
+					$questions,
652
+					$answers,
653
+					$template,
654
+					$valid_shortcodes,
655
+					$extra_data
656
+				);
657
+				break;
658
+
659
+			default:
660
+				return $parsed;
661
+				break;
662
+		}
663
+	}
664
+
665
+
666
+	/**
667
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
668
+	 *
669
+	 * @since   4.3.2
670
+	 *
671
+	 * @return  void
672
+	 */
673
+	public function register_caf_message_types()
674
+	{
675
+		// register newsletter message type
676
+		$setup_args = array(
677
+			'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678
+			'autoloadpaths'                                    => array(
679
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
680
+			),
681
+			'messengers_to_activate_with'                      => array('email'),
682
+			'messengers_to_validate_with'                      => array('email'),
683
+			'messengers_supporting_default_template_pack_with' => array('email'),
684
+		);
685
+		EE_Register_Message_Type::register('newsletter', $setup_args);
686
+
687
+		// register payment reminder message type
688
+		$setup_args = array(
689
+			'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
691
+			'messengers_to_activate_with'                      => array('email'),
692
+			'messengers_to_validate_with'                      => array('email'),
693
+			'messengers_supporting_default_template_pack_with' => array('email'),
694
+		);
695
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
696
+
697
+		// register payment declined message type
698
+		$setup_args = array(
699
+			'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
701
+			'messengers_to_activate_with'                      => array('email'),
702
+			'messengers_to_validate_with'                      => array('email'),
703
+			'messengers_supporting_default_template_pack_with' => array('email'),
704
+		);
705
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
706
+
707
+		// register registration declined message type
708
+		$setup_args = array(
709
+			'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
711
+			'messengers_to_activate_with'                      => array('email'),
712
+			'messengers_to_validate_with'                      => array('email'),
713
+			'messengers_supporting_default_template_pack_with' => array('email'),
714
+		);
715
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
716
+
717
+		// register registration cancelled message type
718
+		$setup_args = array(
719
+			'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
721
+			'messengers_to_activate_with'                      => array('email'),
722
+			'messengers_to_validate_with'                      => array('email'),
723
+			'messengers_supporting_default_template_pack_with' => array('email'),
724
+		);
725
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
726
+
727
+
728
+		// register payment failed message type
729
+		$setup_args = array(
730
+			'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
732
+			'messengers_to_activate_with'                      => array('email'),
733
+			'messengers_to_validate_with'                      => array('email'),
734
+			'messengers_supporting_default_template_pack_with' => array('email'),
735
+		);
736
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
737
+
738
+		// register payment declined message type
739
+		$setup_args = array(
740
+			'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
742
+			'messengers_to_activate_with'                      => array('email'),
743
+			'messengers_to_validate_with'                      => array('email'),
744
+			'messengers_supporting_default_template_pack_with' => array('email'),
745
+		);
746
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
747
+	}
748
+
749
+
750
+	/**
751
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
752
+	 *
753
+	 * @since   4.3.2
754
+	 *
755
+	 * @return void
756
+	 */
757
+	public function register_caf_shortcodes()
758
+	{
759
+		$setup_args = array(
760
+			'autoloadpaths'                 => array(
761
+				EE_CAF_LIBRARIES . 'shortcodes/',
762
+			),
763
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
765
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
766
+		);
767
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
768
+	}
769
+
770
+
771
+	/**
772
+	 * Parses a question list shortcode using given data and template
773
+	 *
774
+	 * @param \EE_Shortcodes $shortcode_parser
775
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
776
+	 * @param EE_Answer[]    $answers          An array of answer objects
777
+	 * @param string         $template         Template content to be parsed.
778
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
779
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
780
+	 */
781
+	protected function _parse_question_list_for_primary_or_recipient_registration(
782
+		$shortcode_parser,
783
+		$questions,
784
+		$answers,
785
+		$template,
786
+		$valid_shortcodes,
787
+		$extra_data
788
+	) {
789
+		$question_list = '';
790
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
791
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
792
+		foreach ($answers as $answer) {
793
+			if ($answer instanceof EE_Answer) {
794
+				// first see if the question is in our $questions array. If not then try to get from answer object.
795
+				$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
796
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
+				if (! $question instanceof EE_Question
798
+					|| (
799
+						$question instanceof EE_Question
800
+						&& $question->admin_only()
801
+					)
802
+				) {
803
+					continue;
804
+				}
805
+				$question_list .= $shortcode_helper->parse_question_list_template(
806
+					$template,
807
+					$answer,
808
+					$valid_shortcodes,
809
+					$extra_data
810
+				);
811
+			}
812
+		}
813
+		return $question_list;
814
+	}
815 815
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function messages_autoload_paths($dir_ref)
132 132
     {
133
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
133
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
134 134
 
135 135
         return $dir_ref;
136 136
     }
@@ -246,32 +246,32 @@  discard block
 block discarded – undo
246 246
     ) {
247 247
 
248 248
         // we're only modifying templates for the default template pack
249
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
249
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250 250
             return $contents;
251 251
         }
252 252
 
253 253
         // the template file name we're replacing contents for.
254
-        $template_file_prefix = $field . '_' . $context;
255
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
254
+        $template_file_prefix = $field.'_'.$context;
255
+        $msg_prefix = $messenger->name.'_'.$message_type->name.'_';
256 256
 
257
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
257
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
258 258
 
259 259
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
260 260
             switch ($template_file_prefix) {
261 261
                 case 'question_list_admin':
262 262
                 case 'question_list_attendee':
263 263
                 case 'question_list_primary_attendee':
264
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
264
+                    $path = $base_path.$msg_prefix.'question_list.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
 
268 268
                 case 'attendee_list_primary_attendee':
269
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
269
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
 
273 273
                 case 'attendee_list_admin':
274
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
274
+                    $path = $base_path.$msg_prefix.'attendee_list_admin.template.php';
275 275
                     $contents = EEH_Template::display_template(
276 276
                         $path,
277 277
                         array(),
@@ -284,31 +284,31 @@  discard block
 block discarded – undo
284 284
                     break;
285 285
 
286 286
                 case 'event_list_attendee':
287
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
287
+                    $path = $base_path.$msg_prefix.'event_list_attendee.template.php';
288 288
                     $contents = EEH_Template::display_template($path, array(), true);
289 289
                     break;
290 290
             }
291 291
         } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292 292
             switch ($template_file_prefix) {
293 293
                 case 'content_attendee':
294
-                    $path = $base_path . $msg_prefix . 'content.template.php';
294
+                    $path = $base_path.$msg_prefix.'content.template.php';
295 295
                     $contents = EEH_Template::display_template($path, array(), true);
296 296
                     break;
297 297
 
298 298
                 case 'newsletter_content_attendee':
299
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
299
+                    $path = $base_path.$msg_prefix.'newsletter_content.template.php';
300 300
                     $contents = EEH_Template::display_template($path, array(), true);
301 301
                     break;
302 302
 
303 303
                 case 'newsletter_subject_attendee':
304
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
304
+                    $path = $base_path.$msg_prefix.'subject.template.php';
305 305
                     $contents = EEH_Template::display_template($path, array(), true);
306 306
                     break;
307 307
             }
308 308
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309 309
             switch ($template_file_prefix) {
310 310
                 case 'attendee_list_purchaser':
311
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
311
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
312 312
                     $contents = EEH_Template::display_template($path, array(), true);
313 313
                     break;
314 314
             }
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
         if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340 340
             $contexts = array_keys($msg->get_contexts());
341 341
             foreach ($contexts as $context) {
342
-                $valid_shortcodes[ $context ][] = 'question_list';
343
-                $valid_shortcodes[ $context ][] = 'question';
342
+                $valid_shortcodes[$context][] = 'question_list';
343
+                $valid_shortcodes[$context][] = 'question';
344 344
             }
345 345
         }
346 346
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $extra_data
384 384
         ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385 385
 
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
386
+        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387 387
             return $parsed;
388 388
         }
389 389
 
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
         foreach ($aee->questions as $ansid => $question) {
392 392
             if ($question instanceof EE_Question
393 393
                 && trim($question->display_text()) == trim($shortcode)
394
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
394
+                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
395 395
             ) {
396
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
396
+                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty(
397 397
                     'ANS_value',
398 398
                     'no_wpautop'
399 399
                 );
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455 455
     {
456 456
 
457
-        if (! $data instanceof EE_Datetime) {
457
+        if ( ! $data instanceof EE_Datetime) {
458 458
             return ''; // get out because we can only parse with the datetime object.
459 459
         }
460 460
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508 508
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509 509
 
510
-        if (! $recipient instanceof EE_Messages_Addressee) {
510
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
511 511
             return $parsed;
512 512
         }
513 513
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
             case '[RECIPIENT_QUESTION_LIST]':
516 516
                 $att = $recipient->att_obj;
517 517
                 $registrations_on_attendee = $att instanceof EE_Attendee
518
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
518
+                    ? $recipient->attendees[$att->ID()]['reg_objs']
519 519
                     : array();
520 520
                 $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521 521
                 $answers = array();
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
                 if ($data['data'] instanceof EE_Messages_Addressee) {
530 530
                     foreach ($registrations_on_attendee as $reg) {
531 531
                         if ($reg instanceof EE_Registration) {
532
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
532
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
533
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
534 534
                                 : array();
535 535
                             foreach ($anss as $ans) {
536 536
                                 if ($ans instanceof EE_Answer) {
537
-                                    $answers[ $ans->ID() ] = $ans;
537
+                                    $answers[$ans->ID()] = $ans;
538 538
                                 }
539 539
                             }
540 540
                         }
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
                     $event = $data['data'];
547 547
                     foreach ($registrations_on_attendee as $reg) {
548 548
                         if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
549
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
550
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
551 551
                                 : array();
552 552
                             foreach ($anss as $ans) {
553 553
                                 if ($ans instanceof EE_Answer) {
554
-                                    $answers[ $ans->ID() ] = $ans;
554
+                                    $answers[$ans->ID()] = $ans;
555 555
                                 }
556 556
                             }
557 557
                         }
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564 564
                 // object on it.
565
-                if (! isset($extra_data['data'])) {
565
+                if ( ! isset($extra_data['data'])) {
566 566
                     $extra_data['data'] = $recipient;
567 567
                 }
568 568
 
@@ -619,18 +619,18 @@  discard block
 block discarded – undo
619 619
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620 620
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621 621
 
622
-        if (! $recipient instanceof EE_Messages_Addressee) {
622
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
623 623
             return $parsed;
624 624
         }
625 625
 
626 626
         switch ($shortcode) {
627 627
             case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
628
+                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629 629
                     return '';
630 630
                 }
631 631
                 $registration = $recipient->primary_reg_obj;
632
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
632
+                $answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
633
+                    ? $recipient->registrations[$registration->ID()]['ans_objs']
634 634
                     : array();
635 635
                 if (empty($answers)) {
636 636
                     return '';
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
                     ? $data['template']['question_list']
640 640
                     : $extra_data['template']['question_list'];
641 641
                 $valid_shortcodes = array('question');
642
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
642
+                $answers = $recipient->registrations[$registration->ID()]['ans_objs'];
643 643
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
644 644
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645 645
                 // object on it.
646
-                if (! isset($extra_data['data'])) {
646
+                if ( ! isset($extra_data['data'])) {
647 647
                     $extra_data['data'] = $recipient;
648 648
                 }
649 649
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         $setup_args = array(
677 677
             'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678 678
             'autoloadpaths'                                    => array(
679
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
679
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/',
680 680
             ),
681 681
             'messengers_to_activate_with'                      => array('email'),
682 682
             'messengers_to_validate_with'                      => array('email'),
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
         // register payment reminder message type
688 688
         $setup_args = array(
689 689
             'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
690
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
691 691
             'messengers_to_activate_with'                      => array('email'),
692 692
             'messengers_to_validate_with'                      => array('email'),
693 693
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
         // register payment declined message type
698 698
         $setup_args = array(
699 699
             'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
700
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
701 701
             'messengers_to_activate_with'                      => array('email'),
702 702
             'messengers_to_validate_with'                      => array('email'),
703 703
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
         // register registration declined message type
708 708
         $setup_args = array(
709 709
             'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
710
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
711 711
             'messengers_to_activate_with'                      => array('email'),
712 712
             'messengers_to_validate_with'                      => array('email'),
713 713
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         // register registration cancelled message type
718 718
         $setup_args = array(
719 719
             'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
720
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
721 721
             'messengers_to_activate_with'                      => array('email'),
722 722
             'messengers_to_validate_with'                      => array('email'),
723 723
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
         // register payment failed message type
729 729
         $setup_args = array(
730 730
             'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
731
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
732 732
             'messengers_to_activate_with'                      => array('email'),
733 733
             'messengers_to_validate_with'                      => array('email'),
734 734
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         // register payment declined message type
739 739
         $setup_args = array(
740 740
             'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
741
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
742 742
             'messengers_to_activate_with'                      => array('email'),
743 743
             'messengers_to_validate_with'                      => array('email'),
744 744
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     {
759 759
         $setup_args = array(
760 760
             'autoloadpaths'                 => array(
761
-                EE_CAF_LIBRARIES . 'shortcodes/',
761
+                EE_CAF_LIBRARIES.'shortcodes/',
762 762
             ),
763 763
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764 764
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
@@ -792,9 +792,9 @@  discard block
 block discarded – undo
792 792
         foreach ($answers as $answer) {
793 793
             if ($answer instanceof EE_Answer) {
794 794
                 // first see if the question is in our $questions array. If not then try to get from answer object.
795
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
795
+                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
796 796
                 $question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
-                if (! $question instanceof EE_Question
797
+                if ( ! $question instanceof EE_Question
798 798
                     || (
799 799
                         $question instanceof EE_Question
800 800
                         && $question->admin_only()
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
      * _get_transaction_and_cart_for_previous_visit
782 782
      *
783 783
      * @access private
784
-     * @return mixed EE_Transaction|NULL
784
+     * @return EE_Transaction|null EE_Transaction|NULL
785 785
      */
786 786
     private function _get_transaction_and_cart_for_previous_visit()
787 787
     {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
      *    generates a new EE_Transaction object and adds it to the $_transaction property.
864 864
      *
865 865
      * @access private
866
-     * @return mixed EE_Transaction|NULL
866
+     * @return EE_Transaction|null EE_Transaction|NULL
867 867
      */
868 868
     private function _initialize_transaction()
869 869
     {
Please login to merge, or discard this patch.
Indentation   +1796 added lines, -1796 removed lines patch added patch discarded remove patch
@@ -15,1800 +15,1800 @@
 block discarded – undo
15 15
 class EED_Single_Page_Checkout extends EED_Module
16 16
 {
17 17
 
18
-    /**
19
-     * $_initialized - has the SPCO controller already been initialized ?
20
-     *
21
-     * @access private
22
-     * @var bool $_initialized
23
-     */
24
-    private static $_initialized = false;
25
-
26
-
27
-    /**
28
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
29
-     *
30
-     * @access private
31
-     * @var bool $_valid_checkout
32
-     */
33
-    private static $_checkout_verified = true;
34
-
35
-    /**
36
-     *    $_reg_steps_array - holds initial array of reg steps
37
-     *
38
-     * @access private
39
-     * @var array $_reg_steps_array
40
-     */
41
-    private static $_reg_steps_array = array();
42
-
43
-    /**
44
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
45
-     *
46
-     * @access public
47
-     * @var EE_Checkout $checkout
48
-     */
49
-    public $checkout;
50
-
51
-
52
-    /**
53
-     * @return EED_Module|EED_Single_Page_Checkout
54
-     */
55
-    public static function instance()
56
-    {
57
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
58
-        return parent::get_instance(__CLASS__);
59
-    }
60
-
61
-
62
-    /**
63
-     * @return EE_CART
64
-     */
65
-    public function cart()
66
-    {
67
-        return $this->checkout->cart;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return EE_Transaction
73
-     */
74
-    public function transaction()
75
-    {
76
-        return $this->checkout->transaction;
77
-    }
78
-
79
-
80
-    /**
81
-     *    set_hooks - for hooking into EE Core, other modules, etc
82
-     *
83
-     * @access    public
84
-     * @return    void
85
-     * @throws EE_Error
86
-     */
87
-    public static function set_hooks()
88
-    {
89
-        EED_Single_Page_Checkout::set_definitions();
90
-    }
91
-
92
-
93
-    /**
94
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
95
-     *
96
-     * @access    public
97
-     * @return    void
98
-     * @throws EE_Error
99
-     */
100
-    public static function set_hooks_admin()
101
-    {
102
-        EED_Single_Page_Checkout::set_definitions();
103
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
104
-            return;
105
-        }
106
-        // going to start an output buffer in case anything gets accidentally output
107
-        // that might disrupt our JSON response
108
-        ob_start();
109
-        EED_Single_Page_Checkout::load_request_handler();
110
-        EED_Single_Page_Checkout::load_reg_steps();
111
-        // set ajax hooks
112
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
113
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
114
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
115
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
116
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
117
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
118
-    }
119
-
120
-
121
-    /**
122
-     *    process ajax request
123
-     *
124
-     * @param string $ajax_action
125
-     * @throws EE_Error
126
-     */
127
-    public static function process_ajax_request($ajax_action)
128
-    {
129
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
130
-        EED_Single_Page_Checkout::instance()->_initialize();
131
-    }
132
-
133
-
134
-    /**
135
-     *    ajax display registration step
136
-     *
137
-     * @throws EE_Error
138
-     */
139
-    public static function display_reg_step()
140
-    {
141
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
142
-    }
143
-
144
-
145
-    /**
146
-     *    ajax process registration step
147
-     *
148
-     * @throws EE_Error
149
-     */
150
-    public static function process_reg_step()
151
-    {
152
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
153
-    }
154
-
155
-
156
-    /**
157
-     *    ajax process registration step
158
-     *
159
-     * @throws EE_Error
160
-     */
161
-    public static function update_reg_step()
162
-    {
163
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
164
-    }
165
-
166
-
167
-    /**
168
-     *   update_checkout
169
-     *
170
-     * @access public
171
-     * @return void
172
-     * @throws EE_Error
173
-     */
174
-    public static function update_checkout()
175
-    {
176
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
177
-    }
178
-
179
-
180
-    /**
181
-     *    load_request_handler
182
-     *
183
-     * @access    public
184
-     * @return    void
185
-     */
186
-    public static function load_request_handler()
187
-    {
188
-        // load core Request_Handler class
189
-        if (EE_Registry::instance()->REQ !== null) {
190
-            EE_Registry::instance()->load_core('Request_Handler');
191
-        }
192
-    }
193
-
194
-
195
-    /**
196
-     *    set_definitions
197
-     *
198
-     * @access    public
199
-     * @return    void
200
-     * @throws EE_Error
201
-     */
202
-    public static function set_definitions()
203
-    {
204
-        if (defined('SPCO_BASE_PATH')) {
205
-            return;
206
-        }
207
-        define(
208
-            'SPCO_BASE_PATH',
209
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
210
-        );
211
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
212
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
213
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
214
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
215
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
216
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
217
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
218
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * load_reg_steps
225
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
226
-     *
227
-     * @access    private
228
-     * @throws EE_Error
229
-     */
230
-    public static function load_reg_steps()
231
-    {
232
-        static $reg_steps_loaded = false;
233
-        if ($reg_steps_loaded) {
234
-            return;
235
-        }
236
-        // filter list of reg_steps
237
-        $reg_steps_to_load = (array) apply_filters(
238
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
239
-            EED_Single_Page_Checkout::get_reg_steps()
240
-        );
241
-        // sort by key (order)
242
-        ksort($reg_steps_to_load);
243
-        // loop through folders
244
-        foreach ($reg_steps_to_load as $order => $reg_step) {
245
-            // we need a
246
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
247
-                // copy over to the reg_steps_array
248
-                EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
249
-                // register custom key route for each reg step
250
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
251
-                EE_Config::register_route(
252
-                    $reg_step['slug'],
253
-                    'EED_Single_Page_Checkout',
254
-                    'run',
255
-                    'step'
256
-                );
257
-                // add AJAX or other hooks
258
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
259
-                    // setup autoloaders if necessary
260
-                    if (! class_exists($reg_step['class_name'])) {
261
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
262
-                            $reg_step['file_path'],
263
-                            true
264
-                        );
265
-                    }
266
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
267
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
268
-                    }
269
-                }
270
-            }
271
-        }
272
-        $reg_steps_loaded = true;
273
-    }
274
-
275
-
276
-    /**
277
-     *    get_reg_steps
278
-     *
279
-     * @access    public
280
-     * @return    array
281
-     */
282
-    public static function get_reg_steps()
283
-    {
284
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
285
-        if (empty($reg_steps)) {
286
-            $reg_steps = array(
287
-                10  => array(
288
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
289
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
290
-                    'slug'       => 'attendee_information',
291
-                    'has_hooks'  => false,
292
-                ),
293
-                30  => array(
294
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
295
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
296
-                    'slug'       => 'payment_options',
297
-                    'has_hooks'  => true,
298
-                ),
299
-                999 => array(
300
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
301
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
302
-                    'slug'       => 'finalize_registration',
303
-                    'has_hooks'  => false,
304
-                ),
305
-            );
306
-        }
307
-        return $reg_steps;
308
-    }
309
-
310
-
311
-    /**
312
-     *    registration_checkout_for_admin
313
-     *
314
-     * @access    public
315
-     * @return    string
316
-     * @throws EE_Error
317
-     */
318
-    public static function registration_checkout_for_admin()
319
-    {
320
-        EED_Single_Page_Checkout::load_request_handler();
321
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
322
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
323
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
324
-        EED_Single_Page_Checkout::instance()->_initialize();
325
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
326
-        return EE_Registry::instance()->REQ->get_output();
327
-    }
328
-
329
-
330
-    /**
331
-     * process_registration_from_admin
332
-     *
333
-     * @access public
334
-     * @return \EE_Transaction
335
-     * @throws EE_Error
336
-     */
337
-    public static function process_registration_from_admin()
338
-    {
339
-        EED_Single_Page_Checkout::load_request_handler();
340
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
341
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
342
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
343
-        EED_Single_Page_Checkout::instance()->_initialize();
344
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
345
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
346
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
347
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
348
-                if ($final_reg_step->process_reg_step()) {
349
-                    $final_reg_step->set_completed();
350
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
351
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
352
-                }
353
-            }
354
-        }
355
-        return null;
356
-    }
357
-
358
-
359
-    /**
360
-     *    run
361
-     *
362
-     * @access    public
363
-     * @param WP_Query $WP_Query
364
-     * @return    void
365
-     * @throws EE_Error
366
-     */
367
-    public function run($WP_Query)
368
-    {
369
-        if ($WP_Query instanceof WP_Query
370
-            && $WP_Query->is_main_query()
371
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
372
-            && $this->_is_reg_checkout()
373
-        ) {
374
-            $this->_initialize();
375
-        }
376
-    }
377
-
378
-
379
-    /**
380
-     * determines whether current url matches reg page url
381
-     *
382
-     * @return bool
383
-     */
384
-    protected function _is_reg_checkout()
385
-    {
386
-        // get current permalink for reg page without any extra query args
387
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
388
-        // get request URI for current request, but without the scheme or host
389
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
390
-        $current_request_uri = html_entity_decode($current_request_uri);
391
-        // get array of query args from the current request URI
392
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
393
-        // grab page id if it is set
394
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
395
-        // and remove the page id from the query args (we will re-add it later)
396
-        unset($query_args['page_id']);
397
-        // now strip all query args from current request URI
398
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
399
-        // and re-add the page id if it was set
400
-        if ($page_id) {
401
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
402
-        }
403
-        // remove slashes and ?
404
-        $current_request_uri = trim($current_request_uri, '?/');
405
-        // is current request URI part of the known full reg page URL ?
406
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
407
-    }
408
-
409
-
410
-    /**
411
-     * @param WP_Query $wp_query
412
-     * @return    void
413
-     * @throws EE_Error
414
-     */
415
-    public static function init($wp_query)
416
-    {
417
-        EED_Single_Page_Checkout::instance()->run($wp_query);
418
-    }
419
-
420
-
421
-    /**
422
-     *    _initialize - initial module setup
423
-     *
424
-     * @access    private
425
-     * @throws EE_Error
426
-     * @return    void
427
-     */
428
-    private function _initialize()
429
-    {
430
-        // ensure SPCO doesn't run twice
431
-        if (EED_Single_Page_Checkout::$_initialized) {
432
-            return;
433
-        }
434
-        try {
435
-            EED_Single_Page_Checkout::load_reg_steps();
436
-            $this->_verify_session();
437
-            // setup the EE_Checkout object
438
-            $this->checkout = $this->_initialize_checkout();
439
-            // filter checkout
440
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
441
-            // get the $_GET
442
-            $this->_get_request_vars();
443
-            if ($this->_block_bots()) {
444
-                return;
445
-            }
446
-            // filter continue_reg
447
-            $this->checkout->continue_reg = apply_filters(
448
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
449
-                true,
450
-                $this->checkout
451
-            );
452
-            // load the reg steps array
453
-            if (! $this->_load_and_instantiate_reg_steps()) {
454
-                EED_Single_Page_Checkout::$_initialized = true;
455
-                return;
456
-            }
457
-            // set the current step
458
-            $this->checkout->set_current_step($this->checkout->step);
459
-            // and the next step
460
-            $this->checkout->set_next_step();
461
-            // verify that everything has been setup correctly
462
-            if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
463
-                EED_Single_Page_Checkout::$_initialized = true;
464
-                return;
465
-            }
466
-            // lock the transaction
467
-            $this->checkout->transaction->lock();
468
-            // make sure all of our cached objects are added to their respective model entity mappers
469
-            $this->checkout->refresh_all_entities();
470
-            // set amount owing
471
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
472
-            // initialize each reg step, which gives them the chance to potentially alter the process
473
-            $this->_initialize_reg_steps();
474
-            // DEBUG LOG
475
-            // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
476
-            // get reg form
477
-            if (! $this->_check_form_submission()) {
478
-                EED_Single_Page_Checkout::$_initialized = true;
479
-                return;
480
-            }
481
-            // checkout the action!!!
482
-            $this->_process_form_action();
483
-            // add some style and make it dance
484
-            $this->add_styles_and_scripts();
485
-            // kk... SPCO has successfully run
486
-            EED_Single_Page_Checkout::$_initialized = true;
487
-            // set no cache headers and constants
488
-            EE_System::do_not_cache();
489
-            // add anchor
490
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
491
-            // remove transaction lock
492
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
493
-        } catch (Exception $e) {
494
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
495
-        }
496
-    }
497
-
498
-
499
-    /**
500
-     *    _verify_session
501
-     * checks that the session is valid and not expired
502
-     *
503
-     * @access    private
504
-     * @throws EE_Error
505
-     */
506
-    private function _verify_session()
507
-    {
508
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
509
-            throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
510
-        }
511
-        $clear_session_requested = filter_var(
512
-            EE_Registry::instance()->REQ->get('clear_session', false),
513
-            FILTER_VALIDATE_BOOLEAN
514
-        );
515
-        // is session still valid ?
516
-        if ($clear_session_requested
517
-            || (EE_Registry::instance()->SSN->expired()
518
-                && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
519
-            )
520
-        ) {
521
-            $this->checkout = new EE_Checkout();
522
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
523
-            // EE_Registry::instance()->SSN->reset_cart();
524
-            // EE_Registry::instance()->SSN->reset_checkout();
525
-            // EE_Registry::instance()->SSN->reset_transaction();
526
-            if (! $clear_session_requested) {
527
-                EE_Error::add_attention(
528
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
529
-                    __FILE__,
530
-                    __FUNCTION__,
531
-                    __LINE__
532
-                );
533
-            }
534
-            // EE_Registry::instance()->SSN->reset_expired();
535
-        }
536
-    }
537
-
538
-
539
-    /**
540
-     *    _initialize_checkout
541
-     * loads and instantiates EE_Checkout
542
-     *
543
-     * @access    private
544
-     * @throws EE_Error
545
-     * @return EE_Checkout
546
-     */
547
-    private function _initialize_checkout()
548
-    {
549
-        // look in session for existing checkout
550
-        /** @type EE_Checkout $checkout */
551
-        $checkout = EE_Registry::instance()->SSN->checkout();
552
-        // verify
553
-        if (! $checkout instanceof EE_Checkout) {
554
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
555
-            $checkout = EE_Registry::instance()->load_file(
556
-                SPCO_INC_PATH,
557
-                'EE_Checkout',
558
-                'class',
559
-                array(),
560
-                false
561
-            );
562
-        } else {
563
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
564
-                $this->unlock_transaction();
565
-                wp_safe_redirect($checkout->redirect_url);
566
-                exit();
567
-            }
568
-        }
569
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
570
-        // verify again
571
-        if (! $checkout instanceof EE_Checkout) {
572
-            throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
573
-        }
574
-        // reset anything that needs a clean slate for each request
575
-        $checkout->reset_for_current_request();
576
-        return $checkout;
577
-    }
578
-
579
-
580
-    /**
581
-     *    _get_request_vars
582
-     *
583
-     * @access    private
584
-     * @return    void
585
-     * @throws EE_Error
586
-     */
587
-    private function _get_request_vars()
588
-    {
589
-        // load classes
590
-        EED_Single_Page_Checkout::load_request_handler();
591
-        // make sure this request is marked as belonging to EE
592
-        EE_Registry::instance()->REQ->set_espresso_page(true);
593
-        // which step is being requested ?
594
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
595
-        // which step is being edited ?
596
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
597
-        // and what we're doing on the current step
598
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
599
-        // timestamp
600
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
601
-        // returning to edit ?
602
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
603
-        // add reg url link to registration query params
604
-        if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
605
-            $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
606
-        }
607
-        // or some other kind of revisit ?
608
-        $this->checkout->revisit = filter_var(
609
-            EE_Registry::instance()->REQ->get('revisit', false),
610
-            FILTER_VALIDATE_BOOLEAN
611
-        );
612
-        // and whether or not to generate a reg form for this request
613
-        $this->checkout->generate_reg_form = filter_var(
614
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
615
-            FILTER_VALIDATE_BOOLEAN
616
-        );
617
-        // and whether or not to process a reg form submission for this request
618
-        $this->checkout->process_form_submission = filter_var(
619
-            EE_Registry::instance()->REQ->get(
620
-                'process_form_submission',
621
-                $this->checkout->action === 'process_reg_step'
622
-            ),
623
-            FILTER_VALIDATE_BOOLEAN
624
-        );
625
-        $this->checkout->process_form_submission = filter_var(
626
-            $this->checkout->action !== 'display_spco_reg_step'
627
-                ? $this->checkout->process_form_submission
628
-                : false,
629
-            FILTER_VALIDATE_BOOLEAN
630
-        );
631
-        // $this->_display_request_vars();
632
-    }
633
-
634
-
635
-    /**
636
-     *  _display_request_vars
637
-     *
638
-     * @access    protected
639
-     * @return    void
640
-     */
641
-    protected function _display_request_vars()
642
-    {
643
-        if (! WP_DEBUG) {
644
-            return;
645
-        }
646
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
647
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
648
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
649
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
650
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
651
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
652
-        EEH_Debug_Tools::printr(
653
-            $this->checkout->generate_reg_form,
654
-            '$this->checkout->generate_reg_form',
655
-            __FILE__,
656
-            __LINE__
657
-        );
658
-        EEH_Debug_Tools::printr(
659
-            $this->checkout->process_form_submission,
660
-            '$this->checkout->process_form_submission',
661
-            __FILE__,
662
-            __LINE__
663
-        );
664
-    }
665
-
666
-
667
-    /**
668
-     * _block_bots
669
-     * checks that the incoming request has either of the following set:
670
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
671
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
672
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
673
-     * then where you coming from man?
674
-     *
675
-     * @return boolean
676
-     */
677
-    private function _block_bots()
678
-    {
679
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
680
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
681
-            return true;
682
-        }
683
-        return false;
684
-    }
685
-
686
-
687
-    /**
688
-     *    _get_first_step
689
-     *  gets slug for first step in $_reg_steps_array
690
-     *
691
-     * @access    private
692
-     * @throws EE_Error
693
-     * @return    string
694
-     */
695
-    private function _get_first_step()
696
-    {
697
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
698
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
699
-    }
700
-
701
-
702
-    /**
703
-     * instantiates each reg step based on the loaded reg_steps array
704
-     *
705
-     * @return    bool
706
-     * @throws EE_Error
707
-     * @throws InvalidArgumentException
708
-     * @throws InvalidDataTypeException
709
-     * @throws InvalidInterfaceException
710
-     */
711
-    private function _load_and_instantiate_reg_steps()
712
-    {
713
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
714
-        // have reg_steps already been instantiated ?
715
-        if (empty($this->checkout->reg_steps)
716
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
717
-        ) {
718
-            // if not, then loop through raw reg steps array
719
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
720
-                if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
721
-                    return false;
722
-                }
723
-            }
724
-            if (isset($this->checkout->reg_steps['registration_confirmation'])) {
725
-                // skip the registration_confirmation page ?
726
-                if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
727
-                    // just remove it from the reg steps array
728
-                    $this->checkout->remove_reg_step('registration_confirmation', false);
729
-                } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last
730
-                ) {
731
-                    // set the order to something big like 100
732
-                    $this->checkout->set_reg_step_order('registration_confirmation', 100);
733
-                }
734
-            }
735
-            // filter the array for good luck
736
-            $this->checkout->reg_steps = apply_filters(
737
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
738
-                $this->checkout->reg_steps
739
-            );
740
-            // finally re-sort based on the reg step class order properties
741
-            $this->checkout->sort_reg_steps();
742
-        } else {
743
-            foreach ($this->checkout->reg_steps as $reg_step) {
744
-                // set all current step stati to FALSE
745
-                $reg_step->set_is_current_step(false);
746
-            }
747
-        }
748
-        if (empty($this->checkout->reg_steps)) {
749
-            EE_Error::add_error(
750
-                esc_html__('No Reg Steps were loaded..', 'event_espresso'),
751
-                __FILE__,
752
-                __FUNCTION__,
753
-                __LINE__
754
-            );
755
-            return false;
756
-        }
757
-        // make reg step details available to JS
758
-        $this->checkout->set_reg_step_JSON_info();
759
-        return true;
760
-    }
761
-
762
-
763
-    /**
764
-     *     _load_and_instantiate_reg_step
765
-     *
766
-     * @access    private
767
-     * @param array $reg_step
768
-     * @param int   $order
769
-     * @return bool
770
-     */
771
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
772
-    {
773
-        // we need a file_path, class_name, and slug to add a reg step
774
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
775
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
776
-            if ($this->checkout->reg_url_link
777
-                && $this->checkout->step !== $reg_step['slug']
778
-                && $reg_step['slug'] !== 'finalize_registration'
779
-                // normally at this point we would NOT load the reg step, but this filter can change that
780
-                && apply_filters(
781
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
782
-                    true,
783
-                    $reg_step,
784
-                    $this->checkout
785
-                )
786
-            ) {
787
-                return true;
788
-            }
789
-            // instantiate step class using file path and class name
790
-            $reg_step_obj = EE_Registry::instance()->load_file(
791
-                $reg_step['file_path'],
792
-                $reg_step['class_name'],
793
-                'class',
794
-                $this->checkout,
795
-                false
796
-            );
797
-            // did we gets the goods ?
798
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
799
-                // set reg step order based on config
800
-                $reg_step_obj->set_order($order);
801
-                // add instantiated reg step object to the master reg steps array
802
-                $this->checkout->add_reg_step($reg_step_obj);
803
-            } else {
804
-                EE_Error::add_error(
805
-                    esc_html__('The current step could not be set.', 'event_espresso'),
806
-                    __FILE__,
807
-                    __FUNCTION__,
808
-                    __LINE__
809
-                );
810
-                return false;
811
-            }
812
-        } else {
813
-            if (WP_DEBUG) {
814
-                EE_Error::add_error(
815
-                    sprintf(
816
-                        esc_html__(
817
-                            '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',
818
-                            'event_espresso'
819
-                        ),
820
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
821
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
822
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
823
-                        '<ul>',
824
-                        '<li>',
825
-                        '</li>',
826
-                        '</ul>'
827
-                    ),
828
-                    __FILE__,
829
-                    __FUNCTION__,
830
-                    __LINE__
831
-                );
832
-            }
833
-            return false;
834
-        }
835
-        return true;
836
-    }
837
-
838
-
839
-    /**
840
-     * _verify_transaction_and_get_registrations
841
-     *
842
-     * @access private
843
-     * @return bool
844
-     * @throws InvalidDataTypeException
845
-     * @throws InvalidEntityException
846
-     * @throws EE_Error
847
-     */
848
-    private function _verify_transaction_and_get_registrations()
849
-    {
850
-        // was there already a valid transaction in the checkout from the session ?
851
-        if (! $this->checkout->transaction instanceof EE_Transaction) {
852
-            // get transaction from db or session
853
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
854
-                ? $this->_get_transaction_and_cart_for_previous_visit()
855
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
856
-            if (! $this->checkout->transaction instanceof EE_Transaction) {
857
-                EE_Error::add_error(
858
-                    esc_html__(
859
-                        'Your Registration and Transaction information could not be retrieved from the db.',
860
-                        'event_espresso'
861
-                    ),
862
-                    __FILE__,
863
-                    __FUNCTION__,
864
-                    __LINE__
865
-                );
866
-                $this->checkout->transaction = EE_Transaction::new_instance();
867
-                // add some style and make it dance
868
-                $this->add_styles_and_scripts();
869
-                EED_Single_Page_Checkout::$_initialized = true;
870
-                return false;
871
-            }
872
-            // and the registrations for the transaction
873
-            $this->_get_registrations($this->checkout->transaction);
874
-        }
875
-        return true;
876
-    }
877
-
878
-
879
-    /**
880
-     * _get_transaction_and_cart_for_previous_visit
881
-     *
882
-     * @access private
883
-     * @return mixed EE_Transaction|NULL
884
-     */
885
-    private function _get_transaction_and_cart_for_previous_visit()
886
-    {
887
-        /** @var $TXN_model EEM_Transaction */
888
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
889
-        // because the reg_url_link is present in the request,
890
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
891
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
892
-        // verify transaction
893
-        if ($transaction instanceof EE_Transaction) {
894
-            // and get the cart that was used for that transaction
895
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
896
-            return $transaction;
897
-        }
898
-        EE_Error::add_error(
899
-            esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
900
-            __FILE__,
901
-            __FUNCTION__,
902
-            __LINE__
903
-        );
904
-        return null;
905
-    }
906
-
907
-
908
-    /**
909
-     * _get_cart_for_transaction
910
-     *
911
-     * @access private
912
-     * @param EE_Transaction $transaction
913
-     * @return EE_Cart
914
-     */
915
-    private function _get_cart_for_transaction($transaction)
916
-    {
917
-        return $this->checkout->get_cart_for_transaction($transaction);
918
-    }
919
-
920
-
921
-    /**
922
-     * get_cart_for_transaction
923
-     *
924
-     * @access public
925
-     * @param EE_Transaction $transaction
926
-     * @return EE_Cart
927
-     */
928
-    public function get_cart_for_transaction(EE_Transaction $transaction)
929
-    {
930
-        return $this->checkout->get_cart_for_transaction($transaction);
931
-    }
932
-
933
-
934
-    /**
935
-     * _get_transaction_and_cart_for_current_session
936
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
937
-     *
938
-     * @access private
939
-     * @return EE_Transaction
940
-     * @throws EE_Error
941
-     */
942
-    private function _get_cart_for_current_session_and_setup_new_transaction()
943
-    {
944
-        //  if there's no transaction, then this is the FIRST visit to SPCO
945
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
946
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
947
-        // and then create a new transaction
948
-        $transaction = $this->_initialize_transaction();
949
-        // verify transaction
950
-        if ($transaction instanceof EE_Transaction) {
951
-            // save it so that we have an ID for other objects to use
952
-            $transaction->save();
953
-            // and save TXN data to the cart
954
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
955
-        } else {
956
-            EE_Error::add_error(
957
-                esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'),
958
-                __FILE__,
959
-                __FUNCTION__,
960
-                __LINE__
961
-            );
962
-        }
963
-        return $transaction;
964
-    }
965
-
966
-
967
-    /**
968
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
969
-     *
970
-     * @access private
971
-     * @return mixed EE_Transaction|NULL
972
-     */
973
-    private function _initialize_transaction()
974
-    {
975
-        try {
976
-            // ensure cart totals have been calculated
977
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
978
-            // grab the cart grand total
979
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
980
-            // create new TXN
981
-            $transaction = EE_Transaction::new_instance(
982
-                array(
983
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
984
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
985
-                    'TXN_paid'      => 0,
986
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
987
-                )
988
-            );
989
-            // save it so that we have an ID for other objects to use
990
-            $transaction->save();
991
-            // set cron job for following up on TXNs after their session has expired
992
-            EE_Cron_Tasks::schedule_expired_transaction_check(
993
-                EE_Registry::instance()->SSN->expiration() + 1,
994
-                $transaction->ID()
995
-            );
996
-            return $transaction;
997
-        } catch (Exception $e) {
998
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
999
-        }
1000
-        return null;
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * _get_registrations
1006
-     *
1007
-     * @access private
1008
-     * @param EE_Transaction $transaction
1009
-     * @return void
1010
-     * @throws InvalidDataTypeException
1011
-     * @throws InvalidEntityException
1012
-     * @throws EE_Error
1013
-     */
1014
-    private function _get_registrations(EE_Transaction $transaction)
1015
-    {
1016
-        // first step: grab the registrants  { : o
1017
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1018
-        $this->checkout->total_ticket_count = count($registrations);
1019
-        // verify registrations have been set
1020
-        if (empty($registrations)) {
1021
-            // if no cached registrations, then check the db
1022
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1023
-            // still nothing ? well as long as this isn't a revisit
1024
-            if (empty($registrations) && ! $this->checkout->revisit) {
1025
-                // generate new registrations from scratch
1026
-                $registrations = $this->_initialize_registrations($transaction);
1027
-            }
1028
-        }
1029
-        // sort by their original registration order
1030
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1031
-        // then loop thru the array
1032
-        foreach ($registrations as $registration) {
1033
-            // verify each registration
1034
-            if ($registration instanceof EE_Registration) {
1035
-                // we display all attendee info for the primary registrant
1036
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1037
-                    && $registration->is_primary_registrant()
1038
-                ) {
1039
-                    $this->checkout->primary_revisit = true;
1040
-                    break;
1041
-                }
1042
-                if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1043
-                    // but hide info if it doesn't belong to you
1044
-                    $transaction->clear_cache('Registration', $registration->ID());
1045
-                    $this->checkout->total_ticket_count--;
1046
-                }
1047
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1048
-            }
1049
-        }
1050
-    }
1051
-
1052
-
1053
-    /**
1054
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1055
-     *
1056
-     * @access private
1057
-     * @param EE_Transaction $transaction
1058
-     * @return    array
1059
-     * @throws InvalidDataTypeException
1060
-     * @throws InvalidEntityException
1061
-     * @throws EE_Error
1062
-     */
1063
-    private function _initialize_registrations(EE_Transaction $transaction)
1064
-    {
1065
-        $att_nmbr = 0;
1066
-        $registrations = array();
1067
-        if ($transaction instanceof EE_Transaction) {
1068
-            /** @type EE_Registration_Processor $registration_processor */
1069
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1070
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1071
-            // now let's add the cart items to the $transaction
1072
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1073
-                // do the following for each ticket of this type they selected
1074
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1075
-                    $att_nmbr++;
1076
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1077
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1078
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1079
-                        array(
1080
-                            $transaction,
1081
-                            $line_item,
1082
-                            $att_nmbr,
1083
-                            $this->checkout->total_ticket_count,
1084
-                        )
1085
-                    );
1086
-                    // override capabilities for frontend registrations
1087
-                    if (! is_admin()) {
1088
-                        $CreateRegistrationCommand->setCapCheck(
1089
-                            new PublicCapabilities('', 'create_new_registration')
1090
-                        );
1091
-                    }
1092
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1093
-                    if (! $registration instanceof EE_Registration) {
1094
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1095
-                    }
1096
-                    $registrations[ $registration->ID() ] = $registration;
1097
-                }
1098
-            }
1099
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1100
-        }
1101
-        return $registrations;
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * sorts registrations by REG_count
1107
-     *
1108
-     * @access public
1109
-     * @param EE_Registration $reg_A
1110
-     * @param EE_Registration $reg_B
1111
-     * @return int
1112
-     */
1113
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1114
-    {
1115
-        // this shouldn't ever happen within the same TXN, but oh well
1116
-        if ($reg_A->count() === $reg_B->count()) {
1117
-            return 0;
1118
-        }
1119
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1120
-    }
1121
-
1122
-
1123
-    /**
1124
-     *    _final_verifications
1125
-     * just makes sure that everything is set up correctly before proceeding
1126
-     *
1127
-     * @access    private
1128
-     * @return    bool
1129
-     * @throws EE_Error
1130
-     */
1131
-    private function _final_verifications()
1132
-    {
1133
-        // filter checkout
1134
-        $this->checkout = apply_filters(
1135
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1136
-            $this->checkout
1137
-        );
1138
-        // verify that current step is still set correctly
1139
-        if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1140
-            EE_Error::add_error(
1141
-                esc_html__(
1142
-                    '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.',
1143
-                    'event_espresso'
1144
-                ),
1145
-                __FILE__,
1146
-                __FUNCTION__,
1147
-                __LINE__
1148
-            );
1149
-            return false;
1150
-        }
1151
-        // if returning to SPCO, then verify that primary registrant is set
1152
-        if (! empty($this->checkout->reg_url_link)) {
1153
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1154
-            if (! $valid_registrant instanceof EE_Registration) {
1155
-                EE_Error::add_error(
1156
-                    esc_html__(
1157
-                        '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.',
1158
-                        'event_espresso'
1159
-                    ),
1160
-                    __FILE__,
1161
-                    __FUNCTION__,
1162
-                    __LINE__
1163
-                );
1164
-                return false;
1165
-            }
1166
-            $valid_registrant = null;
1167
-            foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1168
-                if ($registration instanceof EE_Registration
1169
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1170
-                ) {
1171
-                    $valid_registrant = $registration;
1172
-                }
1173
-            }
1174
-            if (! $valid_registrant instanceof EE_Registration) {
1175
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1176
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1177
-                    // clear the session, mark the checkout as unverified, and try again
1178
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1179
-                    EED_Single_Page_Checkout::$_initialized = false;
1180
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1181
-                    $this->_initialize();
1182
-                    EE_Error::reset_notices();
1183
-                    return false;
1184
-                }
1185
-                EE_Error::add_error(
1186
-                    esc_html__(
1187
-                        '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.',
1188
-                        'event_espresso'
1189
-                    ),
1190
-                    __FILE__,
1191
-                    __FUNCTION__,
1192
-                    __LINE__
1193
-                );
1194
-                return false;
1195
-            }
1196
-        }
1197
-        // now that things have been kinda sufficiently verified,
1198
-        // let's add the checkout to the session so that it's available to other systems
1199
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1200
-        return true;
1201
-    }
1202
-
1203
-
1204
-    /**
1205
-     *    _initialize_reg_steps
1206
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1207
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1208
-     *
1209
-     * @access    private
1210
-     * @param bool $reinitializing
1211
-     * @throws EE_Error
1212
-     */
1213
-    private function _initialize_reg_steps($reinitializing = false)
1214
-    {
1215
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1216
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1217
-        foreach ($this->checkout->reg_steps as $reg_step) {
1218
-            if (! $reg_step->initialize_reg_step()) {
1219
-                // if not initialized then maybe this step is being removed...
1220
-                if (! $reinitializing && $reg_step->is_current_step()) {
1221
-                    // if it was the current step, then we need to start over here
1222
-                    $this->_initialize_reg_steps(true);
1223
-                    return;
1224
-                }
1225
-                continue;
1226
-            }
1227
-            // add css and JS for current step
1228
-            $reg_step->enqueue_styles_and_scripts();
1229
-            // i18n
1230
-            $reg_step->translate_js_strings();
1231
-            if ($reg_step->is_current_step()) {
1232
-                // the text that appears on the reg step form submit button
1233
-                $reg_step->set_submit_button_text();
1234
-            }
1235
-        }
1236
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1237
-        do_action(
1238
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1239
-            $this->checkout->current_step
1240
-        );
1241
-    }
1242
-
1243
-
1244
-    /**
1245
-     * _check_form_submission
1246
-     *
1247
-     * @access private
1248
-     * @return boolean
1249
-     */
1250
-    private function _check_form_submission()
1251
-    {
1252
-        // does this request require the reg form to be generated ?
1253
-        if ($this->checkout->generate_reg_form) {
1254
-            // ever heard that song by Blue Rodeo ?
1255
-            try {
1256
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1257
-                // if not displaying a form, then check for form submission
1258
-                if ($this->checkout->process_form_submission
1259
-                    && $this->checkout->current_step->reg_form->was_submitted()
1260
-                ) {
1261
-                    // clear out any old data in case this step is being run again
1262
-                    $this->checkout->current_step->set_valid_data(array());
1263
-                    // capture submitted form data
1264
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1265
-                        apply_filters(
1266
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1267
-                            EE_Registry::instance()->REQ->params(),
1268
-                            $this->checkout
1269
-                        )
1270
-                    );
1271
-                    // validate submitted form data
1272
-                    if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1273
-                        // thou shall not pass !!!
1274
-                        $this->checkout->continue_reg = false;
1275
-                        // any form validation errors?
1276
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1277
-                            EE_Error::add_error(
1278
-                                $this->checkout->current_step->reg_form->submission_error_message(),
1279
-                                __FILE__,
1280
-                                __FUNCTION__,
1281
-                                __LINE__
1282
-                            );
1283
-                        }
1284
-                        // well not really... what will happen is
1285
-                        // we'll just get redirected back to redo the current step
1286
-                        $this->go_to_next_step();
1287
-                        return false;
1288
-                    }
1289
-                }
1290
-            } catch (EE_Error $e) {
1291
-                $e->get_error();
1292
-            }
1293
-        }
1294
-        return true;
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     * _process_action
1300
-     *
1301
-     * @access private
1302
-     * @return void
1303
-     * @throws EE_Error
1304
-     */
1305
-    private function _process_form_action()
1306
-    {
1307
-        // what cha wanna do?
1308
-        switch ($this->checkout->action) {
1309
-            // AJAX next step reg form
1310
-            case 'display_spco_reg_step':
1311
-                $this->checkout->redirect = false;
1312
-                if (EE_Registry::instance()->REQ->ajax) {
1313
-                    $this->checkout->json_response->set_reg_step_html(
1314
-                        $this->checkout->current_step->display_reg_form()
1315
-                    );
1316
-                }
1317
-                break;
1318
-            default:
1319
-                // meh... do one of those other steps first
1320
-                if (! empty($this->checkout->action)
1321
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1322
-                ) {
1323
-                    // dynamically creates hook point like:
1324
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1325
-                    do_action(
1326
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1327
-                        $this->checkout->current_step
1328
-                    );
1329
-                    // call action on current step
1330
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1331
-                        // good registrant, you get to proceed
1332
-                        if ($this->checkout->current_step->success_message() !== ''
1333
-                            && apply_filters(
1334
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1335
-                                false
1336
-                            )
1337
-                        ) {
1338
-                            EE_Error::add_success(
1339
-                                $this->checkout->current_step->success_message()
1340
-                                . '<br />' . $this->checkout->next_step->_instructions()
1341
-                            );
1342
-                        }
1343
-                        // pack it up, pack it in...
1344
-                        $this->_setup_redirect();
1345
-                    }
1346
-                    // dynamically creates hook point like:
1347
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1348
-                    do_action(
1349
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1350
-                        $this->checkout->current_step
1351
-                    );
1352
-                } else {
1353
-                    EE_Error::add_error(
1354
-                        sprintf(
1355
-                            esc_html__(
1356
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1357
-                                'event_espresso'
1358
-                            ),
1359
-                            $this->checkout->action,
1360
-                            $this->checkout->current_step->name()
1361
-                        ),
1362
-                        __FILE__,
1363
-                        __FUNCTION__,
1364
-                        __LINE__
1365
-                    );
1366
-                }
1367
-            // end default
1368
-        }
1369
-        // store our progress so far
1370
-        $this->checkout->stash_transaction_and_checkout();
1371
-        // advance to the next step! If you pass GO, collect $200
1372
-        $this->go_to_next_step();
1373
-    }
1374
-
1375
-
1376
-    /**
1377
-     *        add_styles_and_scripts
1378
-     *
1379
-     * @access        public
1380
-     * @return        void
1381
-     */
1382
-    public function add_styles_and_scripts()
1383
-    {
1384
-        // i18n
1385
-        $this->translate_js_strings();
1386
-        if ($this->checkout->admin_request) {
1387
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1388
-        } else {
1389
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1390
-        }
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     *        translate_js_strings
1396
-     *
1397
-     * @access        public
1398
-     * @return        void
1399
-     */
1400
-    public function translate_js_strings()
1401
-    {
1402
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1403
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1404
-        EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
1405
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1406
-            'event_espresso'
1407
-        );
1408
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__(
1409
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1410
-            'event_espresso'
1411
-        );
1412
-        EE_Registry::$i18n_js_strings['validation_error'] = esc_html__(
1413
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1414
-            'event_espresso'
1415
-        );
1416
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
1417
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1418
-            'event_espresso'
1419
-        );
1420
-        EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__(
1421
-            'This registration step could not be completed. Please refresh the page and try again.',
1422
-            'event_espresso'
1423
-        );
1424
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__(
1425
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1426
-            'event_espresso'
1427
-        );
1428
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1429
-            esc_html__(
1430
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1431
-                'event_espresso'
1432
-            ),
1433
-            '<br/>',
1434
-            '<br/>'
1435
-        );
1436
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1437
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1438
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1439
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1440
-        EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso');
1441
-        EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso');
1442
-        EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso');
1443
-        EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso');
1444
-        EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso');
1445
-        EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso');
1446
-        EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso');
1447
-        EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso');
1448
-        EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso');
1449
-        EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso');
1450
-        EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso');
1451
-        EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso');
1452
-        EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso');
1453
-        EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso');
1454
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
1455
-        );
1456
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1457
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1458
-            true
1459
-        );
1460
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1461
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1462
-        );
1463
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1464
-            'M d, Y H:i:s',
1465
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1466
-        );
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     *    enqueue_styles_and_scripts
1472
-     *
1473
-     * @access        public
1474
-     * @return        void
1475
-     * @throws EE_Error
1476
-     */
1477
-    public function enqueue_styles_and_scripts()
1478
-    {
1479
-        // load css
1480
-        wp_register_style(
1481
-            'single_page_checkout',
1482
-            SPCO_CSS_URL . 'single_page_checkout.css',
1483
-            array('espresso_default'),
1484
-            EVENT_ESPRESSO_VERSION
1485
-        );
1486
-        wp_enqueue_style('single_page_checkout');
1487
-        // load JS
1488
-        wp_register_script(
1489
-            'jquery_plugin',
1490
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1491
-            array('jquery'),
1492
-            '1.0.1',
1493
-            true
1494
-        );
1495
-        wp_register_script(
1496
-            'jquery_countdown',
1497
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1498
-            array('jquery_plugin'),
1499
-            '2.1.0',
1500
-            true
1501
-        );
1502
-        wp_register_script(
1503
-            'single_page_checkout',
1504
-            SPCO_JS_URL . 'single_page_checkout.js',
1505
-            array('espresso_core', 'underscore', 'ee_form_section_validation'),
1506
-            EVENT_ESPRESSO_VERSION,
1507
-            true
1508
-        );
1509
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1510
-            $this->checkout->registration_form->enqueue_js();
1511
-        }
1512
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1513
-            $this->checkout->current_step->reg_form->enqueue_js();
1514
-        }
1515
-        wp_enqueue_script('single_page_checkout');
1516
-        if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) {
1517
-            wp_enqueue_script('jquery_countdown');
1518
-        }
1519
-        /**
1520
-         * global action hook for enqueueing styles and scripts with
1521
-         * spco calls.
1522
-         */
1523
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1524
-        /**
1525
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1526
-         * The hook will end up being something like:
1527
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1528
-         */
1529
-        do_action(
1530
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1531
-            $this
1532
-        );
1533
-    }
1534
-
1535
-
1536
-    /**
1537
-     *    display the Registration Single Page Checkout Form
1538
-     *
1539
-     * @access    private
1540
-     * @return    void
1541
-     * @throws EE_Error
1542
-     */
1543
-    private function _display_spco_reg_form()
1544
-    {
1545
-        // if registering via the admin, just display the reg form for the current step
1546
-        if ($this->checkout->admin_request) {
1547
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1548
-        } else {
1549
-            // add powered by EE msg
1550
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1551
-            $empty_cart = count($this->checkout->transaction
1552
-                                    ->registrations($this->checkout->reg_cache_where_params)) < 1;
1553
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1554
-            $cookies_not_set_msg = '';
1555
-            if ($empty_cart) {
1556
-                $cookies_not_set_msg = apply_filters(
1557
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1558
-                    sprintf(
1559
-                        esc_html__(
1560
-                            '%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',
1561
-                            'event_espresso'
1562
-                        ),
1563
-                        '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1564
-                        '</div>',
1565
-                        '<h6 class="important-notice">',
1566
-                        '</h6>',
1567
-                        '<p>',
1568
-                        '</p>',
1569
-                        '<br />',
1570
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">',
1571
-                        '</a>'
1572
-                    )
1573
-                );
1574
-            }
1575
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1576
-                array(
1577
-                    'name'            => 'single-page-checkout',
1578
-                    'html_id'         => 'ee-single-page-checkout-dv',
1579
-                    'layout_strategy' =>
1580
-                        new EE_Template_Layout(
1581
-                            array(
1582
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1583
-                                'template_args'        => array(
1584
-                                    'empty_cart'              => $empty_cart,
1585
-                                    'revisit'                 => $this->checkout->revisit,
1586
-                                    'reg_steps'               => $this->checkout->reg_steps,
1587
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1588
-                                        ? $this->checkout->next_step->slug()
1589
-                                        : '',
1590
-                                    'empty_msg'               => apply_filters(
1591
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1592
-                                        sprintf(
1593
-                                            esc_html__(
1594
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1595
-                                                'event_espresso'
1596
-                                            ),
1597
-                                            '<a href="'
1598
-                                            . get_post_type_archive_link('espresso_events')
1599
-                                            . '" title="',
1600
-                                            '">',
1601
-                                            '</a>'
1602
-                                        )
1603
-                                    ),
1604
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1605
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1606
-                                    'session_expiration'      => gmdate(
1607
-                                        'M d, Y H:i:s',
1608
-                                        EE_Registry::instance()->SSN->expiration()
1609
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1610
-                                    ),
1611
-                                ),
1612
-                            )
1613
-                        ),
1614
-                )
1615
-            );
1616
-            // load template and add to output sent that gets filtered into the_content()
1617
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1618
-        }
1619
-    }
1620
-
1621
-
1622
-    /**
1623
-     *    add_extra_finalize_registration_inputs
1624
-     *
1625
-     * @access    public
1626
-     * @param $next_step
1627
-     * @internal  param string $label
1628
-     * @return void
1629
-     */
1630
-    public function add_extra_finalize_registration_inputs($next_step)
1631
-    {
1632
-        if ($next_step === 'finalize_registration') {
1633
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1634
-        }
1635
-    }
1636
-
1637
-
1638
-    /**
1639
-     *    display_registration_footer
1640
-     *
1641
-     * @access    public
1642
-     * @return    string
1643
-     */
1644
-    public static function display_registration_footer()
1645
-    {
1646
-        if (apply_filters(
1647
-            'FHEE__EE_Front__Controller__show_reg_footer',
1648
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1649
-        )) {
1650
-            add_filter(
1651
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1652
-                function ($url) {
1653
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1654
-                }
1655
-            );
1656
-            echo apply_filters(
1657
-                'FHEE__EE_Front_Controller__display_registration_footer',
1658
-                \EEH_Template::powered_by_event_espresso(
1659
-                    '',
1660
-                    'espresso-registration-footer-dv',
1661
-                    array('utm_content' => 'registration_checkout')
1662
-                )
1663
-            );
1664
-        }
1665
-        return '';
1666
-    }
1667
-
1668
-
1669
-    /**
1670
-     *    unlock_transaction
1671
-     *
1672
-     * @access    public
1673
-     * @return    void
1674
-     * @throws EE_Error
1675
-     */
1676
-    public function unlock_transaction()
1677
-    {
1678
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1679
-            $this->checkout->transaction->unlock();
1680
-        }
1681
-    }
1682
-
1683
-
1684
-    /**
1685
-     *        _setup_redirect
1686
-     *
1687
-     * @access    private
1688
-     * @return void
1689
-     */
1690
-    private function _setup_redirect()
1691
-    {
1692
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1693
-            $this->checkout->redirect = true;
1694
-            if (empty($this->checkout->redirect_url)) {
1695
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1696
-            }
1697
-            $this->checkout->redirect_url = apply_filters(
1698
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1699
-                $this->checkout->redirect_url,
1700
-                $this->checkout
1701
-            );
1702
-        }
1703
-    }
1704
-
1705
-
1706
-    /**
1707
-     *   handle ajax message responses and redirects
1708
-     *
1709
-     * @access public
1710
-     * @return void
1711
-     * @throws EE_Error
1712
-     */
1713
-    public function go_to_next_step()
1714
-    {
1715
-        if (EE_Registry::instance()->REQ->ajax) {
1716
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1717
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1718
-        }
1719
-        $this->unlock_transaction();
1720
-        // just return for these conditions
1721
-        if ($this->checkout->admin_request
1722
-            || $this->checkout->action === 'redirect_form'
1723
-            || $this->checkout->action === 'update_checkout'
1724
-        ) {
1725
-            return;
1726
-        }
1727
-        // AJAX response
1728
-        $this->_handle_json_response();
1729
-        // redirect to next step or the Thank You page
1730
-        $this->_handle_html_redirects();
1731
-        // hmmm... must be something wrong, so let's just display the form again !
1732
-        $this->_display_spco_reg_form();
1733
-    }
1734
-
1735
-
1736
-    /**
1737
-     *   _handle_json_response
1738
-     *
1739
-     * @access protected
1740
-     * @return void
1741
-     */
1742
-    protected function _handle_json_response()
1743
-    {
1744
-        // if this is an ajax request
1745
-        if (EE_Registry::instance()->REQ->ajax) {
1746
-            $this->checkout->json_response->set_registration_time_limit(
1747
-                $this->checkout->get_registration_time_limit()
1748
-            );
1749
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1750
-            // just send the ajax (
1751
-            $json_response = apply_filters(
1752
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1753
-                $this->checkout->json_response
1754
-            );
1755
-            echo $json_response;
1756
-            exit();
1757
-        }
1758
-    }
1759
-
1760
-
1761
-    /**
1762
-     *   _handle_redirects
1763
-     *
1764
-     * @access protected
1765
-     * @return void
1766
-     */
1767
-    protected function _handle_html_redirects()
1768
-    {
1769
-        // going somewhere ?
1770
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1771
-            // store notices in a transient
1772
-            EE_Error::get_notices(false, true, true);
1773
-            wp_safe_redirect($this->checkout->redirect_url);
1774
-            exit();
1775
-        }
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     *   set_checkout_anchor
1781
-     *
1782
-     * @access public
1783
-     * @return void
1784
-     */
1785
-    public function set_checkout_anchor()
1786
-    {
1787
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1788
-    }
1789
-
1790
-    /**
1791
-     *    getRegistrationExpirationNotice
1792
-     *
1793
-     * @since     4.9.59.p
1794
-     * @access    public
1795
-     * @return    string
1796
-     */
1797
-    public static function getRegistrationExpirationNotice()
1798
-    {
1799
-        return sprintf(
1800
-            esc_html__(
1801
-                '%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 accept our apologies for any inconvenience this may have caused.%8$s',
1802
-                'event_espresso'
1803
-            ),
1804
-            '<h4 class="important-notice">',
1805
-            '</h4>',
1806
-            '<br />',
1807
-            '<p>',
1808
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1809
-            '">',
1810
-            '</a>',
1811
-            '</p>'
1812
-        );
1813
-    }
18
+	/**
19
+	 * $_initialized - has the SPCO controller already been initialized ?
20
+	 *
21
+	 * @access private
22
+	 * @var bool $_initialized
23
+	 */
24
+	private static $_initialized = false;
25
+
26
+
27
+	/**
28
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
29
+	 *
30
+	 * @access private
31
+	 * @var bool $_valid_checkout
32
+	 */
33
+	private static $_checkout_verified = true;
34
+
35
+	/**
36
+	 *    $_reg_steps_array - holds initial array of reg steps
37
+	 *
38
+	 * @access private
39
+	 * @var array $_reg_steps_array
40
+	 */
41
+	private static $_reg_steps_array = array();
42
+
43
+	/**
44
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
45
+	 *
46
+	 * @access public
47
+	 * @var EE_Checkout $checkout
48
+	 */
49
+	public $checkout;
50
+
51
+
52
+	/**
53
+	 * @return EED_Module|EED_Single_Page_Checkout
54
+	 */
55
+	public static function instance()
56
+	{
57
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
58
+		return parent::get_instance(__CLASS__);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return EE_CART
64
+	 */
65
+	public function cart()
66
+	{
67
+		return $this->checkout->cart;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return EE_Transaction
73
+	 */
74
+	public function transaction()
75
+	{
76
+		return $this->checkout->transaction;
77
+	}
78
+
79
+
80
+	/**
81
+	 *    set_hooks - for hooking into EE Core, other modules, etc
82
+	 *
83
+	 * @access    public
84
+	 * @return    void
85
+	 * @throws EE_Error
86
+	 */
87
+	public static function set_hooks()
88
+	{
89
+		EED_Single_Page_Checkout::set_definitions();
90
+	}
91
+
92
+
93
+	/**
94
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
95
+	 *
96
+	 * @access    public
97
+	 * @return    void
98
+	 * @throws EE_Error
99
+	 */
100
+	public static function set_hooks_admin()
101
+	{
102
+		EED_Single_Page_Checkout::set_definitions();
103
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
104
+			return;
105
+		}
106
+		// going to start an output buffer in case anything gets accidentally output
107
+		// that might disrupt our JSON response
108
+		ob_start();
109
+		EED_Single_Page_Checkout::load_request_handler();
110
+		EED_Single_Page_Checkout::load_reg_steps();
111
+		// set ajax hooks
112
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
113
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
114
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
115
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
116
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
117
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
118
+	}
119
+
120
+
121
+	/**
122
+	 *    process ajax request
123
+	 *
124
+	 * @param string $ajax_action
125
+	 * @throws EE_Error
126
+	 */
127
+	public static function process_ajax_request($ajax_action)
128
+	{
129
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
130
+		EED_Single_Page_Checkout::instance()->_initialize();
131
+	}
132
+
133
+
134
+	/**
135
+	 *    ajax display registration step
136
+	 *
137
+	 * @throws EE_Error
138
+	 */
139
+	public static function display_reg_step()
140
+	{
141
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
142
+	}
143
+
144
+
145
+	/**
146
+	 *    ajax process registration step
147
+	 *
148
+	 * @throws EE_Error
149
+	 */
150
+	public static function process_reg_step()
151
+	{
152
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
153
+	}
154
+
155
+
156
+	/**
157
+	 *    ajax process registration step
158
+	 *
159
+	 * @throws EE_Error
160
+	 */
161
+	public static function update_reg_step()
162
+	{
163
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
164
+	}
165
+
166
+
167
+	/**
168
+	 *   update_checkout
169
+	 *
170
+	 * @access public
171
+	 * @return void
172
+	 * @throws EE_Error
173
+	 */
174
+	public static function update_checkout()
175
+	{
176
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
177
+	}
178
+
179
+
180
+	/**
181
+	 *    load_request_handler
182
+	 *
183
+	 * @access    public
184
+	 * @return    void
185
+	 */
186
+	public static function load_request_handler()
187
+	{
188
+		// load core Request_Handler class
189
+		if (EE_Registry::instance()->REQ !== null) {
190
+			EE_Registry::instance()->load_core('Request_Handler');
191
+		}
192
+	}
193
+
194
+
195
+	/**
196
+	 *    set_definitions
197
+	 *
198
+	 * @access    public
199
+	 * @return    void
200
+	 * @throws EE_Error
201
+	 */
202
+	public static function set_definitions()
203
+	{
204
+		if (defined('SPCO_BASE_PATH')) {
205
+			return;
206
+		}
207
+		define(
208
+			'SPCO_BASE_PATH',
209
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
210
+		);
211
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
212
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
213
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
214
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
215
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
216
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
217
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
218
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * load_reg_steps
225
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
226
+	 *
227
+	 * @access    private
228
+	 * @throws EE_Error
229
+	 */
230
+	public static function load_reg_steps()
231
+	{
232
+		static $reg_steps_loaded = false;
233
+		if ($reg_steps_loaded) {
234
+			return;
235
+		}
236
+		// filter list of reg_steps
237
+		$reg_steps_to_load = (array) apply_filters(
238
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
239
+			EED_Single_Page_Checkout::get_reg_steps()
240
+		);
241
+		// sort by key (order)
242
+		ksort($reg_steps_to_load);
243
+		// loop through folders
244
+		foreach ($reg_steps_to_load as $order => $reg_step) {
245
+			// we need a
246
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
247
+				// copy over to the reg_steps_array
248
+				EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
249
+				// register custom key route for each reg step
250
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
251
+				EE_Config::register_route(
252
+					$reg_step['slug'],
253
+					'EED_Single_Page_Checkout',
254
+					'run',
255
+					'step'
256
+				);
257
+				// add AJAX or other hooks
258
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
259
+					// setup autoloaders if necessary
260
+					if (! class_exists($reg_step['class_name'])) {
261
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
262
+							$reg_step['file_path'],
263
+							true
264
+						);
265
+					}
266
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
267
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
268
+					}
269
+				}
270
+			}
271
+		}
272
+		$reg_steps_loaded = true;
273
+	}
274
+
275
+
276
+	/**
277
+	 *    get_reg_steps
278
+	 *
279
+	 * @access    public
280
+	 * @return    array
281
+	 */
282
+	public static function get_reg_steps()
283
+	{
284
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
285
+		if (empty($reg_steps)) {
286
+			$reg_steps = array(
287
+				10  => array(
288
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
289
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
290
+					'slug'       => 'attendee_information',
291
+					'has_hooks'  => false,
292
+				),
293
+				30  => array(
294
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
295
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
296
+					'slug'       => 'payment_options',
297
+					'has_hooks'  => true,
298
+				),
299
+				999 => array(
300
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
301
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
302
+					'slug'       => 'finalize_registration',
303
+					'has_hooks'  => false,
304
+				),
305
+			);
306
+		}
307
+		return $reg_steps;
308
+	}
309
+
310
+
311
+	/**
312
+	 *    registration_checkout_for_admin
313
+	 *
314
+	 * @access    public
315
+	 * @return    string
316
+	 * @throws EE_Error
317
+	 */
318
+	public static function registration_checkout_for_admin()
319
+	{
320
+		EED_Single_Page_Checkout::load_request_handler();
321
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
322
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
323
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
324
+		EED_Single_Page_Checkout::instance()->_initialize();
325
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
326
+		return EE_Registry::instance()->REQ->get_output();
327
+	}
328
+
329
+
330
+	/**
331
+	 * process_registration_from_admin
332
+	 *
333
+	 * @access public
334
+	 * @return \EE_Transaction
335
+	 * @throws EE_Error
336
+	 */
337
+	public static function process_registration_from_admin()
338
+	{
339
+		EED_Single_Page_Checkout::load_request_handler();
340
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
341
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
342
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
343
+		EED_Single_Page_Checkout::instance()->_initialize();
344
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
345
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
346
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
347
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
348
+				if ($final_reg_step->process_reg_step()) {
349
+					$final_reg_step->set_completed();
350
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
351
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
352
+				}
353
+			}
354
+		}
355
+		return null;
356
+	}
357
+
358
+
359
+	/**
360
+	 *    run
361
+	 *
362
+	 * @access    public
363
+	 * @param WP_Query $WP_Query
364
+	 * @return    void
365
+	 * @throws EE_Error
366
+	 */
367
+	public function run($WP_Query)
368
+	{
369
+		if ($WP_Query instanceof WP_Query
370
+			&& $WP_Query->is_main_query()
371
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
372
+			&& $this->_is_reg_checkout()
373
+		) {
374
+			$this->_initialize();
375
+		}
376
+	}
377
+
378
+
379
+	/**
380
+	 * determines whether current url matches reg page url
381
+	 *
382
+	 * @return bool
383
+	 */
384
+	protected function _is_reg_checkout()
385
+	{
386
+		// get current permalink for reg page without any extra query args
387
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
388
+		// get request URI for current request, but without the scheme or host
389
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
390
+		$current_request_uri = html_entity_decode($current_request_uri);
391
+		// get array of query args from the current request URI
392
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
393
+		// grab page id if it is set
394
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
395
+		// and remove the page id from the query args (we will re-add it later)
396
+		unset($query_args['page_id']);
397
+		// now strip all query args from current request URI
398
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
399
+		// and re-add the page id if it was set
400
+		if ($page_id) {
401
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
402
+		}
403
+		// remove slashes and ?
404
+		$current_request_uri = trim($current_request_uri, '?/');
405
+		// is current request URI part of the known full reg page URL ?
406
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
407
+	}
408
+
409
+
410
+	/**
411
+	 * @param WP_Query $wp_query
412
+	 * @return    void
413
+	 * @throws EE_Error
414
+	 */
415
+	public static function init($wp_query)
416
+	{
417
+		EED_Single_Page_Checkout::instance()->run($wp_query);
418
+	}
419
+
420
+
421
+	/**
422
+	 *    _initialize - initial module setup
423
+	 *
424
+	 * @access    private
425
+	 * @throws EE_Error
426
+	 * @return    void
427
+	 */
428
+	private function _initialize()
429
+	{
430
+		// ensure SPCO doesn't run twice
431
+		if (EED_Single_Page_Checkout::$_initialized) {
432
+			return;
433
+		}
434
+		try {
435
+			EED_Single_Page_Checkout::load_reg_steps();
436
+			$this->_verify_session();
437
+			// setup the EE_Checkout object
438
+			$this->checkout = $this->_initialize_checkout();
439
+			// filter checkout
440
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
441
+			// get the $_GET
442
+			$this->_get_request_vars();
443
+			if ($this->_block_bots()) {
444
+				return;
445
+			}
446
+			// filter continue_reg
447
+			$this->checkout->continue_reg = apply_filters(
448
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
449
+				true,
450
+				$this->checkout
451
+			);
452
+			// load the reg steps array
453
+			if (! $this->_load_and_instantiate_reg_steps()) {
454
+				EED_Single_Page_Checkout::$_initialized = true;
455
+				return;
456
+			}
457
+			// set the current step
458
+			$this->checkout->set_current_step($this->checkout->step);
459
+			// and the next step
460
+			$this->checkout->set_next_step();
461
+			// verify that everything has been setup correctly
462
+			if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
463
+				EED_Single_Page_Checkout::$_initialized = true;
464
+				return;
465
+			}
466
+			// lock the transaction
467
+			$this->checkout->transaction->lock();
468
+			// make sure all of our cached objects are added to their respective model entity mappers
469
+			$this->checkout->refresh_all_entities();
470
+			// set amount owing
471
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
472
+			// initialize each reg step, which gives them the chance to potentially alter the process
473
+			$this->_initialize_reg_steps();
474
+			// DEBUG LOG
475
+			// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
476
+			// get reg form
477
+			if (! $this->_check_form_submission()) {
478
+				EED_Single_Page_Checkout::$_initialized = true;
479
+				return;
480
+			}
481
+			// checkout the action!!!
482
+			$this->_process_form_action();
483
+			// add some style and make it dance
484
+			$this->add_styles_and_scripts();
485
+			// kk... SPCO has successfully run
486
+			EED_Single_Page_Checkout::$_initialized = true;
487
+			// set no cache headers and constants
488
+			EE_System::do_not_cache();
489
+			// add anchor
490
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
491
+			// remove transaction lock
492
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
493
+		} catch (Exception $e) {
494
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
495
+		}
496
+	}
497
+
498
+
499
+	/**
500
+	 *    _verify_session
501
+	 * checks that the session is valid and not expired
502
+	 *
503
+	 * @access    private
504
+	 * @throws EE_Error
505
+	 */
506
+	private function _verify_session()
507
+	{
508
+		if (! EE_Registry::instance()->SSN instanceof EE_Session) {
509
+			throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
510
+		}
511
+		$clear_session_requested = filter_var(
512
+			EE_Registry::instance()->REQ->get('clear_session', false),
513
+			FILTER_VALIDATE_BOOLEAN
514
+		);
515
+		// is session still valid ?
516
+		if ($clear_session_requested
517
+			|| (EE_Registry::instance()->SSN->expired()
518
+				&& EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
519
+			)
520
+		) {
521
+			$this->checkout = new EE_Checkout();
522
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
523
+			// EE_Registry::instance()->SSN->reset_cart();
524
+			// EE_Registry::instance()->SSN->reset_checkout();
525
+			// EE_Registry::instance()->SSN->reset_transaction();
526
+			if (! $clear_session_requested) {
527
+				EE_Error::add_attention(
528
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
529
+					__FILE__,
530
+					__FUNCTION__,
531
+					__LINE__
532
+				);
533
+			}
534
+			// EE_Registry::instance()->SSN->reset_expired();
535
+		}
536
+	}
537
+
538
+
539
+	/**
540
+	 *    _initialize_checkout
541
+	 * loads and instantiates EE_Checkout
542
+	 *
543
+	 * @access    private
544
+	 * @throws EE_Error
545
+	 * @return EE_Checkout
546
+	 */
547
+	private function _initialize_checkout()
548
+	{
549
+		// look in session for existing checkout
550
+		/** @type EE_Checkout $checkout */
551
+		$checkout = EE_Registry::instance()->SSN->checkout();
552
+		// verify
553
+		if (! $checkout instanceof EE_Checkout) {
554
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
555
+			$checkout = EE_Registry::instance()->load_file(
556
+				SPCO_INC_PATH,
557
+				'EE_Checkout',
558
+				'class',
559
+				array(),
560
+				false
561
+			);
562
+		} else {
563
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
564
+				$this->unlock_transaction();
565
+				wp_safe_redirect($checkout->redirect_url);
566
+				exit();
567
+			}
568
+		}
569
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
570
+		// verify again
571
+		if (! $checkout instanceof EE_Checkout) {
572
+			throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
573
+		}
574
+		// reset anything that needs a clean slate for each request
575
+		$checkout->reset_for_current_request();
576
+		return $checkout;
577
+	}
578
+
579
+
580
+	/**
581
+	 *    _get_request_vars
582
+	 *
583
+	 * @access    private
584
+	 * @return    void
585
+	 * @throws EE_Error
586
+	 */
587
+	private function _get_request_vars()
588
+	{
589
+		// load classes
590
+		EED_Single_Page_Checkout::load_request_handler();
591
+		// make sure this request is marked as belonging to EE
592
+		EE_Registry::instance()->REQ->set_espresso_page(true);
593
+		// which step is being requested ?
594
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
595
+		// which step is being edited ?
596
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
597
+		// and what we're doing on the current step
598
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
599
+		// timestamp
600
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
601
+		// returning to edit ?
602
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
603
+		// add reg url link to registration query params
604
+		if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
605
+			$this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
606
+		}
607
+		// or some other kind of revisit ?
608
+		$this->checkout->revisit = filter_var(
609
+			EE_Registry::instance()->REQ->get('revisit', false),
610
+			FILTER_VALIDATE_BOOLEAN
611
+		);
612
+		// and whether or not to generate a reg form for this request
613
+		$this->checkout->generate_reg_form = filter_var(
614
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
615
+			FILTER_VALIDATE_BOOLEAN
616
+		);
617
+		// and whether or not to process a reg form submission for this request
618
+		$this->checkout->process_form_submission = filter_var(
619
+			EE_Registry::instance()->REQ->get(
620
+				'process_form_submission',
621
+				$this->checkout->action === 'process_reg_step'
622
+			),
623
+			FILTER_VALIDATE_BOOLEAN
624
+		);
625
+		$this->checkout->process_form_submission = filter_var(
626
+			$this->checkout->action !== 'display_spco_reg_step'
627
+				? $this->checkout->process_form_submission
628
+				: false,
629
+			FILTER_VALIDATE_BOOLEAN
630
+		);
631
+		// $this->_display_request_vars();
632
+	}
633
+
634
+
635
+	/**
636
+	 *  _display_request_vars
637
+	 *
638
+	 * @access    protected
639
+	 * @return    void
640
+	 */
641
+	protected function _display_request_vars()
642
+	{
643
+		if (! WP_DEBUG) {
644
+			return;
645
+		}
646
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
647
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
648
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
649
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
650
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
651
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
652
+		EEH_Debug_Tools::printr(
653
+			$this->checkout->generate_reg_form,
654
+			'$this->checkout->generate_reg_form',
655
+			__FILE__,
656
+			__LINE__
657
+		);
658
+		EEH_Debug_Tools::printr(
659
+			$this->checkout->process_form_submission,
660
+			'$this->checkout->process_form_submission',
661
+			__FILE__,
662
+			__LINE__
663
+		);
664
+	}
665
+
666
+
667
+	/**
668
+	 * _block_bots
669
+	 * checks that the incoming request has either of the following set:
670
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
671
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
672
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
673
+	 * then where you coming from man?
674
+	 *
675
+	 * @return boolean
676
+	 */
677
+	private function _block_bots()
678
+	{
679
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
680
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
681
+			return true;
682
+		}
683
+		return false;
684
+	}
685
+
686
+
687
+	/**
688
+	 *    _get_first_step
689
+	 *  gets slug for first step in $_reg_steps_array
690
+	 *
691
+	 * @access    private
692
+	 * @throws EE_Error
693
+	 * @return    string
694
+	 */
695
+	private function _get_first_step()
696
+	{
697
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
698
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
699
+	}
700
+
701
+
702
+	/**
703
+	 * instantiates each reg step based on the loaded reg_steps array
704
+	 *
705
+	 * @return    bool
706
+	 * @throws EE_Error
707
+	 * @throws InvalidArgumentException
708
+	 * @throws InvalidDataTypeException
709
+	 * @throws InvalidInterfaceException
710
+	 */
711
+	private function _load_and_instantiate_reg_steps()
712
+	{
713
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
714
+		// have reg_steps already been instantiated ?
715
+		if (empty($this->checkout->reg_steps)
716
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
717
+		) {
718
+			// if not, then loop through raw reg steps array
719
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
720
+				if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
721
+					return false;
722
+				}
723
+			}
724
+			if (isset($this->checkout->reg_steps['registration_confirmation'])) {
725
+				// skip the registration_confirmation page ?
726
+				if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
727
+					// just remove it from the reg steps array
728
+					$this->checkout->remove_reg_step('registration_confirmation', false);
729
+				} elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last
730
+				) {
731
+					// set the order to something big like 100
732
+					$this->checkout->set_reg_step_order('registration_confirmation', 100);
733
+				}
734
+			}
735
+			// filter the array for good luck
736
+			$this->checkout->reg_steps = apply_filters(
737
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
738
+				$this->checkout->reg_steps
739
+			);
740
+			// finally re-sort based on the reg step class order properties
741
+			$this->checkout->sort_reg_steps();
742
+		} else {
743
+			foreach ($this->checkout->reg_steps as $reg_step) {
744
+				// set all current step stati to FALSE
745
+				$reg_step->set_is_current_step(false);
746
+			}
747
+		}
748
+		if (empty($this->checkout->reg_steps)) {
749
+			EE_Error::add_error(
750
+				esc_html__('No Reg Steps were loaded..', 'event_espresso'),
751
+				__FILE__,
752
+				__FUNCTION__,
753
+				__LINE__
754
+			);
755
+			return false;
756
+		}
757
+		// make reg step details available to JS
758
+		$this->checkout->set_reg_step_JSON_info();
759
+		return true;
760
+	}
761
+
762
+
763
+	/**
764
+	 *     _load_and_instantiate_reg_step
765
+	 *
766
+	 * @access    private
767
+	 * @param array $reg_step
768
+	 * @param int   $order
769
+	 * @return bool
770
+	 */
771
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
772
+	{
773
+		// we need a file_path, class_name, and slug to add a reg step
774
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
775
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
776
+			if ($this->checkout->reg_url_link
777
+				&& $this->checkout->step !== $reg_step['slug']
778
+				&& $reg_step['slug'] !== 'finalize_registration'
779
+				// normally at this point we would NOT load the reg step, but this filter can change that
780
+				&& apply_filters(
781
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
782
+					true,
783
+					$reg_step,
784
+					$this->checkout
785
+				)
786
+			) {
787
+				return true;
788
+			}
789
+			// instantiate step class using file path and class name
790
+			$reg_step_obj = EE_Registry::instance()->load_file(
791
+				$reg_step['file_path'],
792
+				$reg_step['class_name'],
793
+				'class',
794
+				$this->checkout,
795
+				false
796
+			);
797
+			// did we gets the goods ?
798
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
799
+				// set reg step order based on config
800
+				$reg_step_obj->set_order($order);
801
+				// add instantiated reg step object to the master reg steps array
802
+				$this->checkout->add_reg_step($reg_step_obj);
803
+			} else {
804
+				EE_Error::add_error(
805
+					esc_html__('The current step could not be set.', 'event_espresso'),
806
+					__FILE__,
807
+					__FUNCTION__,
808
+					__LINE__
809
+				);
810
+				return false;
811
+			}
812
+		} else {
813
+			if (WP_DEBUG) {
814
+				EE_Error::add_error(
815
+					sprintf(
816
+						esc_html__(
817
+							'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',
818
+							'event_espresso'
819
+						),
820
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
821
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
822
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
823
+						'<ul>',
824
+						'<li>',
825
+						'</li>',
826
+						'</ul>'
827
+					),
828
+					__FILE__,
829
+					__FUNCTION__,
830
+					__LINE__
831
+				);
832
+			}
833
+			return false;
834
+		}
835
+		return true;
836
+	}
837
+
838
+
839
+	/**
840
+	 * _verify_transaction_and_get_registrations
841
+	 *
842
+	 * @access private
843
+	 * @return bool
844
+	 * @throws InvalidDataTypeException
845
+	 * @throws InvalidEntityException
846
+	 * @throws EE_Error
847
+	 */
848
+	private function _verify_transaction_and_get_registrations()
849
+	{
850
+		// was there already a valid transaction in the checkout from the session ?
851
+		if (! $this->checkout->transaction instanceof EE_Transaction) {
852
+			// get transaction from db or session
853
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
854
+				? $this->_get_transaction_and_cart_for_previous_visit()
855
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
856
+			if (! $this->checkout->transaction instanceof EE_Transaction) {
857
+				EE_Error::add_error(
858
+					esc_html__(
859
+						'Your Registration and Transaction information could not be retrieved from the db.',
860
+						'event_espresso'
861
+					),
862
+					__FILE__,
863
+					__FUNCTION__,
864
+					__LINE__
865
+				);
866
+				$this->checkout->transaction = EE_Transaction::new_instance();
867
+				// add some style and make it dance
868
+				$this->add_styles_and_scripts();
869
+				EED_Single_Page_Checkout::$_initialized = true;
870
+				return false;
871
+			}
872
+			// and the registrations for the transaction
873
+			$this->_get_registrations($this->checkout->transaction);
874
+		}
875
+		return true;
876
+	}
877
+
878
+
879
+	/**
880
+	 * _get_transaction_and_cart_for_previous_visit
881
+	 *
882
+	 * @access private
883
+	 * @return mixed EE_Transaction|NULL
884
+	 */
885
+	private function _get_transaction_and_cart_for_previous_visit()
886
+	{
887
+		/** @var $TXN_model EEM_Transaction */
888
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
889
+		// because the reg_url_link is present in the request,
890
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
891
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
892
+		// verify transaction
893
+		if ($transaction instanceof EE_Transaction) {
894
+			// and get the cart that was used for that transaction
895
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
896
+			return $transaction;
897
+		}
898
+		EE_Error::add_error(
899
+			esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
900
+			__FILE__,
901
+			__FUNCTION__,
902
+			__LINE__
903
+		);
904
+		return null;
905
+	}
906
+
907
+
908
+	/**
909
+	 * _get_cart_for_transaction
910
+	 *
911
+	 * @access private
912
+	 * @param EE_Transaction $transaction
913
+	 * @return EE_Cart
914
+	 */
915
+	private function _get_cart_for_transaction($transaction)
916
+	{
917
+		return $this->checkout->get_cart_for_transaction($transaction);
918
+	}
919
+
920
+
921
+	/**
922
+	 * get_cart_for_transaction
923
+	 *
924
+	 * @access public
925
+	 * @param EE_Transaction $transaction
926
+	 * @return EE_Cart
927
+	 */
928
+	public function get_cart_for_transaction(EE_Transaction $transaction)
929
+	{
930
+		return $this->checkout->get_cart_for_transaction($transaction);
931
+	}
932
+
933
+
934
+	/**
935
+	 * _get_transaction_and_cart_for_current_session
936
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
937
+	 *
938
+	 * @access private
939
+	 * @return EE_Transaction
940
+	 * @throws EE_Error
941
+	 */
942
+	private function _get_cart_for_current_session_and_setup_new_transaction()
943
+	{
944
+		//  if there's no transaction, then this is the FIRST visit to SPCO
945
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
946
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
947
+		// and then create a new transaction
948
+		$transaction = $this->_initialize_transaction();
949
+		// verify transaction
950
+		if ($transaction instanceof EE_Transaction) {
951
+			// save it so that we have an ID for other objects to use
952
+			$transaction->save();
953
+			// and save TXN data to the cart
954
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
955
+		} else {
956
+			EE_Error::add_error(
957
+				esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'),
958
+				__FILE__,
959
+				__FUNCTION__,
960
+				__LINE__
961
+			);
962
+		}
963
+		return $transaction;
964
+	}
965
+
966
+
967
+	/**
968
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
969
+	 *
970
+	 * @access private
971
+	 * @return mixed EE_Transaction|NULL
972
+	 */
973
+	private function _initialize_transaction()
974
+	{
975
+		try {
976
+			// ensure cart totals have been calculated
977
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
978
+			// grab the cart grand total
979
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
980
+			// create new TXN
981
+			$transaction = EE_Transaction::new_instance(
982
+				array(
983
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
984
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
985
+					'TXN_paid'      => 0,
986
+					'STS_ID'        => EEM_Transaction::failed_status_code,
987
+				)
988
+			);
989
+			// save it so that we have an ID for other objects to use
990
+			$transaction->save();
991
+			// set cron job for following up on TXNs after their session has expired
992
+			EE_Cron_Tasks::schedule_expired_transaction_check(
993
+				EE_Registry::instance()->SSN->expiration() + 1,
994
+				$transaction->ID()
995
+			);
996
+			return $transaction;
997
+		} catch (Exception $e) {
998
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
999
+		}
1000
+		return null;
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * _get_registrations
1006
+	 *
1007
+	 * @access private
1008
+	 * @param EE_Transaction $transaction
1009
+	 * @return void
1010
+	 * @throws InvalidDataTypeException
1011
+	 * @throws InvalidEntityException
1012
+	 * @throws EE_Error
1013
+	 */
1014
+	private function _get_registrations(EE_Transaction $transaction)
1015
+	{
1016
+		// first step: grab the registrants  { : o
1017
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1018
+		$this->checkout->total_ticket_count = count($registrations);
1019
+		// verify registrations have been set
1020
+		if (empty($registrations)) {
1021
+			// if no cached registrations, then check the db
1022
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1023
+			// still nothing ? well as long as this isn't a revisit
1024
+			if (empty($registrations) && ! $this->checkout->revisit) {
1025
+				// generate new registrations from scratch
1026
+				$registrations = $this->_initialize_registrations($transaction);
1027
+			}
1028
+		}
1029
+		// sort by their original registration order
1030
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1031
+		// then loop thru the array
1032
+		foreach ($registrations as $registration) {
1033
+			// verify each registration
1034
+			if ($registration instanceof EE_Registration) {
1035
+				// we display all attendee info for the primary registrant
1036
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1037
+					&& $registration->is_primary_registrant()
1038
+				) {
1039
+					$this->checkout->primary_revisit = true;
1040
+					break;
1041
+				}
1042
+				if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1043
+					// but hide info if it doesn't belong to you
1044
+					$transaction->clear_cache('Registration', $registration->ID());
1045
+					$this->checkout->total_ticket_count--;
1046
+				}
1047
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1048
+			}
1049
+		}
1050
+	}
1051
+
1052
+
1053
+	/**
1054
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1055
+	 *
1056
+	 * @access private
1057
+	 * @param EE_Transaction $transaction
1058
+	 * @return    array
1059
+	 * @throws InvalidDataTypeException
1060
+	 * @throws InvalidEntityException
1061
+	 * @throws EE_Error
1062
+	 */
1063
+	private function _initialize_registrations(EE_Transaction $transaction)
1064
+	{
1065
+		$att_nmbr = 0;
1066
+		$registrations = array();
1067
+		if ($transaction instanceof EE_Transaction) {
1068
+			/** @type EE_Registration_Processor $registration_processor */
1069
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1070
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1071
+			// now let's add the cart items to the $transaction
1072
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1073
+				// do the following for each ticket of this type they selected
1074
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1075
+					$att_nmbr++;
1076
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1077
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1078
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1079
+						array(
1080
+							$transaction,
1081
+							$line_item,
1082
+							$att_nmbr,
1083
+							$this->checkout->total_ticket_count,
1084
+						)
1085
+					);
1086
+					// override capabilities for frontend registrations
1087
+					if (! is_admin()) {
1088
+						$CreateRegistrationCommand->setCapCheck(
1089
+							new PublicCapabilities('', 'create_new_registration')
1090
+						);
1091
+					}
1092
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1093
+					if (! $registration instanceof EE_Registration) {
1094
+						throw new InvalidEntityException($registration, 'EE_Registration');
1095
+					}
1096
+					$registrations[ $registration->ID() ] = $registration;
1097
+				}
1098
+			}
1099
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1100
+		}
1101
+		return $registrations;
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * sorts registrations by REG_count
1107
+	 *
1108
+	 * @access public
1109
+	 * @param EE_Registration $reg_A
1110
+	 * @param EE_Registration $reg_B
1111
+	 * @return int
1112
+	 */
1113
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1114
+	{
1115
+		// this shouldn't ever happen within the same TXN, but oh well
1116
+		if ($reg_A->count() === $reg_B->count()) {
1117
+			return 0;
1118
+		}
1119
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1120
+	}
1121
+
1122
+
1123
+	/**
1124
+	 *    _final_verifications
1125
+	 * just makes sure that everything is set up correctly before proceeding
1126
+	 *
1127
+	 * @access    private
1128
+	 * @return    bool
1129
+	 * @throws EE_Error
1130
+	 */
1131
+	private function _final_verifications()
1132
+	{
1133
+		// filter checkout
1134
+		$this->checkout = apply_filters(
1135
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1136
+			$this->checkout
1137
+		);
1138
+		// verify that current step is still set correctly
1139
+		if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1140
+			EE_Error::add_error(
1141
+				esc_html__(
1142
+					'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.',
1143
+					'event_espresso'
1144
+				),
1145
+				__FILE__,
1146
+				__FUNCTION__,
1147
+				__LINE__
1148
+			);
1149
+			return false;
1150
+		}
1151
+		// if returning to SPCO, then verify that primary registrant is set
1152
+		if (! empty($this->checkout->reg_url_link)) {
1153
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1154
+			if (! $valid_registrant instanceof EE_Registration) {
1155
+				EE_Error::add_error(
1156
+					esc_html__(
1157
+						'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.',
1158
+						'event_espresso'
1159
+					),
1160
+					__FILE__,
1161
+					__FUNCTION__,
1162
+					__LINE__
1163
+				);
1164
+				return false;
1165
+			}
1166
+			$valid_registrant = null;
1167
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1168
+				if ($registration instanceof EE_Registration
1169
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1170
+				) {
1171
+					$valid_registrant = $registration;
1172
+				}
1173
+			}
1174
+			if (! $valid_registrant instanceof EE_Registration) {
1175
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1176
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1177
+					// clear the session, mark the checkout as unverified, and try again
1178
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1179
+					EED_Single_Page_Checkout::$_initialized = false;
1180
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1181
+					$this->_initialize();
1182
+					EE_Error::reset_notices();
1183
+					return false;
1184
+				}
1185
+				EE_Error::add_error(
1186
+					esc_html__(
1187
+						'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.',
1188
+						'event_espresso'
1189
+					),
1190
+					__FILE__,
1191
+					__FUNCTION__,
1192
+					__LINE__
1193
+				);
1194
+				return false;
1195
+			}
1196
+		}
1197
+		// now that things have been kinda sufficiently verified,
1198
+		// let's add the checkout to the session so that it's available to other systems
1199
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1200
+		return true;
1201
+	}
1202
+
1203
+
1204
+	/**
1205
+	 *    _initialize_reg_steps
1206
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1207
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1208
+	 *
1209
+	 * @access    private
1210
+	 * @param bool $reinitializing
1211
+	 * @throws EE_Error
1212
+	 */
1213
+	private function _initialize_reg_steps($reinitializing = false)
1214
+	{
1215
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1216
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1217
+		foreach ($this->checkout->reg_steps as $reg_step) {
1218
+			if (! $reg_step->initialize_reg_step()) {
1219
+				// if not initialized then maybe this step is being removed...
1220
+				if (! $reinitializing && $reg_step->is_current_step()) {
1221
+					// if it was the current step, then we need to start over here
1222
+					$this->_initialize_reg_steps(true);
1223
+					return;
1224
+				}
1225
+				continue;
1226
+			}
1227
+			// add css and JS for current step
1228
+			$reg_step->enqueue_styles_and_scripts();
1229
+			// i18n
1230
+			$reg_step->translate_js_strings();
1231
+			if ($reg_step->is_current_step()) {
1232
+				// the text that appears on the reg step form submit button
1233
+				$reg_step->set_submit_button_text();
1234
+			}
1235
+		}
1236
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1237
+		do_action(
1238
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1239
+			$this->checkout->current_step
1240
+		);
1241
+	}
1242
+
1243
+
1244
+	/**
1245
+	 * _check_form_submission
1246
+	 *
1247
+	 * @access private
1248
+	 * @return boolean
1249
+	 */
1250
+	private function _check_form_submission()
1251
+	{
1252
+		// does this request require the reg form to be generated ?
1253
+		if ($this->checkout->generate_reg_form) {
1254
+			// ever heard that song by Blue Rodeo ?
1255
+			try {
1256
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1257
+				// if not displaying a form, then check for form submission
1258
+				if ($this->checkout->process_form_submission
1259
+					&& $this->checkout->current_step->reg_form->was_submitted()
1260
+				) {
1261
+					// clear out any old data in case this step is being run again
1262
+					$this->checkout->current_step->set_valid_data(array());
1263
+					// capture submitted form data
1264
+					$this->checkout->current_step->reg_form->receive_form_submission(
1265
+						apply_filters(
1266
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1267
+							EE_Registry::instance()->REQ->params(),
1268
+							$this->checkout
1269
+						)
1270
+					);
1271
+					// validate submitted form data
1272
+					if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1273
+						// thou shall not pass !!!
1274
+						$this->checkout->continue_reg = false;
1275
+						// any form validation errors?
1276
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1277
+							EE_Error::add_error(
1278
+								$this->checkout->current_step->reg_form->submission_error_message(),
1279
+								__FILE__,
1280
+								__FUNCTION__,
1281
+								__LINE__
1282
+							);
1283
+						}
1284
+						// well not really... what will happen is
1285
+						// we'll just get redirected back to redo the current step
1286
+						$this->go_to_next_step();
1287
+						return false;
1288
+					}
1289
+				}
1290
+			} catch (EE_Error $e) {
1291
+				$e->get_error();
1292
+			}
1293
+		}
1294
+		return true;
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 * _process_action
1300
+	 *
1301
+	 * @access private
1302
+	 * @return void
1303
+	 * @throws EE_Error
1304
+	 */
1305
+	private function _process_form_action()
1306
+	{
1307
+		// what cha wanna do?
1308
+		switch ($this->checkout->action) {
1309
+			// AJAX next step reg form
1310
+			case 'display_spco_reg_step':
1311
+				$this->checkout->redirect = false;
1312
+				if (EE_Registry::instance()->REQ->ajax) {
1313
+					$this->checkout->json_response->set_reg_step_html(
1314
+						$this->checkout->current_step->display_reg_form()
1315
+					);
1316
+				}
1317
+				break;
1318
+			default:
1319
+				// meh... do one of those other steps first
1320
+				if (! empty($this->checkout->action)
1321
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1322
+				) {
1323
+					// dynamically creates hook point like:
1324
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1325
+					do_action(
1326
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1327
+						$this->checkout->current_step
1328
+					);
1329
+					// call action on current step
1330
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1331
+						// good registrant, you get to proceed
1332
+						if ($this->checkout->current_step->success_message() !== ''
1333
+							&& apply_filters(
1334
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1335
+								false
1336
+							)
1337
+						) {
1338
+							EE_Error::add_success(
1339
+								$this->checkout->current_step->success_message()
1340
+								. '<br />' . $this->checkout->next_step->_instructions()
1341
+							);
1342
+						}
1343
+						// pack it up, pack it in...
1344
+						$this->_setup_redirect();
1345
+					}
1346
+					// dynamically creates hook point like:
1347
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1348
+					do_action(
1349
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1350
+						$this->checkout->current_step
1351
+					);
1352
+				} else {
1353
+					EE_Error::add_error(
1354
+						sprintf(
1355
+							esc_html__(
1356
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1357
+								'event_espresso'
1358
+							),
1359
+							$this->checkout->action,
1360
+							$this->checkout->current_step->name()
1361
+						),
1362
+						__FILE__,
1363
+						__FUNCTION__,
1364
+						__LINE__
1365
+					);
1366
+				}
1367
+			// end default
1368
+		}
1369
+		// store our progress so far
1370
+		$this->checkout->stash_transaction_and_checkout();
1371
+		// advance to the next step! If you pass GO, collect $200
1372
+		$this->go_to_next_step();
1373
+	}
1374
+
1375
+
1376
+	/**
1377
+	 *        add_styles_and_scripts
1378
+	 *
1379
+	 * @access        public
1380
+	 * @return        void
1381
+	 */
1382
+	public function add_styles_and_scripts()
1383
+	{
1384
+		// i18n
1385
+		$this->translate_js_strings();
1386
+		if ($this->checkout->admin_request) {
1387
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1388
+		} else {
1389
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1390
+		}
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 *        translate_js_strings
1396
+	 *
1397
+	 * @access        public
1398
+	 * @return        void
1399
+	 */
1400
+	public function translate_js_strings()
1401
+	{
1402
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1403
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1404
+		EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
1405
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1406
+			'event_espresso'
1407
+		);
1408
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__(
1409
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1410
+			'event_espresso'
1411
+		);
1412
+		EE_Registry::$i18n_js_strings['validation_error'] = esc_html__(
1413
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1414
+			'event_espresso'
1415
+		);
1416
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
1417
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1418
+			'event_espresso'
1419
+		);
1420
+		EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__(
1421
+			'This registration step could not be completed. Please refresh the page and try again.',
1422
+			'event_espresso'
1423
+		);
1424
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__(
1425
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1426
+			'event_espresso'
1427
+		);
1428
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1429
+			esc_html__(
1430
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1431
+				'event_espresso'
1432
+			),
1433
+			'<br/>',
1434
+			'<br/>'
1435
+		);
1436
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1437
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1438
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1439
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1440
+		EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso');
1441
+		EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso');
1442
+		EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso');
1443
+		EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso');
1444
+		EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso');
1445
+		EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso');
1446
+		EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso');
1447
+		EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso');
1448
+		EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso');
1449
+		EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso');
1450
+		EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso');
1451
+		EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso');
1452
+		EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso');
1453
+		EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso');
1454
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
1455
+		);
1456
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1457
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1458
+			true
1459
+		);
1460
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1461
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1462
+		);
1463
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1464
+			'M d, Y H:i:s',
1465
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1466
+		);
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 *    enqueue_styles_and_scripts
1472
+	 *
1473
+	 * @access        public
1474
+	 * @return        void
1475
+	 * @throws EE_Error
1476
+	 */
1477
+	public function enqueue_styles_and_scripts()
1478
+	{
1479
+		// load css
1480
+		wp_register_style(
1481
+			'single_page_checkout',
1482
+			SPCO_CSS_URL . 'single_page_checkout.css',
1483
+			array('espresso_default'),
1484
+			EVENT_ESPRESSO_VERSION
1485
+		);
1486
+		wp_enqueue_style('single_page_checkout');
1487
+		// load JS
1488
+		wp_register_script(
1489
+			'jquery_plugin',
1490
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1491
+			array('jquery'),
1492
+			'1.0.1',
1493
+			true
1494
+		);
1495
+		wp_register_script(
1496
+			'jquery_countdown',
1497
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1498
+			array('jquery_plugin'),
1499
+			'2.1.0',
1500
+			true
1501
+		);
1502
+		wp_register_script(
1503
+			'single_page_checkout',
1504
+			SPCO_JS_URL . 'single_page_checkout.js',
1505
+			array('espresso_core', 'underscore', 'ee_form_section_validation'),
1506
+			EVENT_ESPRESSO_VERSION,
1507
+			true
1508
+		);
1509
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1510
+			$this->checkout->registration_form->enqueue_js();
1511
+		}
1512
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1513
+			$this->checkout->current_step->reg_form->enqueue_js();
1514
+		}
1515
+		wp_enqueue_script('single_page_checkout');
1516
+		if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) {
1517
+			wp_enqueue_script('jquery_countdown');
1518
+		}
1519
+		/**
1520
+		 * global action hook for enqueueing styles and scripts with
1521
+		 * spco calls.
1522
+		 */
1523
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1524
+		/**
1525
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1526
+		 * The hook will end up being something like:
1527
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1528
+		 */
1529
+		do_action(
1530
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1531
+			$this
1532
+		);
1533
+	}
1534
+
1535
+
1536
+	/**
1537
+	 *    display the Registration Single Page Checkout Form
1538
+	 *
1539
+	 * @access    private
1540
+	 * @return    void
1541
+	 * @throws EE_Error
1542
+	 */
1543
+	private function _display_spco_reg_form()
1544
+	{
1545
+		// if registering via the admin, just display the reg form for the current step
1546
+		if ($this->checkout->admin_request) {
1547
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1548
+		} else {
1549
+			// add powered by EE msg
1550
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1551
+			$empty_cart = count($this->checkout->transaction
1552
+									->registrations($this->checkout->reg_cache_where_params)) < 1;
1553
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1554
+			$cookies_not_set_msg = '';
1555
+			if ($empty_cart) {
1556
+				$cookies_not_set_msg = apply_filters(
1557
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1558
+					sprintf(
1559
+						esc_html__(
1560
+							'%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',
1561
+							'event_espresso'
1562
+						),
1563
+						'<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1564
+						'</div>',
1565
+						'<h6 class="important-notice">',
1566
+						'</h6>',
1567
+						'<p>',
1568
+						'</p>',
1569
+						'<br />',
1570
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">',
1571
+						'</a>'
1572
+					)
1573
+				);
1574
+			}
1575
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1576
+				array(
1577
+					'name'            => 'single-page-checkout',
1578
+					'html_id'         => 'ee-single-page-checkout-dv',
1579
+					'layout_strategy' =>
1580
+						new EE_Template_Layout(
1581
+							array(
1582
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1583
+								'template_args'        => array(
1584
+									'empty_cart'              => $empty_cart,
1585
+									'revisit'                 => $this->checkout->revisit,
1586
+									'reg_steps'               => $this->checkout->reg_steps,
1587
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1588
+										? $this->checkout->next_step->slug()
1589
+										: '',
1590
+									'empty_msg'               => apply_filters(
1591
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1592
+										sprintf(
1593
+											esc_html__(
1594
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1595
+												'event_espresso'
1596
+											),
1597
+											'<a href="'
1598
+											. get_post_type_archive_link('espresso_events')
1599
+											. '" title="',
1600
+											'">',
1601
+											'</a>'
1602
+										)
1603
+									),
1604
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1605
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1606
+									'session_expiration'      => gmdate(
1607
+										'M d, Y H:i:s',
1608
+										EE_Registry::instance()->SSN->expiration()
1609
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1610
+									),
1611
+								),
1612
+							)
1613
+						),
1614
+				)
1615
+			);
1616
+			// load template and add to output sent that gets filtered into the_content()
1617
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1618
+		}
1619
+	}
1620
+
1621
+
1622
+	/**
1623
+	 *    add_extra_finalize_registration_inputs
1624
+	 *
1625
+	 * @access    public
1626
+	 * @param $next_step
1627
+	 * @internal  param string $label
1628
+	 * @return void
1629
+	 */
1630
+	public function add_extra_finalize_registration_inputs($next_step)
1631
+	{
1632
+		if ($next_step === 'finalize_registration') {
1633
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1634
+		}
1635
+	}
1636
+
1637
+
1638
+	/**
1639
+	 *    display_registration_footer
1640
+	 *
1641
+	 * @access    public
1642
+	 * @return    string
1643
+	 */
1644
+	public static function display_registration_footer()
1645
+	{
1646
+		if (apply_filters(
1647
+			'FHEE__EE_Front__Controller__show_reg_footer',
1648
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1649
+		)) {
1650
+			add_filter(
1651
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1652
+				function ($url) {
1653
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1654
+				}
1655
+			);
1656
+			echo apply_filters(
1657
+				'FHEE__EE_Front_Controller__display_registration_footer',
1658
+				\EEH_Template::powered_by_event_espresso(
1659
+					'',
1660
+					'espresso-registration-footer-dv',
1661
+					array('utm_content' => 'registration_checkout')
1662
+				)
1663
+			);
1664
+		}
1665
+		return '';
1666
+	}
1667
+
1668
+
1669
+	/**
1670
+	 *    unlock_transaction
1671
+	 *
1672
+	 * @access    public
1673
+	 * @return    void
1674
+	 * @throws EE_Error
1675
+	 */
1676
+	public function unlock_transaction()
1677
+	{
1678
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1679
+			$this->checkout->transaction->unlock();
1680
+		}
1681
+	}
1682
+
1683
+
1684
+	/**
1685
+	 *        _setup_redirect
1686
+	 *
1687
+	 * @access    private
1688
+	 * @return void
1689
+	 */
1690
+	private function _setup_redirect()
1691
+	{
1692
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1693
+			$this->checkout->redirect = true;
1694
+			if (empty($this->checkout->redirect_url)) {
1695
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1696
+			}
1697
+			$this->checkout->redirect_url = apply_filters(
1698
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1699
+				$this->checkout->redirect_url,
1700
+				$this->checkout
1701
+			);
1702
+		}
1703
+	}
1704
+
1705
+
1706
+	/**
1707
+	 *   handle ajax message responses and redirects
1708
+	 *
1709
+	 * @access public
1710
+	 * @return void
1711
+	 * @throws EE_Error
1712
+	 */
1713
+	public function go_to_next_step()
1714
+	{
1715
+		if (EE_Registry::instance()->REQ->ajax) {
1716
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1717
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1718
+		}
1719
+		$this->unlock_transaction();
1720
+		// just return for these conditions
1721
+		if ($this->checkout->admin_request
1722
+			|| $this->checkout->action === 'redirect_form'
1723
+			|| $this->checkout->action === 'update_checkout'
1724
+		) {
1725
+			return;
1726
+		}
1727
+		// AJAX response
1728
+		$this->_handle_json_response();
1729
+		// redirect to next step or the Thank You page
1730
+		$this->_handle_html_redirects();
1731
+		// hmmm... must be something wrong, so let's just display the form again !
1732
+		$this->_display_spco_reg_form();
1733
+	}
1734
+
1735
+
1736
+	/**
1737
+	 *   _handle_json_response
1738
+	 *
1739
+	 * @access protected
1740
+	 * @return void
1741
+	 */
1742
+	protected function _handle_json_response()
1743
+	{
1744
+		// if this is an ajax request
1745
+		if (EE_Registry::instance()->REQ->ajax) {
1746
+			$this->checkout->json_response->set_registration_time_limit(
1747
+				$this->checkout->get_registration_time_limit()
1748
+			);
1749
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1750
+			// just send the ajax (
1751
+			$json_response = apply_filters(
1752
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1753
+				$this->checkout->json_response
1754
+			);
1755
+			echo $json_response;
1756
+			exit();
1757
+		}
1758
+	}
1759
+
1760
+
1761
+	/**
1762
+	 *   _handle_redirects
1763
+	 *
1764
+	 * @access protected
1765
+	 * @return void
1766
+	 */
1767
+	protected function _handle_html_redirects()
1768
+	{
1769
+		// going somewhere ?
1770
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1771
+			// store notices in a transient
1772
+			EE_Error::get_notices(false, true, true);
1773
+			wp_safe_redirect($this->checkout->redirect_url);
1774
+			exit();
1775
+		}
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 *   set_checkout_anchor
1781
+	 *
1782
+	 * @access public
1783
+	 * @return void
1784
+	 */
1785
+	public function set_checkout_anchor()
1786
+	{
1787
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1788
+	}
1789
+
1790
+	/**
1791
+	 *    getRegistrationExpirationNotice
1792
+	 *
1793
+	 * @since     4.9.59.p
1794
+	 * @access    public
1795
+	 * @return    string
1796
+	 */
1797
+	public static function getRegistrationExpirationNotice()
1798
+	{
1799
+		return sprintf(
1800
+			esc_html__(
1801
+				'%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 accept our apologies for any inconvenience this may have caused.%8$s',
1802
+				'event_espresso'
1803
+			),
1804
+			'<h4 class="important-notice">',
1805
+			'</h4>',
1806
+			'<br />',
1807
+			'<p>',
1808
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1809
+			'">',
1810
+			'</a>',
1811
+			'</p>'
1812
+		);
1813
+	}
1814 1814
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public static function set_hooks_admin()
101 101
     {
102 102
         EED_Single_Page_Checkout::set_definitions();
103
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
103
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
104 104
             return;
105 105
         }
106 106
         // going to start an output buffer in case anything gets accidentally output
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
         }
207 207
         define(
208 208
             'SPCO_BASE_PATH',
209
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
209
+            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS
210 210
         );
211
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
212
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
213
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
214
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
215
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
216
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
211
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
212
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
213
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
214
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
215
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
216
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
217 217
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
218 218
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
219 219
         );
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             // we need a
246 246
             if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
247 247
                 // copy over to the reg_steps_array
248
-                EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
248
+                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
249 249
                 // register custom key route for each reg step
250 250
                 // ie: step=>"slug" - this is the entire reason we load the reg steps array now
251 251
                 EE_Config::register_route(
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 // add AJAX or other hooks
258 258
                 if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
259 259
                     // setup autoloaders if necessary
260
-                    if (! class_exists($reg_step['class_name'])) {
260
+                    if ( ! class_exists($reg_step['class_name'])) {
261 261
                         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
262 262
                             $reg_step['file_path'],
263 263
                             true
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
         if (empty($reg_steps)) {
286 286
             $reg_steps = array(
287 287
                 10  => array(
288
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
288
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
289 289
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
290 290
                     'slug'       => 'attendee_information',
291 291
                     'has_hooks'  => false,
292 292
                 ),
293 293
                 30  => array(
294
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
294
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
295 295
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
296 296
                     'slug'       => 'payment_options',
297 297
                     'has_hooks'  => true,
298 298
                 ),
299 299
                 999 => array(
300
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
300
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
301 301
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
302 302
                     'slug'       => 'finalize_registration',
303 303
                     'has_hooks'  => false,
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                 $this->checkout
451 451
             );
452 452
             // load the reg steps array
453
-            if (! $this->_load_and_instantiate_reg_steps()) {
453
+            if ( ! $this->_load_and_instantiate_reg_steps()) {
454 454
                 EED_Single_Page_Checkout::$_initialized = true;
455 455
                 return;
456 456
             }
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
             // and the next step
460 460
             $this->checkout->set_next_step();
461 461
             // verify that everything has been setup correctly
462
-            if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
462
+            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
463 463
                 EED_Single_Page_Checkout::$_initialized = true;
464 464
                 return;
465 465
             }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             // DEBUG LOG
475 475
             // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
476 476
             // get reg form
477
-            if (! $this->_check_form_submission()) {
477
+            if ( ! $this->_check_form_submission()) {
478 478
                 EED_Single_Page_Checkout::$_initialized = true;
479 479
                 return;
480 480
             }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
      */
506 506
     private function _verify_session()
507 507
     {
508
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
508
+        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
509 509
             throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
510 510
         }
511 511
         $clear_session_requested = filter_var(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             // EE_Registry::instance()->SSN->reset_cart();
524 524
             // EE_Registry::instance()->SSN->reset_checkout();
525 525
             // EE_Registry::instance()->SSN->reset_transaction();
526
-            if (! $clear_session_requested) {
526
+            if ( ! $clear_session_requested) {
527 527
                 EE_Error::add_attention(
528 528
                     EE_Registry::$i18n_js_strings['registration_expiration_notice'],
529 529
                     __FILE__,
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         /** @type EE_Checkout $checkout */
551 551
         $checkout = EE_Registry::instance()->SSN->checkout();
552 552
         // verify
553
-        if (! $checkout instanceof EE_Checkout) {
553
+        if ( ! $checkout instanceof EE_Checkout) {
554 554
             // instantiate EE_Checkout object for handling the properties of the current checkout process
555 555
             $checkout = EE_Registry::instance()->load_file(
556 556
                 SPCO_INC_PATH,
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
         }
569 569
         $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
570 570
         // verify again
571
-        if (! $checkout instanceof EE_Checkout) {
571
+        if ( ! $checkout instanceof EE_Checkout) {
572 572
             throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
573 573
         }
574 574
         // reset anything that needs a clean slate for each request
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      */
641 641
     protected function _display_request_vars()
642 642
     {
643
-        if (! WP_DEBUG) {
643
+        if ( ! WP_DEBUG) {
644 644
             return;
645 645
         }
646 646
         EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         ) {
718 718
             // if not, then loop through raw reg steps array
719 719
             foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
720
-                if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
720
+                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
721 721
                     return false;
722 722
                 }
723 723
             }
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
     private function _verify_transaction_and_get_registrations()
849 849
     {
850 850
         // was there already a valid transaction in the checkout from the session ?
851
-        if (! $this->checkout->transaction instanceof EE_Transaction) {
851
+        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
852 852
             // get transaction from db or session
853 853
             $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
854 854
                 ? $this->_get_transaction_and_cart_for_previous_visit()
855 855
                 : $this->_get_cart_for_current_session_and_setup_new_transaction();
856
-            if (! $this->checkout->transaction instanceof EE_Transaction) {
856
+            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
857 857
                 EE_Error::add_error(
858 858
                     esc_html__(
859 859
                         'Your Registration and Transaction information could not be retrieved from the db.',
@@ -1084,16 +1084,16 @@  discard block
 block discarded – undo
1084 1084
                         )
1085 1085
                     );
1086 1086
                     // override capabilities for frontend registrations
1087
-                    if (! is_admin()) {
1087
+                    if ( ! is_admin()) {
1088 1088
                         $CreateRegistrationCommand->setCapCheck(
1089 1089
                             new PublicCapabilities('', 'create_new_registration')
1090 1090
                         );
1091 1091
                     }
1092 1092
                     $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1093
-                    if (! $registration instanceof EE_Registration) {
1093
+                    if ( ! $registration instanceof EE_Registration) {
1094 1094
                         throw new InvalidEntityException($registration, 'EE_Registration');
1095 1095
                     }
1096
-                    $registrations[ $registration->ID() ] = $registration;
1096
+                    $registrations[$registration->ID()] = $registration;
1097 1097
                 }
1098 1098
             }
1099 1099
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
             $this->checkout
1137 1137
         );
1138 1138
         // verify that current step is still set correctly
1139
-        if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1139
+        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1140 1140
             EE_Error::add_error(
1141 1141
                 esc_html__(
1142 1142
                     '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.',
@@ -1149,9 +1149,9 @@  discard block
 block discarded – undo
1149 1149
             return false;
1150 1150
         }
1151 1151
         // if returning to SPCO, then verify that primary registrant is set
1152
-        if (! empty($this->checkout->reg_url_link)) {
1152
+        if ( ! empty($this->checkout->reg_url_link)) {
1153 1153
             $valid_registrant = $this->checkout->transaction->primary_registration();
1154
-            if (! $valid_registrant instanceof EE_Registration) {
1154
+            if ( ! $valid_registrant instanceof EE_Registration) {
1155 1155
                 EE_Error::add_error(
1156 1156
                     esc_html__(
1157 1157
                         '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.',
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
                     $valid_registrant = $registration;
1172 1172
                 }
1173 1173
             }
1174
-            if (! $valid_registrant instanceof EE_Registration) {
1174
+            if ( ! $valid_registrant instanceof EE_Registration) {
1175 1175
                 // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1176 1176
                 if (EED_Single_Page_Checkout::$_checkout_verified) {
1177 1177
                     // clear the session, mark the checkout as unverified, and try again
@@ -1215,9 +1215,9 @@  discard block
 block discarded – undo
1215 1215
         $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1216 1216
         // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1217 1217
         foreach ($this->checkout->reg_steps as $reg_step) {
1218
-            if (! $reg_step->initialize_reg_step()) {
1218
+            if ( ! $reg_step->initialize_reg_step()) {
1219 1219
                 // if not initialized then maybe this step is being removed...
1220
-                if (! $reinitializing && $reg_step->is_current_step()) {
1220
+                if ( ! $reinitializing && $reg_step->is_current_step()) {
1221 1221
                     // if it was the current step, then we need to start over here
1222 1222
                     $this->_initialize_reg_steps(true);
1223 1223
                     return;
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
                         )
1270 1270
                     );
1271 1271
                     // validate submitted form data
1272
-                    if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1272
+                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1273 1273
                         // thou shall not pass !!!
1274 1274
                         $this->checkout->continue_reg = false;
1275 1275
                         // any form validation errors?
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
                 break;
1318 1318
             default:
1319 1319
                 // meh... do one of those other steps first
1320
-                if (! empty($this->checkout->action)
1320
+                if ( ! empty($this->checkout->action)
1321 1321
                     && is_callable(array($this->checkout->current_step, $this->checkout->action))
1322 1322
                 ) {
1323 1323
                     // dynamically creates hook point like:
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
                         ) {
1338 1338
                             EE_Error::add_success(
1339 1339
                                 $this->checkout->current_step->success_message()
1340
-                                . '<br />' . $this->checkout->next_step->_instructions()
1340
+                                . '<br />'.$this->checkout->next_step->_instructions()
1341 1341
                             );
1342 1342
                         }
1343 1343
                         // pack it up, pack it in...
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
         // load css
1480 1480
         wp_register_style(
1481 1481
             'single_page_checkout',
1482
-            SPCO_CSS_URL . 'single_page_checkout.css',
1482
+            SPCO_CSS_URL.'single_page_checkout.css',
1483 1483
             array('espresso_default'),
1484 1484
             EVENT_ESPRESSO_VERSION
1485 1485
         );
@@ -1487,21 +1487,21 @@  discard block
 block discarded – undo
1487 1487
         // load JS
1488 1488
         wp_register_script(
1489 1489
             'jquery_plugin',
1490
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1490
+            EE_THIRD_PARTY_URL.'jquery	.plugin.min.js',
1491 1491
             array('jquery'),
1492 1492
             '1.0.1',
1493 1493
             true
1494 1494
         );
1495 1495
         wp_register_script(
1496 1496
             'jquery_countdown',
1497
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1497
+            EE_THIRD_PARTY_URL.'jquery	.countdown.min.js',
1498 1498
             array('jquery_plugin'),
1499 1499
             '2.1.0',
1500 1500
             true
1501 1501
         );
1502 1502
         wp_register_script(
1503 1503
             'single_page_checkout',
1504
-            SPCO_JS_URL . 'single_page_checkout.js',
1504
+            SPCO_JS_URL.'single_page_checkout.js',
1505 1505
             array('espresso_core', 'underscore', 'ee_form_section_validation'),
1506 1506
             EVENT_ESPRESSO_VERSION,
1507 1507
             true
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
          *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1528 1528
          */
1529 1529
         do_action(
1530
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1530
+            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(),
1531 1531
             $this
1532 1532
         );
1533 1533
     }
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
                     'layout_strategy' =>
1580 1580
                         new EE_Template_Layout(
1581 1581
                             array(
1582
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1582
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1583 1583
                                 'template_args'        => array(
1584 1584
                                     'empty_cart'              => $empty_cart,
1585 1585
                                     'revisit'                 => $this->checkout->revisit,
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
         )) {
1650 1650
             add_filter(
1651 1651
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1652
-                function ($url) {
1652
+                function($url) {
1653 1653
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1654 1654
                 }
1655 1655
             );
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
             '</h4>',
1806 1806
             '<br />',
1807 1807
             '<p>',
1808
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1808
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1809 1809
             '">',
1810 1810
             '</a>',
1811 1811
             '</p>'
Please login to merge, or discard this patch.