Completed
Branch BUG-10202-persistent-admin-not... (e0303c)
by
unknown
19:00 queued 08:37
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +1335 added lines, -1335 removed lines patch added patch discarded remove patch
@@ -17,1343 +17,1343 @@
 block discarded – undo
17 17
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
18 18
 {
19 19
 
20
-    /**
21
-     * @type bool $_print_copy_info
22
-     */
23
-    private $_print_copy_info = false;
24
-
25
-    /**
26
-     * @type array $_attendee_data
27
-     */
28
-    private $_attendee_data = array();
29
-
30
-    /**
31
-     * @type array $_required_questions
32
-     */
33
-    private $_required_questions = array();
34
-
35
-    /**
36
-     * @type array $_registration_answers
37
-     */
38
-    private $_registration_answers = array();
39
-
40
-
41
-    /**
42
-     *    class constructor
43
-     *
44
-     * @access    public
45
-     * @param    EE_Checkout $checkout
46
-     */
47
-    public function __construct(EE_Checkout $checkout)
48
-    {
49
-        $this->_slug     = 'attendee_information';
50
-        $this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
52
-        $this->checkout  = $checkout;
53
-        $this->_reset_success_message();
54
-        $this->set_instructions(
55
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
56
-        );
57
-    }
58
-
59
-
60
-    public function translate_js_strings()
61
-    {
62
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
63
-            ' is a required question.',
64
-            'event_espresso'
65
-        );
66
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
67
-            ' is a required question. Please enter a value for at least one of the options.',
68
-            'event_espresso'
69
-        );
70
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
71
-            'Please answer all required questions correctly before proceeding.',
72
-            'event_espresso'
73
-        );
74
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
75
-            esc_html__(
76
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77
-                'event_espresso'
78
-            ),
79
-            '<br/>'
80
-        );
81
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
82
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83
-            'event_espresso'
84
-        );
85
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
86
-            'You must enter a valid email address.',
87
-            'event_espresso'
88
-        );
89
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
90
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
91
-            'event_espresso'
92
-        );
93
-    }
94
-
95
-
96
-    public function enqueue_styles_and_scripts()
97
-    {
98
-    }
99
-
100
-
101
-    /**
102
-     * @return boolean
103
-     */
104
-    public function initialize_reg_step()
105
-    {
106
-        return true;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return EE_Form_Section_Proper
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
115
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
116
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
117
-     */
118
-    public function generate_reg_form()
119
-    {
120
-        $this->_print_copy_info = false;
121
-        $primary_registrant     = null;
122
-        // autoload Line_Item_Display classes
123
-        EEH_Autoloader::register_line_item_display_autoloaders();
124
-        $Line_Item_Display = new EE_Line_Item_Display();
125
-        // calculate taxes
126
-        $Line_Item_Display->display_line_item(
127
-            $this->checkout->cart->get_grand_total(),
128
-            array('set_tax_rate' => true)
129
-        );
130
-        /** @var $subsections EE_Form_Section_Proper[] */
131
-        $subsections   = array(
132
-            'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
133
-        );
134
-        $template_args = array(
135
-            'revisit'       => $this->checkout->revisit,
136
-            'registrations' => array(),
137
-            'ticket_count'  => array(),
138
-        );
139
-        // grab the saved registrations from the transaction
140
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
141
-        if ($registrations) {
142
-            foreach ($registrations as $registration) {
143
-                // can this registration be processed during this visit ?
144
-                if ($registration instanceof EE_Registration
145
-                    && $this->checkout->visit_allows_processing_of_this_registration($registration)
146
-                ) {
147
-                    $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
-                    if (! $this->checkout->admin_request) {
149
-                        $template_args['registrations'][$registration->reg_url_link()]    = $registration;
150
-                        $template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151
-                            $template_args['ticket_count'][$registration->ticket()->ID()]
152
-                        )
153
-                            ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
154
-                            : 1;
155
-                        $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
156
-                            $this->checkout->cart->get_grand_total(),
157
-                            'Ticket',
158
-                            array($registration->ticket()->ID())
159
-                        );
160
-                        $ticket_line_item = is_array($ticket_line_item)
161
-                            ? reset($ticket_line_item)
162
-                            : $ticket_line_item;
163
-                        $template_args['ticket_line_item'][$registration->ticket()->ID()] =
164
-                            $Line_Item_Display->display_line_item($ticket_line_item);
165
-                    }
166
-                    if ($registration->is_primary_registrant()) {
167
-                        $primary_registrant = $registration->reg_url_link();
168
-                    }
169
-                }
170
-            }
171
-            // print_copy_info ?
172
-            if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
173
-                // TODO: add admin option for toggling copy attendee info,
174
-                // then use that value to change $this->_print_copy_info
175
-                $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
176
-                    ? $this->_copy_attendee_info_form()
177
-                    : $this->_auto_copy_attendee_info();
178
-                // generate hidden input
179
-                if (isset($subsections[$primary_registrant])
180
-                    && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
181
-                ) {
182
-                    $subsections[$primary_registrant]->add_subsections(
183
-                        $copy_options,
184
-                        'primary_registrant',
185
-                        false
186
-                    );
187
-                }
188
-            }
189
-        }
190
-
191
-        return new EE_Form_Section_Proper(
192
-            array(
193
-                'name'            => $this->reg_form_name(),
194
-                'html_id'         => $this->reg_form_name(),
195
-                'subsections'     => $subsections,
196
-                'layout_strategy' => $this->checkout->admin_request ?
197
-                    new EE_Div_Per_Section_Layout() :
198
-                    new EE_Template_Layout(
199
-                        array(
200
-                            'layout_template_file' => $this->_template, // layout_template
201
-                            'template_args'        => $template_args,
202
-                        )
203
-                    ),
204
-            )
205
-        );
206
-    }
207
-
208
-
209
-    /**
210
-     * @param EE_Registration $registration
211
-     * @return EE_Form_Section_Base
212
-     * @throws EE_Error
213
-     * @throws InvalidArgumentException
214
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
215
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
216
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
217
-     */
218
-    private function _registrations_reg_form(EE_Registration $registration)
219
-    {
220
-        static $attendee_nmbr = 1;
221
-        $form_args = array();
222
-        // verify that registration has valid event
223
-        if ($registration->event() instanceof EE_Event) {
224
-            $question_groups = $registration->event()->question_groups(
225
-                apply_filters(
226
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
227
-                    array(
228
-                        array(
229
-                            'Event.EVT_ID'                     => $registration->event()->ID(),
230
-                            'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
231
-                        ),
232
-                        'order_by' => array('QSG_order' => 'ASC'),
233
-                    ),
234
-                    $registration,
235
-                    $this
236
-                )
237
-            );
238
-            if ($question_groups) {
239
-                // array of params to pass to parent constructor
240
-                $form_args = array(
241
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
242
-                    'html_class'      => 'ee-reg-form-attendee-dv',
243
-                    'html_style'      => $this->checkout->admin_request
244
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
245
-                        : '',
246
-                    'subsections'     => array(),
247
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
248
-                        array(
249
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
250
-                            'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
251
-                        )
252
-                    ),
253
-                );
254
-                foreach ($question_groups as $question_group) {
255
-                    if ($question_group instanceof EE_Question_Group) {
256
-                        $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
257
-                            $registration,
258
-                            $question_group
259
-                        );
260
-                    }
261
-                }
262
-                // add hidden input
263
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
264
-                    $registration
265
-                );
266
-                // if we have question groups for additional attendees, then display the copy options
267
-                $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
268
-                if ($registration->is_primary_registrant()) {
269
-                    // generate hidden input
270
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
271
-                        $registration
272
-                    );
273
-                }
274
-            }
275
-        }
276
-        $attendee_nmbr++;
277
-        return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
278
-    }
279
-
280
-
281
-    /**
282
-     * _additional_attendee_reg_info_input
283
-     *
284
-     * @access public
285
-     * @param EE_Registration $registration
286
-     * @param bool            $additional_attendee_reg_info
287
-     * @return    EE_Form_Input_Base
288
-     * @throws \EE_Error
289
-     */
290
-    private function _additional_attendee_reg_info_input(
291
-        EE_Registration $registration,
292
-        $additional_attendee_reg_info = true
293
-    ) {
294
-        // generate hidden input
295
-        return new EE_Hidden_Input(
296
-            array(
297
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
298
-                'default' => $additional_attendee_reg_info,
299
-            )
300
-        );
301
-    }
302
-
303
-
304
-    /**
305
-     * @param EE_Registration   $registration
306
-     * @param EE_Question_Group $question_group
307
-     * @return EE_Form_Section_Proper
308
-     * @throws EE_Error
309
-     * @throws InvalidArgumentException
310
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
311
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
312
-     */
313
-    private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
314
-    {
315
-        // array of params to pass to parent constructor
316
-        $form_args = array(
317
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
318
-            'html_class'      => $this->checkout->admin_request
319
-                ? 'form-table ee-reg-form-qstn-grp-dv'
320
-                : 'ee-reg-form-qstn-grp-dv',
321
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
322
-            'subsections'     => array(
323
-                'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324
-            ),
325
-            'layout_strategy' => $this->checkout->admin_request
326
-                ? new EE_Admin_Two_Column_Layout()
327
-                : new EE_Div_Per_Section_Layout(),
328
-        );
329
-        // where params
330
-        $query_params = array('QST_deleted' => 0);
331
-        // don't load admin only questions on the frontend
332
-        if (! $this->checkout->admin_request) {
333
-            $query_params['QST_admin_only'] = array('!=', true);
334
-        }
335
-        $questions = $question_group->get_many_related(
336
-            'Question',
337
-            apply_filters(
338
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
339
-                array(
340
-                    $query_params,
341
-                    'order_by' => array(
342
-                        'Question_Group_Question.QGQ_order' => 'ASC',
343
-                    ),
344
-                ),
345
-                $question_group,
346
-                $registration,
347
-                $this
348
-            )
349
-        );
350
-        // filter for additional content before questions
351
-        $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
352
-            apply_filters(
353
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
354
-                '',
355
-                $registration,
356
-                $question_group,
357
-                $this
358
-            )
359
-        );
360
-        // loop thru questions
361
-        foreach ($questions as $question) {
362
-            if ($question instanceof EE_Question) {
363
-                $identifier                            = $question->is_system_question()
364
-                    ? $question->system_ID()
365
-                    : $question->ID();
366
-                $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
367
-            }
368
-        }
369
-        $form_args['subsections'] = apply_filters(
370
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
371
-            $form_args['subsections'],
372
-            $registration,
373
-            $question_group,
374
-            $this
375
-        );
376
-        // filter for additional content after questions
377
-        $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
378
-            apply_filters(
379
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
380
-                '',
381
-                $registration,
382
-                $question_group,
383
-                $this
384
-            )
385
-        );
20
+	/**
21
+	 * @type bool $_print_copy_info
22
+	 */
23
+	private $_print_copy_info = false;
24
+
25
+	/**
26
+	 * @type array $_attendee_data
27
+	 */
28
+	private $_attendee_data = array();
29
+
30
+	/**
31
+	 * @type array $_required_questions
32
+	 */
33
+	private $_required_questions = array();
34
+
35
+	/**
36
+	 * @type array $_registration_answers
37
+	 */
38
+	private $_registration_answers = array();
39
+
40
+
41
+	/**
42
+	 *    class constructor
43
+	 *
44
+	 * @access    public
45
+	 * @param    EE_Checkout $checkout
46
+	 */
47
+	public function __construct(EE_Checkout $checkout)
48
+	{
49
+		$this->_slug     = 'attendee_information';
50
+		$this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
52
+		$this->checkout  = $checkout;
53
+		$this->_reset_success_message();
54
+		$this->set_instructions(
55
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
56
+		);
57
+	}
58
+
59
+
60
+	public function translate_js_strings()
61
+	{
62
+		EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
63
+			' is a required question.',
64
+			'event_espresso'
65
+		);
66
+		EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
67
+			' is a required question. Please enter a value for at least one of the options.',
68
+			'event_espresso'
69
+		);
70
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
71
+			'Please answer all required questions correctly before proceeding.',
72
+			'event_espresso'
73
+		);
74
+		EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
75
+			esc_html__(
76
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77
+				'event_espresso'
78
+			),
79
+			'<br/>'
80
+		);
81
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
82
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83
+			'event_espresso'
84
+		);
85
+		EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
86
+			'You must enter a valid email address.',
87
+			'event_espresso'
88
+		);
89
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
90
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
91
+			'event_espresso'
92
+		);
93
+	}
94
+
95
+
96
+	public function enqueue_styles_and_scripts()
97
+	{
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return boolean
103
+	 */
104
+	public function initialize_reg_step()
105
+	{
106
+		return true;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return EE_Form_Section_Proper
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
115
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
116
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
117
+	 */
118
+	public function generate_reg_form()
119
+	{
120
+		$this->_print_copy_info = false;
121
+		$primary_registrant     = null;
122
+		// autoload Line_Item_Display classes
123
+		EEH_Autoloader::register_line_item_display_autoloaders();
124
+		$Line_Item_Display = new EE_Line_Item_Display();
125
+		// calculate taxes
126
+		$Line_Item_Display->display_line_item(
127
+			$this->checkout->cart->get_grand_total(),
128
+			array('set_tax_rate' => true)
129
+		);
130
+		/** @var $subsections EE_Form_Section_Proper[] */
131
+		$subsections   = array(
132
+			'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
133
+		);
134
+		$template_args = array(
135
+			'revisit'       => $this->checkout->revisit,
136
+			'registrations' => array(),
137
+			'ticket_count'  => array(),
138
+		);
139
+		// grab the saved registrations from the transaction
140
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
141
+		if ($registrations) {
142
+			foreach ($registrations as $registration) {
143
+				// can this registration be processed during this visit ?
144
+				if ($registration instanceof EE_Registration
145
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
146
+				) {
147
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
+					if (! $this->checkout->admin_request) {
149
+						$template_args['registrations'][$registration->reg_url_link()]    = $registration;
150
+						$template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151
+							$template_args['ticket_count'][$registration->ticket()->ID()]
152
+						)
153
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
154
+							: 1;
155
+						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
156
+							$this->checkout->cart->get_grand_total(),
157
+							'Ticket',
158
+							array($registration->ticket()->ID())
159
+						);
160
+						$ticket_line_item = is_array($ticket_line_item)
161
+							? reset($ticket_line_item)
162
+							: $ticket_line_item;
163
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] =
164
+							$Line_Item_Display->display_line_item($ticket_line_item);
165
+					}
166
+					if ($registration->is_primary_registrant()) {
167
+						$primary_registrant = $registration->reg_url_link();
168
+					}
169
+				}
170
+			}
171
+			// print_copy_info ?
172
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
173
+				// TODO: add admin option for toggling copy attendee info,
174
+				// then use that value to change $this->_print_copy_info
175
+				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
176
+					? $this->_copy_attendee_info_form()
177
+					: $this->_auto_copy_attendee_info();
178
+				// generate hidden input
179
+				if (isset($subsections[$primary_registrant])
180
+					&& $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
181
+				) {
182
+					$subsections[$primary_registrant]->add_subsections(
183
+						$copy_options,
184
+						'primary_registrant',
185
+						false
186
+					);
187
+				}
188
+			}
189
+		}
190
+
191
+		return new EE_Form_Section_Proper(
192
+			array(
193
+				'name'            => $this->reg_form_name(),
194
+				'html_id'         => $this->reg_form_name(),
195
+				'subsections'     => $subsections,
196
+				'layout_strategy' => $this->checkout->admin_request ?
197
+					new EE_Div_Per_Section_Layout() :
198
+					new EE_Template_Layout(
199
+						array(
200
+							'layout_template_file' => $this->_template, // layout_template
201
+							'template_args'        => $template_args,
202
+						)
203
+					),
204
+			)
205
+		);
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param EE_Registration $registration
211
+	 * @return EE_Form_Section_Base
212
+	 * @throws EE_Error
213
+	 * @throws InvalidArgumentException
214
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
215
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
216
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
217
+	 */
218
+	private function _registrations_reg_form(EE_Registration $registration)
219
+	{
220
+		static $attendee_nmbr = 1;
221
+		$form_args = array();
222
+		// verify that registration has valid event
223
+		if ($registration->event() instanceof EE_Event) {
224
+			$question_groups = $registration->event()->question_groups(
225
+				apply_filters(
226
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
227
+					array(
228
+						array(
229
+							'Event.EVT_ID'                     => $registration->event()->ID(),
230
+							'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
231
+						),
232
+						'order_by' => array('QSG_order' => 'ASC'),
233
+					),
234
+					$registration,
235
+					$this
236
+				)
237
+			);
238
+			if ($question_groups) {
239
+				// array of params to pass to parent constructor
240
+				$form_args = array(
241
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
242
+					'html_class'      => 'ee-reg-form-attendee-dv',
243
+					'html_style'      => $this->checkout->admin_request
244
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
245
+						: '',
246
+					'subsections'     => array(),
247
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
248
+						array(
249
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
250
+							'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
251
+						)
252
+					),
253
+				);
254
+				foreach ($question_groups as $question_group) {
255
+					if ($question_group instanceof EE_Question_Group) {
256
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
257
+							$registration,
258
+							$question_group
259
+						);
260
+					}
261
+				}
262
+				// add hidden input
263
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
264
+					$registration
265
+				);
266
+				// if we have question groups for additional attendees, then display the copy options
267
+				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
268
+				if ($registration->is_primary_registrant()) {
269
+					// generate hidden input
270
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
271
+						$registration
272
+					);
273
+				}
274
+			}
275
+		}
276
+		$attendee_nmbr++;
277
+		return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
278
+	}
279
+
280
+
281
+	/**
282
+	 * _additional_attendee_reg_info_input
283
+	 *
284
+	 * @access public
285
+	 * @param EE_Registration $registration
286
+	 * @param bool            $additional_attendee_reg_info
287
+	 * @return    EE_Form_Input_Base
288
+	 * @throws \EE_Error
289
+	 */
290
+	private function _additional_attendee_reg_info_input(
291
+		EE_Registration $registration,
292
+		$additional_attendee_reg_info = true
293
+	) {
294
+		// generate hidden input
295
+		return new EE_Hidden_Input(
296
+			array(
297
+				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
298
+				'default' => $additional_attendee_reg_info,
299
+			)
300
+		);
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param EE_Registration   $registration
306
+	 * @param EE_Question_Group $question_group
307
+	 * @return EE_Form_Section_Proper
308
+	 * @throws EE_Error
309
+	 * @throws InvalidArgumentException
310
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
311
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
312
+	 */
313
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
314
+	{
315
+		// array of params to pass to parent constructor
316
+		$form_args = array(
317
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
318
+			'html_class'      => $this->checkout->admin_request
319
+				? 'form-table ee-reg-form-qstn-grp-dv'
320
+				: 'ee-reg-form-qstn-grp-dv',
321
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
322
+			'subsections'     => array(
323
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324
+			),
325
+			'layout_strategy' => $this->checkout->admin_request
326
+				? new EE_Admin_Two_Column_Layout()
327
+				: new EE_Div_Per_Section_Layout(),
328
+		);
329
+		// where params
330
+		$query_params = array('QST_deleted' => 0);
331
+		// don't load admin only questions on the frontend
332
+		if (! $this->checkout->admin_request) {
333
+			$query_params['QST_admin_only'] = array('!=', true);
334
+		}
335
+		$questions = $question_group->get_many_related(
336
+			'Question',
337
+			apply_filters(
338
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
339
+				array(
340
+					$query_params,
341
+					'order_by' => array(
342
+						'Question_Group_Question.QGQ_order' => 'ASC',
343
+					),
344
+				),
345
+				$question_group,
346
+				$registration,
347
+				$this
348
+			)
349
+		);
350
+		// filter for additional content before questions
351
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
352
+			apply_filters(
353
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
354
+				'',
355
+				$registration,
356
+				$question_group,
357
+				$this
358
+			)
359
+		);
360
+		// loop thru questions
361
+		foreach ($questions as $question) {
362
+			if ($question instanceof EE_Question) {
363
+				$identifier                            = $question->is_system_question()
364
+					? $question->system_ID()
365
+					: $question->ID();
366
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
367
+			}
368
+		}
369
+		$form_args['subsections'] = apply_filters(
370
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
371
+			$form_args['subsections'],
372
+			$registration,
373
+			$question_group,
374
+			$this
375
+		);
376
+		// filter for additional content after questions
377
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
378
+			apply_filters(
379
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
380
+				'',
381
+				$registration,
382
+				$question_group,
383
+				$this
384
+			)
385
+		);
386 386
 //		d( $form_args );
