Completed
Branch FET/add-copy-attendee-at-admin (f4d637)
by
unknown
27:40 queued 19:32
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 1 patch
Indentation   +1418 added lines, -1418 removed lines patch added patch discarded remove patch
@@ -18,1426 +18,1426 @@
 block discarded – undo
18 18
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
19 19
 {
20 20
 
21
-    /**
22
-     * @type bool $_print_copy_info
23
-     */
24
-    private $_print_copy_info = false;
25
-
26
-    /**
27
-     * @type array $_attendee_data
28
-     */
29
-    private $_attendee_data = array();
30
-
31
-    /**
32
-     * @type array $_required_questions
33
-     */
34
-    private $_required_questions = array();
35
-
36
-    /**
37
-     * @type array $_registration_answers
38
-     */
39
-    private $_registration_answers = array();
40
-
41
-
42
-    /**
43
-     *    class constructor
44
-     *
45
-     * @access    public
46
-     * @param    EE_Checkout $checkout
47
-     */
48
-    public function __construct(EE_Checkout $checkout)
49
-    {
50
-        $this->_slug = 'attendee_information';
51
-        $this->_name = esc_html__('Attendee Information', 'event_espresso');
52
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php';
53
-        $this->checkout = $checkout;
54
-        $this->_reset_success_message();
55
-        $this->set_instructions(
56
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
57
-        );
58
-    }
59
-
60
-
61
-    public function translate_js_strings()
62
-    {
63
-        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
64
-            ' is a required question.',
65
-            'event_espresso'
66
-        );
67
-        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
68
-            ' is a required question. Please enter a value for at least one of the options.',
69
-            'event_espresso'
70
-        );
71
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
72
-            'Please answer all required questions correctly before proceeding.',
73
-            'event_espresso'
74
-        );
75
-        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
76
-            esc_html_x(
77
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
78
-                'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
79
-                'event_espresso'
80
-            ),
81
-            '<br/>'
82
-        );
83
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
84
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
85
-            'event_espresso'
86
-        );
87
-        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
88
-            'You must enter a valid email address.',
89
-            'event_espresso'
90
-        );
91
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
92
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
93
-            'event_espresso'
94
-        );
95
-    }
96
-
97
-
98
-    public function enqueue_styles_and_scripts()
99
-    {
100
-    }
101
-
102
-
103
-    /**
104
-     * @return boolean
105
-     */
106
-    public function initialize_reg_step()
107
-    {
108
-        return true;
109
-    }
110
-
111
-
112
-    /**
113
-     * @return EE_Form_Section_Proper
114
-     * @throws DomainException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws ReflectionException
118
-     * @throws EntityNotFoundException
119
-     * @throws InvalidDataTypeException
120
-     * @throws InvalidInterfaceException
121
-     */
122
-    public function generate_reg_form()
123
-    {
124
-        /**
125
-         * @var $reg_config EE_Registration_Config
126
-         */
127
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
21
+	/**
22
+	 * @type bool $_print_copy_info
23
+	 */
24
+	private $_print_copy_info = false;
25
+
26
+	/**
27
+	 * @type array $_attendee_data
28
+	 */
29
+	private $_attendee_data = array();
30
+
31
+	/**
32
+	 * @type array $_required_questions
33
+	 */
34
+	private $_required_questions = array();
35
+
36
+	/**
37
+	 * @type array $_registration_answers
38
+	 */
39
+	private $_registration_answers = array();
40
+
41
+
42
+	/**
43
+	 *    class constructor
44
+	 *
45
+	 * @access    public
46
+	 * @param    EE_Checkout $checkout
47
+	 */
48
+	public function __construct(EE_Checkout $checkout)
49
+	{
50
+		$this->_slug = 'attendee_information';
51
+		$this->_name = esc_html__('Attendee Information', 'event_espresso');
52
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php';
53
+		$this->checkout = $checkout;
54
+		$this->_reset_success_message();
55
+		$this->set_instructions(
56
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
57
+		);
58
+	}
59
+
60
+
61
+	public function translate_js_strings()
62
+	{
63
+		EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
64
+			' is a required question.',
65
+			'event_espresso'
66
+		);
67
+		EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
68
+			' is a required question. Please enter a value for at least one of the options.',
69
+			'event_espresso'
70
+		);
71
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
72
+			'Please answer all required questions correctly before proceeding.',
73
+			'event_espresso'
74
+		);
75
+		EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
76
+			esc_html_x(
77
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
78
+				'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
79
+				'event_espresso'
80
+			),
81
+			'<br/>'
82
+		);
83
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
84
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
85
+			'event_espresso'
86
+		);
87
+		EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
88
+			'You must enter a valid email address.',
89
+			'event_espresso'
90
+		);
91
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
92
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
93
+			'event_espresso'
94
+		);
95
+	}
96
+
97
+
98
+	public function enqueue_styles_and_scripts()
99
+	{
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return boolean
105
+	 */
106
+	public function initialize_reg_step()
107
+	{
108
+		return true;
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return EE_Form_Section_Proper
114
+	 * @throws DomainException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws ReflectionException
118
+	 * @throws EntityNotFoundException
119
+	 * @throws InvalidDataTypeException
120
+	 * @throws InvalidInterfaceException
121
+	 */
122
+	public function generate_reg_form()
123
+	{
124
+		/**
125
+		 * @var $reg_config EE_Registration_Config
126
+		 */
127
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
128 128
     
129
-        $this->_print_copy_info = $reg_config->copyAttendeeInfo();
130
-        $primary_registrant = null;
131
-        // autoload Line_Item_Display classes
132
-        EEH_Autoloader::register_line_item_display_autoloaders();
133
-        $Line_Item_Display = new EE_Line_Item_Display();
134
-        // calculate taxes
135
-        $Line_Item_Display->display_line_item(
136
-            $this->checkout->cart->get_grand_total(),
137
-            array('set_tax_rate' => true)
138
-        );
139
-        /** @var $subsections EE_Form_Section_Proper[] */
140
-        $extra_inputs_section = $this->reg_step_hidden_inputs();
141
-        $subsections = array(
142
-            'default_hidden_inputs' => $extra_inputs_section,
143
-        );
144
-
145
-        // if this isn't a revisit, and they have the privacy consent box enalbed, add it
146
-        if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) {
147
-            $extra_inputs_section->add_subsections(
148
-                array(
149
-                    'consent_box' => new EE_Form_Section_Proper(
150
-                        array(
151
-                            'layout_strategy' =>
152
-                                new EE_Template_Layout(
153
-                                    array(
154
-                                        'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php',
155
-                                    )
156
-                                ),
157
-                            'subsections'     => array(
158
-                                'consent' => new EE_Checkbox_Multi_Input(
159
-                                    array(
160
-                                        'consent' => $reg_config->getConsentCheckboxLabelText(),
161
-                                    ),
162
-                                    array(
163
-                                        'required'                          => true,
164
-                                        'required_validation_error_message' => esc_html__(
165
-                                            'You must consent to these terms in order to register.',
166
-                                            'event_espresso'
167
-                                        ),
168
-                                        'html_label_text'                   => '',
169
-                                    )
170
-                                ),
171
-                            ),
172
-                        )
173
-                    ),
174
-                ),
175
-                null,
176
-                false
177
-            );
178
-        }
179
-        $template_args = array(
180
-            'revisit'       => $this->checkout->revisit,
181
-            'registrations' => array(),
182
-            'ticket_count'  => array(),
183
-        );
184
-        // grab the saved registrations from the transaction
185
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
186
-        if ($registrations) {
187
-            foreach ($registrations as $registration) {
188
-                // can this registration be processed during this visit ?
189
-                if ($registration instanceof EE_Registration
190
-                    && $this->checkout->visit_allows_processing_of_this_registration($registration)
191
-                ) {
192
-                    $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration);
193
-                    $template_args['registrations'][ $registration->reg_url_link() ] = $registration;
194
-                    $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
195
-                        $template_args['ticket_count'][ $registration->ticket()->ID() ]
196
-                    )
197
-                        ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
198
-                        : 1;
199
-                    $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
200
-                        $this->checkout->cart->get_grand_total(),
201
-                        'Ticket',
202
-                        array($registration->ticket()->ID())
203
-                    );
204
-                    $ticket_line_item = is_array($ticket_line_item)
205
-                        ? reset($ticket_line_item)
206
-                        : $ticket_line_item;
207
-                    $template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
208
-                        $Line_Item_Display->display_line_item($ticket_line_item);
209
-                    if ($registration->is_primary_registrant()) {
210
-                        $primary_registrant = $registration->reg_url_link();
211
-                    }
212
-                }
213
-            }
214
-            if ($primary_registrant && count($registrations) > 1) {
215
-                $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
216
-                    ? $this->_copy_attendee_info_form()
217
-                    : $this->_auto_copy_attendee_info();
218
-                // generate hidden input
219
-                if (isset($subsections[ $primary_registrant ])
220
-                    && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
221
-                ) {
222
-                    $subsections[ $primary_registrant ]->add_subsections(
223
-                        $copy_options,
224
-                        'primary_registrant',
225
-                        false
226
-                    );
227
-                }
228
-            }
229
-        }
230
-        return new EE_Form_Section_Proper(
231
-            array(
232
-                'name'            => $this->reg_form_name(),
233
-                'html_id'         => $this->reg_form_name(),
234
-                'subsections'     => $subsections,
235
-                'layout_strategy' => new EE_Template_Layout(
236
-                    array(
237
-                        'layout_template_file' => $this->_template, // layout_template
238
-                        'template_args'        => $template_args,
239
-                    )
240
-                ),
241
-            )
242
-        );
243
-    }
244
-
245
-
246
-    /**
247
-     * @param EE_Registration $registration
248
-     * @return EE_Form_Section_Base
249
-     * @throws EE_Error
250
-     * @throws InvalidArgumentException
251
-     * @throws EntityNotFoundException
252
-     * @throws InvalidDataTypeException
253
-     * @throws InvalidInterfaceException
254
-     * @throws ReflectionException
255
-     */
256
-    private function _registrations_reg_form(EE_Registration $registration)
257
-    {
258
-        static $attendee_nmbr = 1;
259
-        $form_args = array();
260
-        // verify that registration has valid event
261
-        if ($registration->event() instanceof EE_Event) {
262
-            $field_name = 'Event_Question_Group.'
263
-                . EEM_Event_Question_Group::instance()->fieldNameForContext(
264
-                    $registration->is_primary_registrant()
265
-                );
266
-            $question_groups = $registration->event()->question_groups(
267
-                apply_filters(
268
-                    // @codingStandardsIgnoreStart
269
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
270
-                    // @codingStandardsIgnoreEnd
271
-                    [
272
-                        [
273
-                            'Event.EVT_ID'                     => $registration->event()->ID(),
274
-                            $field_name => true,
275
-                        ],
276
-                        'order_by' => ['QSG_order' => 'ASC'],
277
-                    ],
278
-                    $registration,
279
-                    $this
280
-                )
281
-            );
282
-            if ($question_groups) {
283
-                // array of params to pass to parent constructor
284
-                $form_args = array(
285
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
286
-                    'html_class'      => 'ee-reg-form-attendee-dv',
287
-                    'html_style'      => $this->checkout->admin_request
288
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
289
-                        : '',
290
-                    'subsections'     => array(),
291
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
292
-                        array(
293
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
294
-                            'legend_text'  => sprintf(
295
-                                esc_html_x(
296
-                                    'Attendee %d',
297
-                                    'Attendee 123',
298
-                                    'event_espresso'
299
-                                ),
300
-                                $attendee_nmbr
301
-                            ),
302
-                        )
303
-                    ),
304
-                );
305
-                foreach ($question_groups as $question_group) {
306
-                    if ($question_group instanceof EE_Question_Group) {
307
-                        $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
308
-                            $registration,
309
-                            $question_group
310
-                        );
311
-                    }
312
-                }
313
-                // add hidden input
314
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
315
-                    $registration
316
-                );
317
-
318
-                /**
319
-                 * @var $reg_config EE_Registration_Config
320
-                 */
321
-                $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
322
-
323
-                // if we have question groups for additional attendees, then display the copy options
324
-                $this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false;
325
-                if ($registration->is_primary_registrant()) {
326
-                    // generate hidden input
327
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
328
-                        $registration
329
-                    );
330
-                }
331
-            }
332
-        }
333
-        $attendee_nmbr++;
334
-        return ! empty($form_args)
335
-            ? new EE_Form_Section_Proper($form_args)
336
-            : new EE_Form_Section_HTML();
337
-    }
338
-
339
-
340
-    /**
341
-     * @param EE_Registration $registration
342
-     * @param bool            $additional_attendee_reg_info
343
-     * @return EE_Form_Input_Base
344
-     * @throws EE_Error
345
-     */
346
-    private function _additional_attendee_reg_info_input(
347
-        EE_Registration $registration,
348
-        $additional_attendee_reg_info = true
349
-    ) {
350
-        // generate hidden input
351
-        return new EE_Hidden_Input(
352
-            array(
353
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
354
-                'default' => $additional_attendee_reg_info,
355
-            )
356
-        );
357
-    }
358
-
359
-
360
-    /**
361
-     * @param EE_Registration   $registration
362
-     * @param EE_Question_Group $question_group
363
-     * @return EE_Form_Section_Proper
364
-     * @throws EE_Error
365
-     * @throws InvalidArgumentException
366
-     * @throws InvalidDataTypeException
367
-     * @throws InvalidInterfaceException
368
-     * @throws ReflectionException
369
-     */
370
-    private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
371
-    {
372
-        // array of params to pass to parent constructor
373
-        $form_args = array(
374
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
375
-            'html_class'      => $this->checkout->admin_request
376
-                ? 'form-table ee-reg-form-qstn-grp-dv'
377
-                : 'ee-reg-form-qstn-grp-dv',
378
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
379
-                                 . $registration->ID() . '-lbl',
380
-            'subsections'     => array(
381
-                'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
382
-            ),
383
-            'layout_strategy' => $this->checkout->admin_request
384
-                ? new EE_Admin_Two_Column_Layout()
385
-                : new EE_Div_Per_Section_Layout(),
386
-        );
387
-        // where params
388
-        $query_params = array('QST_deleted' => 0);
389
-        // don't load admin only questions on the frontend
390
-        if (! $this->checkout->admin_request) {
391
-            $query_params['QST_admin_only'] = array('!=', true);
392
-        }
393
-        $questions = $question_group->get_many_related(
394
-            'Question',
395
-            apply_filters(
396
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
397
-                array(
398
-                    $query_params,
399
-                    'order_by' => array(
400
-                        'Question_Group_Question.QGQ_order' => 'ASC',
401
-                    ),
402
-                ),
403
-                $question_group,
404
-                $registration,
405
-                $this
406
-            )
407
-        );
408
-        // filter for additional content before questions
409
-        $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
410
-            apply_filters(
411
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
412
-                '',
413
-                $registration,
414
-                $question_group,
415
-                $this
416
-            )
417
-        );
418
-        // loop thru questions
419
-        foreach ($questions as $question) {
420
-            if ($question instanceof EE_Question) {
421
-                $identifier = $question->is_system_question()
422
-                    ? $question->system_ID()
423
-                    : $question->ID();
424
-                $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
425
-            }
426
-        }
427
-        $form_args['subsections'] = apply_filters(
428
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
429
-            $form_args['subsections'],
430
-            $registration,
431
-            $question_group,
432
-            $this
433
-        );
434
-        // filter for additional content after questions
435
-        $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
436
-            apply_filters(
437
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
438
-                '',
439
-                $registration,
440
-                $question_group,
441
-                $this
442
-            )
443
-        );
444
-        // d($form_args);
445
-        $question_group_reg_form = new EE_Form_Section_Proper($form_args);
446
-        return apply_filters(
447
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
448
-            $question_group_reg_form,
449
-            $registration,
450
-            $question_group,
451
-            $this
452
-        );
453
-    }
454
-
455
-
456
-    /**
457
-     * @param EE_Question_Group $question_group
458
-     * @return    EE_Form_Section_HTML
459
-     */
460
-    private function _question_group_header(EE_Question_Group $question_group)
461
-    {
462
-        $html = '';
463
-        // group_name
464
-        if ($question_group->show_group_name() && $question_group->name() !== '') {
465
-            if ($this->checkout->admin_request) {
466
-                $html .= EEH_HTML::br();
467
-                $html .= EEH_HTML::h3(
468
-                    $question_group->name(),
469
-                    '',
470
-                    'ee-reg-form-qstn-grp-title title',
471
-                    'font-size: 1.3em; padding-left:0;'
472
-                );
473
-            } else {
474
-                $html .= EEH_HTML::h4(
475
-                    $question_group->name(),
476
-                    '',
477
-                    'ee-reg-form-qstn-grp-title section-title'
478
-                );
479
-            }
480
-        }
481
-        // group_desc
482
-        if ($question_group->show_group_desc() && $question_group->desc() !== '') {
483
-            $html .= EEH_HTML::p(
484
-                $question_group->desc(),
485
-                '',
486
-                $this->checkout->admin_request
487
-                    ? 'ee-reg-form-qstn-grp-desc-pg'
488
-                    : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
489
-            );
490
-        }
491
-        return new EE_Form_Section_HTML($html);
492
-    }
493
-
494
-
495
-    /**
496
-     * @return    EE_Form_Section_Proper
497
-     * @throws EE_Error
498
-     * @throws InvalidArgumentException
499
-     * @throws ReflectionException
500
-     * @throws InvalidDataTypeException
501
-     * @throws InvalidInterfaceException
502
-     */
503
-    private function _copy_attendee_info_form()
504
-    {
505
-        // array of params to pass to parent constructor
506
-        return new EE_Form_Section_Proper(
507
-            array(
508
-                'subsections'     => $this->_copy_attendee_info_inputs(),
509
-                'layout_strategy' => new EE_Template_Layout(
510
-                    array(
511
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
512
-                                                      . $this->_slug
513
-                                                      . '/copy_attendee_info.template.php',
514
-                        'begin_template_file'      => null,
515
-                        'input_template_file'      => null,
516
-                        'subsection_template_file' => null,
517
-                        'end_template_file'        => null,
518
-                    )
519
-                ),
520
-            )
521
-        );
522
-    }
523
-
524
-
525
-    /**
526
-     * @return EE_Form_Section_HTML
527
-     * @throws DomainException
528
-     * @throws InvalidArgumentException
529
-     * @throws InvalidDataTypeException
530
-     * @throws InvalidInterfaceException
531
-     */
532
-    private function _auto_copy_attendee_info()
533
-    {
534
-        return new EE_Form_Section_HTML(
535
-            EEH_Template::locate_template(
536
-                SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php',
537
-                apply_filters(
538
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
539
-                    array()
540
-                ),
541
-                true,
542
-                true
543
-            )
544
-        );
545
-    }
546
-
547
-
548
-    /**
549
-     * @return array
550
-     * @throws EE_Error
551
-     * @throws InvalidArgumentException
552
-     * @throws ReflectionException
553
-     * @throws InvalidDataTypeException
554
-     * @throws InvalidInterfaceException
555
-     */
556
-    private function _copy_attendee_info_inputs()
557
-    {
558
-        $copy_attendee_info_inputs = array();
559
-        $prev_ticket = null;
560
-        // grab the saved registrations from the transaction
561
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
562
-        foreach ($registrations as $registration) {
563
-            // for all  attendees other than the primary attendee
564
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
565
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
566
-                if ($registration->ticket()->ID() !== $prev_ticket) {
567
-                    $item_name = $registration->ticket()->name();
568
-                    $item_name .= $registration->ticket()->description() !== ''
569
-                        ? ' - ' . $registration->ticket()->description()
570
-                        : '';
571
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
572
-                    ) . ']' ] =
573
-                        new EE_Form_Section_HTML(
574
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
575
-                        );
576
-                    $prev_ticket = $registration->ticket()->ID();
577
-                }
578
-
579
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
580
-                    new EE_Checkbox_Multi_Input(
581
-                        array(
582
-                            $registration->ID() => sprintf(
583
-                                esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
584
-                                $registration->count()
585
-                            ),
586
-                        ),
587
-                        array(
588
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
589
-                            'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
590
-                            'display_html_label_text' => false,
591
-                        )
592
-                    );
593
-            }
594
-        }
595
-        return $copy_attendee_info_inputs;
596
-    }
597
-
598
-
599
-    /**
600
-     * @param EE_Registration $registration
601
-     * @return    EE_Form_Input_Base
602
-     * @throws EE_Error
603
-     */
604
-    private function _additional_primary_registrant_inputs(EE_Registration $registration)
605
-    {
606
-        // generate hidden input
607
-        return new EE_Hidden_Input(
608
-            array(
609
-                'html_id' => 'primary_registrant',
610
-                'default' => $registration->reg_url_link(),
611
-            )
612
-        );
613
-    }
614
-
615
-
616
-    /**
617
-     * @param EE_Registration $registration
618
-     * @param EE_Question     $question
619
-     * @return EE_Form_Input_Base
620
-     * @throws EE_Error
621
-     * @throws InvalidArgumentException
622
-     * @throws InvalidDataTypeException
623
-     * @throws InvalidInterfaceException
624
-     * @throws ReflectionException
625
-     */
626
-    public function reg_form_question(EE_Registration $registration, EE_Question $question)
627
-    {
628
-
629
-        // if this question was for an attendee detail, then check for that answer
630
-        $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
631
-            $registration,
632
-            $question->system_ID()
633
-        );
634
-        $answer = $answer_value === null
635
-            ? EEM_Answer::instance()->get_one(
636
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
637
-            )
638
-            : null;
639
-        // if NOT returning to edit an existing registration
640
-        // OR if this question is for an attendee property
641
-        // OR we still don't have an EE_Answer object
642
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
643
-            // create an EE_Answer object for storing everything in
644
-            $answer = EE_Answer::new_instance(
645
-                array(
646
-                    'QST_ID' => $question->ID(),
647
-                    'REG_ID' => $registration->ID(),
648
-                )
649
-            );
650
-        }
651
-        // verify instance
652
-        if ($answer instanceof EE_Answer) {
653
-            if (! empty($answer_value)) {
654
-                $answer->set('ANS_value', $answer_value);
655
-            }
656
-            $answer->cache('Question', $question);
657
-            // remember system ID had a bug where sometimes it could be null
658
-            $answer_cache_id = $question->is_system_question()
659
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
660
-                : $question->ID() . '-' . $registration->reg_url_link();
661
-            $registration->cache('Answer', $answer, $answer_cache_id);
662
-        }
663
-        return $this->_generate_question_input($registration, $question, $answer);
664
-    }
665
-
666
-
667
-    /**
668
-     * @param EE_Registration $registration
669
-     * @param EE_Question     $question
670
-     * @param                 $answer
671
-     * @return EE_Form_Input_Base
672
-     * @throws EE_Error
673
-     * @throws InvalidArgumentException
674
-     * @throws ReflectionException
675
-     * @throws InvalidDataTypeException
676
-     * @throws InvalidInterfaceException
677
-     */
678
-    private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
679
-    {
680
-        $identifier = $question->is_system_question()
681
-            ? $question->system_ID()
682
-            : $question->ID();
683
-        $this->_required_questions[ $identifier ] = $question->required() ? true : false;
684
-        add_filter(
685
-            'FHEE__EE_Question__generate_form_input__country_options',
686
-            array($this, 'use_cached_countries_for_form_input'),
687
-            10,
688
-            4
689
-        );
690
-        add_filter(
691
-            'FHEE__EE_Question__generate_form_input__state_options',
692
-            array($this, 'use_cached_states_for_form_input'),
693
-            10,
694
-            4
695
-        );
696
-        $input_constructor_args = array(
697
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
698
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
699
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
700
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
701
-            'html_label_class' => 'ee-reg-qstn',
702
-        );
703
-        $input_constructor_args['html_label_id'] .= '-lbl';
704
-        if ($answer instanceof EE_Answer && $answer->ID()) {
705
-            $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
706
-            $input_constructor_args['html_id'] .= '-' . $answer->ID();
707
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
708
-        }
709
-        $form_input = $question->generate_form_input(
710
-            $registration,
711
-            $answer,
712
-            $input_constructor_args
713
-        );
714
-        remove_filter(
715
-            'FHEE__EE_Question__generate_form_input__country_options',
716
-            array($this, 'use_cached_countries_for_form_input')
717
-        );
718
-        remove_filter(
719
-            'FHEE__EE_Question__generate_form_input__state_options',
720
-            array($this, 'use_cached_states_for_form_input')
721
-        );
722
-        return $form_input;
723
-    }
724
-
725
-
726
-    /**
727
-     * Gets the list of countries for the form input
728
-     *
729
-     * @param array|null      $countries_list
730
-     * @param EE_Question     $question
731
-     * @param EE_Registration $registration
732
-     * @param EE_Answer       $answer
733
-     * @return array 2d keys are country IDs, values are their names
734
-     * @throws EE_Error
735
-     * @throws InvalidArgumentException
736
-     * @throws InvalidDataTypeException
737
-     * @throws InvalidInterfaceException
738
-     * @throws ReflectionException
739
-     */
740
-    public function use_cached_countries_for_form_input(
741
-        $countries_list,
742
-        EE_Question $question = null,
743
-        EE_Registration $registration = null,
744
-        EE_Answer $answer = null
745
-    ) {
746
-        $country_options = array('' => '');
747
-        // get possibly cached list of countries
748
-        $countries = $this->checkout->action === 'process_reg_step'
749
-            ? EEM_Country::instance()->get_all_countries()
750
-            : EEM_Country::instance()->get_all_active_countries();
751
-        if (! empty($countries)) {
752
-            foreach ($countries as $country) {
753
-                if ($country instanceof EE_Country) {
754
-                    $country_options[ $country->ID() ] = $country->name();
755
-                }
756
-            }
757
-        }
758
-        if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
759
-            $answer = EEM_Answer::instance()->get_one(
760
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
761
-            );
762
-        } else {
763
-            $answer = EE_Answer::new_instance();
764
-        }
765
-        $country_options = apply_filters(
766
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
767
-            $country_options,
768
-            $this,
769
-            $registration,
770
-            $question,
771
-            $answer
772
-        );
773
-        return $country_options;
774
-    }
775
-
776
-
777
-    /**
778
-     * Gets the list of states for the form input
779
-     *
780
-     * @param array|null      $states_list
781
-     * @param EE_Question     $question
782
-     * @param EE_Registration $registration
783
-     * @param EE_Answer       $answer
784
-     * @return array 2d keys are state IDs, values are their names
785
-     * @throws EE_Error
786
-     * @throws InvalidArgumentException
787
-     * @throws InvalidDataTypeException
788
-     * @throws InvalidInterfaceException
789
-     * @throws ReflectionException
790
-     */
791
-    public function use_cached_states_for_form_input(
792
-        $states_list,
793
-        EE_Question $question = null,
794
-        EE_Registration $registration = null,
795
-        EE_Answer $answer = null
796
-    ) {
797
-        $state_options = array('' => array('' => ''));
798
-        $states = $this->checkout->action === 'process_reg_step'
799
-            ? EEM_State::instance()->get_all_states()
800
-            : EEM_State::instance()->get_all_active_states();
801
-        if (! empty($states)) {
802
-            foreach ($states as $state) {
803
-                if ($state instanceof EE_State) {
804
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
805
-                }
806
-            }
807
-        }
808
-        $state_options = apply_filters(
809
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
810
-            $state_options,
811
-            $this,
812
-            $registration,
813
-            $question,
814
-            $answer
815
-        );
816
-        return $state_options;
817
-    }
818
-
819
-
820
-    /********************************************************************************************************/
821
-    /****************************************  PROCESS REG STEP  ****************************************/
822
-    /********************************************************************************************************/
823
-
824
-
825
-    /**
826
-     * @return bool
827
-     * @throws EE_Error
828
-     * @throws InvalidArgumentException
829
-     * @throws ReflectionException
830
-     * @throws RuntimeException
831
-     * @throws InvalidDataTypeException
832
-     * @throws InvalidInterfaceException
833
-     */
834
-    public function process_reg_step()
835
-    {
836
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
837
-        // grab validated data from form
838
-        $valid_data = $this->checkout->current_step->valid_data();
839
-        // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
840
-        // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
841
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
842
-        if (empty($valid_data)) {
843
-            EE_Error::add_error(
844
-                esc_html__('No valid question responses were received.', 'event_espresso'),
845
-                __FILE__,
846
-                __FUNCTION__,
847
-                __LINE__
848
-            );
849
-            return false;
850
-        }
851
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
852
-            EE_Error::add_error(
853
-                esc_html__(
854
-                    'A valid transaction could not be initiated for processing your registrations.',
855
-                    'event_espresso'
856
-                ),
857
-                __FILE__,
858
-                __FUNCTION__,
859
-                __LINE__
860
-            );
861
-            return false;
862
-        }
863
-        // get cached registrations
864
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
865
-        // verify we got the goods
866
-        if (empty($registrations)) {
867
-            // combine the old translated string with a new one, in order to not break translations
868
-            $error_message = esc_html__(
869
-                'Your form data could not be applied to any valid registrations.',
870
-                'event_espresso'
871
-            )
872
-            . sprintf(
873
-                esc_html_x(
874
-                    '%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.',
875
-                    '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
876
-                    'event_espresso'
877
-                ),
878
-                '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
879
-                '</a>',
880
-                '<br />'
881
-            );
882
-            EE_Error::add_error(
883
-                $error_message,
884
-                __FILE__,
885
-                __FUNCTION__,
886
-                __LINE__
887
-            );
888
-            return false;
889
-        }
890
-        // extract attendee info from form data and save to model objects
891
-        $registrations_processed = $this->_process_registrations($registrations, $valid_data);
892
-        // if first pass thru SPCO,
893
-        // then let's check processed registrations against the total number of tickets in the cart
894
-        if ($registrations_processed === false) {
895
-            // but return immediately if the previous step exited early due to errors
896
-            return false;
897
-        }
898
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
899
-            // generate a correctly translated string for all possible singular/plural combinations
900
-            if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
901
-                $error_msg = sprintf(
902
-                    esc_html_x(
903
-                        'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
904
-                        'There was 1 ticket in the Event Queue, but 2 registrations were processed',
905
-                        'event_espresso'
906
-                    ),
907
-                    $this->checkout->total_ticket_count,
908
-                    $registrations_processed
909
-                );
910
-            } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
911
-                $error_msg = sprintf(
912
-                    esc_html_x(
913
-                        'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
914
-                        'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
915
-                        'event_espresso'
916
-                    ),
917
-                    $this->checkout->total_ticket_count,
918
-                    $registrations_processed
919
-                );
920
-            } else {
921
-                $error_msg = sprintf(
922
-                    esc_html__(
923
-                        'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
924
-                        'event_espresso'
925
-                    ),
926
-                    $this->checkout->total_ticket_count,
927
-                    $registrations_processed
928
-                );
929
-            }
930
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
931
-            return false;
932
-        }
933
-        // mark this reg step as completed
934
-        $this->set_completed();
935
-        $this->_set_success_message(
936
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
937
-        );
938
-        // do action in case a plugin wants to do something with the data submitted in step 1.
939
-        // passes EE_Single_Page_Checkout, and it's posted data
940
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
941
-        return true;
942
-    }
943
-
944
-
945
-    /**
946
-     *    _process_registrations
947
-     *
948
-     * @param EE_Registration[] $registrations
949
-     * @param array[][]         $valid_data
950
-     * @return bool|int
951
-     * @throws EntityNotFoundException
952
-     * @throws EE_Error
953
-     * @throws InvalidArgumentException
954
-     * @throws ReflectionException
955
-     * @throws RuntimeException
956
-     * @throws InvalidDataTypeException
957
-     * @throws InvalidInterfaceException
958
-     */
959
-    private function _process_registrations($registrations = array(), $valid_data = array())
960
-    {
961
-        // load resources and set some defaults
962
-        EE_Registry::instance()->load_model('Attendee');
963
-        // holder for primary registrant attendee object
964
-        $this->checkout->primary_attendee_obj = null;
965
-        // array for tracking reg form data for the primary registrant
966
-        $primary_registrant = array(
967
-            'line_item_id' => null,
968
-        );
969
-        $copy_primary = false;
970
-        // reg form sections that do not contain inputs
971
-        $non_input_form_sections = array(
972
-            'primary_registrant',
973
-            'additional_attendee_reg_info',
974
-            'spco_copy_attendee_chk',
975
-        );
976
-        // attendee counter
977
-        $att_nmbr = 0;
978
-        // grab the saved registrations from the transaction
979
-        foreach ($registrations as $registration) {
980
-            // verify EE_Registration object
981
-            if (! $registration instanceof EE_Registration) {
982
-                EE_Error::add_error(
983
-                    esc_html__(
984
-                        'An invalid Registration object was discovered when attempting to process your registration information.',
985
-                        'event_espresso'
986
-                    ),
987
-                    __FILE__,
988
-                    __FUNCTION__,
989
-                    __LINE__
990
-                );
991
-                return false;
992
-            }
993
-            /** @var string $reg_url_link */
994
-            $reg_url_link = $registration->reg_url_link();
995
-            // reg_url_link exists ?
996
-            if (! empty($reg_url_link)) {
997
-                // should this registration be processed during this visit ?
998
-                if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
999
-                    // if NOT revisiting, then let's save the registration now,
1000
-                    // so that we have a REG_ID to use when generating other objects
1001
-                    if (! $this->checkout->revisit) {
1002
-                        $registration->save();
1003
-                    }
1004
-                    /**
1005
-                     * This allows plugins to trigger a fail on processing of a
1006
-                     * registration for any conditions they may have for it to pass.
1007
-                     *
1008
-                     * @var bool   if true is returned by the plugin then the
1009
-                     *            registration processing is halted.
1010
-                     */
1011
-                    if (apply_filters(
1012
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
1013
-                        false,
1014
-                        $att_nmbr,
1015
-                        $registration,
1016
-                        $registrations,
1017
-                        $valid_data,
1018
-                        $this
1019
-                    )) {
1020
-                        return false;
1021
-                    }
1022
-
1023
-                    // Houston, we have a registration!
1024
-                    $att_nmbr++;
1025
-                    $this->_attendee_data[ $reg_url_link ] = array();
1026
-                    // grab any existing related answer objects
1027
-                    $this->_registration_answers = $registration->answers();
1028
-                    // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
1029
-                    if (isset($valid_data[ $reg_url_link ])) {
1030
-                        // do we need to copy basic info from primary attendee ?
1031
-                        $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
1032
-                                        && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
1033
-                        // filter form input data for this registration
1034
-                        $valid_data[ $reg_url_link ] = (array) apply_filters(
1035
-                            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
1036
-                            $valid_data[ $reg_url_link ]
1037
-                        );
1038
-                        if (isset($valid_data['primary_attendee'])) {
1039
-                            $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
1040
-                                ? $valid_data['primary_attendee']
1041
-                                : false;
1042
-                            unset($valid_data['primary_attendee']);
1043
-                        }
1044
-                        // now loop through our array of valid post data && process attendee reg forms
1045
-                        foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
1046
-                            if (! in_array($form_section, $non_input_form_sections, true)) {
1047
-                                foreach ($form_inputs as $form_input => $input_value) {
1048
-                                    // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
1049
-                                    // check for critical inputs
1050
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
1051
-                                        $form_input,
1052
-                                        $input_value
1053
-                                    )
1054
-                                    ) {
1055
-                                        return false;
1056
-                                    }
1057
-                                    // store a bit of data about the primary attendee
1058
-                                    if ($att_nmbr === 1
1059
-                                        && ! empty($input_value)
1060
-                                        && $reg_url_link === $primary_registrant['line_item_id']
1061
-                                    ) {
1062
-                                        $primary_registrant[ $form_input ] = $input_value;
1063
-                                    } elseif ($copy_primary
1064
-                                              && $input_value === null
1065
-                                              && isset($primary_registrant[ $form_input ])
1066
-                                    ) {
1067
-                                        $input_value = $primary_registrant[ $form_input ];
1068
-                                    }
1069
-                                    // now attempt to save the input data
1070
-                                    if (! $this->_save_registration_form_input(
1071
-                                        $registration,
1072
-                                        $form_input,
1073
-                                        $input_value
1074
-                                    )
1075
-                                    ) {
1076
-                                        EE_Error::add_error(
1077
-                                            sprintf(
1078
-                                                esc_html_x(
1079
-                                                    'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1080
-                                                    'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
1081
-                                                    'event_espresso'
1082
-                                                ),
1083
-                                                $form_input,
1084
-                                                $input_value
1085
-                                            ),
1086
-                                            __FILE__,
1087
-                                            __FUNCTION__,
1088
-                                            __LINE__
1089
-                                        );
1090
-                                        return false;
1091
-                                    }
1092
-                                }
1093
-                            }
1094
-                        }  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1095
-                    }
1096
-                    // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1097
-                    // this registration does not require additional attendee information ?
1098
-                    if ($copy_primary
1099
-                        && $att_nmbr > 1
1100
-                        && $this->checkout->primary_attendee_obj instanceof EE_Attendee
1101
-                    ) {
1102
-                        // just copy the primary registrant
1103
-                        $attendee = $this->checkout->primary_attendee_obj;
1104
-                    } else {
1105
-                        // ensure critical details are set for additional attendees
1106
-                        $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1107
-                            ? $this->_copy_critical_attendee_details_from_primary_registrant(
1108
-                                $this->_attendee_data[ $reg_url_link ]
1109
-                            )
1110
-                            : $this->_attendee_data[ $reg_url_link ];
1111
-                        // execute create attendee command (which may return an existing attendee)
1112
-                        $attendee = EE_Registry::instance()->BUS->execute(
1113
-                            new CreateAttendeeCommand(
1114
-                                $this->_attendee_data[ $reg_url_link ],
1115
-                                $registration
1116
-                            )
1117
-                        );
1118
-                        // who's #1 ?
1119
-                        if ($att_nmbr === 1) {
1120
-                            $this->checkout->primary_attendee_obj = $attendee;
1121
-                        }
1122
-                    }
1123
-                    // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1124
-                    // add relation to registration, set attendee ID, and cache attendee
1125
-                    $this->_associate_attendee_with_registration($registration, $attendee);
1126
-                    // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1127
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1128
-                        EE_Error::add_error(
1129
-                            sprintf(
1130
-                                esc_html_x(
1131
-                                    'Registration %s has an invalid or missing Attendee object.',
1132
-                                    'Registration 123-456-789 has an invalid or missing Attendee object.',
1133
-                                    'event_espresso'
1134
-                                ),
1135
-                                $reg_url_link
1136
-                            ),
1137
-                            __FILE__,
1138
-                            __FUNCTION__,
1139
-                            __LINE__
1140
-                        );
1141
-                        return false;
1142
-                    }
1143
-                    /** @type EE_Registration_Processor $registration_processor */
1144
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1145
-                    // at this point, we should have enough details about the registrant to consider the registration
1146
-                    // NOT incomplete
1147
-                    $registration_processor->toggle_incomplete_registration_status_to_default(
1148
-                        $registration,
1149
-                        false,
1150
-                        new Context(
1151
-                            'spco_reg_step_attendee_information_process_registrations',
1152
-                            esc_html__(
1153
-                                'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1154
-                                'event_espresso'
1155
-                            )
1156
-                        )
1157
-                    );
1158
-                    // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1159
-                    // abandoned
1160
-                    $this->checkout->transaction->toggle_failed_transaction_status();
1161
-                    // if we've gotten this far, then let's save what we have
1162
-                    $registration->save();
1163
-                    // add relation between TXN and registration
1164
-                    $this->_associate_registration_with_transaction($registration);
1165
-                }
1166
-            } else {
1167
-                EE_Error::add_error(
1168
-                    esc_html__(
1169
-                        'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1170
-                        'event_espresso'
1171
-                    ),
1172
-                    __FILE__,
1173
-                    __FUNCTION__,
1174
-                    __LINE__
1175
-                );
1176
-                // remove malformed data
1177
-                unset($valid_data[ $reg_url_link ]);
1178
-                return false;
1179
-            }
1180
-        } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1181
-        return $att_nmbr;
1182
-    }
1183
-
1184
-
1185
-    /**
1186
-     *    _save_registration_form_input
1187
-     *
1188
-     * @param EE_Registration $registration
1189
-     * @param string          $form_input
1190
-     * @param string          $input_value
1191
-     * @return bool
1192
-     * @throws EE_Error
1193
-     * @throws InvalidArgumentException
1194
-     * @throws InvalidDataTypeException
1195
-     * @throws InvalidInterfaceException
1196
-     * @throws ReflectionException
1197
-     */
1198
-    private function _save_registration_form_input(
1199
-        EE_Registration $registration,
1200
-        $form_input = '',
1201
-        $input_value = ''
1202
-    ) {
1203
-        // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1204
-        // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1205
-        // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1206
-        // allow for plugins to hook in and do their own processing of the form input.
1207
-        // For plugins to bypass normal processing here, they just need to return a boolean value.
1208
-        if (apply_filters(
1209
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1210
-            false,
1211
-            $registration,
1212
-            $form_input,
1213
-            $input_value,
1214
-            $this
1215
-        )) {
1216
-            return true;
1217
-        }
1218
-        /*
129
+		$this->_print_copy_info = $reg_config->copyAttendeeInfo();
130
+		$primary_registrant = null;
131
+		// autoload Line_Item_Display classes
132
+		EEH_Autoloader::register_line_item_display_autoloaders();
133
+		$Line_Item_Display = new EE_Line_Item_Display();
134
+		// calculate taxes
135
+		$Line_Item_Display->display_line_item(
136
+			$this->checkout->cart->get_grand_total(),
137
+			array('set_tax_rate' => true)
138
+		);
139
+		/** @var $subsections EE_Form_Section_Proper[] */
140
+		$extra_inputs_section = $this->reg_step_hidden_inputs();
141
+		$subsections = array(
142
+			'default_hidden_inputs' => $extra_inputs_section,
143
+		);
144
+
145
+		// if this isn't a revisit, and they have the privacy consent box enalbed, add it
146
+		if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) {
147
+			$extra_inputs_section->add_subsections(
148
+				array(
149
+					'consent_box' => new EE_Form_Section_Proper(
150
+						array(
151
+							'layout_strategy' =>
152
+								new EE_Template_Layout(
153
+									array(
154
+										'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php',
155
+									)
156
+								),
157
+							'subsections'     => array(
158
+								'consent' => new EE_Checkbox_Multi_Input(
159
+									array(
160
+										'consent' => $reg_config->getConsentCheckboxLabelText(),
161
+									),
162
+									array(
163
+										'required'                          => true,
164
+										'required_validation_error_message' => esc_html__(
165
+											'You must consent to these terms in order to register.',
166
+											'event_espresso'
167
+										),
168
+										'html_label_text'                   => '',
169
+									)
170
+								),
171
+							),
172
+						)
173
+					),
174
+				),
175
+				null,
176
+				false
177
+			);
178
+		}
179
+		$template_args = array(
180
+			'revisit'       => $this->checkout->revisit,
181
+			'registrations' => array(),
182
+			'ticket_count'  => array(),
183
+		);
184
+		// grab the saved registrations from the transaction
185
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
186
+		if ($registrations) {
187
+			foreach ($registrations as $registration) {
188
+				// can this registration be processed during this visit ?
189
+				if ($registration instanceof EE_Registration
190
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
191
+				) {
192
+					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration);
193
+					$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
194
+					$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
195
+						$template_args['ticket_count'][ $registration->ticket()->ID() ]
196
+					)
197
+						? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
198
+						: 1;
199
+					$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
200
+						$this->checkout->cart->get_grand_total(),
201
+						'Ticket',
202
+						array($registration->ticket()->ID())
203
+					);
204
+					$ticket_line_item = is_array($ticket_line_item)
205
+						? reset($ticket_line_item)
206
+						: $ticket_line_item;
207
+					$template_args['ticket_line_item'][ $registration->ticket()->ID() ] =
208
+						$Line_Item_Display->display_line_item($ticket_line_item);
209
+					if ($registration->is_primary_registrant()) {
210
+						$primary_registrant = $registration->reg_url_link();
211
+					}
212
+				}
213
+			}
214
+			if ($primary_registrant && count($registrations) > 1) {
215
+				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
216
+					? $this->_copy_attendee_info_form()
217
+					: $this->_auto_copy_attendee_info();
218
+				// generate hidden input
219
+				if (isset($subsections[ $primary_registrant ])
220
+					&& $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
221
+				) {
222
+					$subsections[ $primary_registrant ]->add_subsections(
223
+						$copy_options,
224
+						'primary_registrant',
225
+						false
226
+					);
227
+				}
228
+			}
229
+		}
230
+		return new EE_Form_Section_Proper(
231
+			array(
232
+				'name'            => $this->reg_form_name(),
233
+				'html_id'         => $this->reg_form_name(),
234
+				'subsections'     => $subsections,
235
+				'layout_strategy' => new EE_Template_Layout(
236
+					array(
237
+						'layout_template_file' => $this->_template, // layout_template
238
+						'template_args'        => $template_args,
239
+					)
240
+				),
241
+			)
242
+		);
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param EE_Registration $registration
248
+	 * @return EE_Form_Section_Base
249
+	 * @throws EE_Error
250
+	 * @throws InvalidArgumentException
251
+	 * @throws EntityNotFoundException
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws InvalidInterfaceException
254
+	 * @throws ReflectionException
255
+	 */
256
+	private function _registrations_reg_form(EE_Registration $registration)
257
+	{
258
+		static $attendee_nmbr = 1;
259
+		$form_args = array();
260
+		// verify that registration has valid event
261
+		if ($registration->event() instanceof EE_Event) {
262
+			$field_name = 'Event_Question_Group.'
263
+				. EEM_Event_Question_Group::instance()->fieldNameForContext(
264
+					$registration->is_primary_registrant()
265
+				);
266
+			$question_groups = $registration->event()->question_groups(
267
+				apply_filters(
268
+					// @codingStandardsIgnoreStart
269
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
270
+					// @codingStandardsIgnoreEnd
271
+					[
272
+						[
273
+							'Event.EVT_ID'                     => $registration->event()->ID(),
274
+							$field_name => true,
275
+						],
276
+						'order_by' => ['QSG_order' => 'ASC'],
277
+					],
278
+					$registration,
279
+					$this
280
+				)
281
+			);
282
+			if ($question_groups) {
283
+				// array of params to pass to parent constructor
284
+				$form_args = array(
285
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
286
+					'html_class'      => 'ee-reg-form-attendee-dv',
287
+					'html_style'      => $this->checkout->admin_request
288
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
289
+						: '',
290
+					'subsections'     => array(),
291
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
292
+						array(
293
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
294
+							'legend_text'  => sprintf(
295
+								esc_html_x(
296
+									'Attendee %d',
297
+									'Attendee 123',
298
+									'event_espresso'
299
+								),
300
+								$attendee_nmbr
301
+							),
302
+						)
303
+					),
304
+				);
305
+				foreach ($question_groups as $question_group) {
306
+					if ($question_group instanceof EE_Question_Group) {
307
+						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
308
+							$registration,
309
+							$question_group
310
+						);
311
+					}
312
+				}
313
+				// add hidden input
314
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
315
+					$registration
316
+				);
317
+
318
+				/**
319
+				 * @var $reg_config EE_Registration_Config
320
+				 */
321
+				$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
322
+
323
+				// if we have question groups for additional attendees, then display the copy options
324
+				$this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false;
325
+				if ($registration->is_primary_registrant()) {
326
+					// generate hidden input
327
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
328
+						$registration
329
+					);
330
+				}
331
+			}
332
+		}
333
+		$attendee_nmbr++;
334
+		return ! empty($form_args)
335
+			? new EE_Form_Section_Proper($form_args)
336
+			: new EE_Form_Section_HTML();
337
+	}
338
+
339
+
340
+	/**
341
+	 * @param EE_Registration $registration
342
+	 * @param bool            $additional_attendee_reg_info
343
+	 * @return EE_Form_Input_Base
344
+	 * @throws EE_Error
345
+	 */
346
+	private function _additional_attendee_reg_info_input(
347
+		EE_Registration $registration,
348
+		$additional_attendee_reg_info = true
349
+	) {
350
+		// generate hidden input
351
+		return new EE_Hidden_Input(
352
+			array(
353
+				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
354
+				'default' => $additional_attendee_reg_info,
355
+			)
356
+		);
357
+	}
358
+
359
+
360
+	/**
361
+	 * @param EE_Registration   $registration
362
+	 * @param EE_Question_Group $question_group
363
+	 * @return EE_Form_Section_Proper
364
+	 * @throws EE_Error
365
+	 * @throws InvalidArgumentException
366
+	 * @throws InvalidDataTypeException
367
+	 * @throws InvalidInterfaceException
368
+	 * @throws ReflectionException
369
+	 */
370
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
371
+	{
372
+		// array of params to pass to parent constructor
373
+		$form_args = array(
374
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(),
375
+			'html_class'      => $this->checkout->admin_request
376
+				? 'form-table ee-reg-form-qstn-grp-dv'
377
+				: 'ee-reg-form-qstn-grp-dv',
378
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-'
379
+								 . $registration->ID() . '-lbl',
380
+			'subsections'     => array(
381
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
382
+			),
383
+			'layout_strategy' => $this->checkout->admin_request
384
+				? new EE_Admin_Two_Column_Layout()
385
+				: new EE_Div_Per_Section_Layout(),
386
+		);
387
+		// where params
388
+		$query_params = array('QST_deleted' => 0);
389
+		// don't load admin only questions on the frontend
390
+		if (! $this->checkout->admin_request) {
391
+			$query_params['QST_admin_only'] = array('!=', true);
392
+		}
393
+		$questions = $question_group->get_many_related(
394
+			'Question',
395
+			apply_filters(
396
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
397
+				array(
398
+					$query_params,
399
+					'order_by' => array(
400
+						'Question_Group_Question.QGQ_order' => 'ASC',
401
+					),
402
+				),
403
+				$question_group,
404
+				$registration,
405
+				$this
406
+			)
407
+		);
408
+		// filter for additional content before questions
409
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
410
+			apply_filters(
411
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
412
+				'',
413
+				$registration,
414
+				$question_group,
415
+				$this
416
+			)
417
+		);
418
+		// loop thru questions
419
+		foreach ($questions as $question) {
420
+			if ($question instanceof EE_Question) {
421
+				$identifier = $question->is_system_question()
422
+					? $question->system_ID()
423
+					: $question->ID();
424
+				$form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question);
425
+			}
426
+		}
427
+		$form_args['subsections'] = apply_filters(
428
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
429
+			$form_args['subsections'],
430
+			$registration,
431
+			$question_group,
432
+			$this
433
+		);
434
+		// filter for additional content after questions
435
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
436
+			apply_filters(
437
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
438
+				'',
439
+				$registration,
440
+				$question_group,
441
+				$this
442
+			)
443
+		);
444
+		// d($form_args);
445
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
446
+		return apply_filters(
447
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
448
+			$question_group_reg_form,
449
+			$registration,
450
+			$question_group,
451
+			$this
452
+		);
453
+	}
454
+
455
+
456
+	/**
457
+	 * @param EE_Question_Group $question_group
458
+	 * @return    EE_Form_Section_HTML
459
+	 */
460
+	private function _question_group_header(EE_Question_Group $question_group)
461
+	{
462
+		$html = '';
463
+		// group_name
464
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
465
+			if ($this->checkout->admin_request) {
466
+				$html .= EEH_HTML::br();
467
+				$html .= EEH_HTML::h3(
468
+					$question_group->name(),
469
+					'',
470
+					'ee-reg-form-qstn-grp-title title',
471
+					'font-size: 1.3em; padding-left:0;'
472
+				);
473
+			} else {
474
+				$html .= EEH_HTML::h4(
475
+					$question_group->name(),
476
+					'',
477
+					'ee-reg-form-qstn-grp-title section-title'
478
+				);
479
+			}
480
+		}
481
+		// group_desc
482
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
483
+			$html .= EEH_HTML::p(
484
+				$question_group->desc(),
485
+				'',
486
+				$this->checkout->admin_request
487
+					? 'ee-reg-form-qstn-grp-desc-pg'
488
+					: 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
489
+			);
490
+		}
491
+		return new EE_Form_Section_HTML($html);
492
+	}
493
+
494
+
495
+	/**
496
+	 * @return    EE_Form_Section_Proper
497
+	 * @throws EE_Error
498
+	 * @throws InvalidArgumentException
499
+	 * @throws ReflectionException
500
+	 * @throws InvalidDataTypeException
501
+	 * @throws InvalidInterfaceException
502
+	 */
503
+	private function _copy_attendee_info_form()
504
+	{
505
+		// array of params to pass to parent constructor
506
+		return new EE_Form_Section_Proper(
507
+			array(
508
+				'subsections'     => $this->_copy_attendee_info_inputs(),
509
+				'layout_strategy' => new EE_Template_Layout(
510
+					array(
511
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
512
+													  . $this->_slug
513
+													  . '/copy_attendee_info.template.php',
514
+						'begin_template_file'      => null,
515
+						'input_template_file'      => null,
516
+						'subsection_template_file' => null,
517
+						'end_template_file'        => null,
518
+					)
519
+				),
520
+			)
521
+		);
522
+	}
523
+
524
+
525
+	/**
526
+	 * @return EE_Form_Section_HTML
527
+	 * @throws DomainException
528
+	 * @throws InvalidArgumentException
529
+	 * @throws InvalidDataTypeException
530
+	 * @throws InvalidInterfaceException
531
+	 */
532
+	private function _auto_copy_attendee_info()
533
+	{
534
+		return new EE_Form_Section_HTML(
535
+			EEH_Template::locate_template(
536
+				SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php',
537
+				apply_filters(
538
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
539
+					array()
540
+				),
541
+				true,
542
+				true
543
+			)
544
+		);
545
+	}
546
+
547
+
548
+	/**
549
+	 * @return array
550
+	 * @throws EE_Error
551
+	 * @throws InvalidArgumentException
552
+	 * @throws ReflectionException
553
+	 * @throws InvalidDataTypeException
554
+	 * @throws InvalidInterfaceException
555
+	 */
556
+	private function _copy_attendee_info_inputs()
557
+	{
558
+		$copy_attendee_info_inputs = array();
559
+		$prev_ticket = null;
560
+		// grab the saved registrations from the transaction
561
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
562
+		foreach ($registrations as $registration) {
563
+			// for all  attendees other than the primary attendee
564
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
565
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
566
+				if ($registration->ticket()->ID() !== $prev_ticket) {
567
+					$item_name = $registration->ticket()->name();
568
+					$item_name .= $registration->ticket()->description() !== ''
569
+						? ' - ' . $registration->ticket()->description()
570
+						: '';
571
+					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID(
572
+					) . ']' ] =
573
+						new EE_Form_Section_HTML(
574
+							'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
575
+						);
576
+					$prev_ticket = $registration->ticket()->ID();
577
+				}
578
+
579
+				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] =
580
+					new EE_Checkbox_Multi_Input(
581
+						array(
582
+							$registration->ID() => sprintf(
583
+								esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
584
+								$registration->count()
585
+							),
586
+						),
587
+						array(
588
+							'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
589
+							'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
590
+							'display_html_label_text' => false,
591
+						)
592
+					);
593
+			}
594
+		}
595
+		return $copy_attendee_info_inputs;
596
+	}
597
+
598
+
599
+	/**
600
+	 * @param EE_Registration $registration
601
+	 * @return    EE_Form_Input_Base
602
+	 * @throws EE_Error
603
+	 */
604
+	private function _additional_primary_registrant_inputs(EE_Registration $registration)
605
+	{
606
+		// generate hidden input
607
+		return new EE_Hidden_Input(
608
+			array(
609
+				'html_id' => 'primary_registrant',
610
+				'default' => $registration->reg_url_link(),
611
+			)
612
+		);
613
+	}
614
+
615
+
616
+	/**
617
+	 * @param EE_Registration $registration
618
+	 * @param EE_Question     $question
619
+	 * @return EE_Form_Input_Base
620
+	 * @throws EE_Error
621
+	 * @throws InvalidArgumentException
622
+	 * @throws InvalidDataTypeException
623
+	 * @throws InvalidInterfaceException
624
+	 * @throws ReflectionException
625
+	 */
626
+	public function reg_form_question(EE_Registration $registration, EE_Question $question)
627
+	{
628
+
629
+		// if this question was for an attendee detail, then check for that answer
630
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
631
+			$registration,
632
+			$question->system_ID()
633
+		);
634
+		$answer = $answer_value === null
635
+			? EEM_Answer::instance()->get_one(
636
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
637
+			)
638
+			: null;
639
+		// if NOT returning to edit an existing registration
640
+		// OR if this question is for an attendee property
641
+		// OR we still don't have an EE_Answer object
642
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
643
+			// create an EE_Answer object for storing everything in
644
+			$answer = EE_Answer::new_instance(
645
+				array(
646
+					'QST_ID' => $question->ID(),
647
+					'REG_ID' => $registration->ID(),
648
+				)
649
+			);
650
+		}
651
+		// verify instance
652
+		if ($answer instanceof EE_Answer) {
653
+			if (! empty($answer_value)) {
654
+				$answer->set('ANS_value', $answer_value);
655
+			}
656
+			$answer->cache('Question', $question);
657
+			// remember system ID had a bug where sometimes it could be null
658
+			$answer_cache_id = $question->is_system_question()
659
+				? $question->system_ID() . '-' . $registration->reg_url_link()
660
+				: $question->ID() . '-' . $registration->reg_url_link();
661
+			$registration->cache('Answer', $answer, $answer_cache_id);
662
+		}
663
+		return $this->_generate_question_input($registration, $question, $answer);
664
+	}
665
+
666
+
667
+	/**
668
+	 * @param EE_Registration $registration
669
+	 * @param EE_Question     $question
670
+	 * @param                 $answer
671
+	 * @return EE_Form_Input_Base
672
+	 * @throws EE_Error
673
+	 * @throws InvalidArgumentException
674
+	 * @throws ReflectionException
675
+	 * @throws InvalidDataTypeException
676
+	 * @throws InvalidInterfaceException
677
+	 */
678
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
679
+	{
680
+		$identifier = $question->is_system_question()
681
+			? $question->system_ID()
682
+			: $question->ID();
683
+		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
684
+		add_filter(
685
+			'FHEE__EE_Question__generate_form_input__country_options',
686
+			array($this, 'use_cached_countries_for_form_input'),
687
+			10,
688
+			4
689
+		);
690
+		add_filter(
691
+			'FHEE__EE_Question__generate_form_input__state_options',
692
+			array($this, 'use_cached_states_for_form_input'),
693
+			10,
694
+			4
695
+		);
696
+		$input_constructor_args = array(
697
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
698
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
699
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
700
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
701
+			'html_label_class' => 'ee-reg-qstn',
702
+		);
703
+		$input_constructor_args['html_label_id'] .= '-lbl';
704
+		if ($answer instanceof EE_Answer && $answer->ID()) {
705
+			$input_constructor_args['html_name'] .= '[' . $answer->ID() . ']';
706
+			$input_constructor_args['html_id'] .= '-' . $answer->ID();
707
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
708
+		}
709
+		$form_input = $question->generate_form_input(
710
+			$registration,
711
+			$answer,
712
+			$input_constructor_args
713
+		);
714
+		remove_filter(
715
+			'FHEE__EE_Question__generate_form_input__country_options',
716
+			array($this, 'use_cached_countries_for_form_input')
717
+		);
718
+		remove_filter(
719
+			'FHEE__EE_Question__generate_form_input__state_options',
720
+			array($this, 'use_cached_states_for_form_input')
721
+		);
722
+		return $form_input;
723
+	}
724
+
725
+
726
+	/**
727
+	 * Gets the list of countries for the form input
728
+	 *
729
+	 * @param array|null      $countries_list
730
+	 * @param EE_Question     $question
731
+	 * @param EE_Registration $registration
732
+	 * @param EE_Answer       $answer
733
+	 * @return array 2d keys are country IDs, values are their names
734
+	 * @throws EE_Error
735
+	 * @throws InvalidArgumentException
736
+	 * @throws InvalidDataTypeException
737
+	 * @throws InvalidInterfaceException
738
+	 * @throws ReflectionException
739
+	 */
740
+	public function use_cached_countries_for_form_input(
741
+		$countries_list,
742
+		EE_Question $question = null,
743
+		EE_Registration $registration = null,
744
+		EE_Answer $answer = null
745
+	) {
746
+		$country_options = array('' => '');
747
+		// get possibly cached list of countries
748
+		$countries = $this->checkout->action === 'process_reg_step'
749
+			? EEM_Country::instance()->get_all_countries()
750
+			: EEM_Country::instance()->get_all_active_countries();
751
+		if (! empty($countries)) {
752
+			foreach ($countries as $country) {
753
+				if ($country instanceof EE_Country) {
754
+					$country_options[ $country->ID() ] = $country->name();
755
+				}
756
+			}
757
+		}
758
+		if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
759
+			$answer = EEM_Answer::instance()->get_one(
760
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
761
+			);
762
+		} else {
763
+			$answer = EE_Answer::new_instance();
764
+		}
765
+		$country_options = apply_filters(
766
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
767
+			$country_options,
768
+			$this,
769
+			$registration,
770
+			$question,
771
+			$answer
772
+		);
773
+		return $country_options;
774
+	}
775
+
776
+
777
+	/**
778
+	 * Gets the list of states for the form input
779
+	 *
780
+	 * @param array|null      $states_list
781
+	 * @param EE_Question     $question
782
+	 * @param EE_Registration $registration
783
+	 * @param EE_Answer       $answer
784
+	 * @return array 2d keys are state IDs, values are their names
785
+	 * @throws EE_Error
786
+	 * @throws InvalidArgumentException
787
+	 * @throws InvalidDataTypeException
788
+	 * @throws InvalidInterfaceException
789
+	 * @throws ReflectionException
790
+	 */
791
+	public function use_cached_states_for_form_input(
792
+		$states_list,
793
+		EE_Question $question = null,
794
+		EE_Registration $registration = null,
795
+		EE_Answer $answer = null
796
+	) {
797
+		$state_options = array('' => array('' => ''));
798
+		$states = $this->checkout->action === 'process_reg_step'
799
+			? EEM_State::instance()->get_all_states()
800
+			: EEM_State::instance()->get_all_active_states();
801
+		if (! empty($states)) {
802
+			foreach ($states as $state) {
803
+				if ($state instanceof EE_State) {
804
+					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
805
+				}
806
+			}
807
+		}
808
+		$state_options = apply_filters(
809
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
810
+			$state_options,
811
+			$this,
812
+			$registration,
813
+			$question,
814
+			$answer
815
+		);
816
+		return $state_options;
817
+	}
818
+
819
+
820
+	/********************************************************************************************************/
821
+	/****************************************  PROCESS REG STEP  ****************************************/
822
+	/********************************************************************************************************/
823
+
824
+
825
+	/**
826
+	 * @return bool
827
+	 * @throws EE_Error
828
+	 * @throws InvalidArgumentException
829
+	 * @throws ReflectionException
830
+	 * @throws RuntimeException
831
+	 * @throws InvalidDataTypeException
832
+	 * @throws InvalidInterfaceException
833
+	 */
834
+	public function process_reg_step()
835
+	{
836
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
837
+		// grab validated data from form
838
+		$valid_data = $this->checkout->current_step->valid_data();
839
+		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
840
+		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
841
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
842
+		if (empty($valid_data)) {
843
+			EE_Error::add_error(
844
+				esc_html__('No valid question responses were received.', 'event_espresso'),
845
+				__FILE__,
846
+				__FUNCTION__,
847
+				__LINE__
848
+			);
849
+			return false;
850
+		}
851
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
852
+			EE_Error::add_error(
853
+				esc_html__(
854
+					'A valid transaction could not be initiated for processing your registrations.',
855
+					'event_espresso'
856
+				),
857
+				__FILE__,
858
+				__FUNCTION__,
859
+				__LINE__
860
+			);
861
+			return false;
862
+		}
863
+		// get cached registrations
864
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
865
+		// verify we got the goods
866
+		if (empty($registrations)) {
867
+			// combine the old translated string with a new one, in order to not break translations
868
+			$error_message = esc_html__(
869
+				'Your form data could not be applied to any valid registrations.',
870
+				'event_espresso'
871
+			)
872
+			. sprintf(
873
+				esc_html_x(
874
+					'%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.',
875
+					'(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
876
+					'event_espresso'
877
+				),
878
+				'<a href="' . get_post_type_archive_link('espresso_events') . '" >',
879
+				'</a>',
880
+				'<br />'
881
+			);
882
+			EE_Error::add_error(
883
+				$error_message,
884
+				__FILE__,
885
+				__FUNCTION__,
886
+				__LINE__
887
+			);
888
+			return false;
889
+		}
890
+		// extract attendee info from form data and save to model objects
891
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
892
+		// if first pass thru SPCO,
893
+		// then let's check processed registrations against the total number of tickets in the cart
894
+		if ($registrations_processed === false) {
895
+			// but return immediately if the previous step exited early due to errors
896
+			return false;
897
+		}
898
+		if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
899
+			// generate a correctly translated string for all possible singular/plural combinations
900
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
901
+				$error_msg = sprintf(
902
+					esc_html_x(
903
+						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
904
+						'There was 1 ticket in the Event Queue, but 2 registrations were processed',
905
+						'event_espresso'
906
+					),
907
+					$this->checkout->total_ticket_count,
908
+					$registrations_processed
909
+				);
910
+			} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
911
+				$error_msg = sprintf(
912
+					esc_html_x(
913
+						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
914
+						'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
915
+						'event_espresso'
916
+					),
917
+					$this->checkout->total_ticket_count,
918
+					$registrations_processed
919
+				);
920
+			} else {
921
+				$error_msg = sprintf(
922
+					esc_html__(
923
+						'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
924
+						'event_espresso'
925
+					),
926
+					$this->checkout->total_ticket_count,
927
+					$registrations_processed
928
+				);
929
+			}
930
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
931
+			return false;
932
+		}
933
+		// mark this reg step as completed
934
+		$this->set_completed();
935
+		$this->_set_success_message(
936
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
937
+		);
938
+		// do action in case a plugin wants to do something with the data submitted in step 1.
939
+		// passes EE_Single_Page_Checkout, and it's posted data
940
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
941
+		return true;
942
+	}
943
+
944
+
945
+	/**
946
+	 *    _process_registrations
947
+	 *
948
+	 * @param EE_Registration[] $registrations
949
+	 * @param array[][]         $valid_data
950
+	 * @return bool|int
951
+	 * @throws EntityNotFoundException
952
+	 * @throws EE_Error
953
+	 * @throws InvalidArgumentException
954
+	 * @throws ReflectionException
955
+	 * @throws RuntimeException
956
+	 * @throws InvalidDataTypeException
957
+	 * @throws InvalidInterfaceException
958
+	 */
959
+	private function _process_registrations($registrations = array(), $valid_data = array())
960
+	{
961
+		// load resources and set some defaults
962
+		EE_Registry::instance()->load_model('Attendee');
963
+		// holder for primary registrant attendee object
964
+		$this->checkout->primary_attendee_obj = null;
965
+		// array for tracking reg form data for the primary registrant
966
+		$primary_registrant = array(
967
+			'line_item_id' => null,
968
+		);
969
+		$copy_primary = false;
970
+		// reg form sections that do not contain inputs
971
+		$non_input_form_sections = array(
972
+			'primary_registrant',
973
+			'additional_attendee_reg_info',
974
+			'spco_copy_attendee_chk',
975
+		);
976
+		// attendee counter
977
+		$att_nmbr = 0;
978
+		// grab the saved registrations from the transaction
979
+		foreach ($registrations as $registration) {
980
+			// verify EE_Registration object
981
+			if (! $registration instanceof EE_Registration) {
982
+				EE_Error::add_error(
983
+					esc_html__(
984
+						'An invalid Registration object was discovered when attempting to process your registration information.',
985
+						'event_espresso'
986
+					),
987
+					__FILE__,
988
+					__FUNCTION__,
989
+					__LINE__
990
+				);
991
+				return false;
992
+			}
993
+			/** @var string $reg_url_link */
994
+			$reg_url_link = $registration->reg_url_link();
995
+			// reg_url_link exists ?
996
+			if (! empty($reg_url_link)) {
997
+				// should this registration be processed during this visit ?
998
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
999
+					// if NOT revisiting, then let's save the registration now,
1000
+					// so that we have a REG_ID to use when generating other objects
1001
+					if (! $this->checkout->revisit) {
1002
+						$registration->save();
1003
+					}
1004
+					/**
1005
+					 * This allows plugins to trigger a fail on processing of a
1006
+					 * registration for any conditions they may have for it to pass.
1007
+					 *
1008
+					 * @var bool   if true is returned by the plugin then the
1009
+					 *            registration processing is halted.
1010
+					 */
1011
+					if (apply_filters(
1012
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
1013
+						false,
1014
+						$att_nmbr,
1015
+						$registration,
1016
+						$registrations,
1017
+						$valid_data,
1018
+						$this
1019
+					)) {
1020
+						return false;
1021
+					}
1022
+
1023
+					// Houston, we have a registration!
1024
+					$att_nmbr++;
1025
+					$this->_attendee_data[ $reg_url_link ] = array();
1026
+					// grab any existing related answer objects
1027
+					$this->_registration_answers = $registration->answers();
1028
+					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
1029
+					if (isset($valid_data[ $reg_url_link ])) {
1030
+						// do we need to copy basic info from primary attendee ?
1031
+						$copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info'])
1032
+										&& absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
1033
+						// filter form input data for this registration
1034
+						$valid_data[ $reg_url_link ] = (array) apply_filters(
1035
+							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
1036
+							$valid_data[ $reg_url_link ]
1037
+						);
1038
+						if (isset($valid_data['primary_attendee'])) {
1039
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
1040
+								? $valid_data['primary_attendee']
1041
+								: false;
1042
+							unset($valid_data['primary_attendee']);
1043
+						}
1044
+						// now loop through our array of valid post data && process attendee reg forms
1045
+						foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) {
1046
+							if (! in_array($form_section, $non_input_form_sections, true)) {
1047
+								foreach ($form_inputs as $form_input => $input_value) {
1048
+									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
1049
+									// check for critical inputs
1050
+									if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
1051
+										$form_input,
1052
+										$input_value
1053
+									)
1054
+									) {
1055
+										return false;
1056
+									}
1057
+									// store a bit of data about the primary attendee
1058
+									if ($att_nmbr === 1
1059
+										&& ! empty($input_value)
1060
+										&& $reg_url_link === $primary_registrant['line_item_id']
1061
+									) {
1062
+										$primary_registrant[ $form_input ] = $input_value;
1063
+									} elseif ($copy_primary
1064
+											  && $input_value === null
1065
+											  && isset($primary_registrant[ $form_input ])
1066
+									) {
1067
+										$input_value = $primary_registrant[ $form_input ];
1068
+									}
1069
+									// now attempt to save the input data
1070
+									if (! $this->_save_registration_form_input(
1071
+										$registration,
1072
+										$form_input,
1073
+										$input_value
1074
+									)
1075
+									) {
1076
+										EE_Error::add_error(
1077
+											sprintf(
1078
+												esc_html_x(
1079
+													'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1080
+													'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
1081
+													'event_espresso'
1082
+												),
1083
+												$form_input,
1084
+												$input_value
1085
+											),
1086
+											__FILE__,
1087
+											__FUNCTION__,
1088
+											__LINE__
1089
+										);
1090
+										return false;
1091
+									}
1092
+								}
1093
+							}
1094
+						}  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1095
+					}
1096
+					// EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1097
+					// this registration does not require additional attendee information ?
1098
+					if ($copy_primary
1099
+						&& $att_nmbr > 1
1100
+						&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1101
+					) {
1102
+						// just copy the primary registrant
1103
+						$attendee = $this->checkout->primary_attendee_obj;
1104
+					} else {
1105
+						// ensure critical details are set for additional attendees
1106
+						$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
1107
+							? $this->_copy_critical_attendee_details_from_primary_registrant(
1108
+								$this->_attendee_data[ $reg_url_link ]
1109
+							)
1110
+							: $this->_attendee_data[ $reg_url_link ];
1111
+						// execute create attendee command (which may return an existing attendee)
1112
+						$attendee = EE_Registry::instance()->BUS->execute(
1113
+							new CreateAttendeeCommand(
1114
+								$this->_attendee_data[ $reg_url_link ],
1115
+								$registration
1116
+							)
1117
+						);
1118
+						// who's #1 ?
1119
+						if ($att_nmbr === 1) {
1120
+							$this->checkout->primary_attendee_obj = $attendee;
1121
+						}
1122
+					}
1123
+					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1124
+					// add relation to registration, set attendee ID, and cache attendee
1125
+					$this->_associate_attendee_with_registration($registration, $attendee);
1126
+					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1127
+					if (! $registration->attendee() instanceof EE_Attendee) {
1128
+						EE_Error::add_error(
1129
+							sprintf(
1130
+								esc_html_x(
1131
+									'Registration %s has an invalid or missing Attendee object.',
1132
+									'Registration 123-456-789 has an invalid or missing Attendee object.',
1133
+									'event_espresso'
1134
+								),
1135
+								$reg_url_link
1136
+							),
1137
+							__FILE__,
1138
+							__FUNCTION__,
1139
+							__LINE__
1140
+						);
1141
+						return false;
1142
+					}
1143
+					/** @type EE_Registration_Processor $registration_processor */
1144
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1145
+					// at this point, we should have enough details about the registrant to consider the registration
1146
+					// NOT incomplete
1147
+					$registration_processor->toggle_incomplete_registration_status_to_default(
1148
+						$registration,
1149
+						false,
1150
+						new Context(
1151
+							'spco_reg_step_attendee_information_process_registrations',
1152
+							esc_html__(
1153
+								'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1154
+								'event_espresso'
1155
+							)
1156
+						)
1157
+					);
1158
+					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1159
+					// abandoned
1160
+					$this->checkout->transaction->toggle_failed_transaction_status();
1161
+					// if we've gotten this far, then let's save what we have
1162
+					$registration->save();
1163
+					// add relation between TXN and registration
1164
+					$this->_associate_registration_with_transaction($registration);
1165
+				}
1166
+			} else {
1167
+				EE_Error::add_error(
1168
+					esc_html__(
1169
+						'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1170
+						'event_espresso'
1171
+					),
1172
+					__FILE__,
1173
+					__FUNCTION__,
1174
+					__LINE__
1175
+				);
1176
+				// remove malformed data
1177
+				unset($valid_data[ $reg_url_link ]);
1178
+				return false;
1179
+			}
1180
+		} // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1181
+		return $att_nmbr;
1182
+	}
1183
+
1184
+
1185
+	/**
1186
+	 *    _save_registration_form_input
1187
+	 *
1188
+	 * @param EE_Registration $registration
1189
+	 * @param string          $form_input
1190
+	 * @param string          $input_value
1191
+	 * @return bool
1192
+	 * @throws EE_Error
1193
+	 * @throws InvalidArgumentException
1194
+	 * @throws InvalidDataTypeException
1195
+	 * @throws InvalidInterfaceException
1196
+	 * @throws ReflectionException
1197
+	 */
1198
+	private function _save_registration_form_input(
1199
+		EE_Registration $registration,
1200
+		$form_input = '',
1201
+		$input_value = ''
1202
+	) {
1203
+		// \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1204
+		// \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1205
+		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1206
+		// allow for plugins to hook in and do their own processing of the form input.
1207
+		// For plugins to bypass normal processing here, they just need to return a boolean value.
1208
+		if (apply_filters(
1209
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1210
+			false,
1211
+			$registration,
1212
+			$form_input,
1213
+			$input_value,
1214
+			$this
1215
+		)) {
1216
+			return true;
1217
+		}
1218
+		/*
1219 1219
          * $answer_cache_id is the key used to find the EE_Answer we want
1220 1220
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1221 1221
          */
1222
-        $answer_cache_id = $this->checkout->reg_url_link
1223
-            ? $form_input . '-' . $registration->reg_url_link()
1224
-            : $form_input;
1225
-        $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1226
-                         && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer;
1227
-        // rename form_inputs if they are EE_Attendee properties
1228
-        switch ((string) $form_input) {
1229
-            case 'state':
1230
-            case 'STA_ID':
1231
-                $attendee_property = true;
1232
-                $form_input = 'STA_ID';
1233
-                break;
1234
-
1235
-            case 'country':
1236
-            case 'CNT_ISO':
1237
-                $attendee_property = true;
1238
-                $form_input = 'CNT_ISO';
1239
-                break;
1240
-
1241
-            default:
1242
-                $ATT_input = 'ATT_' . $form_input;
1243
-                // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1244
-                $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1245
-                $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1246
-        }
1247
-        // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1248
-        // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1249
-        // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1250
-        // if this form input has a corresponding attendee property
1251
-        if ($attendee_property) {
1252
-            $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1253
-            if ($answer_is_obj) {
1254
-                // and delete the corresponding answer since we won't be storing this data in that object
1255
-                $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1256
-                $this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1257
-            }
1258
-            return true;
1259
-        }
1260
-        if ($answer_is_obj) {
1261
-            // save this data to the answer object
1262
-            $this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1263
-            $result = $this->_registration_answers[ $answer_cache_id ]->save();
1264
-            return $result !== false;
1265
-        }
1266
-        foreach ($this->_registration_answers as $answer) {
1267
-            if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1268
-                $answer->set_value($input_value);
1269
-                $result = $answer->save();
1270
-                return $result !== false;
1271
-            }
1272
-        }
1273
-        return false;
1274
-    }
1275
-
1276
-
1277
-    /**
1278
-     *    _verify_critical_attendee_details_are_set
1279
-     *
1280
-     * @param string $form_input
1281
-     * @param string $input_value
1282
-     * @return boolean
1283
-     */
1284
-    private function _verify_critical_attendee_details_are_set_and_validate_email(
1285
-        $form_input = '',
1286
-        $input_value = ''
1287
-    ) {
1288
-        if (empty($input_value)) {
1289
-            // if the form input isn't marked as being required, then just return
1290
-            if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1291
-                return true;
1292
-            }
1293
-            switch ($form_input) {
1294
-                case 'fname':
1295
-                    EE_Error::add_error(
1296
-                        esc_html__('First Name is a required value.', 'event_espresso'),
1297
-                        __FILE__,
1298
-                        __FUNCTION__,
1299
-                        __LINE__
1300
-                    );
1301
-                    return false;
1302
-                    break;
1303
-                case 'lname':
1304
-                    EE_Error::add_error(
1305
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
1306
-                        __FILE__,
1307
-                        __FUNCTION__,
1308
-                        __LINE__
1309
-                    );
1310
-                    return false;
1311
-                    break;
1312
-                case 'email':
1313
-                    EE_Error::add_error(
1314
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
1315
-                        __FILE__,
1316
-                        __FUNCTION__,
1317
-                        __LINE__
1318
-                    );
1319
-                    return false;
1320
-                    break;
1321
-            }
1322
-        }
1323
-        return true;
1324
-    }
1325
-
1326
-
1327
-    /**
1328
-     *    _associate_attendee_with_registration
1329
-     *
1330
-     * @param EE_Registration $registration
1331
-     * @param EE_Attendee     $attendee
1332
-     * @return void
1333
-     * @throws EE_Error
1334
-     * @throws InvalidArgumentException
1335
-     * @throws ReflectionException
1336
-     * @throws RuntimeException
1337
-     * @throws InvalidDataTypeException
1338
-     * @throws InvalidInterfaceException
1339
-     */
1340
-    private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1341
-    {
1342
-        // add relation to attendee
1343
-        $registration->_add_relation_to($attendee, 'Attendee');
1344
-        $registration->set_attendee_id($attendee->ID());
1345
-        $registration->update_cache_after_object_save('Attendee', $attendee);
1346
-    }
1347
-
1348
-
1349
-    /**
1350
-     *    _associate_registration_with_transaction
1351
-     *
1352
-     * @param EE_Registration $registration
1353
-     * @return void
1354
-     * @throws EE_Error
1355
-     * @throws InvalidArgumentException
1356
-     * @throws ReflectionException
1357
-     * @throws InvalidDataTypeException
1358
-     * @throws InvalidInterfaceException
1359
-     */
1360
-    private function _associate_registration_with_transaction(EE_Registration $registration)
1361
-    {
1362
-        // add relation to registration
1363
-        $this->checkout->transaction->_add_relation_to($registration, 'Registration');
1364
-        $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1365
-    }
1366
-
1367
-
1368
-    /**
1369
-     *    _copy_critical_attendee_details_from_primary_registrant
1370
-     *    ensures that all attendees at least have data for first name, last name, and email address
1371
-     *
1372
-     * @param array $attendee_data
1373
-     * @return array
1374
-     * @throws EE_Error
1375
-     * @throws InvalidArgumentException
1376
-     * @throws ReflectionException
1377
-     * @throws InvalidDataTypeException
1378
-     * @throws InvalidInterfaceException
1379
-     */
1380
-    private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1381
-    {
1382
-        // bare minimum critical details include first name, last name, email address
1383
-        $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1384
-        // add address info to critical details?
1385
-        if (apply_filters(
1386
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1387
-            false
1388
-        )) {
1389
-            $address_details = array(
1390
-                'ATT_address',
1391
-                'ATT_address2',
1392
-                'ATT_city',
1393
-                'STA_ID',
1394
-                'CNT_ISO',
1395
-                'ATT_zip',
1396
-                'ATT_phone',
1397
-            );
1398
-            $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1399
-        }
1400
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
1401
-            if (! isset($attendee_data[ $critical_attendee_detail ])
1402
-                || empty($attendee_data[ $critical_attendee_detail ])
1403
-            ) {
1404
-                $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1405
-                    $critical_attendee_detail
1406
-                );
1407
-            }
1408
-        }
1409
-        return $attendee_data;
1410
-    }
1411
-
1412
-
1413
-    /**
1414
-     *    update_reg_step
1415
-     *    this is the final step after a user  revisits the site to edit their attendee information
1416
-     *    this gets called AFTER the process_reg_step() method above
1417
-     *
1418
-     * @return bool
1419
-     * @throws EE_Error
1420
-     * @throws InvalidArgumentException
1421
-     * @throws ReflectionException
1422
-     * @throws RuntimeException
1423
-     * @throws InvalidDataTypeException
1424
-     * @throws InvalidInterfaceException
1425
-     */
1426
-    public function update_reg_step()
1427
-    {
1428
-        // save everything
1429
-        if ($this->process_reg_step()) {
1430
-            $this->checkout->redirect = true;
1431
-            $this->checkout->redirect_url = add_query_arg(
1432
-                array(
1433
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
1434
-                    'revisit'        => true,
1435
-                ),
1436
-                $this->checkout->thank_you_page_url
1437
-            );
1438
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1439
-            return true;
1440
-        }
1441
-        return false;
1442
-    }
1222
+		$answer_cache_id = $this->checkout->reg_url_link
1223
+			? $form_input . '-' . $registration->reg_url_link()
1224
+			: $form_input;
1225
+		$answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ])
1226
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer;
1227
+		// rename form_inputs if they are EE_Attendee properties
1228
+		switch ((string) $form_input) {
1229
+			case 'state':
1230
+			case 'STA_ID':
1231
+				$attendee_property = true;
1232
+				$form_input = 'STA_ID';
1233
+				break;
1234
+
1235
+			case 'country':
1236
+			case 'CNT_ISO':
1237
+				$attendee_property = true;
1238
+				$form_input = 'CNT_ISO';
1239
+				break;
1240
+
1241
+			default:
1242
+				$ATT_input = 'ATT_' . $form_input;
1243
+				// EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1244
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1245
+				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1246
+		}
1247
+		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1248
+		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1249
+		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1250
+		// if this form input has a corresponding attendee property
1251
+		if ($attendee_property) {
1252
+			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1253
+			if ($answer_is_obj) {
1254
+				// and delete the corresponding answer since we won't be storing this data in that object
1255
+				$registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer');
1256
+				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1257
+			}
1258
+			return true;
1259
+		}
1260
+		if ($answer_is_obj) {
1261
+			// save this data to the answer object
1262
+			$this->_registration_answers[ $answer_cache_id ]->set_value($input_value);
1263
+			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1264
+			return $result !== false;
1265
+		}
1266
+		foreach ($this->_registration_answers as $answer) {
1267
+			if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1268
+				$answer->set_value($input_value);
1269
+				$result = $answer->save();
1270
+				return $result !== false;
1271
+			}
1272
+		}
1273
+		return false;
1274
+	}
1275
+
1276
+
1277
+	/**
1278
+	 *    _verify_critical_attendee_details_are_set
1279
+	 *
1280
+	 * @param string $form_input
1281
+	 * @param string $input_value
1282
+	 * @return boolean
1283
+	 */
1284
+	private function _verify_critical_attendee_details_are_set_and_validate_email(
1285
+		$form_input = '',
1286
+		$input_value = ''
1287
+	) {
1288
+		if (empty($input_value)) {
1289
+			// if the form input isn't marked as being required, then just return
1290
+			if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) {
1291
+				return true;
1292
+			}
1293
+			switch ($form_input) {
1294
+				case 'fname':
1295
+					EE_Error::add_error(
1296
+						esc_html__('First Name is a required value.', 'event_espresso'),
1297
+						__FILE__,
1298
+						__FUNCTION__,
1299
+						__LINE__
1300
+					);
1301
+					return false;
1302
+					break;
1303
+				case 'lname':
1304
+					EE_Error::add_error(
1305
+						esc_html__('Last Name is a required value.', 'event_espresso'),
1306
+						__FILE__,
1307
+						__FUNCTION__,
1308
+						__LINE__
1309
+					);
1310
+					return false;
1311
+					break;
1312
+				case 'email':
1313
+					EE_Error::add_error(
1314
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
1315
+						__FILE__,
1316
+						__FUNCTION__,
1317
+						__LINE__
1318
+					);
1319
+					return false;
1320
+					break;
1321
+			}
1322
+		}
1323
+		return true;
1324
+	}
1325
+
1326
+
1327
+	/**
1328
+	 *    _associate_attendee_with_registration
1329
+	 *
1330
+	 * @param EE_Registration $registration
1331
+	 * @param EE_Attendee     $attendee
1332
+	 * @return void
1333
+	 * @throws EE_Error
1334
+	 * @throws InvalidArgumentException
1335
+	 * @throws ReflectionException
1336
+	 * @throws RuntimeException
1337
+	 * @throws InvalidDataTypeException
1338
+	 * @throws InvalidInterfaceException
1339
+	 */
1340
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1341
+	{
1342
+		// add relation to attendee
1343
+		$registration->_add_relation_to($attendee, 'Attendee');
1344
+		$registration->set_attendee_id($attendee->ID());
1345
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1346
+	}
1347
+
1348
+
1349
+	/**
1350
+	 *    _associate_registration_with_transaction
1351
+	 *
1352
+	 * @param EE_Registration $registration
1353
+	 * @return void
1354
+	 * @throws EE_Error
1355
+	 * @throws InvalidArgumentException
1356
+	 * @throws ReflectionException
1357
+	 * @throws InvalidDataTypeException
1358
+	 * @throws InvalidInterfaceException
1359
+	 */
1360
+	private function _associate_registration_with_transaction(EE_Registration $registration)
1361
+	{
1362
+		// add relation to registration
1363
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1364
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1365
+	}
1366
+
1367
+
1368
+	/**
1369
+	 *    _copy_critical_attendee_details_from_primary_registrant
1370
+	 *    ensures that all attendees at least have data for first name, last name, and email address
1371
+	 *
1372
+	 * @param array $attendee_data
1373
+	 * @return array
1374
+	 * @throws EE_Error
1375
+	 * @throws InvalidArgumentException
1376
+	 * @throws ReflectionException
1377
+	 * @throws InvalidDataTypeException
1378
+	 * @throws InvalidInterfaceException
1379
+	 */
1380
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1381
+	{
1382
+		// bare minimum critical details include first name, last name, email address
1383
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1384
+		// add address info to critical details?
1385
+		if (apply_filters(
1386
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1387
+			false
1388
+		)) {
1389
+			$address_details = array(
1390
+				'ATT_address',
1391
+				'ATT_address2',
1392
+				'ATT_city',
1393
+				'STA_ID',
1394
+				'CNT_ISO',
1395
+				'ATT_zip',
1396
+				'ATT_phone',
1397
+			);
1398
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1399
+		}
1400
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1401
+			if (! isset($attendee_data[ $critical_attendee_detail ])
1402
+				|| empty($attendee_data[ $critical_attendee_detail ])
1403
+			) {
1404
+				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1405
+					$critical_attendee_detail
1406
+				);
1407
+			}
1408
+		}
1409
+		return $attendee_data;
1410
+	}
1411
+
1412
+
1413
+	/**
1414
+	 *    update_reg_step
1415
+	 *    this is the final step after a user  revisits the site to edit their attendee information
1416
+	 *    this gets called AFTER the process_reg_step() method above
1417
+	 *
1418
+	 * @return bool
1419
+	 * @throws EE_Error
1420
+	 * @throws InvalidArgumentException
1421
+	 * @throws ReflectionException
1422
+	 * @throws RuntimeException
1423
+	 * @throws InvalidDataTypeException
1424
+	 * @throws InvalidInterfaceException
1425
+	 */
1426
+	public function update_reg_step()
1427
+	{
1428
+		// save everything
1429
+		if ($this->process_reg_step()) {
1430
+			$this->checkout->redirect = true;
1431
+			$this->checkout->redirect_url = add_query_arg(
1432
+				array(
1433
+					'e_reg_url_link' => $this->checkout->reg_url_link,
1434
+					'revisit'        => true,
1435
+				),
1436
+				$this->checkout->thank_you_page_url
1437
+			);
1438
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1439
+			return true;
1440
+		}
1441
+		return false;
1442
+	}
1443 1443
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.2.rc.037');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.2.rc.037');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.