Completed
Branch BUG/registration-answers-caps-... (fc4276)
by
unknown
27:39 queued 14:40
created
core/EE_Deprecated.core.php 1 patch
Indentation   +1121 added lines, -1121 removed lines patch added patch discarded remove patch
@@ -37,31 +37,31 @@  discard block
 block discarded – undo
37 37
  * @param string $action_or_filter
38 38
  */
39 39
 function deprecated_espresso_action_or_filter_doing_it_wrong(
40
-    $deprecated_filter,
41
-    $replacement,
42
-    $replacement_location,
43
-    $version_deprecated,
44
-    $version_applies,
45
-    $action_or_filter = 'action'
40
+	$deprecated_filter,
41
+	$replacement,
42
+	$replacement_location,
43
+	$version_deprecated,
44
+	$version_applies,
45
+	$action_or_filter = 'action'
46 46
 ) {
47
-    $action_or_filter = $action_or_filter === 'action'
48
-        ? esc_html__('action', 'event_espresso')
49
-        : esc_html__('filter', 'event_espresso');
50
-    EE_Error::doing_it_wrong(
51
-        $deprecated_filter,
52
-        sprintf(
53
-            __(
54
-                'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
55
-                'event_espresso'
56
-            ),
57
-            $action_or_filter,
58
-            $replacement,
59
-            $replacement_location,
60
-            '<br />'
61
-        ),
62
-        $version_deprecated,
63
-        $version_applies
64
-    );
47
+	$action_or_filter = $action_or_filter === 'action'
48
+		? esc_html__('action', 'event_espresso')
49
+		: esc_html__('filter', 'event_espresso');
50
+	EE_Error::doing_it_wrong(
51
+		$deprecated_filter,
52
+		sprintf(
53
+			__(
54
+				'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
55
+				'event_espresso'
56
+			),
57
+			$action_or_filter,
58
+			$replacement,
59
+			$replacement_location,
60
+			'<br />'
61
+		),
62
+		$version_deprecated,
63
+		$version_applies
64
+	);
65 65
 }
66 66
 
67 67
 /**
@@ -73,90 +73,90 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout)
75 75
 {
76
-    // list of old filters
77
-    $deprecated_filters = array(
78
-        'update_registration_details' => true,
79
-        'process_payment'             => true,
80
-        'finalize_registration'       => true,
81
-        'and_proceed_to_payment'      => true,
82
-        'proceed_to'                  => true,
83
-    );
84
-    // loop thru and call doing_it_wrong() or remove any that aren't being used
85
-    foreach ($deprecated_filters as $deprecated_filter => $on) {
86
-        // was this filter called ?
87
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
88
-            // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
89
-            if (EE_Registry::instance()->CAP->current_user_can(
90
-                    'ee_read_ee',
91
-                    'hide_doing_it_wrong_for_deprecated_SPCO_filter'
92
-                ) && ! defined('DOING_AJAX')) {
93
-                EE_Error::doing_it_wrong(
94
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
95
-                    sprintf(
96
-                        __(
97
-                            'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
98
-                            'event_espresso'
99
-                        ),
100
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
101
-                        '<br />',
102
-                        'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
103
-                        '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
104
-                    ),
105
-                    '4.6.10'
106
-                );
107
-            }
108
-        } else {
109
-            unset($deprecated_filters[ $deprecated_filter ]);
110
-        }
111
-    }
112
-    if (! empty($deprecated_filters)) {
113
-
114
-        if ($checkout->current_step->slug(
115
-            ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
116
-            $submit_button_text = apply_filters(
117
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
118
-                $submit_button_text
119
-            );
120
-        } elseif ($checkout->current_step->slug(
121
-            ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
122
-            $submit_button_text = apply_filters(
123
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
124
-                $submit_button_text
125
-            );
126
-        } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
127
-            ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
128
-            $submit_button_text = apply_filters(
129
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
130
-                $submit_button_text
131
-            );
132
-        }
133
-        if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
134
-            if ($checkout->payment_required() && $checkout->next_step->slug(
135
-                ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
136
-                $submit_button_text .= apply_filters(
137
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
138
-                    $submit_button_text
139
-                );
140
-            }
141
-            if ($checkout->next_step->slug(
142
-                ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
143
-                $submit_button_text = apply_filters(
144
-                                          'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
145
-                                          $submit_button_text
146
-                                      ) . $checkout->next_step->name();
147
-            }
148
-        }
149
-
150
-    }
151
-    return $submit_button_text;
76
+	// list of old filters
77
+	$deprecated_filters = array(
78
+		'update_registration_details' => true,
79
+		'process_payment'             => true,
80
+		'finalize_registration'       => true,
81
+		'and_proceed_to_payment'      => true,
82
+		'proceed_to'                  => true,
83
+	);
84
+	// loop thru and call doing_it_wrong() or remove any that aren't being used
85
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
86
+		// was this filter called ?
87
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
88
+			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
89
+			if (EE_Registry::instance()->CAP->current_user_can(
90
+					'ee_read_ee',
91
+					'hide_doing_it_wrong_for_deprecated_SPCO_filter'
92
+				) && ! defined('DOING_AJAX')) {
93
+				EE_Error::doing_it_wrong(
94
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
95
+					sprintf(
96
+						__(
97
+							'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
98
+							'event_espresso'
99
+						),
100
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
101
+						'<br />',
102
+						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
103
+						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
104
+					),
105
+					'4.6.10'
106
+				);
107
+			}
108
+		} else {
109
+			unset($deprecated_filters[ $deprecated_filter ]);
110
+		}
111
+	}
112
+	if (! empty($deprecated_filters)) {
113
+
114
+		if ($checkout->current_step->slug(
115
+			) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
116
+			$submit_button_text = apply_filters(
117
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
118
+				$submit_button_text
119
+			);
120
+		} elseif ($checkout->current_step->slug(
121
+			) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
122
+			$submit_button_text = apply_filters(
123
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
124
+				$submit_button_text
125
+			);
126
+		} elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
127
+			) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
128
+			$submit_button_text = apply_filters(
129
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
130
+				$submit_button_text
131
+			);
132
+		}
133
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
134
+			if ($checkout->payment_required() && $checkout->next_step->slug(
135
+				) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
136
+				$submit_button_text .= apply_filters(
137
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
138
+					$submit_button_text
139
+				);
140
+			}
141
+			if ($checkout->next_step->slug(
142
+				) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
143
+				$submit_button_text = apply_filters(
144
+										  'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
145
+										  $submit_button_text
146
+									  ) . $checkout->next_step->name();
147
+			}
148
+		}
149
+
150
+	}
151
+	return $submit_button_text;
152 152
 
153 153
 }
154 154
 
155 155
 add_filter(
156
-    'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
157
-    'ee_deprecated__registration_checkout__button_text',
158
-    10,
159
-    2
156
+	'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
157
+	'ee_deprecated__registration_checkout__button_text',
158
+	10,
159
+	2
160 160
 );
161 161
 
162 162
 
@@ -168,54 +168,54 @@  discard block
 block discarded – undo
168 168
  */
169 169
 function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates)
170 170
 {
171
-    $action_ref = null;
172
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
173
-        ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
174
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
175
-        ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
176
-    if ($action_ref) {
177
-
178
-        EE_Error::doing_it_wrong(
179
-            $action_ref,
180
-            sprintf(
181
-                __(
182
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
183
-                    'event_espresso'
184
-                ),
185
-                '<br />',
186
-                '/core/business/EE_Transaction_Processor.class.php',
187
-                'AHEE__EE_Transaction_Processor__finalize',
188
-                'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
189
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
190
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
191
-            ),
192
-            '4.6.0'
193
-        );
194
-        switch ($action_ref) {
195
-            case 'AHEE__EE_Transaction__finalize__new_transaction' :
196
-                do_action(
197
-                    'AHEE__EE_Transaction__finalize__new_transaction',
198
-                    $checkout->transaction,
199
-                    $checkout->admin_request
200
-                );
201
-                break;
202
-            case 'AHEE__EE_Transaction__finalize__all_transaction' :
203
-                do_action(
204
-                    'AHEE__EE_Transaction__finalize__new_transaction',
205
-                    $checkout->transaction,
206
-                    array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
207
-                    $checkout->admin_request
208
-                );
209
-                break;
210
-        }
211
-    }
171
+	$action_ref = null;
172
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
173
+		? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
174
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
175
+		? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
176
+	if ($action_ref) {
177
+
178
+		EE_Error::doing_it_wrong(
179
+			$action_ref,
180
+			sprintf(
181
+				__(
182
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
183
+					'event_espresso'
184
+				),
185
+				'<br />',
186
+				'/core/business/EE_Transaction_Processor.class.php',
187
+				'AHEE__EE_Transaction_Processor__finalize',
188
+				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
189
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
190
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
191
+			),
192
+			'4.6.0'
193
+		);
194
+		switch ($action_ref) {
195
+			case 'AHEE__EE_Transaction__finalize__new_transaction' :
196
+				do_action(
197
+					'AHEE__EE_Transaction__finalize__new_transaction',
198
+					$checkout->transaction,
199
+					$checkout->admin_request
200
+				);
201
+				break;
202
+			case 'AHEE__EE_Transaction__finalize__all_transaction' :
203
+				do_action(
204
+					'AHEE__EE_Transaction__finalize__new_transaction',
205
+					$checkout->transaction,
206
+					array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
207
+					$checkout->admin_request
208
+				);
209
+				break;
210
+		}
211
+	}
212 212
 }
213 213
 
214 214
 add_action(
215
-    'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
216
-    'ee_deprecated_finalize_transaction',
217
-    10,
218
-    2
215
+	'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
216
+	'ee_deprecated_finalize_transaction',
217
+	10,
218
+	2
219 219
 );
220 220
 /**
221 221
  * ee_deprecated_finalize_registration
@@ -224,35 +224,35 @@  discard block
 block discarded – undo
224 224
  */
225 225
 function ee_deprecated_finalize_registration(EE_Registration $registration)
226 226
 {
227
-    $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
228
-        ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
229
-    if ($action_ref) {
230
-        EE_Error::doing_it_wrong(
231
-            $action_ref,
232
-            sprintf(
233
-                __(
234
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
235
-                    'event_espresso'
236
-                ),
237
-                '<br />',
238
-                '/core/business/EE_Registration_Processor.class.php',
239
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
240
-            ),
241
-            '4.6.0'
242
-        );
243
-        do_action(
244
-            'AHEE__EE_Registration__finalize__update_and_new_reg',
245
-            $registration,
246
-            (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
247
-        );
248
-    }
227
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
228
+		? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
229
+	if ($action_ref) {
230
+		EE_Error::doing_it_wrong(
231
+			$action_ref,
232
+			sprintf(
233
+				__(
234
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
235
+					'event_espresso'
236
+				),
237
+				'<br />',
238
+				'/core/business/EE_Registration_Processor.class.php',
239
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
240
+			),
241
+			'4.6.0'
242
+		);
243
+		do_action(
244
+			'AHEE__EE_Registration__finalize__update_and_new_reg',
245
+			$registration,
246
+			(is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
247
+		);
248
+	}
249 249
 }
250 250
 
251 251
 add_action(
252
-    'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
253
-    'ee_deprecated_finalize_registration',
254
-    10,
255
-    1
252
+	'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
253
+	'ee_deprecated_finalize_registration',
254
+	10,
255
+	1
256 256
 );
257 257
 
258 258
 
@@ -262,44 +262,44 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function ee_deprecated_hooks()
264 264
 {
265
-    /**
266
-     * @var          $hooks       array where keys are hook names, and their values are array{
267
-     * @type string  $version     when deprecated
268
-     * @type string  $alternative saying what to use instead
269
-     * @type boolean $still_works whether or not the hook still works
270
-     *        }
271
-     */
272
-    $hooks = array(
273
-        'AHEE__EE_System___do_setup_validations' => array(
274
-            'version'     => '4.6.0',
275
-            'alternative' => __(
276
-                'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
277
-                'event_espresso'
278
-            ),
279
-            'still_works' => false,
280
-        ),
281
-    );
282
-    foreach ($hooks as $name => $deprecation_info) {
283
-        if (has_action($name)) {
284
-            EE_Error::doing_it_wrong(
285
-                $name,
286
-                sprintf(
287
-                    __('This filter is deprecated. %1$s%2$s', 'event_espresso'),
288
-                    $deprecation_info['still_works'] ? __(
289
-                        'It *may* work as an attempt to build in backwards compatibility.',
290
-                        'event_espresso'
291
-                    ) : __('It has been completely removed.', 'event_espresso'),
292
-                    isset($deprecation_info['alternative'])
293
-                        ? $deprecation_info['alternative']
294
-                        : __(
295
-                        'Please read the current EE4 documentation further or contact Support.',
296
-                        'event_espresso'
297
-                    )
298
-                ),
299
-                isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
300
-            );
301
-        }
302
-    }
265
+	/**
266
+	 * @var          $hooks       array where keys are hook names, and their values are array{
267
+	 * @type string  $version     when deprecated
268
+	 * @type string  $alternative saying what to use instead
269
+	 * @type boolean $still_works whether or not the hook still works
270
+	 *        }
271
+	 */
272
+	$hooks = array(
273
+		'AHEE__EE_System___do_setup_validations' => array(
274
+			'version'     => '4.6.0',
275
+			'alternative' => __(
276
+				'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
277
+				'event_espresso'
278
+			),
279
+			'still_works' => false,
280
+		),
281
+	);
282
+	foreach ($hooks as $name => $deprecation_info) {
283
+		if (has_action($name)) {
284
+			EE_Error::doing_it_wrong(
285
+				$name,
286
+				sprintf(
287
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
288
+					$deprecation_info['still_works'] ? __(
289
+						'It *may* work as an attempt to build in backwards compatibility.',
290
+						'event_espresso'
291
+					) : __('It has been completely removed.', 'event_espresso'),
292
+					isset($deprecation_info['alternative'])
293
+						? $deprecation_info['alternative']
294
+						: __(
295
+						'Please read the current EE4 documentation further or contact Support.',
296
+						'event_espresso'
297
+					)
298
+				),
299
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
300
+			);
301
+		}
302
+	}
303 303
 }
304 304
 
305 305
 add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
@@ -314,34 +314,34 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
316 316
 {
317
-    $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
318
-              || has_action(
319
-                  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
320
-              );
321
-    if ($in_use) {
322
-        $msg = __(
323
-            'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
324
-            . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
325
-            . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
326
-            . 'to add other actions after a form submission has been received.',
327
-            'event_espresso'
328
-        );
329
-        EE_Error::doing_it_wrong(
330
-            __CLASS__ . '::' . __FUNCTION__,
331
-            $msg,
332
-            '4.8.32.rc.000'
333
-        );
334
-        // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
335
-        if (is_admin() && ! defined('DOING_AJAX')) {
336
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
337
-        }
338
-    }
339
-    return $in_use;
317
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
318
+			  || has_action(
319
+				  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
320
+			  );
321
+	if ($in_use) {
322
+		$msg = __(
323
+			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
324
+			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
325
+			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
326
+			. 'to add other actions after a form submission has been received.',
327
+			'event_espresso'
328
+		);
329
+		EE_Error::doing_it_wrong(
330
+			__CLASS__ . '::' . __FUNCTION__,
331
+			$msg,
332
+			'4.8.32.rc.000'
333
+		);
334
+		// it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
335
+		if (is_admin() && ! defined('DOING_AJAX')) {
336
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
337
+		}
338
+	}
339
+	return $in_use;
340 340
 }
341 341
 
342 342
 add_action(
343
-    'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
344
-    'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
343
+	'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
344
+	'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
345 345
 );
346 346
 
347 347
 /**
@@ -353,77 +353,77 @@  discard block
 block discarded – undo
353 353
  */
354 354
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
355 355
 {
356
-    // check if the old hooks are in use. If not, do the default
357
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
358
-        || ! $admin_page instanceof EE_Admin_Page) {
359
-        return;
360
-    }
361
-    $req_data = $admin_page->get_request_data();
362
-    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
363
-    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
364
-    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
365
-    if (! $REG_ID || ! $qstns) {
366
-        EE_Error::add_error(
367
-            __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
368
-            __FILE__,
369
-            __FUNCTION__,
370
-            __LINE__
371
-        );
372
-    }
373
-    $success = true;
374
-
375
-    // allow others to get in on this awesome fun   :D
376
-    do_action(
377
-        'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
378
-        $REG_ID,
379
-        $qstns
380
-    );
381
-    // loop thru questions... FINALLY!!!
382
-
383
-    foreach ($qstns as $QST_ID => $qstn) {
384
-        // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
385
-        if (! is_array($qstn)) {
386
-            $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
387
-            continue;
388
-        }
389
-
390
-
391
-        foreach ($qstn as $ANS_ID => $ANS_value) {
392
-            // get answer
393
-            $query_params = array(
394
-                0 => array(
395
-                    'ANS_ID' => $ANS_ID,
396
-                    'REG_ID' => $REG_ID,
397
-                    'QST_ID' => $QST_ID,
398
-                ),
399
-            );
400
-            $answer = EEM_Answer::instance()->get_one($query_params);
401
-            // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
402
-            if (! $answer instanceof EE_Answer) {
403
-                $set_values = array(
404
-                    'QST_ID'    => $QST_ID,
405
-                    'REG_ID'    => $REG_ID,
406
-                    'ANS_value' => $qstn,
407
-                );
408
-                $success = EEM_Answer::instance()->insert($set_values);
409
-                continue 2;
410
-            }
411
-
412
-            $answer->set('ANS_value', $ANS_value);
413
-            $success = $answer->save();
414
-        }
415
-    }
416
-    $what = __('Registration Form', 'event_espresso');
417
-    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
418
-    $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
419
-    exit;
356
+	// check if the old hooks are in use. If not, do the default
357
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
358
+		|| ! $admin_page instanceof EE_Admin_Page) {
359
+		return;
360
+	}
361
+	$req_data = $admin_page->get_request_data();
362
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
363
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
364
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
365
+	if (! $REG_ID || ! $qstns) {
366
+		EE_Error::add_error(
367
+			__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
368
+			__FILE__,
369
+			__FUNCTION__,
370
+			__LINE__
371
+		);
372
+	}
373
+	$success = true;
374
+
375
+	// allow others to get in on this awesome fun   :D
376
+	do_action(
377
+		'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
378
+		$REG_ID,
379
+		$qstns
380
+	);
381
+	// loop thru questions... FINALLY!!!
382
+
383
+	foreach ($qstns as $QST_ID => $qstn) {
384
+		// if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
385
+		if (! is_array($qstn)) {
386
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
387
+			continue;
388
+		}
389
+
390
+
391
+		foreach ($qstn as $ANS_ID => $ANS_value) {
392
+			// get answer
393
+			$query_params = array(
394
+				0 => array(
395
+					'ANS_ID' => $ANS_ID,
396
+					'REG_ID' => $REG_ID,
397
+					'QST_ID' => $QST_ID,
398
+				),
399
+			);
400
+			$answer = EEM_Answer::instance()->get_one($query_params);
401
+			// this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
402
+			if (! $answer instanceof EE_Answer) {
403
+				$set_values = array(
404
+					'QST_ID'    => $QST_ID,
405
+					'REG_ID'    => $REG_ID,
406
+					'ANS_value' => $qstn,
407
+				);
408
+				$success = EEM_Answer::instance()->insert($set_values);
409
+				continue 2;
410
+			}
411
+
412
+			$answer->set('ANS_value', $ANS_value);
413
+			$success = $answer->save();
414
+		}
415
+	}
416
+	$what = __('Registration Form', 'event_espresso');
417
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
418
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
419
+	exit;
420 420
 }
421 421
 
422 422
 add_action(
423
-    'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
424
-    'ee_deprecated_update_attendee_registration_form_old',
425
-    10,
426
-    1
423
+	'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
424
+	'ee_deprecated_update_attendee_registration_form_old',
425
+	10,
426
+	1
427 427
 );
428 428
 /**
429 429
  * Render the registration admin page's custom questions area in the old fashion
@@ -439,50 +439,50 @@  discard block
 block discarded – undo
439 439
  */
440 440
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
441 441
 {
442
-    // check if the old hooks are in use. If not, do the default
443
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
444
-        || ! $admin_page instanceof EE_Admin_Page) {
445
-        return $do_default_action;
446
-    }
447
-    add_filter(
448
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
449
-        array($admin_page, 'form_before_question_group'),
450
-        10,
451
-        1
452
-    );
453
-    add_filter(
454
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
455
-        array($admin_page, 'form_after_question_group'),
456
-        10,
457
-        1
458
-    );
459
-    add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
460
-    add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
461
-
462
-    $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
463
-        $registration,
464
-        $registration->get(
465
-            'EVT_ID'
466
-        )
467
-    );
468
-
469
-    EE_Registry::instance()->load_helper('Form_Fields');
470
-    $template_args = array(
471
-        'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
-        'reg_questions_form_action' => 'edit_registration',
473
-        'REG_ID'                    => $registration->ID(),
474
-    );
475
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
-    echo EEH_Template::display_template($template_path, $template_args, true);
477
-    // indicate that we should not do the default admin page code
478
-    return false;
442
+	// check if the old hooks are in use. If not, do the default
443
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
444
+		|| ! $admin_page instanceof EE_Admin_Page) {
445
+		return $do_default_action;
446
+	}
447
+	add_filter(
448
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
449
+		array($admin_page, 'form_before_question_group'),
450
+		10,
451
+		1
452
+	);
453
+	add_filter(
454
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
455
+		array($admin_page, 'form_after_question_group'),
456
+		10,
457
+		1
458
+	);
459
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
460
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
461
+
462
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
463
+		$registration,
464
+		$registration->get(
465
+			'EVT_ID'
466
+		)
467
+	);
468
+
469
+	EE_Registry::instance()->load_helper('Form_Fields');
470
+	$template_args = array(
471
+		'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
+		'reg_questions_form_action' => 'edit_registration',
473
+		'REG_ID'                    => $registration->ID(),
474
+	);
475
+	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
+	echo EEH_Template::display_template($template_path, $template_args, true);
477
+	// indicate that we should not do the default admin page code
478
+	return false;
479 479
 }
480 480
 
481 481
 add_action(
482
-    'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
-    'ee_deprecated_reg_questions_meta_box_old',
484
-    10,
485
-    3
482
+	'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
+	'ee_deprecated_reg_questions_meta_box_old',
484
+	10,
485
+	3
486 486
 );
487 487
 
488 488
 
@@ -499,42 +499,42 @@  discard block
 block discarded – undo
499 499
 class EE_Message_Template_Defaults extends EE_Base
500 500
 {
501 501
 
502
-    /**
503
-     * EE_Message_Template_Defaults constructor.
504
-     *
505
-     * @param EE_messages $messages
506
-     * @param             $messenger_name
507
-     * @param             $message_type_name
508
-     * @param int         $GRP_ID
509
-     * @return EE_Messages_Template_Defaults
510
-     */
511
-    public function __construct(
512
-        EE_messages $messages,
513
-        $messenger_name,
514
-        $message_type_name,
515
-        $GRP_ID = 0
516
-    ) {
517
-        EE_Error::doing_it_wrong(
518
-            __FUNCTION__,
519
-            __(
520
-                'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
-                'event_espresso'
522
-            ),
523
-            '4.9.0'
524
-        );
525
-        /** @var EE_Message_Resource_Manager $message_resource_manager */
526
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
-        $messenger = $message_resource_manager->get_messenger($messenger_name);
528
-        $message_type = $message_resource_manager->get_message_type($message_type_name);
529
-        return EE_Registry::instance()->load_lib(
530
-            'Messages_Template_Defaults',
531
-            array(
532
-                $GRP_ID,
533
-                $messenger,
534
-                $message_type,
535
-            )
536
-        );
537
-    }
502
+	/**
503
+	 * EE_Message_Template_Defaults constructor.
504
+	 *
505
+	 * @param EE_messages $messages
506
+	 * @param             $messenger_name
507
+	 * @param             $message_type_name
508
+	 * @param int         $GRP_ID
509
+	 * @return EE_Messages_Template_Defaults
510
+	 */
511
+	public function __construct(
512
+		EE_messages $messages,
513
+		$messenger_name,
514
+		$message_type_name,
515
+		$GRP_ID = 0
516
+	) {
517
+		EE_Error::doing_it_wrong(
518
+			__FUNCTION__,
519
+			__(
520
+				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
+				'event_espresso'
522
+			),
523
+			'4.9.0'
524
+		);
525
+		/** @var EE_Message_Resource_Manager $message_resource_manager */
526
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
528
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
529
+		return EE_Registry::instance()->load_lib(
530
+			'Messages_Template_Defaults',
531
+			array(
532
+				$GRP_ID,
533
+				$messenger,
534
+				$message_type,
535
+			)
536
+		);
537
+	}
538 538
 }
539 539
 
540 540
 
@@ -552,525 +552,525 @@  discard block
 block discarded – undo
552 552
 class EE_messages
553 553
 {
554 554
 
555
-    /** @type EE_messenger[] */
556
-    protected $_active_messengers = array();
557
-
558
-    /** @type array */
559
-    protected $_active_message_types = array();
560
-
561
-    /** @type EE_message_type[] */
562
-    protected $_installed_message_types = array();
563
-
564
-    /** @type EE_messenger */
565
-    protected $_messenger;
566
-
567
-    /** @type EE_message_type */
568
-    protected $_message_type;
569
-
570
-    /** @type array */
571
-    protected $_contexts = array();
572
-
573
-    /** @type EE_Message_Resource_Manager $_message_resource_manager */
574
-    protected $_message_resource_manager;
575
-
576
-
577
-    /**
578
-     * EE_messages constructor.
579
-     *
580
-     * @deprecated 4.9.0
581
-     */
582
-    public function __construct()
583
-    {
584
-    }
585
-
586
-
587
-    /**
588
-     * @param string $method
589
-     */
590
-    public function _class_is_deprecated($method)
591
-    {
592
-        EE_Error::doing_it_wrong(
593
-            'EE_messages::' . $method,
594
-            __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
-            '4.9.0',
596
-            '4.10.0.p'
597
-        );
598
-        // Please use EE_Message_Resource_Manager instead
599
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
-    }
601
-
602
-
603
-    /**
604
-     * @deprecated 4.9.0
605
-     * @param string $messenger_name
606
-     * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
-     */
608
-    public function ensure_messenger_is_active($messenger_name)
609
-    {
610
-        // EE_messages has been deprecated
611
-        $this->_class_is_deprecated(__FUNCTION__);
612
-        return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
-    }
614
-
615
-
616
-    /**
617
-     * @deprecated 4.9.0
618
-     * @param string $message_type message type name
619
-     * @param        $messenger
620
-     * @return bool true if it got activated (or was active) and false if not.
621
-     * @throws \EE_Error
622
-     */
623
-    public function ensure_message_type_is_active($message_type, $messenger)
624
-    {
625
-        // EE_messages has been deprecated
626
-        $this->_class_is_deprecated(__FUNCTION__);
627
-        return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
-    }
629
-
630
-
631
-    /**
632
-     * @deprecated 4.9.0
633
-     * @param string $messenger_name
634
-     * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
-     *                                             If included we do NOT setup the default message types (assuming they
636
-     *                                             are already setup.)
637
-     * @return boolean an array of generated templates or false if nothing generated/activated.
638
-     */
639
-    public function activate_messenger($messenger_name, $mts_to_activate = array())
640
-    {
641
-        // EE_messages has been deprecated
642
-        $this->_class_is_deprecated(__FUNCTION__);
643
-        return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
-    }
645
-
646
-
647
-    /**
648
-     * @deprecated 4.9.0
649
-     * @param EE_messenger    $messenger    messenger used in trigger
650
-     * @param EE_message_type $message_type message type used in trigger
651
-     *
652
-     * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
-     */
654
-    public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
-    {
656
-        // EE_messages has been deprecated
657
-        $this->_class_is_deprecated(__FUNCTION__);
658
-        return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
-    }
660
-
661
-
662
-    /**
663
-     * @deprecated 4.9.0
664
-     * @param string $messenger
665
-     * @return EE_messenger | null
666
-     */
667
-    public function get_messenger_if_active($messenger)
668
-    {
669
-        // EE_messages has been deprecated
670
-        $this->_class_is_deprecated(__FUNCTION__);
671
-        return $this->_message_resource_manager->get_active_messenger($messenger);
672
-    }
673
-
674
-
675
-    /**
676
-     * @deprecated 4.9.0
677
-     * @param EE_Message $message
678
-     * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
-     *                  available.
680
-     *                  Eg. Valid Messenger and Message Type:
681
-     *                  array(
682
-     *                  'messenger' => new EE_Email_messenger(),
683
-     *                  'message_type' => new EE_Registration_Approved_message_type()
684
-     *                  )
685
-     *                  Valid Messenger and Invalid Message Type:
686
-     *                  array(
687
-     *                  'messenger' => new EE_Email_messenger(),
688
-     *                  'message_type' => null
689
-     *                  )
690
-     */
691
-    public function validate_for_use(EE_Message $message)
692
-    {
693
-        // EE_messages has been deprecated
694
-        $this->_class_is_deprecated(__FUNCTION__);
695
-        return array(
696
-            'messenger'    => $message->messenger_object(),
697
-            'message_type' => $message->message_type_object(),
698
-        );
699
-    }
700
-
701
-
702
-    /**
703
-     * @deprecated 4.9.0
704
-     * @param  string $type                 What type of message are we sending (corresponds to message types)
705
-     * @param  mixed  $vars                 Data being sent for parsing in the message
706
-     * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
-     *                                      Otherwise we cycle through all active messengers.
708
-     * @param string  $generating_messenger if included then this messenger is used for generating the message
709
-     *                                      templates (but not for sending).
710
-     * @param string  $context              If included then only a message type for a specific context will be
711
-     *                                      generated.
712
-     * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
-     *                                      EE_messages objects which might be used by the trigger to setup a batch
714
-     *                                      message (typically html messenger uses it).
715
-     * @return bool
716
-     */
717
-    public function send_message(
718
-        $type,
719
-        $vars,
720
-        $sending_messenger = '',
721
-        $generating_messenger = '',
722
-        $context = '',
723
-        $send = true
724
-    ) {
725
-        // EE_messages has been deprecated
726
-        $this->_class_is_deprecated(__FUNCTION__);
727
-        /** @type EE_Messages_Processor $processor */
728
-        $processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
-        $error = false;
730
-        // try to intelligently determine what method we'll call based on the incoming data.
731
-        // if generating and sending are different then generate and send immediately.
732
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
-            // in the legacy system, when generating and sending were different, that means all the
734
-            // vars are already in the request object.  So let's just use that.
735
-            try {
736
-                /** @type EE_Message_To_Generate_From_Request $mtg */
737
-                $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
-                $processor->generate_and_send_now($mtg);
739
-            } catch (EE_Error $e) {
740
-                $error_msg = __(
741
-                    'Please note that a system message failed to send due to a technical issue.',
742
-                    'event_espresso'
743
-                );
744
-                // add specific message for developers if WP_DEBUG in on
745
-                $error_msg .= '||' . $e->getMessage();
746
-                EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
-                $error = true;
748
-            }
749
-        } else {
750
-            $processor->generate_for_all_active_messengers($type, $vars, $send);
751
-            // let's find out if there were any errors and how many successfully were queued.
752
-            $count_errors = $processor->get_queue()->count_STS_in_queue(
753
-                array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
-            );
755
-            $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
-            $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
-            $count_errors = $count_errors + $count_retry;
758
-            if ($count_errors > 0) {
759
-                $error = true;
760
-                if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
-                    $message = sprintf(
762
-                        __(
763
-                            'There were %d errors and %d messages successfully queued for generation and sending',
764
-                            'event_espresso'
765
-                        ),
766
-                        $count_errors,
767
-                        $count_queued
768
-                    );
769
-                } elseif ($count_errors > 1 && $count_queued === 1) {
770
-                    $message = sprintf(
771
-                        __(
772
-                            'There were %d errors and %d message successfully queued for generation.',
773
-                            'event_espresso'
774
-                        ),
775
-                        $count_errors,
776
-                        $count_queued
777
-                    );
778
-                } elseif ($count_errors === 1 && $count_queued > 1) {
779
-                    $message = sprintf(
780
-                        __(
781
-                            'There was %d error and %d messages successfully queued for generation.',
782
-                            'event_espresso'
783
-                        ),
784
-                        $count_errors,
785
-                        $count_queued
786
-                    );
787
-                } else {
788
-                    $message = sprintf(
789
-                        __(
790
-                            'There was %d message that failed to be queued for generation.',
791
-                            'event_espresso'
792
-                        ),
793
-                        $count_errors
794
-                    );
795
-                }
796
-                EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
-            } else {
798
-                if ($count_queued === 1) {
799
-                    $message = sprintf(
800
-                        __(
801
-                            '%d message successfully queued for generation.',
802
-                            'event_espresso'
803
-                        ),
804
-                        $count_queued
805
-                    );
806
-                } else {
807
-                    $message = sprintf(
808
-                        __(
809
-                            '%d messages were successfully queued for generation.',
810
-                            'event_espresso'
811
-                        ),
812
-                        $count_queued
813
-                    );
814
-                }
815
-                EE_Error::add_success($message);
816
-            }
817
-        }
818
-        // if no error then return the generated message(s).
819
-        if (! $error && ! $send) {
820
-            $generated_queue = $processor->generate_queue(false);
821
-            // get message and return.
822
-            $generated_queue->get_message_repository()->rewind();
823
-            $messages = array();
824
-            while ($generated_queue->get_message_repository()->valid()) {
825
-                $message = $generated_queue->get_message_repository()->current();
826
-                if ($message instanceof EE_Message) {
827
-                    // set properties that might be expected by add-ons (backward compat)
828
-                    $message->content = $message->content();
829
-                    $message->template_pack = $message->get_template_pack();
830
-                    $message->template_variation = $message->get_template_pack_variation();
831
-                    $messages[] = $message;
832
-                }
833
-                $generated_queue->get_message_repository()->next();
834
-            }
835
-            return $messages;
836
-        }
837
-        return $error ? false
838
-            : true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
-    }
840
-
841
-
842
-    /**
843
-     * @deprecated 4.9.0
844
-     * @param  string $type      This should correspond with a valid message type
845
-     * @param  string $context   This should correspond with a valid context for the message type
846
-     * @param  string $messenger This should correspond with a valid messenger.
847
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
-     *                           preview
849
-     * @return string          The body of the message.
850
-     */
851
-    public function preview_message($type, $context, $messenger, $send = false)
852
-    {
853
-        // EE_messages has been deprecated
854
-        $this->_class_is_deprecated(__FUNCTION__);
855
-        return EED_Messages::preview_message($type, $context, $messenger, $send);
856
-    }
857
-
858
-
859
-    /**
860
-     * @since      4.5.0
861
-     * @deprecated 4.9.0   Moved to EED_Messages Module
862
-     * @param string   $messenger    a string matching a valid active messenger in the system
863
-     * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
-     *                               required to send along the message type to the messenger because this is used for
865
-     *                               determining what specific variations might be loaded for the generated message.
866
-     * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
-     *
868
-     * @return bool          success or fail.
869
-     */
870
-    public function send_message_with_messenger_only($messenger, $message_type, $message)
871
-    {
872
-        // EE_messages has been deprecated
873
-        $this->_class_is_deprecated(__FUNCTION__);
874
-        // setup for sending to new method.
875
-        /** @type EE_Messages_Queue $queue */
876
-        $queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
-        // make sure we have a proper message object
878
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
-            $msg = EE_Message_Factory::create(
880
-                array(
881
-                    'MSG_messenger'    => $messenger,
882
-                    'MSG_message_type' => $message_type,
883
-                    'MSG_content'      => $message->content,
884
-                    'MSG_subject'      => $message->subject,
885
-                )
886
-            );
887
-        } else {
888
-            $msg = $message;
889
-        }
890
-        if (! $msg instanceof EE_Message) {
891
-            return false;
892
-        }
893
-        // make sure any content in a content property (if not empty) is set on the MSG_content.
894
-        if (! empty($msg->content)) {
895
-            $msg->set('MSG_content', $msg->content);
896
-        }
897
-        $queue->add($msg);
898
-        return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
-    }
900
-
901
-
902
-    /**
903
-     * @deprecated 4.9.0
904
-     * @param         $messenger
905
-     * @param  string $message_type message type that the templates are being created for
906
-     * @param int     $GRP_ID
907
-     * @param bool    $is_global
908
-     * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
-     *                      returned.
910
-     * @throws \EE_Error
911
-     */
912
-    public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
-    {
914
-        // EE_messages has been deprecated
915
-        $this->_class_is_deprecated(__FUNCTION__);
916
-        EE_Registry::instance()->load_helper('MSG_Template');
917
-        return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
-    }
919
-
920
-
921
-    /**
922
-     * @deprecated 4.9.0
923
-     * @param  string $messenger_name    name of EE_messenger
924
-     * @param  string $message_type_name name of EE_message_type
925
-     * @return array
926
-     */
927
-    public function get_fields($messenger_name, $message_type_name)
928
-    {
929
-        // EE_messages has been deprecated
930
-        $this->_class_is_deprecated(__FUNCTION__);
931
-        EE_Registry::instance()->load_helper('MSG_Template');
932
-        return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
-    }
934
-
935
-
936
-    /**
937
-     * @deprecated 4.9.0
938
-     * @access     public
939
-     * @param string $type                we can indicate just returning installed message types
940
-     *                                    or messengers (or both) via this parameter.
941
-     * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
-     * @return array                    multidimensional array of messenger and message_type objects
943
-     *                                    (messengers index, and message_type index);
944
-     */
945
-    public function get_installed($type = 'all', $skip_cache = false)
946
-    {
947
-        // EE_messages has been deprecated
948
-        $this->_class_is_deprecated(__FUNCTION__);
949
-        if ($skip_cache) {
950
-            $this->_message_resource_manager->reset_active_messengers_and_message_types();
951
-        }
952
-        switch ($type) {
953
-            case 'messengers' :
954
-                return array(
955
-                    'messenger' => $this->_message_resource_manager->installed_messengers(),
956
-                );
957
-                break;
958
-            case 'message_types' :
959
-                return array(
960
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
961
-                );
962
-                break;
963
-            case 'all' :
964
-            default :
965
-                return array(
966
-                    'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
968
-                );
969
-                break;
970
-        }
971
-    }
972
-
973
-
974
-    /**
975
-     * @deprecated 4.9.0
976
-     * @return \EE_messenger[]
977
-     */
978
-    public function get_active_messengers()
979
-    {
980
-        // EE_messages has been deprecated
981
-        $this->_class_is_deprecated(__FUNCTION__);
982
-        return $this->_message_resource_manager->active_messengers();
983
-    }
984
-
985
-
986
-    /**
987
-     * @deprecated 4.9.0
988
-     * @return array array of message_type references (string)
989
-     */
990
-    public function get_active_message_types()
991
-    {
992
-        // EE_messages has been deprecated
993
-        $this->_class_is_deprecated(__FUNCTION__);
994
-        return $this->_message_resource_manager->list_of_active_message_types();
995
-    }
996
-
997
-
998
-    /**
999
-     * @deprecated 4.9.0
1000
-     * @return EE_message_type[]
1001
-     */
1002
-    public function get_active_message_type_objects()
1003
-    {
1004
-        // EE_messages has been deprecated
1005
-        $this->_class_is_deprecated(__FUNCTION__);
1006
-        return $this->_message_resource_manager->get_active_message_type_objects();
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     * @deprecated 4.9.0
1012
-     * @since      4.5.0
1013
-     * @param string $messenger The messenger being checked
1014
-     * @return EE_message_type[]    (or empty array if none present)
1015
-     */
1016
-    public function get_active_message_types_per_messenger($messenger)
1017
-    {
1018
-        // EE_messages has been deprecated
1019
-        $this->_class_is_deprecated(__FUNCTION__);
1020
-        return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * @deprecated 4.9.0
1026
-     * @param string $messenger    The string should correspond to the messenger (message types are
1027
-     * @param string $message_type The string should correspond to a message type.
1028
-     * @return EE_message_type|null
1029
-     */
1030
-    public function get_active_message_type($messenger, $message_type)
1031
-    {
1032
-        // EE_messages has been deprecated
1033
-        $this->_class_is_deprecated(__FUNCTION__);
1034
-        return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @deprecated 4.9.0
1040
-     * @return array|\EE_message_type[]
1041
-     */
1042
-    public function get_installed_message_types()
1043
-    {
1044
-        // EE_messages has been deprecated
1045
-        $this->_class_is_deprecated(__FUNCTION__);
1046
-        return $this->_message_resource_manager->installed_message_types();
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     * @deprecated 4.9.0
1052
-     * @return array
1053
-     */
1054
-    public function get_installed_messengers()
1055
-    {
1056
-        // EE_messages has been deprecated
1057
-        $this->_class_is_deprecated(__FUNCTION__);
1058
-        return $this->_message_resource_manager->installed_messengers();
1059
-    }
1060
-
1061
-
1062
-    /**
1063
-     * @deprecated 4.9.0
1064
-     * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
-     *                           message type.
1066
-     * @return array
1067
-     */
1068
-    public function get_all_contexts($slugs_only = true)
1069
-    {
1070
-        // EE_messages has been deprecated
1071
-        $this->_class_is_deprecated(__FUNCTION__);
1072
-        return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
-    }
555
+	/** @type EE_messenger[] */
556
+	protected $_active_messengers = array();
557
+
558
+	/** @type array */
559
+	protected $_active_message_types = array();
560
+
561
+	/** @type EE_message_type[] */
562
+	protected $_installed_message_types = array();
563
+
564
+	/** @type EE_messenger */
565
+	protected $_messenger;
566
+
567
+	/** @type EE_message_type */
568
+	protected $_message_type;
569
+
570
+	/** @type array */
571
+	protected $_contexts = array();
572
+
573
+	/** @type EE_Message_Resource_Manager $_message_resource_manager */
574
+	protected $_message_resource_manager;
575
+
576
+
577
+	/**
578
+	 * EE_messages constructor.
579
+	 *
580
+	 * @deprecated 4.9.0
581
+	 */
582
+	public function __construct()
583
+	{
584
+	}
585
+
586
+
587
+	/**
588
+	 * @param string $method
589
+	 */
590
+	public function _class_is_deprecated($method)
591
+	{
592
+		EE_Error::doing_it_wrong(
593
+			'EE_messages::' . $method,
594
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
+			'4.9.0',
596
+			'4.10.0.p'
597
+		);
598
+		// Please use EE_Message_Resource_Manager instead
599
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
+	}
601
+
602
+
603
+	/**
604
+	 * @deprecated 4.9.0
605
+	 * @param string $messenger_name
606
+	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
+	 */
608
+	public function ensure_messenger_is_active($messenger_name)
609
+	{
610
+		// EE_messages has been deprecated
611
+		$this->_class_is_deprecated(__FUNCTION__);
612
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
+	}
614
+
615
+
616
+	/**
617
+	 * @deprecated 4.9.0
618
+	 * @param string $message_type message type name
619
+	 * @param        $messenger
620
+	 * @return bool true if it got activated (or was active) and false if not.
621
+	 * @throws \EE_Error
622
+	 */
623
+	public function ensure_message_type_is_active($message_type, $messenger)
624
+	{
625
+		// EE_messages has been deprecated
626
+		$this->_class_is_deprecated(__FUNCTION__);
627
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
+	}
629
+
630
+
631
+	/**
632
+	 * @deprecated 4.9.0
633
+	 * @param string $messenger_name
634
+	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
+	 *                                             If included we do NOT setup the default message types (assuming they
636
+	 *                                             are already setup.)
637
+	 * @return boolean an array of generated templates or false if nothing generated/activated.
638
+	 */
639
+	public function activate_messenger($messenger_name, $mts_to_activate = array())
640
+	{
641
+		// EE_messages has been deprecated
642
+		$this->_class_is_deprecated(__FUNCTION__);
643
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
+	}
645
+
646
+
647
+	/**
648
+	 * @deprecated 4.9.0
649
+	 * @param EE_messenger    $messenger    messenger used in trigger
650
+	 * @param EE_message_type $message_type message type used in trigger
651
+	 *
652
+	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
+	 */
654
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
+	{
656
+		// EE_messages has been deprecated
657
+		$this->_class_is_deprecated(__FUNCTION__);
658
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
+	}
660
+
661
+
662
+	/**
663
+	 * @deprecated 4.9.0
664
+	 * @param string $messenger
665
+	 * @return EE_messenger | null
666
+	 */
667
+	public function get_messenger_if_active($messenger)
668
+	{
669
+		// EE_messages has been deprecated
670
+		$this->_class_is_deprecated(__FUNCTION__);
671
+		return $this->_message_resource_manager->get_active_messenger($messenger);
672
+	}
673
+
674
+
675
+	/**
676
+	 * @deprecated 4.9.0
677
+	 * @param EE_Message $message
678
+	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
+	 *                  available.
680
+	 *                  Eg. Valid Messenger and Message Type:
681
+	 *                  array(
682
+	 *                  'messenger' => new EE_Email_messenger(),
683
+	 *                  'message_type' => new EE_Registration_Approved_message_type()
684
+	 *                  )
685
+	 *                  Valid Messenger and Invalid Message Type:
686
+	 *                  array(
687
+	 *                  'messenger' => new EE_Email_messenger(),
688
+	 *                  'message_type' => null
689
+	 *                  )
690
+	 */
691
+	public function validate_for_use(EE_Message $message)
692
+	{
693
+		// EE_messages has been deprecated
694
+		$this->_class_is_deprecated(__FUNCTION__);
695
+		return array(
696
+			'messenger'    => $message->messenger_object(),
697
+			'message_type' => $message->message_type_object(),
698
+		);
699
+	}
700
+
701
+
702
+	/**
703
+	 * @deprecated 4.9.0
704
+	 * @param  string $type                 What type of message are we sending (corresponds to message types)
705
+	 * @param  mixed  $vars                 Data being sent for parsing in the message
706
+	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
+	 *                                      Otherwise we cycle through all active messengers.
708
+	 * @param string  $generating_messenger if included then this messenger is used for generating the message
709
+	 *                                      templates (but not for sending).
710
+	 * @param string  $context              If included then only a message type for a specific context will be
711
+	 *                                      generated.
712
+	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
+	 *                                      EE_messages objects which might be used by the trigger to setup a batch
714
+	 *                                      message (typically html messenger uses it).
715
+	 * @return bool
716
+	 */
717
+	public function send_message(
718
+		$type,
719
+		$vars,
720
+		$sending_messenger = '',
721
+		$generating_messenger = '',
722
+		$context = '',
723
+		$send = true
724
+	) {
725
+		// EE_messages has been deprecated
726
+		$this->_class_is_deprecated(__FUNCTION__);
727
+		/** @type EE_Messages_Processor $processor */
728
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
+		$error = false;
730
+		// try to intelligently determine what method we'll call based on the incoming data.
731
+		// if generating and sending are different then generate and send immediately.
732
+		if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
+			// in the legacy system, when generating and sending were different, that means all the
734
+			// vars are already in the request object.  So let's just use that.
735
+			try {
736
+				/** @type EE_Message_To_Generate_From_Request $mtg */
737
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
+				$processor->generate_and_send_now($mtg);
739
+			} catch (EE_Error $e) {
740
+				$error_msg = __(
741
+					'Please note that a system message failed to send due to a technical issue.',
742
+					'event_espresso'
743
+				);
744
+				// add specific message for developers if WP_DEBUG in on
745
+				$error_msg .= '||' . $e->getMessage();
746
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
+				$error = true;
748
+			}
749
+		} else {
750
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
751
+			// let's find out if there were any errors and how many successfully were queued.
752
+			$count_errors = $processor->get_queue()->count_STS_in_queue(
753
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
+			);
755
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
+			$count_errors = $count_errors + $count_retry;
758
+			if ($count_errors > 0) {
759
+				$error = true;
760
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
+					$message = sprintf(
762
+						__(
763
+							'There were %d errors and %d messages successfully queued for generation and sending',
764
+							'event_espresso'
765
+						),
766
+						$count_errors,
767
+						$count_queued
768
+					);
769
+				} elseif ($count_errors > 1 && $count_queued === 1) {
770
+					$message = sprintf(
771
+						__(
772
+							'There were %d errors and %d message successfully queued for generation.',
773
+							'event_espresso'
774
+						),
775
+						$count_errors,
776
+						$count_queued
777
+					);
778
+				} elseif ($count_errors === 1 && $count_queued > 1) {
779
+					$message = sprintf(
780
+						__(
781
+							'There was %d error and %d messages successfully queued for generation.',
782
+							'event_espresso'
783
+						),
784
+						$count_errors,
785
+						$count_queued
786
+					);
787
+				} else {
788
+					$message = sprintf(
789
+						__(
790
+							'There was %d message that failed to be queued for generation.',
791
+							'event_espresso'
792
+						),
793
+						$count_errors
794
+					);
795
+				}
796
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
+			} else {
798
+				if ($count_queued === 1) {
799
+					$message = sprintf(
800
+						__(
801
+							'%d message successfully queued for generation.',
802
+							'event_espresso'
803
+						),
804
+						$count_queued
805
+					);
806
+				} else {
807
+					$message = sprintf(
808
+						__(
809
+							'%d messages were successfully queued for generation.',
810
+							'event_espresso'
811
+						),
812
+						$count_queued
813
+					);
814
+				}
815
+				EE_Error::add_success($message);
816
+			}
817
+		}
818
+		// if no error then return the generated message(s).
819
+		if (! $error && ! $send) {
820
+			$generated_queue = $processor->generate_queue(false);
821
+			// get message and return.
822
+			$generated_queue->get_message_repository()->rewind();
823
+			$messages = array();
824
+			while ($generated_queue->get_message_repository()->valid()) {
825
+				$message = $generated_queue->get_message_repository()->current();
826
+				if ($message instanceof EE_Message) {
827
+					// set properties that might be expected by add-ons (backward compat)
828
+					$message->content = $message->content();
829
+					$message->template_pack = $message->get_template_pack();
830
+					$message->template_variation = $message->get_template_pack_variation();
831
+					$messages[] = $message;
832
+				}
833
+				$generated_queue->get_message_repository()->next();
834
+			}
835
+			return $messages;
836
+		}
837
+		return $error ? false
838
+			: true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
+	}
840
+
841
+
842
+	/**
843
+	 * @deprecated 4.9.0
844
+	 * @param  string $type      This should correspond with a valid message type
845
+	 * @param  string $context   This should correspond with a valid context for the message type
846
+	 * @param  string $messenger This should correspond with a valid messenger.
847
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
+	 *                           preview
849
+	 * @return string          The body of the message.
850
+	 */
851
+	public function preview_message($type, $context, $messenger, $send = false)
852
+	{
853
+		// EE_messages has been deprecated
854
+		$this->_class_is_deprecated(__FUNCTION__);
855
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
856
+	}
857
+
858
+
859
+	/**
860
+	 * @since      4.5.0
861
+	 * @deprecated 4.9.0   Moved to EED_Messages Module
862
+	 * @param string   $messenger    a string matching a valid active messenger in the system
863
+	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
+	 *                               required to send along the message type to the messenger because this is used for
865
+	 *                               determining what specific variations might be loaded for the generated message.
866
+	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
+	 *
868
+	 * @return bool          success or fail.
869
+	 */
870
+	public function send_message_with_messenger_only($messenger, $message_type, $message)
871
+	{
872
+		// EE_messages has been deprecated
873
+		$this->_class_is_deprecated(__FUNCTION__);
874
+		// setup for sending to new method.
875
+		/** @type EE_Messages_Queue $queue */
876
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
+		// make sure we have a proper message object
878
+		if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
+			$msg = EE_Message_Factory::create(
880
+				array(
881
+					'MSG_messenger'    => $messenger,
882
+					'MSG_message_type' => $message_type,
883
+					'MSG_content'      => $message->content,
884
+					'MSG_subject'      => $message->subject,
885
+				)
886
+			);
887
+		} else {
888
+			$msg = $message;
889
+		}
890
+		if (! $msg instanceof EE_Message) {
891
+			return false;
892
+		}
893
+		// make sure any content in a content property (if not empty) is set on the MSG_content.
894
+		if (! empty($msg->content)) {
895
+			$msg->set('MSG_content', $msg->content);
896
+		}
897
+		$queue->add($msg);
898
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
+	}
900
+
901
+
902
+	/**
903
+	 * @deprecated 4.9.0
904
+	 * @param         $messenger
905
+	 * @param  string $message_type message type that the templates are being created for
906
+	 * @param int     $GRP_ID
907
+	 * @param bool    $is_global
908
+	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
+	 *                      returned.
910
+	 * @throws \EE_Error
911
+	 */
912
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
+	{
914
+		// EE_messages has been deprecated
915
+		$this->_class_is_deprecated(__FUNCTION__);
916
+		EE_Registry::instance()->load_helper('MSG_Template');
917
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
+	}
919
+
920
+
921
+	/**
922
+	 * @deprecated 4.9.0
923
+	 * @param  string $messenger_name    name of EE_messenger
924
+	 * @param  string $message_type_name name of EE_message_type
925
+	 * @return array
926
+	 */
927
+	public function get_fields($messenger_name, $message_type_name)
928
+	{
929
+		// EE_messages has been deprecated
930
+		$this->_class_is_deprecated(__FUNCTION__);
931
+		EE_Registry::instance()->load_helper('MSG_Template');
932
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
+	}
934
+
935
+
936
+	/**
937
+	 * @deprecated 4.9.0
938
+	 * @access     public
939
+	 * @param string $type                we can indicate just returning installed message types
940
+	 *                                    or messengers (or both) via this parameter.
941
+	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
+	 * @return array                    multidimensional array of messenger and message_type objects
943
+	 *                                    (messengers index, and message_type index);
944
+	 */
945
+	public function get_installed($type = 'all', $skip_cache = false)
946
+	{
947
+		// EE_messages has been deprecated
948
+		$this->_class_is_deprecated(__FUNCTION__);
949
+		if ($skip_cache) {
950
+			$this->_message_resource_manager->reset_active_messengers_and_message_types();
951
+		}
952
+		switch ($type) {
953
+			case 'messengers' :
954
+				return array(
955
+					'messenger' => $this->_message_resource_manager->installed_messengers(),
956
+				);
957
+				break;
958
+			case 'message_types' :
959
+				return array(
960
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
961
+				);
962
+				break;
963
+			case 'all' :
964
+			default :
965
+				return array(
966
+					'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
968
+				);
969
+				break;
970
+		}
971
+	}
972
+
973
+
974
+	/**
975
+	 * @deprecated 4.9.0
976
+	 * @return \EE_messenger[]
977
+	 */
978
+	public function get_active_messengers()
979
+	{
980
+		// EE_messages has been deprecated
981
+		$this->_class_is_deprecated(__FUNCTION__);
982
+		return $this->_message_resource_manager->active_messengers();
983
+	}
984
+
985
+
986
+	/**
987
+	 * @deprecated 4.9.0
988
+	 * @return array array of message_type references (string)
989
+	 */
990
+	public function get_active_message_types()
991
+	{
992
+		// EE_messages has been deprecated
993
+		$this->_class_is_deprecated(__FUNCTION__);
994
+		return $this->_message_resource_manager->list_of_active_message_types();
995
+	}
996
+
997
+
998
+	/**
999
+	 * @deprecated 4.9.0
1000
+	 * @return EE_message_type[]
1001
+	 */
1002
+	public function get_active_message_type_objects()
1003
+	{
1004
+		// EE_messages has been deprecated
1005
+		$this->_class_is_deprecated(__FUNCTION__);
1006
+		return $this->_message_resource_manager->get_active_message_type_objects();
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 * @deprecated 4.9.0
1012
+	 * @since      4.5.0
1013
+	 * @param string $messenger The messenger being checked
1014
+	 * @return EE_message_type[]    (or empty array if none present)
1015
+	 */
1016
+	public function get_active_message_types_per_messenger($messenger)
1017
+	{
1018
+		// EE_messages has been deprecated
1019
+		$this->_class_is_deprecated(__FUNCTION__);
1020
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * @deprecated 4.9.0
1026
+	 * @param string $messenger    The string should correspond to the messenger (message types are
1027
+	 * @param string $message_type The string should correspond to a message type.
1028
+	 * @return EE_message_type|null
1029
+	 */
1030
+	public function get_active_message_type($messenger, $message_type)
1031
+	{
1032
+		// EE_messages has been deprecated
1033
+		$this->_class_is_deprecated(__FUNCTION__);
1034
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @deprecated 4.9.0
1040
+	 * @return array|\EE_message_type[]
1041
+	 */
1042
+	public function get_installed_message_types()
1043
+	{
1044
+		// EE_messages has been deprecated
1045
+		$this->_class_is_deprecated(__FUNCTION__);
1046
+		return $this->_message_resource_manager->installed_message_types();
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 * @deprecated 4.9.0
1052
+	 * @return array
1053
+	 */
1054
+	public function get_installed_messengers()
1055
+	{
1056
+		// EE_messages has been deprecated
1057
+		$this->_class_is_deprecated(__FUNCTION__);
1058
+		return $this->_message_resource_manager->installed_messengers();
1059
+	}
1060
+
1061
+
1062
+	/**
1063
+	 * @deprecated 4.9.0
1064
+	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
+	 *                           message type.
1066
+	 * @return array
1067
+	 */
1068
+	public function get_all_contexts($slugs_only = true)
1069
+	{
1070
+		// EE_messages has been deprecated
1071
+		$this->_class_is_deprecated(__FUNCTION__);
1072
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
+	}
1074 1074
 
1075 1075
 
1076 1076
 }
@@ -1129,88 +1129,88 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 
1131 1131
 add_filter(
1132
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
-    function ($event_list_iframe_css) {
1134
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
-            return $event_list_iframe_css;
1136
-        }
1137
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1138
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
-            '4.9.14',
1142
-            '5.0.0',
1143
-            'filter'
1144
-        );
1145
-        return apply_filters(
1146
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
-            $event_list_iframe_css
1148
-        );
1149
-    }
1132
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
+	function ($event_list_iframe_css) {
1134
+		if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
+			return $event_list_iframe_css;
1136
+		}
1137
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1138
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
+			'4.9.14',
1142
+			'5.0.0',
1143
+			'filter'
1144
+		);
1145
+		return apply_filters(
1146
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
+			$event_list_iframe_css
1148
+		);
1149
+	}
1150 1150
 );
1151 1151
 add_filter(
1152
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
-    function ($event_list_iframe_js) {
1154
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
-            return $event_list_iframe_js;
1156
-        }
1157
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1158
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
-            '4.9.14',
1162
-            '5.0.0',
1163
-            'filter'
1164
-        );
1165
-        return apply_filters(
1166
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
-            $event_list_iframe_js
1168
-        );
1169
-    }
1152
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
+	function ($event_list_iframe_js) {
1154
+		if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
+			return $event_list_iframe_js;
1156
+		}
1157
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1158
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
+			'4.9.14',
1162
+			'5.0.0',
1163
+			'filter'
1164
+		);
1165
+		return apply_filters(
1166
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
+			$event_list_iframe_js
1168
+		);
1169
+	}
1170 1170
 );
1171 1171
 add_action(
1172
-    'AHEE__EE_Capabilities__addCaps__complete',
1173
-    function ($capabilities_map) {
1174
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
-            return;
1176
-        }
1177
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1178
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1179
-            'AHEE__EE_Capabilities__addCaps__complete',
1180
-            '\EE_Capabilities::addCaps()',
1181
-            '4.9.42',
1182
-            '5.0.0'
1183
-        );
1184
-        do_action(
1185
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1186
-            $capabilities_map
1187
-        );
1188
-    }
1172
+	'AHEE__EE_Capabilities__addCaps__complete',
1173
+	function ($capabilities_map) {
1174
+		if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
+			return;
1176
+		}
1177
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1178
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1179
+			'AHEE__EE_Capabilities__addCaps__complete',
1180
+			'\EE_Capabilities::addCaps()',
1181
+			'4.9.42',
1182
+			'5.0.0'
1183
+		);
1184
+		do_action(
1185
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1186
+			$capabilities_map
1187
+		);
1188
+	}
1189 1189
 );
1190 1190
 
1191 1191
 add_filter(
1192
-    'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
-    function ($existing_attendee, $registration, $attendee_data) {
1194
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
-            return $existing_attendee;
1196
-        }
1197
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1198
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
-            'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
-            '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
-            '4.9.34',
1202
-            '5.0.0',
1203
-            'filter'
1204
-        );
1205
-        return apply_filters(
1206
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
-            $existing_attendee,
1208
-            $registration,
1209
-            $attendee_data
1210
-        );
1211
-    },
1212
-    10,
1213
-    3
1192
+	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
+	function ($existing_attendee, $registration, $attendee_data) {
1194
+		if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
+			return $existing_attendee;
1196
+		}
1197
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1198
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
+			'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
+			'\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
+			'4.9.34',
1202
+			'5.0.0',
1203
+			'filter'
1204
+		);
1205
+		return apply_filters(
1206
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
+			$existing_attendee,
1208
+			$registration,
1209
+			$attendee_data
1210
+		);
1211
+	},
1212
+	10,
1213
+	3
1214 1214
 );
1215 1215
 
1216 1216
 /**
@@ -1221,88 +1221,88 @@  discard block
 block discarded – undo
1221 1221
 class EE_Event_List_Query extends WP_Query
1222 1222
 {
1223 1223
 
1224
-    private $title;
1225
-
1226
-    private $css_class;
1227
-
1228
-    private $category_slug;
1229
-
1230
-    /**
1231
-     * EE_Event_List_Query constructor.
1232
-     *
1233
-     * @param array $args
1234
-     */
1235
-    public function __construct($args = array())
1236
-    {
1237
-        \EE_Error::doing_it_wrong(
1238
-            __METHOD__,
1239
-            __(
1240
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
-                'event_espresso'
1242
-            ),
1243
-            '4.9.27',
1244
-            '5.0.0'
1245
-        );
1246
-        $this->title = isset($args['title']) ? $args['title'] : '';
1247
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
-        // the current "page" we are viewing
1251
-        $paged = max(1, get_query_var('paged'));
1252
-        // Force these args
1253
-        $args = array_merge(
1254
-            $args,
1255
-            array(
1256
-                'post_type'              => 'espresso_events',
1257
-                'posts_per_page'         => $limit,
1258
-                'update_post_term_cache' => false,
1259
-                'update_post_meta_cache' => false,
1260
-                'paged'                  => $paged,
1261
-                'offset'                 => ($paged - 1) * $limit,
1262
-            )
1263
-        );
1264
-        // run the query
1265
-        parent::__construct($args);
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * event_list_title
1271
-     *
1272
-     * @param string $event_list_title
1273
-     * @return string
1274
-     */
1275
-    public function event_list_title($event_list_title = '')
1276
-    {
1277
-        if (! empty($this->title)) {
1278
-            return $this->title;
1279
-        }
1280
-        return $event_list_title;
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * event_list_css
1286
-     *
1287
-     * @param string $event_list_css
1288
-     * @return string
1289
-     */
1290
-    public function event_list_css($event_list_css = '')
1291
-    {
1292
-        $event_list_css .= ! empty($event_list_css)
1293
-            ? ' '
1294
-            : '';
1295
-        $event_list_css .= ! empty($this->css_class)
1296
-            ? $this->css_class
1297
-            : '';
1298
-        $event_list_css .= ! empty($event_list_css)
1299
-            ? ' '
1300
-            : '';
1301
-        $event_list_css .= ! empty($this->category_slug)
1302
-            ? $this->category_slug
1303
-            : '';
1304
-        return $event_list_css;
1305
-    }
1224
+	private $title;
1225
+
1226
+	private $css_class;
1227
+
1228
+	private $category_slug;
1229
+
1230
+	/**
1231
+	 * EE_Event_List_Query constructor.
1232
+	 *
1233
+	 * @param array $args
1234
+	 */
1235
+	public function __construct($args = array())
1236
+	{
1237
+		\EE_Error::doing_it_wrong(
1238
+			__METHOD__,
1239
+			__(
1240
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
+				'event_espresso'
1242
+			),
1243
+			'4.9.27',
1244
+			'5.0.0'
1245
+		);
1246
+		$this->title = isset($args['title']) ? $args['title'] : '';
1247
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
+		// the current "page" we are viewing
1251
+		$paged = max(1, get_query_var('paged'));
1252
+		// Force these args
1253
+		$args = array_merge(
1254
+			$args,
1255
+			array(
1256
+				'post_type'              => 'espresso_events',
1257
+				'posts_per_page'         => $limit,
1258
+				'update_post_term_cache' => false,
1259
+				'update_post_meta_cache' => false,
1260
+				'paged'                  => $paged,
1261
+				'offset'                 => ($paged - 1) * $limit,
1262
+			)
1263
+		);
1264
+		// run the query
1265
+		parent::__construct($args);
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * event_list_title
1271
+	 *
1272
+	 * @param string $event_list_title
1273
+	 * @return string
1274
+	 */
1275
+	public function event_list_title($event_list_title = '')
1276
+	{
1277
+		if (! empty($this->title)) {
1278
+			return $this->title;
1279
+		}
1280
+		return $event_list_title;
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * event_list_css
1286
+	 *
1287
+	 * @param string $event_list_css
1288
+	 * @return string
1289
+	 */
1290
+	public function event_list_css($event_list_css = '')
1291
+	{
1292
+		$event_list_css .= ! empty($event_list_css)
1293
+			? ' '
1294
+			: '';
1295
+		$event_list_css .= ! empty($this->css_class)
1296
+			? $this->css_class
1297
+			: '';
1298
+		$event_list_css .= ! empty($event_list_css)
1299
+			? ' '
1300
+			: '';
1301
+		$event_list_css .= ! empty($this->category_slug)
1302
+			? $this->category_slug
1303
+			: '';
1304
+		return $event_list_css;
1305
+	}
1306 1306
 
1307 1307
 }
1308 1308
 
@@ -1319,66 +1319,66 @@  discard block
 block discarded – undo
1319 1319
 {
1320 1320
 
1321 1321
 
1322
-    /**
1323
-     *    class constructor
1324
-     *
1325
-     * @deprecated 4.9.59.p
1326
-     */
1327
-    public function __construct()
1328
-    {
1329
-        EE_Error::doing_it_wrong(
1330
-            __METHOD__,
1331
-            sprintf(
1332
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
-                __CLASS__,
1334
-                'EventEspresso\core\services\licensing\LicenseServices'
1335
-            ),
1336
-            '4.9.59.p'
1337
-        );
1338
-    }
1339
-
1340
-
1341
-    /**
1342
-     * The purpose of this function is to display information about Event Espresso data collection
1343
-     * and a optin selection for extra data collecting by users.
1344
-     *
1345
-     * @param bool $extra
1346
-     * @return string html.
1347
-     * @deprecated 4.9.59.p
1348
-     */
1349
-    public static function espresso_data_collection_optin_text($extra = true)
1350
-    {
1351
-        EE_Error::doing_it_wrong(
1352
-            __METHOD__,
1353
-            sprintf(
1354
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
-                __METHOD__,
1356
-                'EventEspresso\core\domain\services\Stats::optinText'
1357
-            ),
1358
-            '4.9.59.p'
1359
-        );
1360
-        Stats::optinText($extra);
1361
-    }
1362
-
1363
-    /**
1364
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
-     *
1366
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
-     *                          identify plugins. Defaults to core update
1368
-     * @return boolean           True if update available, false if not.
1369
-     * @deprecated 4.9.59.p
1370
-     */
1371
-    public static function is_update_available($basename = '')
1372
-    {
1373
-        EE_Error::doing_it_wrong(
1374
-            __METHOD__,
1375
-            sprintf(
1376
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
-                __METHOD__,
1378
-                'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
-            ),
1380
-            '4.9.59.p'
1381
-        );
1382
-        return LicenseService::isUpdateAvailable($basename);
1383
-    }
1322
+	/**
1323
+	 *    class constructor
1324
+	 *
1325
+	 * @deprecated 4.9.59.p
1326
+	 */
1327
+	public function __construct()
1328
+	{
1329
+		EE_Error::doing_it_wrong(
1330
+			__METHOD__,
1331
+			sprintf(
1332
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
+				__CLASS__,
1334
+				'EventEspresso\core\services\licensing\LicenseServices'
1335
+			),
1336
+			'4.9.59.p'
1337
+		);
1338
+	}
1339
+
1340
+
1341
+	/**
1342
+	 * The purpose of this function is to display information about Event Espresso data collection
1343
+	 * and a optin selection for extra data collecting by users.
1344
+	 *
1345
+	 * @param bool $extra
1346
+	 * @return string html.
1347
+	 * @deprecated 4.9.59.p
1348
+	 */
1349
+	public static function espresso_data_collection_optin_text($extra = true)
1350
+	{
1351
+		EE_Error::doing_it_wrong(
1352
+			__METHOD__,
1353
+			sprintf(
1354
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
+				__METHOD__,
1356
+				'EventEspresso\core\domain\services\Stats::optinText'
1357
+			),
1358
+			'4.9.59.p'
1359
+		);
1360
+		Stats::optinText($extra);
1361
+	}
1362
+
1363
+	/**
1364
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
+	 *
1366
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
+	 *                          identify plugins. Defaults to core update
1368
+	 * @return boolean           True if update available, false if not.
1369
+	 * @deprecated 4.9.59.p
1370
+	 */
1371
+	public static function is_update_available($basename = '')
1372
+	{
1373
+		EE_Error::doing_it_wrong(
1374
+			__METHOD__,
1375
+			sprintf(
1376
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
+				__METHOD__,
1378
+				'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
+			),
1380
+			'4.9.59.p'
1381
+		);
1382
+		return LicenseService::isUpdateAvailable($basename);
1383
+	}
1384 1384
 }
1385 1385
\ No newline at end of file
Please login to merge, or discard this patch.
templates/reg_admin_details_main_meta_box_reg_questions.template.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <div id="admin-primary-mbox-questions-dv" class="admin-primary-mbox-dv">
2 2
     <p>
3 3
         <?php _e(
4
-            'This displays the custom questions and answers for this registrant.  Please note that any answers to system questions have been saved with the contact record.  You can edit those answers via the "View/Edit this Contact" link in the Contact Details metabox in the sidebar.',
5
-            'event_espresso'
6
-        ); ?></p>
4
+			'This displays the custom questions and answers for this registrant.  Please note that any answers to system questions have been saved with the contact record.  You can edit those answers via the "View/Edit this Contact" link in the Contact Details metabox in the sidebar.',
5
+			'event_espresso'
6
+		); ?></p>
7 7
 
8 8
     <form name="reg-admin-attendee-questions-frm" id="reg-admin-attendee-questions-frm"
9 9
           action="<?php echo REG_ADMIN_URL; ?>" method="post">
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
         <?php echo $att_questions; ?>
17 17
         <?php if (! empty($att_questions)) : ?>
18 18
             <?php if (EE_Registry::instance()->CAP->current_user_can(
19
-                'ee_edit_registration',
20
-                'edit-reg-questions-mbox',
21
-                $REG_ID
22
-            )) : ?>
19
+				'ee_edit_registration',
20
+				'edit-reg-questions-mbox',
21
+				$REG_ID
22
+			)) : ?>
23 23
             <input id="reg-admin-attendee-questions-submit" class="button-primary" value="Update Registration Questions"
24 24
                    type="submit"/>
25 25
             <?php endif; ?>
26 26
         <?php else : ?>
27 27
             <p class="ee-attention">
28 28
                 <?php _e(
29
-                    'There were no custom questions asked for this registration.',
30
-                    'event_espresso'
31
-                ); ?></p>
29
+					'There were no custom questions asked for this registration.',
30
+					'event_espresso'
31
+				); ?></p>
32 32
         <?php endif; ?>
33 33
 
34 34
     </form>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 
8 8
     <form name="reg-admin-attendee-questions-frm" id="reg-admin-attendee-questions-frm"
9 9
           action="<?php echo REG_ADMIN_URL; ?>" method="post">
10
-        <?php wp_nonce_field($reg_questions_form_action . '_nonce', $reg_questions_form_action . '_nonce'); ?>
10
+        <?php wp_nonce_field($reg_questions_form_action.'_nonce', $reg_questions_form_action.'_nonce'); ?>
11 11
         <input type="hidden" name="page" value="<?php echo REG_PG_SLUG; ?>"/>
12 12
         <input type="hidden" name="action" value="<?php echo $reg_questions_form_action; ?>"/>
13 13
         <input type="hidden" name="_REG_ID" value="<?php echo $REG_ID; ?>"/>
14 14
         <input type="hidden" name="espresso_ajax" id="espresso-ajax" value="0"/>
15 15
         <input type="hidden" name="noheader" id="reg-admin-noheader-inp" value="true"/>
16 16
         <?php echo $att_questions; ?>
17
-        <?php if (! empty($att_questions)) : ?>
17
+        <?php if ( ! empty($att_questions)) : ?>
18 18
             <?php if (EE_Registry::instance()->CAP->current_user_can(
19 19
                 'ee_edit_registration',
20 20
                 'edit-reg-questions-mbox',
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,12 +23,15 @@
 block discarded – undo
23 23
             <input id="reg-admin-attendee-questions-submit" class="button-primary" value="Update Registration Questions"
24 24
                    type="submit"/>
25 25
             <?php endif; ?>
26
-        <?php else : ?>
26
+        <?php else {
27
+	: ?>
27 28
             <p class="ee-attention">
28 29
                 <?php _e(
29 30
                     'There were no custom questions asked for this registration.',
30 31
                     'event_espresso'
31
-                ); ?></p>
32
+                );
33
+}
34
+?></p>
32 35
         <?php endif; ?>
33 36
 
34 37
     </form>
Please login to merge, or discard this patch.
registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php 2 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -15,168 +15,168 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper
17 17
 {
18
-    /**
19
-     *
20
-     * @var EE_Registration
21
-     */
22
-    protected $_registration = null;
18
+	/**
19
+	 *
20
+	 * @var EE_Registration
21
+	 */
22
+	protected $_registration = null;
23 23
 
24
-    /**
25
-     *
26
-     * @param EE_Registration $reg
27
-     * @param array $options
28
-     */
29
-    public function __construct(EE_Registration $reg, $options = array())
30
-    {
31
-        $this->_registration = $reg;
32
-        if (! isset($options['layout_strategy'])) {
33
-            $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34
-        }
35
-        if (! isset($options['html_id'])) {
36
-            $options['html_id'] = 'reg-admin-attendee-questions-frm';
37
-        }
38
-        $this->build_form_from_registration();
39
-        parent::__construct($options);
40
-    }
24
+	/**
25
+	 *
26
+	 * @param EE_Registration $reg
27
+	 * @param array $options
28
+	 */
29
+	public function __construct(EE_Registration $reg, $options = array())
30
+	{
31
+		$this->_registration = $reg;
32
+		if (! isset($options['layout_strategy'])) {
33
+			$options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34
+		}
35
+		if (! isset($options['html_id'])) {
36
+			$options['html_id'] = 'reg-admin-attendee-questions-frm';
37
+		}
38
+		$this->build_form_from_registration();
39
+		parent::__construct($options);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Gets the registration object this form is about
45
-     * @return EE_Registration
46
-     */
47
-    public function get_registration()
48
-    {
49
-        return $this->_registration;
50
-    }
43
+	/**
44
+	 * Gets the registration object this form is about
45
+	 * @return EE_Registration
46
+	 */
47
+	public function get_registration()
48
+	{
49
+		return $this->_registration;
50
+	}
51 51
 
52
-    public function build_form_from_registration()
53
-    {
54
-        $reg = $this->get_registration();
55
-        if (! $reg instanceof EE_Registration) {
56
-            throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57
-        }
58
-        // we want to get all their question groups
59
-        $question_groups = EEM_Question_Group::instance()->get_all(
60
-            array(
61
-                array(
62
-                    'Event_Question_Group.EVT_ID' => $reg->event_ID(),
63
-                    'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64
-                    'OR' => array(
65
-                        'Question.QST_system*blank' =>  '',
66
-                        'Question.QST_system*null' => array( 'IS_NULL' )
67
-                    )
68
-                ),
69
-                'order_by' => array( 'QSG_order' => 'ASC' )
70
-            )
71
-        );
72
-        // get each question groups questions
73
-        foreach ($question_groups as $question_group) {
74
-            if ($question_group instanceof EE_Question_Group) {
75
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
76
-                    $question_group,
77
-                    $reg
78
-                );
79
-            }
80
-        }
81
-    }
52
+	public function build_form_from_registration()
53
+	{
54
+		$reg = $this->get_registration();
55
+		if (! $reg instanceof EE_Registration) {
56
+			throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57
+		}
58
+		// we want to get all their question groups
59
+		$question_groups = EEM_Question_Group::instance()->get_all(
60
+			array(
61
+				array(
62
+					'Event_Question_Group.EVT_ID' => $reg->event_ID(),
63
+					'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64
+					'OR' => array(
65
+						'Question.QST_system*blank' =>  '',
66
+						'Question.QST_system*null' => array( 'IS_NULL' )
67
+					)
68
+				),
69
+				'order_by' => array( 'QSG_order' => 'ASC' )
70
+			)
71
+		);
72
+		// get each question groups questions
73
+		foreach ($question_groups as $question_group) {
74
+			if ($question_group instanceof EE_Question_Group) {
75
+				$this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
76
+					$question_group,
77
+					$reg
78
+				);
79
+			}
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     *
87
-     * @param EE_Question_Group $question_group
88
-     * @param EE_Registration   $registration
89
-     * @return \EE_Form_Section_Proper
90
-     * @throws \EE_Error
91
-     */
92
-    public function build_subform_from_question_group($question_group, $registration)
93
-    {
94
-        if (! $question_group instanceof EE_Question_Group ||
95
-            ! $registration instanceof EE_Registration) {
96
-            throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97
-        }
98
-        $parts_of_subsection = array(
99
-            'title' => new EE_Form_Section_HTML(
100
-                EEH_HTML::h5(
101
-                    $question_group->name(),
102
-                    $question_group->identifier(),
103
-                    'espresso-question-group-title-h5 section-title'
104
-                )
105
-            )
106
-        );
107
-        $questions = $question_group->questions(
108
-            array(
109
-                array(
110
-                    'OR' => array(
111
-                        'QST_system*blank' => '',
112
-                        'QST_system*null' => array( 'IS_NULL' )
113
-                    )
114
-                )
115
-            )
116
-        );
117
-        foreach ($questions as $question) {
118
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
119
-        }
120
-        if (EE_Registry::instance()->CAP->current_user_can(
121
-            'ee_edit_registration',
122
-            'edit-reg-questions-mbox',
123
-            $this->_registration->ID()
124
-        )) {
125
-            $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126
-                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso') . '">
85
+	/**
86
+	 *
87
+	 * @param EE_Question_Group $question_group
88
+	 * @param EE_Registration   $registration
89
+	 * @return \EE_Form_Section_Proper
90
+	 * @throws \EE_Error
91
+	 */
92
+	public function build_subform_from_question_group($question_group, $registration)
93
+	{
94
+		if (! $question_group instanceof EE_Question_Group ||
95
+			! $registration instanceof EE_Registration) {
96
+			throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97
+		}
98
+		$parts_of_subsection = array(
99
+			'title' => new EE_Form_Section_HTML(
100
+				EEH_HTML::h5(
101
+					$question_group->name(),
102
+					$question_group->identifier(),
103
+					'espresso-question-group-title-h5 section-title'
104
+				)
105
+			)
106
+		);
107
+		$questions = $question_group->questions(
108
+			array(
109
+				array(
110
+					'OR' => array(
111
+						'QST_system*blank' => '',
112
+						'QST_system*null' => array( 'IS_NULL' )
113
+					)
114
+				)
115
+			)
116
+		);
117
+		foreach ($questions as $question) {
118
+			$parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
119
+		}
120
+		if (EE_Registry::instance()->CAP->current_user_can(
121
+			'ee_edit_registration',
122
+			'edit-reg-questions-mbox',
123
+			$this->_registration->ID()
124
+		)) {
125
+			$parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126
+				'<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso') . '">
127 127
 		  			<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso') . '</span>
128 128
 		  			<div class="dashicons dashicons-edit"></div>
129 129
 		  		</a></td></tr>'
130
-            );
131
-        }
132
-        return new EE_Form_Section_Proper(
133
-            array(
134
-                'subsections' => $parts_of_subsection,
135
-                'html_class' => 'question-group-questions',
136
-            )
137
-        );
138
-    }
130
+			);
131
+		}
132
+		return new EE_Form_Section_Proper(
133
+			array(
134
+				'subsections' => $parts_of_subsection,
135
+				'html_class' => 'question-group-questions',
136
+			)
137
+		);
138
+	}
139 139
 
140
-    /**
141
-     * Overrides parent so if inputs were disabled, we leave those with their defaults
142
-     * from the answers in the DB
143
-     * @param array $req_data like $_POST
144
-     * @return void
145
-     */
146
-    protected function _normalize($req_data)
147
-    {
148
-        $this->_received_submission = true;
149
-        $this->_validation_errors = array();
150
-        foreach ($this->get_validatable_subsections() as $subsection) {
151
-            if ($subsection->form_data_present_in($req_data)) {
152
-                try {
153
-                    $subsection->_normalize($req_data);
154
-                } catch (EE_Validation_Error $e) {
155
-                    $subsection->add_validation_error($e);
156
-                }
157
-            }
158
-        }
159
-    }
140
+	/**
141
+	 * Overrides parent so if inputs were disabled, we leave those with their defaults
142
+	 * from the answers in the DB
143
+	 * @param array $req_data like $_POST
144
+	 * @return void
145
+	 */
146
+	protected function _normalize($req_data)
147
+	{
148
+		$this->_received_submission = true;
149
+		$this->_validation_errors = array();
150
+		foreach ($this->get_validatable_subsections() as $subsection) {
151
+			if ($subsection->form_data_present_in($req_data)) {
152
+				try {
153
+					$subsection->_normalize($req_data);
154
+				} catch (EE_Validation_Error $e) {
155
+					$subsection->add_validation_error($e);
156
+				}
157
+			}
158
+		}
159
+	}
160 160
 
161 161
 
162 162
 
163
-    /**
164
-     * Performs validation on this form section and its subsections. For each subsection,
165
-     * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
166
-     * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
167
-     * calling parent::_validate() first.
168
-     */
169
-    protected function _validate()
170
-    {
171
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
172
-            if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
173
-                if (method_exists($this, '_validate_'.$subsection_name)) {
174
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
175
-                }
176
-                $subsection->_validate();
177
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
178
-                $subsection->_received_submission = true;
179
-            }
180
-        }
181
-    }
163
+	/**
164
+	 * Performs validation on this form section and its subsections. For each subsection,
165
+	 * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
166
+	 * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
167
+	 * calling parent::_validate() first.
168
+	 */
169
+	protected function _validate()
170
+	{
171
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
172
+			if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
173
+				if (method_exists($this, '_validate_'.$subsection_name)) {
174
+					call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
175
+				}
176
+				$subsection->_validate();
177
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
178
+				$subsection->_received_submission = true;
179
+			}
180
+		}
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     public function __construct(EE_Registration $reg, $options = array())
30 30
     {
31 31
         $this->_registration = $reg;
32
-        if (! isset($options['layout_strategy'])) {
32
+        if ( ! isset($options['layout_strategy'])) {
33 33
             $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34 34
         }
35
-        if (! isset($options['html_id'])) {
35
+        if ( ! isset($options['html_id'])) {
36 36
             $options['html_id'] = 'reg-admin-attendee-questions-frm';
37 37
         }
38 38
         $this->build_form_from_registration();
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function build_form_from_registration()
53 53
     {
54 54
         $reg = $this->get_registration();
55
-        if (! $reg instanceof EE_Registration) {
55
+        if ( ! $reg instanceof EE_Registration) {
56 56
             throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57 57
         }
58 58
         // we want to get all their question groups
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
                     'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64 64
                     'OR' => array(
65 65
                         'Question.QST_system*blank' =>  '',
66
-                        'Question.QST_system*null' => array( 'IS_NULL' )
66
+                        'Question.QST_system*null' => array('IS_NULL')
67 67
                     )
68 68
                 ),
69
-                'order_by' => array( 'QSG_order' => 'ASC' )
69
+                'order_by' => array('QSG_order' => 'ASC')
70 70
             )
71 71
         );
72 72
         // get each question groups questions
73 73
         foreach ($question_groups as $question_group) {
74 74
             if ($question_group instanceof EE_Question_Group) {
75
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
75
+                $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group(
76 76
                     $question_group,
77 77
                     $reg
78 78
                 );
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function build_subform_from_question_group($question_group, $registration)
93 93
     {
94
-        if (! $question_group instanceof EE_Question_Group ||
94
+        if ( ! $question_group instanceof EE_Question_Group ||
95 95
             ! $registration instanceof EE_Registration) {
96 96
             throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97 97
         }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
                 array(
110 110
                     'OR' => array(
111 111
                         'QST_system*blank' => '',
112
-                        'QST_system*null' => array( 'IS_NULL' )
112
+                        'QST_system*null' => array('IS_NULL')
113 113
                     )
114 114
                 )
115 115
             )
116 116
         );
117 117
         foreach ($questions as $question) {
118
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
118
+            $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration);
119 119
         }
120 120
         if (EE_Registry::instance()->CAP->current_user_can(
121 121
             'ee_edit_registration',
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
             $this->_registration->ID()
124 124
         )) {
125 125
             $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126
-                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso') . '">
127
-		  			<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso') . '</span>
126
+                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="'.esc_attr__('click to edit question', 'event_espresso').'">
127
+		  			<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span>
128 128
 		  			<div class="dashicons dashicons-edit"></div>
129 129
 		  		</a></td></tr>'
130 130
             );
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
172 172
             if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
173 173
                 if (method_exists($this, '_validate_'.$subsection_name)) {
174
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
174
+                    call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
175 175
                 }
176 176
                 $subsection->_validate();
177 177
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3824 added lines, -3824 removed lines patch added patch discarded remove patch
@@ -19,2399 +19,2399 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    private static $_reg_status;
38
-
39
-    /**
40
-     * Form for displaying the custom questions for this registration.
41
-     * This gets used a few times throughout the request so its best to cache it
42
-     *
43
-     * @var EE_Registration_Custom_Questions_Form
44
-     */
45
-    protected $_reg_custom_questions_form = null;
46
-
47
-
48
-    /**
49
-     *        constructor
50
-     *
51
-     * @Constructor
52
-     * @access public
53
-     * @param bool $routing
54
-     * @return Registrations_Admin_Page
55
-     */
56
-    public function __construct($routing = true)
57
-    {
58
-        parent::__construct($routing);
59
-        add_action('wp_loaded', array($this, 'wp_loaded'));
60
-    }
61
-
62
-
63
-    public function wp_loaded()
64
-    {
65
-        // when adding a new registration...
66
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
-            EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
69
-                || absint($this->_req_data['processing_registration']) !== 1
70
-            ) {
71
-                // and it's NOT the attendee information reg step
72
-                // force cookie expiration by setting time to last week
73
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
-                // and update the global
75
-                $_COOKIE['ee_registration_added'] = 0;
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-    protected function _init_page_props()
82
-    {
83
-        $this->page_slug = REG_PG_SLUG;
84
-        $this->_admin_base_url = REG_ADMIN_URL;
85
-        $this->_admin_base_path = REG_ADMIN;
86
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
87
-        $this->_cpt_routes = array(
88
-            'add_new_attendee' => 'espresso_attendees',
89
-            'edit_attendee'    => 'espresso_attendees',
90
-            'insert_attendee'  => 'espresso_attendees',
91
-            'update_attendee'  => 'espresso_attendees',
92
-        );
93
-        $this->_cpt_model_names = array(
94
-            'add_new_attendee' => 'EEM_Attendee',
95
-            'edit_attendee'    => 'EEM_Attendee',
96
-        );
97
-        $this->_cpt_edit_routes = array(
98
-            'espresso_attendees' => 'edit_attendee',
99
-        );
100
-        $this->_pagenow_map = array(
101
-            'add_new_attendee' => 'post-new.php',
102
-            'edit_attendee'    => 'post.php',
103
-            'trash'            => 'post.php',
104
-        );
105
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
-        // add filters so that the comment urls don't take users to a confusing 404 page
107
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
-    }
109
-
110
-
111
-    public function clear_comment_link($link, $comment, $args)
112
-    {
113
-        // gotta make sure this only happens on this route
114
-        $post_type = get_post_type($comment->comment_post_ID);
115
-        if ($post_type === 'espresso_attendees') {
116
-            return '#commentsdiv';
117
-        }
118
-        return $link;
119
-    }
120
-
121
-
122
-    protected function _ajax_hooks()
123
-    {
124
-        // todo: all hooks for registrations ajax goes in here
125
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
-    }
127
-
128
-
129
-    protected function _define_page_props()
130
-    {
131
-        $this->_admin_page_title = $this->page_label;
132
-        $this->_labels = array(
133
-            'buttons'                      => array(
134
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
-                'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
-                'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
-            ),
143
-            'publishbox'                   => array(
144
-                'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
-                'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
-            ),
147
-            'hide_add_button_on_cpt_route' => array(
148
-                'edit_attendee' => true,
149
-            ),
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     *        grab url requests and route them
156
-     *
157
-     * @access private
158
-     * @return void
159
-     */
160
-    public function _set_page_routes()
161
-    {
162
-        $this->_get_registration_status_array();
163
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
-            ? $this->_req_data['_REG_ID'] : 0;
165
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
167
-            : $reg_id;
168
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
-            ? $this->_req_data['ATT_ID'] : 0;
170
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
-            ? $this->_req_data['post']
172
-            : $att_id;
173
-        $this->_page_routes = array(
174
-            'default'                             => array(
175
-                'func'       => '_registrations_overview_list_table',
176
-                'capability' => 'ee_read_registrations',
177
-            ),
178
-            'view_registration'                   => array(
179
-                'func'       => '_registration_details',
180
-                'capability' => 'ee_read_registration',
181
-                'obj_id'     => $reg_id,
182
-            ),
183
-            'edit_registration'                   => array(
184
-                'func'               => '_update_attendee_registration_form',
185
-                'noheader'           => true,
186
-                'headers_sent_route' => 'view_registration',
187
-                'capability'         => 'ee_edit_registration',
188
-                'obj_id'             => $reg_id,
189
-                '_REG_ID'            => $reg_id,
190
-            ),
191
-            'trash_registrations'                 => array(
192
-                'func'       => '_trash_or_restore_registrations',
193
-                'args'       => array('trash' => true),
194
-                'noheader'   => true,
195
-                'capability' => 'ee_delete_registrations',
196
-            ),
197
-            'restore_registrations'               => array(
198
-                'func'       => '_trash_or_restore_registrations',
199
-                'args'       => array('trash' => false),
200
-                'noheader'   => true,
201
-                'capability' => 'ee_delete_registrations',
202
-            ),
203
-            'delete_registrations'                => array(
204
-                'func'       => '_delete_registrations',
205
-                'noheader'   => true,
206
-                'capability' => 'ee_delete_registrations',
207
-            ),
208
-            'new_registration'                    => array(
209
-                'func'       => 'new_registration',
210
-                'capability' => 'ee_edit_registrations',
211
-            ),
212
-            'process_reg_step'                    => array(
213
-                'func'       => 'process_reg_step',
214
-                'noheader'   => true,
215
-                'capability' => 'ee_edit_registrations',
216
-            ),
217
-            'redirect_to_txn'                     => array(
218
-                'func'       => 'redirect_to_txn',
219
-                'noheader'   => true,
220
-                'capability' => 'ee_edit_registrations',
221
-            ),
222
-            'change_reg_status'                   => array(
223
-                'func'       => '_change_reg_status',
224
-                'noheader'   => true,
225
-                'capability' => 'ee_edit_registration',
226
-                'obj_id'     => $reg_id,
227
-            ),
228
-            'approve_registration'                => array(
229
-                'func'       => 'approve_registration',
230
-                'noheader'   => true,
231
-                'capability' => 'ee_edit_registration',
232
-                'obj_id'     => $reg_id,
233
-            ),
234
-            'approve_and_notify_registration'     => array(
235
-                'func'       => 'approve_registration',
236
-                'noheader'   => true,
237
-                'args'       => array(true),
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_registrations'               => array(
242
-                'func'       => 'bulk_action_on_registrations',
243
-                'noheader'   => true,
244
-                'capability' => 'ee_edit_registrations',
245
-                'args'       => array('approve'),
246
-            ),
247
-            'approve_and_notify_registrations'    => array(
248
-                'func'       => 'bulk_action_on_registrations',
249
-                'noheader'   => true,
250
-                'capability' => 'ee_edit_registrations',
251
-                'args'       => array('approve', true),
252
-            ),
253
-            'decline_registration'                => array(
254
-                'func'       => 'decline_registration',
255
-                'noheader'   => true,
256
-                'capability' => 'ee_edit_registration',
257
-                'obj_id'     => $reg_id,
258
-            ),
259
-            'decline_and_notify_registration'     => array(
260
-                'func'       => 'decline_registration',
261
-                'noheader'   => true,
262
-                'args'       => array(true),
263
-                'capability' => 'ee_edit_registration',
264
-                'obj_id'     => $reg_id,
265
-            ),
266
-            'decline_registrations'               => array(
267
-                'func'       => 'bulk_action_on_registrations',
268
-                'noheader'   => true,
269
-                'capability' => 'ee_edit_registrations',
270
-                'args'       => array('decline'),
271
-            ),
272
-            'decline_and_notify_registrations'    => array(
273
-                'func'       => 'bulk_action_on_registrations',
274
-                'noheader'   => true,
275
-                'capability' => 'ee_edit_registrations',
276
-                'args'       => array('decline', true),
277
-            ),
278
-            'pending_registration'                => array(
279
-                'func'       => 'pending_registration',
280
-                'noheader'   => true,
281
-                'capability' => 'ee_edit_registration',
282
-                'obj_id'     => $reg_id,
283
-            ),
284
-            'pending_and_notify_registration'     => array(
285
-                'func'       => 'pending_registration',
286
-                'noheader'   => true,
287
-                'args'       => array(true),
288
-                'capability' => 'ee_edit_registration',
289
-                'obj_id'     => $reg_id,
290
-            ),
291
-            'pending_registrations'               => array(
292
-                'func'       => 'bulk_action_on_registrations',
293
-                'noheader'   => true,
294
-                'capability' => 'ee_edit_registrations',
295
-                'args'       => array('pending'),
296
-            ),
297
-            'pending_and_notify_registrations'    => array(
298
-                'func'       => 'bulk_action_on_registrations',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-                'args'       => array('pending', true),
302
-            ),
303
-            'no_approve_registration'             => array(
304
-                'func'       => 'not_approve_registration',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $reg_id,
308
-            ),
309
-            'no_approve_and_notify_registration'  => array(
310
-                'func'       => 'not_approve_registration',
311
-                'noheader'   => true,
312
-                'args'       => array(true),
313
-                'capability' => 'ee_edit_registration',
314
-                'obj_id'     => $reg_id,
315
-            ),
316
-            'no_approve_registrations'            => array(
317
-                'func'       => 'bulk_action_on_registrations',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_registrations',
320
-                'args'       => array('not_approve'),
321
-            ),
322
-            'no_approve_and_notify_registrations' => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('not_approve', true),
327
-            ),
328
-            'cancel_registration'                 => array(
329
-                'func'       => 'cancel_registration',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registration',
332
-                'obj_id'     => $reg_id,
333
-            ),
334
-            'cancel_and_notify_registration'      => array(
335
-                'func'       => 'cancel_registration',
336
-                'noheader'   => true,
337
-                'args'       => array(true),
338
-                'capability' => 'ee_edit_registration',
339
-                'obj_id'     => $reg_id,
340
-            ),
341
-            'cancel_registrations'                => array(
342
-                'func'       => 'bulk_action_on_registrations',
343
-                'noheader'   => true,
344
-                'capability' => 'ee_edit_registrations',
345
-                'args'       => array('cancel'),
346
-            ),
347
-            'cancel_and_notify_registrations'     => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('cancel', true),
352
-            ),
353
-            'wait_list_registration'              => array(
354
-                'func'       => 'wait_list_registration',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registration',
357
-                'obj_id'     => $reg_id,
358
-            ),
359
-            'wait_list_and_notify_registration'   => array(
360
-                'func'       => 'wait_list_registration',
361
-                'noheader'   => true,
362
-                'args'       => array(true),
363
-                'capability' => 'ee_edit_registration',
364
-                'obj_id'     => $reg_id,
365
-            ),
366
-            'contact_list'                        => array(
367
-                'func'       => '_attendee_contact_list_table',
368
-                'capability' => 'ee_read_contacts',
369
-            ),
370
-            'add_new_attendee'                    => array(
371
-                'func' => '_create_new_cpt_item',
372
-                'args' => array(
373
-                    'new_attendee' => true,
374
-                    'capability'   => 'ee_edit_contacts',
375
-                ),
376
-            ),
377
-            'edit_attendee'                       => array(
378
-                'func'       => '_edit_cpt_item',
379
-                'capability' => 'ee_edit_contacts',
380
-                'obj_id'     => $att_id,
381
-            ),
382
-            'duplicate_attendee'                  => array(
383
-                'func'       => '_duplicate_attendee',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_contacts',
386
-                'obj_id'     => $att_id,
387
-            ),
388
-            'insert_attendee'                     => array(
389
-                'func'       => '_insert_or_update_attendee',
390
-                'args'       => array(
391
-                    'new_attendee' => true,
392
-                ),
393
-                'noheader'   => true,
394
-                'capability' => 'ee_edit_contacts',
395
-            ),
396
-            'update_attendee'                     => array(
397
-                'func'       => '_insert_or_update_attendee',
398
-                'args'       => array(
399
-                    'new_attendee' => false,
400
-                ),
401
-                'noheader'   => true,
402
-                'capability' => 'ee_edit_contacts',
403
-                'obj_id'     => $att_id,
404
-            ),
405
-            'trash_attendees'                     => array(
406
-                'func'       => '_trash_or_restore_attendees',
407
-                'args'       => array(
408
-                    'trash' => 'true',
409
-                ),
410
-                'noheader'   => true,
411
-                'capability' => 'ee_delete_contacts',
412
-            ),
413
-            'trash_attendee'                      => array(
414
-                'func'       => '_trash_or_restore_attendees',
415
-                'args'       => array(
416
-                    'trash' => true,
417
-                ),
418
-                'noheader'   => true,
419
-                'capability' => 'ee_delete_contacts',
420
-                'obj_id'     => $att_id,
421
-            ),
422
-            'restore_attendees'                   => array(
423
-                'func'       => '_trash_or_restore_attendees',
424
-                'args'       => array(
425
-                    'trash' => false,
426
-                ),
427
-                'noheader'   => true,
428
-                'capability' => 'ee_delete_contacts',
429
-                'obj_id'     => $att_id,
430
-            ),
431
-            'resend_registration'                 => array(
432
-                'func'       => '_resend_registration',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_send_message',
435
-            ),
436
-            'registrations_report'                => array(
437
-                'func'       => '_registrations_report',
438
-                'noheader'   => true,
439
-                'capability' => 'ee_read_registrations',
440
-            ),
441
-            'contact_list_export'                 => array(
442
-                'func'       => '_contact_list_export',
443
-                'noheader'   => true,
444
-                'capability' => 'export',
445
-            ),
446
-            'contact_list_report'                 => array(
447
-                'func'       => '_contact_list_report',
448
-                'noheader'   => true,
449
-                'capability' => 'ee_read_contacts',
450
-            ),
451
-        );
452
-    }
453
-
454
-
455
-    protected function _set_page_config()
456
-    {
457
-        $this->_page_config = array(
458
-            'default'           => array(
459
-                'nav'           => array(
460
-                    'label' => esc_html__('Overview', 'event_espresso'),
461
-                    'order' => 5,
462
-                ),
463
-                'help_tabs'     => array(
464
-                    'registrations_overview_help_tab'                       => array(
465
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
-                        'filename' => 'registrations_overview',
467
-                    ),
468
-                    'registrations_overview_table_column_headings_help_tab' => array(
469
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
-                        'filename' => 'registrations_overview_table_column_headings',
471
-                    ),
472
-                    'registrations_overview_filters_help_tab'               => array(
473
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
-                        'filename' => 'registrations_overview_filters',
475
-                    ),
476
-                    'registrations_overview_views_help_tab'                 => array(
477
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
478
-                        'filename' => 'registrations_overview_views',
479
-                    ),
480
-                    'registrations_regoverview_other_help_tab'              => array(
481
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
-                        'filename' => 'registrations_overview_other',
483
-                    ),
484
-                ),
485
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
486
-                'qtips'         => array('Registration_List_Table_Tips'),
487
-                'list_table'    => 'EE_Registrations_List_Table',
488
-                'require_nonce' => false,
489
-            ),
490
-            'view_registration' => array(
491
-                'nav'           => array(
492
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
493
-                    'order'      => 15,
494
-                    'url'        => isset($this->_req_data['_REG_ID'])
495
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
-                        : $this->_admin_base_url,
497
-                    'persistent' => false,
498
-                ),
499
-                'help_tabs'     => array(
500
-                    'registrations_details_help_tab'                    => array(
501
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
502
-                        'filename' => 'registrations_details',
503
-                    ),
504
-                    'registrations_details_table_help_tab'              => array(
505
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
-                        'filename' => 'registrations_details_table',
507
-                    ),
508
-                    'registrations_details_form_answers_help_tab'       => array(
509
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
-                        'filename' => 'registrations_details_form_answers',
511
-                    ),
512
-                    'registrations_details_registrant_details_help_tab' => array(
513
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
514
-                        'filename' => 'registrations_details_registrant_details',
515
-                    ),
516
-                ),
517
-                'help_tour'     => array('Registration_Details_Help_Tour'),
518
-                'metaboxes'     => array_merge(
519
-                    $this->_default_espresso_metaboxes,
520
-                    array('_registration_details_metaboxes')
521
-                ),
522
-                'require_nonce' => false,
523
-            ),
524
-            'new_registration'  => array(
525
-                'nav'           => array(
526
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
-                    'url'        => '#',
528
-                    'order'      => 15,
529
-                    'persistent' => false,
530
-                ),
531
-                'metaboxes'     => $this->_default_espresso_metaboxes,
532
-                'labels'        => array(
533
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
-                ),
535
-                'require_nonce' => false,
536
-            ),
537
-            'add_new_attendee'  => array(
538
-                'nav'           => array(
539
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
540
-                    'order'      => 15,
541
-                    'persistent' => false,
542
-                ),
543
-                'metaboxes'     => array_merge(
544
-                    $this->_default_espresso_metaboxes,
545
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
546
-                ),
547
-                'require_nonce' => false,
548
-            ),
549
-            'edit_attendee'     => array(
550
-                'nav'           => array(
551
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
-                    'order'      => 15,
553
-                    'persistent' => false,
554
-                    'url'        => isset($this->_req_data['ATT_ID'])
555
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
-                        : $this->_admin_base_url,
557
-                ),
558
-                'metaboxes'     => array('attendee_editor_metaboxes'),
559
-                'require_nonce' => false,
560
-            ),
561
-            'contact_list'      => array(
562
-                'nav'           => array(
563
-                    'label' => esc_html__('Contact List', 'event_espresso'),
564
-                    'order' => 20,
565
-                ),
566
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
567
-                'help_tabs'     => array(
568
-                    'registrations_contact_list_help_tab'                       => array(
569
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
-                        'filename' => 'registrations_contact_list',
571
-                    ),
572
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
573
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
-                        'filename' => 'registrations_contact_list_table_column_headings',
575
-                    ),
576
-                    'registrations_contact_list_views_help_tab'                 => array(
577
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
-                        'filename' => 'registrations_contact_list_views',
579
-                    ),
580
-                    'registrations_contact_list_other_help_tab'                 => array(
581
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
-                        'filename' => 'registrations_contact_list_other',
583
-                    ),
584
-                ),
585
-                'help_tour'     => array('Contact_List_Help_Tour'),
586
-                'metaboxes'     => array(),
587
-                'require_nonce' => false,
588
-            ),
589
-            // override default cpt routes
590
-            'create_new'        => '',
591
-            'edit'              => '',
592
-        );
593
-    }
594
-
595
-
596
-    /**
597
-     * The below methods aren't used by this class currently
598
-     */
599
-    protected function _add_screen_options()
600
-    {
601
-    }
602
-
603
-
604
-    protected function _add_feature_pointers()
605
-    {
606
-    }
607
-
608
-
609
-    public function admin_init()
610
-    {
611
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
-            'click "Update Registration Questions" to save your changes',
613
-            'event_espresso'
614
-        );
615
-    }
616
-
617
-
618
-    public function admin_notices()
619
-    {
620
-    }
621
-
622
-
623
-    public function admin_footer_scripts()
624
-    {
625
-    }
626
-
627
-
628
-    /**
629
-     *        get list of registration statuses
630
-     *
631
-     * @access private
632
-     * @return void
633
-     * @throws EE_Error
634
-     */
635
-    private function _get_registration_status_array()
636
-    {
637
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
-    }
639
-
640
-
641
-    protected function _add_screen_options_default()
642
-    {
643
-        $this->_per_page_screen_option();
644
-    }
645
-
646
-
647
-    protected function _add_screen_options_contact_list()
648
-    {
649
-        $page_title = $this->_admin_page_title;
650
-        $this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
-        $this->_per_page_screen_option();
652
-        $this->_admin_page_title = $page_title;
653
-    }
654
-
655
-
656
-    public function load_scripts_styles()
657
-    {
658
-        // style
659
-        wp_register_style(
660
-            'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
-            array('ee-admin-css'),
663
-            EVENT_ESPRESSO_VERSION
664
-        );
665
-        wp_enqueue_style('espresso_reg');
666
-        // script
667
-        wp_register_script(
668
-            'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
-            EVENT_ESPRESSO_VERSION,
672
-            true
673
-        );
674
-        wp_enqueue_script('espresso_reg');
675
-    }
676
-
677
-
678
-    public function load_scripts_styles_edit_attendee()
679
-    {
680
-        // stuff to only show up on our attendee edit details page.
681
-        $attendee_details_translations = array(
682
-            'att_publish_text' => sprintf(
683
-                esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
-                $this->_cpt_model_obj->get_datetime('ATT_created')
685
-            ),
686
-        );
687
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
-        wp_enqueue_script('jquery-validate');
689
-    }
690
-
691
-
692
-    public function load_scripts_styles_view_registration()
693
-    {
694
-        // styles
695
-        wp_enqueue_style('espresso-ui-theme');
696
-        // scripts
697
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
698
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
-    }
700
-
701
-
702
-    public function load_scripts_styles_contact_list()
703
-    {
704
-        wp_dequeue_style('espresso_reg');
705
-        wp_register_style(
706
-            'espresso_att',
707
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
-            array('ee-admin-css'),
709
-            EVENT_ESPRESSO_VERSION
710
-        );
711
-        wp_enqueue_style('espresso_att');
712
-    }
713
-
714
-
715
-    public function load_scripts_styles_new_registration()
716
-    {
717
-        wp_register_script(
718
-            'ee-spco-for-admin',
719
-            REG_ASSETS_URL . 'spco_for_admin.js',
720
-            array('underscore', 'jquery'),
721
-            EVENT_ESPRESSO_VERSION,
722
-            true
723
-        );
724
-        wp_enqueue_script('ee-spco-for-admin');
725
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
-        EE_Form_Section_Proper::wp_enqueue_scripts();
727
-        EED_Ticket_Selector::load_tckt_slctr_assets();
728
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
729
-    }
730
-
731
-
732
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
-    {
734
-        add_filter('FHEE_load_EE_messages', '__return_true');
735
-    }
736
-
737
-
738
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
-    {
740
-        add_filter('FHEE_load_EE_messages', '__return_true');
741
-    }
742
-
743
-
744
-    protected function _set_list_table_views_default()
745
-    {
746
-        // for notification related bulk actions we need to make sure only active messengers have an option.
747
-        EED_Messages::set_autoloaders();
748
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
749
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
-        $active_mts = $message_resource_manager->list_of_active_message_types();
751
-        // key= bulk_action_slug, value= message type.
752
-        $match_array = array(
753
-            'approve_registrations'    => 'registration',
754
-            'decline_registrations'    => 'declined_registration',
755
-            'pending_registrations'    => 'pending_approval',
756
-            'no_approve_registrations' => 'not_approved_registration',
757
-            'cancel_registrations'     => 'cancelled_registration',
758
-        );
759
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
760
-            'ee_send_message',
761
-            'batch_send_messages'
762
-        );
763
-        /** setup reg status bulk actions **/
764
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
-                'Approve and Notify Registrations',
768
-                'event_espresso'
769
-            );
770
-        }
771
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
-                'Decline and Notify Registrations',
775
-                'event_espresso'
776
-            );
777
-        }
778
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
779
-            'Set Registrations to Pending Payment',
780
-            'event_espresso'
781
-        );
782
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
-                'Set Registrations to Pending Payment and Notify',
785
-                'event_espresso'
786
-            );
787
-        }
788
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
-            'Set Registrations to Not Approved',
790
-            'event_espresso'
791
-        );
792
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
-                'Set Registrations to Not Approved and Notify',
795
-                'event_espresso'
796
-            );
797
-        }
798
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
-                'Cancel Registrations and Notify',
802
-                'event_espresso'
803
-            );
804
-        }
805
-        $def_reg_status_actions = apply_filters(
806
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
-            $def_reg_status_actions,
808
-            $active_mts,
809
-            $can_send
810
-        );
811
-
812
-        $this->_views = array(
813
-            'all'   => array(
814
-                'slug'        => 'all',
815
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
-                'count'       => 0,
817
-                'bulk_action' => array_merge(
818
-                    $def_reg_status_actions,
819
-                    array(
820
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
-                    )
822
-                ),
823
-            ),
824
-            'month' => array(
825
-                'slug'        => 'month',
826
-                'label'       => esc_html__('This Month', 'event_espresso'),
827
-                'count'       => 0,
828
-                'bulk_action' => array_merge(
829
-                    $def_reg_status_actions,
830
-                    array(
831
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
-                    )
833
-                ),
834
-            ),
835
-            'today' => array(
836
-                'slug'        => 'today',
837
-                'label'       => sprintf(
838
-                    esc_html__('Today - %s', 'event_espresso'),
839
-                    date('M d, Y', current_time('timestamp'))
840
-                ),
841
-                'count'       => 0,
842
-                'bulk_action' => array_merge(
843
-                    $def_reg_status_actions,
844
-                    array(
845
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
-                    )
847
-                ),
848
-            ),
849
-        );
850
-        if (EE_Registry::instance()->CAP->current_user_can(
851
-            'ee_delete_registrations',
852
-            'espresso_registrations_delete_registration'
853
-        )) {
854
-            $this->_views['incomplete'] = array(
855
-                'slug'        => 'incomplete',
856
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
857
-                'count'       => 0,
858
-                'bulk_action' => array(
859
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
-                ),
861
-            );
862
-            $this->_views['trash'] = array(
863
-                'slug'        => 'trash',
864
-                'label'       => esc_html__('Trash', 'event_espresso'),
865
-                'count'       => 0,
866
-                'bulk_action' => array(
867
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
-                ),
870
-            );
871
-        }
872
-    }
873
-
874
-
875
-    protected function _set_list_table_views_contact_list()
876
-    {
877
-        $this->_views = array(
878
-            'in_use' => array(
879
-                'slug'        => 'in_use',
880
-                'label'       => esc_html__('In Use', 'event_espresso'),
881
-                'count'       => 0,
882
-                'bulk_action' => array(
883
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
-                ),
885
-            ),
886
-        );
887
-        if (EE_Registry::instance()->CAP->current_user_can(
888
-            'ee_delete_contacts',
889
-            'espresso_registrations_trash_attendees'
890
-        )
891
-        ) {
892
-            $this->_views['trash'] = array(
893
-                'slug'        => 'trash',
894
-                'label'       => esc_html__('Trash', 'event_espresso'),
895
-                'count'       => 0,
896
-                'bulk_action' => array(
897
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
-                ),
899
-            );
900
-        }
901
-    }
902
-
903
-
904
-    protected function _registration_legend_items()
905
-    {
906
-        $fc_items = array(
907
-            'star-icon'        => array(
908
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
-            ),
911
-            'view_details'     => array(
912
-                'class' => 'dashicons dashicons-clipboard',
913
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
-            ),
915
-            'edit_attendee'    => array(
916
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
-            ),
919
-            'view_transaction' => array(
920
-                'class' => 'dashicons dashicons-cart',
921
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
-            ),
923
-            'view_invoice'     => array(
924
-                'class' => 'dashicons dashicons-media-spreadsheet',
925
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
-            ),
927
-        );
928
-        if (EE_Registry::instance()->CAP->current_user_can(
929
-            'ee_send_message',
930
-            'espresso_registrations_resend_registration'
931
-        )) {
932
-            $fc_items['resend_registration'] = array(
933
-                'class' => 'dashicons dashicons-email-alt',
934
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
-            );
936
-        } else {
937
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
-        }
939
-        if (EE_Registry::instance()->CAP->current_user_can(
940
-            'ee_read_global_messages',
941
-            'view_filtered_messages'
942
-        )) {
943
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
-                $fc_items['view_related_messages'] = array(
946
-                    'class' => $related_for_icon['css_class'],
947
-                    'desc'  => $related_for_icon['label'],
948
-                );
949
-            }
950
-        }
951
-        $sc_items = array(
952
-            'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
-                'desc'  => EEH_Template::pretty_status(
955
-                    EEM_Registration::status_id_approved,
956
-                    false,
957
-                    'sentence'
958
-                ),
959
-            ),
960
-            'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
-                'desc'  => EEH_Template::pretty_status(
963
-                    EEM_Registration::status_id_pending_payment,
964
-                    false,
965
-                    'sentence'
966
-                ),
967
-            ),
968
-            'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
-                'desc'  => EEH_Template::pretty_status(
971
-                    EEM_Registration::status_id_wait_list,
972
-                    false,
973
-                    'sentence'
974
-                ),
975
-            ),
976
-            'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
-                'desc'  => EEH_Template::pretty_status(
979
-                    EEM_Registration::status_id_incomplete,
980
-                    false,
981
-                    'sentence'
982
-                ),
983
-            ),
984
-            'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
-                'desc'  => EEH_Template::pretty_status(
987
-                    EEM_Registration::status_id_not_approved,
988
-                    false,
989
-                    'sentence'
990
-                ),
991
-            ),
992
-            'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
-                'desc'  => EEH_Template::pretty_status(
995
-                    EEM_Registration::status_id_declined,
996
-                    false,
997
-                    'sentence'
998
-                ),
999
-            ),
1000
-            'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
-                'desc'  => EEH_Template::pretty_status(
1003
-                    EEM_Registration::status_id_cancelled,
1004
-                    false,
1005
-                    'sentence'
1006
-                ),
1007
-            ),
1008
-        );
1009
-        return array_merge($fc_items, $sc_items);
1010
-    }
1011
-
1012
-
1013
-
1014
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1015
-    /**
1016
-     * @throws \EE_Error
1017
-     */
1018
-    protected function _registrations_overview_list_table()
1019
-    {
1020
-        $this->_template_args['admin_page_header'] = '';
1021
-        $EVT_ID = ! empty($this->_req_data['event_id'])
1022
-            ? absint($this->_req_data['event_id'])
1023
-            : 0;
1024
-        $ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
-            ? absint($this->_req_data['ATT_ID'])
1026
-            : 0;
1027
-        if ($ATT_ID) {
1028
-            $attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
-            if ($attendee instanceof EE_Attendee) {
1030
-                $this->_template_args['admin_page_header'] = sprintf(
1031
-                    esc_html__(
1032
-                        '%1$s Viewing registrations for %2$s%3$s',
1033
-                        'event_espresso'
1034
-                    ),
1035
-                    '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
-                        array(
1038
-                            'action' => 'edit_attendee',
1039
-                            'post'   => $ATT_ID,
1040
-                        ),
1041
-                        REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1043
-                    '</h3>'
1044
-                );
1045
-            }
1046
-        }
1047
-        if ($EVT_ID) {
1048
-            if (EE_Registry::instance()->CAP->current_user_can(
1049
-                'ee_edit_registrations',
1050
-                'espresso_registrations_new_registration',
1051
-                $EVT_ID
1052
-            )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
-                    'new_registration',
1055
-                    'add-registrant',
1056
-                    array('event_id' => $EVT_ID),
1057
-                    'add-new-h2'
1058
-                );
1059
-            }
1060
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
-            if ($event instanceof EE_Event) {
1062
-                $this->_template_args['admin_page_header'] = sprintf(
1063
-                    esc_html__(
1064
-                        '%s Viewing registrations for the event: %s%s',
1065
-                        'event_espresso'
1066
-                    ),
1067
-                    '<h3 style="line-height:1.5em;">',
1068
-                    '<br /><a href="'
1069
-                    . EE_Admin_Page::add_query_args_and_nonce(
1070
-                        array(
1071
-                            'action' => 'edit',
1072
-                            'post'   => $event->ID(),
1073
-                        ),
1074
-                        EVENTS_ADMIN_URL
1075
-                    )
1076
-                    . '">&nbsp;'
1077
-                    . $event->get('EVT_name')
1078
-                    . '&nbsp;</a>&nbsp;',
1079
-                    '</h3>'
1080
-                );
1081
-            }
1082
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
-                $this->_template_args['admin_page_header'] = substr(
1086
-                    $this->_template_args['admin_page_header'],
1087
-                    0,
1088
-                    -5
1089
-                );
1090
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
-                $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
1095
-            }
1096
-        }
1097
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
-        $this->display_admin_list_table_page_with_no_sidebar();
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * This sets the _registration property for the registration details screen
1104
-     *
1105
-     * @access private
1106
-     * @return bool
1107
-     * @throws EE_Error
1108
-     * @throws InvalidArgumentException
1109
-     * @throws InvalidDataTypeException
1110
-     * @throws InvalidInterfaceException
1111
-     */
1112
-    private function _set_registration_object()
1113
-    {
1114
-        // get out if we've already set the object
1115
-        if ($this->_registration instanceof EE_Registration) {
1116
-            return true;
1117
-        }
1118
-        $REG = EEM_Registration::instance();
1119
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
-            return true;
1122
-        } else {
1123
-            $error_msg = sprintf(
1124
-                esc_html__(
1125
-                    'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
-                    'event_espresso'
1127
-                ),
1128
-                $REG_ID
1129
-            );
1130
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
-            $this->_registration = null;
1132
-            return false;
1133
-        }
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * Used to retrieve registrations for the list table.
1139
-     *
1140
-     * @param int  $per_page
1141
-     * @param bool $count
1142
-     * @param bool $this_month
1143
-     * @param bool $today
1144
-     * @return EE_Registration[]|int
1145
-     * @throws EE_Error
1146
-     * @throws InvalidArgumentException
1147
-     * @throws InvalidDataTypeException
1148
-     * @throws InvalidInterfaceException
1149
-     */
1150
-    public function get_registrations(
1151
-        $per_page = 10,
1152
-        $count = false,
1153
-        $this_month = false,
1154
-        $today = false
1155
-    ) {
1156
-        if ($this_month) {
1157
-            $this->_req_data['status'] = 'month';
1158
-        }
1159
-        if ($today) {
1160
-            $this->_req_data['status'] = 'today';
1161
-        }
1162
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
-        /**
1164
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
-         *
1166
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
-         * @see  EEM_Base::get_all()
1168
-         */
1169
-        $query_params['group_by'] = '';
1170
-
1171
-        return $count
1172
-            ? EEM_Registration::instance()->count($query_params)
1173
-            /** @type EE_Registration[] */
1174
-            : EEM_Registration::instance()->get_all($query_params);
1175
-    }
1176
-
1177
-
1178
-    /**
1179
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
-     * Note: this listens to values on the request for some of the query parameters.
1181
-     *
1182
-     * @param array $request
1183
-     * @param int   $per_page
1184
-     * @param bool  $count
1185
-     * @return array
1186
-     * @throws EE_Error
1187
-     */
1188
-    protected function _get_registration_query_parameters(
1189
-        $request = array(),
1190
-        $per_page = 10,
1191
-        $count = false
1192
-    ) {
1193
-
1194
-        $query_params = array(
1195
-            0                          => $this->_get_where_conditions_for_registrations_query(
1196
-                $request
1197
-            ),
1198
-            'caps'                     => EEM_Registration::caps_read_admin,
1199
-            'default_where_conditions' => 'this_model_only',
1200
-        );
1201
-        if (! $count) {
1202
-            $query_params = array_merge(
1203
-                $query_params,
1204
-                $this->_get_orderby_for_registrations_query(),
1205
-                $this->_get_limit($per_page)
1206
-            );
1207
-        }
1208
-
1209
-        return $query_params;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
-     *
1216
-     * @param array $request usually the same as $this->_req_data but not necessarily
1217
-     * @return array
1218
-     */
1219
-    protected function addAttendeeIdToWhereConditions(array $request)
1220
-    {
1221
-        $where = array();
1222
-        if (! empty($request['ATT_ID'])) {
1223
-            $where['ATT_ID'] = absint($request['ATT_ID']);
1224
-        }
1225
-        return $where;
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
-     *
1232
-     * @param array $request usually the same as $this->_req_data but not necessarily
1233
-     * @return array
1234
-     */
1235
-    protected function _add_event_id_to_where_conditions(array $request)
1236
-    {
1237
-        $where = array();
1238
-        if (! empty($request['event_id'])) {
1239
-            $where['EVT_ID'] = absint($request['event_id']);
1240
-        }
1241
-        return $where;
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
-     *
1248
-     * @param array $request usually the same as $this->_req_data but not necessarily
1249
-     * @return array
1250
-     */
1251
-    protected function _add_category_id_to_where_conditions(array $request)
1252
-    {
1253
-        $where = array();
1254
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
-            $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
-        }
1257
-        return $where;
1258
-    }
1259
-
1260
-
1261
-    /**
1262
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
-     *
1264
-     * @param array $request usually the same as $this->_req_data but not necessarily
1265
-     * @return array
1266
-     */
1267
-    protected function _add_datetime_id_to_where_conditions(array $request)
1268
-    {
1269
-        $where = array();
1270
-        if (! empty($request['datetime_id'])) {
1271
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
-        }
1273
-        if (! empty($request['DTT_ID'])) {
1274
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
-        }
1276
-        return $where;
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     * Adds the correct registration status to the where conditions for the registrations query.
1282
-     *
1283
-     * @param array $request usually the same as $this->_req_data but not necessarily
1284
-     * @return array
1285
-     */
1286
-    protected function _add_registration_status_to_where_conditions(array $request)
1287
-    {
1288
-        $where = array();
1289
-        $view = EEH_Array::is_set($request, 'status', '');
1290
-        $registration_status = ! empty($request['_reg_status'])
1291
-            ? sanitize_text_field($request['_reg_status'])
1292
-            : '';
1293
-
1294
-        /*
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	private static $_reg_status;
38
+
39
+	/**
40
+	 * Form for displaying the custom questions for this registration.
41
+	 * This gets used a few times throughout the request so its best to cache it
42
+	 *
43
+	 * @var EE_Registration_Custom_Questions_Form
44
+	 */
45
+	protected $_reg_custom_questions_form = null;
46
+
47
+
48
+	/**
49
+	 *        constructor
50
+	 *
51
+	 * @Constructor
52
+	 * @access public
53
+	 * @param bool $routing
54
+	 * @return Registrations_Admin_Page
55
+	 */
56
+	public function __construct($routing = true)
57
+	{
58
+		parent::__construct($routing);
59
+		add_action('wp_loaded', array($this, 'wp_loaded'));
60
+	}
61
+
62
+
63
+	public function wp_loaded()
64
+	{
65
+		// when adding a new registration...
66
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
+			EE_System::do_not_cache();
68
+			if (! isset($this->_req_data['processing_registration'])
69
+				|| absint($this->_req_data['processing_registration']) !== 1
70
+			) {
71
+				// and it's NOT the attendee information reg step
72
+				// force cookie expiration by setting time to last week
73
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
+				// and update the global
75
+				$_COOKIE['ee_registration_added'] = 0;
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+	protected function _init_page_props()
82
+	{
83
+		$this->page_slug = REG_PG_SLUG;
84
+		$this->_admin_base_url = REG_ADMIN_URL;
85
+		$this->_admin_base_path = REG_ADMIN;
86
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
87
+		$this->_cpt_routes = array(
88
+			'add_new_attendee' => 'espresso_attendees',
89
+			'edit_attendee'    => 'espresso_attendees',
90
+			'insert_attendee'  => 'espresso_attendees',
91
+			'update_attendee'  => 'espresso_attendees',
92
+		);
93
+		$this->_cpt_model_names = array(
94
+			'add_new_attendee' => 'EEM_Attendee',
95
+			'edit_attendee'    => 'EEM_Attendee',
96
+		);
97
+		$this->_cpt_edit_routes = array(
98
+			'espresso_attendees' => 'edit_attendee',
99
+		);
100
+		$this->_pagenow_map = array(
101
+			'add_new_attendee' => 'post-new.php',
102
+			'edit_attendee'    => 'post.php',
103
+			'trash'            => 'post.php',
104
+		);
105
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
+		// add filters so that the comment urls don't take users to a confusing 404 page
107
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
+	}
109
+
110
+
111
+	public function clear_comment_link($link, $comment, $args)
112
+	{
113
+		// gotta make sure this only happens on this route
114
+		$post_type = get_post_type($comment->comment_post_ID);
115
+		if ($post_type === 'espresso_attendees') {
116
+			return '#commentsdiv';
117
+		}
118
+		return $link;
119
+	}
120
+
121
+
122
+	protected function _ajax_hooks()
123
+	{
124
+		// todo: all hooks for registrations ajax goes in here
125
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
+	}
127
+
128
+
129
+	protected function _define_page_props()
130
+	{
131
+		$this->_admin_page_title = $this->page_label;
132
+		$this->_labels = array(
133
+			'buttons'                      => array(
134
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
+				'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
+				'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
+			),
143
+			'publishbox'                   => array(
144
+				'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
+				'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
+			),
147
+			'hide_add_button_on_cpt_route' => array(
148
+				'edit_attendee' => true,
149
+			),
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 *        grab url requests and route them
156
+	 *
157
+	 * @access private
158
+	 * @return void
159
+	 */
160
+	public function _set_page_routes()
161
+	{
162
+		$this->_get_registration_status_array();
163
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
+			? $this->_req_data['_REG_ID'] : 0;
165
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
+			? $this->_req_data['reg_status_change_form']['REG_ID']
167
+			: $reg_id;
168
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
+			? $this->_req_data['ATT_ID'] : 0;
170
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
+			? $this->_req_data['post']
172
+			: $att_id;
173
+		$this->_page_routes = array(
174
+			'default'                             => array(
175
+				'func'       => '_registrations_overview_list_table',
176
+				'capability' => 'ee_read_registrations',
177
+			),
178
+			'view_registration'                   => array(
179
+				'func'       => '_registration_details',
180
+				'capability' => 'ee_read_registration',
181
+				'obj_id'     => $reg_id,
182
+			),
183
+			'edit_registration'                   => array(
184
+				'func'               => '_update_attendee_registration_form',
185
+				'noheader'           => true,
186
+				'headers_sent_route' => 'view_registration',
187
+				'capability'         => 'ee_edit_registration',
188
+				'obj_id'             => $reg_id,
189
+				'_REG_ID'            => $reg_id,
190
+			),
191
+			'trash_registrations'                 => array(
192
+				'func'       => '_trash_or_restore_registrations',
193
+				'args'       => array('trash' => true),
194
+				'noheader'   => true,
195
+				'capability' => 'ee_delete_registrations',
196
+			),
197
+			'restore_registrations'               => array(
198
+				'func'       => '_trash_or_restore_registrations',
199
+				'args'       => array('trash' => false),
200
+				'noheader'   => true,
201
+				'capability' => 'ee_delete_registrations',
202
+			),
203
+			'delete_registrations'                => array(
204
+				'func'       => '_delete_registrations',
205
+				'noheader'   => true,
206
+				'capability' => 'ee_delete_registrations',
207
+			),
208
+			'new_registration'                    => array(
209
+				'func'       => 'new_registration',
210
+				'capability' => 'ee_edit_registrations',
211
+			),
212
+			'process_reg_step'                    => array(
213
+				'func'       => 'process_reg_step',
214
+				'noheader'   => true,
215
+				'capability' => 'ee_edit_registrations',
216
+			),
217
+			'redirect_to_txn'                     => array(
218
+				'func'       => 'redirect_to_txn',
219
+				'noheader'   => true,
220
+				'capability' => 'ee_edit_registrations',
221
+			),
222
+			'change_reg_status'                   => array(
223
+				'func'       => '_change_reg_status',
224
+				'noheader'   => true,
225
+				'capability' => 'ee_edit_registration',
226
+				'obj_id'     => $reg_id,
227
+			),
228
+			'approve_registration'                => array(
229
+				'func'       => 'approve_registration',
230
+				'noheader'   => true,
231
+				'capability' => 'ee_edit_registration',
232
+				'obj_id'     => $reg_id,
233
+			),
234
+			'approve_and_notify_registration'     => array(
235
+				'func'       => 'approve_registration',
236
+				'noheader'   => true,
237
+				'args'       => array(true),
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_registrations'               => array(
242
+				'func'       => 'bulk_action_on_registrations',
243
+				'noheader'   => true,
244
+				'capability' => 'ee_edit_registrations',
245
+				'args'       => array('approve'),
246
+			),
247
+			'approve_and_notify_registrations'    => array(
248
+				'func'       => 'bulk_action_on_registrations',
249
+				'noheader'   => true,
250
+				'capability' => 'ee_edit_registrations',
251
+				'args'       => array('approve', true),
252
+			),
253
+			'decline_registration'                => array(
254
+				'func'       => 'decline_registration',
255
+				'noheader'   => true,
256
+				'capability' => 'ee_edit_registration',
257
+				'obj_id'     => $reg_id,
258
+			),
259
+			'decline_and_notify_registration'     => array(
260
+				'func'       => 'decline_registration',
261
+				'noheader'   => true,
262
+				'args'       => array(true),
263
+				'capability' => 'ee_edit_registration',
264
+				'obj_id'     => $reg_id,
265
+			),
266
+			'decline_registrations'               => array(
267
+				'func'       => 'bulk_action_on_registrations',
268
+				'noheader'   => true,
269
+				'capability' => 'ee_edit_registrations',
270
+				'args'       => array('decline'),
271
+			),
272
+			'decline_and_notify_registrations'    => array(
273
+				'func'       => 'bulk_action_on_registrations',
274
+				'noheader'   => true,
275
+				'capability' => 'ee_edit_registrations',
276
+				'args'       => array('decline', true),
277
+			),
278
+			'pending_registration'                => array(
279
+				'func'       => 'pending_registration',
280
+				'noheader'   => true,
281
+				'capability' => 'ee_edit_registration',
282
+				'obj_id'     => $reg_id,
283
+			),
284
+			'pending_and_notify_registration'     => array(
285
+				'func'       => 'pending_registration',
286
+				'noheader'   => true,
287
+				'args'       => array(true),
288
+				'capability' => 'ee_edit_registration',
289
+				'obj_id'     => $reg_id,
290
+			),
291
+			'pending_registrations'               => array(
292
+				'func'       => 'bulk_action_on_registrations',
293
+				'noheader'   => true,
294
+				'capability' => 'ee_edit_registrations',
295
+				'args'       => array('pending'),
296
+			),
297
+			'pending_and_notify_registrations'    => array(
298
+				'func'       => 'bulk_action_on_registrations',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+				'args'       => array('pending', true),
302
+			),
303
+			'no_approve_registration'             => array(
304
+				'func'       => 'not_approve_registration',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $reg_id,
308
+			),
309
+			'no_approve_and_notify_registration'  => array(
310
+				'func'       => 'not_approve_registration',
311
+				'noheader'   => true,
312
+				'args'       => array(true),
313
+				'capability' => 'ee_edit_registration',
314
+				'obj_id'     => $reg_id,
315
+			),
316
+			'no_approve_registrations'            => array(
317
+				'func'       => 'bulk_action_on_registrations',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_registrations',
320
+				'args'       => array('not_approve'),
321
+			),
322
+			'no_approve_and_notify_registrations' => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('not_approve', true),
327
+			),
328
+			'cancel_registration'                 => array(
329
+				'func'       => 'cancel_registration',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registration',
332
+				'obj_id'     => $reg_id,
333
+			),
334
+			'cancel_and_notify_registration'      => array(
335
+				'func'       => 'cancel_registration',
336
+				'noheader'   => true,
337
+				'args'       => array(true),
338
+				'capability' => 'ee_edit_registration',
339
+				'obj_id'     => $reg_id,
340
+			),
341
+			'cancel_registrations'                => array(
342
+				'func'       => 'bulk_action_on_registrations',
343
+				'noheader'   => true,
344
+				'capability' => 'ee_edit_registrations',
345
+				'args'       => array('cancel'),
346
+			),
347
+			'cancel_and_notify_registrations'     => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('cancel', true),
352
+			),
353
+			'wait_list_registration'              => array(
354
+				'func'       => 'wait_list_registration',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registration',
357
+				'obj_id'     => $reg_id,
358
+			),
359
+			'wait_list_and_notify_registration'   => array(
360
+				'func'       => 'wait_list_registration',
361
+				'noheader'   => true,
362
+				'args'       => array(true),
363
+				'capability' => 'ee_edit_registration',
364
+				'obj_id'     => $reg_id,
365
+			),
366
+			'contact_list'                        => array(
367
+				'func'       => '_attendee_contact_list_table',
368
+				'capability' => 'ee_read_contacts',
369
+			),
370
+			'add_new_attendee'                    => array(
371
+				'func' => '_create_new_cpt_item',
372
+				'args' => array(
373
+					'new_attendee' => true,
374
+					'capability'   => 'ee_edit_contacts',
375
+				),
376
+			),
377
+			'edit_attendee'                       => array(
378
+				'func'       => '_edit_cpt_item',
379
+				'capability' => 'ee_edit_contacts',
380
+				'obj_id'     => $att_id,
381
+			),
382
+			'duplicate_attendee'                  => array(
383
+				'func'       => '_duplicate_attendee',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_contacts',
386
+				'obj_id'     => $att_id,
387
+			),
388
+			'insert_attendee'                     => array(
389
+				'func'       => '_insert_or_update_attendee',
390
+				'args'       => array(
391
+					'new_attendee' => true,
392
+				),
393
+				'noheader'   => true,
394
+				'capability' => 'ee_edit_contacts',
395
+			),
396
+			'update_attendee'                     => array(
397
+				'func'       => '_insert_or_update_attendee',
398
+				'args'       => array(
399
+					'new_attendee' => false,
400
+				),
401
+				'noheader'   => true,
402
+				'capability' => 'ee_edit_contacts',
403
+				'obj_id'     => $att_id,
404
+			),
405
+			'trash_attendees'                     => array(
406
+				'func'       => '_trash_or_restore_attendees',
407
+				'args'       => array(
408
+					'trash' => 'true',
409
+				),
410
+				'noheader'   => true,
411
+				'capability' => 'ee_delete_contacts',
412
+			),
413
+			'trash_attendee'                      => array(
414
+				'func'       => '_trash_or_restore_attendees',
415
+				'args'       => array(
416
+					'trash' => true,
417
+				),
418
+				'noheader'   => true,
419
+				'capability' => 'ee_delete_contacts',
420
+				'obj_id'     => $att_id,
421
+			),
422
+			'restore_attendees'                   => array(
423
+				'func'       => '_trash_or_restore_attendees',
424
+				'args'       => array(
425
+					'trash' => false,
426
+				),
427
+				'noheader'   => true,
428
+				'capability' => 'ee_delete_contacts',
429
+				'obj_id'     => $att_id,
430
+			),
431
+			'resend_registration'                 => array(
432
+				'func'       => '_resend_registration',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_send_message',
435
+			),
436
+			'registrations_report'                => array(
437
+				'func'       => '_registrations_report',
438
+				'noheader'   => true,
439
+				'capability' => 'ee_read_registrations',
440
+			),
441
+			'contact_list_export'                 => array(
442
+				'func'       => '_contact_list_export',
443
+				'noheader'   => true,
444
+				'capability' => 'export',
445
+			),
446
+			'contact_list_report'                 => array(
447
+				'func'       => '_contact_list_report',
448
+				'noheader'   => true,
449
+				'capability' => 'ee_read_contacts',
450
+			),
451
+		);
452
+	}
453
+
454
+
455
+	protected function _set_page_config()
456
+	{
457
+		$this->_page_config = array(
458
+			'default'           => array(
459
+				'nav'           => array(
460
+					'label' => esc_html__('Overview', 'event_espresso'),
461
+					'order' => 5,
462
+				),
463
+				'help_tabs'     => array(
464
+					'registrations_overview_help_tab'                       => array(
465
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
+						'filename' => 'registrations_overview',
467
+					),
468
+					'registrations_overview_table_column_headings_help_tab' => array(
469
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
+						'filename' => 'registrations_overview_table_column_headings',
471
+					),
472
+					'registrations_overview_filters_help_tab'               => array(
473
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
+						'filename' => 'registrations_overview_filters',
475
+					),
476
+					'registrations_overview_views_help_tab'                 => array(
477
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
478
+						'filename' => 'registrations_overview_views',
479
+					),
480
+					'registrations_regoverview_other_help_tab'              => array(
481
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
+						'filename' => 'registrations_overview_other',
483
+					),
484
+				),
485
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
486
+				'qtips'         => array('Registration_List_Table_Tips'),
487
+				'list_table'    => 'EE_Registrations_List_Table',
488
+				'require_nonce' => false,
489
+			),
490
+			'view_registration' => array(
491
+				'nav'           => array(
492
+					'label'      => esc_html__('REG Details', 'event_espresso'),
493
+					'order'      => 15,
494
+					'url'        => isset($this->_req_data['_REG_ID'])
495
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
+						: $this->_admin_base_url,
497
+					'persistent' => false,
498
+				),
499
+				'help_tabs'     => array(
500
+					'registrations_details_help_tab'                    => array(
501
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
502
+						'filename' => 'registrations_details',
503
+					),
504
+					'registrations_details_table_help_tab'              => array(
505
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
+						'filename' => 'registrations_details_table',
507
+					),
508
+					'registrations_details_form_answers_help_tab'       => array(
509
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
+						'filename' => 'registrations_details_form_answers',
511
+					),
512
+					'registrations_details_registrant_details_help_tab' => array(
513
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
514
+						'filename' => 'registrations_details_registrant_details',
515
+					),
516
+				),
517
+				'help_tour'     => array('Registration_Details_Help_Tour'),
518
+				'metaboxes'     => array_merge(
519
+					$this->_default_espresso_metaboxes,
520
+					array('_registration_details_metaboxes')
521
+				),
522
+				'require_nonce' => false,
523
+			),
524
+			'new_registration'  => array(
525
+				'nav'           => array(
526
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
+					'url'        => '#',
528
+					'order'      => 15,
529
+					'persistent' => false,
530
+				),
531
+				'metaboxes'     => $this->_default_espresso_metaboxes,
532
+				'labels'        => array(
533
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
+				),
535
+				'require_nonce' => false,
536
+			),
537
+			'add_new_attendee'  => array(
538
+				'nav'           => array(
539
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
540
+					'order'      => 15,
541
+					'persistent' => false,
542
+				),
543
+				'metaboxes'     => array_merge(
544
+					$this->_default_espresso_metaboxes,
545
+					array('_publish_post_box', 'attendee_editor_metaboxes')
546
+				),
547
+				'require_nonce' => false,
548
+			),
549
+			'edit_attendee'     => array(
550
+				'nav'           => array(
551
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
+					'order'      => 15,
553
+					'persistent' => false,
554
+					'url'        => isset($this->_req_data['ATT_ID'])
555
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
+						: $this->_admin_base_url,
557
+				),
558
+				'metaboxes'     => array('attendee_editor_metaboxes'),
559
+				'require_nonce' => false,
560
+			),
561
+			'contact_list'      => array(
562
+				'nav'           => array(
563
+					'label' => esc_html__('Contact List', 'event_espresso'),
564
+					'order' => 20,
565
+				),
566
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
567
+				'help_tabs'     => array(
568
+					'registrations_contact_list_help_tab'                       => array(
569
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
+						'filename' => 'registrations_contact_list',
571
+					),
572
+					'registrations_contact-list_table_column_headings_help_tab' => array(
573
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
+						'filename' => 'registrations_contact_list_table_column_headings',
575
+					),
576
+					'registrations_contact_list_views_help_tab'                 => array(
577
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
+						'filename' => 'registrations_contact_list_views',
579
+					),
580
+					'registrations_contact_list_other_help_tab'                 => array(
581
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
+						'filename' => 'registrations_contact_list_other',
583
+					),
584
+				),
585
+				'help_tour'     => array('Contact_List_Help_Tour'),
586
+				'metaboxes'     => array(),
587
+				'require_nonce' => false,
588
+			),
589
+			// override default cpt routes
590
+			'create_new'        => '',
591
+			'edit'              => '',
592
+		);
593
+	}
594
+
595
+
596
+	/**
597
+	 * The below methods aren't used by this class currently
598
+	 */
599
+	protected function _add_screen_options()
600
+	{
601
+	}
602
+
603
+
604
+	protected function _add_feature_pointers()
605
+	{
606
+	}
607
+
608
+
609
+	public function admin_init()
610
+	{
611
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
+			'click "Update Registration Questions" to save your changes',
613
+			'event_espresso'
614
+		);
615
+	}
616
+
617
+
618
+	public function admin_notices()
619
+	{
620
+	}
621
+
622
+
623
+	public function admin_footer_scripts()
624
+	{
625
+	}
626
+
627
+
628
+	/**
629
+	 *        get list of registration statuses
630
+	 *
631
+	 * @access private
632
+	 * @return void
633
+	 * @throws EE_Error
634
+	 */
635
+	private function _get_registration_status_array()
636
+	{
637
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
+	}
639
+
640
+
641
+	protected function _add_screen_options_default()
642
+	{
643
+		$this->_per_page_screen_option();
644
+	}
645
+
646
+
647
+	protected function _add_screen_options_contact_list()
648
+	{
649
+		$page_title = $this->_admin_page_title;
650
+		$this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
+		$this->_per_page_screen_option();
652
+		$this->_admin_page_title = $page_title;
653
+	}
654
+
655
+
656
+	public function load_scripts_styles()
657
+	{
658
+		// style
659
+		wp_register_style(
660
+			'espresso_reg',
661
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
+			array('ee-admin-css'),
663
+			EVENT_ESPRESSO_VERSION
664
+		);
665
+		wp_enqueue_style('espresso_reg');
666
+		// script
667
+		wp_register_script(
668
+			'espresso_reg',
669
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
+			EVENT_ESPRESSO_VERSION,
672
+			true
673
+		);
674
+		wp_enqueue_script('espresso_reg');
675
+	}
676
+
677
+
678
+	public function load_scripts_styles_edit_attendee()
679
+	{
680
+		// stuff to only show up on our attendee edit details page.
681
+		$attendee_details_translations = array(
682
+			'att_publish_text' => sprintf(
683
+				esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
+				$this->_cpt_model_obj->get_datetime('ATT_created')
685
+			),
686
+		);
687
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
+		wp_enqueue_script('jquery-validate');
689
+	}
690
+
691
+
692
+	public function load_scripts_styles_view_registration()
693
+	{
694
+		// styles
695
+		wp_enqueue_style('espresso-ui-theme');
696
+		// scripts
697
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
698
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
+	}
700
+
701
+
702
+	public function load_scripts_styles_contact_list()
703
+	{
704
+		wp_dequeue_style('espresso_reg');
705
+		wp_register_style(
706
+			'espresso_att',
707
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
+			array('ee-admin-css'),
709
+			EVENT_ESPRESSO_VERSION
710
+		);
711
+		wp_enqueue_style('espresso_att');
712
+	}
713
+
714
+
715
+	public function load_scripts_styles_new_registration()
716
+	{
717
+		wp_register_script(
718
+			'ee-spco-for-admin',
719
+			REG_ASSETS_URL . 'spco_for_admin.js',
720
+			array('underscore', 'jquery'),
721
+			EVENT_ESPRESSO_VERSION,
722
+			true
723
+		);
724
+		wp_enqueue_script('ee-spco-for-admin');
725
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
+		EE_Form_Section_Proper::wp_enqueue_scripts();
727
+		EED_Ticket_Selector::load_tckt_slctr_assets();
728
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
729
+	}
730
+
731
+
732
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
+	{
734
+		add_filter('FHEE_load_EE_messages', '__return_true');
735
+	}
736
+
737
+
738
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
+	{
740
+		add_filter('FHEE_load_EE_messages', '__return_true');
741
+	}
742
+
743
+
744
+	protected function _set_list_table_views_default()
745
+	{
746
+		// for notification related bulk actions we need to make sure only active messengers have an option.
747
+		EED_Messages::set_autoloaders();
748
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
749
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
+		$active_mts = $message_resource_manager->list_of_active_message_types();
751
+		// key= bulk_action_slug, value= message type.
752
+		$match_array = array(
753
+			'approve_registrations'    => 'registration',
754
+			'decline_registrations'    => 'declined_registration',
755
+			'pending_registrations'    => 'pending_approval',
756
+			'no_approve_registrations' => 'not_approved_registration',
757
+			'cancel_registrations'     => 'cancelled_registration',
758
+		);
759
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
760
+			'ee_send_message',
761
+			'batch_send_messages'
762
+		);
763
+		/** setup reg status bulk actions **/
764
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
+				'Approve and Notify Registrations',
768
+				'event_espresso'
769
+			);
770
+		}
771
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
+				'Decline and Notify Registrations',
775
+				'event_espresso'
776
+			);
777
+		}
778
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
779
+			'Set Registrations to Pending Payment',
780
+			'event_espresso'
781
+		);
782
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
+				'Set Registrations to Pending Payment and Notify',
785
+				'event_espresso'
786
+			);
787
+		}
788
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
+			'Set Registrations to Not Approved',
790
+			'event_espresso'
791
+		);
792
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
+				'Set Registrations to Not Approved and Notify',
795
+				'event_espresso'
796
+			);
797
+		}
798
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
+				'Cancel Registrations and Notify',
802
+				'event_espresso'
803
+			);
804
+		}
805
+		$def_reg_status_actions = apply_filters(
806
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
+			$def_reg_status_actions,
808
+			$active_mts,
809
+			$can_send
810
+		);
811
+
812
+		$this->_views = array(
813
+			'all'   => array(
814
+				'slug'        => 'all',
815
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
+				'count'       => 0,
817
+				'bulk_action' => array_merge(
818
+					$def_reg_status_actions,
819
+					array(
820
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
+					)
822
+				),
823
+			),
824
+			'month' => array(
825
+				'slug'        => 'month',
826
+				'label'       => esc_html__('This Month', 'event_espresso'),
827
+				'count'       => 0,
828
+				'bulk_action' => array_merge(
829
+					$def_reg_status_actions,
830
+					array(
831
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
+					)
833
+				),
834
+			),
835
+			'today' => array(
836
+				'slug'        => 'today',
837
+				'label'       => sprintf(
838
+					esc_html__('Today - %s', 'event_espresso'),
839
+					date('M d, Y', current_time('timestamp'))
840
+				),
841
+				'count'       => 0,
842
+				'bulk_action' => array_merge(
843
+					$def_reg_status_actions,
844
+					array(
845
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
+					)
847
+				),
848
+			),
849
+		);
850
+		if (EE_Registry::instance()->CAP->current_user_can(
851
+			'ee_delete_registrations',
852
+			'espresso_registrations_delete_registration'
853
+		)) {
854
+			$this->_views['incomplete'] = array(
855
+				'slug'        => 'incomplete',
856
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
857
+				'count'       => 0,
858
+				'bulk_action' => array(
859
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
+				),
861
+			);
862
+			$this->_views['trash'] = array(
863
+				'slug'        => 'trash',
864
+				'label'       => esc_html__('Trash', 'event_espresso'),
865
+				'count'       => 0,
866
+				'bulk_action' => array(
867
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
+				),
870
+			);
871
+		}
872
+	}
873
+
874
+
875
+	protected function _set_list_table_views_contact_list()
876
+	{
877
+		$this->_views = array(
878
+			'in_use' => array(
879
+				'slug'        => 'in_use',
880
+				'label'       => esc_html__('In Use', 'event_espresso'),
881
+				'count'       => 0,
882
+				'bulk_action' => array(
883
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
+				),
885
+			),
886
+		);
887
+		if (EE_Registry::instance()->CAP->current_user_can(
888
+			'ee_delete_contacts',
889
+			'espresso_registrations_trash_attendees'
890
+		)
891
+		) {
892
+			$this->_views['trash'] = array(
893
+				'slug'        => 'trash',
894
+				'label'       => esc_html__('Trash', 'event_espresso'),
895
+				'count'       => 0,
896
+				'bulk_action' => array(
897
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
+				),
899
+			);
900
+		}
901
+	}
902
+
903
+
904
+	protected function _registration_legend_items()
905
+	{
906
+		$fc_items = array(
907
+			'star-icon'        => array(
908
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
+			),
911
+			'view_details'     => array(
912
+				'class' => 'dashicons dashicons-clipboard',
913
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
+			),
915
+			'edit_attendee'    => array(
916
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
+			),
919
+			'view_transaction' => array(
920
+				'class' => 'dashicons dashicons-cart',
921
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
+			),
923
+			'view_invoice'     => array(
924
+				'class' => 'dashicons dashicons-media-spreadsheet',
925
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
+			),
927
+		);
928
+		if (EE_Registry::instance()->CAP->current_user_can(
929
+			'ee_send_message',
930
+			'espresso_registrations_resend_registration'
931
+		)) {
932
+			$fc_items['resend_registration'] = array(
933
+				'class' => 'dashicons dashicons-email-alt',
934
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
+			);
936
+		} else {
937
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
+		}
939
+		if (EE_Registry::instance()->CAP->current_user_can(
940
+			'ee_read_global_messages',
941
+			'view_filtered_messages'
942
+		)) {
943
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
+				$fc_items['view_related_messages'] = array(
946
+					'class' => $related_for_icon['css_class'],
947
+					'desc'  => $related_for_icon['label'],
948
+				);
949
+			}
950
+		}
951
+		$sc_items = array(
952
+			'approved_status'   => array(
953
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
+				'desc'  => EEH_Template::pretty_status(
955
+					EEM_Registration::status_id_approved,
956
+					false,
957
+					'sentence'
958
+				),
959
+			),
960
+			'pending_status'    => array(
961
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
+				'desc'  => EEH_Template::pretty_status(
963
+					EEM_Registration::status_id_pending_payment,
964
+					false,
965
+					'sentence'
966
+				),
967
+			),
968
+			'wait_list'         => array(
969
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
+				'desc'  => EEH_Template::pretty_status(
971
+					EEM_Registration::status_id_wait_list,
972
+					false,
973
+					'sentence'
974
+				),
975
+			),
976
+			'incomplete_status' => array(
977
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
+				'desc'  => EEH_Template::pretty_status(
979
+					EEM_Registration::status_id_incomplete,
980
+					false,
981
+					'sentence'
982
+				),
983
+			),
984
+			'not_approved'      => array(
985
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
+				'desc'  => EEH_Template::pretty_status(
987
+					EEM_Registration::status_id_not_approved,
988
+					false,
989
+					'sentence'
990
+				),
991
+			),
992
+			'declined_status'   => array(
993
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
+				'desc'  => EEH_Template::pretty_status(
995
+					EEM_Registration::status_id_declined,
996
+					false,
997
+					'sentence'
998
+				),
999
+			),
1000
+			'cancelled_status'  => array(
1001
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
+				'desc'  => EEH_Template::pretty_status(
1003
+					EEM_Registration::status_id_cancelled,
1004
+					false,
1005
+					'sentence'
1006
+				),
1007
+			),
1008
+		);
1009
+		return array_merge($fc_items, $sc_items);
1010
+	}
1011
+
1012
+
1013
+
1014
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1015
+	/**
1016
+	 * @throws \EE_Error
1017
+	 */
1018
+	protected function _registrations_overview_list_table()
1019
+	{
1020
+		$this->_template_args['admin_page_header'] = '';
1021
+		$EVT_ID = ! empty($this->_req_data['event_id'])
1022
+			? absint($this->_req_data['event_id'])
1023
+			: 0;
1024
+		$ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
+			? absint($this->_req_data['ATT_ID'])
1026
+			: 0;
1027
+		if ($ATT_ID) {
1028
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
+			if ($attendee instanceof EE_Attendee) {
1030
+				$this->_template_args['admin_page_header'] = sprintf(
1031
+					esc_html__(
1032
+						'%1$s Viewing registrations for %2$s%3$s',
1033
+						'event_espresso'
1034
+					),
1035
+					'<h3 style="line-height:1.5em;">',
1036
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
+						array(
1038
+							'action' => 'edit_attendee',
1039
+							'post'   => $ATT_ID,
1040
+						),
1041
+						REG_ADMIN_URL
1042
+					) . '">' . $attendee->full_name() . '</a>',
1043
+					'</h3>'
1044
+				);
1045
+			}
1046
+		}
1047
+		if ($EVT_ID) {
1048
+			if (EE_Registry::instance()->CAP->current_user_can(
1049
+				'ee_edit_registrations',
1050
+				'espresso_registrations_new_registration',
1051
+				$EVT_ID
1052
+			)) {
1053
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
+					'new_registration',
1055
+					'add-registrant',
1056
+					array('event_id' => $EVT_ID),
1057
+					'add-new-h2'
1058
+				);
1059
+			}
1060
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
+			if ($event instanceof EE_Event) {
1062
+				$this->_template_args['admin_page_header'] = sprintf(
1063
+					esc_html__(
1064
+						'%s Viewing registrations for the event: %s%s',
1065
+						'event_espresso'
1066
+					),
1067
+					'<h3 style="line-height:1.5em;">',
1068
+					'<br /><a href="'
1069
+					. EE_Admin_Page::add_query_args_and_nonce(
1070
+						array(
1071
+							'action' => 'edit',
1072
+							'post'   => $event->ID(),
1073
+						),
1074
+						EVENTS_ADMIN_URL
1075
+					)
1076
+					. '">&nbsp;'
1077
+					. $event->get('EVT_name')
1078
+					. '&nbsp;</a>&nbsp;',
1079
+					'</h3>'
1080
+				);
1081
+			}
1082
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
+				$this->_template_args['admin_page_header'] = substr(
1086
+					$this->_template_args['admin_page_header'],
1087
+					0,
1088
+					-5
1089
+				);
1090
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
+				$this->_template_args['admin_page_header'] .= $datetime->name();
1093
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
1095
+			}
1096
+		}
1097
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
+		$this->display_admin_list_table_page_with_no_sidebar();
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * This sets the _registration property for the registration details screen
1104
+	 *
1105
+	 * @access private
1106
+	 * @return bool
1107
+	 * @throws EE_Error
1108
+	 * @throws InvalidArgumentException
1109
+	 * @throws InvalidDataTypeException
1110
+	 * @throws InvalidInterfaceException
1111
+	 */
1112
+	private function _set_registration_object()
1113
+	{
1114
+		// get out if we've already set the object
1115
+		if ($this->_registration instanceof EE_Registration) {
1116
+			return true;
1117
+		}
1118
+		$REG = EEM_Registration::instance();
1119
+		$REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
+			return true;
1122
+		} else {
1123
+			$error_msg = sprintf(
1124
+				esc_html__(
1125
+					'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
+					'event_espresso'
1127
+				),
1128
+				$REG_ID
1129
+			);
1130
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
+			$this->_registration = null;
1132
+			return false;
1133
+		}
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * Used to retrieve registrations for the list table.
1139
+	 *
1140
+	 * @param int  $per_page
1141
+	 * @param bool $count
1142
+	 * @param bool $this_month
1143
+	 * @param bool $today
1144
+	 * @return EE_Registration[]|int
1145
+	 * @throws EE_Error
1146
+	 * @throws InvalidArgumentException
1147
+	 * @throws InvalidDataTypeException
1148
+	 * @throws InvalidInterfaceException
1149
+	 */
1150
+	public function get_registrations(
1151
+		$per_page = 10,
1152
+		$count = false,
1153
+		$this_month = false,
1154
+		$today = false
1155
+	) {
1156
+		if ($this_month) {
1157
+			$this->_req_data['status'] = 'month';
1158
+		}
1159
+		if ($today) {
1160
+			$this->_req_data['status'] = 'today';
1161
+		}
1162
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
+		/**
1164
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
+		 *
1166
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
+		 * @see  EEM_Base::get_all()
1168
+		 */
1169
+		$query_params['group_by'] = '';
1170
+
1171
+		return $count
1172
+			? EEM_Registration::instance()->count($query_params)
1173
+			/** @type EE_Registration[] */
1174
+			: EEM_Registration::instance()->get_all($query_params);
1175
+	}
1176
+
1177
+
1178
+	/**
1179
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
+	 * Note: this listens to values on the request for some of the query parameters.
1181
+	 *
1182
+	 * @param array $request
1183
+	 * @param int   $per_page
1184
+	 * @param bool  $count
1185
+	 * @return array
1186
+	 * @throws EE_Error
1187
+	 */
1188
+	protected function _get_registration_query_parameters(
1189
+		$request = array(),
1190
+		$per_page = 10,
1191
+		$count = false
1192
+	) {
1193
+
1194
+		$query_params = array(
1195
+			0                          => $this->_get_where_conditions_for_registrations_query(
1196
+				$request
1197
+			),
1198
+			'caps'                     => EEM_Registration::caps_read_admin,
1199
+			'default_where_conditions' => 'this_model_only',
1200
+		);
1201
+		if (! $count) {
1202
+			$query_params = array_merge(
1203
+				$query_params,
1204
+				$this->_get_orderby_for_registrations_query(),
1205
+				$this->_get_limit($per_page)
1206
+			);
1207
+		}
1208
+
1209
+		return $query_params;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
+	 *
1216
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1217
+	 * @return array
1218
+	 */
1219
+	protected function addAttendeeIdToWhereConditions(array $request)
1220
+	{
1221
+		$where = array();
1222
+		if (! empty($request['ATT_ID'])) {
1223
+			$where['ATT_ID'] = absint($request['ATT_ID']);
1224
+		}
1225
+		return $where;
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
+	 *
1232
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1233
+	 * @return array
1234
+	 */
1235
+	protected function _add_event_id_to_where_conditions(array $request)
1236
+	{
1237
+		$where = array();
1238
+		if (! empty($request['event_id'])) {
1239
+			$where['EVT_ID'] = absint($request['event_id']);
1240
+		}
1241
+		return $where;
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
+	 *
1248
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1249
+	 * @return array
1250
+	 */
1251
+	protected function _add_category_id_to_where_conditions(array $request)
1252
+	{
1253
+		$where = array();
1254
+		if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
+			$where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
+		}
1257
+		return $where;
1258
+	}
1259
+
1260
+
1261
+	/**
1262
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
+	 *
1264
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1265
+	 * @return array
1266
+	 */
1267
+	protected function _add_datetime_id_to_where_conditions(array $request)
1268
+	{
1269
+		$where = array();
1270
+		if (! empty($request['datetime_id'])) {
1271
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
+		}
1273
+		if (! empty($request['DTT_ID'])) {
1274
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
+		}
1276
+		return $where;
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 * Adds the correct registration status to the where conditions for the registrations query.
1282
+	 *
1283
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1284
+	 * @return array
1285
+	 */
1286
+	protected function _add_registration_status_to_where_conditions(array $request)
1287
+	{
1288
+		$where = array();
1289
+		$view = EEH_Array::is_set($request, 'status', '');
1290
+		$registration_status = ! empty($request['_reg_status'])
1291
+			? sanitize_text_field($request['_reg_status'])
1292
+			: '';
1293
+
1294
+		/*
1295 1295
          * If filtering by registration status, then we show registrations matching that status.
1296 1296
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1297 1297
          * UNLESS viewing trashed registrations.
1298 1298
          */
1299
-        if (! empty($registration_status)) {
1300
-            $where['STS_ID'] = $registration_status;
1301
-        } else {
1302
-            // make sure we exclude incomplete registrations, but only if not trashed.
1303
-            if ($view === 'trash') {
1304
-                $where['REG_deleted'] = true;
1305
-            } elseif ($view === 'incomplete') {
1306
-                $where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
-            } else {
1308
-                $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
-            }
1310
-        }
1311
-        return $where;
1312
-    }
1313
-
1314
-
1315
-    /**
1316
-     * Adds any provided date restraints to the where conditions for the registrations query.
1317
-     *
1318
-     * @param array $request usually the same as $this->_req_data but not necessarily
1319
-     * @return array
1320
-     * @throws EE_Error
1321
-     * @throws InvalidArgumentException
1322
-     * @throws InvalidDataTypeException
1323
-     * @throws InvalidInterfaceException
1324
-     */
1325
-    protected function _add_date_to_where_conditions(array $request)
1326
-    {
1327
-        $where = array();
1328
-        $view = EEH_Array::is_set($request, 'status', '');
1329
-        $month_range = ! empty($request['month_range'])
1330
-            ? sanitize_text_field($request['month_range'])
1331
-            : '';
1332
-        $retrieve_for_today = $view === 'today';
1333
-        $retrieve_for_this_month = $view === 'month';
1334
-
1335
-        if ($retrieve_for_today) {
1336
-            $now = date('Y-m-d', current_time('timestamp'));
1337
-            $where['REG_date'] = array(
1338
-                'BETWEEN',
1339
-                array(
1340
-                    EEM_Registration::instance()->convert_datetime_for_query(
1341
-                        'REG_date',
1342
-                        $now . ' 00:00:00',
1343
-                        'Y-m-d H:i:s'
1344
-                    ),
1345
-                    EEM_Registration::instance()->convert_datetime_for_query(
1346
-                        'REG_date',
1347
-                        $now . ' 23:59:59',
1348
-                        'Y-m-d H:i:s'
1349
-                    ),
1350
-                ),
1351
-            );
1352
-        } elseif ($retrieve_for_this_month) {
1353
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
1354
-            $days_this_month = date('t', current_time('timestamp'));
1355
-            $where['REG_date'] = array(
1356
-                'BETWEEN',
1357
-                array(
1358
-                    EEM_Registration::instance()->convert_datetime_for_query(
1359
-                        'REG_date',
1360
-                        $current_year_and_month . '-01 00:00:00',
1361
-                        'Y-m-d H:i:s'
1362
-                    ),
1363
-                    EEM_Registration::instance()->convert_datetime_for_query(
1364
-                        'REG_date',
1365
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
-                        'Y-m-d H:i:s'
1367
-                    ),
1368
-                ),
1369
-            );
1370
-        } elseif ($month_range) {
1371
-            $pieces = explode(' ', $month_range, 3);
1372
-            $month_requested = ! empty($pieces[0])
1373
-                ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
-                : '';
1375
-            $year_requested = ! empty($pieces[1])
1376
-                ? $pieces[1]
1377
-                : '';
1378
-            // if there is not a month or year then we can't go further
1379
-            if ($month_requested && $year_requested) {
1380
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
-                $where['REG_date'] = array(
1382
-                    'BETWEEN',
1383
-                    array(
1384
-                        EEM_Registration::instance()->convert_datetime_for_query(
1385
-                            'REG_date',
1386
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1387
-                            'Y-m-d H:i:s'
1388
-                        ),
1389
-                        EEM_Registration::instance()->convert_datetime_for_query(
1390
-                            'REG_date',
1391
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
-                            'Y-m-d H:i:s'
1393
-                        ),
1394
-                    ),
1395
-                );
1396
-            }
1397
-        }
1398
-        return $where;
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * Adds any provided search restraints to the where conditions for the registrations query
1404
-     *
1405
-     * @param array $request usually the same as $this->_req_data but not necessarily
1406
-     * @return array
1407
-     */
1408
-    protected function _add_search_to_where_conditions(array $request)
1409
-    {
1410
-        $where = array();
1411
-        if (! empty($request['s'])) {
1412
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
-            $where['OR*search_conditions'] = array(
1414
-                'Event.EVT_name'                          => array('LIKE', $search_string),
1415
-                'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
-                'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
-                'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
-                'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
-                'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
-                'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
-                'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
-                'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
-                'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
-                'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
-                'REG_final_price'                         => array('LIKE', $search_string),
1426
-                'REG_code'                                => array('LIKE', $search_string),
1427
-                'REG_count'                               => array('LIKE', $search_string),
1428
-                'REG_group_size'                          => array('LIKE', $search_string),
1429
-                'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
-                'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
-            );
1433
-        }
1434
-        return $where;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * Sets up the where conditions for the registrations query.
1440
-     *
1441
-     * @param array $request
1442
-     * @return array
1443
-     * @throws EE_Error
1444
-     */
1445
-    protected function _get_where_conditions_for_registrations_query($request)
1446
-    {
1447
-        return apply_filters(
1448
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
-            array_merge(
1450
-                $this->addAttendeeIdToWhereConditions($request),
1451
-                $this->_add_event_id_to_where_conditions($request),
1452
-                $this->_add_category_id_to_where_conditions($request),
1453
-                $this->_add_datetime_id_to_where_conditions($request),
1454
-                $this->_add_registration_status_to_where_conditions($request),
1455
-                $this->_add_date_to_where_conditions($request),
1456
-                $this->_add_search_to_where_conditions($request)
1457
-            ),
1458
-            $request
1459
-        );
1460
-    }
1461
-
1462
-
1463
-    /**
1464
-     * Sets up the orderby for the registrations query.
1465
-     *
1466
-     * @return array
1467
-     */
1468
-    protected function _get_orderby_for_registrations_query()
1469
-    {
1470
-        $orderby_field = ! empty($this->_req_data['orderby'])
1471
-            ? sanitize_text_field($this->_req_data['orderby'])
1472
-            : '_REG_date';
1473
-        switch ($orderby_field) {
1474
-            case '_REG_ID':
1475
-                $orderby = array('REG_ID');
1476
-                break;
1477
-            case '_Reg_status':
1478
-                $orderby = array('STS_ID');
1479
-                break;
1480
-            case 'ATT_fname':
1481
-                $orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
-                break;
1483
-            case 'ATT_lname':
1484
-                $orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
-                break;
1486
-            case 'event_name':
1487
-                $orderby = array('Event.EVT_name');
1488
-                break;
1489
-            case 'DTT_EVT_start':
1490
-                $orderby = array('Event.Datetime.DTT_EVT_start');
1491
-                break;
1492
-            case '_REG_date':
1493
-                $orderby = array('REG_date');
1494
-                break;
1495
-            default:
1496
-                $orderby = array($orderby_field);
1497
-                break;
1498
-        }
1499
-
1500
-        // order
1501
-        $order = ! empty($this->_req_data['order'])
1502
-            ? sanitize_text_field($this->_req_data['order'])
1503
-            : 'DESC';
1504
-        $orderby = array_combine(
1505
-            $orderby,
1506
-            array_fill(0, count($orderby), $order)
1507
-        );
1508
-        // because there are many registrations with the same date, define
1509
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
1510
-        if (empty($orderby['REG_ID'])) {
1511
-            $orderby['REG_ID'] = $order;
1512
-        }
1513
-
1514
-        $orderby = apply_filters(
1515
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
-            $orderby,
1517
-            $this->_req_data
1518
-        );
1519
-
1520
-        return array('order_by' => $orderby);
1521
-    }
1522
-
1523
-
1524
-    /**
1525
-     * Sets up the limit for the registrations query.
1526
-     *
1527
-     * @param $per_page
1528
-     * @return array
1529
-     */
1530
-    protected function _get_limit($per_page)
1531
-    {
1532
-        $current_page = ! empty($this->_req_data['paged'])
1533
-            ? absint($this->_req_data['paged'])
1534
-            : 1;
1535
-        $per_page = ! empty($this->_req_data['perpage'])
1536
-            ? $this->_req_data['perpage']
1537
-            : $per_page;
1538
-
1539
-        // -1 means return all results so get out if that's set.
1540
-        if ((int) $per_page === -1) {
1541
-            return array();
1542
-        }
1543
-        $per_page = absint($per_page);
1544
-        $offset = ($current_page - 1) * $per_page;
1545
-        return array('limit' => array($offset, $per_page));
1546
-    }
1547
-
1548
-
1549
-    public function get_registration_status_array()
1550
-    {
1551
-        return self::$_reg_status;
1552
-    }
1553
-
1554
-
1555
-
1556
-
1557
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1558
-    /**
1559
-     *        generates HTML for the View Registration Details Admin page
1560
-     *
1561
-     * @access protected
1562
-     * @return void
1563
-     * @throws DomainException
1564
-     * @throws EE_Error
1565
-     * @throws InvalidArgumentException
1566
-     * @throws InvalidDataTypeException
1567
-     * @throws InvalidInterfaceException
1568
-     * @throws EntityNotFoundException
1569
-     */
1570
-    protected function _registration_details()
1571
-    {
1572
-        $this->_template_args = array();
1573
-        $this->_set_registration_object();
1574
-        if (is_object($this->_registration)) {
1575
-            $transaction = $this->_registration->transaction()
1576
-                ? $this->_registration->transaction()
1577
-                : EE_Transaction::new_instance();
1578
-            $this->_session = $transaction->session_data();
1579
-            $event_id = $this->_registration->event_ID();
1580
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
-            $this->_template_args['grand_total'] = $transaction->total();
1585
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
-            // link back to overview
1587
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
-            $this->_template_args['registration'] = $this->_registration;
1589
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
-                array(
1591
-                    'action'   => 'default',
1592
-                    'event_id' => $event_id,
1593
-                ),
1594
-                REG_ADMIN_URL
1595
-            );
1596
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
-                array(
1598
-                    'action' => 'default',
1599
-                    'EVT_ID' => $event_id,
1600
-                    'page'   => 'espresso_transactions',
1601
-                ),
1602
-                admin_url('admin.php')
1603
-            );
1604
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
-                array(
1606
-                    'page'   => 'espresso_events',
1607
-                    'action' => 'edit',
1608
-                    'post'   => $event_id,
1609
-                ),
1610
-                admin_url('admin.php')
1611
-            );
1612
-            // next and previous links
1613
-            $next_reg = $this->_registration->next(
1614
-                null,
1615
-                array(),
1616
-                'REG_ID'
1617
-            );
1618
-            $this->_template_args['next_registration'] = $next_reg
1619
-                ? $this->_next_link(
1620
-                    EE_Admin_Page::add_query_args_and_nonce(
1621
-                        array(
1622
-                            'action'  => 'view_registration',
1623
-                            '_REG_ID' => $next_reg['REG_ID'],
1624
-                        ),
1625
-                        REG_ADMIN_URL
1626
-                    ),
1627
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1628
-                )
1629
-                : '';
1630
-            $previous_reg = $this->_registration->previous(
1631
-                null,
1632
-                array(),
1633
-                'REG_ID'
1634
-            );
1635
-            $this->_template_args['previous_registration'] = $previous_reg
1636
-                ? $this->_previous_link(
1637
-                    EE_Admin_Page::add_query_args_and_nonce(
1638
-                        array(
1639
-                            'action'  => 'view_registration',
1640
-                            '_REG_ID' => $previous_reg['REG_ID'],
1641
-                        ),
1642
-                        REG_ADMIN_URL
1643
-                    ),
1644
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1645
-                )
1646
-                : '';
1647
-            // grab header
1648
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1650
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
-                $template_path,
1652
-                $this->_template_args,
1653
-                true
1654
-            );
1655
-        } else {
1656
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
-        }
1658
-        // the details template wrapper
1659
-        $this->display_admin_page_with_sidebar();
1660
-    }
1661
-
1662
-
1663
-    protected function _registration_details_metaboxes()
1664
-    {
1665
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
-        $this->_set_registration_object();
1667
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
-        add_meta_box(
1669
-            'edit-reg-status-mbox',
1670
-            esc_html__('Registration Status', 'event_espresso'),
1671
-            array($this, 'set_reg_status_buttons_metabox'),
1672
-            $this->wp_page_slug,
1673
-            'normal',
1674
-            'high'
1675
-        );
1676
-        add_meta_box(
1677
-            'edit-reg-details-mbox',
1678
-            esc_html__('Registration Details', 'event_espresso'),
1679
-            array($this, '_reg_details_meta_box'),
1680
-            $this->wp_page_slug,
1681
-            'normal',
1682
-            'high'
1683
-        );
1684
-        if ($attendee instanceof EE_Attendee
1685
-            && EE_Registry::instance()->CAP->current_user_can(
1686
-                'ee_read_registration',
1687
-                'edit-reg-questions-mbox',
1688
-                $this->_registration->ID()
1689
-            )
1690
-        ) {
1691
-            add_meta_box(
1692
-                'edit-reg-questions-mbox',
1693
-                esc_html__('Registration Form Answers', 'event_espresso'),
1694
-                array($this, '_reg_questions_meta_box'),
1695
-                $this->wp_page_slug,
1696
-                'normal',
1697
-                'high'
1698
-            );
1699
-        }
1700
-        add_meta_box(
1701
-            'edit-reg-registrant-mbox',
1702
-            esc_html__('Contact Details', 'event_espresso'),
1703
-            array($this, '_reg_registrant_side_meta_box'),
1704
-            $this->wp_page_slug,
1705
-            'side',
1706
-            'high'
1707
-        );
1708
-        if ($this->_registration->group_size() > 1) {
1709
-            add_meta_box(
1710
-                'edit-reg-attendees-mbox',
1711
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
-                array($this, '_reg_attendees_meta_box'),
1713
-                $this->wp_page_slug,
1714
-                'normal',
1715
-                'high'
1716
-            );
1717
-        }
1718
-    }
1719
-
1720
-
1721
-    /**
1722
-     * set_reg_status_buttons_metabox
1723
-     *
1724
-     * @access protected
1725
-     * @return string
1726
-     * @throws \EE_Error
1727
-     */
1728
-    public function set_reg_status_buttons_metabox()
1729
-    {
1730
-        $this->_set_registration_object();
1731
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1732
-        echo $change_reg_status_form->form_open(
1733
-            self::add_query_args_and_nonce(
1734
-                array(
1735
-                    'action' => 'change_reg_status',
1736
-                ),
1737
-                REG_ADMIN_URL
1738
-            )
1739
-        );
1740
-        echo $change_reg_status_form->get_html();
1741
-        echo $change_reg_status_form->form_close();
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * @return EE_Form_Section_Proper
1747
-     * @throws EE_Error
1748
-     * @throws InvalidArgumentException
1749
-     * @throws InvalidDataTypeException
1750
-     * @throws InvalidInterfaceException
1751
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
-     */
1753
-    protected function _generate_reg_status_change_form()
1754
-    {
1755
-        return new EE_Form_Section_Proper(
1756
-            array(
1757
-                'name'            => 'reg_status_change_form',
1758
-                'html_id'         => 'reg-status-change-form',
1759
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1760
-                'subsections'     => array(
1761
-                    'return'             => new EE_Hidden_Input(
1762
-                        array(
1763
-                            'name'    => 'return',
1764
-                            'default' => 'view_registration',
1765
-                        )
1766
-                    ),
1767
-                    'REG_ID'             => new EE_Hidden_Input(
1768
-                        array(
1769
-                            'name'    => 'REG_ID',
1770
-                            'default' => $this->_registration->ID(),
1771
-                        )
1772
-                    ),
1773
-                    'current_status'     => new EE_Form_Section_HTML(
1774
-                        EEH_HTML::tr(
1775
-                            EEH_HTML::th(
1776
-                                EEH_HTML::label(
1777
-                                    EEH_HTML::strong(
1778
-                                        esc_html__('Current Registration Status', 'event_espresso')
1779
-                                    )
1780
-                                )
1781
-                            )
1782
-                            . EEH_HTML::td(
1783
-                                EEH_HTML::strong(
1784
-                                    $this->_registration->pretty_status(),
1785
-                                    '',
1786
-                                    'status-' . $this->_registration->status_ID(),
1787
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1788
-                                )
1789
-                            )
1790
-                        )
1791
-                    ),
1792
-                    'reg_status'         => new EE_Select_Input(
1793
-                        $this->_get_reg_statuses(),
1794
-                        array(
1795
-                            'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1796
-                            'default'         => $this->_registration->status_ID(),
1797
-                        )
1798
-                    ),
1799
-                    'send_notifications' => new EE_Yes_No_Input(
1800
-                        array(
1801
-                            'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1802
-                            'default'         => false,
1803
-                            'html_help_text'  => esc_html__(
1804
-                                'If set to "Yes", then the related messages will be sent to the registrant.',
1805
-                                'event_espresso'
1806
-                            ),
1807
-                        )
1808
-                    ),
1809
-                    'submit'             => new EE_Submit_Input(
1810
-                        array(
1811
-                            'html_class'      => 'button-primary',
1812
-                            'html_label_text' => '&nbsp;',
1813
-                            'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1814
-                        )
1815
-                    ),
1816
-                ),
1817
-            )
1818
-        );
1819
-    }
1820
-
1821
-
1822
-    /**
1823
-     * Returns an array of all the buttons for the various statuses and switch status actions
1824
-     *
1825
-     * @return array
1826
-     * @throws EE_Error
1827
-     * @throws InvalidArgumentException
1828
-     * @throws InvalidDataTypeException
1829
-     * @throws InvalidInterfaceException
1830
-     * @throws EntityNotFoundException
1831
-     */
1832
-    protected function _get_reg_statuses()
1833
-    {
1834
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1835
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1836
-        // get current reg status
1837
-        $current_status = $this->_registration->status_ID();
1838
-        // is registration for free event? This will determine whether to display the pending payment option
1839
-        if ($current_status !== EEM_Registration::status_id_pending_payment
1840
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1841
-        ) {
1842
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1843
-        }
1844
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1845
-    }
1846
-
1847
-
1848
-    /**
1849
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1850
-     *
1851
-     * @param bool $status REG status given for changing registrations to.
1852
-     * @param bool $notify Whether to send messages notifications or not.
1853
-     * @return array (array with reg_id(s) updated and whether update was successful.
1854
-     * @throws EE_Error
1855
-     * @throws InvalidArgumentException
1856
-     * @throws InvalidDataTypeException
1857
-     * @throws InvalidInterfaceException
1858
-     * @throws ReflectionException
1859
-     * @throws RuntimeException
1860
-     * @throws EntityNotFoundException
1861
-     */
1862
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1863
-    {
1864
-        if (isset($this->_req_data['reg_status_change_form'])) {
1865
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1866
-                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1867
-                : array();
1868
-        } else {
1869
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1870
-                ? (array) $this->_req_data['_REG_ID']
1871
-                : array();
1872
-        }
1873
-        // sanitize $REG_IDs
1874
-        $REG_IDs = array_map('absint', $REG_IDs);
1875
-        // and remove empty entries
1876
-        $REG_IDs = array_filter($REG_IDs);
1877
-
1878
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1879
-
1880
-        /**
1881
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1882
-         * Currently this value is used downstream by the _process_resend_registration method.
1883
-         *
1884
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1885
-         * @param bool                     $status           The status registrations were changed to.
1886
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1887
-         * @param Registrations_Admin_Page $admin_page_object
1888
-         */
1889
-        $this->_req_data['_REG_ID'] = apply_filters(
1890
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1891
-            $result['REG_ID'],
1892
-            $status,
1893
-            $result['success'],
1894
-            $this
1895
-        );
1896
-
1897
-        // notify?
1898
-        if ($notify
1899
-            && $result['success']
1900
-            && ! empty($this->_req_data['_REG_ID'])
1901
-            && EE_Registry::instance()->CAP->current_user_can(
1902
-                'ee_send_message',
1903
-                'espresso_registrations_resend_registration'
1904
-            )
1905
-        ) {
1906
-            $this->_process_resend_registration();
1907
-        }
1908
-        return $result;
1909
-    }
1910
-
1911
-
1912
-    /**
1913
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1914
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1915
-     *
1916
-     * @param array  $REG_IDs
1917
-     * @param string $status
1918
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1919
-     *                        slug sent with setting the registration status.
1920
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1921
-     * @throws EE_Error
1922
-     * @throws InvalidArgumentException
1923
-     * @throws InvalidDataTypeException
1924
-     * @throws InvalidInterfaceException
1925
-     * @throws ReflectionException
1926
-     * @throws RuntimeException
1927
-     * @throws EntityNotFoundException
1928
-     */
1929
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1930
-    {
1931
-        $success = false;
1932
-        // typecast $REG_IDs
1933
-        $REG_IDs = (array) $REG_IDs;
1934
-        if (! empty($REG_IDs)) {
1935
-            $success = true;
1936
-            // set default status if none is passed
1937
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1938
-            $status_context = $notify
1939
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1940
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1941
-            // loop through REG_ID's and change status
1942
-            foreach ($REG_IDs as $REG_ID) {
1943
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1944
-                if ($registration instanceof EE_Registration) {
1945
-                    $registration->set_status(
1946
-                        $status,
1947
-                        false,
1948
-                        new Context(
1949
-                            $status_context,
1950
-                            esc_html__(
1951
-                                'Manually triggered status change on a Registration Admin Page route.',
1952
-                                'event_espresso'
1953
-                            )
1954
-                        )
1955
-                    );
1956
-                    $result = $registration->save();
1957
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1958
-                    $success = $result !== false ? $success : false;
1959
-                }
1960
-            }
1961
-        }
1962
-
1963
-        // return $success and processed registrations
1964
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1965
-    }
1966
-
1967
-
1968
-    /**
1969
-     * Common logic for setting up success message and redirecting to appropriate route
1970
-     *
1971
-     * @param  string $STS_ID status id for the registration changed to
1972
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1973
-     * @return void
1974
-     * @throws EE_Error
1975
-     */
1976
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1977
-    {
1978
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1979
-            : array('success' => false);
1980
-        $success = isset($result['success']) && $result['success'];
1981
-        // setup success message
1982
-        if ($success) {
1983
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1984
-                $msg = sprintf(
1985
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1986
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1987
-                );
1988
-            } else {
1989
-                $msg = sprintf(
1990
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1991
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
-                );
1993
-            }
1994
-            EE_Error::add_success($msg);
1995
-        } else {
1996
-            EE_Error::add_error(
1997
-                esc_html__(
1998
-                    'Something went wrong, and the status was not changed',
1999
-                    'event_espresso'
2000
-                ),
2001
-                __FILE__,
2002
-                __LINE__,
2003
-                __FUNCTION__
2004
-            );
2005
-        }
2006
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2007
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2008
-        } else {
2009
-            $route = array('action' => 'default');
2010
-        }
2011
-        // unset nonces
2012
-        foreach ($this->_req_data as $ref => $value) {
2013
-            if (strpos($ref, 'nonce') !== false) {
2014
-                unset($this->_req_data[ $ref ]);
2015
-                continue;
2016
-            }
2017
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2018
-            $this->_req_data[ $ref ] = $value;
2019
-        }
2020
-        // merge request vars so that the reloaded list table contains any existing filter query params
2021
-        $route = array_merge($this->_req_data, $route);
2022
-        $this->_redirect_after_action($success, '', '', $route, true);
2023
-    }
2024
-
2025
-
2026
-    /**
2027
-     * incoming reg status change from reg details page.
2028
-     *
2029
-     * @return void
2030
-     */
2031
-    protected function _change_reg_status()
2032
-    {
2033
-        $this->_req_data['return'] = 'view_registration';
2034
-        // set notify based on whether the send notifications toggle is set or not
2035
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
-        // $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
-            case EEM_Registration::status_id_approved:
2041
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
-                $this->approve_registration($notify);
2043
-                break;
2044
-            case EEM_Registration::status_id_pending_payment:
2045
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
-                $this->pending_registration($notify);
2047
-                break;
2048
-            case EEM_Registration::status_id_not_approved:
2049
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
-                $this->not_approve_registration($notify);
2051
-                break;
2052
-            case EEM_Registration::status_id_declined:
2053
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
-                $this->decline_registration($notify);
2055
-                break;
2056
-            case EEM_Registration::status_id_cancelled:
2057
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
-                $this->cancel_registration($notify);
2059
-                break;
2060
-            case EEM_Registration::status_id_wait_list:
2061
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
-                $this->wait_list_registration($notify);
2063
-                break;
2064
-            case EEM_Registration::status_id_incomplete:
2065
-            default:
2066
-                $result['success'] = false;
2067
-                unset($this->_req_data['return']);
2068
-                $this->_reg_status_change_return('', false);
2069
-                break;
2070
-        }
2071
-    }
2072
-
2073
-
2074
-    /**
2075
-     * Callback for bulk action routes.
2076
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
-     * when an action is happening on just a single registration).
2080
-     *
2081
-     * @param      $action
2082
-     * @param bool $notify
2083
-     */
2084
-    protected function bulk_action_on_registrations($action, $notify = false)
2085
-    {
2086
-        do_action(
2087
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
-            $this,
2089
-            $action,
2090
-            $notify
2091
-        );
2092
-        $method = $action . '_registration';
2093
-        if (method_exists($this, $method)) {
2094
-            $this->$method($notify);
2095
-        }
2096
-    }
2097
-
2098
-
2099
-    /**
2100
-     * approve_registration
2101
-     *
2102
-     * @access protected
2103
-     * @param bool $notify whether or not to notify the registrant about their approval.
2104
-     * @return void
2105
-     */
2106
-    protected function approve_registration($notify = false)
2107
-    {
2108
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
-    }
2110
-
2111
-
2112
-    /**
2113
-     *        decline_registration
2114
-     *
2115
-     * @access protected
2116
-     * @param bool $notify whether or not to notify the registrant about their status change.
2117
-     * @return void
2118
-     */
2119
-    protected function decline_registration($notify = false)
2120
-    {
2121
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
-    }
2123
-
2124
-
2125
-    /**
2126
-     *        cancel_registration
2127
-     *
2128
-     * @access protected
2129
-     * @param bool $notify whether or not to notify the registrant about their status change.
2130
-     * @return void
2131
-     */
2132
-    protected function cancel_registration($notify = false)
2133
-    {
2134
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     *        not_approve_registration
2140
-     *
2141
-     * @access protected
2142
-     * @param bool $notify whether or not to notify the registrant about their status change.
2143
-     * @return void
2144
-     */
2145
-    protected function not_approve_registration($notify = false)
2146
-    {
2147
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
-    }
2149
-
2150
-
2151
-    /**
2152
-     *        decline_registration
2153
-     *
2154
-     * @access protected
2155
-     * @param bool $notify whether or not to notify the registrant about their status change.
2156
-     * @return void
2157
-     */
2158
-    protected function pending_registration($notify = false)
2159
-    {
2160
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
-    }
2162
-
2163
-
2164
-    /**
2165
-     * waitlist_registration
2166
-     *
2167
-     * @access protected
2168
-     * @param bool $notify whether or not to notify the registrant about their status change.
2169
-     * @return void
2170
-     */
2171
-    protected function wait_list_registration($notify = false)
2172
-    {
2173
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
-    }
2175
-
2176
-
2177
-    /**
2178
-     *        generates HTML for the Registration main meta box
2179
-     *
2180
-     * @access public
2181
-     * @return void
2182
-     * @throws DomainException
2183
-     * @throws EE_Error
2184
-     * @throws InvalidArgumentException
2185
-     * @throws InvalidDataTypeException
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws ReflectionException
2188
-     * @throws EntityNotFoundException
2189
-     */
2190
-    public function _reg_details_meta_box()
2191
-    {
2192
-        EEH_Autoloader::register_line_item_display_autoloaders();
2193
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2194
-        EE_Registry::instance()->load_helper('Line_Item');
2195
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
-            : EE_Transaction::new_instance();
2197
-        $this->_session = $transaction->session_data();
2198
-        $filters = new EE_Line_Item_Filter_Collection();
2199
-        // $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2200
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2201
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
-            $filters,
2203
-            $transaction->total_line_item()
2204
-        );
2205
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2206
-        $line_item_display = new EE_Line_Item_Display(
2207
-            'reg_admin_table',
2208
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
-        );
2210
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
-            $filtered_line_item_tree,
2212
-            array('EE_Registration' => $this->_registration)
2213
-        );
2214
-        $attendee = $this->_registration->attendee();
2215
-        if (EE_Registry::instance()->CAP->current_user_can(
2216
-            'ee_read_transaction',
2217
-            'espresso_transactions_view_transaction'
2218
-        )) {
2219
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
-                EE_Admin_Page::add_query_args_and_nonce(
2221
-                    array(
2222
-                        'action' => 'view_transaction',
2223
-                        'TXN_ID' => $transaction->ID(),
2224
-                    ),
2225
-                    TXN_ADMIN_URL
2226
-                ),
2227
-                esc_html__(' View Transaction', 'event_espresso'),
2228
-                'button secondary-button right',
2229
-                'dashicons dashicons-cart'
2230
-            );
2231
-        } else {
2232
-            $this->_template_args['view_transaction_button'] = '';
2233
-        }
2234
-        if ($attendee instanceof EE_Attendee
2235
-            && EE_Registry::instance()->CAP->current_user_can(
2236
-                'ee_send_message',
2237
-                'espresso_registrations_resend_registration'
2238
-            )
2239
-        ) {
2240
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
-                EE_Admin_Page::add_query_args_and_nonce(
2242
-                    array(
2243
-                        'action'      => 'resend_registration',
2244
-                        '_REG_ID'     => $this->_registration->ID(),
2245
-                        'redirect_to' => 'view_registration',
2246
-                    ),
2247
-                    REG_ADMIN_URL
2248
-                ),
2249
-                esc_html__(' Resend Registration', 'event_espresso'),
2250
-                'button secondary-button right',
2251
-                'dashicons dashicons-email-alt'
2252
-            );
2253
-        } else {
2254
-            $this->_template_args['resend_registration_button'] = '';
2255
-        }
2256
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
-        $payment = $transaction->get_first_related('Payment');
2258
-        $payment = ! $payment instanceof EE_Payment
2259
-            ? EE_Payment::new_instance()
2260
-            : $payment;
2261
-        $payment_method = $payment->get_first_related('Payment_Method');
2262
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2263
-            ? EE_Payment_Method::new_instance()
2264
-            : $payment_method;
2265
-        $reg_details = array(
2266
-            'payment_method'       => $payment_method->name(),
2267
-            'response_msg'         => $payment->gateway_response(),
2268
-            'registration_id'      => $this->_registration->get('REG_code'),
2269
-            'registration_session' => $this->_registration->session_ID(),
2270
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
-        );
2273
-        if (isset($reg_details['registration_id'])) {
2274
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
-                'Registration ID',
2277
-                'event_espresso'
2278
-            );
2279
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
-        }
2281
-        if (isset($reg_details['payment_method'])) {
2282
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
-                'Most Recent Payment Method',
2285
-                'event_espresso'
2286
-            );
2287
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
-                'Payment method response',
2291
-                'event_espresso'
2292
-            );
2293
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
-        }
2295
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
-            'Registration Session',
2298
-            'event_espresso'
2299
-        );
2300
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
-            'Registration placed from IP',
2304
-            'event_espresso'
2305
-        );
2306
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
-            'Registrant User Agent',
2310
-            'event_espresso'
2311
-        );
2312
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
-            array(
2315
-                'action'   => 'default',
2316
-                'event_id' => $this->_registration->event_ID(),
2317
-            ),
2318
-            REG_ADMIN_URL
2319
-        );
2320
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2321
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2322
-        $template_path =
2323
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
-    }
2326
-
2327
-
2328
-    /**
2329
-     * generates HTML for the Registration Questions meta box.
2330
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
-     * otherwise uses new forms system
2332
-     *
2333
-     * @access public
2334
-     * @return void
2335
-     * @throws DomainException
2336
-     * @throws EE_Error
2337
-     */
2338
-    public function _reg_questions_meta_box()
2339
-    {
2340
-        // allow someone to override this method entirely
2341
-        if (apply_filters(
2342
-            'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
-            true,
2344
-            $this,
2345
-            $this->_registration
2346
-        )) {
2347
-            $form = $this->_get_reg_custom_questions_form(
2348
-                $this->_registration->ID()
2349
-            );
2350
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
-                ? $form->get_html_and_js()
2352
-                : '';
2353
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2355
-            $template_path =
2356
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
-        }
2359
-    }
2360
-
2361
-
2362
-    /**
2363
-     * form_before_question_group
2364
-     *
2365
-     * @deprecated    as of 4.8.32.rc.000
2366
-     * @access        public
2367
-     * @param        string $output
2368
-     * @return        string
2369
-     */
2370
-    public function form_before_question_group($output)
2371
-    {
2372
-        EE_Error::doing_it_wrong(
2373
-            __CLASS__ . '::' . __FUNCTION__,
2374
-            esc_html__(
2375
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2376
-                'event_espresso'
2377
-            ),
2378
-            '4.8.32.rc.000'
2379
-        );
2380
-        return '
1299
+		if (! empty($registration_status)) {
1300
+			$where['STS_ID'] = $registration_status;
1301
+		} else {
1302
+			// make sure we exclude incomplete registrations, but only if not trashed.
1303
+			if ($view === 'trash') {
1304
+				$where['REG_deleted'] = true;
1305
+			} elseif ($view === 'incomplete') {
1306
+				$where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
+			} else {
1308
+				$where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
+			}
1310
+		}
1311
+		return $where;
1312
+	}
1313
+
1314
+
1315
+	/**
1316
+	 * Adds any provided date restraints to the where conditions for the registrations query.
1317
+	 *
1318
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1319
+	 * @return array
1320
+	 * @throws EE_Error
1321
+	 * @throws InvalidArgumentException
1322
+	 * @throws InvalidDataTypeException
1323
+	 * @throws InvalidInterfaceException
1324
+	 */
1325
+	protected function _add_date_to_where_conditions(array $request)
1326
+	{
1327
+		$where = array();
1328
+		$view = EEH_Array::is_set($request, 'status', '');
1329
+		$month_range = ! empty($request['month_range'])
1330
+			? sanitize_text_field($request['month_range'])
1331
+			: '';
1332
+		$retrieve_for_today = $view === 'today';
1333
+		$retrieve_for_this_month = $view === 'month';
1334
+
1335
+		if ($retrieve_for_today) {
1336
+			$now = date('Y-m-d', current_time('timestamp'));
1337
+			$where['REG_date'] = array(
1338
+				'BETWEEN',
1339
+				array(
1340
+					EEM_Registration::instance()->convert_datetime_for_query(
1341
+						'REG_date',
1342
+						$now . ' 00:00:00',
1343
+						'Y-m-d H:i:s'
1344
+					),
1345
+					EEM_Registration::instance()->convert_datetime_for_query(
1346
+						'REG_date',
1347
+						$now . ' 23:59:59',
1348
+						'Y-m-d H:i:s'
1349
+					),
1350
+				),
1351
+			);
1352
+		} elseif ($retrieve_for_this_month) {
1353
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
1354
+			$days_this_month = date('t', current_time('timestamp'));
1355
+			$where['REG_date'] = array(
1356
+				'BETWEEN',
1357
+				array(
1358
+					EEM_Registration::instance()->convert_datetime_for_query(
1359
+						'REG_date',
1360
+						$current_year_and_month . '-01 00:00:00',
1361
+						'Y-m-d H:i:s'
1362
+					),
1363
+					EEM_Registration::instance()->convert_datetime_for_query(
1364
+						'REG_date',
1365
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
+						'Y-m-d H:i:s'
1367
+					),
1368
+				),
1369
+			);
1370
+		} elseif ($month_range) {
1371
+			$pieces = explode(' ', $month_range, 3);
1372
+			$month_requested = ! empty($pieces[0])
1373
+				? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
+				: '';
1375
+			$year_requested = ! empty($pieces[1])
1376
+				? $pieces[1]
1377
+				: '';
1378
+			// if there is not a month or year then we can't go further
1379
+			if ($month_requested && $year_requested) {
1380
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
+				$where['REG_date'] = array(
1382
+					'BETWEEN',
1383
+					array(
1384
+						EEM_Registration::instance()->convert_datetime_for_query(
1385
+							'REG_date',
1386
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
1387
+							'Y-m-d H:i:s'
1388
+						),
1389
+						EEM_Registration::instance()->convert_datetime_for_query(
1390
+							'REG_date',
1391
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
+							'Y-m-d H:i:s'
1393
+						),
1394
+					),
1395
+				);
1396
+			}
1397
+		}
1398
+		return $where;
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * Adds any provided search restraints to the where conditions for the registrations query
1404
+	 *
1405
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1406
+	 * @return array
1407
+	 */
1408
+	protected function _add_search_to_where_conditions(array $request)
1409
+	{
1410
+		$where = array();
1411
+		if (! empty($request['s'])) {
1412
+			$search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
+			$where['OR*search_conditions'] = array(
1414
+				'Event.EVT_name'                          => array('LIKE', $search_string),
1415
+				'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
+				'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
+				'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
+				'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
+				'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
+				'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
+				'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
+				'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
+				'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
+				'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
+				'REG_final_price'                         => array('LIKE', $search_string),
1426
+				'REG_code'                                => array('LIKE', $search_string),
1427
+				'REG_count'                               => array('LIKE', $search_string),
1428
+				'REG_group_size'                          => array('LIKE', $search_string),
1429
+				'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
+				'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
+			);
1433
+		}
1434
+		return $where;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * Sets up the where conditions for the registrations query.
1440
+	 *
1441
+	 * @param array $request
1442
+	 * @return array
1443
+	 * @throws EE_Error
1444
+	 */
1445
+	protected function _get_where_conditions_for_registrations_query($request)
1446
+	{
1447
+		return apply_filters(
1448
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
+			array_merge(
1450
+				$this->addAttendeeIdToWhereConditions($request),
1451
+				$this->_add_event_id_to_where_conditions($request),
1452
+				$this->_add_category_id_to_where_conditions($request),
1453
+				$this->_add_datetime_id_to_where_conditions($request),
1454
+				$this->_add_registration_status_to_where_conditions($request),
1455
+				$this->_add_date_to_where_conditions($request),
1456
+				$this->_add_search_to_where_conditions($request)
1457
+			),
1458
+			$request
1459
+		);
1460
+	}
1461
+
1462
+
1463
+	/**
1464
+	 * Sets up the orderby for the registrations query.
1465
+	 *
1466
+	 * @return array
1467
+	 */
1468
+	protected function _get_orderby_for_registrations_query()
1469
+	{
1470
+		$orderby_field = ! empty($this->_req_data['orderby'])
1471
+			? sanitize_text_field($this->_req_data['orderby'])
1472
+			: '_REG_date';
1473
+		switch ($orderby_field) {
1474
+			case '_REG_ID':
1475
+				$orderby = array('REG_ID');
1476
+				break;
1477
+			case '_Reg_status':
1478
+				$orderby = array('STS_ID');
1479
+				break;
1480
+			case 'ATT_fname':
1481
+				$orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
+				break;
1483
+			case 'ATT_lname':
1484
+				$orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
+				break;
1486
+			case 'event_name':
1487
+				$orderby = array('Event.EVT_name');
1488
+				break;
1489
+			case 'DTT_EVT_start':
1490
+				$orderby = array('Event.Datetime.DTT_EVT_start');
1491
+				break;
1492
+			case '_REG_date':
1493
+				$orderby = array('REG_date');
1494
+				break;
1495
+			default:
1496
+				$orderby = array($orderby_field);
1497
+				break;
1498
+		}
1499
+
1500
+		// order
1501
+		$order = ! empty($this->_req_data['order'])
1502
+			? sanitize_text_field($this->_req_data['order'])
1503
+			: 'DESC';
1504
+		$orderby = array_combine(
1505
+			$orderby,
1506
+			array_fill(0, count($orderby), $order)
1507
+		);
1508
+		// because there are many registrations with the same date, define
1509
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
1510
+		if (empty($orderby['REG_ID'])) {
1511
+			$orderby['REG_ID'] = $order;
1512
+		}
1513
+
1514
+		$orderby = apply_filters(
1515
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
+			$orderby,
1517
+			$this->_req_data
1518
+		);
1519
+
1520
+		return array('order_by' => $orderby);
1521
+	}
1522
+
1523
+
1524
+	/**
1525
+	 * Sets up the limit for the registrations query.
1526
+	 *
1527
+	 * @param $per_page
1528
+	 * @return array
1529
+	 */
1530
+	protected function _get_limit($per_page)
1531
+	{
1532
+		$current_page = ! empty($this->_req_data['paged'])
1533
+			? absint($this->_req_data['paged'])
1534
+			: 1;
1535
+		$per_page = ! empty($this->_req_data['perpage'])
1536
+			? $this->_req_data['perpage']
1537
+			: $per_page;
1538
+
1539
+		// -1 means return all results so get out if that's set.
1540
+		if ((int) $per_page === -1) {
1541
+			return array();
1542
+		}
1543
+		$per_page = absint($per_page);
1544
+		$offset = ($current_page - 1) * $per_page;
1545
+		return array('limit' => array($offset, $per_page));
1546
+	}
1547
+
1548
+
1549
+	public function get_registration_status_array()
1550
+	{
1551
+		return self::$_reg_status;
1552
+	}
1553
+
1554
+
1555
+
1556
+
1557
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1558
+	/**
1559
+	 *        generates HTML for the View Registration Details Admin page
1560
+	 *
1561
+	 * @access protected
1562
+	 * @return void
1563
+	 * @throws DomainException
1564
+	 * @throws EE_Error
1565
+	 * @throws InvalidArgumentException
1566
+	 * @throws InvalidDataTypeException
1567
+	 * @throws InvalidInterfaceException
1568
+	 * @throws EntityNotFoundException
1569
+	 */
1570
+	protected function _registration_details()
1571
+	{
1572
+		$this->_template_args = array();
1573
+		$this->_set_registration_object();
1574
+		if (is_object($this->_registration)) {
1575
+			$transaction = $this->_registration->transaction()
1576
+				? $this->_registration->transaction()
1577
+				: EE_Transaction::new_instance();
1578
+			$this->_session = $transaction->session_data();
1579
+			$event_id = $this->_registration->event_ID();
1580
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
+			$this->_template_args['grand_total'] = $transaction->total();
1585
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
+			// link back to overview
1587
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
+			$this->_template_args['registration'] = $this->_registration;
1589
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
+				array(
1591
+					'action'   => 'default',
1592
+					'event_id' => $event_id,
1593
+				),
1594
+				REG_ADMIN_URL
1595
+			);
1596
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
+				array(
1598
+					'action' => 'default',
1599
+					'EVT_ID' => $event_id,
1600
+					'page'   => 'espresso_transactions',
1601
+				),
1602
+				admin_url('admin.php')
1603
+			);
1604
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
+				array(
1606
+					'page'   => 'espresso_events',
1607
+					'action' => 'edit',
1608
+					'post'   => $event_id,
1609
+				),
1610
+				admin_url('admin.php')
1611
+			);
1612
+			// next and previous links
1613
+			$next_reg = $this->_registration->next(
1614
+				null,
1615
+				array(),
1616
+				'REG_ID'
1617
+			);
1618
+			$this->_template_args['next_registration'] = $next_reg
1619
+				? $this->_next_link(
1620
+					EE_Admin_Page::add_query_args_and_nonce(
1621
+						array(
1622
+							'action'  => 'view_registration',
1623
+							'_REG_ID' => $next_reg['REG_ID'],
1624
+						),
1625
+						REG_ADMIN_URL
1626
+					),
1627
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1628
+				)
1629
+				: '';
1630
+			$previous_reg = $this->_registration->previous(
1631
+				null,
1632
+				array(),
1633
+				'REG_ID'
1634
+			);
1635
+			$this->_template_args['previous_registration'] = $previous_reg
1636
+				? $this->_previous_link(
1637
+					EE_Admin_Page::add_query_args_and_nonce(
1638
+						array(
1639
+							'action'  => 'view_registration',
1640
+							'_REG_ID' => $previous_reg['REG_ID'],
1641
+						),
1642
+						REG_ADMIN_URL
1643
+					),
1644
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1645
+				)
1646
+				: '';
1647
+			// grab header
1648
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1650
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
+				$template_path,
1652
+				$this->_template_args,
1653
+				true
1654
+			);
1655
+		} else {
1656
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
+		}
1658
+		// the details template wrapper
1659
+		$this->display_admin_page_with_sidebar();
1660
+	}
1661
+
1662
+
1663
+	protected function _registration_details_metaboxes()
1664
+	{
1665
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
+		$this->_set_registration_object();
1667
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
+		add_meta_box(
1669
+			'edit-reg-status-mbox',
1670
+			esc_html__('Registration Status', 'event_espresso'),
1671
+			array($this, 'set_reg_status_buttons_metabox'),
1672
+			$this->wp_page_slug,
1673
+			'normal',
1674
+			'high'
1675
+		);
1676
+		add_meta_box(
1677
+			'edit-reg-details-mbox',
1678
+			esc_html__('Registration Details', 'event_espresso'),
1679
+			array($this, '_reg_details_meta_box'),
1680
+			$this->wp_page_slug,
1681
+			'normal',
1682
+			'high'
1683
+		);
1684
+		if ($attendee instanceof EE_Attendee
1685
+			&& EE_Registry::instance()->CAP->current_user_can(
1686
+				'ee_read_registration',
1687
+				'edit-reg-questions-mbox',
1688
+				$this->_registration->ID()
1689
+			)
1690
+		) {
1691
+			add_meta_box(
1692
+				'edit-reg-questions-mbox',
1693
+				esc_html__('Registration Form Answers', 'event_espresso'),
1694
+				array($this, '_reg_questions_meta_box'),
1695
+				$this->wp_page_slug,
1696
+				'normal',
1697
+				'high'
1698
+			);
1699
+		}
1700
+		add_meta_box(
1701
+			'edit-reg-registrant-mbox',
1702
+			esc_html__('Contact Details', 'event_espresso'),
1703
+			array($this, '_reg_registrant_side_meta_box'),
1704
+			$this->wp_page_slug,
1705
+			'side',
1706
+			'high'
1707
+		);
1708
+		if ($this->_registration->group_size() > 1) {
1709
+			add_meta_box(
1710
+				'edit-reg-attendees-mbox',
1711
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
+				array($this, '_reg_attendees_meta_box'),
1713
+				$this->wp_page_slug,
1714
+				'normal',
1715
+				'high'
1716
+			);
1717
+		}
1718
+	}
1719
+
1720
+
1721
+	/**
1722
+	 * set_reg_status_buttons_metabox
1723
+	 *
1724
+	 * @access protected
1725
+	 * @return string
1726
+	 * @throws \EE_Error
1727
+	 */
1728
+	public function set_reg_status_buttons_metabox()
1729
+	{
1730
+		$this->_set_registration_object();
1731
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1732
+		echo $change_reg_status_form->form_open(
1733
+			self::add_query_args_and_nonce(
1734
+				array(
1735
+					'action' => 'change_reg_status',
1736
+				),
1737
+				REG_ADMIN_URL
1738
+			)
1739
+		);
1740
+		echo $change_reg_status_form->get_html();
1741
+		echo $change_reg_status_form->form_close();
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * @return EE_Form_Section_Proper
1747
+	 * @throws EE_Error
1748
+	 * @throws InvalidArgumentException
1749
+	 * @throws InvalidDataTypeException
1750
+	 * @throws InvalidInterfaceException
1751
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
+	 */
1753
+	protected function _generate_reg_status_change_form()
1754
+	{
1755
+		return new EE_Form_Section_Proper(
1756
+			array(
1757
+				'name'            => 'reg_status_change_form',
1758
+				'html_id'         => 'reg-status-change-form',
1759
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1760
+				'subsections'     => array(
1761
+					'return'             => new EE_Hidden_Input(
1762
+						array(
1763
+							'name'    => 'return',
1764
+							'default' => 'view_registration',
1765
+						)
1766
+					),
1767
+					'REG_ID'             => new EE_Hidden_Input(
1768
+						array(
1769
+							'name'    => 'REG_ID',
1770
+							'default' => $this->_registration->ID(),
1771
+						)
1772
+					),
1773
+					'current_status'     => new EE_Form_Section_HTML(
1774
+						EEH_HTML::tr(
1775
+							EEH_HTML::th(
1776
+								EEH_HTML::label(
1777
+									EEH_HTML::strong(
1778
+										esc_html__('Current Registration Status', 'event_espresso')
1779
+									)
1780
+								)
1781
+							)
1782
+							. EEH_HTML::td(
1783
+								EEH_HTML::strong(
1784
+									$this->_registration->pretty_status(),
1785
+									'',
1786
+									'status-' . $this->_registration->status_ID(),
1787
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1788
+								)
1789
+							)
1790
+						)
1791
+					),
1792
+					'reg_status'         => new EE_Select_Input(
1793
+						$this->_get_reg_statuses(),
1794
+						array(
1795
+							'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1796
+							'default'         => $this->_registration->status_ID(),
1797
+						)
1798
+					),
1799
+					'send_notifications' => new EE_Yes_No_Input(
1800
+						array(
1801
+							'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1802
+							'default'         => false,
1803
+							'html_help_text'  => esc_html__(
1804
+								'If set to "Yes", then the related messages will be sent to the registrant.',
1805
+								'event_espresso'
1806
+							),
1807
+						)
1808
+					),
1809
+					'submit'             => new EE_Submit_Input(
1810
+						array(
1811
+							'html_class'      => 'button-primary',
1812
+							'html_label_text' => '&nbsp;',
1813
+							'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1814
+						)
1815
+					),
1816
+				),
1817
+			)
1818
+		);
1819
+	}
1820
+
1821
+
1822
+	/**
1823
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1824
+	 *
1825
+	 * @return array
1826
+	 * @throws EE_Error
1827
+	 * @throws InvalidArgumentException
1828
+	 * @throws InvalidDataTypeException
1829
+	 * @throws InvalidInterfaceException
1830
+	 * @throws EntityNotFoundException
1831
+	 */
1832
+	protected function _get_reg_statuses()
1833
+	{
1834
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1835
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1836
+		// get current reg status
1837
+		$current_status = $this->_registration->status_ID();
1838
+		// is registration for free event? This will determine whether to display the pending payment option
1839
+		if ($current_status !== EEM_Registration::status_id_pending_payment
1840
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1841
+		) {
1842
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1843
+		}
1844
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1845
+	}
1846
+
1847
+
1848
+	/**
1849
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1850
+	 *
1851
+	 * @param bool $status REG status given for changing registrations to.
1852
+	 * @param bool $notify Whether to send messages notifications or not.
1853
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1854
+	 * @throws EE_Error
1855
+	 * @throws InvalidArgumentException
1856
+	 * @throws InvalidDataTypeException
1857
+	 * @throws InvalidInterfaceException
1858
+	 * @throws ReflectionException
1859
+	 * @throws RuntimeException
1860
+	 * @throws EntityNotFoundException
1861
+	 */
1862
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1863
+	{
1864
+		if (isset($this->_req_data['reg_status_change_form'])) {
1865
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1866
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1867
+				: array();
1868
+		} else {
1869
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1870
+				? (array) $this->_req_data['_REG_ID']
1871
+				: array();
1872
+		}
1873
+		// sanitize $REG_IDs
1874
+		$REG_IDs = array_map('absint', $REG_IDs);
1875
+		// and remove empty entries
1876
+		$REG_IDs = array_filter($REG_IDs);
1877
+
1878
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1879
+
1880
+		/**
1881
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1882
+		 * Currently this value is used downstream by the _process_resend_registration method.
1883
+		 *
1884
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1885
+		 * @param bool                     $status           The status registrations were changed to.
1886
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1887
+		 * @param Registrations_Admin_Page $admin_page_object
1888
+		 */
1889
+		$this->_req_data['_REG_ID'] = apply_filters(
1890
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1891
+			$result['REG_ID'],
1892
+			$status,
1893
+			$result['success'],
1894
+			$this
1895
+		);
1896
+
1897
+		// notify?
1898
+		if ($notify
1899
+			&& $result['success']
1900
+			&& ! empty($this->_req_data['_REG_ID'])
1901
+			&& EE_Registry::instance()->CAP->current_user_can(
1902
+				'ee_send_message',
1903
+				'espresso_registrations_resend_registration'
1904
+			)
1905
+		) {
1906
+			$this->_process_resend_registration();
1907
+		}
1908
+		return $result;
1909
+	}
1910
+
1911
+
1912
+	/**
1913
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1914
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1915
+	 *
1916
+	 * @param array  $REG_IDs
1917
+	 * @param string $status
1918
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1919
+	 *                        slug sent with setting the registration status.
1920
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1921
+	 * @throws EE_Error
1922
+	 * @throws InvalidArgumentException
1923
+	 * @throws InvalidDataTypeException
1924
+	 * @throws InvalidInterfaceException
1925
+	 * @throws ReflectionException
1926
+	 * @throws RuntimeException
1927
+	 * @throws EntityNotFoundException
1928
+	 */
1929
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1930
+	{
1931
+		$success = false;
1932
+		// typecast $REG_IDs
1933
+		$REG_IDs = (array) $REG_IDs;
1934
+		if (! empty($REG_IDs)) {
1935
+			$success = true;
1936
+			// set default status if none is passed
1937
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1938
+			$status_context = $notify
1939
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1940
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1941
+			// loop through REG_ID's and change status
1942
+			foreach ($REG_IDs as $REG_ID) {
1943
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1944
+				if ($registration instanceof EE_Registration) {
1945
+					$registration->set_status(
1946
+						$status,
1947
+						false,
1948
+						new Context(
1949
+							$status_context,
1950
+							esc_html__(
1951
+								'Manually triggered status change on a Registration Admin Page route.',
1952
+								'event_espresso'
1953
+							)
1954
+						)
1955
+					);
1956
+					$result = $registration->save();
1957
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1958
+					$success = $result !== false ? $success : false;
1959
+				}
1960
+			}
1961
+		}
1962
+
1963
+		// return $success and processed registrations
1964
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1965
+	}
1966
+
1967
+
1968
+	/**
1969
+	 * Common logic for setting up success message and redirecting to appropriate route
1970
+	 *
1971
+	 * @param  string $STS_ID status id for the registration changed to
1972
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1973
+	 * @return void
1974
+	 * @throws EE_Error
1975
+	 */
1976
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1977
+	{
1978
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1979
+			: array('success' => false);
1980
+		$success = isset($result['success']) && $result['success'];
1981
+		// setup success message
1982
+		if ($success) {
1983
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1984
+				$msg = sprintf(
1985
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1986
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1987
+				);
1988
+			} else {
1989
+				$msg = sprintf(
1990
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1991
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
+				);
1993
+			}
1994
+			EE_Error::add_success($msg);
1995
+		} else {
1996
+			EE_Error::add_error(
1997
+				esc_html__(
1998
+					'Something went wrong, and the status was not changed',
1999
+					'event_espresso'
2000
+				),
2001
+				__FILE__,
2002
+				__LINE__,
2003
+				__FUNCTION__
2004
+			);
2005
+		}
2006
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2007
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2008
+		} else {
2009
+			$route = array('action' => 'default');
2010
+		}
2011
+		// unset nonces
2012
+		foreach ($this->_req_data as $ref => $value) {
2013
+			if (strpos($ref, 'nonce') !== false) {
2014
+				unset($this->_req_data[ $ref ]);
2015
+				continue;
2016
+			}
2017
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2018
+			$this->_req_data[ $ref ] = $value;
2019
+		}
2020
+		// merge request vars so that the reloaded list table contains any existing filter query params
2021
+		$route = array_merge($this->_req_data, $route);
2022
+		$this->_redirect_after_action($success, '', '', $route, true);
2023
+	}
2024
+
2025
+
2026
+	/**
2027
+	 * incoming reg status change from reg details page.
2028
+	 *
2029
+	 * @return void
2030
+	 */
2031
+	protected function _change_reg_status()
2032
+	{
2033
+		$this->_req_data['return'] = 'view_registration';
2034
+		// set notify based on whether the send notifications toggle is set or not
2035
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
+		// $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
+			case EEM_Registration::status_id_approved:
2041
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
+				$this->approve_registration($notify);
2043
+				break;
2044
+			case EEM_Registration::status_id_pending_payment:
2045
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
+				$this->pending_registration($notify);
2047
+				break;
2048
+			case EEM_Registration::status_id_not_approved:
2049
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
+				$this->not_approve_registration($notify);
2051
+				break;
2052
+			case EEM_Registration::status_id_declined:
2053
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
+				$this->decline_registration($notify);
2055
+				break;
2056
+			case EEM_Registration::status_id_cancelled:
2057
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
+				$this->cancel_registration($notify);
2059
+				break;
2060
+			case EEM_Registration::status_id_wait_list:
2061
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
+				$this->wait_list_registration($notify);
2063
+				break;
2064
+			case EEM_Registration::status_id_incomplete:
2065
+			default:
2066
+				$result['success'] = false;
2067
+				unset($this->_req_data['return']);
2068
+				$this->_reg_status_change_return('', false);
2069
+				break;
2070
+		}
2071
+	}
2072
+
2073
+
2074
+	/**
2075
+	 * Callback for bulk action routes.
2076
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
+	 * when an action is happening on just a single registration).
2080
+	 *
2081
+	 * @param      $action
2082
+	 * @param bool $notify
2083
+	 */
2084
+	protected function bulk_action_on_registrations($action, $notify = false)
2085
+	{
2086
+		do_action(
2087
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
+			$this,
2089
+			$action,
2090
+			$notify
2091
+		);
2092
+		$method = $action . '_registration';
2093
+		if (method_exists($this, $method)) {
2094
+			$this->$method($notify);
2095
+		}
2096
+	}
2097
+
2098
+
2099
+	/**
2100
+	 * approve_registration
2101
+	 *
2102
+	 * @access protected
2103
+	 * @param bool $notify whether or not to notify the registrant about their approval.
2104
+	 * @return void
2105
+	 */
2106
+	protected function approve_registration($notify = false)
2107
+	{
2108
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
+	}
2110
+
2111
+
2112
+	/**
2113
+	 *        decline_registration
2114
+	 *
2115
+	 * @access protected
2116
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2117
+	 * @return void
2118
+	 */
2119
+	protected function decline_registration($notify = false)
2120
+	{
2121
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
+	}
2123
+
2124
+
2125
+	/**
2126
+	 *        cancel_registration
2127
+	 *
2128
+	 * @access protected
2129
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2130
+	 * @return void
2131
+	 */
2132
+	protected function cancel_registration($notify = false)
2133
+	{
2134
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 *        not_approve_registration
2140
+	 *
2141
+	 * @access protected
2142
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2143
+	 * @return void
2144
+	 */
2145
+	protected function not_approve_registration($notify = false)
2146
+	{
2147
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
+	}
2149
+
2150
+
2151
+	/**
2152
+	 *        decline_registration
2153
+	 *
2154
+	 * @access protected
2155
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2156
+	 * @return void
2157
+	 */
2158
+	protected function pending_registration($notify = false)
2159
+	{
2160
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
+	}
2162
+
2163
+
2164
+	/**
2165
+	 * waitlist_registration
2166
+	 *
2167
+	 * @access protected
2168
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2169
+	 * @return void
2170
+	 */
2171
+	protected function wait_list_registration($notify = false)
2172
+	{
2173
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
+	}
2175
+
2176
+
2177
+	/**
2178
+	 *        generates HTML for the Registration main meta box
2179
+	 *
2180
+	 * @access public
2181
+	 * @return void
2182
+	 * @throws DomainException
2183
+	 * @throws EE_Error
2184
+	 * @throws InvalidArgumentException
2185
+	 * @throws InvalidDataTypeException
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws ReflectionException
2188
+	 * @throws EntityNotFoundException
2189
+	 */
2190
+	public function _reg_details_meta_box()
2191
+	{
2192
+		EEH_Autoloader::register_line_item_display_autoloaders();
2193
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2194
+		EE_Registry::instance()->load_helper('Line_Item');
2195
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
+			: EE_Transaction::new_instance();
2197
+		$this->_session = $transaction->session_data();
2198
+		$filters = new EE_Line_Item_Filter_Collection();
2199
+		// $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2200
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2201
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
+			$filters,
2203
+			$transaction->total_line_item()
2204
+		);
2205
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2206
+		$line_item_display = new EE_Line_Item_Display(
2207
+			'reg_admin_table',
2208
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
+		);
2210
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
+			$filtered_line_item_tree,
2212
+			array('EE_Registration' => $this->_registration)
2213
+		);
2214
+		$attendee = $this->_registration->attendee();
2215
+		if (EE_Registry::instance()->CAP->current_user_can(
2216
+			'ee_read_transaction',
2217
+			'espresso_transactions_view_transaction'
2218
+		)) {
2219
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
+				EE_Admin_Page::add_query_args_and_nonce(
2221
+					array(
2222
+						'action' => 'view_transaction',
2223
+						'TXN_ID' => $transaction->ID(),
2224
+					),
2225
+					TXN_ADMIN_URL
2226
+				),
2227
+				esc_html__(' View Transaction', 'event_espresso'),
2228
+				'button secondary-button right',
2229
+				'dashicons dashicons-cart'
2230
+			);
2231
+		} else {
2232
+			$this->_template_args['view_transaction_button'] = '';
2233
+		}
2234
+		if ($attendee instanceof EE_Attendee
2235
+			&& EE_Registry::instance()->CAP->current_user_can(
2236
+				'ee_send_message',
2237
+				'espresso_registrations_resend_registration'
2238
+			)
2239
+		) {
2240
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
+				EE_Admin_Page::add_query_args_and_nonce(
2242
+					array(
2243
+						'action'      => 'resend_registration',
2244
+						'_REG_ID'     => $this->_registration->ID(),
2245
+						'redirect_to' => 'view_registration',
2246
+					),
2247
+					REG_ADMIN_URL
2248
+				),
2249
+				esc_html__(' Resend Registration', 'event_espresso'),
2250
+				'button secondary-button right',
2251
+				'dashicons dashicons-email-alt'
2252
+			);
2253
+		} else {
2254
+			$this->_template_args['resend_registration_button'] = '';
2255
+		}
2256
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
+		$payment = $transaction->get_first_related('Payment');
2258
+		$payment = ! $payment instanceof EE_Payment
2259
+			? EE_Payment::new_instance()
2260
+			: $payment;
2261
+		$payment_method = $payment->get_first_related('Payment_Method');
2262
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2263
+			? EE_Payment_Method::new_instance()
2264
+			: $payment_method;
2265
+		$reg_details = array(
2266
+			'payment_method'       => $payment_method->name(),
2267
+			'response_msg'         => $payment->gateway_response(),
2268
+			'registration_id'      => $this->_registration->get('REG_code'),
2269
+			'registration_session' => $this->_registration->session_ID(),
2270
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
+		);
2273
+		if (isset($reg_details['registration_id'])) {
2274
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
+				'Registration ID',
2277
+				'event_espresso'
2278
+			);
2279
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
+		}
2281
+		if (isset($reg_details['payment_method'])) {
2282
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
+				'Most Recent Payment Method',
2285
+				'event_espresso'
2286
+			);
2287
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
+				'Payment method response',
2291
+				'event_espresso'
2292
+			);
2293
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
+		}
2295
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
+			'Registration Session',
2298
+			'event_espresso'
2299
+		);
2300
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
+			'Registration placed from IP',
2304
+			'event_espresso'
2305
+		);
2306
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
+			'Registrant User Agent',
2310
+			'event_espresso'
2311
+		);
2312
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
+			array(
2315
+				'action'   => 'default',
2316
+				'event_id' => $this->_registration->event_ID(),
2317
+			),
2318
+			REG_ADMIN_URL
2319
+		);
2320
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2321
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2322
+		$template_path =
2323
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
+	}
2326
+
2327
+
2328
+	/**
2329
+	 * generates HTML for the Registration Questions meta box.
2330
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
+	 * otherwise uses new forms system
2332
+	 *
2333
+	 * @access public
2334
+	 * @return void
2335
+	 * @throws DomainException
2336
+	 * @throws EE_Error
2337
+	 */
2338
+	public function _reg_questions_meta_box()
2339
+	{
2340
+		// allow someone to override this method entirely
2341
+		if (apply_filters(
2342
+			'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
+			true,
2344
+			$this,
2345
+			$this->_registration
2346
+		)) {
2347
+			$form = $this->_get_reg_custom_questions_form(
2348
+				$this->_registration->ID()
2349
+			);
2350
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
+				? $form->get_html_and_js()
2352
+				: '';
2353
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2355
+			$template_path =
2356
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
+		}
2359
+	}
2360
+
2361
+
2362
+	/**
2363
+	 * form_before_question_group
2364
+	 *
2365
+	 * @deprecated    as of 4.8.32.rc.000
2366
+	 * @access        public
2367
+	 * @param        string $output
2368
+	 * @return        string
2369
+	 */
2370
+	public function form_before_question_group($output)
2371
+	{
2372
+		EE_Error::doing_it_wrong(
2373
+			__CLASS__ . '::' . __FUNCTION__,
2374
+			esc_html__(
2375
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2376
+				'event_espresso'
2377
+			),
2378
+			'4.8.32.rc.000'
2379
+		);
2380
+		return '
2381 2381
 	<table class="form-table ee-width-100">
2382 2382
 		<tbody>
2383 2383
 			';
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * form_after_question_group
2389
-     *
2390
-     * @deprecated    as of 4.8.32.rc.000
2391
-     * @access        public
2392
-     * @param        string $output
2393
-     * @return        string
2394
-     */
2395
-    public function form_after_question_group($output)
2396
-    {
2397
-        EE_Error::doing_it_wrong(
2398
-            __CLASS__ . '::' . __FUNCTION__,
2399
-            esc_html__(
2400
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2401
-                'event_espresso'
2402
-            ),
2403
-            '4.8.32.rc.000'
2404
-        );
2405
-        return '
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * form_after_question_group
2389
+	 *
2390
+	 * @deprecated    as of 4.8.32.rc.000
2391
+	 * @access        public
2392
+	 * @param        string $output
2393
+	 * @return        string
2394
+	 */
2395
+	public function form_after_question_group($output)
2396
+	{
2397
+		EE_Error::doing_it_wrong(
2398
+			__CLASS__ . '::' . __FUNCTION__,
2399
+			esc_html__(
2400
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2401
+				'event_espresso'
2402
+			),
2403
+			'4.8.32.rc.000'
2404
+		);
2405
+		return '
2406 2406
 			<tr class="hide-if-no-js">
2407 2407
 				<th> </th>
2408 2408
 				<td class="reg-admin-edit-attendee-question-td">
2409 2409
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2410
-               . esc_attr__('click to edit question', 'event_espresso')
2411
-               . '">
2410
+			   . esc_attr__('click to edit question', 'event_espresso')
2411
+			   . '">
2412 2412
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2413
-               . esc_html__('edit the above question group', 'event_espresso')
2414
-               . '</span>
2413
+			   . esc_html__('edit the above question group', 'event_espresso')
2414
+			   . '</span>
2415 2415
 						<div class="dashicons dashicons-edit"></div>
2416 2416
 					</a>
2417 2417
 				</td>
@@ -2419,606 +2419,606 @@  discard block
 block discarded – undo
2419 2419
 		</tbody>
2420 2420
 	</table>
2421 2421
 ';
2422
-    }
2423
-
2424
-
2425
-    /**
2426
-     * form_form_field_label_wrap
2427
-     *
2428
-     * @deprecated    as of 4.8.32.rc.000
2429
-     * @access        public
2430
-     * @param        string $label
2431
-     * @return        string
2432
-     */
2433
-    public function form_form_field_label_wrap($label)
2434
-    {
2435
-        EE_Error::doing_it_wrong(
2436
-            __CLASS__ . '::' . __FUNCTION__,
2437
-            esc_html__(
2438
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2439
-                'event_espresso'
2440
-            ),
2441
-            '4.8.32.rc.000'
2442
-        );
2443
-        return '
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * form_form_field_label_wrap
2427
+	 *
2428
+	 * @deprecated    as of 4.8.32.rc.000
2429
+	 * @access        public
2430
+	 * @param        string $label
2431
+	 * @return        string
2432
+	 */
2433
+	public function form_form_field_label_wrap($label)
2434
+	{
2435
+		EE_Error::doing_it_wrong(
2436
+			__CLASS__ . '::' . __FUNCTION__,
2437
+			esc_html__(
2438
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2439
+				'event_espresso'
2440
+			),
2441
+			'4.8.32.rc.000'
2442
+		);
2443
+		return '
2444 2444
 			<tr>
2445 2445
 				<th>
2446 2446
 					' . $label . '
2447 2447
 				</th>';
2448
-    }
2449
-
2450
-
2451
-    /**
2452
-     * form_form_field_input__wrap
2453
-     *
2454
-     * @deprecated    as of 4.8.32.rc.000
2455
-     * @access        public
2456
-     * @param        string $input
2457
-     * @return        string
2458
-     */
2459
-    public function form_form_field_input__wrap($input)
2460
-    {
2461
-        EE_Error::doing_it_wrong(
2462
-            __CLASS__ . '::' . __FUNCTION__,
2463
-            esc_html__(
2464
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2465
-                'event_espresso'
2466
-            ),
2467
-            '4.8.32.rc.000'
2468
-        );
2469
-        return '
2448
+	}
2449
+
2450
+
2451
+	/**
2452
+	 * form_form_field_input__wrap
2453
+	 *
2454
+	 * @deprecated    as of 4.8.32.rc.000
2455
+	 * @access        public
2456
+	 * @param        string $input
2457
+	 * @return        string
2458
+	 */
2459
+	public function form_form_field_input__wrap($input)
2460
+	{
2461
+		EE_Error::doing_it_wrong(
2462
+			__CLASS__ . '::' . __FUNCTION__,
2463
+			esc_html__(
2464
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2465
+				'event_espresso'
2466
+			),
2467
+			'4.8.32.rc.000'
2468
+		);
2469
+		return '
2470 2470
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2471 2471
 					' . $input . '
2472 2472
 				</td>
2473 2473
 			</tr>';
2474
-    }
2475
-
2476
-
2477
-    /**
2478
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
-     * to display the page
2481
-     *
2482
-     * @access protected
2483
-     * @return void
2484
-     * @throws EE_Error
2485
-     */
2486
-    protected function _update_attendee_registration_form()
2487
-    {
2488
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2492
-            if ($success) {
2493
-                $what = esc_html__('Registration Form', 'event_espresso');
2494
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
-                    : array('action' => 'default');
2496
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
-            }
2498
-        }
2499
-    }
2500
-
2501
-
2502
-    /**
2503
-     * Gets the form for saving registrations custom questions (if done
2504
-     * previously retrieves the cached form object, which may have validation errors in it)
2505
-     *
2506
-     * @param int $REG_ID
2507
-     * @return EE_Registration_Custom_Questions_Form
2508
-     * @throws EE_Error
2509
-     * @throws InvalidArgumentException
2510
-     * @throws InvalidDataTypeException
2511
-     * @throws InvalidInterfaceException
2512
-     */
2513
-    protected function _get_reg_custom_questions_form($REG_ID)
2514
-    {
2515
-        if (! $this->_reg_custom_questions_form) {
2516
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2517
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
-                EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
-            );
2520
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
-        }
2522
-        return $this->_reg_custom_questions_form;
2523
-    }
2524
-
2525
-
2526
-    /**
2527
-     * Saves
2528
-     *
2529
-     * @access private
2530
-     * @param bool $REG_ID
2531
-     * @return bool
2532
-     * @throws EE_Error
2533
-     * @throws InvalidArgumentException
2534
-     * @throws InvalidDataTypeException
2535
-     * @throws InvalidInterfaceException
2536
-     */
2537
-    private function _save_reg_custom_questions_form($REG_ID = false)
2538
-    {
2539
-        if (! $REG_ID) {
2540
-            EE_Error::add_error(
2541
-                esc_html__(
2542
-                    'An error occurred. No registration ID was received.',
2543
-                    'event_espresso'
2544
-                ),
2545
-                __FILE__,
2546
-                __FUNCTION__,
2547
-                __LINE__
2548
-            );
2549
-        }
2550
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2551
-        $form->receive_form_submission($this->_req_data);
2552
-        $success = false;
2553
-        if ($form->is_valid()) {
2554
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2556
-                    $where_conditions = array(
2557
-                        'QST_ID' => $question_id,
2558
-                        'REG_ID' => $REG_ID,
2559
-                    );
2560
-                    $possibly_new_values = array(
2561
-                        'ANS_value' => $input->normalized_value(),
2562
-                    );
2563
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
-                    if ($answer instanceof EE_Answer) {
2565
-                        $success = $answer->save($possibly_new_values);
2566
-                    } else {
2567
-                        // insert it then
2568
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2570
-                        $success = $answer->save();
2571
-                    }
2572
-                }
2573
-            }
2574
-        } else {
2575
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
-        }
2577
-        return $success;
2578
-    }
2579
-
2580
-
2581
-    /**
2582
-     *        generates HTML for the Registration main meta box
2583
-     *
2584
-     * @access public
2585
-     * @return void
2586
-     * @throws DomainException
2587
-     * @throws EE_Error
2588
-     * @throws InvalidArgumentException
2589
-     * @throws InvalidDataTypeException
2590
-     * @throws InvalidInterfaceException
2591
-     */
2592
-    public function _reg_attendees_meta_box()
2593
-    {
2594
-        $REG = EEM_Registration::instance();
2595
-        // get all other registrations on this transaction, and cache
2596
-        // the attendees for them so we don't have to run another query using force_join
2597
-        $registrations = $REG->get_all(
2598
-            array(
2599
-                array(
2600
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2601
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2602
-                ),
2603
-                'force_join' => array('Attendee'),
2604
-            )
2605
-        );
2606
-        $this->_template_args['attendees'] = array();
2607
-        $this->_template_args['attendee_notice'] = '';
2608
-        if (empty($registrations)
2609
-            || (is_array($registrations)
2610
-                && ! EEH_Array::get_one_item_from_array($registrations))
2611
-        ) {
2612
-            EE_Error::add_error(
2613
-                esc_html__(
2614
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2615
-                    'event_espresso'
2616
-                ),
2617
-                __FILE__,
2618
-                __FUNCTION__,
2619
-                __LINE__
2620
-            );
2621
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2622
-        } else {
2623
-            $att_nmbr = 1;
2624
-            foreach ($registrations as $registration) {
2625
-                /* @var $registration EE_Registration */
2626
-                $attendee = $registration->attendee()
2627
-                    ? $registration->attendee()
2628
-                    : EEM_Attendee::instance()
2629
-                                  ->create_default_object();
2630
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2631
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2632
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2633
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2634
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2636
-                    ', ',
2637
-                    $attendee->full_address_as_array()
2638
-                );
2639
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2640
-                    array(
2641
-                        'action' => 'edit_attendee',
2642
-                        'post'   => $attendee->ID(),
2643
-                    ),
2644
-                    REG_ADMIN_URL
2645
-                );
2646
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2647
-                $att_nmbr++;
2648
-            }
2649
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2650
-        }
2651
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2652
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2653
-    }
2654
-
2655
-
2656
-    /**
2657
-     *        generates HTML for the Edit Registration side meta box
2658
-     *
2659
-     * @access public
2660
-     * @return void
2661
-     * @throws DomainException
2662
-     * @throws EE_Error
2663
-     * @throws InvalidArgumentException
2664
-     * @throws InvalidDataTypeException
2665
-     * @throws InvalidInterfaceException
2666
-     */
2667
-    public function _reg_registrant_side_meta_box()
2668
-    {
2669
-        /*@var $attendee EE_Attendee */
2670
-        $att_check = $this->_registration->attendee();
2671
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2672
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2673
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2674
-        // primary registration object (that way we know if we need to show create button or not)
2675
-        if (! $this->_registration->is_primary_registrant()) {
2676
-            $primary_registration = $this->_registration->get_primary_registration();
2677
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2678
-                : null;
2679
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2680
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2681
-                // custom attendee object so let's not worry about the primary reg.
2682
-                $primary_registration = null;
2683
-            }
2684
-        } else {
2685
-            $primary_registration = null;
2686
-        }
2687
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2688
-        $this->_template_args['fname'] = $attendee->fname();
2689
-        $this->_template_args['lname'] = $attendee->lname();
2690
-        $this->_template_args['email'] = $attendee->email();
2691
-        $this->_template_args['phone'] = $attendee->phone();
2692
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2693
-        // edit link
2694
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2695
-            array(
2696
-                'action' => 'edit_attendee',
2697
-                'post'   => $attendee->ID(),
2698
-            ),
2699
-            REG_ADMIN_URL
2700
-        );
2701
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2702
-        // create link
2703
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2704
-            ? EE_Admin_Page::add_query_args_and_nonce(
2705
-                array(
2706
-                    'action'  => 'duplicate_attendee',
2707
-                    '_REG_ID' => $this->_registration->ID(),
2708
-                ),
2709
-                REG_ADMIN_URL
2710
-            ) : '';
2711
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2712
-        $this->_template_args['att_check'] = $att_check;
2713
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2714
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2715
-    }
2716
-
2717
-
2718
-    /**
2719
-     * trash or restore registrations
2720
-     *
2721
-     * @param  boolean $trash whether to archive or restore
2722
-     * @return void
2723
-     * @throws EE_Error
2724
-     * @throws InvalidArgumentException
2725
-     * @throws InvalidDataTypeException
2726
-     * @throws InvalidInterfaceException
2727
-     * @throws RuntimeException
2728
-     * @access protected
2729
-     */
2730
-    protected function _trash_or_restore_registrations($trash = true)
2731
-    {
2732
-        // if empty _REG_ID then get out because there's nothing to do
2733
-        if (empty($this->_req_data['_REG_ID'])) {
2734
-            EE_Error::add_error(
2735
-                sprintf(
2736
-                    esc_html__(
2737
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2738
-                        'event_espresso'
2739
-                    ),
2740
-                    $trash ? 'trash' : 'restore'
2741
-                ),
2742
-                __FILE__,
2743
-                __LINE__,
2744
-                __FUNCTION__
2745
-            );
2746
-            $this->_redirect_after_action(false, '', '', array(), true);
2747
-        }
2748
-        $success = 0;
2749
-        $overwrite_msgs = false;
2750
-        // Checkboxes
2751
-        if (! is_array($this->_req_data['_REG_ID'])) {
2752
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2753
-        }
2754
-        $reg_count = count($this->_req_data['_REG_ID']);
2755
-        // cycle thru checkboxes
2756
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2757
-            /** @var EE_Registration $REG */
2758
-            $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2759
-            $payments = $REG->registration_payments();
2760
-            if (! empty($payments)) {
2761
-                $name = $REG->attendee() instanceof EE_Attendee
2762
-                    ? $REG->attendee()->full_name()
2763
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2764
-                $overwrite_msgs = true;
2765
-                EE_Error::add_error(
2766
-                    sprintf(
2767
-                        esc_html__(
2768
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2769
-                            'event_espresso'
2770
-                        ),
2771
-                        $name
2772
-                    ),
2773
-                    __FILE__,
2774
-                    __FUNCTION__,
2775
-                    __LINE__
2776
-                );
2777
-                // can't trash this registration because it has payments.
2778
-                continue;
2779
-            }
2780
-            $updated = $trash ? $REG->delete() : $REG->restore();
2781
-            if ($updated) {
2782
-                $success++;
2783
-            }
2784
-        }
2785
-        $this->_redirect_after_action(
2786
-            $success === $reg_count, // were ALL registrations affected?
2787
-            $success > 1
2788
-                ? esc_html__('Registrations', 'event_espresso')
2789
-                : esc_html__('Registration', 'event_espresso'),
2790
-            $trash
2791
-                ? esc_html__('moved to the trash', 'event_espresso')
2792
-                : esc_html__('restored', 'event_espresso'),
2793
-            array('action' => 'default'),
2794
-            $overwrite_msgs
2795
-        );
2796
-    }
2797
-
2798
-
2799
-    /**
2800
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2801
-     * registration but also.
2802
-     * 1. Removing relations to EE_Attendee
2803
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2804
-     * ALSO trashed.
2805
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2806
-     * 4. Removing relationships between all tickets and the related registrations
2807
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2808
-     * 6. Deleting permanently any related Checkins.
2809
-     *
2810
-     * @return void
2811
-     * @throws EE_Error
2812
-     * @throws InvalidArgumentException
2813
-     * @throws InvalidDataTypeException
2814
-     * @throws InvalidInterfaceException
2815
-     */
2816
-    protected function _delete_registrations()
2817
-    {
2818
-        $REG_MDL = EEM_Registration::instance();
2819
-        $success = 1;
2820
-        // Checkboxes
2821
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2822
-            // if array has more than one element than success message should be plural
2823
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2824
-            // cycle thru checkboxes
2825
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2826
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2827
-                if (! $REG instanceof EE_Registration) {
2828
-                    continue;
2829
-                }
2830
-                $deleted = $this->_delete_registration($REG);
2831
-                if (! $deleted) {
2832
-                    $success = 0;
2833
-                }
2834
-            }
2835
-        } else {
2836
-            // grab single id and delete
2837
-            $REG_ID = $this->_req_data['_REG_ID'];
2838
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2839
-            $deleted = $this->_delete_registration($REG);
2840
-            if (! $deleted) {
2841
-                $success = 0;
2842
-            }
2843
-        }
2844
-        $what = $success > 1
2845
-            ? esc_html__('Registrations', 'event_espresso')
2846
-            : esc_html__('Registration', 'event_espresso');
2847
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2848
-        $this->_redirect_after_action(
2849
-            $success,
2850
-            $what,
2851
-            $action_desc,
2852
-            array('action' => 'default'),
2853
-            true
2854
-        );
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2860
-     * models get affected.
2861
-     *
2862
-     * @param  EE_Registration $REG registration to be deleted permenantly
2863
-     * @return bool true = successful deletion, false = fail.
2864
-     * @throws EE_Error
2865
-     */
2866
-    protected function _delete_registration(EE_Registration $REG)
2867
-    {
2868
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2869
-        // registrations on the transaction that are NOT trashed.
2870
-        $TXN = $REG->get_first_related('Transaction');
2871
-        $REGS = $TXN->get_many_related('Registration');
2872
-        $all_trashed = true;
2873
-        foreach ($REGS as $registration) {
2874
-            if (! $registration->get('REG_deleted')) {
2875
-                $all_trashed = false;
2876
-            }
2877
-        }
2878
-        if (! $all_trashed) {
2879
-            EE_Error::add_error(
2880
-                esc_html__(
2881
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2882
-                    'event_espresso'
2883
-                ),
2884
-                __FILE__,
2885
-                __FUNCTION__,
2886
-                __LINE__
2887
-            );
2888
-            return false;
2889
-        }
2890
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2891
-        // separately from THIS one).
2892
-        foreach ($REGS as $registration) {
2893
-            // delete related answers
2894
-            $registration->delete_related_permanently('Answer');
2895
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2896
-            $attendee = $registration->get_first_related('Attendee');
2897
-            if ($attendee instanceof EE_Attendee) {
2898
-                $registration->_remove_relation_to($attendee, 'Attendee');
2899
-            }
2900
-            // now remove relationships to tickets on this registration.
2901
-            $registration->_remove_relations('Ticket');
2902
-            // now delete permanently the checkins related to this registration.
2903
-            $registration->delete_related_permanently('Checkin');
2904
-            if ($registration->ID() === $REG->ID()) {
2905
-                continue;
2906
-            } //we don't want to delete permanently the existing registration just yet.
2907
-            // remove relation to transaction for these registrations if NOT the existing registrations
2908
-            $registration->_remove_relations('Transaction');
2909
-            // delete permanently any related messages.
2910
-            $registration->delete_related_permanently('Message');
2911
-            // now delete this registration permanently
2912
-            $registration->delete_permanently();
2913
-        }
2914
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2915
-        // (the transaction and line items should be all that's left).
2916
-        // delete the line items related to the transaction for this registration.
2917
-        $TXN->delete_related_permanently('Line_Item');
2918
-        // we need to remove all the relationships on the transaction
2919
-        $TXN->delete_related_permanently('Payment');
2920
-        $TXN->delete_related_permanently('Extra_Meta');
2921
-        $TXN->delete_related_permanently('Message');
2922
-        // now we can delete this REG permanently (and the transaction of course)
2923
-        $REG->delete_related_permanently('Transaction');
2924
-        return $REG->delete_permanently();
2925
-    }
2926
-
2927
-
2928
-    /**
2929
-     *    generates HTML for the Register New Attendee Admin page
2930
-     *
2931
-     * @access private
2932
-     * @throws DomainException
2933
-     * @throws EE_Error
2934
-     */
2935
-    public function new_registration()
2936
-    {
2937
-        if (! $this->_set_reg_event()) {
2938
-            throw new EE_Error(
2939
-                esc_html__(
2940
-                    'Unable to continue with registering because there is no Event ID in the request',
2941
-                    'event_espresso'
2942
-                )
2943
-            );
2944
-        }
2945
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2946
-        // gotta start with a clean slate if we're not coming here via ajax
2947
-        if (! defined('DOING_AJAX')
2948
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2949
-        ) {
2950
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2951
-        }
2952
-        $this->_template_args['event_name'] = '';
2953
-        // event name
2954
-        if ($this->_reg_event) {
2955
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2956
-            $edit_event_url = self::add_query_args_and_nonce(
2957
-                array(
2958
-                    'action' => 'edit',
2959
-                    'post'   => $this->_reg_event->ID(),
2960
-                ),
2961
-                EVENTS_ADMIN_URL
2962
-            );
2963
-            $edit_event_lnk = '<a href="'
2964
-                              . $edit_event_url
2965
-                              . '" title="'
2966
-                              . esc_attr__('Edit ', 'event_espresso')
2967
-                              . $this->_reg_event->name()
2968
-                              . '">'
2969
-                              . esc_html__('Edit Event', 'event_espresso')
2970
-                              . '</a>';
2971
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2972
-                                                   . $edit_event_lnk
2973
-                                                   . '</span>';
2974
-        }
2975
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2976
-        if (defined('DOING_AJAX')) {
2977
-            $this->_return_json();
2978
-        }
2979
-        // grab header
2980
-        $template_path =
2981
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2982
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2983
-            $template_path,
2984
-            $this->_template_args,
2985
-            true
2986
-        );
2987
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2988
-        // the details template wrapper
2989
-        $this->display_admin_page_with_sidebar();
2990
-    }
2991
-
2992
-
2993
-    /**
2994
-     * This returns the content for a registration step
2995
-     *
2996
-     * @access protected
2997
-     * @return string html
2998
-     * @throws DomainException
2999
-     * @throws EE_Error
3000
-     * @throws InvalidArgumentException
3001
-     * @throws InvalidDataTypeException
3002
-     * @throws InvalidInterfaceException
3003
-     */
3004
-    protected function _get_registration_step_content()
3005
-    {
3006
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3007
-            $warning_msg = sprintf(
3008
-                esc_html__(
3009
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
3010
-                    'event_espresso'
3011
-                ),
3012
-                '<br />',
3013
-                '<h3 class="important-notice">',
3014
-                '</h3>',
3015
-                '<div class="float-right">',
3016
-                '<span id="redirect_timer" class="important-notice">30</span>',
3017
-                '</div>',
3018
-                '<b>',
3019
-                '</b>'
3020
-            );
3021
-            return '
2474
+	}
2475
+
2476
+
2477
+	/**
2478
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
+	 * to display the page
2481
+	 *
2482
+	 * @access protected
2483
+	 * @return void
2484
+	 * @throws EE_Error
2485
+	 */
2486
+	protected function _update_attendee_registration_form()
2487
+	{
2488
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2492
+			if ($success) {
2493
+				$what = esc_html__('Registration Form', 'event_espresso');
2494
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
+					: array('action' => 'default');
2496
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
+			}
2498
+		}
2499
+	}
2500
+
2501
+
2502
+	/**
2503
+	 * Gets the form for saving registrations custom questions (if done
2504
+	 * previously retrieves the cached form object, which may have validation errors in it)
2505
+	 *
2506
+	 * @param int $REG_ID
2507
+	 * @return EE_Registration_Custom_Questions_Form
2508
+	 * @throws EE_Error
2509
+	 * @throws InvalidArgumentException
2510
+	 * @throws InvalidDataTypeException
2511
+	 * @throws InvalidInterfaceException
2512
+	 */
2513
+	protected function _get_reg_custom_questions_form($REG_ID)
2514
+	{
2515
+		if (! $this->_reg_custom_questions_form) {
2516
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2517
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
+				EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
+			);
2520
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
+		}
2522
+		return $this->_reg_custom_questions_form;
2523
+	}
2524
+
2525
+
2526
+	/**
2527
+	 * Saves
2528
+	 *
2529
+	 * @access private
2530
+	 * @param bool $REG_ID
2531
+	 * @return bool
2532
+	 * @throws EE_Error
2533
+	 * @throws InvalidArgumentException
2534
+	 * @throws InvalidDataTypeException
2535
+	 * @throws InvalidInterfaceException
2536
+	 */
2537
+	private function _save_reg_custom_questions_form($REG_ID = false)
2538
+	{
2539
+		if (! $REG_ID) {
2540
+			EE_Error::add_error(
2541
+				esc_html__(
2542
+					'An error occurred. No registration ID was received.',
2543
+					'event_espresso'
2544
+				),
2545
+				__FILE__,
2546
+				__FUNCTION__,
2547
+				__LINE__
2548
+			);
2549
+		}
2550
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2551
+		$form->receive_form_submission($this->_req_data);
2552
+		$success = false;
2553
+		if ($form->is_valid()) {
2554
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2556
+					$where_conditions = array(
2557
+						'QST_ID' => $question_id,
2558
+						'REG_ID' => $REG_ID,
2559
+					);
2560
+					$possibly_new_values = array(
2561
+						'ANS_value' => $input->normalized_value(),
2562
+					);
2563
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
+					if ($answer instanceof EE_Answer) {
2565
+						$success = $answer->save($possibly_new_values);
2566
+					} else {
2567
+						// insert it then
2568
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
+						$answer = EE_Answer::new_instance($cols_n_vals);
2570
+						$success = $answer->save();
2571
+					}
2572
+				}
2573
+			}
2574
+		} else {
2575
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
+		}
2577
+		return $success;
2578
+	}
2579
+
2580
+
2581
+	/**
2582
+	 *        generates HTML for the Registration main meta box
2583
+	 *
2584
+	 * @access public
2585
+	 * @return void
2586
+	 * @throws DomainException
2587
+	 * @throws EE_Error
2588
+	 * @throws InvalidArgumentException
2589
+	 * @throws InvalidDataTypeException
2590
+	 * @throws InvalidInterfaceException
2591
+	 */
2592
+	public function _reg_attendees_meta_box()
2593
+	{
2594
+		$REG = EEM_Registration::instance();
2595
+		// get all other registrations on this transaction, and cache
2596
+		// the attendees for them so we don't have to run another query using force_join
2597
+		$registrations = $REG->get_all(
2598
+			array(
2599
+				array(
2600
+					'TXN_ID' => $this->_registration->transaction_ID(),
2601
+					'REG_ID' => array('!=', $this->_registration->ID()),
2602
+				),
2603
+				'force_join' => array('Attendee'),
2604
+			)
2605
+		);
2606
+		$this->_template_args['attendees'] = array();
2607
+		$this->_template_args['attendee_notice'] = '';
2608
+		if (empty($registrations)
2609
+			|| (is_array($registrations)
2610
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2611
+		) {
2612
+			EE_Error::add_error(
2613
+				esc_html__(
2614
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2615
+					'event_espresso'
2616
+				),
2617
+				__FILE__,
2618
+				__FUNCTION__,
2619
+				__LINE__
2620
+			);
2621
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2622
+		} else {
2623
+			$att_nmbr = 1;
2624
+			foreach ($registrations as $registration) {
2625
+				/* @var $registration EE_Registration */
2626
+				$attendee = $registration->attendee()
2627
+					? $registration->attendee()
2628
+					: EEM_Attendee::instance()
2629
+								  ->create_default_object();
2630
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2631
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2632
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2633
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2634
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2635
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2636
+					', ',
2637
+					$attendee->full_address_as_array()
2638
+				);
2639
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2640
+					array(
2641
+						'action' => 'edit_attendee',
2642
+						'post'   => $attendee->ID(),
2643
+					),
2644
+					REG_ADMIN_URL
2645
+				);
2646
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2647
+				$att_nmbr++;
2648
+			}
2649
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2650
+		}
2651
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2652
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2653
+	}
2654
+
2655
+
2656
+	/**
2657
+	 *        generates HTML for the Edit Registration side meta box
2658
+	 *
2659
+	 * @access public
2660
+	 * @return void
2661
+	 * @throws DomainException
2662
+	 * @throws EE_Error
2663
+	 * @throws InvalidArgumentException
2664
+	 * @throws InvalidDataTypeException
2665
+	 * @throws InvalidInterfaceException
2666
+	 */
2667
+	public function _reg_registrant_side_meta_box()
2668
+	{
2669
+		/*@var $attendee EE_Attendee */
2670
+		$att_check = $this->_registration->attendee();
2671
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2672
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2673
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2674
+		// primary registration object (that way we know if we need to show create button or not)
2675
+		if (! $this->_registration->is_primary_registrant()) {
2676
+			$primary_registration = $this->_registration->get_primary_registration();
2677
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2678
+				: null;
2679
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2680
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2681
+				// custom attendee object so let's not worry about the primary reg.
2682
+				$primary_registration = null;
2683
+			}
2684
+		} else {
2685
+			$primary_registration = null;
2686
+		}
2687
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2688
+		$this->_template_args['fname'] = $attendee->fname();
2689
+		$this->_template_args['lname'] = $attendee->lname();
2690
+		$this->_template_args['email'] = $attendee->email();
2691
+		$this->_template_args['phone'] = $attendee->phone();
2692
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2693
+		// edit link
2694
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2695
+			array(
2696
+				'action' => 'edit_attendee',
2697
+				'post'   => $attendee->ID(),
2698
+			),
2699
+			REG_ADMIN_URL
2700
+		);
2701
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2702
+		// create link
2703
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2704
+			? EE_Admin_Page::add_query_args_and_nonce(
2705
+				array(
2706
+					'action'  => 'duplicate_attendee',
2707
+					'_REG_ID' => $this->_registration->ID(),
2708
+				),
2709
+				REG_ADMIN_URL
2710
+			) : '';
2711
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2712
+		$this->_template_args['att_check'] = $att_check;
2713
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2714
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2715
+	}
2716
+
2717
+
2718
+	/**
2719
+	 * trash or restore registrations
2720
+	 *
2721
+	 * @param  boolean $trash whether to archive or restore
2722
+	 * @return void
2723
+	 * @throws EE_Error
2724
+	 * @throws InvalidArgumentException
2725
+	 * @throws InvalidDataTypeException
2726
+	 * @throws InvalidInterfaceException
2727
+	 * @throws RuntimeException
2728
+	 * @access protected
2729
+	 */
2730
+	protected function _trash_or_restore_registrations($trash = true)
2731
+	{
2732
+		// if empty _REG_ID then get out because there's nothing to do
2733
+		if (empty($this->_req_data['_REG_ID'])) {
2734
+			EE_Error::add_error(
2735
+				sprintf(
2736
+					esc_html__(
2737
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2738
+						'event_espresso'
2739
+					),
2740
+					$trash ? 'trash' : 'restore'
2741
+				),
2742
+				__FILE__,
2743
+				__LINE__,
2744
+				__FUNCTION__
2745
+			);
2746
+			$this->_redirect_after_action(false, '', '', array(), true);
2747
+		}
2748
+		$success = 0;
2749
+		$overwrite_msgs = false;
2750
+		// Checkboxes
2751
+		if (! is_array($this->_req_data['_REG_ID'])) {
2752
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2753
+		}
2754
+		$reg_count = count($this->_req_data['_REG_ID']);
2755
+		// cycle thru checkboxes
2756
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2757
+			/** @var EE_Registration $REG */
2758
+			$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2759
+			$payments = $REG->registration_payments();
2760
+			if (! empty($payments)) {
2761
+				$name = $REG->attendee() instanceof EE_Attendee
2762
+					? $REG->attendee()->full_name()
2763
+					: esc_html__('Unknown Attendee', 'event_espresso');
2764
+				$overwrite_msgs = true;
2765
+				EE_Error::add_error(
2766
+					sprintf(
2767
+						esc_html__(
2768
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2769
+							'event_espresso'
2770
+						),
2771
+						$name
2772
+					),
2773
+					__FILE__,
2774
+					__FUNCTION__,
2775
+					__LINE__
2776
+				);
2777
+				// can't trash this registration because it has payments.
2778
+				continue;
2779
+			}
2780
+			$updated = $trash ? $REG->delete() : $REG->restore();
2781
+			if ($updated) {
2782
+				$success++;
2783
+			}
2784
+		}
2785
+		$this->_redirect_after_action(
2786
+			$success === $reg_count, // were ALL registrations affected?
2787
+			$success > 1
2788
+				? esc_html__('Registrations', 'event_espresso')
2789
+				: esc_html__('Registration', 'event_espresso'),
2790
+			$trash
2791
+				? esc_html__('moved to the trash', 'event_espresso')
2792
+				: esc_html__('restored', 'event_espresso'),
2793
+			array('action' => 'default'),
2794
+			$overwrite_msgs
2795
+		);
2796
+	}
2797
+
2798
+
2799
+	/**
2800
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2801
+	 * registration but also.
2802
+	 * 1. Removing relations to EE_Attendee
2803
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2804
+	 * ALSO trashed.
2805
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2806
+	 * 4. Removing relationships between all tickets and the related registrations
2807
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2808
+	 * 6. Deleting permanently any related Checkins.
2809
+	 *
2810
+	 * @return void
2811
+	 * @throws EE_Error
2812
+	 * @throws InvalidArgumentException
2813
+	 * @throws InvalidDataTypeException
2814
+	 * @throws InvalidInterfaceException
2815
+	 */
2816
+	protected function _delete_registrations()
2817
+	{
2818
+		$REG_MDL = EEM_Registration::instance();
2819
+		$success = 1;
2820
+		// Checkboxes
2821
+		if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2822
+			// if array has more than one element than success message should be plural
2823
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2824
+			// cycle thru checkboxes
2825
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2826
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2827
+				if (! $REG instanceof EE_Registration) {
2828
+					continue;
2829
+				}
2830
+				$deleted = $this->_delete_registration($REG);
2831
+				if (! $deleted) {
2832
+					$success = 0;
2833
+				}
2834
+			}
2835
+		} else {
2836
+			// grab single id and delete
2837
+			$REG_ID = $this->_req_data['_REG_ID'];
2838
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2839
+			$deleted = $this->_delete_registration($REG);
2840
+			if (! $deleted) {
2841
+				$success = 0;
2842
+			}
2843
+		}
2844
+		$what = $success > 1
2845
+			? esc_html__('Registrations', 'event_espresso')
2846
+			: esc_html__('Registration', 'event_espresso');
2847
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2848
+		$this->_redirect_after_action(
2849
+			$success,
2850
+			$what,
2851
+			$action_desc,
2852
+			array('action' => 'default'),
2853
+			true
2854
+		);
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2860
+	 * models get affected.
2861
+	 *
2862
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2863
+	 * @return bool true = successful deletion, false = fail.
2864
+	 * @throws EE_Error
2865
+	 */
2866
+	protected function _delete_registration(EE_Registration $REG)
2867
+	{
2868
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2869
+		// registrations on the transaction that are NOT trashed.
2870
+		$TXN = $REG->get_first_related('Transaction');
2871
+		$REGS = $TXN->get_many_related('Registration');
2872
+		$all_trashed = true;
2873
+		foreach ($REGS as $registration) {
2874
+			if (! $registration->get('REG_deleted')) {
2875
+				$all_trashed = false;
2876
+			}
2877
+		}
2878
+		if (! $all_trashed) {
2879
+			EE_Error::add_error(
2880
+				esc_html__(
2881
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2882
+					'event_espresso'
2883
+				),
2884
+				__FILE__,
2885
+				__FUNCTION__,
2886
+				__LINE__
2887
+			);
2888
+			return false;
2889
+		}
2890
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2891
+		// separately from THIS one).
2892
+		foreach ($REGS as $registration) {
2893
+			// delete related answers
2894
+			$registration->delete_related_permanently('Answer');
2895
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2896
+			$attendee = $registration->get_first_related('Attendee');
2897
+			if ($attendee instanceof EE_Attendee) {
2898
+				$registration->_remove_relation_to($attendee, 'Attendee');
2899
+			}
2900
+			// now remove relationships to tickets on this registration.
2901
+			$registration->_remove_relations('Ticket');
2902
+			// now delete permanently the checkins related to this registration.
2903
+			$registration->delete_related_permanently('Checkin');
2904
+			if ($registration->ID() === $REG->ID()) {
2905
+				continue;
2906
+			} //we don't want to delete permanently the existing registration just yet.
2907
+			// remove relation to transaction for these registrations if NOT the existing registrations
2908
+			$registration->_remove_relations('Transaction');
2909
+			// delete permanently any related messages.
2910
+			$registration->delete_related_permanently('Message');
2911
+			// now delete this registration permanently
2912
+			$registration->delete_permanently();
2913
+		}
2914
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2915
+		// (the transaction and line items should be all that's left).
2916
+		// delete the line items related to the transaction for this registration.
2917
+		$TXN->delete_related_permanently('Line_Item');
2918
+		// we need to remove all the relationships on the transaction
2919
+		$TXN->delete_related_permanently('Payment');
2920
+		$TXN->delete_related_permanently('Extra_Meta');
2921
+		$TXN->delete_related_permanently('Message');
2922
+		// now we can delete this REG permanently (and the transaction of course)
2923
+		$REG->delete_related_permanently('Transaction');
2924
+		return $REG->delete_permanently();
2925
+	}
2926
+
2927
+
2928
+	/**
2929
+	 *    generates HTML for the Register New Attendee Admin page
2930
+	 *
2931
+	 * @access private
2932
+	 * @throws DomainException
2933
+	 * @throws EE_Error
2934
+	 */
2935
+	public function new_registration()
2936
+	{
2937
+		if (! $this->_set_reg_event()) {
2938
+			throw new EE_Error(
2939
+				esc_html__(
2940
+					'Unable to continue with registering because there is no Event ID in the request',
2941
+					'event_espresso'
2942
+				)
2943
+			);
2944
+		}
2945
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2946
+		// gotta start with a clean slate if we're not coming here via ajax
2947
+		if (! defined('DOING_AJAX')
2948
+			&& (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2949
+		) {
2950
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2951
+		}
2952
+		$this->_template_args['event_name'] = '';
2953
+		// event name
2954
+		if ($this->_reg_event) {
2955
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2956
+			$edit_event_url = self::add_query_args_and_nonce(
2957
+				array(
2958
+					'action' => 'edit',
2959
+					'post'   => $this->_reg_event->ID(),
2960
+				),
2961
+				EVENTS_ADMIN_URL
2962
+			);
2963
+			$edit_event_lnk = '<a href="'
2964
+							  . $edit_event_url
2965
+							  . '" title="'
2966
+							  . esc_attr__('Edit ', 'event_espresso')
2967
+							  . $this->_reg_event->name()
2968
+							  . '">'
2969
+							  . esc_html__('Edit Event', 'event_espresso')
2970
+							  . '</a>';
2971
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2972
+												   . $edit_event_lnk
2973
+												   . '</span>';
2974
+		}
2975
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2976
+		if (defined('DOING_AJAX')) {
2977
+			$this->_return_json();
2978
+		}
2979
+		// grab header
2980
+		$template_path =
2981
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2982
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2983
+			$template_path,
2984
+			$this->_template_args,
2985
+			true
2986
+		);
2987
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2988
+		// the details template wrapper
2989
+		$this->display_admin_page_with_sidebar();
2990
+	}
2991
+
2992
+
2993
+	/**
2994
+	 * This returns the content for a registration step
2995
+	 *
2996
+	 * @access protected
2997
+	 * @return string html
2998
+	 * @throws DomainException
2999
+	 * @throws EE_Error
3000
+	 * @throws InvalidArgumentException
3001
+	 * @throws InvalidDataTypeException
3002
+	 * @throws InvalidInterfaceException
3003
+	 */
3004
+	protected function _get_registration_step_content()
3005
+	{
3006
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3007
+			$warning_msg = sprintf(
3008
+				esc_html__(
3009
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
3010
+					'event_espresso'
3011
+				),
3012
+				'<br />',
3013
+				'<h3 class="important-notice">',
3014
+				'</h3>',
3015
+				'<div class="float-right">',
3016
+				'<span id="redirect_timer" class="important-notice">30</span>',
3017
+				'</div>',
3018
+				'<b>',
3019
+				'</b>'
3020
+			);
3021
+			return '
3022 3022
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3023 3023
 	<script >
3024 3024
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -3031,855 +3031,855 @@  discard block
 block discarded – undo
3031 3031
 	        }
3032 3032
 	    }, 800 );
3033 3033
 	</script >';
3034
-        }
3035
-        $template_args = array(
3036
-            'title'                    => '',
3037
-            'content'                  => '',
3038
-            'step_button_text'         => '',
3039
-            'show_notification_toggle' => false,
3040
-        );
3041
-        // to indicate we're processing a new registration
3042
-        $hidden_fields = array(
3043
-            'processing_registration' => array(
3044
-                'type'  => 'hidden',
3045
-                'value' => 0,
3046
-            ),
3047
-            'event_id'                => array(
3048
-                'type'  => 'hidden',
3049
-                'value' => $this->_reg_event->ID(),
3050
-            ),
3051
-        );
3052
-        // if the cart is empty then we know we're at step one so we'll display ticket selector
3053
-        $cart = EE_Registry::instance()->SSN->cart();
3054
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3055
-        switch ($step) {
3056
-            case 'ticket':
3057
-                $hidden_fields['processing_registration']['value'] = 1;
3058
-                $template_args['title'] = esc_html__(
3059
-                    'Step One: Select the Ticket for this registration',
3060
-                    'event_espresso'
3061
-                );
3062
-                $template_args['content'] =
3063
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3064
-                $template_args['step_button_text'] = esc_html__(
3065
-                    'Add Tickets and Continue to Registrant Details',
3066
-                    'event_espresso'
3067
-                );
3068
-                $template_args['show_notification_toggle'] = false;
3069
-                break;
3070
-            case 'questions':
3071
-                $hidden_fields['processing_registration']['value'] = 2;
3072
-                $template_args['title'] = esc_html__(
3073
-                    'Step Two: Add Registrant Details for this Registration',
3074
-                    'event_espresso'
3075
-                );
3076
-                // in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3077
-                // properly by the first process_reg_step run.
3078
-                $template_args['content'] =
3079
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
3080
-                $template_args['step_button_text'] = esc_html__(
3081
-                    'Save Registration and Continue to Details',
3082
-                    'event_espresso'
3083
-                );
3084
-                $template_args['show_notification_toggle'] = true;
3085
-                break;
3086
-        }
3087
-        // we come back to the process_registration_step route.
3088
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3089
-        return EEH_Template::display_template(
3090
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3091
-            $template_args,
3092
-            true
3093
-        );
3094
-    }
3095
-
3096
-
3097
-    /**
3098
-     *        set_reg_event
3099
-     *
3100
-     * @access private
3101
-     * @return bool
3102
-     * @throws EE_Error
3103
-     * @throws InvalidArgumentException
3104
-     * @throws InvalidDataTypeException
3105
-     * @throws InvalidInterfaceException
3106
-     */
3107
-    private function _set_reg_event()
3108
-    {
3109
-        if (is_object($this->_reg_event)) {
3110
-            return true;
3111
-        }
3112
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3113
-        if (! $EVT_ID) {
3114
-            return false;
3115
-        }
3116
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3117
-        return true;
3118
-    }
3119
-
3120
-
3121
-    /**
3122
-     * process_reg_step
3123
-     *
3124
-     * @access        public
3125
-     * @return string
3126
-     * @throws DomainException
3127
-     * @throws EE_Error
3128
-     * @throws InvalidArgumentException
3129
-     * @throws InvalidDataTypeException
3130
-     * @throws InvalidInterfaceException
3131
-     * @throws ReflectionException
3132
-     * @throws RuntimeException
3133
-     */
3134
-    public function process_reg_step()
3135
-    {
3136
-        EE_System::do_not_cache();
3137
-        $this->_set_reg_event();
3138
-        EE_Registry::instance()->REQ->set_espresso_page(true);
3139
-        EE_Registry::instance()->REQ->set('uts', time());
3140
-        // what step are we on?
3141
-        $cart = EE_Registry::instance()->SSN->cart();
3142
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3143
-        // if doing ajax then we need to verify the nonce
3144
-        if (defined('DOING_AJAX')) {
3145
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3146
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3147
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3148
-        }
3149
-        switch ($step) {
3150
-            case 'ticket':
3151
-                // process ticket selection
3152
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3153
-                if ($success) {
3154
-                    EE_Error::add_success(
3155
-                        esc_html__(
3156
-                            'Tickets Selected. Now complete the registration.',
3157
-                            'event_espresso'
3158
-                        )
3159
-                    );
3160
-                } else {
3161
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3162
-                }
3163
-                if (defined('DOING_AJAX')) {
3164
-                    $this->new_registration(); // display next step
3165
-                } else {
3166
-                    $query_args = array(
3167
-                        'action'                  => 'new_registration',
3168
-                        'processing_registration' => 1,
3169
-                        'event_id'                => $this->_reg_event->ID(),
3170
-                        'uts'                     => time(),
3171
-                    );
3172
-                    $this->_redirect_after_action(
3173
-                        false,
3174
-                        '',
3175
-                        '',
3176
-                        $query_args,
3177
-                        true
3178
-                    );
3179
-                }
3180
-                break;
3181
-            case 'questions':
3182
-                if (! isset(
3183
-                    $this->_req_data['txn_reg_status_change'],
3184
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
3185
-                )
3186
-                ) {
3187
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3188
-                }
3189
-                // process registration
3190
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3191
-                if ($cart instanceof EE_Cart) {
3192
-                    $grand_total = $cart->get_cart_grand_total();
3193
-                    if ($grand_total instanceof EE_Line_Item) {
3194
-                        $grand_total->save_this_and_descendants_to_txn();
3195
-                    }
3196
-                }
3197
-                if (! $transaction instanceof EE_Transaction) {
3198
-                    $query_args = array(
3199
-                        'action'                  => 'new_registration',
3200
-                        'processing_registration' => 2,
3201
-                        'event_id'                => $this->_reg_event->ID(),
3202
-                        'uts'                     => time(),
3203
-                    );
3204
-                    if (defined('DOING_AJAX')) {
3205
-                        // display registration form again because there are errors (maybe validation?)
3206
-                        $this->new_registration();
3207
-                        return;
3208
-                    } else {
3209
-                        $this->_redirect_after_action(
3210
-                            false,
3211
-                            '',
3212
-                            '',
3213
-                            $query_args,
3214
-                            true
3215
-                        );
3216
-                        return;
3217
-                    }
3218
-                }
3219
-                // maybe update status, and make sure to save transaction if not done already
3220
-                if (! $transaction->update_status_based_on_total_paid()) {
3221
-                    $transaction->save();
3222
-                }
3223
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3224
-                $this->_req_data = array();
3225
-                $query_args = array(
3226
-                    'action'        => 'redirect_to_txn',
3227
-                    'TXN_ID'        => $transaction->ID(),
3228
-                    'EVT_ID'        => $this->_reg_event->ID(),
3229
-                    'event_name'    => urlencode($this->_reg_event->name()),
3230
-                    'redirect_from' => 'new_registration',
3231
-                );
3232
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3233
-                break;
3234
-        }
3235
-        // what are you looking here for?  Should be nothing to do at this point.
3236
-    }
3237
-
3238
-
3239
-    /**
3240
-     * redirect_to_txn
3241
-     *
3242
-     * @access public
3243
-     * @return void
3244
-     * @throws EE_Error
3245
-     * @throws InvalidArgumentException
3246
-     * @throws InvalidDataTypeException
3247
-     * @throws InvalidInterfaceException
3248
-     */
3249
-    public function redirect_to_txn()
3250
-    {
3251
-        EE_System::do_not_cache();
3252
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3253
-        $query_args = array(
3254
-            'action' => 'view_transaction',
3255
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3256
-            'page'   => 'espresso_transactions',
3257
-        );
3258
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3259
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3260
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
3261
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3262
-        }
3263
-        EE_Error::add_success(
3264
-            esc_html__(
3265
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3266
-                'event_espresso'
3267
-            )
3268
-        );
3269
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3270
-    }
3271
-
3272
-
3273
-    /**
3274
-     *        generates HTML for the Attendee Contact List
3275
-     *
3276
-     * @access protected
3277
-     * @return void
3278
-     */
3279
-    protected function _attendee_contact_list_table()
3280
-    {
3281
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3282
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3283
-        $this->display_admin_list_table_page_with_no_sidebar();
3284
-    }
3285
-
3286
-
3287
-    /**
3288
-     *        get_attendees
3289
-     *
3290
-     * @param      $per_page
3291
-     * @param bool $count whether to return count or data.
3292
-     * @param bool $trash
3293
-     * @return array
3294
-     * @throws EE_Error
3295
-     * @throws InvalidArgumentException
3296
-     * @throws InvalidDataTypeException
3297
-     * @throws InvalidInterfaceException
3298
-     * @access public
3299
-     */
3300
-    public function get_attendees($per_page, $count = false, $trash = false)
3301
-    {
3302
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3303
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3304
-        $ATT_MDL = EEM_Attendee::instance();
3305
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3306
-        switch ($this->_req_data['orderby']) {
3307
-            case 'ATT_ID':
3308
-                $orderby = 'ATT_ID';
3309
-                break;
3310
-            case 'ATT_fname':
3311
-                $orderby = 'ATT_fname';
3312
-                break;
3313
-            case 'ATT_email':
3314
-                $orderby = 'ATT_email';
3315
-                break;
3316
-            case 'ATT_city':
3317
-                $orderby = 'ATT_city';
3318
-                break;
3319
-            case 'STA_ID':
3320
-                $orderby = 'STA_ID';
3321
-                break;
3322
-            case 'CNT_ID':
3323
-                $orderby = 'CNT_ID';
3324
-                break;
3325
-            case 'Registration_Count':
3326
-                $orderby = 'Registration_Count';
3327
-                break;
3328
-            default:
3329
-                $orderby = 'ATT_lname';
3330
-        }
3331
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3332
-            ? $this->_req_data['order']
3333
-            : 'ASC';
3334
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3335
-            ? $this->_req_data['paged']
3336
-            : 1;
3337
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3338
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3339
-            ? $this->_req_data['perpage']
3340
-            : $per_page;
3341
-        $_where = array();
3342
-        if (! empty($this->_req_data['s'])) {
3343
-            $sstr = '%' . $this->_req_data['s'] . '%';
3344
-            $_where['OR'] = array(
3345
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3346
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3347
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3348
-                'ATT_fname'                         => array('LIKE', $sstr),
3349
-                'ATT_lname'                         => array('LIKE', $sstr),
3350
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3351
-                'ATT_email'                         => array('LIKE', $sstr),
3352
-                'ATT_address'                       => array('LIKE', $sstr),
3353
-                'ATT_address2'                      => array('LIKE', $sstr),
3354
-                'ATT_city'                          => array('LIKE', $sstr),
3355
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3356
-                'State.STA_name'                    => array('LIKE', $sstr),
3357
-                'ATT_phone'                         => array('LIKE', $sstr),
3358
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3359
-                'Registration.REG_code'             => array('LIKE', $sstr),
3360
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3361
-            );
3362
-        }
3363
-        $offset = ($current_page - 1) * $per_page;
3364
-        $limit = $count ? null : array($offset, $per_page);
3365
-        $query_args = array(
3366
-            $_where,
3367
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3368
-            'limit'         => $limit,
3369
-        );
3370
-        if (! $count) {
3371
-            $query_args['order_by'] = array($orderby => $sort);
3372
-        }
3373
-        if ($trash) {
3374
-            $query_args[0]['status'] = array('!=', 'publish');
3375
-            $all_attendees = $count
3376
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3377
-                : $ATT_MDL->get_all($query_args);
3378
-        } else {
3379
-            $query_args[0]['status'] = array('IN', array('publish'));
3380
-            $all_attendees = $count
3381
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
-                : $ATT_MDL->get_all($query_args);
3383
-        }
3384
-        return $all_attendees;
3385
-    }
3386
-
3387
-
3388
-    /**
3389
-     * This is just taking care of resending the registration confirmation
3390
-     *
3391
-     * @access protected
3392
-     * @return void
3393
-     */
3394
-    protected function _resend_registration()
3395
-    {
3396
-        $this->_process_resend_registration();
3397
-        $query_args = isset($this->_req_data['redirect_to'])
3398
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3399
-            : array('action' => 'default');
3400
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3401
-    }
3402
-
3403
-    /**
3404
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3405
-     * to use when selecting registrations
3406
-     *
3407
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3408
-     *                                                     the query parameters from the request
3409
-     * @return void ends the request with a redirect or download
3410
-     */
3411
-    public function _registrations_report_base($method_name_for_getting_query_params)
3412
-    {
3413
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3414
-            wp_redirect(
3415
-                EE_Admin_Page::add_query_args_and_nonce(
3416
-                    array(
3417
-                        'page'        => 'espresso_batch',
3418
-                        'batch'       => 'file',
3419
-                        'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3420
-                        'filters'     => urlencode(
3421
-                            serialize(
3422
-                                call_user_func(
3423
-                                    array($this, $method_name_for_getting_query_params),
3424
-                                    EEH_Array::is_set(
3425
-                                        $this->_req_data,
3426
-                                        'filters',
3427
-                                        array()
3428
-                                    )
3429
-                                )
3430
-                            )
3431
-                        ),
3432
-                        'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3433
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3434
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3435
-                    )
3436
-                )
3437
-            );
3438
-        } else {
3439
-            $new_request_args = array(
3440
-                'export' => 'report',
3441
-                'action' => 'registrations_report_for_event',
3442
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3443
-            );
3444
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3445
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3446
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3447
-                $EE_Export = EE_Export::instance($this->_req_data);
3448
-                $EE_Export->export();
3449
-            }
3450
-        }
3451
-    }
3452
-
3453
-
3454
-    /**
3455
-     * Creates a registration report using only query parameters in the request
3456
-     *
3457
-     * @return void
3458
-     */
3459
-    public function _registrations_report()
3460
-    {
3461
-        $this->_registrations_report_base('_get_registration_query_parameters');
3462
-    }
3463
-
3464
-
3465
-    public function _contact_list_export()
3466
-    {
3467
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3468
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3469
-            $EE_Export = EE_Export::instance($this->_req_data);
3470
-            $EE_Export->export_attendees();
3471
-        }
3472
-    }
3473
-
3474
-
3475
-    public function _contact_list_report()
3476
-    {
3477
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3478
-            wp_redirect(
3479
-                EE_Admin_Page::add_query_args_and_nonce(
3480
-                    array(
3481
-                        'page'        => 'espresso_batch',
3482
-                        'batch'       => 'file',
3483
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3484
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3485
-                    )
3486
-                )
3487
-            );
3488
-        } else {
3489
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3490
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3491
-                $EE_Export = EE_Export::instance($this->_req_data);
3492
-                $EE_Export->report_attendees();
3493
-            }
3494
-        }
3495
-    }
3496
-
3497
-
3498
-
3499
-
3500
-
3501
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3502
-    /**
3503
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3504
-     *
3505
-     * @return void
3506
-     * @throws EE_Error
3507
-     * @throws InvalidArgumentException
3508
-     * @throws InvalidDataTypeException
3509
-     * @throws InvalidInterfaceException
3510
-     */
3511
-    protected function _duplicate_attendee()
3512
-    {
3513
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3514
-        // verify we have necessary info
3515
-        if (empty($this->_req_data['_REG_ID'])) {
3516
-            EE_Error::add_error(
3517
-                esc_html__(
3518
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3519
-                    'event_espresso'
3520
-                ),
3521
-                __FILE__,
3522
-                __LINE__,
3523
-                __FUNCTION__
3524
-            );
3525
-            $query_args = array('action' => $action);
3526
-            $this->_redirect_after_action('', '', '', $query_args, true);
3527
-        }
3528
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3529
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3530
-        $attendee = $registration->attendee();
3531
-        // remove relation of existing attendee on registration
3532
-        $registration->_remove_relation_to($attendee, 'Attendee');
3533
-        // new attendee
3534
-        $new_attendee = clone $attendee;
3535
-        $new_attendee->set('ATT_ID', 0);
3536
-        $new_attendee->save();
3537
-        // add new attendee to reg
3538
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3539
-        EE_Error::add_success(
3540
-            esc_html__(
3541
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3542
-                'event_espresso'
3543
-            )
3544
-        );
3545
-        // redirect to edit page for attendee
3546
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3547
-        $this->_redirect_after_action('', '', '', $query_args, true);
3548
-    }
3549
-
3550
-
3551
-    /**
3552
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3553
-     *
3554
-     * @param int     $post_id
3555
-     * @param WP_POST $post
3556
-     * @throws DomainException
3557
-     * @throws EE_Error
3558
-     * @throws InvalidArgumentException
3559
-     * @throws InvalidDataTypeException
3560
-     * @throws InvalidInterfaceException
3561
-     * @throws LogicException
3562
-     * @throws InvalidFormSubmissionException
3563
-     */
3564
-    protected function _insert_update_cpt_item($post_id, $post)
3565
-    {
3566
-        $success = true;
3567
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3568
-            ? EEM_Attendee::instance()->get_one_by_ID($post_id)
3569
-            : null;
3570
-        // for attendee updates
3571
-        if ($attendee instanceof EE_Attendee) {
3572
-            // note we should only be UPDATING attendees at this point.
3573
-            $updated_fields = array(
3574
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3575
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3576
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3577
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3578
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3579
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3580
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3581
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3582
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3583
-            );
3584
-            foreach ($updated_fields as $field => $value) {
3585
-                $attendee->set($field, $value);
3586
-            }
3587
-
3588
-            // process contact details metabox form handler (which will also save the attendee)
3589
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3590
-            $success = $contact_details_form->process($this->_req_data);
3591
-
3592
-            $attendee_update_callbacks = apply_filters(
3593
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3594
-                array()
3595
-            );
3596
-            foreach ($attendee_update_callbacks as $a_callback) {
3597
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3598
-                    throw new EE_Error(
3599
-                        sprintf(
3600
-                            esc_html__(
3601
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3602
-                                'event_espresso'
3603
-                            ),
3604
-                            $a_callback
3605
-                        )
3606
-                    );
3607
-                }
3608
-            }
3609
-        }
3610
-
3611
-        if ($success === false) {
3612
-            EE_Error::add_error(
3613
-                esc_html__(
3614
-                    'Something went wrong with updating the meta table data for the registration.',
3615
-                    'event_espresso'
3616
-                ),
3617
-                __FILE__,
3618
-                __FUNCTION__,
3619
-                __LINE__
3620
-            );
3621
-        }
3622
-    }
3623
-
3624
-
3625
-    public function trash_cpt_item($post_id)
3626
-    {
3627
-    }
3628
-
3629
-
3630
-    public function delete_cpt_item($post_id)
3631
-    {
3632
-    }
3633
-
3634
-
3635
-    public function restore_cpt_item($post_id)
3636
-    {
3637
-    }
3638
-
3639
-
3640
-    protected function _restore_cpt_item($post_id, $revision_id)
3641
-    {
3642
-    }
3643
-
3644
-
3645
-    public function attendee_editor_metaboxes()
3646
-    {
3647
-        $this->verify_cpt_object();
3648
-        remove_meta_box(
3649
-            'postexcerpt',
3650
-            esc_html__('Excerpt', 'event_espresso'),
3651
-            'post_excerpt_meta_box',
3652
-            $this->_cpt_routes[ $this->_req_action ],
3653
-            'normal',
3654
-            'core'
3655
-        );
3656
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3657
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3658
-            add_meta_box(
3659
-                'postexcerpt',
3660
-                esc_html__('Short Biography', 'event_espresso'),
3661
-                'post_excerpt_meta_box',
3662
-                $this->_cpt_routes[ $this->_req_action ],
3663
-                'normal'
3664
-            );
3665
-        }
3666
-        if (post_type_supports('espresso_attendees', 'comments')) {
3667
-            add_meta_box(
3668
-                'commentsdiv',
3669
-                esc_html__('Notes on the Contact', 'event_espresso'),
3670
-                'post_comment_meta_box',
3671
-                $this->_cpt_routes[ $this->_req_action ],
3672
-                'normal',
3673
-                'core'
3674
-            );
3675
-        }
3676
-        add_meta_box(
3677
-            'attendee_contact_info',
3678
-            esc_html__('Contact Info', 'event_espresso'),
3679
-            array($this, 'attendee_contact_info'),
3680
-            $this->_cpt_routes[ $this->_req_action ],
3681
-            'side',
3682
-            'core'
3683
-        );
3684
-        add_meta_box(
3685
-            'attendee_details_address',
3686
-            esc_html__('Address Details', 'event_espresso'),
3687
-            array($this, 'attendee_address_details'),
3688
-            $this->_cpt_routes[ $this->_req_action ],
3689
-            'normal',
3690
-            'core'
3691
-        );
3692
-        add_meta_box(
3693
-            'attendee_registrations',
3694
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3695
-            array($this, 'attendee_registrations_meta_box'),
3696
-            $this->_cpt_routes[ $this->_req_action ],
3697
-            'normal',
3698
-            'high'
3699
-        );
3700
-    }
3701
-
3702
-
3703
-    /**
3704
-     * Metabox for attendee contact info
3705
-     *
3706
-     * @param  WP_Post $post wp post object
3707
-     * @return string attendee contact info ( and form )
3708
-     * @throws EE_Error
3709
-     * @throws InvalidArgumentException
3710
-     * @throws InvalidDataTypeException
3711
-     * @throws InvalidInterfaceException
3712
-     * @throws LogicException
3713
-     * @throws DomainException
3714
-     */
3715
-    public function attendee_contact_info($post)
3716
-    {
3717
-        // get attendee object ( should already have it )
3718
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3719
-        $form->enqueueStylesAndScripts();
3720
-        echo $form->display();
3721
-    }
3722
-
3723
-
3724
-    /**
3725
-     * Return form handler for the contact details metabox
3726
-     *
3727
-     * @param EE_Attendee $attendee
3728
-     * @return AttendeeContactDetailsMetaboxFormHandler
3729
-     * @throws DomainException
3730
-     * @throws InvalidArgumentException
3731
-     * @throws InvalidDataTypeException
3732
-     * @throws InvalidInterfaceException
3733
-     */
3734
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3735
-    {
3736
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3737
-    }
3738
-
3739
-
3740
-    /**
3741
-     * Metabox for attendee details
3742
-     *
3743
-     * @param  WP_Post $post wp post object
3744
-     * @throws DomainException
3745
-     */
3746
-    public function attendee_address_details($post)
3747
-    {
3748
-        // get attendee object (should already have it)
3749
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3750
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3751
-            new EE_Question_Form_Input(
3752
-                EE_Question::new_instance(
3753
-                    array(
3754
-                        'QST_ID'           => 0,
3755
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3756
-                        'QST_system'       => 'admin-state',
3757
-                    )
3758
-                ),
3759
-                EE_Answer::new_instance(
3760
-                    array(
3761
-                        'ANS_ID'    => 0,
3762
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3763
-                    )
3764
-                ),
3765
-                array(
3766
-                    'input_id'       => 'STA_ID',
3767
-                    'input_name'     => 'STA_ID',
3768
-                    'input_prefix'   => '',
3769
-                    'append_qstn_id' => false,
3770
-                )
3771
-            )
3772
-        );
3773
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3774
-            new EE_Question_Form_Input(
3775
-                EE_Question::new_instance(
3776
-                    array(
3777
-                        'QST_ID'           => 0,
3778
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3779
-                        'QST_system'       => 'admin-country',
3780
-                    )
3781
-                ),
3782
-                EE_Answer::new_instance(
3783
-                    array(
3784
-                        'ANS_ID'    => 0,
3785
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3786
-                    )
3787
-                ),
3788
-                array(
3789
-                    'input_id'       => 'CNT_ISO',
3790
-                    'input_name'     => 'CNT_ISO',
3791
-                    'input_prefix'   => '',
3792
-                    'append_qstn_id' => false,
3793
-                )
3794
-            )
3795
-        );
3796
-        $template =
3797
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3798
-        EEH_Template::display_template($template, $this->_template_args);
3799
-    }
3800
-
3801
-
3802
-    /**
3803
-     *        _attendee_details
3804
-     *
3805
-     * @access protected
3806
-     * @param $post
3807
-     * @return void
3808
-     * @throws DomainException
3809
-     * @throws EE_Error
3810
-     */
3811
-    public function attendee_registrations_meta_box($post)
3812
-    {
3813
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3814
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3815
-        $template =
3816
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3817
-        EEH_Template::display_template($template, $this->_template_args);
3818
-    }
3819
-
3820
-
3821
-    /**
3822
-     * add in the form fields for the attendee edit
3823
-     *
3824
-     * @param  WP_Post $post wp post object
3825
-     * @return string html for new form.
3826
-     * @throws DomainException
3827
-     */
3828
-    public function after_title_form_fields($post)
3829
-    {
3830
-        if ($post->post_type == 'espresso_attendees') {
3831
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3832
-            $template_args['attendee'] = $this->_cpt_model_obj;
3833
-            EEH_Template::display_template($template, $template_args);
3834
-        }
3835
-    }
3836
-
3837
-
3838
-    /**
3839
-     *        _trash_or_restore_attendee
3840
-     *
3841
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3842
-     * @return void
3843
-     * @throws EE_Error
3844
-     * @throws InvalidArgumentException
3845
-     * @throws InvalidDataTypeException
3846
-     * @throws InvalidInterfaceException
3847
-     * @access protected
3848
-     */
3849
-    protected function _trash_or_restore_attendees($trash = true)
3850
-    {
3851
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3852
-        $ATT_MDL = EEM_Attendee::instance();
3853
-        $success = 1;
3854
-        // Checkboxes
3855
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3856
-            // if array has more than one element than success message should be plural
3857
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3858
-            // cycle thru checkboxes
3859
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3860
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3861
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3862
-                if (! $updated) {
3863
-                    $success = 0;
3864
-                }
3865
-            }
3866
-        } else {
3867
-            // grab single id and delete
3868
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3869
-            // get attendee
3870
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3871
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3872
-            $updated = $att->save();
3873
-            if (! $updated) {
3874
-                $success = 0;
3875
-            }
3876
-        }
3877
-        $what = $success > 1
3878
-            ? esc_html__('Contacts', 'event_espresso')
3879
-            : esc_html__('Contact', 'event_espresso');
3880
-        $action_desc = $trash
3881
-            ? esc_html__('moved to the trash', 'event_espresso')
3882
-            : esc_html__('restored', 'event_espresso');
3883
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3884
-    }
3034
+		}
3035
+		$template_args = array(
3036
+			'title'                    => '',
3037
+			'content'                  => '',
3038
+			'step_button_text'         => '',
3039
+			'show_notification_toggle' => false,
3040
+		);
3041
+		// to indicate we're processing a new registration
3042
+		$hidden_fields = array(
3043
+			'processing_registration' => array(
3044
+				'type'  => 'hidden',
3045
+				'value' => 0,
3046
+			),
3047
+			'event_id'                => array(
3048
+				'type'  => 'hidden',
3049
+				'value' => $this->_reg_event->ID(),
3050
+			),
3051
+		);
3052
+		// if the cart is empty then we know we're at step one so we'll display ticket selector
3053
+		$cart = EE_Registry::instance()->SSN->cart();
3054
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3055
+		switch ($step) {
3056
+			case 'ticket':
3057
+				$hidden_fields['processing_registration']['value'] = 1;
3058
+				$template_args['title'] = esc_html__(
3059
+					'Step One: Select the Ticket for this registration',
3060
+					'event_espresso'
3061
+				);
3062
+				$template_args['content'] =
3063
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3064
+				$template_args['step_button_text'] = esc_html__(
3065
+					'Add Tickets and Continue to Registrant Details',
3066
+					'event_espresso'
3067
+				);
3068
+				$template_args['show_notification_toggle'] = false;
3069
+				break;
3070
+			case 'questions':
3071
+				$hidden_fields['processing_registration']['value'] = 2;
3072
+				$template_args['title'] = esc_html__(
3073
+					'Step Two: Add Registrant Details for this Registration',
3074
+					'event_espresso'
3075
+				);
3076
+				// in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3077
+				// properly by the first process_reg_step run.
3078
+				$template_args['content'] =
3079
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
3080
+				$template_args['step_button_text'] = esc_html__(
3081
+					'Save Registration and Continue to Details',
3082
+					'event_espresso'
3083
+				);
3084
+				$template_args['show_notification_toggle'] = true;
3085
+				break;
3086
+		}
3087
+		// we come back to the process_registration_step route.
3088
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3089
+		return EEH_Template::display_template(
3090
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3091
+			$template_args,
3092
+			true
3093
+		);
3094
+	}
3095
+
3096
+
3097
+	/**
3098
+	 *        set_reg_event
3099
+	 *
3100
+	 * @access private
3101
+	 * @return bool
3102
+	 * @throws EE_Error
3103
+	 * @throws InvalidArgumentException
3104
+	 * @throws InvalidDataTypeException
3105
+	 * @throws InvalidInterfaceException
3106
+	 */
3107
+	private function _set_reg_event()
3108
+	{
3109
+		if (is_object($this->_reg_event)) {
3110
+			return true;
3111
+		}
3112
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3113
+		if (! $EVT_ID) {
3114
+			return false;
3115
+		}
3116
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3117
+		return true;
3118
+	}
3119
+
3120
+
3121
+	/**
3122
+	 * process_reg_step
3123
+	 *
3124
+	 * @access        public
3125
+	 * @return string
3126
+	 * @throws DomainException
3127
+	 * @throws EE_Error
3128
+	 * @throws InvalidArgumentException
3129
+	 * @throws InvalidDataTypeException
3130
+	 * @throws InvalidInterfaceException
3131
+	 * @throws ReflectionException
3132
+	 * @throws RuntimeException
3133
+	 */
3134
+	public function process_reg_step()
3135
+	{
3136
+		EE_System::do_not_cache();
3137
+		$this->_set_reg_event();
3138
+		EE_Registry::instance()->REQ->set_espresso_page(true);
3139
+		EE_Registry::instance()->REQ->set('uts', time());
3140
+		// what step are we on?
3141
+		$cart = EE_Registry::instance()->SSN->cart();
3142
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3143
+		// if doing ajax then we need to verify the nonce
3144
+		if (defined('DOING_AJAX')) {
3145
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
3146
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3147
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3148
+		}
3149
+		switch ($step) {
3150
+			case 'ticket':
3151
+				// process ticket selection
3152
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3153
+				if ($success) {
3154
+					EE_Error::add_success(
3155
+						esc_html__(
3156
+							'Tickets Selected. Now complete the registration.',
3157
+							'event_espresso'
3158
+						)
3159
+					);
3160
+				} else {
3161
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3162
+				}
3163
+				if (defined('DOING_AJAX')) {
3164
+					$this->new_registration(); // display next step
3165
+				} else {
3166
+					$query_args = array(
3167
+						'action'                  => 'new_registration',
3168
+						'processing_registration' => 1,
3169
+						'event_id'                => $this->_reg_event->ID(),
3170
+						'uts'                     => time(),
3171
+					);
3172
+					$this->_redirect_after_action(
3173
+						false,
3174
+						'',
3175
+						'',
3176
+						$query_args,
3177
+						true
3178
+					);
3179
+				}
3180
+				break;
3181
+			case 'questions':
3182
+				if (! isset(
3183
+					$this->_req_data['txn_reg_status_change'],
3184
+					$this->_req_data['txn_reg_status_change']['send_notifications']
3185
+				)
3186
+				) {
3187
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3188
+				}
3189
+				// process registration
3190
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3191
+				if ($cart instanceof EE_Cart) {
3192
+					$grand_total = $cart->get_cart_grand_total();
3193
+					if ($grand_total instanceof EE_Line_Item) {
3194
+						$grand_total->save_this_and_descendants_to_txn();
3195
+					}
3196
+				}
3197
+				if (! $transaction instanceof EE_Transaction) {
3198
+					$query_args = array(
3199
+						'action'                  => 'new_registration',
3200
+						'processing_registration' => 2,
3201
+						'event_id'                => $this->_reg_event->ID(),
3202
+						'uts'                     => time(),
3203
+					);
3204
+					if (defined('DOING_AJAX')) {
3205
+						// display registration form again because there are errors (maybe validation?)
3206
+						$this->new_registration();
3207
+						return;
3208
+					} else {
3209
+						$this->_redirect_after_action(
3210
+							false,
3211
+							'',
3212
+							'',
3213
+							$query_args,
3214
+							true
3215
+						);
3216
+						return;
3217
+					}
3218
+				}
3219
+				// maybe update status, and make sure to save transaction if not done already
3220
+				if (! $transaction->update_status_based_on_total_paid()) {
3221
+					$transaction->save();
3222
+				}
3223
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3224
+				$this->_req_data = array();
3225
+				$query_args = array(
3226
+					'action'        => 'redirect_to_txn',
3227
+					'TXN_ID'        => $transaction->ID(),
3228
+					'EVT_ID'        => $this->_reg_event->ID(),
3229
+					'event_name'    => urlencode($this->_reg_event->name()),
3230
+					'redirect_from' => 'new_registration',
3231
+				);
3232
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3233
+				break;
3234
+		}
3235
+		// what are you looking here for?  Should be nothing to do at this point.
3236
+	}
3237
+
3238
+
3239
+	/**
3240
+	 * redirect_to_txn
3241
+	 *
3242
+	 * @access public
3243
+	 * @return void
3244
+	 * @throws EE_Error
3245
+	 * @throws InvalidArgumentException
3246
+	 * @throws InvalidDataTypeException
3247
+	 * @throws InvalidInterfaceException
3248
+	 */
3249
+	public function redirect_to_txn()
3250
+	{
3251
+		EE_System::do_not_cache();
3252
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3253
+		$query_args = array(
3254
+			'action' => 'view_transaction',
3255
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3256
+			'page'   => 'espresso_transactions',
3257
+		);
3258
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3259
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3260
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
3261
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3262
+		}
3263
+		EE_Error::add_success(
3264
+			esc_html__(
3265
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3266
+				'event_espresso'
3267
+			)
3268
+		);
3269
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3270
+	}
3271
+
3272
+
3273
+	/**
3274
+	 *        generates HTML for the Attendee Contact List
3275
+	 *
3276
+	 * @access protected
3277
+	 * @return void
3278
+	 */
3279
+	protected function _attendee_contact_list_table()
3280
+	{
3281
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3282
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3283
+		$this->display_admin_list_table_page_with_no_sidebar();
3284
+	}
3285
+
3286
+
3287
+	/**
3288
+	 *        get_attendees
3289
+	 *
3290
+	 * @param      $per_page
3291
+	 * @param bool $count whether to return count or data.
3292
+	 * @param bool $trash
3293
+	 * @return array
3294
+	 * @throws EE_Error
3295
+	 * @throws InvalidArgumentException
3296
+	 * @throws InvalidDataTypeException
3297
+	 * @throws InvalidInterfaceException
3298
+	 * @access public
3299
+	 */
3300
+	public function get_attendees($per_page, $count = false, $trash = false)
3301
+	{
3302
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3303
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3304
+		$ATT_MDL = EEM_Attendee::instance();
3305
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3306
+		switch ($this->_req_data['orderby']) {
3307
+			case 'ATT_ID':
3308
+				$orderby = 'ATT_ID';
3309
+				break;
3310
+			case 'ATT_fname':
3311
+				$orderby = 'ATT_fname';
3312
+				break;
3313
+			case 'ATT_email':
3314
+				$orderby = 'ATT_email';
3315
+				break;
3316
+			case 'ATT_city':
3317
+				$orderby = 'ATT_city';
3318
+				break;
3319
+			case 'STA_ID':
3320
+				$orderby = 'STA_ID';
3321
+				break;
3322
+			case 'CNT_ID':
3323
+				$orderby = 'CNT_ID';
3324
+				break;
3325
+			case 'Registration_Count':
3326
+				$orderby = 'Registration_Count';
3327
+				break;
3328
+			default:
3329
+				$orderby = 'ATT_lname';
3330
+		}
3331
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3332
+			? $this->_req_data['order']
3333
+			: 'ASC';
3334
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3335
+			? $this->_req_data['paged']
3336
+			: 1;
3337
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3338
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3339
+			? $this->_req_data['perpage']
3340
+			: $per_page;
3341
+		$_where = array();
3342
+		if (! empty($this->_req_data['s'])) {
3343
+			$sstr = '%' . $this->_req_data['s'] . '%';
3344
+			$_where['OR'] = array(
3345
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3346
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3347
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3348
+				'ATT_fname'                         => array('LIKE', $sstr),
3349
+				'ATT_lname'                         => array('LIKE', $sstr),
3350
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3351
+				'ATT_email'                         => array('LIKE', $sstr),
3352
+				'ATT_address'                       => array('LIKE', $sstr),
3353
+				'ATT_address2'                      => array('LIKE', $sstr),
3354
+				'ATT_city'                          => array('LIKE', $sstr),
3355
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3356
+				'State.STA_name'                    => array('LIKE', $sstr),
3357
+				'ATT_phone'                         => array('LIKE', $sstr),
3358
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3359
+				'Registration.REG_code'             => array('LIKE', $sstr),
3360
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3361
+			);
3362
+		}
3363
+		$offset = ($current_page - 1) * $per_page;
3364
+		$limit = $count ? null : array($offset, $per_page);
3365
+		$query_args = array(
3366
+			$_where,
3367
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3368
+			'limit'         => $limit,
3369
+		);
3370
+		if (! $count) {
3371
+			$query_args['order_by'] = array($orderby => $sort);
3372
+		}
3373
+		if ($trash) {
3374
+			$query_args[0]['status'] = array('!=', 'publish');
3375
+			$all_attendees = $count
3376
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3377
+				: $ATT_MDL->get_all($query_args);
3378
+		} else {
3379
+			$query_args[0]['status'] = array('IN', array('publish'));
3380
+			$all_attendees = $count
3381
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
+				: $ATT_MDL->get_all($query_args);
3383
+		}
3384
+		return $all_attendees;
3385
+	}
3386
+
3387
+
3388
+	/**
3389
+	 * This is just taking care of resending the registration confirmation
3390
+	 *
3391
+	 * @access protected
3392
+	 * @return void
3393
+	 */
3394
+	protected function _resend_registration()
3395
+	{
3396
+		$this->_process_resend_registration();
3397
+		$query_args = isset($this->_req_data['redirect_to'])
3398
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3399
+			: array('action' => 'default');
3400
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3401
+	}
3402
+
3403
+	/**
3404
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3405
+	 * to use when selecting registrations
3406
+	 *
3407
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3408
+	 *                                                     the query parameters from the request
3409
+	 * @return void ends the request with a redirect or download
3410
+	 */
3411
+	public function _registrations_report_base($method_name_for_getting_query_params)
3412
+	{
3413
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3414
+			wp_redirect(
3415
+				EE_Admin_Page::add_query_args_and_nonce(
3416
+					array(
3417
+						'page'        => 'espresso_batch',
3418
+						'batch'       => 'file',
3419
+						'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3420
+						'filters'     => urlencode(
3421
+							serialize(
3422
+								call_user_func(
3423
+									array($this, $method_name_for_getting_query_params),
3424
+									EEH_Array::is_set(
3425
+										$this->_req_data,
3426
+										'filters',
3427
+										array()
3428
+									)
3429
+								)
3430
+							)
3431
+						),
3432
+						'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3433
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3434
+						'return_url'  => urlencode($this->_req_data['return_url']),
3435
+					)
3436
+				)
3437
+			);
3438
+		} else {
3439
+			$new_request_args = array(
3440
+				'export' => 'report',
3441
+				'action' => 'registrations_report_for_event',
3442
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3443
+			);
3444
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3445
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3446
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3447
+				$EE_Export = EE_Export::instance($this->_req_data);
3448
+				$EE_Export->export();
3449
+			}
3450
+		}
3451
+	}
3452
+
3453
+
3454
+	/**
3455
+	 * Creates a registration report using only query parameters in the request
3456
+	 *
3457
+	 * @return void
3458
+	 */
3459
+	public function _registrations_report()
3460
+	{
3461
+		$this->_registrations_report_base('_get_registration_query_parameters');
3462
+	}
3463
+
3464
+
3465
+	public function _contact_list_export()
3466
+	{
3467
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3468
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3469
+			$EE_Export = EE_Export::instance($this->_req_data);
3470
+			$EE_Export->export_attendees();
3471
+		}
3472
+	}
3473
+
3474
+
3475
+	public function _contact_list_report()
3476
+	{
3477
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3478
+			wp_redirect(
3479
+				EE_Admin_Page::add_query_args_and_nonce(
3480
+					array(
3481
+						'page'        => 'espresso_batch',
3482
+						'batch'       => 'file',
3483
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3484
+						'return_url'  => urlencode($this->_req_data['return_url']),
3485
+					)
3486
+				)
3487
+			);
3488
+		} else {
3489
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3490
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3491
+				$EE_Export = EE_Export::instance($this->_req_data);
3492
+				$EE_Export->report_attendees();
3493
+			}
3494
+		}
3495
+	}
3496
+
3497
+
3498
+
3499
+
3500
+
3501
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3502
+	/**
3503
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3504
+	 *
3505
+	 * @return void
3506
+	 * @throws EE_Error
3507
+	 * @throws InvalidArgumentException
3508
+	 * @throws InvalidDataTypeException
3509
+	 * @throws InvalidInterfaceException
3510
+	 */
3511
+	protected function _duplicate_attendee()
3512
+	{
3513
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3514
+		// verify we have necessary info
3515
+		if (empty($this->_req_data['_REG_ID'])) {
3516
+			EE_Error::add_error(
3517
+				esc_html__(
3518
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3519
+					'event_espresso'
3520
+				),
3521
+				__FILE__,
3522
+				__LINE__,
3523
+				__FUNCTION__
3524
+			);
3525
+			$query_args = array('action' => $action);
3526
+			$this->_redirect_after_action('', '', '', $query_args, true);
3527
+		}
3528
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3529
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3530
+		$attendee = $registration->attendee();
3531
+		// remove relation of existing attendee on registration
3532
+		$registration->_remove_relation_to($attendee, 'Attendee');
3533
+		// new attendee
3534
+		$new_attendee = clone $attendee;
3535
+		$new_attendee->set('ATT_ID', 0);
3536
+		$new_attendee->save();
3537
+		// add new attendee to reg
3538
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3539
+		EE_Error::add_success(
3540
+			esc_html__(
3541
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3542
+				'event_espresso'
3543
+			)
3544
+		);
3545
+		// redirect to edit page for attendee
3546
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3547
+		$this->_redirect_after_action('', '', '', $query_args, true);
3548
+	}
3549
+
3550
+
3551
+	/**
3552
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3553
+	 *
3554
+	 * @param int     $post_id
3555
+	 * @param WP_POST $post
3556
+	 * @throws DomainException
3557
+	 * @throws EE_Error
3558
+	 * @throws InvalidArgumentException
3559
+	 * @throws InvalidDataTypeException
3560
+	 * @throws InvalidInterfaceException
3561
+	 * @throws LogicException
3562
+	 * @throws InvalidFormSubmissionException
3563
+	 */
3564
+	protected function _insert_update_cpt_item($post_id, $post)
3565
+	{
3566
+		$success = true;
3567
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3568
+			? EEM_Attendee::instance()->get_one_by_ID($post_id)
3569
+			: null;
3570
+		// for attendee updates
3571
+		if ($attendee instanceof EE_Attendee) {
3572
+			// note we should only be UPDATING attendees at this point.
3573
+			$updated_fields = array(
3574
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3575
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3576
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3577
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3578
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3579
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3580
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3581
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3582
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3583
+			);
3584
+			foreach ($updated_fields as $field => $value) {
3585
+				$attendee->set($field, $value);
3586
+			}
3587
+
3588
+			// process contact details metabox form handler (which will also save the attendee)
3589
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3590
+			$success = $contact_details_form->process($this->_req_data);
3591
+
3592
+			$attendee_update_callbacks = apply_filters(
3593
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3594
+				array()
3595
+			);
3596
+			foreach ($attendee_update_callbacks as $a_callback) {
3597
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3598
+					throw new EE_Error(
3599
+						sprintf(
3600
+							esc_html__(
3601
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3602
+								'event_espresso'
3603
+							),
3604
+							$a_callback
3605
+						)
3606
+					);
3607
+				}
3608
+			}
3609
+		}
3610
+
3611
+		if ($success === false) {
3612
+			EE_Error::add_error(
3613
+				esc_html__(
3614
+					'Something went wrong with updating the meta table data for the registration.',
3615
+					'event_espresso'
3616
+				),
3617
+				__FILE__,
3618
+				__FUNCTION__,
3619
+				__LINE__
3620
+			);
3621
+		}
3622
+	}
3623
+
3624
+
3625
+	public function trash_cpt_item($post_id)
3626
+	{
3627
+	}
3628
+
3629
+
3630
+	public function delete_cpt_item($post_id)
3631
+	{
3632
+	}
3633
+
3634
+
3635
+	public function restore_cpt_item($post_id)
3636
+	{
3637
+	}
3638
+
3639
+
3640
+	protected function _restore_cpt_item($post_id, $revision_id)
3641
+	{
3642
+	}
3643
+
3644
+
3645
+	public function attendee_editor_metaboxes()
3646
+	{
3647
+		$this->verify_cpt_object();
3648
+		remove_meta_box(
3649
+			'postexcerpt',
3650
+			esc_html__('Excerpt', 'event_espresso'),
3651
+			'post_excerpt_meta_box',
3652
+			$this->_cpt_routes[ $this->_req_action ],
3653
+			'normal',
3654
+			'core'
3655
+		);
3656
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3657
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3658
+			add_meta_box(
3659
+				'postexcerpt',
3660
+				esc_html__('Short Biography', 'event_espresso'),
3661
+				'post_excerpt_meta_box',
3662
+				$this->_cpt_routes[ $this->_req_action ],
3663
+				'normal'
3664
+			);
3665
+		}
3666
+		if (post_type_supports('espresso_attendees', 'comments')) {
3667
+			add_meta_box(
3668
+				'commentsdiv',
3669
+				esc_html__('Notes on the Contact', 'event_espresso'),
3670
+				'post_comment_meta_box',
3671
+				$this->_cpt_routes[ $this->_req_action ],
3672
+				'normal',
3673
+				'core'
3674
+			);
3675
+		}
3676
+		add_meta_box(
3677
+			'attendee_contact_info',
3678
+			esc_html__('Contact Info', 'event_espresso'),
3679
+			array($this, 'attendee_contact_info'),
3680
+			$this->_cpt_routes[ $this->_req_action ],
3681
+			'side',
3682
+			'core'
3683
+		);
3684
+		add_meta_box(
3685
+			'attendee_details_address',
3686
+			esc_html__('Address Details', 'event_espresso'),
3687
+			array($this, 'attendee_address_details'),
3688
+			$this->_cpt_routes[ $this->_req_action ],
3689
+			'normal',
3690
+			'core'
3691
+		);
3692
+		add_meta_box(
3693
+			'attendee_registrations',
3694
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3695
+			array($this, 'attendee_registrations_meta_box'),
3696
+			$this->_cpt_routes[ $this->_req_action ],
3697
+			'normal',
3698
+			'high'
3699
+		);
3700
+	}
3701
+
3702
+
3703
+	/**
3704
+	 * Metabox for attendee contact info
3705
+	 *
3706
+	 * @param  WP_Post $post wp post object
3707
+	 * @return string attendee contact info ( and form )
3708
+	 * @throws EE_Error
3709
+	 * @throws InvalidArgumentException
3710
+	 * @throws InvalidDataTypeException
3711
+	 * @throws InvalidInterfaceException
3712
+	 * @throws LogicException
3713
+	 * @throws DomainException
3714
+	 */
3715
+	public function attendee_contact_info($post)
3716
+	{
3717
+		// get attendee object ( should already have it )
3718
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3719
+		$form->enqueueStylesAndScripts();
3720
+		echo $form->display();
3721
+	}
3722
+
3723
+
3724
+	/**
3725
+	 * Return form handler for the contact details metabox
3726
+	 *
3727
+	 * @param EE_Attendee $attendee
3728
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3729
+	 * @throws DomainException
3730
+	 * @throws InvalidArgumentException
3731
+	 * @throws InvalidDataTypeException
3732
+	 * @throws InvalidInterfaceException
3733
+	 */
3734
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3735
+	{
3736
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3737
+	}
3738
+
3739
+
3740
+	/**
3741
+	 * Metabox for attendee details
3742
+	 *
3743
+	 * @param  WP_Post $post wp post object
3744
+	 * @throws DomainException
3745
+	 */
3746
+	public function attendee_address_details($post)
3747
+	{
3748
+		// get attendee object (should already have it)
3749
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3750
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3751
+			new EE_Question_Form_Input(
3752
+				EE_Question::new_instance(
3753
+					array(
3754
+						'QST_ID'           => 0,
3755
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3756
+						'QST_system'       => 'admin-state',
3757
+					)
3758
+				),
3759
+				EE_Answer::new_instance(
3760
+					array(
3761
+						'ANS_ID'    => 0,
3762
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3763
+					)
3764
+				),
3765
+				array(
3766
+					'input_id'       => 'STA_ID',
3767
+					'input_name'     => 'STA_ID',
3768
+					'input_prefix'   => '',
3769
+					'append_qstn_id' => false,
3770
+				)
3771
+			)
3772
+		);
3773
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3774
+			new EE_Question_Form_Input(
3775
+				EE_Question::new_instance(
3776
+					array(
3777
+						'QST_ID'           => 0,
3778
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3779
+						'QST_system'       => 'admin-country',
3780
+					)
3781
+				),
3782
+				EE_Answer::new_instance(
3783
+					array(
3784
+						'ANS_ID'    => 0,
3785
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3786
+					)
3787
+				),
3788
+				array(
3789
+					'input_id'       => 'CNT_ISO',
3790
+					'input_name'     => 'CNT_ISO',
3791
+					'input_prefix'   => '',
3792
+					'append_qstn_id' => false,
3793
+				)
3794
+			)
3795
+		);
3796
+		$template =
3797
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3798
+		EEH_Template::display_template($template, $this->_template_args);
3799
+	}
3800
+
3801
+
3802
+	/**
3803
+	 *        _attendee_details
3804
+	 *
3805
+	 * @access protected
3806
+	 * @param $post
3807
+	 * @return void
3808
+	 * @throws DomainException
3809
+	 * @throws EE_Error
3810
+	 */
3811
+	public function attendee_registrations_meta_box($post)
3812
+	{
3813
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3814
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3815
+		$template =
3816
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3817
+		EEH_Template::display_template($template, $this->_template_args);
3818
+	}
3819
+
3820
+
3821
+	/**
3822
+	 * add in the form fields for the attendee edit
3823
+	 *
3824
+	 * @param  WP_Post $post wp post object
3825
+	 * @return string html for new form.
3826
+	 * @throws DomainException
3827
+	 */
3828
+	public function after_title_form_fields($post)
3829
+	{
3830
+		if ($post->post_type == 'espresso_attendees') {
3831
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3832
+			$template_args['attendee'] = $this->_cpt_model_obj;
3833
+			EEH_Template::display_template($template, $template_args);
3834
+		}
3835
+	}
3836
+
3837
+
3838
+	/**
3839
+	 *        _trash_or_restore_attendee
3840
+	 *
3841
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3842
+	 * @return void
3843
+	 * @throws EE_Error
3844
+	 * @throws InvalidArgumentException
3845
+	 * @throws InvalidDataTypeException
3846
+	 * @throws InvalidInterfaceException
3847
+	 * @access protected
3848
+	 */
3849
+	protected function _trash_or_restore_attendees($trash = true)
3850
+	{
3851
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3852
+		$ATT_MDL = EEM_Attendee::instance();
3853
+		$success = 1;
3854
+		// Checkboxes
3855
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3856
+			// if array has more than one element than success message should be plural
3857
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3858
+			// cycle thru checkboxes
3859
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3860
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3861
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3862
+				if (! $updated) {
3863
+					$success = 0;
3864
+				}
3865
+			}
3866
+		} else {
3867
+			// grab single id and delete
3868
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3869
+			// get attendee
3870
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
3871
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3872
+			$updated = $att->save();
3873
+			if (! $updated) {
3874
+				$success = 0;
3875
+			}
3876
+		}
3877
+		$what = $success > 1
3878
+			? esc_html__('Contacts', 'event_espresso')
3879
+			: esc_html__('Contact', 'event_espresso');
3880
+		$action_desc = $trash
3881
+			? esc_html__('moved to the trash', 'event_espresso')
3882
+			: esc_html__('restored', 'event_espresso');
3883
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3884
+	}
3885 3885
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.002');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.002');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.