387
-        $question_group_reg_form = new EE_Form_Section_Proper($form_args);
388
-        return apply_filters(
389
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
390
-            $question_group_reg_form,
391
-            $registration,
392
-            $question_group,
393
-            $this
394
-        );
395
-    }
396
-
397
-
398
-    /**
399
-     * @access public
400
-     * @param EE_Question_Group $question_group
401
-     * @return    EE_Form_Section_HTML
402
-     */
403
-    private function _question_group_header(EE_Question_Group $question_group)
404
-    {
405
-        $html = '';
406
-        // group_name
407
-        if ($question_group->show_group_name() && $question_group->name() !== '') {
408
-            if ($this->checkout->admin_request) {
409
-                $html .= EEH_HTML::br();
410
-                $html .= EEH_HTML::h3(
411
-                    $question_group->name(),
412
-                    '',
413
-                    'ee-reg-form-qstn-grp-title title',
414
-                    'font-size: 1.3em; padding-left:0;'
415
-                );
416
-            } else {
417
-                $html .= EEH_HTML::h4(
418
-                    $question_group->name(),
419
-                    '',
420
-                    'ee-reg-form-qstn-grp-title section-title'
421
-                );
422
-            }
423
-        }
424
-        // group_desc
425
-        if ($question_group->show_group_desc() && $question_group->desc() !== '') {
426
-            $html .= EEH_HTML::p(
427
-                $question_group->desc(),
428
-                '',
429
-                $this->checkout->admin_request
430
-                    ? 'ee-reg-form-qstn-grp-desc-pg'
431
-                    : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
432
-            );
433
-        }
434
-        return new EE_Form_Section_HTML($html);
435
-    }
436
-
437
-
438
-    /**
439
-     * @access public
440
-     * @return    EE_Form_Section_Proper
441
-     * @throws \EE_Error
442
-     */
443
-    private function _copy_attendee_info_form()
444
-    {
445
-        // array of params to pass to parent constructor
446
-        return new EE_Form_Section_Proper(
447
-            array(
448
-                'subsections'     => $this->_copy_attendee_info_inputs(),
449
-                'layout_strategy' => new EE_Template_Layout(
450
-                    array(
451
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
452
-                                                      . $this->_slug
453
-                                                      . DS
454
-                                                      . 'copy_attendee_info.template.php',
455
-                        'begin_template_file'      => null,
456
-                        'input_template_file'      => null,
457
-                        'subsection_template_file' => null,
458
-                        'end_template_file'        => null,
459
-                    )
460
-                ),
461
-            )
462
-        );
463
-    }
464
-
465
-
466
-    /**
467
-     * _auto_copy_attendee_info
468
-     *
469
-     * @access public
470
-     * @return EE_Form_Section_HTML
471
-     */
472
-    private function _auto_copy_attendee_info()
473
-    {
474
-        return new EE_Form_Section_HTML(
475
-            EEH_Template::locate_template(
476
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
477
-                apply_filters(
478
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479
-                    array()
480
-                ),
481
-                true,
482
-                true
483
-            )
484
-        );
485
-    }
486
-
487
-
488
-    /**
489
-     * _copy_attendee_info_inputs
490
-     *
491
-     * @access public
492
-     * @return array
493
-     * @throws \EE_Error
494
-     */
495
-    private function _copy_attendee_info_inputs()
496
-    {
497
-        $copy_attendee_info_inputs = array();
498
-        $prev_ticket               = null;
499
-        // grab the saved registrations from the transaction
500
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
501
-        foreach ($registrations as $registration) {
502
-            // for all  attendees other than the primary attendee
503
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
504
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
505
-                if ($registration->ticket()->ID() !== $prev_ticket) {
506
-                    $item_name = $registration->ticket()->name();
507
-                    $item_name .= $registration->ticket()->description() !== ''
508
-                        ? ' - ' . $registration->ticket()->description()
509
-                        : '';
510
-                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
511
-                        new EE_Form_Section_HTML(
512
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
513
-                        );
514
-                    $prev_ticket = $registration->ticket()->ID();
515
-                }
516
-
517
-                $copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
518
-                    new EE_Checkbox_Multi_Input(
519
-                        array(
520
-                            $registration->ID() => sprintf(
521
-                                esc_html__('Attendee #%s', 'event_espresso'),
522
-                                $registration->count()
523
-                            ),
524
-                        ),
525
-                        array(
526
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
527
-                            'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528
-                            'display_html_label_text' => false,
529
-                        )
530
-                    );
531
-            }
532
-        }
533
-        return $copy_attendee_info_inputs;
534
-    }
535
-
536
-
537
-    /**
538
-     * _additional_primary_registrant_inputs
539
-     *
540
-     * @access public
541
-     * @param EE_Registration $registration
542
-     * @return    EE_Form_Input_Base
543
-     * @throws \EE_Error
544
-     */
545
-    private function _additional_primary_registrant_inputs(EE_Registration $registration)
546
-    {
547
-        // generate hidden input
548
-        return new EE_Hidden_Input(
549
-            array(
550
-                'html_id' => 'primary_registrant',
551
-                'default' => $registration->reg_url_link(),
552
-            )
553
-        );
554
-    }
555
-
556
-
557
-    /**
558
-     * @access public
559
-     * @param EE_Registration $registration
560
-     * @param EE_Question     $question
561
-     * @return EE_Form_Input_Base
562
-     * @throws EE_Error
563
-     * @throws InvalidArgumentException
564
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
565
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
566
-     */
567
-    public function reg_form_question(EE_Registration $registration, EE_Question $question)
568
-    {
569
-
570
-        // if this question was for an attendee detail, then check for that answer
571
-        $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
572
-            $registration,
573
-            $question->system_ID()
574
-        );
575
-        $answer       = $answer_value === null
576
-            ? EEM_Answer::instance()->get_one(
577
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578
-            )
579
-            : null;
580
-        // if NOT returning to edit an existing registration
581
-        // OR if this question is for an attendee property
582
-        // OR we still don't have an EE_Answer object
583
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
584
-            // create an EE_Answer object for storing everything in
585
-            $answer = EE_Answer::new_instance(array(
586
-                'QST_ID' => $question->ID(),
587
-                'REG_ID' => $registration->ID(),
588
-            ));
589
-        }
590
-        // verify instance
591
-        if ($answer instanceof EE_Answer) {
592
-            if (! empty($answer_value)) {
593
-                $answer->set('ANS_value', $answer_value);
594
-            }
595
-            $answer->cache('Question', $question);
596
-            //remember system ID had a bug where sometimes it could be null
597
-            $answer_cache_id = $question->is_system_question()
598
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
599
-                : $question->ID() . '-' . $registration->reg_url_link();
600
-            $registration->cache('Answer', $answer, $answer_cache_id);
601
-        }
602
-        return $this->_generate_question_input($registration, $question, $answer);
603
-    }
604
-
605
-
606
-    /**
607
-     * @param EE_Registration $registration
608
-     * @param EE_Question     $question
609
-     * @param                 mixed EE_Answer|NULL      $answer
610
-     * @return EE_Form_Input_Base
611
-     * @throws \EE_Error
612
-     */
613
-    private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
614
-    {
615
-        $identifier                             = $question->is_system_question()
616
-            ? $question->system_ID()
617
-            : $question->ID();
618
-        $this->_required_questions[$identifier] = $question->required() ? true : false;
619
-        add_filter(
620
-            'FHEE__EE_Question__generate_form_input__country_options',
621
-            array($this, 'use_cached_countries_for_form_input'),
622
-            10,
623
-            4
624
-        );
625
-        add_filter(
626
-            'FHEE__EE_Question__generate_form_input__state_options',
627
-            array($this, 'use_cached_states_for_form_input'),
628
-            10,
629
-            4
630
-        );
631
-        $input_constructor_args                  = array(
632
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
636
-            'html_label_class' => 'ee-reg-qstn',
637
-        );
638
-        $input_constructor_args['html_label_id'] .= '-lbl';
639
-        if ($answer instanceof EE_Answer && $answer->ID()) {
640
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
642
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
643
-        }
644
-        $form_input = $question->generate_form_input(
645
-            $registration,
646
-            $answer,
647
-            $input_constructor_args
648
-        );
649
-        remove_filter(
650
-            'FHEE__EE_Question__generate_form_input__country_options',
651
-            array($this, 'use_cached_countries_for_form_input')
652
-        );
653
-        remove_filter(
654
-            'FHEE__EE_Question__generate_form_input__state_options',
655
-            array($this, 'use_cached_states_for_form_input')
656
-        );
657
-        return $form_input;
658
-    }
659
-
660
-
661
-    /**
662
-     * Gets the list of countries for the form input
663
-     *
664
-     * @param array|null       $countries_list
665
-     * @param \EE_Question     $question
666
-     * @param \EE_Registration $registration
667
-     * @param \EE_Answer       $answer
668
-     * @return array 2d keys are country IDs, values are their names
669
-     * @throws EE_Error
670
-     * @throws InvalidArgumentException
671
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
672
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
673
-     */
674
-    public function use_cached_countries_for_form_input(
675
-        $countries_list,
676
-        \EE_Question $question = null,
677
-        \EE_Registration $registration = null,
678
-        \EE_Answer $answer = null
679
-    ) {
680
-        $country_options = array('' => '');
681
-        // get possibly cached list of countries
682
-        $countries = $this->checkout->action === 'process_reg_step'
683
-            ? EEM_Country::instance()->get_all_countries()
684
-            : EEM_Country::instance()->get_all_active_countries();
685
-        if (! empty($countries)) {
686
-            foreach ($countries as $country) {
687
-                if ($country instanceof EE_Country) {
688
-                    $country_options[$country->ID()] = $country->name();
689
-                }
690
-            }
691
-        }
692
-        if ($question instanceof EE_Question
693
-            && $registration instanceof EE_Registration) {
694
-            $answer = EEM_Answer::instance()->get_one(
695
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
696
-            );
697
-        } else {
698
-            $answer = EE_Answer::new_instance();
699
-        }
700
-        $country_options = apply_filters(
701
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
702
-            $country_options,
703
-            $this,
704
-            $registration,
705
-            $question,
706
-            $answer
707
-        );
708
-        return $country_options;
709
-    }
710
-
711
-
712
-    /**
713
-     * Gets the list of states for the form input
714
-     *
715
-     * @param array|null       $states_list
716
-     * @param \EE_Question     $question
717
-     * @param \EE_Registration $registration
718
-     * @param \EE_Answer       $answer
719
-     * @return array 2d keys are state IDs, values are their names
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
723
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
724
-     */
725
-    public function use_cached_states_for_form_input(
726
-        $states_list,
727
-        \EE_Question $question = null,
728
-        \EE_Registration $registration = null,
729
-        \EE_Answer $answer = null
730
-    ) {
731
-        $state_options = array('' => array('' => ''));
732
-        $states        = $this->checkout->action === 'process_reg_step'
733
-            ? EEM_State::instance()->get_all_states()
734
-            : EEM_State::instance()->get_all_active_states();
735
-        if (! empty($states)) {
736
-            foreach ($states as $state) {
737
-                if ($state instanceof EE_State) {
738
-                    $state_options[$state->country()->name()][$state->ID()] = $state->name();
739
-                }
740
-            }
741
-        }
742
-        $state_options = apply_filters(
743
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
744
-            $state_options,
745
-            $this,
746
-            $registration,
747
-            $question,
748
-            $answer
749
-        );
750
-        return $state_options;
751
-    }
752
-
753
-
754
-
755
-
756
-
757
-
758
-    /********************************************************************************************************/
759
-    /****************************************  PROCESS REG STEP  ****************************************/
760
-    /********************************************************************************************************/
761
-    /**
762
-     * @return bool
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws ReflectionException
766
-     * @throws RuntimeException
767
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
768
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
769
-     */
770
-    public function process_reg_step()
771
-    {
772
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
773
-        // grab validated data from form
774
-        $valid_data = $this->checkout->current_step->valid_data();
775
-        // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
776
-        // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
777
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
778
-        if (empty($valid_data)) {
779
-            EE_Error::add_error(
780
-                esc_html__('No valid question responses were received.', 'event_espresso'),
781
-                __FILE__,
782
-                __FUNCTION__,
783
-                __LINE__
784
-            );
785
-            return false;
786
-        }
787
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788
-            EE_Error::add_error(
789
-                esc_html__(
790
-                    'A valid transaction could not be initiated for processing your registrations.',
791
-                    'event_espresso'
792
-                ),
793
-                __FILE__,
794
-                __FUNCTION__,
795
-                __LINE__
796
-            );
797
-            return false;
798
-        }
799
-        // get cached registrations
800
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
801
-        // verify we got the goods
802
-        if (empty($registrations)) {
803
-            //combine the old translated string with a new one, in order to not break translations
804
-            $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
805
-                             . sprintf(
806
-                                 esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
807
-                                 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
808
-                                 '</a>',
809
-                                 '<br />'
810
-                             );
811
-            EE_Error::add_error(
812
-                $error_message,
813
-                __FILE__,
814
-                __FUNCTION__,
815
-                __LINE__
816
-            );
817
-            return false;
818
-        }
819
-        // extract attendee info from form data and save to model objects
820
-        $registrations_processed = $this->_process_registrations($registrations, $valid_data);
821
-        // if first pass thru SPCO,
822
-        // then let's check processed registrations against the total number of tickets in the cart
823
-        if ($registrations_processed === false) {
824
-            // but return immediately if the previous step exited early due to errors
825
-            return false;
826
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
827
-            // generate a correctly translated string for all possible singular/plural combinations
828
-            if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
829
-                $error_msg = sprintf(
830
-                    esc_html__(
831
-                        'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
832
-                        'event_espresso'
833
-                    ),
834
-                    $this->checkout->total_ticket_count,
835
-                    $registrations_processed
836
-                );
837
-            } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
838
-                $error_msg = sprintf(
839
-                    esc_html__(
840
-                        'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
841
-                        'event_espresso'
842
-                    ),
843
-                    $this->checkout->total_ticket_count,
844
-                    $registrations_processed
845
-                );
846
-            } else {
847
-                $error_msg = sprintf(
848
-                    esc_html__(
849
-                        'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
850
-                        'event_espresso'
851
-                    ),
852
-                    $this->checkout->total_ticket_count,
853
-                    $registrations_processed
854
-                );
855
-            }
856
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
857
-            return false;
858
-        }
859
-        // mark this reg step as completed
860
-        $this->set_completed();
861
-        $this->_set_success_message(
862
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
863
-        );
864
-        //do action in case a plugin wants to do something with the data submitted in step 1.
865
-        //passes EE_Single_Page_Checkout, and it's posted data
866
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
867
-        return true;
868
-    }
869
-
870
-
871
-    /**
872
-     *    _process_registrations
873
-     *
874
-     * @param EE_Registration[] $registrations
875
-     * @param array             $valid_data
876
-     * @return bool|int
877
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
878
-     * @throws EE_Error
879
-     * @throws InvalidArgumentException
880
-     * @throws ReflectionException
881
-     * @throws RuntimeException
882
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
883
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
884
-     */
885
-    private function _process_registrations($registrations = array(), $valid_data = array())
886
-    {
887
-        // load resources and set some defaults
888
-        EE_Registry::instance()->load_model('Attendee');
889
-        // holder for primary registrant attendee object
890
-        $this->checkout->primary_attendee_obj = null;
891
-        // array for tracking reg form data for the primary registrant
892
-        $primary_registrant = array(
893
-            'line_item_id' => null,
894
-        );
895
-        $copy_primary       = false;
896
-        // reg form sections that do not contain inputs
897
-        $non_input_form_sections = array(
898
-            'primary_registrant',
899
-            'additional_attendee_reg_info',
900
-            'spco_copy_attendee_chk',
901
-        );
902
-        // attendee counter
903
-        $att_nmbr = 0;
904
-        // grab the saved registrations from the transaction
905
-        foreach ($registrations as $registration) {
906
-            // verify EE_Registration object
907
-            if (! $registration instanceof EE_Registration) {
908
-                EE_Error::add_error(
909
-                    esc_html__(
910
-                        'An invalid Registration object was discovered when attempting to process your registration information.',
911
-                        'event_espresso'
912
-                    ),
913
-                    __FILE__,
914
-                    __FUNCTION__,
915
-                    __LINE__
916
-                );
917
-                return false;
918
-            }
919
-            /** @var string $reg_url_link */
920
-            $reg_url_link = $registration->reg_url_link();
921
-            // reg_url_link exists ?
922
-            if (! empty($reg_url_link)) {
923
-                // should this registration be processed during this visit ?
924
-                if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
925
-                    // if NOT revisiting, then let's save the registration now,
926
-                    // so that we have a REG_ID to use when generating other objects
927
-                    if (! $this->checkout->revisit) {
928
-                        $registration->save();
929
-                    }
930
-                    /**
931
-                     * This allows plugins to trigger a fail on processing of a
932
-                     * registration for any conditions they may have for it to pass.
933
-                     *
934
-                     * @var bool   if true is returned by the plugin then the
935
-                     *            registration processing is halted.
936
-                     */
937
-                    if (apply_filters(
938
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
939
-                        false,
940
-                        $att_nmbr,
941
-                        $registration,
942
-                        $registrations,
943
-                        $valid_data,
944
-                        $this
945
-                    )) {
946
-                        return false;
947
-                    }
948
-
949
-                    // Houston, we have a registration!
950
-                    $att_nmbr++;
951
-                    $this->_attendee_data[$reg_url_link] = array();
952
-                    // grab any existing related answer objects
953
-                    $this->_registration_answers = $registration->answers();
954
-                    // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
955
-                    if (isset($valid_data[$reg_url_link])) {
956
-                        // do we need to copy basic info from primary attendee ?
957
-                        $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
958
-                                        && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
959
-                            ? true
960
-                            : false;
961
-                        // filter form input data for this registration
962
-                        $valid_data[$reg_url_link] = (array)apply_filters(
963
-                            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
964
-                            $valid_data[$reg_url_link]
965
-                        );
966
-                        if (isset($valid_data['primary_attendee'])) {
967
-                            $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
968
-                                ? $valid_data['primary_attendee']
969
-                                : false;
970
-                            unset($valid_data['primary_attendee']);
971
-                        }
972
-                        // now loop through our array of valid post data && process attendee reg forms
973
-                        foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
974
-                            if (! in_array($form_section, $non_input_form_sections)) {
975
-                                foreach ($form_inputs as $form_input => $input_value) {
976
-                                    // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
977
-                                    // check for critical inputs
978
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
979
-                                        $form_input,
980
-                                        $input_value
981
-                                    )
982
-                                    ) {
983
-                                        return false;
984
-                                    }
985
-                                    // store a bit of data about the primary attendee
986
-                                    if ($att_nmbr === 1
987
-                                        && ! empty($input_value)
988
-                                        && $reg_url_link === $primary_registrant['line_item_id']
989
-                                    ) {
990
-                                        $primary_registrant[$form_input] = $input_value;
991
-                                    } elseif ($copy_primary
992
-                                        && $input_value === null
993
-                                        && isset($primary_registrant[$form_input])
994
-                                    ) {
995
-                                        $input_value = $primary_registrant[$form_input];
996
-                                    }
997
-                                    // now attempt to save the input data
998
-                                    if (! $this->_save_registration_form_input(
999
-                                        $registration,
1000
-                                        $form_input,
1001
-                                        $input_value
1002
-                                    )
1003
-                                    ) {
1004
-                                        EE_Error::add_error(
1005
-                                            sprintf(
1006
-                                                esc_html__(
1007
-                                                    'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1008
-                                                    'event_espresso'
1009
-                                                ),
1010
-                                                $form_input,
1011
-                                                $input_value
1012
-                                            ),
1013
-                                            __FILE__,
1014
-                                            __FUNCTION__,
1015
-                                            __LINE__
1016
-                                        );
1017
-                                        return false;
1018
-                                    }
1019
-                                }
1020
-                            }
1021
-                        }  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1022
-                    }
1023
-                    //EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1024
-                    // this registration does not require additional attendee information ?
1025
-                    if ($copy_primary
1026
-                        && $att_nmbr > 1
1027
-                        && $this->checkout->primary_attendee_obj instanceof EE_Attendee
1028
-                    ) {
1029
-                        // just copy the primary registrant
1030
-                        $attendee = $this->checkout->primary_attendee_obj;
1031
-                    } else {
1032
-                        // ensure critical details are set for additional attendees
1033
-                        $this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1034
-                            ? $this->_copy_critical_attendee_details_from_primary_registrant(
1035
-                                $this->_attendee_data[$reg_url_link]
1036
-                            )
1037
-                            : $this->_attendee_data[$reg_url_link];
1038
-                        // execute create attendee command (which may return an existing attendee)
1039
-                        $attendee = EE_Registry::instance()->BUS->execute(
1040
-                            new CreateAttendeeCommand(
1041
-                                $this->_attendee_data[$reg_url_link],
1042
-                                $registration
1043
-                            )
1044
-                        );
1045
-                        // who's #1 ?
1046
-                        if ($att_nmbr === 1) {
1047
-                            $this->checkout->primary_attendee_obj = $attendee;
1048
-                        }
1049
-                    }
1050
-                    // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1051
-                    // add relation to registration, set attendee ID, and cache attendee
1052
-                    $this->_associate_attendee_with_registration($registration, $attendee);
1053
-                    // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1054
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1055
-                        EE_Error::add_error(
1056
-                            sprintf(
1057
-                                esc_html__(
1058
-                                    'Registration %s has an invalid or missing Attendee object.',
1059
-                                    'event_espresso'
1060
-                                ),
1061
-                                $reg_url_link
1062
-                            ),
1063
-                            __FILE__,
1064
-                            __FUNCTION__,
1065
-                            __LINE__
1066
-                        );
1067
-                        return false;
1068
-                    }
1069
-                    /** @type EE_Registration_Processor $registration_processor */
1070
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1071
-                    // at this point, we should have enough details about the registrant to consider the registration
1072
-                    // NOT incomplete
1073
-                    $registration_processor->toggle_incomplete_registration_status_to_default(
1074
-                        $registration,
1075
-                        false,
1076
-                        new Context(
1077
-                            'spco_reg_step_attendee_information_process_registrations',
1078
-                            esc_html__(
1079
-                                'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1080
-                                'event_espresso'
1081
-                            )
1082
-                        )
1083
-                    );
1084
-                    // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1085
-                    // abandoned
1086
-                    $this->checkout->transaction->toggle_failed_transaction_status();
1087
-                    // if we've gotten this far, then let's save what we have
1088
-                    $registration->save();
1089
-                    // add relation between TXN and registration
1090
-                    $this->_associate_registration_with_transaction($registration);
1091
-                }
1092
-            } else {
1093
-                EE_Error::add_error(
1094
-                    esc_html__(
1095
-                        'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1096
-                        'event_espresso'
1097
-                    ),
1098
-                    __FILE__,
1099
-                    __FUNCTION__,
1100
-                    __LINE__
1101
-                );
1102
-                // remove malformed data
1103
-                unset($valid_data[$reg_url_link]);
1104
-                return false;
1105
-            }
1106
-
1107
-        } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1108
-        return $att_nmbr;
1109
-    }
1110
-
1111
-
1112
-    /**
1113
-     *    _save_registration_form_input
1114
-     *
1115
-     * @param EE_Registration $registration
1116
-     * @param string          $form_input
1117
-     * @param string          $input_value
1118
-     * @return bool
1119
-     * @throws EE_Error
1120
-     * @throws InvalidArgumentException
1121
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1122
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1123
-     */
1124
-    private function _save_registration_form_input(
1125
-        EE_Registration $registration,
1126
-        $form_input = '',
1127
-        $input_value = ''
1128
-    ) {
1129
-        // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1130
-        // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1131
-        // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1132
-        // allow for plugins to hook in and do their own processing of the form input.
1133
-        // For plugins to bypass normal processing here, they just need to return a boolean value.
1134
-        if (apply_filters(
1135
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1136
-            false,
1137
-            $registration,
1138
-            $form_input,
1139
-            $input_value,
1140
-            $this
1141
-        )) {
1142
-            return true;
1143
-        }
1144
-        /*
387
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
388
+		return apply_filters(
389
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
390
+			$question_group_reg_form,
391
+			$registration,
392
+			$question_group,
393
+			$this
394
+		);
395
+	}
396
+
397
+
398
+	/**
399
+	 * @access public
400
+	 * @param EE_Question_Group $question_group
401
+	 * @return    EE_Form_Section_HTML
402
+	 */
403
+	private function _question_group_header(EE_Question_Group $question_group)
404
+	{
405
+		$html = '';
406
+		// group_name
407
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
408
+			if ($this->checkout->admin_request) {
409
+				$html .= EEH_HTML::br();
410
+				$html .= EEH_HTML::h3(
411
+					$question_group->name(),
412
+					'',
413
+					'ee-reg-form-qstn-grp-title title',
414
+					'font-size: 1.3em; padding-left:0;'
415
+				);
416
+			} else {
417
+				$html .= EEH_HTML::h4(
418
+					$question_group->name(),
419
+					'',
420
+					'ee-reg-form-qstn-grp-title section-title'
421
+				);
422
+			}
423
+		}
424
+		// group_desc
425
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
426
+			$html .= EEH_HTML::p(
427
+				$question_group->desc(),
428
+				'',
429
+				$this->checkout->admin_request
430
+					? 'ee-reg-form-qstn-grp-desc-pg'
431
+					: 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
432
+			);
433
+		}
434
+		return new EE_Form_Section_HTML($html);
435
+	}
436
+
437
+
438
+	/**
439
+	 * @access public
440
+	 * @return    EE_Form_Section_Proper
441
+	 * @throws \EE_Error
442
+	 */
443
+	private function _copy_attendee_info_form()
444
+	{
445
+		// array of params to pass to parent constructor
446
+		return new EE_Form_Section_Proper(
447
+			array(
448
+				'subsections'     => $this->_copy_attendee_info_inputs(),
449
+				'layout_strategy' => new EE_Template_Layout(
450
+					array(
451
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
452
+													  . $this->_slug
453
+													  . DS
454
+													  . 'copy_attendee_info.template.php',
455
+						'begin_template_file'      => null,
456
+						'input_template_file'      => null,
457
+						'subsection_template_file' => null,
458
+						'end_template_file'        => null,
459
+					)
460
+				),
461
+			)
462
+		);
463
+	}
464
+
465
+
466
+	/**
467
+	 * _auto_copy_attendee_info
468
+	 *
469
+	 * @access public
470
+	 * @return EE_Form_Section_HTML
471
+	 */
472
+	private function _auto_copy_attendee_info()
473
+	{
474
+		return new EE_Form_Section_HTML(
475
+			EEH_Template::locate_template(
476
+				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
477
+				apply_filters(
478
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479
+					array()
480
+				),
481
+				true,
482
+				true
483
+			)
484
+		);
485
+	}
486
+
487
+
488
+	/**
489
+	 * _copy_attendee_info_inputs
490
+	 *
491
+	 * @access public
492
+	 * @return array
493
+	 * @throws \EE_Error
494
+	 */
495
+	private function _copy_attendee_info_inputs()
496
+	{
497
+		$copy_attendee_info_inputs = array();
498
+		$prev_ticket               = null;
499
+		// grab the saved registrations from the transaction
500
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
501
+		foreach ($registrations as $registration) {
502
+			// for all  attendees other than the primary attendee
503
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
504
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
505
+				if ($registration->ticket()->ID() !== $prev_ticket) {
506
+					$item_name = $registration->ticket()->name();
507
+					$item_name .= $registration->ticket()->description() !== ''
508
+						? ' - ' . $registration->ticket()->description()
509
+						: '';
510
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
511
+						new EE_Form_Section_HTML(
512
+							'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
513
+						);
514
+					$prev_ticket = $registration->ticket()->ID();
515
+				}
516
+
517
+				$copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
518
+					new EE_Checkbox_Multi_Input(
519
+						array(
520
+							$registration->ID() => sprintf(
521
+								esc_html__('Attendee #%s', 'event_espresso'),
522
+								$registration->count()
523
+							),
524
+						),
525
+						array(
526
+							'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
527
+							'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528
+							'display_html_label_text' => false,
529
+						)
530
+					);
531
+			}
532
+		}
533
+		return $copy_attendee_info_inputs;
534
+	}
535
+
536
+
537
+	/**
538
+	 * _additional_primary_registrant_inputs
539
+	 *
540
+	 * @access public
541
+	 * @param EE_Registration $registration
542
+	 * @return    EE_Form_Input_Base
543
+	 * @throws \EE_Error
544
+	 */
545
+	private function _additional_primary_registrant_inputs(EE_Registration $registration)
546
+	{
547
+		// generate hidden input
548
+		return new EE_Hidden_Input(
549
+			array(
550
+				'html_id' => 'primary_registrant',
551
+				'default' => $registration->reg_url_link(),
552
+			)
553
+		);
554
+	}
555
+
556
+
557
+	/**
558
+	 * @access public
559
+	 * @param EE_Registration $registration
560
+	 * @param EE_Question     $question
561
+	 * @return EE_Form_Input_Base
562
+	 * @throws EE_Error
563
+	 * @throws InvalidArgumentException
564
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
565
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
566
+	 */
567
+	public function reg_form_question(EE_Registration $registration, EE_Question $question)
568
+	{
569
+
570
+		// if this question was for an attendee detail, then check for that answer
571
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
572
+			$registration,
573
+			$question->system_ID()
574
+		);
575
+		$answer       = $answer_value === null
576
+			? EEM_Answer::instance()->get_one(
577
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578
+			)
579
+			: null;
580
+		// if NOT returning to edit an existing registration
581
+		// OR if this question is for an attendee property
582
+		// OR we still don't have an EE_Answer object
583
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
584
+			// create an EE_Answer object for storing everything in
585
+			$answer = EE_Answer::new_instance(array(
586
+				'QST_ID' => $question->ID(),
587
+				'REG_ID' => $registration->ID(),
588
+			));
589
+		}
590
+		// verify instance
591
+		if ($answer instanceof EE_Answer) {
592
+			if (! empty($answer_value)) {
593
+				$answer->set('ANS_value', $answer_value);
594
+			}
595
+			$answer->cache('Question', $question);
596
+			//remember system ID had a bug where sometimes it could be null
597
+			$answer_cache_id = $question->is_system_question()
598
+				? $question->system_ID() . '-' . $registration->reg_url_link()
599
+				: $question->ID() . '-' . $registration->reg_url_link();
600
+			$registration->cache('Answer', $answer, $answer_cache_id);
601
+		}
602
+		return $this->_generate_question_input($registration, $question, $answer);
603
+	}
604
+
605
+
606
+	/**
607
+	 * @param EE_Registration $registration
608
+	 * @param EE_Question     $question
609
+	 * @param                 mixed EE_Answer|NULL      $answer
610
+	 * @return EE_Form_Input_Base
611
+	 * @throws \EE_Error
612
+	 */
613
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
614
+	{
615
+		$identifier                             = $question->is_system_question()
616
+			? $question->system_ID()
617
+			: $question->ID();
618
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
619
+		add_filter(
620
+			'FHEE__EE_Question__generate_form_input__country_options',
621
+			array($this, 'use_cached_countries_for_form_input'),
622
+			10,
623
+			4
624
+		);
625
+		add_filter(
626
+			'FHEE__EE_Question__generate_form_input__state_options',
627
+			array($this, 'use_cached_states_for_form_input'),
628
+			10,
629
+			4
630
+		);
631
+		$input_constructor_args                  = array(
632
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
636
+			'html_label_class' => 'ee-reg-qstn',
637
+		);
638
+		$input_constructor_args['html_label_id'] .= '-lbl';
639
+		if ($answer instanceof EE_Answer && $answer->ID()) {
640
+			$input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
+			$input_constructor_args['html_id']       .= '-' . $answer->ID();
642
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
643
+		}
644
+		$form_input = $question->generate_form_input(
645
+			$registration,
646
+			$answer,
647
+			$input_constructor_args
648
+		);
649
+		remove_filter(
650
+			'FHEE__EE_Question__generate_form_input__country_options',
651
+			array($this, 'use_cached_countries_for_form_input')
652
+		);
653
+		remove_filter(
654
+			'FHEE__EE_Question__generate_form_input__state_options',
655
+			array($this, 'use_cached_states_for_form_input')
656
+		);
657
+		return $form_input;
658
+	}
659
+
660
+
661
+	/**
662
+	 * Gets the list of countries for the form input
663
+	 *
664
+	 * @param array|null       $countries_list
665
+	 * @param \EE_Question     $question
666
+	 * @param \EE_Registration $registration
667
+	 * @param \EE_Answer       $answer
668
+	 * @return array 2d keys are country IDs, values are their names
669
+	 * @throws EE_Error
670
+	 * @throws InvalidArgumentException
671
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
672
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
673
+	 */
674
+	public function use_cached_countries_for_form_input(
675
+		$countries_list,
676
+		\EE_Question $question = null,
677
+		\EE_Registration $registration = null,
678
+		\EE_Answer $answer = null
679
+	) {
680
+		$country_options = array('' => '');
681
+		// get possibly cached list of countries
682
+		$countries = $this->checkout->action === 'process_reg_step'
683
+			? EEM_Country::instance()->get_all_countries()
684
+			: EEM_Country::instance()->get_all_active_countries();
685
+		if (! empty($countries)) {
686
+			foreach ($countries as $country) {
687
+				if ($country instanceof EE_Country) {
688
+					$country_options[$country->ID()] = $country->name();
689
+				}
690
+			}
691
+		}
692
+		if ($question instanceof EE_Question
693
+			&& $registration instanceof EE_Registration) {
694
+			$answer = EEM_Answer::instance()->get_one(
695
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
696
+			);
697
+		} else {
698
+			$answer = EE_Answer::new_instance();
699
+		}
700
+		$country_options = apply_filters(
701
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
702
+			$country_options,
703
+			$this,
704
+			$registration,
705
+			$question,
706
+			$answer
707
+		);
708
+		return $country_options;
709
+	}
710
+
711
+
712
+	/**
713
+	 * Gets the list of states for the form input
714
+	 *
715
+	 * @param array|null       $states_list
716
+	 * @param \EE_Question     $question
717
+	 * @param \EE_Registration $registration
718
+	 * @param \EE_Answer       $answer
719
+	 * @return array 2d keys are state IDs, values are their names
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
723
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
724
+	 */
725
+	public function use_cached_states_for_form_input(
726
+		$states_list,
727
+		\EE_Question $question = null,
728
+		\EE_Registration $registration = null,
729
+		\EE_Answer $answer = null
730
+	) {
731
+		$state_options = array('' => array('' => ''));
732
+		$states        = $this->checkout->action === 'process_reg_step'
733
+			? EEM_State::instance()->get_all_states()
734
+			: EEM_State::instance()->get_all_active_states();
735
+		if (! empty($states)) {
736
+			foreach ($states as $state) {
737
+				if ($state instanceof EE_State) {
738
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
739
+				}
740
+			}
741
+		}
742
+		$state_options = apply_filters(
743
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
744
+			$state_options,
745
+			$this,
746
+			$registration,
747
+			$question,
748
+			$answer
749
+		);
750
+		return $state_options;
751
+	}
752
+
753
+
754
+
755
+
756
+
757
+
758
+	/********************************************************************************************************/
759
+	/****************************************  PROCESS REG STEP  ****************************************/
760
+	/********************************************************************************************************/
761
+	/**
762
+	 * @return bool
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws ReflectionException
766
+	 * @throws RuntimeException
767
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
768
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
769
+	 */
770
+	public function process_reg_step()
771
+	{
772
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
773
+		// grab validated data from form
774
+		$valid_data = $this->checkout->current_step->valid_data();
775
+		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
776
+		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
777
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
778
+		if (empty($valid_data)) {
779
+			EE_Error::add_error(
780
+				esc_html__('No valid question responses were received.', 'event_espresso'),
781
+				__FILE__,
782
+				__FUNCTION__,
783
+				__LINE__
784
+			);
785
+			return false;
786
+		}
787
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788
+			EE_Error::add_error(
789
+				esc_html__(
790
+					'A valid transaction could not be initiated for processing your registrations.',
791
+					'event_espresso'
792
+				),
793
+				__FILE__,
794
+				__FUNCTION__,
795
+				__LINE__
796
+			);
797
+			return false;
798
+		}
799
+		// get cached registrations
800
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
801
+		// verify we got the goods
802
+		if (empty($registrations)) {
803
+			//combine the old translated string with a new one, in order to not break translations
804
+			$error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
805
+							 . sprintf(
806
+								 esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
807
+								 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
808
+								 '</a>',
809
+								 '<br />'
810
+							 );
811
+			EE_Error::add_error(
812
+				$error_message,
813
+				__FILE__,
814
+				__FUNCTION__,
815
+				__LINE__
816
+			);
817
+			return false;
818
+		}
819
+		// extract attendee info from form data and save to model objects
820
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
821
+		// if first pass thru SPCO,
822
+		// then let's check processed registrations against the total number of tickets in the cart
823
+		if ($registrations_processed === false) {
824
+			// but return immediately if the previous step exited early due to errors
825
+			return false;
826
+		} elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
827
+			// generate a correctly translated string for all possible singular/plural combinations
828
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
829
+				$error_msg = sprintf(
830
+					esc_html__(
831
+						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
832
+						'event_espresso'
833
+					),
834
+					$this->checkout->total_ticket_count,
835
+					$registrations_processed
836
+				);
837
+			} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
838
+				$error_msg = sprintf(
839
+					esc_html__(
840
+						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
841
+						'event_espresso'
842
+					),
843
+					$this->checkout->total_ticket_count,
844
+					$registrations_processed
845
+				);
846
+			} else {
847
+				$error_msg = sprintf(
848
+					esc_html__(
849
+						'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
850
+						'event_espresso'
851
+					),
852
+					$this->checkout->total_ticket_count,
853
+					$registrations_processed
854
+				);
855
+			}
856
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
857
+			return false;
858
+		}
859
+		// mark this reg step as completed
860
+		$this->set_completed();
861
+		$this->_set_success_message(
862
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
863
+		);
864
+		//do action in case a plugin wants to do something with the data submitted in step 1.
865
+		//passes EE_Single_Page_Checkout, and it's posted data
866
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
867
+		return true;
868
+	}
869
+
870
+
871
+	/**
872
+	 *    _process_registrations
873
+	 *
874
+	 * @param EE_Registration[] $registrations
875
+	 * @param array             $valid_data
876
+	 * @return bool|int
877
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
878
+	 * @throws EE_Error
879
+	 * @throws InvalidArgumentException
880
+	 * @throws ReflectionException
881
+	 * @throws RuntimeException
882
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
883
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
884
+	 */
885
+	private function _process_registrations($registrations = array(), $valid_data = array())
886
+	{
887
+		// load resources and set some defaults
888
+		EE_Registry::instance()->load_model('Attendee');
889
+		// holder for primary registrant attendee object
890
+		$this->checkout->primary_attendee_obj = null;
891
+		// array for tracking reg form data for the primary registrant
892
+		$primary_registrant = array(
893
+			'line_item_id' => null,
894
+		);
895
+		$copy_primary       = false;
896
+		// reg form sections that do not contain inputs
897
+		$non_input_form_sections = array(
898
+			'primary_registrant',
899
+			'additional_attendee_reg_info',
900
+			'spco_copy_attendee_chk',
901
+		);
902
+		// attendee counter
903
+		$att_nmbr = 0;
904
+		// grab the saved registrations from the transaction
905
+		foreach ($registrations as $registration) {
906
+			// verify EE_Registration object
907
+			if (! $registration instanceof EE_Registration) {
908
+				EE_Error::add_error(
909
+					esc_html__(
910
+						'An invalid Registration object was discovered when attempting to process your registration information.',
911
+						'event_espresso'
912
+					),
913
+					__FILE__,
914
+					__FUNCTION__,
915
+					__LINE__
916
+				);
917
+				return false;
918
+			}
919
+			/** @var string $reg_url_link */
920
+			$reg_url_link = $registration->reg_url_link();
921
+			// reg_url_link exists ?
922
+			if (! empty($reg_url_link)) {
923
+				// should this registration be processed during this visit ?
924
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
925
+					// if NOT revisiting, then let's save the registration now,
926
+					// so that we have a REG_ID to use when generating other objects
927
+					if (! $this->checkout->revisit) {
928
+						$registration->save();
929
+					}
930
+					/**
931
+					 * This allows plugins to trigger a fail on processing of a
932
+					 * registration for any conditions they may have for it to pass.
933
+					 *
934
+					 * @var bool   if true is returned by the plugin then the
935
+					 *            registration processing is halted.
936
+					 */
937
+					if (apply_filters(
938
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
939
+						false,
940
+						$att_nmbr,
941
+						$registration,
942
+						$registrations,
943
+						$valid_data,
944
+						$this
945
+					)) {
946
+						return false;
947
+					}
948
+
949
+					// Houston, we have a registration!
950
+					$att_nmbr++;
951
+					$this->_attendee_data[$reg_url_link] = array();
952
+					// grab any existing related answer objects
953
+					$this->_registration_answers = $registration->answers();
954
+					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
955
+					if (isset($valid_data[$reg_url_link])) {
956
+						// do we need to copy basic info from primary attendee ?
957
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
958
+										&& absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
959
+							? true
960
+							: false;
961
+						// filter form input data for this registration
962
+						$valid_data[$reg_url_link] = (array)apply_filters(
963
+							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
964
+							$valid_data[$reg_url_link]
965
+						);
966
+						if (isset($valid_data['primary_attendee'])) {
967
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
968
+								? $valid_data['primary_attendee']
969
+								: false;
970
+							unset($valid_data['primary_attendee']);
971
+						}
972
+						// now loop through our array of valid post data && process attendee reg forms
973
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
974
+							if (! in_array($form_section, $non_input_form_sections)) {
975
+								foreach ($form_inputs as $form_input => $input_value) {
976
+									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
977
+									// check for critical inputs
978
+									if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
979
+										$form_input,
980
+										$input_value
981
+									)
982
+									) {
983
+										return false;
984
+									}
985
+									// store a bit of data about the primary attendee
986
+									if ($att_nmbr === 1
987
+										&& ! empty($input_value)
988
+										&& $reg_url_link === $primary_registrant['line_item_id']
989
+									) {
990
+										$primary_registrant[$form_input] = $input_value;
991
+									} elseif ($copy_primary
992
+										&& $input_value === null
993
+										&& isset($primary_registrant[$form_input])
994
+									) {
995
+										$input_value = $primary_registrant[$form_input];
996
+									}
997
+									// now attempt to save the input data
998
+									if (! $this->_save_registration_form_input(
999
+										$registration,
1000
+										$form_input,
1001
+										$input_value
1002
+									)
1003
+									) {
1004
+										EE_Error::add_error(
1005
+											sprintf(
1006
+												esc_html__(
1007
+													'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1008
+													'event_espresso'
1009
+												),
1010
+												$form_input,
1011
+												$input_value
1012
+											),
1013
+											__FILE__,
1014
+											__FUNCTION__,
1015
+											__LINE__
1016
+										);
1017
+										return false;
1018
+									}
1019
+								}
1020
+							}
1021
+						}  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1022
+					}
1023
+					//EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1024
+					// this registration does not require additional attendee information ?
1025
+					if ($copy_primary
1026
+						&& $att_nmbr > 1
1027
+						&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1028
+					) {
1029
+						// just copy the primary registrant
1030
+						$attendee = $this->checkout->primary_attendee_obj;
1031
+					} else {
1032
+						// ensure critical details are set for additional attendees
1033
+						$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1034
+							? $this->_copy_critical_attendee_details_from_primary_registrant(
1035
+								$this->_attendee_data[$reg_url_link]
1036
+							)
1037
+							: $this->_attendee_data[$reg_url_link];
1038
+						// execute create attendee command (which may return an existing attendee)
1039
+						$attendee = EE_Registry::instance()->BUS->execute(
1040
+							new CreateAttendeeCommand(
1041
+								$this->_attendee_data[$reg_url_link],
1042
+								$registration
1043
+							)
1044
+						);
1045
+						// who's #1 ?
1046
+						if ($att_nmbr === 1) {
1047
+							$this->checkout->primary_attendee_obj = $attendee;
1048
+						}
1049
+					}
1050
+					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1051
+					// add relation to registration, set attendee ID, and cache attendee
1052
+					$this->_associate_attendee_with_registration($registration, $attendee);
1053
+					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1054
+					if (! $registration->attendee() instanceof EE_Attendee) {
1055
+						EE_Error::add_error(
1056
+							sprintf(
1057
+								esc_html__(
1058
+									'Registration %s has an invalid or missing Attendee object.',
1059
+									'event_espresso'
1060
+								),
1061
+								$reg_url_link
1062
+							),
1063
+							__FILE__,
1064
+							__FUNCTION__,
1065
+							__LINE__
1066
+						);
1067
+						return false;
1068
+					}
1069
+					/** @type EE_Registration_Processor $registration_processor */
1070
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1071
+					// at this point, we should have enough details about the registrant to consider the registration
1072
+					// NOT incomplete
1073
+					$registration_processor->toggle_incomplete_registration_status_to_default(
1074
+						$registration,
1075
+						false,
1076
+						new Context(
1077
+							'spco_reg_step_attendee_information_process_registrations',
1078
+							esc_html__(
1079
+								'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1080
+								'event_espresso'
1081
+							)
1082
+						)
1083
+					);
1084
+					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1085
+					// abandoned
1086
+					$this->checkout->transaction->toggle_failed_transaction_status();
1087
+					// if we've gotten this far, then let's save what we have
1088
+					$registration->save();
1089
+					// add relation between TXN and registration
1090
+					$this->_associate_registration_with_transaction($registration);
1091
+				}
1092
+			} else {
1093
+				EE_Error::add_error(
1094
+					esc_html__(
1095
+						'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1096
+						'event_espresso'
1097
+					),
1098
+					__FILE__,
1099
+					__FUNCTION__,
1100
+					__LINE__
1101
+				);
1102
+				// remove malformed data
1103
+				unset($valid_data[$reg_url_link]);
1104
+				return false;
1105
+			}
1106
+
1107
+		} // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1108
+		return $att_nmbr;
1109
+	}
1110
+
1111
+
1112
+	/**
1113
+	 *    _save_registration_form_input
1114
+	 *
1115
+	 * @param EE_Registration $registration
1116
+	 * @param string          $form_input
1117
+	 * @param string          $input_value
1118
+	 * @return bool
1119
+	 * @throws EE_Error
1120
+	 * @throws InvalidArgumentException
1121
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1122
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1123
+	 */
1124
+	private function _save_registration_form_input(
1125
+		EE_Registration $registration,
1126
+		$form_input = '',
1127
+		$input_value = ''
1128
+	) {
1129
+		// \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1130
+		// \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1131
+		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1132
+		// allow for plugins to hook in and do their own processing of the form input.
1133
+		// For plugins to bypass normal processing here, they just need to return a boolean value.
1134
+		if (apply_filters(
1135
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1136
+			false,
1137
+			$registration,
1138
+			$form_input,
1139
+			$input_value,
1140
+			$this
1141
+		)) {
1142
+			return true;
1143
+		}
1144
+		/*
1145 1145
          * $answer_cache_id is the key used to find the EE_Answer we want
1146 1146
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1147 1147
          */
1148
-        $answer_cache_id = $this->checkout->reg_url_link
1149
-            ? $form_input . '-' . $registration->reg_url_link()
1150
-            : $form_input;
1151
-        $answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1152
-                           && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1153
-            ? true
1154
-            : false;
1155
-        //rename form_inputs if they are EE_Attendee properties
1156
-        switch ((string) $form_input) {
1157
-            case 'state':
1158
-            case 'STA_ID':
1159
-                $attendee_property = true;
1160
-                $form_input        = 'STA_ID';
1161
-                break;
1162
-
1163
-            case 'country':
1164
-            case 'CNT_ISO':
1165
-                $attendee_property = true;
1166
-                $form_input        = 'CNT_ISO';
1167
-                break;
1168
-
1169
-            default:
1170
-                $ATT_input = 'ATT_' . $form_input;
1171
-                //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1172
-                $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1173
-                $form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1174
-        }
1175
-        // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1176
-        // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1177
-        // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1178
-        // if this form input has a corresponding attendee property
1179
-        if ($attendee_property) {
1180
-            $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1181
-            if ($answer_is_obj) {
1182
-                // and delete the corresponding answer since we won't be storing this data in that object
1183
-                $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1184
-                $this->_registration_answers[$answer_cache_id]->delete_permanently();
1185
-            }
1186
-            return true;
1187
-        } elseif ($answer_is_obj) {
1188
-            // save this data to the answer object
1189
-            $this->_registration_answers[$answer_cache_id]->set_value($input_value);
1190
-            $result = $this->_registration_answers[$answer_cache_id]->save();
1191
-            return $result !== false ? true : false;
1192
-        } else {
1193
-            foreach ($this->_registration_answers as $answer) {
1194
-                if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1195
-                    $answer->set_value($input_value);
1196
-                    $result = $answer->save();
1197
-                    return $result !== false ? true : false;
1198
-                }
1199
-            }
1200
-        }
1201
-        return false;
1202
-    }
1203
-
1204
-
1205
-    /**
1206
-     *    _verify_critical_attendee_details_are_set
1207
-     *
1208
-     * @param string $form_input
1209
-     * @param string $input_value
1210
-     * @return boolean
1211
-     */
1212
-    private function _verify_critical_attendee_details_are_set_and_validate_email(
1213
-        $form_input = '',
1214
-        $input_value = ''
1215
-    ) {
1216
-        if (empty($input_value)) {
1217
-            // if the form input isn't marked as being required, then just return
1218
-            if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1219
-                return true;
1220
-            }
1221
-            switch ($form_input) {
1222
-                case 'fname':
1223
-                    EE_Error::add_error(
1224
-                        esc_html__('First Name is a required value.', 'event_espresso'),
1225
-                        __FILE__,
1226
-                        __FUNCTION__,
1227
-                        __LINE__
1228
-                    );
1229
-                    return false;
1230
-                    break;
1231
-                case 'lname':
1232
-                    EE_Error::add_error(
1233
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
1234
-                        __FILE__,
1235
-                        __FUNCTION__,
1236
-                        __LINE__
1237
-                    );
1238
-                    return false;
1239
-                    break;
1240
-                case 'email':
1241
-                    EE_Error::add_error(
1242
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
1243
-                        __FILE__,
1244
-                        __FUNCTION__,
1245
-                        __LINE__
1246
-                    );
1247
-                    return false;
1248
-                    break;
1249
-            }
1250
-        }
1251
-        return true;
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     *    _associate_attendee_with_registration
1257
-     *
1258
-     * @param EE_Registration $registration
1259
-     * @param EE_Attendee     $attendee
1260
-     * @return void
1261
-     * @throws EE_Error
1262
-     * @throws RuntimeException
1263
-     */
1264
-    private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1265
-    {
1266
-        // add relation to attendee
1267
-        $registration->_add_relation_to($attendee, 'Attendee');
1268
-        $registration->set_attendee_id($attendee->ID());
1269
-        $registration->update_cache_after_object_save('Attendee', $attendee);
1270
-    }
1271
-
1272
-
1273
-    /**
1274
-     *    _associate_registration_with_transaction
1275
-     *
1276
-     * @param EE_Registration $registration
1277
-     * @return void
1278
-     * @throws \EE_Error
1279
-     */
1280
-    private function _associate_registration_with_transaction(EE_Registration $registration)
1281
-    {
1282
-        // add relation to registration
1283
-        $this->checkout->transaction->_add_relation_to($registration, 'Registration');
1284
-        $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1285
-    }
1286
-
1287
-
1288
-    /**
1289
-     *    _copy_critical_attendee_details_from_primary_registrant
1290
-     *    ensures that all attendees at least have data for first name, last name, and email address
1291
-     *
1292
-     * @param array $attendee_data
1293
-     * @return array
1294
-     * @throws \EE_Error
1295
-     */
1296
-    private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1297
-    {
1298
-        // bare minimum critical details include first name, last name, email address
1299
-        $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1300
-        // add address info to critical details?
1301
-        if (apply_filters(
1302
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1303
-            false
1304
-        )) {
1305
-            $address_details           = array(
1306
-                'ATT_address',
1307
-                'ATT_address2',
1308
-                'ATT_city',
1309
-                'STA_ID',
1310
-                'CNT_ISO',
1311
-                'ATT_zip',
1312
-                'ATT_phone',
1313
-            );
1314
-            $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1315
-        }
1316
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
1317
-            if (! isset($attendee_data[$critical_attendee_detail])
1318
-                || empty($attendee_data[$critical_attendee_detail])
1319
-            ) {
1320
-                $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1321
-                    $critical_attendee_detail
1322
-                );
1323
-            }
1324
-        }
1325
-        return $attendee_data;
1326
-    }
1327
-
1328
-
1329
-    /**
1330
-     *    update_reg_step
1331
-     *    this is the final step after a user  revisits the site to edit their attendee information
1332
-     *    this gets called AFTER the process_reg_step() method above
1333
-     *
1334
-     * @return bool
1335
-     * @throws EE_Error
1336
-     * @throws InvalidArgumentException
1337
-     * @throws ReflectionException
1338
-     * @throws RuntimeException
1339
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1340
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1341
-     */
1342
-    public function update_reg_step()
1343
-    {
1344
-        // save everything
1345
-        if ($this->process_reg_step()) {
1346
-            $this->checkout->redirect     = true;
1347
-            $this->checkout->redirect_url = add_query_arg(
1348
-                array(
1349
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
1350
-                    'revisit'        => true,
1351
-                ),
1352
-                $this->checkout->thank_you_page_url
1353
-            );
1354
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1355
-            return true;
1356
-        }
1357
-        return false;
1358
-    }
1148
+		$answer_cache_id = $this->checkout->reg_url_link
1149
+			? $form_input . '-' . $registration->reg_url_link()
1150
+			: $form_input;
1151
+		$answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1152
+						   && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1153
+			? true
1154
+			: false;
1155
+		//rename form_inputs if they are EE_Attendee properties
1156
+		switch ((string) $form_input) {
1157
+			case 'state':
1158
+			case 'STA_ID':
1159
+				$attendee_property = true;
1160
+				$form_input        = 'STA_ID';
1161
+				break;
1162
+
1163
+			case 'country':
1164
+			case 'CNT_ISO':
1165
+				$attendee_property = true;
1166
+				$form_input        = 'CNT_ISO';
1167
+				break;
1168
+
1169
+			default:
1170
+				$ATT_input = 'ATT_' . $form_input;
1171
+				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1172
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1173
+				$form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1174
+		}
1175
+		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1176
+		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1177
+		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1178
+		// if this form input has a corresponding attendee property
1179
+		if ($attendee_property) {
1180
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1181
+			if ($answer_is_obj) {
1182
+				// and delete the corresponding answer since we won't be storing this data in that object
1183
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1184
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1185
+			}
1186
+			return true;
1187
+		} elseif ($answer_is_obj) {
1188
+			// save this data to the answer object
1189
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1190
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1191
+			return $result !== false ? true : false;
1192
+		} else {
1193
+			foreach ($this->_registration_answers as $answer) {
1194
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1195
+					$answer->set_value($input_value);
1196
+					$result = $answer->save();
1197
+					return $result !== false ? true : false;
1198
+				}
1199
+			}
1200
+		}
1201
+		return false;
1202
+	}
1203
+
1204
+
1205
+	/**
1206
+	 *    _verify_critical_attendee_details_are_set
1207
+	 *
1208
+	 * @param string $form_input
1209
+	 * @param string $input_value
1210
+	 * @return boolean
1211
+	 */
1212
+	private function _verify_critical_attendee_details_are_set_and_validate_email(
1213
+		$form_input = '',
1214
+		$input_value = ''
1215
+	) {
1216
+		if (empty($input_value)) {
1217
+			// if the form input isn't marked as being required, then just return
1218
+			if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1219
+				return true;
1220
+			}
1221
+			switch ($form_input) {
1222
+				case 'fname':
1223
+					EE_Error::add_error(
1224
+						esc_html__('First Name is a required value.', 'event_espresso'),
1225
+						__FILE__,
1226
+						__FUNCTION__,
1227
+						__LINE__
1228
+					);
1229
+					return false;
1230
+					break;
1231
+				case 'lname':
1232
+					EE_Error::add_error(
1233
+						esc_html__('Last Name is a required value.', 'event_espresso'),
1234
+						__FILE__,
1235
+						__FUNCTION__,
1236
+						__LINE__
1237
+					);
1238
+					return false;
1239
+					break;
1240
+				case 'email':
1241
+					EE_Error::add_error(
1242
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
1243
+						__FILE__,
1244
+						__FUNCTION__,
1245
+						__LINE__
1246
+					);
1247
+					return false;
1248
+					break;
1249
+			}
1250
+		}
1251
+		return true;
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 *    _associate_attendee_with_registration
1257
+	 *
1258
+	 * @param EE_Registration $registration
1259
+	 * @param EE_Attendee     $attendee
1260
+	 * @return void
1261
+	 * @throws EE_Error
1262
+	 * @throws RuntimeException
1263
+	 */
1264
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1265
+	{
1266
+		// add relation to attendee
1267
+		$registration->_add_relation_to($attendee, 'Attendee');
1268
+		$registration->set_attendee_id($attendee->ID());
1269
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1270
+	}
1271
+
1272
+
1273
+	/**
1274
+	 *    _associate_registration_with_transaction
1275
+	 *
1276
+	 * @param EE_Registration $registration
1277
+	 * @return void
1278
+	 * @throws \EE_Error
1279
+	 */
1280
+	private function _associate_registration_with_transaction(EE_Registration $registration)
1281
+	{
1282
+		// add relation to registration
1283
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1284
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1285
+	}
1286
+
1287
+
1288
+	/**
1289
+	 *    _copy_critical_attendee_details_from_primary_registrant
1290
+	 *    ensures that all attendees at least have data for first name, last name, and email address
1291
+	 *
1292
+	 * @param array $attendee_data
1293
+	 * @return array
1294
+	 * @throws \EE_Error
1295
+	 */
1296
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1297
+	{
1298
+		// bare minimum critical details include first name, last name, email address
1299
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1300
+		// add address info to critical details?
1301
+		if (apply_filters(
1302
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1303
+			false
1304
+		)) {
1305
+			$address_details           = array(
1306
+				'ATT_address',
1307
+				'ATT_address2',
1308
+				'ATT_city',
1309
+				'STA_ID',
1310
+				'CNT_ISO',
1311
+				'ATT_zip',
1312
+				'ATT_phone',
1313
+			);
1314
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1315
+		}
1316
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1317
+			if (! isset($attendee_data[$critical_attendee_detail])
1318
+				|| empty($attendee_data[$critical_attendee_detail])
1319
+			) {
1320
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1321
+					$critical_attendee_detail
1322
+				);
1323
+			}
1324
+		}
1325
+		return $attendee_data;
1326
+	}
1327
+
1328
+
1329
+	/**
1330
+	 *    update_reg_step
1331
+	 *    this is the final step after a user  revisits the site to edit their attendee information
1332
+	 *    this gets called AFTER the process_reg_step() method above
1333
+	 *
1334
+	 * @return bool
1335
+	 * @throws EE_Error
1336
+	 * @throws InvalidArgumentException
1337
+	 * @throws ReflectionException
1338
+	 * @throws RuntimeException
1339
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1340
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1341
+	 */
1342
+	public function update_reg_step()
1343
+	{
1344
+		// save everything
1345
+		if ($this->process_reg_step()) {
1346
+			$this->checkout->redirect     = true;
1347
+			$this->checkout->redirect_url = add_query_arg(
1348
+				array(
1349
+					'e_reg_url_link' => $this->checkout->reg_url_link,
1350
+					'revisit'        => true,
1351
+				),
1352
+				$this->checkout->thank_you_page_url
1353
+			);
1354
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1355
+			return true;
1356
+		}
1357
+		return false;
1358
+	}
1359 1359
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -52 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $this->_slug     = 'attendee_information';
50 50
         $this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
51
+        $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
52 52
         $this->checkout  = $checkout;
53 53
         $this->_reset_success_message();
54 54
         $this->set_instructions(
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function translate_js_strings()
61 61
     {
62
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
62
+        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
63 63
             ' is a required question.',
64 64
             'event_espresso'
65 65
         );
66
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
66
+        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
67 67
             ' is a required question. Please enter a value for at least one of the options.',
68 68
             'event_espresso'
69 69
         );
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
             'Please answer all required questions correctly before proceeding.',
72 72
             'event_espresso'
73 73
         );
74
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
74
+        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
75 75
             esc_html__(
76 76
                 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77 77
                 'event_espresso'
78 78
             ),
79 79
             '<br/>'
80 80
         );
81
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
81
+        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
82 82
             'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83 83
             'event_espresso'
84 84
         );
85
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
85
+        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
86 86
             'You must enter a valid email address.',
87 87
             'event_espresso'
88 88
         );
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     && $this->checkout->visit_allows_processing_of_this_registration($registration)
146 146
                 ) {
147 147
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
-                    if (! $this->checkout->admin_request) {
148
+                    if ( ! $this->checkout->admin_request) {
149 149
                         $template_args['registrations'][$registration->reg_url_link()]    = $registration;
150 150
                         $template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151 151
                             $template_args['ticket_count'][$registration->ticket()->ID()]
@@ -194,8 +194,7 @@  discard block
 block discarded – undo
194 194
                 'html_id'         => $this->reg_form_name(),
195 195
                 'subsections'     => $subsections,
196 196
                 'layout_strategy' => $this->checkout->admin_request ?
197
-                    new EE_Div_Per_Section_Layout() :
198
-                    new EE_Template_Layout(
197
+                    new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
199 198
                         array(
200 199
                             'layout_template_file' => $this->_template, // layout_template
201 200
                             'template_args'        => $template_args,
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
             if ($question_groups) {
239 238
                 // array of params to pass to parent constructor
240 239
                 $form_args = array(
241
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
240
+                    'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
242 241
                     'html_class'      => 'ee-reg-form-attendee-dv',
243 242
                     'html_style'      => $this->checkout->admin_request
244 243
                         ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -294,7 +293,7 @@  discard block
 block discarded – undo
294 293
         // generate hidden input
295 294
         return new EE_Hidden_Input(
296 295
             array(
297
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
296
+                'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
298 297
                 'default' => $additional_attendee_reg_info,
299 298
             )
300 299
         );
@@ -314,11 +313,11 @@  discard block
 block discarded – undo
314 313
     {
315 314
         // array of params to pass to parent constructor
316 315
         $form_args = array(
317
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
316
+            'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
318 317
             'html_class'      => $this->checkout->admin_request
319 318
                 ? 'form-table ee-reg-form-qstn-grp-dv'
320 319
                 : 'ee-reg-form-qstn-grp-dv',
321
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
320
+            'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
322 321
             'subsections'     => array(
323 322
                 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324 323
             ),
@@ -329,7 +328,7 @@  discard block
 block discarded – undo
329 328
         // where params
330 329
         $query_params = array('QST_deleted' => 0);
331 330
         // don't load admin only questions on the frontend
332
-        if (! $this->checkout->admin_request) {
331
+        if ( ! $this->checkout->admin_request) {
333 332
             $query_params['QST_admin_only'] = array('!=', true);
334 333
         }
335 334
         $questions = $question_group->get_many_related(
@@ -473,7 +472,7 @@  discard block
 block discarded – undo
473 472
     {
474 473
         return new EE_Form_Section_HTML(
475 474
             EEH_Template::locate_template(
476
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
475
+                SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
477 476
                 apply_filters(
478 477
                     'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479 478
                     array()
@@ -505,16 +504,16 @@  discard block
 block discarded – undo
505 504
                 if ($registration->ticket()->ID() !== $prev_ticket) {
506 505
                     $item_name = $registration->ticket()->name();
507 506
                     $item_name .= $registration->ticket()->description() !== ''
508
-                        ? ' - ' . $registration->ticket()->description()
507
+                        ? ' - '.$registration->ticket()->description()
509 508
                         : '';
510
-                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
509
+                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] =
511 510
                         new EE_Form_Section_HTML(
512
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
511
+                            '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
513 512
                         );
514 513
                     $prev_ticket = $registration->ticket()->ID();
515 514
                 }
516 515
 
517
-                $copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
516
+                $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] =
518 517
                     new EE_Checkbox_Multi_Input(
519 518
                         array(
520 519
                             $registration->ID() => sprintf(
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
                             ),
524 523
                         ),
525 524
                         array(
526
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
525
+                            'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
527 526
                             'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528 527
                             'display_html_label_text' => false,
529 528
                         )
@@ -572,7 +571,7 @@  discard block
 block discarded – undo
572 571
             $registration,
573 572
             $question->system_ID()
574 573
         );
575
-        $answer       = $answer_value === null
574
+        $answer = $answer_value === null
576 575
             ? EEM_Answer::instance()->get_one(
577 576
                 array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578 577
             )
@@ -589,14 +588,14 @@  discard block
 block discarded – undo
589 588
         }
590 589
         // verify instance
591 590
         if ($answer instanceof EE_Answer) {
592
-            if (! empty($answer_value)) {
591
+            if ( ! empty($answer_value)) {
593 592
                 $answer->set('ANS_value', $answer_value);
594 593
             }
595 594
             $answer->cache('Question', $question);
596 595
             //remember system ID had a bug where sometimes it could be null
597 596
             $answer_cache_id = $question->is_system_question()
598
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
599
-                : $question->ID() . '-' . $registration->reg_url_link();
597
+                ? $question->system_ID().'-'.$registration->reg_url_link()
598
+                : $question->ID().'-'.$registration->reg_url_link();
600 599
             $registration->cache('Answer', $answer, $answer_cache_id);
601 600
         }
602 601
         return $this->_generate_question_input($registration, $question, $answer);
@@ -628,18 +627,18 @@  discard block
 block discarded – undo
628 627
             10,
629 628
             4
630 629
         );
631
-        $input_constructor_args                  = array(
632
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
630
+        $input_constructor_args = array(
631
+            'html_name'        => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
632
+            'html_id'          => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
633
+            'html_class'       => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
634
+            'html_label_id'    => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
636 635
             'html_label_class' => 'ee-reg-qstn',
637 636
         );
638 637
         $input_constructor_args['html_label_id'] .= '-lbl';
639 638
         if ($answer instanceof EE_Answer && $answer->ID()) {
640
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
642
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
639
+            $input_constructor_args['html_name']     .= '['.$answer->ID().']';
640
+            $input_constructor_args['html_id']       .= '-'.$answer->ID();
641
+            $input_constructor_args['html_label_id'] .= '-'.$answer->ID();
643 642
         }
644 643
         $form_input = $question->generate_form_input(
645 644
             $registration,
@@ -682,7 +681,7 @@  discard block
 block discarded – undo
682 681
         $countries = $this->checkout->action === 'process_reg_step'
683 682
             ? EEM_Country::instance()->get_all_countries()
684 683
             : EEM_Country::instance()->get_all_active_countries();
685
-        if (! empty($countries)) {
684
+        if ( ! empty($countries)) {
686 685
             foreach ($countries as $country) {
687 686
                 if ($country instanceof EE_Country) {
688 687
                     $country_options[$country->ID()] = $country->name();
@@ -732,7 +731,7 @@  discard block
 block discarded – undo
732 731
         $states        = $this->checkout->action === 'process_reg_step'
733 732
             ? EEM_State::instance()->get_all_states()
734 733
             : EEM_State::instance()->get_all_active_states();
735
-        if (! empty($states)) {
734
+        if ( ! empty($states)) {
736 735
             foreach ($states as $state) {
737 736
                 if ($state instanceof EE_State) {
738 737
                     $state_options[$state->country()->name()][$state->ID()] = $state->name();
@@ -784,7 +783,7 @@  discard block
 block discarded – undo
784 783
             );
785 784
             return false;
786 785
         }
787
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
786
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788 787
             EE_Error::add_error(
789 788
                 esc_html__(
790 789
                     'A valid transaction could not be initiated for processing your registrations.',
@@ -801,10 +800,10 @@  discard block
 block discarded – undo
801 800
         // verify we got the goods
802 801
         if (empty($registrations)) {
803 802
             //combine the old translated string with a new one, in order to not break translations
804
-            $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
803
+            $error_message = esc_html__('Your form data could not be applied to any valid registrations.', 'event_espresso')
805 804
                              . sprintf(
806 805
                                  esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
807
-                                 '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
806
+                                 '<a href="'.get_post_type_archive_link('espresso_events').'" >',
808 807
                                  '</a>',
809 808
                                  '<br />'
810 809
                              );
@@ -823,7 +822,7 @@  discard block
 block discarded – undo
823 822
         if ($registrations_processed === false) {
824 823
             // but return immediately if the previous step exited early due to errors
825 824
             return false;
826
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
825
+        } elseif ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
827 826
             // generate a correctly translated string for all possible singular/plural combinations
828 827
             if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
829 828
                 $error_msg = sprintf(
@@ -904,7 +903,7 @@  discard block
 block discarded – undo
904 903
         // grab the saved registrations from the transaction
905 904
         foreach ($registrations as $registration) {
906 905
             // verify EE_Registration object
907
-            if (! $registration instanceof EE_Registration) {
906
+            if ( ! $registration instanceof EE_Registration) {
908 907
                 EE_Error::add_error(
909 908
                     esc_html__(
910 909
                         'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -919,12 +918,12 @@  discard block
 block discarded – undo
919 918
             /** @var string $reg_url_link */
920 919
             $reg_url_link = $registration->reg_url_link();
921 920
             // reg_url_link exists ?
922
-            if (! empty($reg_url_link)) {
921
+            if ( ! empty($reg_url_link)) {
923 922
                 // should this registration be processed during this visit ?
924 923
                 if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
925 924
                     // if NOT revisiting, then let's save the registration now,
926 925
                     // so that we have a REG_ID to use when generating other objects
927
-                    if (! $this->checkout->revisit) {
926
+                    if ( ! $this->checkout->revisit) {
928 927
                         $registration->save();
929 928
                     }
930 929
                     /**
@@ -959,7 +958,7 @@  discard block
 block discarded – undo
959 958
                             ? true
960 959
                             : false;
961 960
                         // filter form input data for this registration
962
-                        $valid_data[$reg_url_link] = (array)apply_filters(
961
+                        $valid_data[$reg_url_link] = (array) apply_filters(
963 962
                             'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
964 963
                             $valid_data[$reg_url_link]
965 964
                         );
@@ -971,11 +970,11 @@  discard block
 block discarded – undo
971 970
                         }
972 971
                         // now loop through our array of valid post data && process attendee reg forms
973 972
                         foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
974
-                            if (! in_array($form_section, $non_input_form_sections)) {
973
+                            if ( ! in_array($form_section, $non_input_form_sections)) {
975 974
                                 foreach ($form_inputs as $form_input => $input_value) {
976 975
                                     // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
977 976
                                     // check for critical inputs
978
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
977
+                                    if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email(
979 978
                                         $form_input,
980 979
                                         $input_value
981 980
                                     )
@@ -995,7 +994,7 @@  discard block
 block discarded – undo
995 994
                                         $input_value = $primary_registrant[$form_input];
996 995
                                     }
997 996
                                     // now attempt to save the input data
998
-                                    if (! $this->_save_registration_form_input(
997
+                                    if ( ! $this->_save_registration_form_input(
999 998
                                         $registration,
1000 999
                                         $form_input,
1001 1000
                                         $input_value
@@ -1051,7 +1050,7 @@  discard block
 block discarded – undo
1051 1050
                     // add relation to registration, set attendee ID, and cache attendee
1052 1051
                     $this->_associate_attendee_with_registration($registration, $attendee);
1053 1052
                     // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1054
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1053
+                    if ( ! $registration->attendee() instanceof EE_Attendee) {
1055 1054
                         EE_Error::add_error(
1056 1055
                             sprintf(
1057 1056
                                 esc_html__(
@@ -1146,7 +1145,7 @@  discard block
 block discarded – undo
1146 1145
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1147 1146
          */
1148 1147
         $answer_cache_id = $this->checkout->reg_url_link
1149
-            ? $form_input . '-' . $registration->reg_url_link()
1148
+            ? $form_input.'-'.$registration->reg_url_link()
1150 1149
             : $form_input;
1151 1150
         $answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1152 1151
                            && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
@@ -1167,10 +1166,10 @@  discard block
 block discarded – undo
1167 1166
                 break;
1168 1167
 
1169 1168
             default:
1170
-                $ATT_input = 'ATT_' . $form_input;
1169
+                $ATT_input = 'ATT_'.$form_input;
1171 1170
                 //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1172 1171
                 $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1173
-                $form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1172
+                $form_input        = $attendee_property ? 'ATT_'.$form_input : $form_input;
1174 1173
         }
1175 1174
         // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1176 1175
         // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
@@ -1215,7 +1214,7 @@  discard block
 block discarded – undo
1215 1214
     ) {
1216 1215
         if (empty($input_value)) {
1217 1216
             // if the form input isn't marked as being required, then just return
1218
-            if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1217
+            if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1219 1218
                 return true;
1220 1219
             }
1221 1220
             switch ($form_input) {
@@ -1302,7 +1301,7 @@  discard block
 block discarded – undo
1302 1301
             'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1303 1302
             false
1304 1303
         )) {
1305
-            $address_details           = array(
1304
+            $address_details = array(
1306 1305
                 'ATT_address',
1307 1306
                 'ATT_address2',
1308 1307
                 'ATT_city',
@@ -1314,7 +1313,7 @@  discard block
 block discarded – undo
1314 1313
             $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1315 1314
         }
1316 1315
         foreach ($critical_attendee_details as $critical_attendee_detail) {
1317
-            if (! isset($attendee_data[$critical_attendee_detail])
1316
+            if ( ! isset($attendee_data[$critical_attendee_detail])
1318 1317
                 || empty($attendee_data[$critical_attendee_detail])
1319 1318
             ) {
1320 1319
                 $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -924,7 +924,7 @@
 block discarded – undo
924 924
      * handles toggling the checkin status for the registration,
925 925
      *
926 926
      * @access protected
927
-     * @return int|void
927
+     * @return integer
928 928
      * @throws EE_Error
929 929
      * @throws InvalidArgumentException
930 930
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +1197 added lines, -1197 removed lines patch added patch discarded remove patch
@@ -18,1256 +18,1256 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * This is used to hold the reports template data which is setup early in the request.
23
-     *
24
-     * @type array
25
-     */
26
-    protected $_reports_template_data = array();
21
+	/**
22
+	 * This is used to hold the reports template data which is setup early in the request.
23
+	 *
24
+	 * @type array
25
+	 */
26
+	protected $_reports_template_data = array();
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * Extend_Registrations_Admin_Page constructor.
32
-     *
33
-     * @param bool $routing
34
-     */
35
-    public function __construct($routing = true)
36
-    {
37
-        parent::__construct($routing);
38
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
42
-        }
43
-    }
30
+	/**
31
+	 * Extend_Registrations_Admin_Page constructor.
32
+	 *
33
+	 * @param bool $routing
34
+	 */
35
+	public function __construct($routing = true)
36
+	{
37
+		parent::__construct($routing);
38
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
42
+		}
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Extending page configuration.
48
-     */
49
-    protected function _extend_page_config()
50
-    {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
52
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53
-            ? $this->_req_data['_REG_ID']
54
-            : 0;
55
-        $new_page_routes = array(
56
-            'reports'                  => array(
57
-                'func'       => '_registration_reports',
58
-                'capability' => 'ee_read_registrations',
59
-            ),
60
-            'registration_checkins'    => array(
61
-                'func'       => '_registration_checkin_list_table',
62
-                'capability' => 'ee_read_checkins',
63
-            ),
64
-            'newsletter_selected_send' => array(
65
-                'func'       => '_newsletter_selected_send',
66
-                'noheader'   => true,
67
-                'capability' => 'ee_send_message',
68
-            ),
69
-            'delete_checkin_rows'      => array(
70
-                'func'       => '_delete_checkin_rows',
71
-                'noheader'   => true,
72
-                'capability' => 'ee_delete_checkins',
73
-            ),
74
-            'delete_checkin_row'       => array(
75
-                'func'       => '_delete_checkin_row',
76
-                'noheader'   => true,
77
-                'capability' => 'ee_delete_checkin',
78
-                'obj_id'     => $reg_id,
79
-            ),
80
-            'toggle_checkin_status'    => array(
81
-                'func'       => '_toggle_checkin_status',
82
-                'noheader'   => true,
83
-                'capability' => 'ee_edit_checkin',
84
-                'obj_id'     => $reg_id,
85
-            ),
86
-            'toggle_checkin_status_bulk' => array(
87
-                'func' => '_toggle_checkin_status',
88
-                'noheader' => true,
89
-                'capability' => 'ee_edit_checkins'
90
-            ),
91
-            'event_registrations'      => array(
92
-                'func'       => '_event_registrations_list_table',
93
-                'capability' => 'ee_read_checkins',
94
-            ),
95
-            'registrations_checkin_report' => array(
96
-                'func'       => '_registrations_checkin_report',
97
-                'noheader'   => true,
98
-                'capability' => 'ee_read_registrations',
99
-            ),
100
-        );
101
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
102
-        $new_page_config = array(
103
-            'reports'               => array(
104
-                'nav'           => array(
105
-                    'label' => esc_html__('Reports', 'event_espresso'),
106
-                    'order' => 30,
107
-                ),
108
-                'help_tabs'     => array(
109
-                    'registrations_reports_help_tab' => array(
110
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
-                        'filename' => 'registrations_reports',
112
-                    ),
113
-                ),
114
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
115
-                'require_nonce' => false,
116
-            ),
117
-            'event_registrations'   => array(
118
-                'nav'           => array(
119
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
120
-                    'order'      => 10,
121
-                    'persistent' => true,
122
-                ),
123
-                'help_tabs'     => array(
124
-                    'registrations_event_checkin_help_tab'                       => array(
125
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
-                        'filename' => 'registrations_event_checkin',
127
-                    ),
128
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
129
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
-                        'filename' => 'registrations_event_checkin_table_column_headings',
131
-                    ),
132
-                    'registrations_event_checkin_filters_help_tab'               => array(
133
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
-                        'filename' => 'registrations_event_checkin_filters',
135
-                    ),
136
-                    'registrations_event_checkin_views_help_tab'                 => array(
137
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
-                        'filename' => 'registrations_event_checkin_views',
139
-                    ),
140
-                    'registrations_event_checkin_other_help_tab'                 => array(
141
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
-                        'filename' => 'registrations_event_checkin_other',
143
-                    ),
144
-                ),
145
-                'help_tour'     => array('Event_Checkin_Help_Tour'),
146
-                'qtips'         => array('Registration_List_Table_Tips'),
147
-                'list_table'    => 'EE_Event_Registrations_List_Table',
148
-                'metaboxes'     => array(),
149
-                'require_nonce' => false,
150
-            ),
151
-            'registration_checkins' => array(
152
-                'nav'           => array(
153
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
154
-                    'order'      => 15,
155
-                    'persistent' => false,
156
-                ),
157
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
-                //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
159
-                'metaboxes'     => array(),
160
-                'require_nonce' => false,
161
-            ),
162
-        );
163
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
164
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
165
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
166
-    }
46
+	/**
47
+	 * Extending page configuration.
48
+	 */
49
+	protected function _extend_page_config()
50
+	{
51
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
52
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53
+			? $this->_req_data['_REG_ID']
54
+			: 0;
55
+		$new_page_routes = array(
56
+			'reports'                  => array(
57
+				'func'       => '_registration_reports',
58
+				'capability' => 'ee_read_registrations',
59
+			),
60
+			'registration_checkins'    => array(
61
+				'func'       => '_registration_checkin_list_table',
62
+				'capability' => 'ee_read_checkins',
63
+			),
64
+			'newsletter_selected_send' => array(
65
+				'func'       => '_newsletter_selected_send',
66
+				'noheader'   => true,
67
+				'capability' => 'ee_send_message',
68
+			),
69
+			'delete_checkin_rows'      => array(
70
+				'func'       => '_delete_checkin_rows',
71
+				'noheader'   => true,
72
+				'capability' => 'ee_delete_checkins',
73
+			),
74
+			'delete_checkin_row'       => array(
75
+				'func'       => '_delete_checkin_row',
76
+				'noheader'   => true,
77
+				'capability' => 'ee_delete_checkin',
78
+				'obj_id'     => $reg_id,
79
+			),
80
+			'toggle_checkin_status'    => array(
81
+				'func'       => '_toggle_checkin_status',
82
+				'noheader'   => true,
83
+				'capability' => 'ee_edit_checkin',
84
+				'obj_id'     => $reg_id,
85
+			),
86
+			'toggle_checkin_status_bulk' => array(
87
+				'func' => '_toggle_checkin_status',
88
+				'noheader' => true,
89
+				'capability' => 'ee_edit_checkins'
90
+			),
91
+			'event_registrations'      => array(
92
+				'func'       => '_event_registrations_list_table',
93
+				'capability' => 'ee_read_checkins',
94
+			),
95
+			'registrations_checkin_report' => array(
96
+				'func'       => '_registrations_checkin_report',
97
+				'noheader'   => true,
98
+				'capability' => 'ee_read_registrations',
99
+			),
100
+		);
101
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
102
+		$new_page_config = array(
103
+			'reports'               => array(
104
+				'nav'           => array(
105
+					'label' => esc_html__('Reports', 'event_espresso'),
106
+					'order' => 30,
107
+				),
108
+				'help_tabs'     => array(
109
+					'registrations_reports_help_tab' => array(
110
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
+						'filename' => 'registrations_reports',
112
+					),
113
+				),
114
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
115
+				'require_nonce' => false,
116
+			),
117
+			'event_registrations'   => array(
118
+				'nav'           => array(
119
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
120
+					'order'      => 10,
121
+					'persistent' => true,
122
+				),
123
+				'help_tabs'     => array(
124
+					'registrations_event_checkin_help_tab'                       => array(
125
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
+						'filename' => 'registrations_event_checkin',
127
+					),
128
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
129
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
+						'filename' => 'registrations_event_checkin_table_column_headings',
131
+					),
132
+					'registrations_event_checkin_filters_help_tab'               => array(
133
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
+						'filename' => 'registrations_event_checkin_filters',
135
+					),
136
+					'registrations_event_checkin_views_help_tab'                 => array(
137
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
+						'filename' => 'registrations_event_checkin_views',
139
+					),
140
+					'registrations_event_checkin_other_help_tab'                 => array(
141
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
+						'filename' => 'registrations_event_checkin_other',
143
+					),
144
+				),
145
+				'help_tour'     => array('Event_Checkin_Help_Tour'),
146
+				'qtips'         => array('Registration_List_Table_Tips'),
147
+				'list_table'    => 'EE_Event_Registrations_List_Table',
148
+				'metaboxes'     => array(),
149
+				'require_nonce' => false,
150
+			),
151
+			'registration_checkins' => array(
152
+				'nav'           => array(
153
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
154
+					'order'      => 15,
155
+					'persistent' => false,
156
+				),
157
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
+				//'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
159
+				'metaboxes'     => array(),
160
+				'require_nonce' => false,
161
+			),
162
+		);
163
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
164
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
165
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * Ajax hooks for all routes in this page.
171
-     */
172
-    protected function _ajax_hooks()
173
-    {
174
-        parent::_ajax_hooks();
175
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
176
-    }
169
+	/**
170
+	 * Ajax hooks for all routes in this page.
171
+	 */
172
+	protected function _ajax_hooks()
173
+	{
174
+		parent::_ajax_hooks();
175
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * Global scripts for all routes in this page.
181
-     */
182
-    public function load_scripts_styles()
183
-    {
184
-        parent::load_scripts_styles();
185
-        //if newsletter message type is active then let's add filter and load js for it.
186
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
187
-            //enqueue newsletter js
188
-            wp_enqueue_script(
189
-                'ee-newsletter-trigger',
190
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
191
-                array('ee-dialog'),
192
-                EVENT_ESPRESSO_VERSION,
193
-                true
194
-            );
195
-            wp_enqueue_style(
196
-                'ee-newsletter-trigger-css',
197
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
198
-                array(),
199
-                EVENT_ESPRESSO_VERSION
200
-            );
201
-            //hook in buttons for newsletter message type trigger.
202
-            add_action(
203
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
204
-                array($this, 'add_newsletter_action_buttons'),
205
-                10
206
-            );
207
-        }
208
-    }
179
+	/**
180
+	 * Global scripts for all routes in this page.
181
+	 */
182
+	public function load_scripts_styles()
183
+	{
184
+		parent::load_scripts_styles();
185
+		//if newsletter message type is active then let's add filter and load js for it.
186
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
187
+			//enqueue newsletter js
188
+			wp_enqueue_script(
189
+				'ee-newsletter-trigger',
190
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
191
+				array('ee-dialog'),
192
+				EVENT_ESPRESSO_VERSION,
193
+				true
194
+			);
195
+			wp_enqueue_style(
196
+				'ee-newsletter-trigger-css',
197
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
198
+				array(),
199
+				EVENT_ESPRESSO_VERSION
200
+			);
201
+			//hook in buttons for newsletter message type trigger.
202
+			add_action(
203
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
204
+				array($this, 'add_newsletter_action_buttons'),
205
+				10
206
+			);
207
+		}
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     * Scripts and styles for just the reports route.
213
-     */
214
-    public function load_scripts_styles_reports()
215
-    {
216
-        wp_register_script(
217
-            'ee-reg-reports-js',
218
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
219
-            array('google-charts'),
220
-            EVENT_ESPRESSO_VERSION,
221
-            true
222
-        );
223
-        wp_enqueue_script('ee-reg-reports-js');
224
-        $this->_registration_reports_js_setup();
225
-    }
211
+	/**
212
+	 * Scripts and styles for just the reports route.
213
+	 */
214
+	public function load_scripts_styles_reports()
215
+	{
216
+		wp_register_script(
217
+			'ee-reg-reports-js',
218
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
219
+			array('google-charts'),
220
+			EVENT_ESPRESSO_VERSION,
221
+			true
222
+		);
223
+		wp_enqueue_script('ee-reg-reports-js');
224
+		$this->_registration_reports_js_setup();
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * Register screen options for event_registrations route.
230
-     */
231
-    protected function _add_screen_options_event_registrations()
232
-    {
233
-        $this->_per_page_screen_option();
234
-    }
228
+	/**
229
+	 * Register screen options for event_registrations route.
230
+	 */
231
+	protected function _add_screen_options_event_registrations()
232
+	{
233
+		$this->_per_page_screen_option();
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * Register screen options for registration_checkins route
239
-     */
240
-    protected function _add_screen_options_registration_checkins()
241
-    {
242
-        $page_title = $this->_admin_page_title;
243
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
244
-        $this->_per_page_screen_option();
245
-        $this->_admin_page_title = $page_title;
246
-    }
237
+	/**
238
+	 * Register screen options for registration_checkins route
239
+	 */
240
+	protected function _add_screen_options_registration_checkins()
241
+	{
242
+		$page_title = $this->_admin_page_title;
243
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
244
+		$this->_per_page_screen_option();
245
+		$this->_admin_page_title = $page_title;
246
+	}
247 247
 
248 248
 
249
-    /**
250
-     * Set views property for event_registrations route.
251
-     */
252
-    protected function _set_list_table_views_event_registrations()
253
-    {
254
-        $this->_views = array(
255
-            'all' => array(
256
-                'slug'        => 'all',
257
-                'label'       => esc_html__('All', 'event_espresso'),
258
-                'count'       => 0,
259
-                'bulk_action' => ! isset($this->_req_data['event_id'])
260
-                    ? array()
261
-                    : array(
262
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
263
-                    ),
264
-            ),
265
-        );
266
-    }
249
+	/**
250
+	 * Set views property for event_registrations route.
251
+	 */
252
+	protected function _set_list_table_views_event_registrations()
253
+	{
254
+		$this->_views = array(
255
+			'all' => array(
256
+				'slug'        => 'all',
257
+				'label'       => esc_html__('All', 'event_espresso'),
258
+				'count'       => 0,
259
+				'bulk_action' => ! isset($this->_req_data['event_id'])
260
+					? array()
261
+					: array(
262
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
263
+					),
264
+			),
265
+		);
266
+	}
267 267
 
268 268
 
269
-    /**
270
-     * Set views property for registration_checkins route.
271
-     */
272
-    protected function _set_list_table_views_registration_checkins()
273
-    {
274
-        $this->_views = array(
275
-            'all' => array(
276
-                'slug'        => 'all',
277
-                'label'       => esc_html__('All', 'event_espresso'),
278
-                'count'       => 0,
279
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
280
-            ),
281
-        );
282
-    }
269
+	/**
270
+	 * Set views property for registration_checkins route.
271
+	 */
272
+	protected function _set_list_table_views_registration_checkins()
273
+	{
274
+		$this->_views = array(
275
+			'all' => array(
276
+				'slug'        => 'all',
277
+				'label'       => esc_html__('All', 'event_espresso'),
278
+				'count'       => 0,
279
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
280
+			),
281
+		);
282
+	}
283 283
 
284 284
 
285
-    /**
286
-     * callback for ajax action.
287
-     *
288
-     * @since 4.3.0
289
-     * @return void (JSON)
290
-     * @throws EE_Error
291
-     * @throws InvalidArgumentException
292
-     * @throws InvalidDataTypeException
293
-     * @throws InvalidInterfaceException
294
-     */
295
-    public function get_newsletter_form_content()
296
-    {
297
-        //do a nonce check cause we're not coming in from an normal route here.
298
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
-            $this->_req_data['get_newsletter_form_content_nonce']
300
-        ) : '';
301
-        $nonce_ref = 'get_newsletter_form_content_nonce';
302
-        $this->_verify_nonce($nonce, $nonce_ref);
303
-        //let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
305
-            EE_Error::add_error(
306
-                esc_html__(
307
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
308
-                    'event_espresso'
309
-                ),
310
-                __FILE__,
311
-                __FUNCTION__,
312
-                __LINE__
313
-            );
314
-            $this->_template_args['success'] = false;
315
-            $this->_template_args['error'] = true;
316
-            $this->_return_json();
317
-        }
318
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
320
-            EE_Error::add_error(
321
-                sprintf(
322
-                    esc_html__(
323
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
-                        'event_espresso'
325
-                    ),
326
-                    $this->_req_data['GRP_ID']
327
-                ),
328
-                __FILE__,
329
-                __FUNCTION__,
330
-                __LINE__
331
-            );
332
-            $this->_template_args['success'] = false;
333
-            $this->_template_args['error'] = true;
334
-            $this->_return_json();
335
-        }
336
-        $MTPs = $MTPG->context_templates();
337
-        $MTPs = $MTPs['attendee'];
338
-        $template_fields = array();
339
-        /** @var EE_Message_Template $MTP */
340
-        foreach ($MTPs as $MTP) {
341
-            $field = $MTP->get('MTP_template_field');
342
-            if ($field === 'content') {
343
-                $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
345
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
346
-                }
347
-                continue;
348
-            }
349
-            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
350
-        }
351
-        $this->_template_args['success'] = true;
352
-        $this->_template_args['error'] = false;
353
-        $this->_template_args['data'] = array(
354
-            'batch_message_from'    => isset($template_fields['from'])
355
-                ? $template_fields['from']
356
-                : '',
357
-            'batch_message_subject' => isset($template_fields['subject'])
358
-                ? $template_fields['subject']
359
-                : '',
360
-            'batch_message_content' => isset($template_fields['newsletter_content'])
361
-                ? $template_fields['newsletter_content']
362
-                : '',
363
-        );
364
-        $this->_return_json();
365
-    }
285
+	/**
286
+	 * callback for ajax action.
287
+	 *
288
+	 * @since 4.3.0
289
+	 * @return void (JSON)
290
+	 * @throws EE_Error
291
+	 * @throws InvalidArgumentException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws InvalidInterfaceException
294
+	 */
295
+	public function get_newsletter_form_content()
296
+	{
297
+		//do a nonce check cause we're not coming in from an normal route here.
298
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
+			$this->_req_data['get_newsletter_form_content_nonce']
300
+		) : '';
301
+		$nonce_ref = 'get_newsletter_form_content_nonce';
302
+		$this->_verify_nonce($nonce, $nonce_ref);
303
+		//let's get the mtp for the incoming MTP_ ID
304
+		if (! isset($this->_req_data['GRP_ID'])) {
305
+			EE_Error::add_error(
306
+				esc_html__(
307
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
308
+					'event_espresso'
309
+				),
310
+				__FILE__,
311
+				__FUNCTION__,
312
+				__LINE__
313
+			);
314
+			$this->_template_args['success'] = false;
315
+			$this->_template_args['error'] = true;
316
+			$this->_return_json();
317
+		}
318
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
+		if (! $MTPG instanceof EE_Message_Template_Group) {
320
+			EE_Error::add_error(
321
+				sprintf(
322
+					esc_html__(
323
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
+						'event_espresso'
325
+					),
326
+					$this->_req_data['GRP_ID']
327
+				),
328
+				__FILE__,
329
+				__FUNCTION__,
330
+				__LINE__
331
+			);
332
+			$this->_template_args['success'] = false;
333
+			$this->_template_args['error'] = true;
334
+			$this->_return_json();
335
+		}
336
+		$MTPs = $MTPG->context_templates();
337
+		$MTPs = $MTPs['attendee'];
338
+		$template_fields = array();
339
+		/** @var EE_Message_Template $MTP */
340
+		foreach ($MTPs as $MTP) {
341
+			$field = $MTP->get('MTP_template_field');
342
+			if ($field === 'content') {
343
+				$content = $MTP->get('MTP_content');
344
+				if (! empty($content['newsletter_content'])) {
345
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
346
+				}
347
+				continue;
348
+			}
349
+			$template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
350
+		}
351
+		$this->_template_args['success'] = true;
352
+		$this->_template_args['error'] = false;
353
+		$this->_template_args['data'] = array(
354
+			'batch_message_from'    => isset($template_fields['from'])
355
+				? $template_fields['from']
356
+				: '',
357
+			'batch_message_subject' => isset($template_fields['subject'])
358
+				? $template_fields['subject']
359
+				: '',
360
+			'batch_message_content' => isset($template_fields['newsletter_content'])
361
+				? $template_fields['newsletter_content']
362
+				: '',
363
+		);
364
+		$this->_return_json();
365
+	}
366 366
 
367 367
 
368
-    /**
369
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
370
-     *
371
-     * @since 4.3.0
372
-     * @param EE_Admin_List_Table $list_table
373
-     * @return void
374
-     * @throws InvalidArgumentException
375
-     * @throws InvalidDataTypeException
376
-     * @throws InvalidInterfaceException
377
-     */
378
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379
-    {
380
-        if (! EE_Registry::instance()->CAP->current_user_can(
381
-            'ee_send_message',
382
-            'espresso_registrations_newsletter_selected_send'
383
-        )
384
-        ) {
385
-            return;
386
-        }
387
-        $routes_to_add_to = array(
388
-            'contact_list',
389
-            'event_registrations',
390
-            'default',
391
-        );
392
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
394
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
395
-            ) {
396
-                echo '';
397
-            } else {
398
-                $button_text = sprintf(
399
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
400
-                    '<span class="send-selected-newsletter-count">0</span>'
401
-                );
402
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
403
-                     . '<span class="dashicons dashicons-email "></span>'
404
-                     . $button_text
405
-                     . '</button>';
406
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
407
-            }
408
-        }
409
-    }
368
+	/**
369
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
370
+	 *
371
+	 * @since 4.3.0
372
+	 * @param EE_Admin_List_Table $list_table
373
+	 * @return void
374
+	 * @throws InvalidArgumentException
375
+	 * @throws InvalidDataTypeException
376
+	 * @throws InvalidInterfaceException
377
+	 */
378
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379
+	{
380
+		if (! EE_Registry::instance()->CAP->current_user_can(
381
+			'ee_send_message',
382
+			'espresso_registrations_newsletter_selected_send'
383
+		)
384
+		) {
385
+			return;
386
+		}
387
+		$routes_to_add_to = array(
388
+			'contact_list',
389
+			'event_registrations',
390
+			'default',
391
+		);
392
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
394
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
395
+			) {
396
+				echo '';
397
+			} else {
398
+				$button_text = sprintf(
399
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
400
+					'<span class="send-selected-newsletter-count">0</span>'
401
+				);
402
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
403
+					 . '<span class="dashicons dashicons-email "></span>'
404
+					 . $button_text
405
+					 . '</button>';
406
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
407
+			}
408
+		}
409
+	}
410 410
 
411 411
 
412
-    /**
413
-     * @throws DomainException
414
-     * @throws EE_Error
415
-     * @throws InvalidArgumentException
416
-     * @throws InvalidDataTypeException
417
-     * @throws InvalidInterfaceException
418
-     */
419
-    public function newsletter_send_form_skeleton()
420
-    {
421
-        $list_table = $this->_list_table_object;
422
-        $codes = array();
423
-        //need to templates for the newsletter message type for the template selector.
424
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
425
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
426
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
427
-        );
428
-        foreach ($mtps as $mtp) {
429
-            $name = $mtp->name();
430
-            $values[] = array(
431
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
432
-                'id'   => $mtp->ID(),
433
-            );
434
-        }
435
-        //need to get a list of shortcodes that are available for the newsletter message type.
436
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
437
-            'newsletter',
438
-            'email',
439
-            array(),
440
-            'attendee',
441
-            false
442
-        );
443
-        foreach ($shortcodes as $field => $shortcode_array) {
444
-            $available_shortcodes = array();
445
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
446
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
447
-                    ? 'content'
448
-                    : $field;
449
-                $field_id = 'batch-message-' . strtolower($field_id);
450
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451
-                                          . $shortcode
452
-                                          . '" data-linked-input-id="' . $field_id . '">'
453
-                                          . $shortcode
454
-                                          . '</span>';
455
-            }
456
-            $codes[$field] = implode(', ', $available_shortcodes);
457
-        }
458
-        $shortcodes = $codes;
459
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
460
-        $form_template_args = array(
461
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462
-            'form_route'        => 'newsletter_selected_send',
463
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
464
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
465
-            'redirect_back_to'  => $this->_req_action,
466
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
467
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
468
-            'shortcodes'        => $shortcodes,
469
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
470
-        );
471
-        EEH_Template::display_template($form_template, $form_template_args);
472
-    }
412
+	/**
413
+	 * @throws DomainException
414
+	 * @throws EE_Error
415
+	 * @throws InvalidArgumentException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws InvalidInterfaceException
418
+	 */
419
+	public function newsletter_send_form_skeleton()
420
+	{
421
+		$list_table = $this->_list_table_object;
422
+		$codes = array();
423
+		//need to templates for the newsletter message type for the template selector.
424
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
425
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
426
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
427
+		);
428
+		foreach ($mtps as $mtp) {
429
+			$name = $mtp->name();
430
+			$values[] = array(
431
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
432
+				'id'   => $mtp->ID(),
433
+			);
434
+		}
435
+		//need to get a list of shortcodes that are available for the newsletter message type.
436
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
437
+			'newsletter',
438
+			'email',
439
+			array(),
440
+			'attendee',
441
+			false
442
+		);
443
+		foreach ($shortcodes as $field => $shortcode_array) {
444
+			$available_shortcodes = array();
445
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
446
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
447
+					? 'content'
448
+					: $field;
449
+				$field_id = 'batch-message-' . strtolower($field_id);
450
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451
+										  . $shortcode
452
+										  . '" data-linked-input-id="' . $field_id . '">'
453
+										  . $shortcode
454
+										  . '</span>';
455
+			}
456
+			$codes[$field] = implode(', ', $available_shortcodes);
457
+		}
458
+		$shortcodes = $codes;
459
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
460
+		$form_template_args = array(
461
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462
+			'form_route'        => 'newsletter_selected_send',
463
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
464
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
465
+			'redirect_back_to'  => $this->_req_action,
466
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
467
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
468
+			'shortcodes'        => $shortcodes,
469
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
470
+		);
471
+		EEH_Template::display_template($form_template, $form_template_args);
472
+	}
473 473
 
474 474
 
475
-    /**
476
-     * Handles sending selected registrations/contacts a newsletter.
477
-     *
478
-     * @since  4.3.0
479
-     * @return void
480
-     * @throws EE_Error
481
-     * @throws InvalidArgumentException
482
-     * @throws InvalidDataTypeException
483
-     * @throws InvalidInterfaceException
484
-     */
485
-    protected function _newsletter_selected_send()
486
-    {
487
-        $success = true;
488
-        //first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
-            EE_Error::add_error(
491
-                esc_html__(
492
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
-                    'event_espresso'
494
-                ),
495
-                __FILE__,
496
-                __FUNCTION__,
497
-                __LINE__
498
-            );
499
-            $success = false;
500
-        }
501
-        if ($success) {
502
-            //update Message template in case there are any changes
503
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
-                $this->_req_data['newsletter_mtp_selected']
505
-            );
506
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
507
-                ? $Message_Template_Group->context_templates()
508
-                : array();
509
-            if (empty($Message_Templates)) {
510
-                EE_Error::add_error(
511
-                    esc_html__(
512
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
513
-                        'event_espresso'
514
-                    ),
515
-                    __FILE__,
516
-                    __FUNCTION__,
517
-                    __LINE__
518
-                );
519
-            }
520
-            //let's just update the specific fields
521
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
522
-                if ($Message_Template instanceof EE_Message_Template) {
523
-                    $field = $Message_Template->get('MTP_template_field');
524
-                    $content = $Message_Template->get('MTP_content');
525
-                    $new_content = $content;
526
-                    switch ($field) {
527
-                        case 'from':
528
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
529
-                                ? $this->_req_data['batch_message']['from']
530
-                                : $content;
531
-                            break;
532
-                        case 'subject':
533
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
534
-                                ? $this->_req_data['batch_message']['subject']
535
-                                : $content;
536
-                            break;
537
-                        case 'content':
538
-                            $new_content = $content;
539
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
-                                ? $this->_req_data['batch_message']['content']
541
-                                : $content['newsletter_content'];
542
-                            break;
543
-                        default:
544
-                            //continue the foreach loop, we don't want to set $new_content nor save.
545
-                            continue 2;
546
-                    }
547
-                    $Message_Template->set('MTP_content', $new_content);
548
-                    $Message_Template->save();
549
-                }
550
-            }
551
-            //great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
-                ? $this->_req_data['batch_message']['id_type']
554
-                : 'registration';
555
-            //id_type will affect how we assemble the ids.
556
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
557
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
-                : array();
559
-            $registrations_used_for_contact_data = array();
560
-            //using switch because eventually we'll have other contexts that will be used for generating messages.
561
-            switch ($id_type) {
562
-                case 'registration':
563
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
-                        array(
565
-                            array(
566
-                                'REG_ID' => array('IN', $ids),
567
-                            ),
568
-                        )
569
-                    );
570
-                    break;
571
-                case 'contact':
572
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
573
-                        ->get_latest_registration_for_each_of_given_contacts($ids);
574
-                    break;
575
-            }
576
-            do_action_ref_array(
577
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
-                array(
579
-                    $registrations_used_for_contact_data,
580
-                    $Message_Template_Group->ID()
581
-                )
582
-            );
583
-            //kept for backward compat, internally we no longer use this action.
584
-            //@deprecated 4.8.36.rc.002
585
-            $contacts = $id_type === 'registration'
586
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
-            do_action_ref_array(
589
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
-                array(
591
-                    $contacts,
592
-                    $Message_Template_Group->ID()
593
-                )
594
-            );
595
-        }
596
-        $query_args = array(
597
-            'action' => ! empty($this->_req_data['redirect_back_to'])
598
-                ? $this->_req_data['redirect_back_to']
599
-                : 'default',
600
-        );
601
-        $this->_redirect_after_action(false, '', '', $query_args, true);
602
-    }
475
+	/**
476
+	 * Handles sending selected registrations/contacts a newsletter.
477
+	 *
478
+	 * @since  4.3.0
479
+	 * @return void
480
+	 * @throws EE_Error
481
+	 * @throws InvalidArgumentException
482
+	 * @throws InvalidDataTypeException
483
+	 * @throws InvalidInterfaceException
484
+	 */
485
+	protected function _newsletter_selected_send()
486
+	{
487
+		$success = true;
488
+		//first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
+			EE_Error::add_error(
491
+				esc_html__(
492
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
+					'event_espresso'
494
+				),
495
+				__FILE__,
496
+				__FUNCTION__,
497
+				__LINE__
498
+			);
499
+			$success = false;
500
+		}
501
+		if ($success) {
502
+			//update Message template in case there are any changes
503
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
+				$this->_req_data['newsletter_mtp_selected']
505
+			);
506
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
507
+				? $Message_Template_Group->context_templates()
508
+				: array();
509
+			if (empty($Message_Templates)) {
510
+				EE_Error::add_error(
511
+					esc_html__(
512
+						'Unable to retrieve message template fields from the db. Messages not sent.',
513
+						'event_espresso'
514
+					),
515
+					__FILE__,
516
+					__FUNCTION__,
517
+					__LINE__
518
+				);
519
+			}
520
+			//let's just update the specific fields
521
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
522
+				if ($Message_Template instanceof EE_Message_Template) {
523
+					$field = $Message_Template->get('MTP_template_field');
524
+					$content = $Message_Template->get('MTP_content');
525
+					$new_content = $content;
526
+					switch ($field) {
527
+						case 'from':
528
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
529
+								? $this->_req_data['batch_message']['from']
530
+								: $content;
531
+							break;
532
+						case 'subject':
533
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
534
+								? $this->_req_data['batch_message']['subject']
535
+								: $content;
536
+							break;
537
+						case 'content':
538
+							$new_content = $content;
539
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
+								? $this->_req_data['batch_message']['content']
541
+								: $content['newsletter_content'];
542
+							break;
543
+						default:
544
+							//continue the foreach loop, we don't want to set $new_content nor save.
545
+							continue 2;
546
+					}
547
+					$Message_Template->set('MTP_content', $new_content);
548
+					$Message_Template->save();
549
+				}
550
+			}
551
+			//great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
+				? $this->_req_data['batch_message']['id_type']
554
+				: 'registration';
555
+			//id_type will affect how we assemble the ids.
556
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
557
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
+				: array();
559
+			$registrations_used_for_contact_data = array();
560
+			//using switch because eventually we'll have other contexts that will be used for generating messages.
561
+			switch ($id_type) {
562
+				case 'registration':
563
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
+						array(
565
+							array(
566
+								'REG_ID' => array('IN', $ids),
567
+							),
568
+						)
569
+					);
570
+					break;
571
+				case 'contact':
572
+					$registrations_used_for_contact_data = EEM_Registration::instance()
573
+						->get_latest_registration_for_each_of_given_contacts($ids);
574
+					break;
575
+			}
576
+			do_action_ref_array(
577
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
+				array(
579
+					$registrations_used_for_contact_data,
580
+					$Message_Template_Group->ID()
581
+				)
582
+			);
583
+			//kept for backward compat, internally we no longer use this action.
584
+			//@deprecated 4.8.36.rc.002
585
+			$contacts = $id_type === 'registration'
586
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
+			do_action_ref_array(
589
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
+				array(
591
+					$contacts,
592
+					$Message_Template_Group->ID()
593
+				)
594
+			);
595
+		}
596
+		$query_args = array(
597
+			'action' => ! empty($this->_req_data['redirect_back_to'])
598
+				? $this->_req_data['redirect_back_to']
599
+				: 'default',
600
+		);
601
+		$this->_redirect_after_action(false, '', '', $query_args, true);
602
+	}
603 603
 
604 604
 
605 605
 
606
-    /**
607
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
-     */
610
-    protected function _registration_reports_js_setup()
611
-    {
612
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
-    }
606
+	/**
607
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
+	 */
610
+	protected function _registration_reports_js_setup()
611
+	{
612
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
+	}
615 615
 
616 616
 
617
-    /**
618
-     *        generates Business Reports regarding Registrations
619
-     *
620
-     * @access protected
621
-     * @return void
622
-     * @throws DomainException
623
-     */
624
-    protected function _registration_reports()
625
-    {
626
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
-            $template_path,
629
-            $this->_reports_template_data,
630
-            true
631
-        );
632
-        // the final template wrapper
633
-        $this->display_admin_page_with_no_sidebar();
634
-    }
617
+	/**
618
+	 *        generates Business Reports regarding Registrations
619
+	 *
620
+	 * @access protected
621
+	 * @return void
622
+	 * @throws DomainException
623
+	 */
624
+	protected function _registration_reports()
625
+	{
626
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
+			$template_path,
629
+			$this->_reports_template_data,
630
+			true
631
+		);
632
+		// the final template wrapper
633
+		$this->display_admin_page_with_no_sidebar();
634
+	}
635 635
 
636 636
 
637
-    /**
638
-     * Generates Business Report showing total registrations per day.
639
-     *
640
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
-     * @return string
642
-     * @throws EE_Error
643
-     * @throws InvalidArgumentException
644
-     * @throws InvalidDataTypeException
645
-     * @throws InvalidInterfaceException
646
-     */
647
-    private function _registrations_per_day_report($period = '-1 month')
648
-    {
649
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
650
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
-        $results = (array)$results;
652
-        $regs = array();
653
-        $subtitle = '';
654
-        if ($results) {
655
-            $column_titles = array();
656
-            $tracker = 0;
657
-            foreach ($results as $result) {
658
-                $report_column_values = array();
659
-                foreach ($result as $property_name => $property_value) {
660
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
661
-                        : (int)$property_value;
662
-                    $report_column_values[] = $property_value;
663
-                    if ($tracker === 0) {
664
-                        if ($property_name === 'Registration_REG_date') {
665
-                            $column_titles[] = esc_html__('Date (only days with registrations are shown)', 'event_espresso');
666
-                        } else {
667
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
668
-                        }
669
-                    }
670
-                }
671
-                $tracker++;
672
-                $regs[] = $report_column_values;
673
-            }
674
-            //make sure the column_titles is pushed to the beginning of the array
675
-            array_unshift($regs, $column_titles);
676
-            //setup the date range.
677
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
679
-            $ending_date = new DateTime("now", $DateTimeZone);
680
-            $subtitle = sprintf(
681
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
682
-                $beginning_date->format('Y-m-d'),
683
-                $ending_date->format('Y-m-d')
684
-            );
685
-        }
686
-        $report_title = esc_html__('Total Registrations per Day', 'event_espresso');
687
-        $report_params = array(
688
-            'title'     => $report_title,
689
-            'subtitle'  => $subtitle,
690
-            'id'        => $report_ID,
691
-            'regs'      => $regs,
692
-            'noResults' => empty($regs),
693
-            'noRegsMsg' => sprintf(
694
-                esc_html__(
695
-                    '%sThere are currently no registration records in the last month for this report.%s',
696
-                    'event_espresso'
697
-                ),
698
-                '<h2>' . $report_title . '</h2><p>',
699
-                '</p>'
700
-            ),
701
-        );
702
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
703
-        return $report_ID;
704
-    }
637
+	/**
638
+	 * Generates Business Report showing total registrations per day.
639
+	 *
640
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
+	 * @return string
642
+	 * @throws EE_Error
643
+	 * @throws InvalidArgumentException
644
+	 * @throws InvalidDataTypeException
645
+	 * @throws InvalidInterfaceException
646
+	 */
647
+	private function _registrations_per_day_report($period = '-1 month')
648
+	{
649
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
650
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
+		$results = (array)$results;
652
+		$regs = array();
653
+		$subtitle = '';
654
+		if ($results) {
655
+			$column_titles = array();
656
+			$tracker = 0;
657
+			foreach ($results as $result) {
658
+				$report_column_values = array();
659
+				foreach ($result as $property_name => $property_value) {
660
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
661
+						: (int)$property_value;
662
+					$report_column_values[] = $property_value;
663
+					if ($tracker === 0) {
664
+						if ($property_name === 'Registration_REG_date') {
665
+							$column_titles[] = esc_html__('Date (only days with registrations are shown)', 'event_espresso');
666
+						} else {
667
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
668
+						}
669
+					}
670
+				}
671
+				$tracker++;
672
+				$regs[] = $report_column_values;
673
+			}
674
+			//make sure the column_titles is pushed to the beginning of the array
675
+			array_unshift($regs, $column_titles);
676
+			//setup the date range.
677
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
679
+			$ending_date = new DateTime("now", $DateTimeZone);
680
+			$subtitle = sprintf(
681
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
682
+				$beginning_date->format('Y-m-d'),
683
+				$ending_date->format('Y-m-d')
684
+			);
685
+		}
686
+		$report_title = esc_html__('Total Registrations per Day', 'event_espresso');
687
+		$report_params = array(
688
+			'title'     => $report_title,
689
+			'subtitle'  => $subtitle,
690
+			'id'        => $report_ID,
691
+			'regs'      => $regs,
692
+			'noResults' => empty($regs),
693
+			'noRegsMsg' => sprintf(
694
+				esc_html__(
695
+					'%sThere are currently no registration records in the last month for this report.%s',
696
+					'event_espresso'
697
+				),
698
+				'<h2>' . $report_title . '</h2><p>',
699
+				'</p>'
700
+			),
701
+		);
702
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
703
+		return $report_ID;
704
+	}
705 705
 
706 706
 
707
-    /**
708
-     * Generates Business Report showing total registrations per event.
709
-     *
710
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
711
-     * @return string
712
-     * @throws EE_Error
713
-     * @throws InvalidArgumentException
714
-     * @throws InvalidDataTypeException
715
-     * @throws InvalidInterfaceException
716
-     */
717
-    private function _registrations_per_event_report($period = '-1 month')
718
-    {
719
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
720
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
-        $results = (array)$results;
722
-        $regs = array();
723
-        $subtitle = '';
724
-        if ($results) {
725
-            $column_titles = array();
726
-            $tracker = 0;
727
-            foreach ($results as $result) {
728
-                $report_column_values = array();
729
-                foreach ($result as $property_name => $property_value) {
730
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
731
-                        $property_value,
732
-                        4,
733
-                        '...'
734
-                    ) : (int)$property_value;
735
-                    $report_column_values[] = $property_value;
736
-                    if ($tracker === 0) {
737
-                        if ($property_name === 'Registration_Event') {
738
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
739
-                        } else {
740
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
741
-                        }
742
-                    }
743
-                }
744
-                $tracker++;
745
-                $regs[] = $report_column_values;
746
-            }
747
-            //make sure the column_titles is pushed to the beginning of the array
748
-            array_unshift($regs, $column_titles);
749
-            //setup the date range.
750
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
752
-            $ending_date = new DateTime("now", $DateTimeZone);
753
-            $subtitle = sprintf(
754
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
755
-                $beginning_date->format('Y-m-d'),
756
-                $ending_date->format('Y-m-d')
757
-            );
758
-        }
759
-        $report_title = esc_html__('Total Registrations per Event', 'event_espresso');
760
-        $report_params = array(
761
-            'title'     => $report_title,
762
-            'subtitle'  => $subtitle,
763
-            'id'        => $report_ID,
764
-            'regs'      => $regs,
765
-            'noResults' => empty($regs),
766
-            'noRegsMsg' => sprintf(
767
-                esc_html__(
768
-                    '%sThere are currently no registration records in the last month for this report.%s',
769
-                    'event_espresso'
770
-                ),
771
-                '<h2>' . $report_title . '</h2><p>',
772
-                '</p>'
773
-            ),
774
-        );
775
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
776
-        return $report_ID;
777
-    }
707
+	/**
708
+	 * Generates Business Report showing total registrations per event.
709
+	 *
710
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
711
+	 * @return string
712
+	 * @throws EE_Error
713
+	 * @throws InvalidArgumentException
714
+	 * @throws InvalidDataTypeException
715
+	 * @throws InvalidInterfaceException
716
+	 */
717
+	private function _registrations_per_event_report($period = '-1 month')
718
+	{
719
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
720
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
+		$results = (array)$results;
722
+		$regs = array();
723
+		$subtitle = '';
724
+		if ($results) {
725
+			$column_titles = array();
726
+			$tracker = 0;
727
+			foreach ($results as $result) {
728
+				$report_column_values = array();
729
+				foreach ($result as $property_name => $property_value) {
730
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
731
+						$property_value,
732
+						4,
733
+						'...'
734
+					) : (int)$property_value;
735
+					$report_column_values[] = $property_value;
736
+					if ($tracker === 0) {
737
+						if ($property_name === 'Registration_Event') {
738
+							$column_titles[] = esc_html__('Event', 'event_espresso');
739
+						} else {
740
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
741
+						}
742
+					}
743
+				}
744
+				$tracker++;
745
+				$regs[] = $report_column_values;
746
+			}
747
+			//make sure the column_titles is pushed to the beginning of the array
748
+			array_unshift($regs, $column_titles);
749
+			//setup the date range.
750
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
752
+			$ending_date = new DateTime("now", $DateTimeZone);
753
+			$subtitle = sprintf(
754
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
755
+				$beginning_date->format('Y-m-d'),
756
+				$ending_date->format('Y-m-d')
757
+			);
758
+		}
759
+		$report_title = esc_html__('Total Registrations per Event', 'event_espresso');
760
+		$report_params = array(
761
+			'title'     => $report_title,
762
+			'subtitle'  => $subtitle,
763
+			'id'        => $report_ID,
764
+			'regs'      => $regs,
765
+			'noResults' => empty($regs),
766
+			'noRegsMsg' => sprintf(
767
+				esc_html__(
768
+					'%sThere are currently no registration records in the last month for this report.%s',
769
+					'event_espresso'
770
+				),
771
+				'<h2>' . $report_title . '</h2><p>',
772
+				'</p>'
773
+			),
774
+		);
775
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
776
+		return $report_ID;
777
+	}
778 778
 
779 779
 
780
-    /**
781
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
782
-     *
783
-     * @access protected
784
-     * @return void
785
-     * @throws EE_Error
786
-     * @throws InvalidArgumentException
787
-     * @throws InvalidDataTypeException
788
-     * @throws InvalidInterfaceException
789
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
790
-     */
791
-    protected function _registration_checkin_list_table()
792
-    {
793
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
794
-        $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
795
-        /** @var EE_Registration $registration */
796
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
797
-        $attendee = $registration->attendee();
798
-        $this->_admin_page_title .= $this->get_action_link_or_button(
799
-            'new_registration',
800
-            'add-registrant',
801
-            array('event_id' => $registration->event_ID()),
802
-            'add-new-h2'
803
-        );
804
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
805
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
806
-        $legend_items = array(
807
-            'checkin'  => array(
808
-                'class' => $checked_in->cssClasses(),
809
-                'desc'  => $checked_in->legendLabel(),
810
-            ),
811
-            'checkout' => array(
812
-                'class' => $checked_out->cssClasses(),
813
-                'desc'  => $checked_out->legendLabel(),
814
-            ),
815
-        );
816
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
817
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
818
-        /** @var EE_Datetime $datetime */
819
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
820
-        $datetime_label = '';
821
-        if ($datetime instanceof EE_Datetime) {
822
-            $datetime_label = $datetime->get_dtt_display_name(true);
823
-            $datetime_label .= ! empty($datetime_label)
824
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
825
-                : $datetime->get_dtt_display_name();
826
-        }
827
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
828
-            ? EE_Admin_Page::add_query_args_and_nonce(
829
-                array(
830
-                    'action'   => 'event_registrations',
831
-                    'event_id' => $registration->event_ID(),
832
-                    'DTT_ID'   => $dtt_id,
833
-                ),
834
-                $this->_admin_base_url
835
-            )
836
-            : '';
837
-        $datetime_link = ! empty($datetime_link)
838
-            ? '<a href="' . $datetime_link . '">'
839
-              . '<span id="checkin-dtt">'
840
-              . $datetime_label
841
-              . '</span></a>'
842
-            : $datetime_label;
843
-        $attendee_name = $attendee instanceof EE_Attendee
844
-            ? $attendee->full_name()
845
-            : '';
846
-        $attendee_link = $attendee instanceof EE_Attendee
847
-            ? $attendee->get_admin_details_link()
848
-            : '';
849
-        $attendee_link = ! empty($attendee_link)
850
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
851
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
852
-              . '<span id="checkin-attendee-name">'
853
-              . $attendee_name
854
-              . '</span></a>'
855
-            : '';
856
-        $event_link = $registration->event() instanceof EE_Event
857
-            ? $registration->event()->get_admin_details_link()
858
-            : '';
859
-        $event_link = ! empty($event_link)
860
-            ? '<a href="' . $event_link . '"'
861
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
862
-              . '<span id="checkin-event-name">'
863
-              . $registration->event_name()
864
-              . '</span>'
865
-              . '</a>'
866
-            : '';
867
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
-            ? '<h2>' . sprintf(
869
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870
-                $attendee_link,
871
-                $datetime_link,
872
-                $event_link
873
-            ) . '</h2>'
874
-            : '';
875
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
877
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
879
-        $this->display_admin_list_table_page_with_no_sidebar();
880
-    }
780
+	/**
781
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
782
+	 *
783
+	 * @access protected
784
+	 * @return void
785
+	 * @throws EE_Error
786
+	 * @throws InvalidArgumentException
787
+	 * @throws InvalidDataTypeException
788
+	 * @throws InvalidInterfaceException
789
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
790
+	 */
791
+	protected function _registration_checkin_list_table()
792
+	{
793
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
794
+		$reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
795
+		/** @var EE_Registration $registration */
796
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
797
+		$attendee = $registration->attendee();
798
+		$this->_admin_page_title .= $this->get_action_link_or_button(
799
+			'new_registration',
800
+			'add-registrant',
801
+			array('event_id' => $registration->event_ID()),
802
+			'add-new-h2'
803
+		);
804
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
805
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
806
+		$legend_items = array(
807
+			'checkin'  => array(
808
+				'class' => $checked_in->cssClasses(),
809
+				'desc'  => $checked_in->legendLabel(),
810
+			),
811
+			'checkout' => array(
812
+				'class' => $checked_out->cssClasses(),
813
+				'desc'  => $checked_out->legendLabel(),
814
+			),
815
+		);
816
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
817
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
818
+		/** @var EE_Datetime $datetime */
819
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
820
+		$datetime_label = '';
821
+		if ($datetime instanceof EE_Datetime) {
822
+			$datetime_label = $datetime->get_dtt_display_name(true);
823
+			$datetime_label .= ! empty($datetime_label)
824
+				? ' (' . $datetime->get_dtt_display_name() . ')'
825
+				: $datetime->get_dtt_display_name();
826
+		}
827
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
828
+			? EE_Admin_Page::add_query_args_and_nonce(
829
+				array(
830
+					'action'   => 'event_registrations',
831
+					'event_id' => $registration->event_ID(),
832
+					'DTT_ID'   => $dtt_id,
833
+				),
834
+				$this->_admin_base_url
835
+			)
836
+			: '';
837
+		$datetime_link = ! empty($datetime_link)
838
+			? '<a href="' . $datetime_link . '">'
839
+			  . '<span id="checkin-dtt">'
840
+			  . $datetime_label
841
+			  . '</span></a>'
842
+			: $datetime_label;
843
+		$attendee_name = $attendee instanceof EE_Attendee
844
+			? $attendee->full_name()
845
+			: '';
846
+		$attendee_link = $attendee instanceof EE_Attendee
847
+			? $attendee->get_admin_details_link()
848
+			: '';
849
+		$attendee_link = ! empty($attendee_link)
850
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
851
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
852
+			  . '<span id="checkin-attendee-name">'
853
+			  . $attendee_name
854
+			  . '</span></a>'
855
+			: '';
856
+		$event_link = $registration->event() instanceof EE_Event
857
+			? $registration->event()->get_admin_details_link()
858
+			: '';
859
+		$event_link = ! empty($event_link)
860
+			? '<a href="' . $event_link . '"'
861
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
862
+			  . '<span id="checkin-event-name">'
863
+			  . $registration->event_name()
864
+			  . '</span>'
865
+			  . '</a>'
866
+			: '';
867
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
+			? '<h2>' . sprintf(
869
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870
+				$attendee_link,
871
+				$datetime_link,
872
+				$event_link
873
+			) . '</h2>'
874
+			: '';
875
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
+			? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
877
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
879
+		$this->display_admin_list_table_page_with_no_sidebar();
880
+	}
881 881
 
882 882
 
883
-    /**
884
-     * toggle the Check-in status for the given registration (coming from ajax)
885
-     *
886
-     * @return void (JSON)
887
-     * @throws EE_Error
888
-     * @throws InvalidArgumentException
889
-     * @throws InvalidDataTypeException
890
-     * @throws InvalidInterfaceException
891
-     */
892
-    public function toggle_checkin_status()
893
-    {
894
-        //first make sure we have the necessary data
895
-        if ( ! isset($this->_req_data['_regid'])) {
896
-            EE_Error::add_error(
897
-                esc_html__(
898
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
899
-                    'event_espresso'
900
-                ),
901
-                __FILE__,
902
-                __FUNCTION__,
903
-                __LINE__
904
-            );
905
-            $this->_template_args['success'] = false;
906
-            $this->_template_args['error'] = true;
907
-            $this->_return_json();
908
-        };
909
-        //do a nonce check cause we're not coming in from an normal route here.
910
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
911
-            : '';
912
-        $nonce_ref = 'checkin_nonce';
913
-        $this->_verify_nonce($nonce, $nonce_ref);
914
-        //beautiful! Made it this far so let's get the status.
915
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916
-        //setup new class to return via ajax
917
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
918
-        $this->_template_args['success'] = true;
919
-        $this->_return_json();
920
-    }
883
+	/**
884
+	 * toggle the Check-in status for the given registration (coming from ajax)
885
+	 *
886
+	 * @return void (JSON)
887
+	 * @throws EE_Error
888
+	 * @throws InvalidArgumentException
889
+	 * @throws InvalidDataTypeException
890
+	 * @throws InvalidInterfaceException
891
+	 */
892
+	public function toggle_checkin_status()
893
+	{
894
+		//first make sure we have the necessary data
895
+		if ( ! isset($this->_req_data['_regid'])) {
896
+			EE_Error::add_error(
897
+				esc_html__(
898
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
899
+					'event_espresso'
900
+				),
901
+				__FILE__,
902
+				__FUNCTION__,
903
+				__LINE__
904
+			);
905
+			$this->_template_args['success'] = false;
906
+			$this->_template_args['error'] = true;
907
+			$this->_return_json();
908
+		};
909
+		//do a nonce check cause we're not coming in from an normal route here.
910
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
911
+			: '';
912
+		$nonce_ref = 'checkin_nonce';
913
+		$this->_verify_nonce($nonce, $nonce_ref);
914
+		//beautiful! Made it this far so let's get the status.
915
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916
+		//setup new class to return via ajax
917
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
918
+		$this->_template_args['success'] = true;
919
+		$this->_return_json();
920
+	}
921 921
 
922 922
 
923
-    /**
924
-     * handles toggling the checkin status for the registration,
925
-     *
926
-     * @access protected
927
-     * @return int|void
928
-     * @throws EE_Error
929
-     * @throws InvalidArgumentException
930
-     * @throws InvalidDataTypeException
931
-     * @throws InvalidInterfaceException
932
-     */
933
-    protected function _toggle_checkin_status()
934
-    {
935
-        //first let's get the query args out of the way for the redirect
936
-        $query_args = array(
937
-            'action'   => 'event_registrations',
938
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
939
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
940
-        );
941
-        $new_status = false;
942
-        // bulk action check in toggle
943
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
944
-            // cycle thru checkboxes
945
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
946
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
947
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
948
-            }
949
-        } elseif (isset($this->_req_data['_regid'])) {
950
-            //coming from ajax request
951
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
952
-            $query_args['DTT_ID'] = $DTT_ID;
953
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
954
-        } else {
955
-            EE_Error::add_error(
956
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
957
-                __FILE__,
958
-                __FUNCTION__,
959
-                __LINE__
960
-            );
961
-        }
962
-        if (defined('DOING_AJAX')) {
963
-            return $new_status;
964
-        }
965
-        $this->_redirect_after_action(false, '', '', $query_args, true);
966
-    }
923
+	/**
924
+	 * handles toggling the checkin status for the registration,
925
+	 *
926
+	 * @access protected
927
+	 * @return int|void
928
+	 * @throws EE_Error
929
+	 * @throws InvalidArgumentException
930
+	 * @throws InvalidDataTypeException
931
+	 * @throws InvalidInterfaceException
932
+	 */
933
+	protected function _toggle_checkin_status()
934
+	{
935
+		//first let's get the query args out of the way for the redirect
936
+		$query_args = array(
937
+			'action'   => 'event_registrations',
938
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
939
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
940
+		);
941
+		$new_status = false;
942
+		// bulk action check in toggle
943
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
944
+			// cycle thru checkboxes
945
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
946
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
947
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
948
+			}
949
+		} elseif (isset($this->_req_data['_regid'])) {
950
+			//coming from ajax request
951
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
952
+			$query_args['DTT_ID'] = $DTT_ID;
953
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
954
+		} else {
955
+			EE_Error::add_error(
956
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
957
+				__FILE__,
958
+				__FUNCTION__,
959
+				__LINE__
960
+			);
961
+		}
962
+		if (defined('DOING_AJAX')) {
963
+			return $new_status;
964
+		}
965
+		$this->_redirect_after_action(false, '', '', $query_args, true);
966
+	}
967 967
 
968 968
 
969
-    /**
970
-     * This is toggles a single Check-in for the given registration and datetime.
971
-     *
972
-     * @param  int $REG_ID The registration we're toggling
973
-     * @param  int $DTT_ID The datetime we're toggling
974
-     * @return int The new status toggled to.
975
-     * @throws EE_Error
976
-     * @throws InvalidArgumentException
977
-     * @throws InvalidDataTypeException
978
-     * @throws InvalidInterfaceException
979
-     */
980
-    private function _toggle_checkin($REG_ID, $DTT_ID)
981
-    {
982
-        /** @var EE_Registration $REG */
983
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
984
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
985
-        if ($new_status !== false) {
986
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
987
-        } else {
988
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
989
-            $new_status = false;
990
-        }
991
-        return $new_status;
992
-    }
969
+	/**
970
+	 * This is toggles a single Check-in for the given registration and datetime.
971
+	 *
972
+	 * @param  int $REG_ID The registration we're toggling
973
+	 * @param  int $DTT_ID The datetime we're toggling
974
+	 * @return int The new status toggled to.
975
+	 * @throws EE_Error
976
+	 * @throws InvalidArgumentException
977
+	 * @throws InvalidDataTypeException
978
+	 * @throws InvalidInterfaceException
979
+	 */
980
+	private function _toggle_checkin($REG_ID, $DTT_ID)
981
+	{
982
+		/** @var EE_Registration $REG */
983
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
984
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
985
+		if ($new_status !== false) {
986
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
987
+		} else {
988
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
989
+			$new_status = false;
990
+		}
991
+		return $new_status;
992
+	}
993 993
 
994 994
 
995
-    /**
996
-     * Takes care of deleting multiple EE_Checkin table rows
997
-     *
998
-     * @access protected
999
-     * @return void
1000
-     * @throws EE_Error
1001
-     * @throws InvalidArgumentException
1002
-     * @throws InvalidDataTypeException
1003
-     * @throws InvalidInterfaceException
1004
-     */
1005
-    protected function _delete_checkin_rows()
1006
-    {
1007
-        $query_args = array(
1008
-            'action' => 'registration_checkins',
1009
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1010
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
1011
-        );
1012
-        $errors = 0;
1013
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1014
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1015
-                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1016
-                    $errors++;
1017
-                }
1018
-            }
1019
-        } else {
1020
-            EE_Error::add_error(
1021
-                esc_html__(
1022
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1023
-                    'event_espresso'
1024
-                ),
1025
-                __FILE__,
1026
-                __FUNCTION__,
1027
-                __LINE__
1028
-            );
1029
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1030
-        }
1031
-        if ($errors > 0) {
1032
-            EE_Error::add_error(
1033
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1034
-                __FILE__,
1035
-                __FUNCTION__,
1036
-                __LINE__
1037
-            );
1038
-        } else {
1039
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1040
-        }
1041
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1042
-    }
995
+	/**
996
+	 * Takes care of deleting multiple EE_Checkin table rows
997
+	 *
998
+	 * @access protected
999
+	 * @return void
1000
+	 * @throws EE_Error
1001
+	 * @throws InvalidArgumentException
1002
+	 * @throws InvalidDataTypeException
1003
+	 * @throws InvalidInterfaceException
1004
+	 */
1005
+	protected function _delete_checkin_rows()
1006
+	{
1007
+		$query_args = array(
1008
+			'action' => 'registration_checkins',
1009
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1010
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
1011
+		);
1012
+		$errors = 0;
1013
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1014
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1015
+				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1016
+					$errors++;
1017
+				}
1018
+			}
1019
+		} else {
1020
+			EE_Error::add_error(
1021
+				esc_html__(
1022
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1023
+					'event_espresso'
1024
+				),
1025
+				__FILE__,
1026
+				__FUNCTION__,
1027
+				__LINE__
1028
+			);
1029
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1030
+		}
1031
+		if ($errors > 0) {
1032
+			EE_Error::add_error(
1033
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1034
+				__FILE__,
1035
+				__FUNCTION__,
1036
+				__LINE__
1037
+			);
1038
+		} else {
1039
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1040
+		}
1041
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1042
+	}
1043 1043
 
1044 1044
 
1045
-    /**
1046
-     * Deletes a single EE_Checkin row
1047
-     *
1048
-     * @return void
1049
-     * @throws EE_Error
1050
-     * @throws InvalidArgumentException
1051
-     * @throws InvalidDataTypeException
1052
-     * @throws InvalidInterfaceException
1053
-     */
1054
-    protected function _delete_checkin_row()
1055
-    {
1056
-        $query_args = array(
1057
-            'action' => 'registration_checkins',
1058
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1059
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
1060
-        );
1061
-        if ( ! empty($this->_req_data['CHK_ID'])) {
1062
-            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1063
-                EE_Error::add_error(
1064
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1065
-                    __FILE__,
1066
-                    __FUNCTION__,
1067
-                    __LINE__
1068
-                );
1069
-            } else {
1070
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1071
-            }
1072
-        } else {
1073
-            EE_Error::add_error(
1074
-                esc_html__(
1075
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1076
-                    'event_espresso'
1077
-                ),
1078
-                __FILE__,
1079
-                __FUNCTION__,
1080
-                __LINE__
1081
-            );
1082
-        }
1083
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1084
-    }
1045
+	/**
1046
+	 * Deletes a single EE_Checkin row
1047
+	 *
1048
+	 * @return void
1049
+	 * @throws EE_Error
1050
+	 * @throws InvalidArgumentException
1051
+	 * @throws InvalidDataTypeException
1052
+	 * @throws InvalidInterfaceException
1053
+	 */
1054
+	protected function _delete_checkin_row()
1055
+	{
1056
+		$query_args = array(
1057
+			'action' => 'registration_checkins',
1058
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1059
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
1060
+		);
1061
+		if ( ! empty($this->_req_data['CHK_ID'])) {
1062
+			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1063
+				EE_Error::add_error(
1064
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1065
+					__FILE__,
1066
+					__FUNCTION__,
1067
+					__LINE__
1068
+				);
1069
+			} else {
1070
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1071
+			}
1072
+		} else {
1073
+			EE_Error::add_error(
1074
+				esc_html__(
1075
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1076
+					'event_espresso'
1077
+				),
1078
+				__FILE__,
1079
+				__FUNCTION__,
1080
+				__LINE__
1081
+			);
1082
+		}
1083
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1084
+	}
1085 1085
 
1086 1086
 
1087
-    /**
1088
-     *        generates HTML for the Event Registrations List Table
1089
-     *
1090
-     * @access protected
1091
-     * @return void
1092
-     * @throws EE_Error
1093
-     * @throws InvalidArgumentException
1094
-     * @throws InvalidDataTypeException
1095
-     * @throws InvalidInterfaceException
1096
-     */
1097
-    protected function _event_registrations_list_table()
1098
-    {
1099
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1100
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1101
-            ? $this->get_action_link_or_button(
1102
-                'new_registration',
1103
-                'add-registrant',
1104
-                array('event_id' => $this->_req_data['event_id']),
1105
-                'add-new-h2',
1106
-                '',
1107
-                false
1108
-            )
1109
-            : '';
1110
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1111
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1112
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1113
-        $legend_items = array(
1114
-            'star-icon'        => array(
1115
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1116
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1117
-            ),
1118
-            'checkin'          => array(
1119
-                'class' => $checked_in->cssClasses(),
1120
-                'desc'  => $checked_in->legendLabel(),
1121
-            ),
1122
-            'checkout'         => array(
1123
-                'class' => $checked_out->cssClasses(),
1124
-                'desc'  => $checked_out->legendLabel(),
1125
-            ),
1126
-            'nocheckinrecord'  => array(
1127
-                'class' => $checked_never->cssClasses(),
1128
-                'desc'  => $checked_never->legendLabel(),
1129
-            ),
1130
-            'view_details'     => array(
1131
-                'class' => 'dashicons dashicons-search',
1132
-                'desc'  => esc_html__('View All Check-in Records for this Registrant', 'event_espresso'),
1133
-            ),
1134
-            'approved_status'  => array(
1135
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1136
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1137
-            ),
1138
-            'cancelled_status' => array(
1139
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1140
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1141
-            ),
1142
-            'declined_status'  => array(
1143
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1144
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1145
-            ),
1146
-            'not_approved'     => array(
1147
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1148
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1149
-            ),
1150
-            'pending_status'   => array(
1151
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1152
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1153
-            ),
1154
-            'wait_list'        => array(
1155
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1156
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1157
-            ),
1158
-        );
1159
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1160
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1161
-        $this->_template_args['before_list_table'] = ! empty($event_id)
1162
-            ? '<h2>' . sprintf(
1163
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1164
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1165
-            ) . '</h2>'
1166
-            : '';
1167
-        //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1168
-        // the event.
1169
-        /** @var EE_Event $event */
1170
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1171
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1172
-        $datetime = null;
1173
-        if ($event instanceof EE_Event) {
1174
-            $datetimes_on_event = $event->datetimes();
1175
-            if (count($datetimes_on_event) === 1) {
1176
-                $datetime = reset($datetimes_on_event);
1177
-            }
1178
-        }
1179
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1180
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1181
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1182
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1183
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1184
-            $this->_template_args['before_list_table'] .= $datetime->name();
1185
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1186
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1187
-        }
1188
-        //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1189
-        // column represents
1190
-        if (! $datetime instanceof EE_Datetime) {
1191
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1192
-                . esc_html__(
1193
-                    'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1194
-                    'event_espresso'
1195
-                )
1196
-                . '</p>';
1197
-        }
1198
-        $this->display_admin_list_table_page_with_no_sidebar();
1199
-    }
1087
+	/**
1088
+	 *        generates HTML for the Event Registrations List Table
1089
+	 *
1090
+	 * @access protected
1091
+	 * @return void
1092
+	 * @throws EE_Error
1093
+	 * @throws InvalidArgumentException
1094
+	 * @throws InvalidDataTypeException
1095
+	 * @throws InvalidInterfaceException
1096
+	 */
1097
+	protected function _event_registrations_list_table()
1098
+	{
1099
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1100
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1101
+			? $this->get_action_link_or_button(
1102
+				'new_registration',
1103
+				'add-registrant',
1104
+				array('event_id' => $this->_req_data['event_id']),
1105
+				'add-new-h2',
1106
+				'',
1107
+				false
1108
+			)
1109
+			: '';
1110
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1111
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1112
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1113
+		$legend_items = array(
1114
+			'star-icon'        => array(
1115
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1116
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1117
+			),
1118
+			'checkin'          => array(
1119
+				'class' => $checked_in->cssClasses(),
1120
+				'desc'  => $checked_in->legendLabel(),
1121
+			),
1122
+			'checkout'         => array(
1123
+				'class' => $checked_out->cssClasses(),
1124
+				'desc'  => $checked_out->legendLabel(),
1125
+			),
1126
+			'nocheckinrecord'  => array(
1127
+				'class' => $checked_never->cssClasses(),
1128
+				'desc'  => $checked_never->legendLabel(),
1129
+			),
1130
+			'view_details'     => array(
1131
+				'class' => 'dashicons dashicons-search',
1132
+				'desc'  => esc_html__('View All Check-in Records for this Registrant', 'event_espresso'),
1133
+			),
1134
+			'approved_status'  => array(
1135
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1136
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1137
+			),
1138
+			'cancelled_status' => array(
1139
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1140
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1141
+			),
1142
+			'declined_status'  => array(
1143
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1144
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1145
+			),
1146
+			'not_approved'     => array(
1147
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1148
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1149
+			),
1150
+			'pending_status'   => array(
1151
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1152
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1153
+			),
1154
+			'wait_list'        => array(
1155
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1156
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1157
+			),
1158
+		);
1159
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1160
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1161
+		$this->_template_args['before_list_table'] = ! empty($event_id)
1162
+			? '<h2>' . sprintf(
1163
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1164
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1165
+			) . '</h2>'
1166
+			: '';
1167
+		//need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1168
+		// the event.
1169
+		/** @var EE_Event $event */
1170
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1171
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1172
+		$datetime = null;
1173
+		if ($event instanceof EE_Event) {
1174
+			$datetimes_on_event = $event->datetimes();
1175
+			if (count($datetimes_on_event) === 1) {
1176
+				$datetime = reset($datetimes_on_event);
1177
+			}
1178
+		}
1179
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1180
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1181
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1182
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1183
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1184
+			$this->_template_args['before_list_table'] .= $datetime->name();
1185
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1186
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1187
+		}
1188
+		//if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1189
+		// column represents
1190
+		if (! $datetime instanceof EE_Datetime) {
1191
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1192
+				. esc_html__(
1193
+					'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1194
+					'event_espresso'
1195
+				)
1196
+				. '</p>';
1197
+		}
1198
+		$this->display_admin_list_table_page_with_no_sidebar();
1199
+	}
1200 1200
 
1201
-    /**
1202
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1203
-     * conditions)
1204
-     *
1205
-     * @return void ends the request by a redirect or download
1206
-     */
1207
-    public function _registrations_checkin_report()
1208
-    {
1209
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1210
-    }
1201
+	/**
1202
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1203
+	 * conditions)
1204
+	 *
1205
+	 * @return void ends the request by a redirect or download
1206
+	 */
1207
+	public function _registrations_checkin_report()
1208
+	{
1209
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1210
+	}
1211 1211
 
1212
-    /**
1213
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1214
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1215
-     *
1216
-     * @param array $request
1217
-     * @param int   $per_page
1218
-     * @param bool  $count
1219
-     * @return array
1220
-     * @throws EE_Error
1221
-     */
1222
-    protected function _get_checkin_query_params_from_request(
1223
-        $request,
1224
-        $per_page = 10,
1225
-        $count = false
1226
-    ) {
1227
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1228
-        //unlike the regular registrations list table,
1229
-        $status_ids_array = apply_filters(
1230
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1231
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1232
-        );
1233
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1234
-        return $query_params;
1235
-    }
1212
+	/**
1213
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1214
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1215
+	 *
1216
+	 * @param array $request
1217
+	 * @param int   $per_page
1218
+	 * @param bool  $count
1219
+	 * @return array
1220
+	 * @throws EE_Error
1221
+	 */
1222
+	protected function _get_checkin_query_params_from_request(
1223
+		$request,
1224
+		$per_page = 10,
1225
+		$count = false
1226
+	) {
1227
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1228
+		//unlike the regular registrations list table,
1229
+		$status_ids_array = apply_filters(
1230
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1231
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1232
+		);
1233
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1234
+		return $query_params;
1235
+	}
1236 1236
 
1237 1237
 
1238
-    /**
1239
-     * Gets registrations for an event
1240
-     *
1241
-     * @param int    $per_page
1242
-     * @param bool   $count whether to return count or data.
1243
-     * @param bool   $trash
1244
-     * @param string $orderby
1245
-     * @return EE_Registration[]|int
1246
-     * @throws EE_Error
1247
-     * @throws InvalidArgumentException
1248
-     * @throws InvalidDataTypeException
1249
-     * @throws InvalidInterfaceException
1250
-     */
1251
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1252
-    {
1253
-        //normalize some request params that get setup by the parent `get_registrations` method.
1254
-        $request = $this->_req_data;
1255
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1256
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1257
-        if ($trash) {
1258
-            $request['status'] = 'trash';
1259
-        }
1260
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1261
-        /**
1262
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1263
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1264
-         * @see EEM_Base::get_all()
1265
-         */
1266
-        $query_params['group_by'] = '';
1238
+	/**
1239
+	 * Gets registrations for an event
1240
+	 *
1241
+	 * @param int    $per_page
1242
+	 * @param bool   $count whether to return count or data.
1243
+	 * @param bool   $trash
1244
+	 * @param string $orderby
1245
+	 * @return EE_Registration[]|int
1246
+	 * @throws EE_Error
1247
+	 * @throws InvalidArgumentException
1248
+	 * @throws InvalidDataTypeException
1249
+	 * @throws InvalidInterfaceException
1250
+	 */
1251
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1252
+	{
1253
+		//normalize some request params that get setup by the parent `get_registrations` method.
1254
+		$request = $this->_req_data;
1255
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1256
+		$request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1257
+		if ($trash) {
1258
+			$request['status'] = 'trash';
1259
+		}
1260
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1261
+		/**
1262
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1263
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1264
+		 * @see EEM_Base::get_all()
1265
+		 */
1266
+		$query_params['group_by'] = '';
1267 1267
 
1268
-        return $count
1269
-            ? EEM_Registration::instance()->count($query_params)
1270
-            /** @type EE_Registration[] */
1271
-            : EEM_Registration::instance()->get_all($query_params);
1272
-    }
1268
+		return $count
1269
+			? EEM_Registration::instance()->count($query_params)
1270
+			/** @type EE_Registration[] */
1271
+			: EEM_Registration::instance()->get_all($query_params);
1272
+	}
1273 1273
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
     public function __construct($routing = true)
36 36
     {
37 37
         parent::__construct($routing);
38
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
38
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
39
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
40
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
41
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
42 42
         }
43 43
     }
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function _extend_page_config()
50 50
     {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
51
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
52 52
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53 53
             ? $this->_req_data['_REG_ID']
54 54
             : 0;
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
             //enqueue newsletter js
188 188
             wp_enqueue_script(
189 189
                 'ee-newsletter-trigger',
190
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
191 191
                 array('ee-dialog'),
192 192
                 EVENT_ESPRESSO_VERSION,
193 193
                 true
194 194
             );
195 195
             wp_enqueue_style(
196 196
                 'ee-newsletter-trigger-css',
197
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
198 198
                 array(),
199 199
                 EVENT_ESPRESSO_VERSION
200 200
             );
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     {
216 216
         wp_register_script(
217 217
             'ee-reg-reports-js',
218
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
219 219
             array('google-charts'),
220 220
             EVENT_ESPRESSO_VERSION,
221 221
             true
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $nonce_ref = 'get_newsletter_form_content_nonce';
302 302
         $this->_verify_nonce($nonce, $nonce_ref);
303 303
         //let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
304
+        if ( ! isset($this->_req_data['GRP_ID'])) {
305 305
             EE_Error::add_error(
306 306
                 esc_html__(
307 307
                     'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             $this->_return_json();
317 317
         }
318 318
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
320 320
             EE_Error::add_error(
321 321
                 sprintf(
322 322
                     esc_html__(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             $field = $MTP->get('MTP_template_field');
342 342
             if ($field === 'content') {
343 343
                 $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
344
+                if ( ! empty($content['newsletter_content'])) {
345 345
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
346 346
                 }
347 347
                 continue;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
      */
378 378
     public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379 379
     {
380
-        if (! EE_Registry::instance()->CAP->current_user_can(
380
+        if ( ! EE_Registry::instance()->CAP->current_user_can(
381 381
             'ee_send_message',
382 382
             'espresso_registrations_newsletter_selected_send'
383 383
         )
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
                 $field_id = $field === '[NEWSLETTER_CONTENT]'
447 447
                     ? 'content'
448 448
                     : $field;
449
-                $field_id = 'batch-message-' . strtolower($field_id);
449
+                $field_id = 'batch-message-'.strtolower($field_id);
450 450
                 $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451 451
                                           . $shortcode
452
-                                          . '" data-linked-input-id="' . $field_id . '">'
452
+                                          . '" data-linked-input-id="'.$field_id.'">'
453 453
                                           . $shortcode
454 454
                                           . '</span>';
455 455
             }
456 456
             $codes[$field] = implode(', ', $available_shortcodes);
457 457
         }
458 458
         $shortcodes = $codes;
459
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
459
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
460 460
         $form_template_args = array(
461 461
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462 462
             'form_route'        => 'newsletter_selected_send',
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      */
624 624
     protected function _registration_reports()
625 625
     {
626
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
626
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
627 627
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628 628
             $template_path,
629 629
             $this->_reports_template_data,
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     {
649 649
         $report_ID = 'reg-admin-registrations-per-day-report-dv';
650 650
         $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
-        $results = (array)$results;
651
+        $results = (array) $results;
652 652
         $regs = array();
653 653
         $subtitle = '';
654 654
         if ($results) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                 $report_column_values = array();
659 659
                 foreach ($result as $property_name => $property_value) {
660 660
                     $property_value = $property_name === 'Registration_REG_date' ? $property_value
661
-                        : (int)$property_value;
661
+                        : (int) $property_value;
662 662
                     $report_column_values[] = $property_value;
663 663
                     if ($tracker === 0) {
664 664
                         if ($property_name === 'Registration_REG_date') {
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
             array_unshift($regs, $column_titles);
676 676
             //setup the date range.
677 677
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
678
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
679 679
             $ending_date = new DateTime("now", $DateTimeZone);
680 680
             $subtitle = sprintf(
681 681
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                     '%sThere are currently no registration records in the last month for this report.%s',
696 696
                     'event_espresso'
697 697
                 ),
698
-                '<h2>' . $report_title . '</h2><p>',
698
+                '<h2>'.$report_title.'</h2><p>',
699 699
                 '</p>'
700 700
             ),
701 701
         );
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     {
719 719
         $report_ID = 'reg-admin-registrations-per-event-report-dv';
720 720
         $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
-        $results = (array)$results;
721
+        $results = (array) $results;
722 722
         $regs = array();
723 723
         $subtitle = '';
724 724
         if ($results) {
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
                         $property_value,
732 732
                         4,
733 733
                         '...'
734
-                    ) : (int)$property_value;
734
+                    ) : (int) $property_value;
735 735
                     $report_column_values[] = $property_value;
736 736
                     if ($tracker === 0) {
737 737
                         if ($property_name === 'Registration_Event') {
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
             array_unshift($regs, $column_titles);
749 749
             //setup the date range.
750 750
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
751
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
752 752
             $ending_date = new DateTime("now", $DateTimeZone);
753 753
             $subtitle = sprintf(
754 754
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
                     '%sThere are currently no registration records in the last month for this report.%s',
769 769
                     'event_espresso'
770 770
                 ),
771
-                '<h2>' . $report_title . '</h2><p>',
771
+                '<h2>'.$report_title.'</h2><p>',
772 772
                 '</p>'
773 773
             ),
774 774
         );
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         if ($datetime instanceof EE_Datetime) {
822 822
             $datetime_label = $datetime->get_dtt_display_name(true);
823 823
             $datetime_label .= ! empty($datetime_label)
824
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
824
+                ? ' ('.$datetime->get_dtt_display_name().')'
825 825
                 : $datetime->get_dtt_display_name();
826 826
         }
827 827
         $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
             )
836 836
             : '';
837 837
         $datetime_link = ! empty($datetime_link)
838
-            ? '<a href="' . $datetime_link . '">'
838
+            ? '<a href="'.$datetime_link.'">'
839 839
               . '<span id="checkin-dtt">'
840 840
               . $datetime_label
841 841
               . '</span></a>'
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
             ? $attendee->get_admin_details_link()
848 848
             : '';
849 849
         $attendee_link = ! empty($attendee_link)
850
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
851
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
850
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
851
+              . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">'
852 852
               . '<span id="checkin-attendee-name">'
853 853
               . $attendee_name
854 854
               . '</span></a>'
@@ -857,25 +857,25 @@  discard block
 block discarded – undo
857 857
             ? $registration->event()->get_admin_details_link()
858 858
             : '';
859 859
         $event_link = ! empty($event_link)
860
-            ? '<a href="' . $event_link . '"'
861
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
860
+            ? '<a href="'.$event_link.'"'
861
+              . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
862 862
               . '<span id="checkin-event-name">'
863 863
               . $registration->event_name()
864 864
               . '</span>'
865 865
               . '</a>'
866 866
             : '';
867 867
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
-            ? '<h2>' . sprintf(
868
+            ? '<h2>'.sprintf(
869 869
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870 870
                 $attendee_link,
871 871
                 $datetime_link,
872 872
                 $event_link
873
-            ) . '</h2>'
873
+            ).'</h2>'
874 874
             : '';
875 875
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
876
+            ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : '';
877 877
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
878
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
879 879
         $this->display_admin_list_table_page_with_no_sidebar();
880 880
     }
881 881
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         //beautiful! Made it this far so let's get the status.
915 915
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916 916
         //setup new class to return via ajax
917
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
917
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
918 918
         $this->_template_args['success'] = true;
919 919
         $this->_return_json();
920 920
     }
@@ -1132,37 +1132,37 @@  discard block
 block discarded – undo
1132 1132
                 'desc'  => esc_html__('View All Check-in Records for this Registrant', 'event_espresso'),
1133 1133
             ),
1134 1134
             'approved_status'  => array(
1135
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1135
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1136 1136
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1137 1137
             ),
1138 1138
             'cancelled_status' => array(
1139
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1139
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1140 1140
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1141 1141
             ),
1142 1142
             'declined_status'  => array(
1143
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1143
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1144 1144
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1145 1145
             ),
1146 1146
             'not_approved'     => array(
1147
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1147
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1148 1148
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1149 1149
             ),
1150 1150
             'pending_status'   => array(
1151
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1151
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1152 1152
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1153 1153
             ),
1154 1154
             'wait_list'        => array(
1155
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1155
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1156 1156
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1157 1157
             ),
1158 1158
         );
1159 1159
         $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1160 1160
         $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1161 1161
         $this->_template_args['before_list_table'] = ! empty($event_id)
1162
-            ? '<h2>' . sprintf(
1162
+            ? '<h2>'.sprintf(
1163 1163
                 esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1164 1164
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1165
-            ) . '</h2>'
1165
+            ).'</h2>'
1166 1166
             : '';
1167 1167
         //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1168 1168
         // the event.
@@ -1182,12 +1182,12 @@  discard block
 block discarded – undo
1182 1182
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1183 1183
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1184 1184
             $this->_template_args['before_list_table'] .= $datetime->name();
1185
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1185
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1186 1186
             $this->_template_args['before_list_table'] .= '</span></h2>';
1187 1187
         }
1188 1188
         //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1189 1189
         // column represents
1190
-        if (! $datetime instanceof EE_Datetime) {
1190
+        if ( ! $datetime instanceof EE_Datetime) {
1191 1191
             $this->_template_args['before_list_table'] .= '<br><p class="description">'
1192 1192
                 . esc_html__(
1193 1193
                     'In this view, the check-in status represents the latest check-in record for the registration in that row.',
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
         //normalize some request params that get setup by the parent `get_registrations` method.
1254 1254
         $request = $this->_req_data;
1255 1255
         $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1256
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1256
+        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1257 1257
         if ($trash) {
1258 1258
             $request['status'] = 'trash';
1259 1259
         }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -38,217 +38,217 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         *
70
-         * @return void
71
-         */
72
-        function espresso_minimum_php_version_error()
73
-        {
74
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 *
70
+		 * @return void
71
+		 */
72
+		function espresso_minimum_php_version_error()
73
+		{
74
+			?>
75 75
             <div class="error">
76 76
                 <p>
77 77
                     <?php
78
-                    printf(
79
-                        esc_html__(
80
-                            '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.',
81
-                            'event_espresso'
82
-                        ),
83
-                        EE_MIN_PHP_VER_REQUIRED,
84
-                        PHP_VERSION,
85
-                        '<br/>',
86
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
-                    );
88
-                    ?>
78
+					printf(
79
+						esc_html__(
80
+							'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.',
81
+							'event_espresso'
82
+						),
83
+						EE_MIN_PHP_VER_REQUIRED,
84
+						PHP_VERSION,
85
+						'<br/>',
86
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
+					);
88
+					?>
89 89
                 </p>
90 90
             </div>
91 91
             <?php
92
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
93
-        }
92
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
93
+		}
94 94
 
95
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
-    } else {
97
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.008');
107
-        }
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
+	} else {
97
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.008');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117 117
 
118
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once EE_CORE . 'EE_Error.core.php';
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
118
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once EE_CORE . 'EE_Error.core.php';
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once $full_path_to_file;
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once $full_path_to_file;
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            require_once __DIR__ . '/core/espresso_definitions.php';
183
-            try {
184
-                espresso_load_error_handling();
185
-                espresso_load_required(
186
-                    'EEH_Base',
187
-                    EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
-                );
189
-                espresso_load_required(
190
-                    'EEH_File',
191
-                    EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
-                );
193
-                espresso_load_required(
194
-                    'EEH_File',
195
-                    EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
-                );
197
-                espresso_load_required(
198
-                    'EEH_Array',
199
-                    EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
-                );
201
-                // instantiate and configure PSR4 autoloader
202
-                espresso_load_required(
203
-                    'Psr4Autoloader',
204
-                    EE_CORE . 'Psr4Autoloader.php'
205
-                );
206
-                espresso_load_required(
207
-                    'EE_Psr4AutoloaderInit',
208
-                    EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
-                );
210
-                $AutoloaderInit = new EE_Psr4AutoloaderInit();
211
-                $AutoloaderInit->initializeAutoloader();
212
-                espresso_load_required(
213
-                    'EE_Request',
214
-                    EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
-                );
216
-                espresso_load_required(
217
-                    'EE_Response',
218
-                    EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
-                );
220
-                espresso_load_required(
221
-                    'EE_Bootstrap',
222
-                    EE_CORE . 'EE_Bootstrap.core.php'
223
-                );
224
-                // bootstrap EE and the request stack
225
-                new EE_Bootstrap(
226
-                    new EE_Request($_GET, $_POST, $_COOKIE),
227
-                    new EE_Response()
228
-                );
229
-            } catch (Exception $e) {
230
-                require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
-            }
233
-        }
234
-        bootstrap_espresso();
235
-    }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			require_once __DIR__ . '/core/espresso_definitions.php';
183
+			try {
184
+				espresso_load_error_handling();
185
+				espresso_load_required(
186
+					'EEH_Base',
187
+					EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
+				);
189
+				espresso_load_required(
190
+					'EEH_File',
191
+					EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
+				);
193
+				espresso_load_required(
194
+					'EEH_File',
195
+					EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
+				);
197
+				espresso_load_required(
198
+					'EEH_Array',
199
+					EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
+				);
201
+				// instantiate and configure PSR4 autoloader
202
+				espresso_load_required(
203
+					'Psr4Autoloader',
204
+					EE_CORE . 'Psr4Autoloader.php'
205
+				);
206
+				espresso_load_required(
207
+					'EE_Psr4AutoloaderInit',
208
+					EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
+				);
210
+				$AutoloaderInit = new EE_Psr4AutoloaderInit();
211
+				$AutoloaderInit->initializeAutoloader();
212
+				espresso_load_required(
213
+					'EE_Request',
214
+					EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
+				);
216
+				espresso_load_required(
217
+					'EE_Response',
218
+					EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
+				);
220
+				espresso_load_required(
221
+					'EE_Bootstrap',
222
+					EE_CORE . 'EE_Bootstrap.core.php'
223
+				);
224
+				// bootstrap EE and the request stack
225
+				new EE_Bootstrap(
226
+					new EE_Request($_GET, $_POST, $_COOKIE),
227
+					new EE_Response()
228
+				);
229
+			} catch (Exception $e) {
230
+				require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
+			}
233
+		}
234
+		bootstrap_espresso();
235
+	}
236 236
 }
237 237
 if (! function_exists('espresso_deactivate_plugin')) {
238
-    /**
239
-     *    deactivate_plugin
240
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
-     *
242
-     * @access public
243
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
-     * @return    void
245
-     */
246
-    function espresso_deactivate_plugin($plugin_basename = '')
247
-    {
248
-        if (! function_exists('deactivate_plugins')) {
249
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
-        }
251
-        unset($_GET['activate'], $_REQUEST['activate']);
252
-        deactivate_plugins($plugin_basename);
253
-    }
238
+	/**
239
+	 *    deactivate_plugin
240
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
+	 *
242
+	 * @access public
243
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
+	 * @return    void
245
+	 */
246
+	function espresso_deactivate_plugin($plugin_basename = '')
247
+	{
248
+		if (! function_exists('deactivate_plugins')) {
249
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
+		}
251
+		unset($_GET['activate'], $_REQUEST['activate']);
252
+		deactivate_plugins($plugin_basename);
253
+	}
254 254
 }
Please login to merge, or discard this patch.