Completed
Branch BUG-10375-migrations-not-repor... (1e9646)
by
unknown
62:53 queued 49:42
created
core/db_models/fields/EE_Primary_Key_String_Field.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,22 +4,22 @@
 block discarded – undo
4 4
 class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base
5 5
 {
6 6
 
7
-    public function __construct($table_column, $nicename)
8
-    {
9
-        parent::__construct($table_column, $nicename, null);
10
-    }
7
+	public function __construct($table_column, $nicename)
8
+	{
9
+		parent::__construct($table_column, $nicename, null);
10
+	}
11 11
 
12
-    /**
13
-     * removes all tags when setting
14
-     *
15
-     * @param string $value_inputted_for_field_on_model_object
16
-     * @return string
17
-     */
18
-    function prepare_for_set($value_inputted_for_field_on_model_object)
19
-    {
20
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
21
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
22
-        }
23
-        return wp_strip_all_tags($value_inputted_for_field_on_model_object);
24
-    }
12
+	/**
13
+	 * removes all tags when setting
14
+	 *
15
+	 * @param string $value_inputted_for_field_on_model_object
16
+	 * @return string
17
+	 */
18
+	function prepare_for_set($value_inputted_for_field_on_model_object)
19
+	{
20
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
21
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
22
+		}
23
+		return wp_strip_all_tags($value_inputted_for_field_on_model_object);
24
+	}
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -4,6 +4,9 @@
 block discarded – undo
4 4
 class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base
5 5
 {
6 6
 
7
+    /**
8
+     * @param string $table_column
9
+     */
7 10
     public function __construct($table_column, $nicename)
8 11
     {
9 12
         parent::__construct($table_column, $nicename, null);
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_String_Field.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base
5 5
 {
6 6
 
7
-    /**
8
-     * removes all tags when setting
9
-     *
10
-     * @param string $value_inputted_for_field_on_model_object
11
-     * @return string
12
-     */
13
-    function prepare_for_set($value_inputted_for_field_on_model_object)
14
-    {
15
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
16
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
17
-        }
18
-        return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object));
19
-    }
7
+	/**
8
+	 * removes all tags when setting
9
+	 *
10
+	 * @param string $value_inputted_for_field_on_model_object
11
+	 * @return string
12
+	 */
13
+	function prepare_for_set($value_inputted_for_field_on_model_object)
14
+	{
15
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
16
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
17
+		}
18
+		return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object));
19
+	}
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_All_Caps_Text_Field.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  */
7 7
 class EE_All_Caps_Text_Field extends EE_Text_Field_Base
8 8
 {
9
-    /**
10
-     * makes it all upper case, and key-like
11
-     *
12
-     * @param string $value_inputted_for_field_on_model_object
13
-     * @return string
14
-     */
15
-    function prepare_for_set($value_inputted_for_field_on_model_object)
16
-    {
17
-        return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
-    }
9
+	/**
10
+	 * makes it all upper case, and key-like
11
+	 *
12
+	 * @param string $value_inputted_for_field_on_model_object
13
+	 * @return string
14
+	 */
15
+	function prepare_for_set($value_inputted_for_field_on_model_object)
16
+	{
17
+		return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
+	}
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +1704 added lines, -1704 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\exceptions\InvalidEntityException;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,1709 +17,1709 @@  discard block
 block discarded – undo
17 17
 class EED_Single_Page_Checkout extends EED_Module
18 18
 {
19 19
 
20
-    /**
21
-     * $_initialized - has the SPCO controller already been initialized ?
22
-     *
23
-     * @access private
24
-     * @var bool $_initialized
25
-     */
26
-    private static $_initialized = false;
27
-
28
-
29
-    /**
30
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
31
-     *
32
-     * @access private
33
-     * @var bool $_valid_checkout
34
-     */
35
-    private static $_checkout_verified = true;
36
-
37
-    /**
38
-     *    $_reg_steps_array - holds initial array of reg steps
39
-     *
40
-     * @access private
41
-     * @var array $_reg_steps_array
42
-     */
43
-    private static $_reg_steps_array = array();
44
-
45
-    /**
46
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
47
-     *
48
-     * @access public
49
-     * @var EE_Checkout $checkout
50
-     */
51
-    public $checkout;
52
-
53
-
54
-
55
-    /**
56
-     * @return EED_Single_Page_Checkout
57
-     */
58
-    public static function instance()
59
-    {
60
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
61
-        return parent::get_instance(__CLASS__);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * @return EE_CART
68
-     */
69
-    public function cart()
70
-    {
71
-        return $this->checkout->cart;
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * @return EE_Transaction
78
-     */
79
-    public function transaction()
80
-    {
81
-        return $this->checkout->transaction;
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     *    set_hooks - for hooking into EE Core, other modules, etc
88
-     *
89
-     * @access    public
90
-     * @return    void
91
-     * @throws \EE_Error
92
-     */
93
-    public static function set_hooks()
94
-    {
95
-        EED_Single_Page_Checkout::set_definitions();
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
102
-     *
103
-     * @access    public
104
-     * @return    void
105
-     * @throws \EE_Error
106
-     */
107
-    public static function set_hooks_admin()
108
-    {
109
-        EED_Single_Page_Checkout::set_definitions();
110
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
111
-            // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called
112
-            add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1);
113
-            return;
114
-        }
115
-        // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response
116
-        ob_start();
117
-        EED_Single_Page_Checkout::load_request_handler();
118
-        EED_Single_Page_Checkout::load_reg_steps();
119
-        // set ajax hooks
120
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
121
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
122
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
123
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
124
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
125
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     *    process ajax request
132
-     *
133
-     * @param string $ajax_action
134
-     * @throws \EE_Error
135
-     */
136
-    public static function process_ajax_request($ajax_action)
137
-    {
138
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
139
-        EED_Single_Page_Checkout::instance()->_initialize();
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     *    ajax display registration step
146
-     *
147
-     * @throws \EE_Error
148
-     */
149
-    public static function display_reg_step()
150
-    {
151
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
152
-    }
153
-
154
-
155
-
156
-    /**
157
-     *    ajax process registration step
158
-     *
159
-     * @throws \EE_Error
160
-     */
161
-    public static function process_reg_step()
162
-    {
163
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     *    ajax process registration step
170
-     *
171
-     * @throws \EE_Error
172
-     */
173
-    public static function update_reg_step()
174
-    {
175
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
176
-    }
177
-
178
-
179
-
180
-    /**
181
-     *   update_checkout
182
-     *
183
-     * @access public
184
-     * @return void
185
-     * @throws \EE_Error
186
-     */
187
-    public static function update_checkout()
188
-    {
189
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     *    load_request_handler
196
-     *
197
-     * @access    public
198
-     * @return    void
199
-     */
200
-    public static function load_request_handler()
201
-    {
202
-        // load core Request_Handler class
203
-        if ( ! isset(EE_Registry::instance()->REQ)) {
204
-            EE_Registry::instance()->load_core('Request_Handler');
205
-        }
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     *    set_definitions
212
-     *
213
-     * @access    public
214
-     * @return    void
215
-     * @throws \EE_Error
216
-     */
217
-    public static function set_definitions()
218
-    {
219
-        define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS);
220
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
221
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
222
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
223
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
224
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
225
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
226
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
227
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
228
-            __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
229
-                'event_espresso'),
230
-            '<h4 class="important-notice">',
231
-            '</h4>',
232
-            '<br />',
233
-            '<p>',
234
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
235
-            '">',
236
-            '</a>',
237
-            '</p>'
238
-        );
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * load_reg_steps
245
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
246
-     *
247
-     * @access    private
248
-     * @throws EE_Error
249
-     * @return void
250
-     */
251
-    public static function load_reg_steps()
252
-    {
253
-        static $reg_steps_loaded = false;
254
-        if ($reg_steps_loaded) {
255
-            return;
256
-        }
257
-        // filter list of reg_steps
258
-        $reg_steps_to_load = (array)apply_filters(
259
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
260
-            EED_Single_Page_Checkout::get_reg_steps()
261
-        );
262
-        // sort by key (order)
263
-        ksort($reg_steps_to_load);
264
-        // loop through folders
265
-        foreach ($reg_steps_to_load as $order => $reg_step) {
266
-            // we need a
267
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
268
-                // copy over to the reg_steps_array
269
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
270
-                // register custom key route for each reg step
271
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
272
-                EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
273
-                // add AJAX or other hooks
274
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
275
-                    // setup autoloaders if necessary
276
-                    if ( ! class_exists($reg_step['class_name'])) {
277
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true);
278
-                    }
279
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
280
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
281
-                    }
282
-                }
283
-            }
284
-        }
285
-        $reg_steps_loaded = true;
286
-    }
287
-
288
-
289
-
290
-    /**
291
-     *    get_reg_steps
292
-     *
293
-     * @access    public
294
-     * @return    array
295
-     */
296
-    public static function get_reg_steps()
297
-    {
298
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
299
-        if (empty($reg_steps)) {
300
-            $reg_steps = array(
301
-                10  => array(
302
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
303
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
304
-                    'slug'       => 'attendee_information',
305
-                    'has_hooks'  => false,
306
-                ),
307
-                20  => array(
308
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
309
-                    'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
310
-                    'slug'       => 'registration_confirmation',
311
-                    'has_hooks'  => false,
312
-                ),
313
-                30  => array(
314
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
315
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
316
-                    'slug'       => 'payment_options',
317
-                    'has_hooks'  => true,
318
-                ),
319
-                999 => array(
320
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
321
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
322
-                    'slug'       => 'finalize_registration',
323
-                    'has_hooks'  => false,
324
-                ),
325
-            );
326
-        }
327
-        return $reg_steps;
328
-    }
329
-
330
-
331
-
332
-    /**
333
-     *    registration_checkout_for_admin
334
-     *
335
-     * @access    public
336
-     * @return    string
337
-     * @throws \EE_Error
338
-     */
339
-    public static function registration_checkout_for_admin()
340
-    {
341
-        EED_Single_Page_Checkout::load_reg_steps();
342
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
343
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
344
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
345
-        EED_Single_Page_Checkout::instance()->_initialize();
346
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
347
-        return EE_Registry::instance()->REQ->get_output();
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * process_registration_from_admin
354
-     *
355
-     * @access public
356
-     * @return \EE_Transaction
357
-     * @throws \EE_Error
358
-     */
359
-    public static function process_registration_from_admin()
360
-    {
361
-        EED_Single_Page_Checkout::load_reg_steps();
362
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
363
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
364
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
365
-        EED_Single_Page_Checkout::instance()->_initialize();
366
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
367
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
368
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
369
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
370
-                if ($final_reg_step->process_reg_step()) {
371
-                    $final_reg_step->set_completed();
372
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
373
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
374
-                }
375
-            }
376
-        }
377
-        return null;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     *    run
384
-     *
385
-     * @access    public
386
-     * @param WP_Query $WP_Query
387
-     * @return    void
388
-     * @throws \EE_Error
389
-     */
390
-    public function run($WP_Query)
391
-    {
392
-        if (
393
-            $WP_Query instanceof WP_Query
394
-            && $WP_Query->is_main_query()
395
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
396
-            && $this->_is_reg_checkout()
397
-        ) {
398
-            $this->_initialize();
399
-        }
400
-    }
401
-
402
-
403
-
404
-    /**
405
-     * determines whether current url matches reg page url
406
-     *
407
-     * @return bool
408
-     */
409
-    protected function _is_reg_checkout()
410
-    {
411
-        // get current permalink for reg page without any extra query args
412
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
413
-        // get request URI for current request, but without the scheme or host
414
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
415
-        $current_request_uri = html_entity_decode($current_request_uri);
416
-        // get array of query args from the current request URI
417
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
418
-        // grab page id if it is set
419
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
420
-        // and remove the page id from the query args (we will re-add it later)
421
-        unset($query_args['page_id']);
422
-        // now strip all query args from current request URI
423
-        $current_request_uri = remove_query_arg(array_flip($query_args), $current_request_uri);
424
-        // and re-add the page id if it was set
425
-        if ($page_id) {
426
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
427
-        }
428
-        // remove slashes and ?
429
-        $current_request_uri = trim($current_request_uri, '?/');
430
-        // is current request URI part of the known full reg page URL ?
431
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
432
-    }
433
-
434
-
435
-
436
-    /**
437
-     *    run
438
-     *
439
-     * @access    public
440
-     * @param WP_Query $WP_Query
441
-     * @return    void
442
-     * @throws \EE_Error
443
-     */
444
-    public static function init($WP_Query)
445
-    {
446
-        EED_Single_Page_Checkout::instance()->run($WP_Query);
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     *    _initialize - initial module setup
453
-     *
454
-     * @access    private
455
-     * @throws EE_Error
456
-     * @return    void
457
-     */
458
-    private function _initialize()
459
-    {
460
-        // ensure SPCO doesn't run twice
461
-        if (EED_Single_Page_Checkout::$_initialized) {
462
-            return;
463
-        }
464
-        try {
465
-            $this->_verify_session();
466
-            // setup the EE_Checkout object
467
-            $this->checkout = $this->_initialize_checkout();
468
-            // filter checkout
469
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
470
-            // get the $_GET
471
-            $this->_get_request_vars();
472
-            if ($this->_block_bots()) {
473
-                return;
474
-            }
475
-            // filter continue_reg
476
-            $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout);
477
-            // load the reg steps array
478
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
479
-                EED_Single_Page_Checkout::$_initialized = true;
480
-                return;
481
-            }
482
-            // set the current step
483
-            $this->checkout->set_current_step($this->checkout->step);
484
-            // and the next step
485
-            $this->checkout->set_next_step();
486
-            // verify that everything has been setup correctly
487
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
488
-                EED_Single_Page_Checkout::$_initialized = true;
489
-                return;
490
-            }
491
-            // lock the transaction
492
-            $this->checkout->transaction->lock();
493
-            // make sure all of our cached objects are added to their respective model entity mappers
494
-            $this->checkout->refresh_all_entities();
495
-            // set amount owing
496
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
497
-            // initialize each reg step, which gives them the chance to potentially alter the process
498
-            $this->_initialize_reg_steps();
499
-            // DEBUG LOG
500
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
501
-            // get reg form
502
-            if( ! $this->_check_form_submission()) {
503
-                EED_Single_Page_Checkout::$_initialized = true;
504
-                return;
505
-            }
506
-            // checkout the action!!!
507
-            $this->_process_form_action();
508
-            // add some style and make it dance
509
-            $this->add_styles_and_scripts();
510
-            // kk... SPCO has successfully run
511
-            EED_Single_Page_Checkout::$_initialized = true;
512
-            // set no cache headers and constants
513
-            EE_System::do_not_cache();
514
-            // add anchor
515
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
516
-            // remove transaction lock
517
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
518
-        } catch (Exception $e) {
519
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
520
-        }
521
-    }
522
-
523
-
524
-
525
-    /**
526
-     *    _verify_session
527
-     * checks that the session is valid and not expired
528
-     *
529
-     * @access    private
530
-     * @throws EE_Error
531
-     */
532
-    private function _verify_session()
533
-    {
534
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
535
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
536
-        }
537
-        // is session still valid ?
538
-        if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') {
539
-            $this->checkout = new EE_Checkout();
540
-            EE_Registry::instance()->SSN->reset_cart();
541
-            EE_Registry::instance()->SSN->reset_checkout();
542
-            EE_Registry::instance()->SSN->reset_transaction();
543
-            EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__,
544
-                __FUNCTION__, __LINE__);
545
-            EE_Registry::instance()->SSN->reset_expired();
546
-        }
547
-    }
548
-
549
-
550
-
551
-    /**
552
-     *    _initialize_checkout
553
-     * loads and instantiates EE_Checkout
554
-     *
555
-     * @access    private
556
-     * @throws EE_Error
557
-     * @return EE_Checkout
558
-     */
559
-    private function _initialize_checkout()
560
-    {
561
-        // look in session for existing checkout
562
-        /** @type EE_Checkout $checkout */
563
-        $checkout = EE_Registry::instance()->SSN->checkout();
564
-        // verify
565
-        if ( ! $checkout instanceof EE_Checkout) {
566
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
567
-            $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false);
568
-        } else {
569
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
570
-                $this->unlock_transaction();
571
-                wp_safe_redirect($checkout->redirect_url);
572
-                exit();
573
-            }
574
-        }
575
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
576
-        // verify again
577
-        if ( ! $checkout instanceof EE_Checkout) {
578
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
579
-        }
580
-        // reset anything that needs a clean slate for each request
581
-        $checkout->reset_for_current_request();
582
-        return $checkout;
583
-    }
584
-
585
-
586
-
587
-    /**
588
-     *    _get_request_vars
589
-     *
590
-     * @access    private
591
-     * @return    void
592
-     * @throws \EE_Error
593
-     */
594
-    private function _get_request_vars()
595
-    {
596
-        // load classes
597
-        EED_Single_Page_Checkout::load_request_handler();
598
-        //make sure this request is marked as belonging to EE
599
-        EE_Registry::instance()->REQ->set_espresso_page(true);
600
-        // which step is being requested ?
601
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
602
-        // which step is being edited ?
603
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
604
-        // and what we're doing on the current step
605
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
606
-        // timestamp
607
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
608
-        // returning to edit ?
609
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
610
-        // or some other kind of revisit ?
611
-        $this->checkout->revisit = filter_var(
612
-            EE_Registry::instance()->REQ->get('revisit', false),
613
-            FILTER_VALIDATE_BOOLEAN
614
-        );
615
-        // and whether or not to generate a reg form for this request
616
-        $this->checkout->generate_reg_form = filter_var(
617
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
618
-            FILTER_VALIDATE_BOOLEAN
619
-        );
620
-        // and whether or not to process a reg form submission for this request
621
-        $this->checkout->process_form_submission = filter_var(
622
-            EE_Registry::instance()->REQ->get(
623
-                'process_form_submission',
624
-                $this->checkout->action === 'process_reg_step'
625
-            ),
626
-            FILTER_VALIDATE_BOOLEAN
627
-        );
628
-        $this->checkout->process_form_submission = filter_var(
629
-            $this->checkout->action !== 'display_spco_reg_step'
630
-                ? $this->checkout->process_form_submission
631
-                : false,
632
-            FILTER_VALIDATE_BOOLEAN
633
-        );
634
-        // $this->_display_request_vars();
635
-    }
636
-
637
-
638
-
639
-    /**
640
-     *  _display_request_vars
641
-     *
642
-     * @access    protected
643
-     * @return    void
644
-     */
645
-    protected function _display_request_vars()
646
-    {
647
-        if ( ! WP_DEBUG) {
648
-            return;
649
-        }
650
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
651
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
652
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
653
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
654
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
655
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
656
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
657
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
658
-    }
659
-
660
-
661
-
662
-    /**
663
-     * _block_bots
664
-     * checks that the incoming request has either of the following set:
665
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
666
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
667
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
668
-     * then where you coming from man?
669
-     *
670
-     * @return boolean
671
-     */
672
-    private function _block_bots()
673
-    {
674
-        $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
675
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
676
-            return true;
677
-        }
678
-        return false;
679
-    }
680
-
681
-
682
-
683
-    /**
684
-     *    _get_first_step
685
-     *  gets slug for first step in $_reg_steps_array
686
-     *
687
-     * @access    private
688
-     * @throws EE_Error
689
-     * @return    string
690
-     */
691
-    private function _get_first_step()
692
-    {
693
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
694
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
695
-    }
696
-
697
-
698
-
699
-    /**
700
-     *    _load_and_instantiate_reg_steps
701
-     *  instantiates each reg step based on the loaded reg_steps array
702
-     *
703
-     * @access    private
704
-     * @throws EE_Error
705
-     * @return    bool
706
-     */
707
-    private function _load_and_instantiate_reg_steps()
708
-    {
709
-        // have reg_steps already been instantiated ?
710
-        if (
711
-            empty($this->checkout->reg_steps)
712
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
713
-        ) {
714
-            // if not, then loop through raw reg steps array
715
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
716
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
717
-                    return false;
718
-                }
719
-            }
720
-            EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
721
-            EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
722
-            // skip the registration_confirmation page ?
723
-            if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
724
-                // just remove it from the reg steps array
725
-                $this->checkout->remove_reg_step('registration_confirmation', false);
726
-            } else if (
727
-                isset($this->checkout->reg_steps['registration_confirmation'])
728
-                && EE_Registry::instance()->CFG->registration->reg_confirmation_last
729
-            ) {
730
-                // set the order to something big like 100
731
-                $this->checkout->set_reg_step_order('registration_confirmation', 100);
732
-            }
733
-            // filter the array for good luck
734
-            $this->checkout->reg_steps = apply_filters(
735
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
736
-                $this->checkout->reg_steps
737
-            );
738
-            // finally re-sort based on the reg step class order properties
739
-            $this->checkout->sort_reg_steps();
740
-        } else {
741
-            foreach ($this->checkout->reg_steps as $reg_step) {
742
-                // set all current step stati to FALSE
743
-                $reg_step->set_is_current_step(false);
744
-            }
745
-        }
746
-        if (empty($this->checkout->reg_steps)) {
747
-            EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
748
-            return false;
749
-        }
750
-        // make reg step details available to JS
751
-        $this->checkout->set_reg_step_JSON_info();
752
-        return true;
753
-    }
754
-
755
-
756
-
757
-    /**
758
-     *     _load_and_instantiate_reg_step
759
-     *
760
-     * @access    private
761
-     * @param array $reg_step
762
-     * @param int   $order
763
-     * @return bool
764
-     */
765
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
766
-    {
767
-        // we need a file_path, class_name, and slug to add a reg step
768
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
769
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
770
-            if (
771
-                $this->checkout->reg_url_link
772
-                && $this->checkout->step !== $reg_step['slug']
773
-                && $reg_step['slug'] !== 'finalize_registration'
774
-            ) {
775
-                return true;
776
-            }
777
-            // instantiate step class using file path and class name
778
-            $reg_step_obj = EE_Registry::instance()->load_file(
779
-                $reg_step['file_path'],
780
-                $reg_step['class_name'],
781
-                'class',
782
-                $this->checkout,
783
-                false
784
-            );
785
-            // did we gets the goods ?
786
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
787
-                // set reg step order based on config
788
-                $reg_step_obj->set_order($order);
789
-                // add instantiated reg step object to the master reg steps array
790
-                $this->checkout->add_reg_step($reg_step_obj);
791
-            } else {
792
-                EE_Error::add_error(
793
-                    __('The current step could not be set.', 'event_espresso'),
794
-                    __FILE__, __FUNCTION__, __LINE__
795
-                );
796
-                return false;
797
-            }
798
-        } else {
799
-            if (WP_DEBUG) {
800
-                EE_Error::add_error(
801
-                    sprintf(
802
-                        __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'),
803
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
804
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
805
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
806
-                        '<ul>',
807
-                        '<li>',
808
-                        '</li>',
809
-                        '</ul>'
810
-                    ),
811
-                    __FILE__, __FUNCTION__, __LINE__
812
-                );
813
-            }
814
-            return false;
815
-        }
816
-        return true;
817
-    }
818
-
819
-
820
-
821
-    /**
822
-     * _verify_transaction_and_get_registrations
823
-     *
824
-     * @access private
825
-     * @return bool
826
-     */
827
-    private function _verify_transaction_and_get_registrations()
828
-    {
829
-        // was there already a valid transaction in the checkout from the session ?
830
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
831
-            // get transaction from db or session
832
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
833
-                ? $this->_get_transaction_and_cart_for_previous_visit()
834
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
835
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
836
-                EE_Error::add_error(
837
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
838
-                        'event_espresso'),
839
-                    __FILE__, __FUNCTION__, __LINE__
840
-                );
841
-                $this->checkout->transaction = EE_Transaction::new_instance();
842
-                // add some style and make it dance
843
-                $this->add_styles_and_scripts();
844
-                EED_Single_Page_Checkout::$_initialized = true;
845
-                return false;
846
-            }
847
-            // and the registrations for the transaction
848
-            $this->_get_registrations($this->checkout->transaction);
849
-        }
850
-        return true;
851
-    }
852
-
853
-
854
-
855
-    /**
856
-     * _get_transaction_and_cart_for_previous_visit
857
-     *
858
-     * @access private
859
-     * @return mixed EE_Transaction|NULL
860
-     */
861
-    private function _get_transaction_and_cart_for_previous_visit()
862
-    {
863
-        /** @var $TXN_model EEM_Transaction */
864
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
865
-        // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db
866
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
867
-        // verify transaction
868
-        if ($transaction instanceof EE_Transaction) {
869
-            // and get the cart that was used for that transaction
870
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
871
-            return $transaction;
872
-        } else {
873
-            EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
874
-            return null;
875
-        }
876
-    }
877
-
878
-
879
-
880
-    /**
881
-     * _get_cart_for_transaction
882
-     *
883
-     * @access private
884
-     * @param EE_Transaction $transaction
885
-     * @return EE_Cart
886
-     */
887
-    private function _get_cart_for_transaction($transaction)
888
-    {
889
-        return $this->checkout->get_cart_for_transaction($transaction);
890
-    }
891
-
892
-
893
-
894
-    /**
895
-     * get_cart_for_transaction
896
-     *
897
-     * @access public
898
-     * @param EE_Transaction $transaction
899
-     * @return EE_Cart
900
-     */
901
-    public function get_cart_for_transaction(EE_Transaction $transaction)
902
-    {
903
-        return $this->checkout->get_cart_for_transaction($transaction);
904
-    }
905
-
906
-
907
-
908
-    /**
909
-     * _get_transaction_and_cart_for_current_session
910
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
911
-     *
912
-     * @access private
913
-     * @return EE_Transaction
914
-     * @throws \EE_Error
915
-     */
916
-    private function _get_cart_for_current_session_and_setup_new_transaction()
917
-    {
918
-        //  if there's no transaction, then this is the FIRST visit to SPCO
919
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
920
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
921
-        // and then create a new transaction
922
-        $transaction = $this->_initialize_transaction();
923
-        // verify transaction
924
-        if ($transaction instanceof EE_Transaction) {
925
-            // save it so that we have an ID for other objects to use
926
-            $transaction->save();
927
-            // and save TXN data to the cart
928
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
929
-        } else {
930
-            EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
931
-        }
932
-        return $transaction;
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
939
-     *
940
-     * @access private
941
-     * @return mixed EE_Transaction|NULL
942
-     */
943
-    private function _initialize_transaction()
944
-    {
945
-        try {
946
-            // ensure cart totals have been calculated
947
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
948
-            // grab the cart grand total
949
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
950
-            // create new TXN
951
-            $transaction = EE_Transaction::new_instance(
952
-                array(
953
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
954
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
955
-                    'TXN_paid'      => 0,
956
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
957
-                )
958
-            );
959
-            // save it so that we have an ID for other objects to use
960
-            $transaction->save();
961
-            // set cron job for following up on TXNs after their session has expired
962
-            EE_Cron_Tasks::schedule_expired_transaction_check(
963
-                EE_Registry::instance()->SSN->expiration() + 1,
964
-                $transaction->ID()
965
-            );
966
-            return $transaction;
967
-        } catch (Exception $e) {
968
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
969
-        }
970
-        return null;
971
-    }
972
-
973
-
974
-
975
-    /**
976
-     * _get_registrations
977
-     *
978
-     * @access private
979
-     * @param EE_Transaction $transaction
980
-     * @return void
981
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
982
-     * @throws \EE_Error
983
-     */
984
-    private function _get_registrations(EE_Transaction $transaction)
985
-    {
986
-        // first step: grab the registrants  { : o
987
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
988
-        // verify registrations have been set
989
-        if (empty($registrations)) {
990
-            // if no cached registrations, then check the db
991
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
992
-            // still nothing ? well as long as this isn't a revisit
993
-            if (empty($registrations) && ! $this->checkout->revisit) {
994
-                // generate new registrations from scratch
995
-                $registrations = $this->_initialize_registrations($transaction);
996
-            }
997
-        }
998
-        // sort by their original registration order
999
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1000
-        // then loop thru the array
1001
-        foreach ($registrations as $registration) {
1002
-            // verify each registration
1003
-            if ($registration instanceof EE_Registration) {
1004
-                // we display all attendee info for the primary registrant
1005
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1006
-                    && $registration->is_primary_registrant()
1007
-                ) {
1008
-                    $this->checkout->primary_revisit = true;
1009
-                    break;
1010
-                } else if ($this->checkout->revisit
1011
-                           && $this->checkout->reg_url_link !== $registration->reg_url_link()
1012
-                ) {
1013
-                    // but hide info if it doesn't belong to you
1014
-                    $transaction->clear_cache('Registration', $registration->ID());
1015
-                }
1016
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1017
-            }
1018
-        }
1019
-    }
1020
-
1021
-
1022
-
1023
-    /**
1024
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1025
-     *
1026
-     * @access private
1027
-     * @param EE_Transaction $transaction
1028
-     * @return    array
1029
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
1030
-     * @throws \EE_Error
1031
-     */
1032
-    private function _initialize_registrations(EE_Transaction $transaction)
1033
-    {
1034
-        $att_nmbr = 0;
1035
-        $registrations = array();
1036
-        if ($transaction instanceof EE_Transaction) {
1037
-            /** @type EE_Registration_Processor $registration_processor */
1038
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1039
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1040
-            // now let's add the cart items to the $transaction
1041
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1042
-                //do the following for each ticket of this type they selected
1043
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1044
-                    $att_nmbr++;
1045
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1046
-                    $CreateRegistrationCommand = EE_Registry::instance()
1047
-                                                            ->create(
1048
-                                                                'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1049
-                                                                array(
1050
-                                                                    $transaction,
1051
-                                                                    $line_item,
1052
-                                                                    $att_nmbr,
1053
-                                                                    $this->checkout->total_ticket_count,
1054
-                                                                )
1055
-                                                            );
1056
-                    // override capabilities for frontend registrations
1057
-                    if ( ! is_admin()) {
1058
-                        $CreateRegistrationCommand->setCapCheck(
1059
-                            new PublicCapabilities('', 'create_new_registration')
1060
-                        );
1061
-                    }
1062
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1063
-                    if ( ! $registration instanceof EE_Registration) {
1064
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1065
-                    }
1066
-                    $registrations[ $registration->ID() ] = $registration;
1067
-                }
1068
-            }
1069
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1070
-        }
1071
-        return $registrations;
1072
-    }
1073
-
1074
-
1075
-
1076
-    /**
1077
-     * sorts registrations by REG_count
1078
-     *
1079
-     * @access public
1080
-     * @param EE_Registration $reg_A
1081
-     * @param EE_Registration $reg_B
1082
-     * @return int
1083
-     */
1084
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1085
-    {
1086
-        // this shouldn't ever happen within the same TXN, but oh well
1087
-        if ($reg_A->count() === $reg_B->count()) {
1088
-            return 0;
1089
-        }
1090
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1091
-    }
1092
-
1093
-
1094
-
1095
-    /**
1096
-     *    _final_verifications
1097
-     * just makes sure that everything is set up correctly before proceeding
1098
-     *
1099
-     * @access    private
1100
-     * @return    bool
1101
-     * @throws \EE_Error
1102
-     */
1103
-    private function _final_verifications()
1104
-    {
1105
-        // filter checkout
1106
-        $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout);
1107
-        //verify that current step is still set correctly
1108
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1109
-            EE_Error::add_error(
1110
-                __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1111
-                __FILE__,
1112
-                __FUNCTION__,
1113
-                __LINE__
1114
-            );
1115
-            return false;
1116
-        }
1117
-        // if returning to SPCO, then verify that primary registrant is set
1118
-        if ( ! empty($this->checkout->reg_url_link)) {
1119
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1120
-            if ( ! $valid_registrant instanceof EE_Registration) {
1121
-                EE_Error::add_error(
1122
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1123
-                    __FILE__,
1124
-                    __FUNCTION__,
1125
-                    __LINE__
1126
-                );
1127
-                return false;
1128
-            }
1129
-            $valid_registrant = null;
1130
-            foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1131
-                if (
1132
-                    $registration instanceof EE_Registration
1133
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1134
-                ) {
1135
-                    $valid_registrant = $registration;
1136
-                }
1137
-            }
1138
-            if ( ! $valid_registrant instanceof EE_Registration) {
1139
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1140
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1141
-                    // clear the session, mark the checkout as unverified, and try again
1142
-                    EE_Registry::instance()->SSN->clear_session();
1143
-                    EED_Single_Page_Checkout::$_initialized = false;
1144
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1145
-                    $this->_initialize();
1146
-                    EE_Error::reset_notices();
1147
-                    return false;
1148
-                }
1149
-                EE_Error::add_error(
1150
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'),
1151
-                    __FILE__,
1152
-                    __FUNCTION__,
1153
-                    __LINE__
1154
-                );
1155
-                return false;
1156
-            }
1157
-        }
1158
-        // now that things have been kinda sufficiently verified,
1159
-        // let's add the checkout to the session so that's available other systems
1160
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1161
-        return true;
1162
-    }
1163
-
1164
-
1165
-
1166
-    /**
1167
-     *    _initialize_reg_steps
1168
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1169
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1170
-     *
1171
-     * @access    private
1172
-     * @param bool $reinitializing
1173
-     * @throws \EE_Error
1174
-     */
1175
-    private function _initialize_reg_steps($reinitializing = false)
1176
-    {
1177
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1178
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1179
-        foreach ($this->checkout->reg_steps as $reg_step) {
1180
-            if ( ! $reg_step->initialize_reg_step()) {
1181
-                // if not initialized then maybe this step is being removed...
1182
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1183
-                    // if it was the current step, then we need to start over here
1184
-                    $this->_initialize_reg_steps(true);
1185
-                    return;
1186
-                }
1187
-                continue;
1188
-            }
1189
-            // add css and JS for current step
1190
-            $reg_step->enqueue_styles_and_scripts();
1191
-            // i18n
1192
-            $reg_step->translate_js_strings();
1193
-            if ($reg_step->is_current_step()) {
1194
-                // the text that appears on the reg step form submit button
1195
-                $reg_step->set_submit_button_text();
1196
-            }
1197
-        }
1198
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1199
-        do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step);
1200
-    }
1201
-
1202
-
1203
-
1204
-    /**
1205
-     * _check_form_submission
1206
-     *
1207
-     * @access private
1208
-     * @return boolean
1209
-     */
1210
-    private function _check_form_submission()
1211
-    {
1212
-        //does this request require the reg form to be generated ?
1213
-        if ($this->checkout->generate_reg_form) {
1214
-            // ever heard that song by Blue Rodeo ?
1215
-            try {
1216
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1217
-                // if not displaying a form, then check for form submission
1218
-                if (
1219
-                    $this->checkout->process_form_submission
1220
-                    && $this->checkout->current_step->reg_form->was_submitted()
1221
-                ) {
1222
-                    // clear out any old data in case this step is being run again
1223
-                    $this->checkout->current_step->set_valid_data(array());
1224
-                    // capture submitted form data
1225
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1226
-                        apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout)
1227
-                    );
1228
-                    // validate submitted form data
1229
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1230
-                        // thou shall not pass !!!
1231
-                        $this->checkout->continue_reg = false;
1232
-                        // any form validation errors?
1233
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1234
-                            $submission_error_messages = array();
1235
-                            // bad, bad, bad registrant
1236
-                            foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) {
1237
-                                if ($validation_error instanceof EE_Validation_Error) {
1238
-                                    $submission_error_messages[] = sprintf(
1239
-                                        __('%s : %s', 'event_espresso'),
1240
-                                        $validation_error->get_form_section()->html_label_text(),
1241
-                                        $validation_error->getMessage()
1242
-                                    );
1243
-                                }
1244
-                            }
1245
-                            EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1246
-                        }
1247
-                        // well not really... what will happen is we'll just get redirected back to redo the current step
1248
-                        $this->go_to_next_step();
1249
-                        return false;
1250
-                    }
1251
-                }
1252
-            } catch (EE_Error $e) {
1253
-                $e->get_error();
1254
-            }
1255
-        }
1256
-        return true;
1257
-    }
1258
-
1259
-
1260
-
1261
-    /**
1262
-     * _process_action
1263
-     *
1264
-     * @access private
1265
-     * @return void
1266
-     * @throws \EE_Error
1267
-     */
1268
-    private function _process_form_action()
1269
-    {
1270
-        // what cha wanna do?
1271
-        switch ($this->checkout->action) {
1272
-            // AJAX next step reg form
1273
-            case 'display_spco_reg_step' :
1274
-                $this->checkout->redirect = false;
1275
-                if (EE_Registry::instance()->REQ->ajax) {
1276
-                    $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form());
1277
-                }
1278
-                break;
1279
-            default :
1280
-                // meh... do one of those other steps first
1281
-                if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) {
1282
-                    // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1283
-                    do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1284
-                    // call action on current step
1285
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1286
-                        // good registrant, you get to proceed
1287
-                        if (
1288
-                            $this->checkout->current_step->success_message() !== ''
1289
-                            && apply_filters(
1290
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1291
-                                false
1292
-                            )
1293
-                        ) {
1294
-                            EE_Error::add_success(
1295
-                                $this->checkout->current_step->success_message()
1296
-                                . '<br />' . $this->checkout->next_step->_instructions()
1297
-                            );
1298
-                        }
1299
-                        // pack it up, pack it in...
1300
-                        $this->_setup_redirect();
1301
-                    }
1302
-                    // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1303
-                    do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1304
-                } else {
1305
-                    EE_Error::add_error(
1306
-                        sprintf(
1307
-                            __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'),
1308
-                            $this->checkout->action,
1309
-                            $this->checkout->current_step->name()
1310
-                        ),
1311
-                        __FILE__,
1312
-                        __FUNCTION__,
1313
-                        __LINE__
1314
-                    );
1315
-                }
1316
-            // end default
1317
-        }
1318
-        // store our progress so far
1319
-        $this->checkout->stash_transaction_and_checkout();
1320
-        // advance to the next step! If you pass GO, collect $200
1321
-        $this->go_to_next_step();
1322
-    }
1323
-
1324
-
1325
-
1326
-    /**
1327
-     *        add_styles_and_scripts
1328
-     *
1329
-     * @access        public
1330
-     * @return        void
1331
-     */
1332
-    public function add_styles_and_scripts()
1333
-    {
1334
-        // i18n
1335
-        $this->translate_js_strings();
1336
-        if ($this->checkout->admin_request) {
1337
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1338
-        } else {
1339
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1340
-        }
1341
-    }
1342
-
1343
-
1344
-
1345
-    /**
1346
-     *        translate_js_strings
1347
-     *
1348
-     * @access        public
1349
-     * @return        void
1350
-     */
1351
-    public function translate_js_strings()
1352
-    {
1353
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1354
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1355
-        EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1356
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1357
-        EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso');
1358
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso');
1359
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso');
1360
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso');
1361
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1362
-            __('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'),
1363
-            '<br/>',
1364
-            '<br/>'
1365
-        );
1366
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1367
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1368
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1369
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1370
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1371
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1372
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1373
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1374
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1375
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1376
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1377
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1378
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1379
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1380
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1381
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1382
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1383
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1384
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1385
-            __(
1386
-                '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1387
-                'event_espresso'
1388
-            ),
1389
-            '<h4 class="important-notice">',
1390
-            '</h4>',
1391
-            '<br />',
1392
-            '<p>',
1393
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1394
-            '">',
1395
-            '</a>',
1396
-            '</p>'
1397
-        );
1398
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true);
1399
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1400
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1401
-        );
1402
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1403
-            'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1404
-        );
1405
-    }
1406
-
1407
-
1408
-
1409
-    /**
1410
-     *    enqueue_styles_and_scripts
1411
-     *
1412
-     * @access        public
1413
-     * @return        void
1414
-     * @throws \EE_Error
1415
-     */
1416
-    public function enqueue_styles_and_scripts()
1417
-    {
1418
-        // load css
1419
-        wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1420
-        wp_enqueue_style('single_page_checkout');
1421
-        // load JS
1422
-        wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array('jquery'), '1.0.1', true);
1423
-        wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', true);
1424
-        wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true);
1425
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1426
-            $this->checkout->registration_form->enqueue_js();
1427
-        }
1428
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1429
-            $this->checkout->current_step->reg_form->enqueue_js();
1430
-        }
1431
-        wp_enqueue_script('single_page_checkout');
1432
-        /**
1433
-         * global action hook for enqueueing styles and scripts with
1434
-         * spco calls.
1435
-         */
1436
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1437
-        /**
1438
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1439
-         * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1440
-         */
1441
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this);
1442
-    }
1443
-
1444
-
1445
-
1446
-    /**
1447
-     *    display the Registration Single Page Checkout Form
1448
-     *
1449
-     * @access    private
1450
-     * @return    void
1451
-     * @throws \EE_Error
1452
-     */
1453
-    private function _display_spco_reg_form()
1454
-    {
1455
-        // if registering via the admin, just display the reg form for the current step
1456
-        if ($this->checkout->admin_request) {
1457
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1458
-        } else {
1459
-            // add powered by EE msg
1460
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1461
-            $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1
1462
-                ? true
1463
-                : false;
1464
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1465
-            $cookies_not_set_msg = '';
1466
-            if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1467
-                $cookies_not_set_msg = apply_filters(
1468
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1469
-                    sprintf(
1470
-                        __(
1471
-                            '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1472
-                            'event_espresso'
1473
-                        ),
1474
-                        '<div class="ee-attention">',
1475
-                        '</div>',
1476
-                        '<h6 class="important-notice">',
1477
-                        '</h6>',
1478
-                        '<p>',
1479
-                        '</p>',
1480
-                        '<br />',
1481
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1482
-                        '</a>'
1483
-                    )
1484
-                );
1485
-            }
1486
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1487
-                array(
1488
-                    'name'            => 'single-page-checkout',
1489
-                    'html_id'         => 'ee-single-page-checkout-dv',
1490
-                    'layout_strategy' =>
1491
-                        new EE_Template_Layout(
1492
-                            array(
1493
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1494
-                                'template_args'        => array(
1495
-                                    'empty_cart'              => $empty_cart,
1496
-                                    'revisit'                 => $this->checkout->revisit,
1497
-                                    'reg_steps'               => $this->checkout->reg_steps,
1498
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1499
-                                        ? $this->checkout->next_step->slug()
1500
-                                        : '',
1501
-                                    'cancel_page_url'         => $this->checkout->cancel_page_url,
1502
-                                    'empty_msg'               => apply_filters(
1503
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1504
-                                        sprintf(
1505
-                                            __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1506
-                                                'event_espresso'),
1507
-                                            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1508
-                                            '">',
1509
-                                            '</a>'
1510
-                                        )
1511
-                                    ),
1512
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1513
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1514
-                                    'session_expiration'      =>
1515
-                                        date('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)),
1516
-                                ),
1517
-                            )
1518
-                        ),
1519
-                )
1520
-            );
1521
-            // load template and add to output sent that gets filtered into the_content()
1522
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1523
-        }
1524
-    }
1525
-
1526
-
1527
-
1528
-    /**
1529
-     *    add_extra_finalize_registration_inputs
1530
-     *
1531
-     * @access    public
1532
-     * @param $next_step
1533
-     * @internal  param string $label
1534
-     * @return void
1535
-     */
1536
-    public function add_extra_finalize_registration_inputs($next_step)
1537
-    {
1538
-        if ($next_step === 'finalize_registration') {
1539
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1540
-        }
1541
-    }
1542
-
1543
-
1544
-
1545
-    /**
1546
-     *    display_registration_footer
1547
-     *
1548
-     * @access    public
1549
-     * @return    string
1550
-     */
1551
-    public static function display_registration_footer()
1552
-    {
1553
-        if (
1554
-        apply_filters(
1555
-            'FHEE__EE_Front__Controller__show_reg_footer',
1556
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1557
-        )
1558
-        ) {
1559
-            add_filter(
1560
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1561
-                function ($url) {
1562
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1563
-                }
1564
-            );
1565
-            echo apply_filters(
1566
-                'FHEE__EE_Front_Controller__display_registration_footer',
1567
-                \EEH_Template::powered_by_event_espresso(
1568
-                    '',
1569
-                    'espresso-registration-footer-dv',
1570
-                    array('utm_content' => 'registration_checkout')
1571
-                )
1572
-            );
1573
-        }
1574
-        return '';
1575
-    }
1576
-
1577
-
1578
-
1579
-    /**
1580
-     *    unlock_transaction
1581
-     *
1582
-     * @access    public
1583
-     * @return    void
1584
-     * @throws \EE_Error
1585
-     */
1586
-    public function unlock_transaction()
1587
-    {
1588
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1589
-            $this->checkout->transaction->unlock();
1590
-        }
1591
-    }
1592
-
1593
-
1594
-
1595
-    /**
1596
-     *        _setup_redirect
1597
-     *
1598
-     * @access    private
1599
-     * @return void
1600
-     */
1601
-    private function _setup_redirect()
1602
-    {
1603
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1604
-            $this->checkout->redirect = true;
1605
-            if (empty($this->checkout->redirect_url)) {
1606
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1607
-            }
1608
-            $this->checkout->redirect_url = apply_filters(
1609
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1610
-                $this->checkout->redirect_url,
1611
-                $this->checkout
1612
-            );
1613
-        }
1614
-    }
1615
-
1616
-
1617
-
1618
-    /**
1619
-     *   handle ajax message responses and redirects
1620
-     *
1621
-     * @access public
1622
-     * @return void
1623
-     * @throws \EE_Error
1624
-     */
1625
-    public function go_to_next_step()
1626
-    {
1627
-        if (EE_Registry::instance()->REQ->ajax) {
1628
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1629
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1630
-        }
1631
-        $this->unlock_transaction();
1632
-        // just return for these conditions
1633
-        if (
1634
-            $this->checkout->admin_request
1635
-            || $this->checkout->action === 'redirect_form'
1636
-            || $this->checkout->action === 'update_checkout'
1637
-        ) {
1638
-            return;
1639
-        }
1640
-        // AJAX response
1641
-        $this->_handle_json_response();
1642
-        // redirect to next step or the Thank You page
1643
-        $this->_handle_html_redirects();
1644
-        // hmmm... must be something wrong, so let's just display the form again !
1645
-        $this->_display_spco_reg_form();
1646
-    }
1647
-
1648
-
1649
-
1650
-    /**
1651
-     *   _handle_json_response
1652
-     *
1653
-     * @access protected
1654
-     * @return void
1655
-     */
1656
-    protected function _handle_json_response()
1657
-    {
1658
-        // if this is an ajax request
1659
-        if (EE_Registry::instance()->REQ->ajax) {
1660
-            // DEBUG LOG
1661
-            //$this->checkout->log(
1662
-            //	__CLASS__, __FUNCTION__, __LINE__,
1663
-            //	array(
1664
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1665
-            //		'redirect'                   => $this->checkout->redirect,
1666
-            //		'continue_reg'               => $this->checkout->continue_reg,
1667
-            //	)
1668
-            //);
1669
-            $this->checkout->json_response->set_registration_time_limit(
1670
-                $this->checkout->get_registration_time_limit()
1671
-            );
1672
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1673
-            // just send the ajax (
1674
-            $json_response = apply_filters(
1675
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1676
-                $this->checkout->json_response
1677
-            );
1678
-            echo $json_response;
1679
-            exit();
1680
-        }
1681
-    }
1682
-
1683
-
1684
-
1685
-    /**
1686
-     *   _handle_redirects
1687
-     *
1688
-     * @access protected
1689
-     * @return void
1690
-     */
1691
-    protected function _handle_html_redirects()
1692
-    {
1693
-        // going somewhere ?
1694
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1695
-            // store notices in a transient
1696
-            EE_Error::get_notices(false, true, true);
1697
-            // DEBUG LOG
1698
-            //$this->checkout->log(
1699
-            //	__CLASS__, __FUNCTION__, __LINE__,
1700
-            //	array(
1701
-            //		'headers_sent' => headers_sent(),
1702
-            //		'redirect_url'     => $this->checkout->redirect_url,
1703
-            //		'headers_list'    => headers_list(),
1704
-            //	)
1705
-            //);
1706
-            wp_safe_redirect($this->checkout->redirect_url);
1707
-            exit();
1708
-        }
1709
-    }
1710
-
1711
-
1712
-
1713
-    /**
1714
-     *   set_checkout_anchor
1715
-     *
1716
-     * @access public
1717
-     * @return void
1718
-     */
1719
-    public function set_checkout_anchor()
1720
-    {
1721
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1722
-    }
20
+	/**
21
+	 * $_initialized - has the SPCO controller already been initialized ?
22
+	 *
23
+	 * @access private
24
+	 * @var bool $_initialized
25
+	 */
26
+	private static $_initialized = false;
27
+
28
+
29
+	/**
30
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
31
+	 *
32
+	 * @access private
33
+	 * @var bool $_valid_checkout
34
+	 */
35
+	private static $_checkout_verified = true;
36
+
37
+	/**
38
+	 *    $_reg_steps_array - holds initial array of reg steps
39
+	 *
40
+	 * @access private
41
+	 * @var array $_reg_steps_array
42
+	 */
43
+	private static $_reg_steps_array = array();
44
+
45
+	/**
46
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
47
+	 *
48
+	 * @access public
49
+	 * @var EE_Checkout $checkout
50
+	 */
51
+	public $checkout;
52
+
53
+
54
+
55
+	/**
56
+	 * @return EED_Single_Page_Checkout
57
+	 */
58
+	public static function instance()
59
+	{
60
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
61
+		return parent::get_instance(__CLASS__);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * @return EE_CART
68
+	 */
69
+	public function cart()
70
+	{
71
+		return $this->checkout->cart;
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * @return EE_Transaction
78
+	 */
79
+	public function transaction()
80
+	{
81
+		return $this->checkout->transaction;
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 *    set_hooks - for hooking into EE Core, other modules, etc
88
+	 *
89
+	 * @access    public
90
+	 * @return    void
91
+	 * @throws \EE_Error
92
+	 */
93
+	public static function set_hooks()
94
+	{
95
+		EED_Single_Page_Checkout::set_definitions();
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
102
+	 *
103
+	 * @access    public
104
+	 * @return    void
105
+	 * @throws \EE_Error
106
+	 */
107
+	public static function set_hooks_admin()
108
+	{
109
+		EED_Single_Page_Checkout::set_definitions();
110
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
111
+			// hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called
112
+			add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1);
113
+			return;
114
+		}
115
+		// going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response
116
+		ob_start();
117
+		EED_Single_Page_Checkout::load_request_handler();
118
+		EED_Single_Page_Checkout::load_reg_steps();
119
+		// set ajax hooks
120
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
121
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
122
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
123
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
124
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
125
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 *    process ajax request
132
+	 *
133
+	 * @param string $ajax_action
134
+	 * @throws \EE_Error
135
+	 */
136
+	public static function process_ajax_request($ajax_action)
137
+	{
138
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
139
+		EED_Single_Page_Checkout::instance()->_initialize();
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 *    ajax display registration step
146
+	 *
147
+	 * @throws \EE_Error
148
+	 */
149
+	public static function display_reg_step()
150
+	{
151
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
152
+	}
153
+
154
+
155
+
156
+	/**
157
+	 *    ajax process registration step
158
+	 *
159
+	 * @throws \EE_Error
160
+	 */
161
+	public static function process_reg_step()
162
+	{
163
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 *    ajax process registration step
170
+	 *
171
+	 * @throws \EE_Error
172
+	 */
173
+	public static function update_reg_step()
174
+	{
175
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
176
+	}
177
+
178
+
179
+
180
+	/**
181
+	 *   update_checkout
182
+	 *
183
+	 * @access public
184
+	 * @return void
185
+	 * @throws \EE_Error
186
+	 */
187
+	public static function update_checkout()
188
+	{
189
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 *    load_request_handler
196
+	 *
197
+	 * @access    public
198
+	 * @return    void
199
+	 */
200
+	public static function load_request_handler()
201
+	{
202
+		// load core Request_Handler class
203
+		if ( ! isset(EE_Registry::instance()->REQ)) {
204
+			EE_Registry::instance()->load_core('Request_Handler');
205
+		}
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 *    set_definitions
212
+	 *
213
+	 * @access    public
214
+	 * @return    void
215
+	 * @throws \EE_Error
216
+	 */
217
+	public static function set_definitions()
218
+	{
219
+		define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS);
220
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
221
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
222
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
223
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
224
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
225
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
226
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
227
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
228
+			__('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
229
+				'event_espresso'),
230
+			'<h4 class="important-notice">',
231
+			'</h4>',
232
+			'<br />',
233
+			'<p>',
234
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
235
+			'">',
236
+			'</a>',
237
+			'</p>'
238
+		);
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * load_reg_steps
245
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
246
+	 *
247
+	 * @access    private
248
+	 * @throws EE_Error
249
+	 * @return void
250
+	 */
251
+	public static function load_reg_steps()
252
+	{
253
+		static $reg_steps_loaded = false;
254
+		if ($reg_steps_loaded) {
255
+			return;
256
+		}
257
+		// filter list of reg_steps
258
+		$reg_steps_to_load = (array)apply_filters(
259
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
260
+			EED_Single_Page_Checkout::get_reg_steps()
261
+		);
262
+		// sort by key (order)
263
+		ksort($reg_steps_to_load);
264
+		// loop through folders
265
+		foreach ($reg_steps_to_load as $order => $reg_step) {
266
+			// we need a
267
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
268
+				// copy over to the reg_steps_array
269
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
270
+				// register custom key route for each reg step
271
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
272
+				EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
273
+				// add AJAX or other hooks
274
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
275
+					// setup autoloaders if necessary
276
+					if ( ! class_exists($reg_step['class_name'])) {
277
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true);
278
+					}
279
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
280
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
281
+					}
282
+				}
283
+			}
284
+		}
285
+		$reg_steps_loaded = true;
286
+	}
287
+
288
+
289
+
290
+	/**
291
+	 *    get_reg_steps
292
+	 *
293
+	 * @access    public
294
+	 * @return    array
295
+	 */
296
+	public static function get_reg_steps()
297
+	{
298
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
299
+		if (empty($reg_steps)) {
300
+			$reg_steps = array(
301
+				10  => array(
302
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
303
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
304
+					'slug'       => 'attendee_information',
305
+					'has_hooks'  => false,
306
+				),
307
+				20  => array(
308
+					'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
309
+					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
310
+					'slug'       => 'registration_confirmation',
311
+					'has_hooks'  => false,
312
+				),
313
+				30  => array(
314
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
315
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
316
+					'slug'       => 'payment_options',
317
+					'has_hooks'  => true,
318
+				),
319
+				999 => array(
320
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
321
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
322
+					'slug'       => 'finalize_registration',
323
+					'has_hooks'  => false,
324
+				),
325
+			);
326
+		}
327
+		return $reg_steps;
328
+	}
329
+
330
+
331
+
332
+	/**
333
+	 *    registration_checkout_for_admin
334
+	 *
335
+	 * @access    public
336
+	 * @return    string
337
+	 * @throws \EE_Error
338
+	 */
339
+	public static function registration_checkout_for_admin()
340
+	{
341
+		EED_Single_Page_Checkout::load_reg_steps();
342
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
343
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
344
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
345
+		EED_Single_Page_Checkout::instance()->_initialize();
346
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
347
+		return EE_Registry::instance()->REQ->get_output();
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * process_registration_from_admin
354
+	 *
355
+	 * @access public
356
+	 * @return \EE_Transaction
357
+	 * @throws \EE_Error
358
+	 */
359
+	public static function process_registration_from_admin()
360
+	{
361
+		EED_Single_Page_Checkout::load_reg_steps();
362
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
363
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
364
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
365
+		EED_Single_Page_Checkout::instance()->_initialize();
366
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
367
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
368
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
369
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
370
+				if ($final_reg_step->process_reg_step()) {
371
+					$final_reg_step->set_completed();
372
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
373
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
374
+				}
375
+			}
376
+		}
377
+		return null;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 *    run
384
+	 *
385
+	 * @access    public
386
+	 * @param WP_Query $WP_Query
387
+	 * @return    void
388
+	 * @throws \EE_Error
389
+	 */
390
+	public function run($WP_Query)
391
+	{
392
+		if (
393
+			$WP_Query instanceof WP_Query
394
+			&& $WP_Query->is_main_query()
395
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
396
+			&& $this->_is_reg_checkout()
397
+		) {
398
+			$this->_initialize();
399
+		}
400
+	}
401
+
402
+
403
+
404
+	/**
405
+	 * determines whether current url matches reg page url
406
+	 *
407
+	 * @return bool
408
+	 */
409
+	protected function _is_reg_checkout()
410
+	{
411
+		// get current permalink for reg page without any extra query args
412
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
413
+		// get request URI for current request, but without the scheme or host
414
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
415
+		$current_request_uri = html_entity_decode($current_request_uri);
416
+		// get array of query args from the current request URI
417
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
418
+		// grab page id if it is set
419
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
420
+		// and remove the page id from the query args (we will re-add it later)
421
+		unset($query_args['page_id']);
422
+		// now strip all query args from current request URI
423
+		$current_request_uri = remove_query_arg(array_flip($query_args), $current_request_uri);
424
+		// and re-add the page id if it was set
425
+		if ($page_id) {
426
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
427
+		}
428
+		// remove slashes and ?
429
+		$current_request_uri = trim($current_request_uri, '?/');
430
+		// is current request URI part of the known full reg page URL ?
431
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
432
+	}
433
+
434
+
435
+
436
+	/**
437
+	 *    run
438
+	 *
439
+	 * @access    public
440
+	 * @param WP_Query $WP_Query
441
+	 * @return    void
442
+	 * @throws \EE_Error
443
+	 */
444
+	public static function init($WP_Query)
445
+	{
446
+		EED_Single_Page_Checkout::instance()->run($WP_Query);
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 *    _initialize - initial module setup
453
+	 *
454
+	 * @access    private
455
+	 * @throws EE_Error
456
+	 * @return    void
457
+	 */
458
+	private function _initialize()
459
+	{
460
+		// ensure SPCO doesn't run twice
461
+		if (EED_Single_Page_Checkout::$_initialized) {
462
+			return;
463
+		}
464
+		try {
465
+			$this->_verify_session();
466
+			// setup the EE_Checkout object
467
+			$this->checkout = $this->_initialize_checkout();
468
+			// filter checkout
469
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
470
+			// get the $_GET
471
+			$this->_get_request_vars();
472
+			if ($this->_block_bots()) {
473
+				return;
474
+			}
475
+			// filter continue_reg
476
+			$this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout);
477
+			// load the reg steps array
478
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
479
+				EED_Single_Page_Checkout::$_initialized = true;
480
+				return;
481
+			}
482
+			// set the current step
483
+			$this->checkout->set_current_step($this->checkout->step);
484
+			// and the next step
485
+			$this->checkout->set_next_step();
486
+			// verify that everything has been setup correctly
487
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
488
+				EED_Single_Page_Checkout::$_initialized = true;
489
+				return;
490
+			}
491
+			// lock the transaction
492
+			$this->checkout->transaction->lock();
493
+			// make sure all of our cached objects are added to their respective model entity mappers
494
+			$this->checkout->refresh_all_entities();
495
+			// set amount owing
496
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
497
+			// initialize each reg step, which gives them the chance to potentially alter the process
498
+			$this->_initialize_reg_steps();
499
+			// DEBUG LOG
500
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
501
+			// get reg form
502
+			if( ! $this->_check_form_submission()) {
503
+				EED_Single_Page_Checkout::$_initialized = true;
504
+				return;
505
+			}
506
+			// checkout the action!!!
507
+			$this->_process_form_action();
508
+			// add some style and make it dance
509
+			$this->add_styles_and_scripts();
510
+			// kk... SPCO has successfully run
511
+			EED_Single_Page_Checkout::$_initialized = true;
512
+			// set no cache headers and constants
513
+			EE_System::do_not_cache();
514
+			// add anchor
515
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
516
+			// remove transaction lock
517
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
518
+		} catch (Exception $e) {
519
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
520
+		}
521
+	}
522
+
523
+
524
+
525
+	/**
526
+	 *    _verify_session
527
+	 * checks that the session is valid and not expired
528
+	 *
529
+	 * @access    private
530
+	 * @throws EE_Error
531
+	 */
532
+	private function _verify_session()
533
+	{
534
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
535
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
536
+		}
537
+		// is session still valid ?
538
+		if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') {
539
+			$this->checkout = new EE_Checkout();
540
+			EE_Registry::instance()->SSN->reset_cart();
541
+			EE_Registry::instance()->SSN->reset_checkout();
542
+			EE_Registry::instance()->SSN->reset_transaction();
543
+			EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__,
544
+				__FUNCTION__, __LINE__);
545
+			EE_Registry::instance()->SSN->reset_expired();
546
+		}
547
+	}
548
+
549
+
550
+
551
+	/**
552
+	 *    _initialize_checkout
553
+	 * loads and instantiates EE_Checkout
554
+	 *
555
+	 * @access    private
556
+	 * @throws EE_Error
557
+	 * @return EE_Checkout
558
+	 */
559
+	private function _initialize_checkout()
560
+	{
561
+		// look in session for existing checkout
562
+		/** @type EE_Checkout $checkout */
563
+		$checkout = EE_Registry::instance()->SSN->checkout();
564
+		// verify
565
+		if ( ! $checkout instanceof EE_Checkout) {
566
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
567
+			$checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false);
568
+		} else {
569
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
570
+				$this->unlock_transaction();
571
+				wp_safe_redirect($checkout->redirect_url);
572
+				exit();
573
+			}
574
+		}
575
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
576
+		// verify again
577
+		if ( ! $checkout instanceof EE_Checkout) {
578
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
579
+		}
580
+		// reset anything that needs a clean slate for each request
581
+		$checkout->reset_for_current_request();
582
+		return $checkout;
583
+	}
584
+
585
+
586
+
587
+	/**
588
+	 *    _get_request_vars
589
+	 *
590
+	 * @access    private
591
+	 * @return    void
592
+	 * @throws \EE_Error
593
+	 */
594
+	private function _get_request_vars()
595
+	{
596
+		// load classes
597
+		EED_Single_Page_Checkout::load_request_handler();
598
+		//make sure this request is marked as belonging to EE
599
+		EE_Registry::instance()->REQ->set_espresso_page(true);
600
+		// which step is being requested ?
601
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
602
+		// which step is being edited ?
603
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
604
+		// and what we're doing on the current step
605
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
606
+		// timestamp
607
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
608
+		// returning to edit ?
609
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
610
+		// or some other kind of revisit ?
611
+		$this->checkout->revisit = filter_var(
612
+			EE_Registry::instance()->REQ->get('revisit', false),
613
+			FILTER_VALIDATE_BOOLEAN
614
+		);
615
+		// and whether or not to generate a reg form for this request
616
+		$this->checkout->generate_reg_form = filter_var(
617
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
618
+			FILTER_VALIDATE_BOOLEAN
619
+		);
620
+		// and whether or not to process a reg form submission for this request
621
+		$this->checkout->process_form_submission = filter_var(
622
+			EE_Registry::instance()->REQ->get(
623
+				'process_form_submission',
624
+				$this->checkout->action === 'process_reg_step'
625
+			),
626
+			FILTER_VALIDATE_BOOLEAN
627
+		);
628
+		$this->checkout->process_form_submission = filter_var(
629
+			$this->checkout->action !== 'display_spco_reg_step'
630
+				? $this->checkout->process_form_submission
631
+				: false,
632
+			FILTER_VALIDATE_BOOLEAN
633
+		);
634
+		// $this->_display_request_vars();
635
+	}
636
+
637
+
638
+
639
+	/**
640
+	 *  _display_request_vars
641
+	 *
642
+	 * @access    protected
643
+	 * @return    void
644
+	 */
645
+	protected function _display_request_vars()
646
+	{
647
+		if ( ! WP_DEBUG) {
648
+			return;
649
+		}
650
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
651
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
652
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
653
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
654
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
655
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
656
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
657
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
658
+	}
659
+
660
+
661
+
662
+	/**
663
+	 * _block_bots
664
+	 * checks that the incoming request has either of the following set:
665
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
666
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
667
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
668
+	 * then where you coming from man?
669
+	 *
670
+	 * @return boolean
671
+	 */
672
+	private function _block_bots()
673
+	{
674
+		$invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
675
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
676
+			return true;
677
+		}
678
+		return false;
679
+	}
680
+
681
+
682
+
683
+	/**
684
+	 *    _get_first_step
685
+	 *  gets slug for first step in $_reg_steps_array
686
+	 *
687
+	 * @access    private
688
+	 * @throws EE_Error
689
+	 * @return    string
690
+	 */
691
+	private function _get_first_step()
692
+	{
693
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
694
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
695
+	}
696
+
697
+
698
+
699
+	/**
700
+	 *    _load_and_instantiate_reg_steps
701
+	 *  instantiates each reg step based on the loaded reg_steps array
702
+	 *
703
+	 * @access    private
704
+	 * @throws EE_Error
705
+	 * @return    bool
706
+	 */
707
+	private function _load_and_instantiate_reg_steps()
708
+	{
709
+		// have reg_steps already been instantiated ?
710
+		if (
711
+			empty($this->checkout->reg_steps)
712
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
713
+		) {
714
+			// if not, then loop through raw reg steps array
715
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
716
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
717
+					return false;
718
+				}
719
+			}
720
+			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
721
+			EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
722
+			// skip the registration_confirmation page ?
723
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
724
+				// just remove it from the reg steps array
725
+				$this->checkout->remove_reg_step('registration_confirmation', false);
726
+			} else if (
727
+				isset($this->checkout->reg_steps['registration_confirmation'])
728
+				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
729
+			) {
730
+				// set the order to something big like 100
731
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
732
+			}
733
+			// filter the array for good luck
734
+			$this->checkout->reg_steps = apply_filters(
735
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
736
+				$this->checkout->reg_steps
737
+			);
738
+			// finally re-sort based on the reg step class order properties
739
+			$this->checkout->sort_reg_steps();
740
+		} else {
741
+			foreach ($this->checkout->reg_steps as $reg_step) {
742
+				// set all current step stati to FALSE
743
+				$reg_step->set_is_current_step(false);
744
+			}
745
+		}
746
+		if (empty($this->checkout->reg_steps)) {
747
+			EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
748
+			return false;
749
+		}
750
+		// make reg step details available to JS
751
+		$this->checkout->set_reg_step_JSON_info();
752
+		return true;
753
+	}
754
+
755
+
756
+
757
+	/**
758
+	 *     _load_and_instantiate_reg_step
759
+	 *
760
+	 * @access    private
761
+	 * @param array $reg_step
762
+	 * @param int   $order
763
+	 * @return bool
764
+	 */
765
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
766
+	{
767
+		// we need a file_path, class_name, and slug to add a reg step
768
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
769
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
770
+			if (
771
+				$this->checkout->reg_url_link
772
+				&& $this->checkout->step !== $reg_step['slug']
773
+				&& $reg_step['slug'] !== 'finalize_registration'
774
+			) {
775
+				return true;
776
+			}
777
+			// instantiate step class using file path and class name
778
+			$reg_step_obj = EE_Registry::instance()->load_file(
779
+				$reg_step['file_path'],
780
+				$reg_step['class_name'],
781
+				'class',
782
+				$this->checkout,
783
+				false
784
+			);
785
+			// did we gets the goods ?
786
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
787
+				// set reg step order based on config
788
+				$reg_step_obj->set_order($order);
789
+				// add instantiated reg step object to the master reg steps array
790
+				$this->checkout->add_reg_step($reg_step_obj);
791
+			} else {
792
+				EE_Error::add_error(
793
+					__('The current step could not be set.', 'event_espresso'),
794
+					__FILE__, __FUNCTION__, __LINE__
795
+				);
796
+				return false;
797
+			}
798
+		} else {
799
+			if (WP_DEBUG) {
800
+				EE_Error::add_error(
801
+					sprintf(
802
+						__('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'),
803
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
804
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
805
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
806
+						'<ul>',
807
+						'<li>',
808
+						'</li>',
809
+						'</ul>'
810
+					),
811
+					__FILE__, __FUNCTION__, __LINE__
812
+				);
813
+			}
814
+			return false;
815
+		}
816
+		return true;
817
+	}
818
+
819
+
820
+
821
+	/**
822
+	 * _verify_transaction_and_get_registrations
823
+	 *
824
+	 * @access private
825
+	 * @return bool
826
+	 */
827
+	private function _verify_transaction_and_get_registrations()
828
+	{
829
+		// was there already a valid transaction in the checkout from the session ?
830
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
831
+			// get transaction from db or session
832
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
833
+				? $this->_get_transaction_and_cart_for_previous_visit()
834
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
835
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
836
+				EE_Error::add_error(
837
+					__('Your Registration and Transaction information could not be retrieved from the db.',
838
+						'event_espresso'),
839
+					__FILE__, __FUNCTION__, __LINE__
840
+				);
841
+				$this->checkout->transaction = EE_Transaction::new_instance();
842
+				// add some style and make it dance
843
+				$this->add_styles_and_scripts();
844
+				EED_Single_Page_Checkout::$_initialized = true;
845
+				return false;
846
+			}
847
+			// and the registrations for the transaction
848
+			$this->_get_registrations($this->checkout->transaction);
849
+		}
850
+		return true;
851
+	}
852
+
853
+
854
+
855
+	/**
856
+	 * _get_transaction_and_cart_for_previous_visit
857
+	 *
858
+	 * @access private
859
+	 * @return mixed EE_Transaction|NULL
860
+	 */
861
+	private function _get_transaction_and_cart_for_previous_visit()
862
+	{
863
+		/** @var $TXN_model EEM_Transaction */
864
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
865
+		// because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db
866
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
867
+		// verify transaction
868
+		if ($transaction instanceof EE_Transaction) {
869
+			// and get the cart that was used for that transaction
870
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
871
+			return $transaction;
872
+		} else {
873
+			EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
874
+			return null;
875
+		}
876
+	}
877
+
878
+
879
+
880
+	/**
881
+	 * _get_cart_for_transaction
882
+	 *
883
+	 * @access private
884
+	 * @param EE_Transaction $transaction
885
+	 * @return EE_Cart
886
+	 */
887
+	private function _get_cart_for_transaction($transaction)
888
+	{
889
+		return $this->checkout->get_cart_for_transaction($transaction);
890
+	}
891
+
892
+
893
+
894
+	/**
895
+	 * get_cart_for_transaction
896
+	 *
897
+	 * @access public
898
+	 * @param EE_Transaction $transaction
899
+	 * @return EE_Cart
900
+	 */
901
+	public function get_cart_for_transaction(EE_Transaction $transaction)
902
+	{
903
+		return $this->checkout->get_cart_for_transaction($transaction);
904
+	}
905
+
906
+
907
+
908
+	/**
909
+	 * _get_transaction_and_cart_for_current_session
910
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
911
+	 *
912
+	 * @access private
913
+	 * @return EE_Transaction
914
+	 * @throws \EE_Error
915
+	 */
916
+	private function _get_cart_for_current_session_and_setup_new_transaction()
917
+	{
918
+		//  if there's no transaction, then this is the FIRST visit to SPCO
919
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
920
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
921
+		// and then create a new transaction
922
+		$transaction = $this->_initialize_transaction();
923
+		// verify transaction
924
+		if ($transaction instanceof EE_Transaction) {
925
+			// save it so that we have an ID for other objects to use
926
+			$transaction->save();
927
+			// and save TXN data to the cart
928
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
929
+		} else {
930
+			EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
931
+		}
932
+		return $transaction;
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
939
+	 *
940
+	 * @access private
941
+	 * @return mixed EE_Transaction|NULL
942
+	 */
943
+	private function _initialize_transaction()
944
+	{
945
+		try {
946
+			// ensure cart totals have been calculated
947
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
948
+			// grab the cart grand total
949
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
950
+			// create new TXN
951
+			$transaction = EE_Transaction::new_instance(
952
+				array(
953
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
954
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
955
+					'TXN_paid'      => 0,
956
+					'STS_ID'        => EEM_Transaction::failed_status_code,
957
+				)
958
+			);
959
+			// save it so that we have an ID for other objects to use
960
+			$transaction->save();
961
+			// set cron job for following up on TXNs after their session has expired
962
+			EE_Cron_Tasks::schedule_expired_transaction_check(
963
+				EE_Registry::instance()->SSN->expiration() + 1,
964
+				$transaction->ID()
965
+			);
966
+			return $transaction;
967
+		} catch (Exception $e) {
968
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
969
+		}
970
+		return null;
971
+	}
972
+
973
+
974
+
975
+	/**
976
+	 * _get_registrations
977
+	 *
978
+	 * @access private
979
+	 * @param EE_Transaction $transaction
980
+	 * @return void
981
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
982
+	 * @throws \EE_Error
983
+	 */
984
+	private function _get_registrations(EE_Transaction $transaction)
985
+	{
986
+		// first step: grab the registrants  { : o
987
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
988
+		// verify registrations have been set
989
+		if (empty($registrations)) {
990
+			// if no cached registrations, then check the db
991
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
992
+			// still nothing ? well as long as this isn't a revisit
993
+			if (empty($registrations) && ! $this->checkout->revisit) {
994
+				// generate new registrations from scratch
995
+				$registrations = $this->_initialize_registrations($transaction);
996
+			}
997
+		}
998
+		// sort by their original registration order
999
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1000
+		// then loop thru the array
1001
+		foreach ($registrations as $registration) {
1002
+			// verify each registration
1003
+			if ($registration instanceof EE_Registration) {
1004
+				// we display all attendee info for the primary registrant
1005
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1006
+					&& $registration->is_primary_registrant()
1007
+				) {
1008
+					$this->checkout->primary_revisit = true;
1009
+					break;
1010
+				} else if ($this->checkout->revisit
1011
+						   && $this->checkout->reg_url_link !== $registration->reg_url_link()
1012
+				) {
1013
+					// but hide info if it doesn't belong to you
1014
+					$transaction->clear_cache('Registration', $registration->ID());
1015
+				}
1016
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1017
+			}
1018
+		}
1019
+	}
1020
+
1021
+
1022
+
1023
+	/**
1024
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1025
+	 *
1026
+	 * @access private
1027
+	 * @param EE_Transaction $transaction
1028
+	 * @return    array
1029
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
1030
+	 * @throws \EE_Error
1031
+	 */
1032
+	private function _initialize_registrations(EE_Transaction $transaction)
1033
+	{
1034
+		$att_nmbr = 0;
1035
+		$registrations = array();
1036
+		if ($transaction instanceof EE_Transaction) {
1037
+			/** @type EE_Registration_Processor $registration_processor */
1038
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1039
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1040
+			// now let's add the cart items to the $transaction
1041
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1042
+				//do the following for each ticket of this type they selected
1043
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1044
+					$att_nmbr++;
1045
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1046
+					$CreateRegistrationCommand = EE_Registry::instance()
1047
+															->create(
1048
+																'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1049
+																array(
1050
+																	$transaction,
1051
+																	$line_item,
1052
+																	$att_nmbr,
1053
+																	$this->checkout->total_ticket_count,
1054
+																)
1055
+															);
1056
+					// override capabilities for frontend registrations
1057
+					if ( ! is_admin()) {
1058
+						$CreateRegistrationCommand->setCapCheck(
1059
+							new PublicCapabilities('', 'create_new_registration')
1060
+						);
1061
+					}
1062
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1063
+					if ( ! $registration instanceof EE_Registration) {
1064
+						throw new InvalidEntityException($registration, 'EE_Registration');
1065
+					}
1066
+					$registrations[ $registration->ID() ] = $registration;
1067
+				}
1068
+			}
1069
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1070
+		}
1071
+		return $registrations;
1072
+	}
1073
+
1074
+
1075
+
1076
+	/**
1077
+	 * sorts registrations by REG_count
1078
+	 *
1079
+	 * @access public
1080
+	 * @param EE_Registration $reg_A
1081
+	 * @param EE_Registration $reg_B
1082
+	 * @return int
1083
+	 */
1084
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1085
+	{
1086
+		// this shouldn't ever happen within the same TXN, but oh well
1087
+		if ($reg_A->count() === $reg_B->count()) {
1088
+			return 0;
1089
+		}
1090
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1091
+	}
1092
+
1093
+
1094
+
1095
+	/**
1096
+	 *    _final_verifications
1097
+	 * just makes sure that everything is set up correctly before proceeding
1098
+	 *
1099
+	 * @access    private
1100
+	 * @return    bool
1101
+	 * @throws \EE_Error
1102
+	 */
1103
+	private function _final_verifications()
1104
+	{
1105
+		// filter checkout
1106
+		$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout);
1107
+		//verify that current step is still set correctly
1108
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1109
+			EE_Error::add_error(
1110
+				__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1111
+				__FILE__,
1112
+				__FUNCTION__,
1113
+				__LINE__
1114
+			);
1115
+			return false;
1116
+		}
1117
+		// if returning to SPCO, then verify that primary registrant is set
1118
+		if ( ! empty($this->checkout->reg_url_link)) {
1119
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1120
+			if ( ! $valid_registrant instanceof EE_Registration) {
1121
+				EE_Error::add_error(
1122
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1123
+					__FILE__,
1124
+					__FUNCTION__,
1125
+					__LINE__
1126
+				);
1127
+				return false;
1128
+			}
1129
+			$valid_registrant = null;
1130
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1131
+				if (
1132
+					$registration instanceof EE_Registration
1133
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1134
+				) {
1135
+					$valid_registrant = $registration;
1136
+				}
1137
+			}
1138
+			if ( ! $valid_registrant instanceof EE_Registration) {
1139
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1140
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1141
+					// clear the session, mark the checkout as unverified, and try again
1142
+					EE_Registry::instance()->SSN->clear_session();
1143
+					EED_Single_Page_Checkout::$_initialized = false;
1144
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1145
+					$this->_initialize();
1146
+					EE_Error::reset_notices();
1147
+					return false;
1148
+				}
1149
+				EE_Error::add_error(
1150
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'),
1151
+					__FILE__,
1152
+					__FUNCTION__,
1153
+					__LINE__
1154
+				);
1155
+				return false;
1156
+			}
1157
+		}
1158
+		// now that things have been kinda sufficiently verified,
1159
+		// let's add the checkout to the session so that's available other systems
1160
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1161
+		return true;
1162
+	}
1163
+
1164
+
1165
+
1166
+	/**
1167
+	 *    _initialize_reg_steps
1168
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1169
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1170
+	 *
1171
+	 * @access    private
1172
+	 * @param bool $reinitializing
1173
+	 * @throws \EE_Error
1174
+	 */
1175
+	private function _initialize_reg_steps($reinitializing = false)
1176
+	{
1177
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1178
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1179
+		foreach ($this->checkout->reg_steps as $reg_step) {
1180
+			if ( ! $reg_step->initialize_reg_step()) {
1181
+				// if not initialized then maybe this step is being removed...
1182
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1183
+					// if it was the current step, then we need to start over here
1184
+					$this->_initialize_reg_steps(true);
1185
+					return;
1186
+				}
1187
+				continue;
1188
+			}
1189
+			// add css and JS for current step
1190
+			$reg_step->enqueue_styles_and_scripts();
1191
+			// i18n
1192
+			$reg_step->translate_js_strings();
1193
+			if ($reg_step->is_current_step()) {
1194
+				// the text that appears on the reg step form submit button
1195
+				$reg_step->set_submit_button_text();
1196
+			}
1197
+		}
1198
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1199
+		do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step);
1200
+	}
1201
+
1202
+
1203
+
1204
+	/**
1205
+	 * _check_form_submission
1206
+	 *
1207
+	 * @access private
1208
+	 * @return boolean
1209
+	 */
1210
+	private function _check_form_submission()
1211
+	{
1212
+		//does this request require the reg form to be generated ?
1213
+		if ($this->checkout->generate_reg_form) {
1214
+			// ever heard that song by Blue Rodeo ?
1215
+			try {
1216
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1217
+				// if not displaying a form, then check for form submission
1218
+				if (
1219
+					$this->checkout->process_form_submission
1220
+					&& $this->checkout->current_step->reg_form->was_submitted()
1221
+				) {
1222
+					// clear out any old data in case this step is being run again
1223
+					$this->checkout->current_step->set_valid_data(array());
1224
+					// capture submitted form data
1225
+					$this->checkout->current_step->reg_form->receive_form_submission(
1226
+						apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout)
1227
+					);
1228
+					// validate submitted form data
1229
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1230
+						// thou shall not pass !!!
1231
+						$this->checkout->continue_reg = false;
1232
+						// any form validation errors?
1233
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1234
+							$submission_error_messages = array();
1235
+							// bad, bad, bad registrant
1236
+							foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) {
1237
+								if ($validation_error instanceof EE_Validation_Error) {
1238
+									$submission_error_messages[] = sprintf(
1239
+										__('%s : %s', 'event_espresso'),
1240
+										$validation_error->get_form_section()->html_label_text(),
1241
+										$validation_error->getMessage()
1242
+									);
1243
+								}
1244
+							}
1245
+							EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1246
+						}
1247
+						// well not really... what will happen is we'll just get redirected back to redo the current step
1248
+						$this->go_to_next_step();
1249
+						return false;
1250
+					}
1251
+				}
1252
+			} catch (EE_Error $e) {
1253
+				$e->get_error();
1254
+			}
1255
+		}
1256
+		return true;
1257
+	}
1258
+
1259
+
1260
+
1261
+	/**
1262
+	 * _process_action
1263
+	 *
1264
+	 * @access private
1265
+	 * @return void
1266
+	 * @throws \EE_Error
1267
+	 */
1268
+	private function _process_form_action()
1269
+	{
1270
+		// what cha wanna do?
1271
+		switch ($this->checkout->action) {
1272
+			// AJAX next step reg form
1273
+			case 'display_spco_reg_step' :
1274
+				$this->checkout->redirect = false;
1275
+				if (EE_Registry::instance()->REQ->ajax) {
1276
+					$this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form());
1277
+				}
1278
+				break;
1279
+			default :
1280
+				// meh... do one of those other steps first
1281
+				if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) {
1282
+					// dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1283
+					do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1284
+					// call action on current step
1285
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1286
+						// good registrant, you get to proceed
1287
+						if (
1288
+							$this->checkout->current_step->success_message() !== ''
1289
+							&& apply_filters(
1290
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1291
+								false
1292
+							)
1293
+						) {
1294
+							EE_Error::add_success(
1295
+								$this->checkout->current_step->success_message()
1296
+								. '<br />' . $this->checkout->next_step->_instructions()
1297
+							);
1298
+						}
1299
+						// pack it up, pack it in...
1300
+						$this->_setup_redirect();
1301
+					}
1302
+					// dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1303
+					do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1304
+				} else {
1305
+					EE_Error::add_error(
1306
+						sprintf(
1307
+							__('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'),
1308
+							$this->checkout->action,
1309
+							$this->checkout->current_step->name()
1310
+						),
1311
+						__FILE__,
1312
+						__FUNCTION__,
1313
+						__LINE__
1314
+					);
1315
+				}
1316
+			// end default
1317
+		}
1318
+		// store our progress so far
1319
+		$this->checkout->stash_transaction_and_checkout();
1320
+		// advance to the next step! If you pass GO, collect $200
1321
+		$this->go_to_next_step();
1322
+	}
1323
+
1324
+
1325
+
1326
+	/**
1327
+	 *        add_styles_and_scripts
1328
+	 *
1329
+	 * @access        public
1330
+	 * @return        void
1331
+	 */
1332
+	public function add_styles_and_scripts()
1333
+	{
1334
+		// i18n
1335
+		$this->translate_js_strings();
1336
+		if ($this->checkout->admin_request) {
1337
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1338
+		} else {
1339
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1340
+		}
1341
+	}
1342
+
1343
+
1344
+
1345
+	/**
1346
+	 *        translate_js_strings
1347
+	 *
1348
+	 * @access        public
1349
+	 * @return        void
1350
+	 */
1351
+	public function translate_js_strings()
1352
+	{
1353
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1354
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1355
+		EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1356
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1357
+		EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso');
1358
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso');
1359
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso');
1360
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso');
1361
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1362
+			__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'),
1363
+			'<br/>',
1364
+			'<br/>'
1365
+		);
1366
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1367
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1368
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1369
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1370
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1371
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1372
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1373
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1374
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1375
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1376
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1377
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1378
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1379
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1380
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1381
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1382
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1383
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1384
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1385
+			__(
1386
+				'%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
1387
+				'event_espresso'
1388
+			),
1389
+			'<h4 class="important-notice">',
1390
+			'</h4>',
1391
+			'<br />',
1392
+			'<p>',
1393
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1394
+			'">',
1395
+			'</a>',
1396
+			'</p>'
1397
+		);
1398
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true);
1399
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1400
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1401
+		);
1402
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1403
+			'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1404
+		);
1405
+	}
1406
+
1407
+
1408
+
1409
+	/**
1410
+	 *    enqueue_styles_and_scripts
1411
+	 *
1412
+	 * @access        public
1413
+	 * @return        void
1414
+	 * @throws \EE_Error
1415
+	 */
1416
+	public function enqueue_styles_and_scripts()
1417
+	{
1418
+		// load css
1419
+		wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1420
+		wp_enqueue_style('single_page_checkout');
1421
+		// load JS
1422
+		wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array('jquery'), '1.0.1', true);
1423
+		wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', true);
1424
+		wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true);
1425
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1426
+			$this->checkout->registration_form->enqueue_js();
1427
+		}
1428
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1429
+			$this->checkout->current_step->reg_form->enqueue_js();
1430
+		}
1431
+		wp_enqueue_script('single_page_checkout');
1432
+		/**
1433
+		 * global action hook for enqueueing styles and scripts with
1434
+		 * spco calls.
1435
+		 */
1436
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1437
+		/**
1438
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1439
+		 * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1440
+		 */
1441
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this);
1442
+	}
1443
+
1444
+
1445
+
1446
+	/**
1447
+	 *    display the Registration Single Page Checkout Form
1448
+	 *
1449
+	 * @access    private
1450
+	 * @return    void
1451
+	 * @throws \EE_Error
1452
+	 */
1453
+	private function _display_spco_reg_form()
1454
+	{
1455
+		// if registering via the admin, just display the reg form for the current step
1456
+		if ($this->checkout->admin_request) {
1457
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1458
+		} else {
1459
+			// add powered by EE msg
1460
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1461
+			$empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1
1462
+				? true
1463
+				: false;
1464
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1465
+			$cookies_not_set_msg = '';
1466
+			if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1467
+				$cookies_not_set_msg = apply_filters(
1468
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1469
+					sprintf(
1470
+						__(
1471
+							'%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1472
+							'event_espresso'
1473
+						),
1474
+						'<div class="ee-attention">',
1475
+						'</div>',
1476
+						'<h6 class="important-notice">',
1477
+						'</h6>',
1478
+						'<p>',
1479
+						'</p>',
1480
+						'<br />',
1481
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1482
+						'</a>'
1483
+					)
1484
+				);
1485
+			}
1486
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1487
+				array(
1488
+					'name'            => 'single-page-checkout',
1489
+					'html_id'         => 'ee-single-page-checkout-dv',
1490
+					'layout_strategy' =>
1491
+						new EE_Template_Layout(
1492
+							array(
1493
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1494
+								'template_args'        => array(
1495
+									'empty_cart'              => $empty_cart,
1496
+									'revisit'                 => $this->checkout->revisit,
1497
+									'reg_steps'               => $this->checkout->reg_steps,
1498
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1499
+										? $this->checkout->next_step->slug()
1500
+										: '',
1501
+									'cancel_page_url'         => $this->checkout->cancel_page_url,
1502
+									'empty_msg'               => apply_filters(
1503
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1504
+										sprintf(
1505
+											__('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1506
+												'event_espresso'),
1507
+											'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1508
+											'">',
1509
+											'</a>'
1510
+										)
1511
+									),
1512
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1513
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1514
+									'session_expiration'      =>
1515
+										date('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)),
1516
+								),
1517
+							)
1518
+						),
1519
+				)
1520
+			);
1521
+			// load template and add to output sent that gets filtered into the_content()
1522
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1523
+		}
1524
+	}
1525
+
1526
+
1527
+
1528
+	/**
1529
+	 *    add_extra_finalize_registration_inputs
1530
+	 *
1531
+	 * @access    public
1532
+	 * @param $next_step
1533
+	 * @internal  param string $label
1534
+	 * @return void
1535
+	 */
1536
+	public function add_extra_finalize_registration_inputs($next_step)
1537
+	{
1538
+		if ($next_step === 'finalize_registration') {
1539
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1540
+		}
1541
+	}
1542
+
1543
+
1544
+
1545
+	/**
1546
+	 *    display_registration_footer
1547
+	 *
1548
+	 * @access    public
1549
+	 * @return    string
1550
+	 */
1551
+	public static function display_registration_footer()
1552
+	{
1553
+		if (
1554
+		apply_filters(
1555
+			'FHEE__EE_Front__Controller__show_reg_footer',
1556
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1557
+		)
1558
+		) {
1559
+			add_filter(
1560
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1561
+				function ($url) {
1562
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1563
+				}
1564
+			);
1565
+			echo apply_filters(
1566
+				'FHEE__EE_Front_Controller__display_registration_footer',
1567
+				\EEH_Template::powered_by_event_espresso(
1568
+					'',
1569
+					'espresso-registration-footer-dv',
1570
+					array('utm_content' => 'registration_checkout')
1571
+				)
1572
+			);
1573
+		}
1574
+		return '';
1575
+	}
1576
+
1577
+
1578
+
1579
+	/**
1580
+	 *    unlock_transaction
1581
+	 *
1582
+	 * @access    public
1583
+	 * @return    void
1584
+	 * @throws \EE_Error
1585
+	 */
1586
+	public function unlock_transaction()
1587
+	{
1588
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1589
+			$this->checkout->transaction->unlock();
1590
+		}
1591
+	}
1592
+
1593
+
1594
+
1595
+	/**
1596
+	 *        _setup_redirect
1597
+	 *
1598
+	 * @access    private
1599
+	 * @return void
1600
+	 */
1601
+	private function _setup_redirect()
1602
+	{
1603
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1604
+			$this->checkout->redirect = true;
1605
+			if (empty($this->checkout->redirect_url)) {
1606
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1607
+			}
1608
+			$this->checkout->redirect_url = apply_filters(
1609
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1610
+				$this->checkout->redirect_url,
1611
+				$this->checkout
1612
+			);
1613
+		}
1614
+	}
1615
+
1616
+
1617
+
1618
+	/**
1619
+	 *   handle ajax message responses and redirects
1620
+	 *
1621
+	 * @access public
1622
+	 * @return void
1623
+	 * @throws \EE_Error
1624
+	 */
1625
+	public function go_to_next_step()
1626
+	{
1627
+		if (EE_Registry::instance()->REQ->ajax) {
1628
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1629
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1630
+		}
1631
+		$this->unlock_transaction();
1632
+		// just return for these conditions
1633
+		if (
1634
+			$this->checkout->admin_request
1635
+			|| $this->checkout->action === 'redirect_form'
1636
+			|| $this->checkout->action === 'update_checkout'
1637
+		) {
1638
+			return;
1639
+		}
1640
+		// AJAX response
1641
+		$this->_handle_json_response();
1642
+		// redirect to next step or the Thank You page
1643
+		$this->_handle_html_redirects();
1644
+		// hmmm... must be something wrong, so let's just display the form again !
1645
+		$this->_display_spco_reg_form();
1646
+	}
1647
+
1648
+
1649
+
1650
+	/**
1651
+	 *   _handle_json_response
1652
+	 *
1653
+	 * @access protected
1654
+	 * @return void
1655
+	 */
1656
+	protected function _handle_json_response()
1657
+	{
1658
+		// if this is an ajax request
1659
+		if (EE_Registry::instance()->REQ->ajax) {
1660
+			// DEBUG LOG
1661
+			//$this->checkout->log(
1662
+			//	__CLASS__, __FUNCTION__, __LINE__,
1663
+			//	array(
1664
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1665
+			//		'redirect'                   => $this->checkout->redirect,
1666
+			//		'continue_reg'               => $this->checkout->continue_reg,
1667
+			//	)
1668
+			//);
1669
+			$this->checkout->json_response->set_registration_time_limit(
1670
+				$this->checkout->get_registration_time_limit()
1671
+			);
1672
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1673
+			// just send the ajax (
1674
+			$json_response = apply_filters(
1675
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1676
+				$this->checkout->json_response
1677
+			);
1678
+			echo $json_response;
1679
+			exit();
1680
+		}
1681
+	}
1682
+
1683
+
1684
+
1685
+	/**
1686
+	 *   _handle_redirects
1687
+	 *
1688
+	 * @access protected
1689
+	 * @return void
1690
+	 */
1691
+	protected function _handle_html_redirects()
1692
+	{
1693
+		// going somewhere ?
1694
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1695
+			// store notices in a transient
1696
+			EE_Error::get_notices(false, true, true);
1697
+			// DEBUG LOG
1698
+			//$this->checkout->log(
1699
+			//	__CLASS__, __FUNCTION__, __LINE__,
1700
+			//	array(
1701
+			//		'headers_sent' => headers_sent(),
1702
+			//		'redirect_url'     => $this->checkout->redirect_url,
1703
+			//		'headers_list'    => headers_list(),
1704
+			//	)
1705
+			//);
1706
+			wp_safe_redirect($this->checkout->redirect_url);
1707
+			exit();
1708
+		}
1709
+	}
1710
+
1711
+
1712
+
1713
+	/**
1714
+	 *   set_checkout_anchor
1715
+	 *
1716
+	 * @access public
1717
+	 * @return void
1718
+	 */
1719
+	public function set_checkout_anchor()
1720
+	{
1721
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1722
+	}
1723 1723
 
1724 1724
 
1725 1725
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public static function set_definitions()
218 218
     {
219
-        define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS);
220
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
221
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
222
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
223
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
224
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
225
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
219
+        define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS);
220
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
221
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
222
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
223
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
224
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
225
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
226 226
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
227 227
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
228 228
             __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s',
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             '</h4>',
232 232
             '<br />',
233 233
             '<p>',
234
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
234
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
235 235
             '">',
236 236
             '</a>',
237 237
             '</p>'
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             return;
256 256
         }
257 257
         // filter list of reg_steps
258
-        $reg_steps_to_load = (array)apply_filters(
258
+        $reg_steps_to_load = (array) apply_filters(
259 259
             'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
260 260
             EED_Single_Page_Checkout::get_reg_steps()
261 261
         );
@@ -299,25 +299,25 @@  discard block
 block discarded – undo
299 299
         if (empty($reg_steps)) {
300 300
             $reg_steps = array(
301 301
                 10  => array(
302
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
302
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
303 303
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
304 304
                     'slug'       => 'attendee_information',
305 305
                     'has_hooks'  => false,
306 306
                 ),
307 307
                 20  => array(
308
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
308
+                    'file_path'  => SPCO_REG_STEPS_PATH.'registration_confirmation',
309 309
                     'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
310 310
                     'slug'       => 'registration_confirmation',
311 311
                     'has_hooks'  => false,
312 312
                 ),
313 313
                 30  => array(
314
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
314
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
315 315
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
316 316
                     'slug'       => 'payment_options',
317 317
                     'has_hooks'  => true,
318 318
                 ),
319 319
                 999 => array(
320
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
320
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
321 321
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
322 322
                     'slug'       => 'finalize_registration',
323 323
                     'has_hooks'  => false,
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
             // DEBUG LOG
500 500
             //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
501 501
             // get reg form
502
-            if( ! $this->_check_form_submission()) {
502
+            if ( ! $this->_check_form_submission()) {
503 503
                 EED_Single_Page_Checkout::$_initialized = true;
504 504
                 return;
505 505
             }
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
                     if ( ! $registration instanceof EE_Registration) {
1064 1064
                         throw new InvalidEntityException($registration, 'EE_Registration');
1065 1065
                     }
1066
-                    $registrations[ $registration->ID() ] = $registration;
1066
+                    $registrations[$registration->ID()] = $registration;
1067 1067
                 }
1068 1068
             }
1069 1069
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
                         ) {
1294 1294
                             EE_Error::add_success(
1295 1295
                                 $this->checkout->current_step->success_message()
1296
-                                . '<br />' . $this->checkout->next_step->_instructions()
1296
+                                . '<br />'.$this->checkout->next_step->_instructions()
1297 1297
                             );
1298 1298
                         }
1299 1299
                         // pack it up, pack it in...
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
             '</h4>',
1391 1391
             '<br />',
1392 1392
             '<p>',
1393
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1393
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1394 1394
             '">',
1395 1395
             '</a>',
1396 1396
             '</p>'
@@ -1416,12 +1416,12 @@  discard block
 block discarded – undo
1416 1416
     public function enqueue_styles_and_scripts()
1417 1417
     {
1418 1418
         // load css
1419
-        wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1419
+        wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1420 1420
         wp_enqueue_style('single_page_checkout');
1421 1421
         // load JS
1422
-        wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array('jquery'), '1.0.1', true);
1423
-        wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', true);
1424
-        wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true);
1422
+        wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery	.plugin.min.js', array('jquery'), '1.0.1', true);
1423
+        wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', true);
1424
+        wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true);
1425 1425
         if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1426 1426
             $this->checkout->registration_form->enqueue_js();
1427 1427
         }
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
          * dynamic action hook for enqueueing styles and scripts with spco calls.
1439 1439
          * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1440 1440
          */
1441
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this);
1441
+        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this);
1442 1442
     }
1443 1443
 
1444 1444
 
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
                     'layout_strategy' =>
1491 1491
                         new EE_Template_Layout(
1492 1492
                             array(
1493
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1493
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1494 1494
                                 'template_args'        => array(
1495 1495
                                     'empty_cart'              => $empty_cart,
1496 1496
                                     'revisit'                 => $this->checkout->revisit,
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
                                         sprintf(
1505 1505
                                             __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1506 1506
                                                 'event_espresso'),
1507
-                                            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1507
+                                            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1508 1508
                                             '">',
1509 1509
                                             '</a>'
1510 1510
                                         )
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
         ) {
1559 1559
             add_filter(
1560 1560
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1561
-                function ($url) {
1561
+                function($url) {
1562 1562
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1563 1563
                 }
1564 1564
             );
Please login to merge, or discard this patch.
reg_steps/attendee_information/attendee_info_main.template.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /** @var string $default_hidden_inputs */
5 5
 ?>
6 6
 	<p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text">
7
-		<?php echo apply_filters( 'FHEE__registration_page_attendee_information__attendee_information_pg', sprintf( __('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>' )); ?>
7
+		<?php echo apply_filters('FHEE__registration_page_attendee_information__attendee_information_pg', sprintf(__('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>')); ?>
8 8
 	</p>
9 9
 
10 10
 <?php
@@ -12,34 +12,34 @@  discard block
 block discarded – undo
12 12
 $prev_event = 0;
13 13
 $prev_ticket = 0;
14 14
 
15
-if ( count( $registrations ) > 0 ) {
16
-	foreach ( $registrations as $registration ) {
17
-		if ( $registration instanceof EE_Registration ) {
15
+if (count($registrations) > 0) {
16
+	foreach ($registrations as $registration) {
17
+		if ($registration instanceof EE_Registration) {
18 18
 			$att_nmbr++;
19 19
 ?>
20 20
 
21
-		<div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link();?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID();?>">
21
+		<div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link(); ?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID(); ?>">
22 22
 
23
-			<?php if ( $registration->event()->ID() !== $prev_event ) { ?>
23
+			<?php if ($registration->event()->ID() !== $prev_event) { ?>
24 24
 			<h4 id="event_title-<?php echo $registration->event()->ID() ?>" class="big-event-title-hdr">
25 25
 				<?php echo $registration->event()->name(); ?>
26 26
 			</h4>
27 27
 			<?php } ?>
28
-			<?php if ( $registration->ticket()->ID() !== $prev_ticket ) { ?>
29
-				<?php if ( ! $revisit ) { ?>
28
+			<?php if ($registration->ticket()->ID() !== $prev_ticket) { ?>
29
+				<?php if ( ! $revisit) { ?>
30 30
 			<div class="spco-ticket-info-dv small-text">
31
-				<h5><?php _e('Details', 'event_espresso');?></h5>
31
+				<h5><?php _e('Details', 'event_espresso'); ?></h5>
32 32
 				<table>
33 33
 					<thead>
34 34
 						<tr>
35
-							<th scope="col" width=""><?php _e('Name and Description', 'event_espresso');?></th>
36
-							<th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso');?></th>
37
-							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso');?></th>
38
-							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso');?></th>
35
+							<th scope="col" width=""><?php _e('Name and Description', 'event_espresso'); ?></th>
36
+							<th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso'); ?></th>
37
+							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso'); ?></th>
38
+							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso'); ?></th>
39 39
 						</tr>
40 40
 					</thead>
41 41
 					<tbody>
42
-					<?php echo $ticket_line_item[ $registration->ticket()->ID() ]; ?>
42
+					<?php echo $ticket_line_item[$registration->ticket()->ID()]; ?>
43 43
 					</tbody>
44 44
 				</table>
45 45
 			</div>
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 			<?php
50 50
 			// ATTENDEE QUESTIONS
51
-			$reg_form = EE_Template_Layout::get_subform_name( $registration->reg_url_link() );
51
+			$reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
52 52
 			echo ${$reg_form};
53 53
 			?>
54 54
 
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -135,28 +135,28 @@  discard block
 block discarded – undo
135 135
 					$registration instanceof EE_Registration
136 136
 					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
137 137
 				) {
138
-                    $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
-                    if ( ! $this->checkout->admin_request) {
140
-                        $template_args['registrations'][$registration->reg_url_link()] = $registration;
141
-                        $template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
-                            $template_args['ticket_count'][$registration->ticket()->ID()]
143
-                        )
144
-                            ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145
-                            : 1;
146
-                        $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147
-                            $this->checkout->cart->get_grand_total(),
148
-                            'Ticket',
149
-                            array($registration->ticket()->ID())
150
-                        );
151
-                        $ticket_line_item = is_array($ticket_line_item)
152
-                            ? reset($ticket_line_item)
153
-                            : $ticket_line_item;
154
-                        $template_args['ticket_line_item'][$registration->ticket()->ID()] =
155
-                            $Line_Item_Display->display_line_item($ticket_line_item);
156
-                    }
157
-                    if ($registration->is_primary_registrant()) {
158
-                        $primary_registrant = $registration->reg_url_link();
159
-                    }
138
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
+					if ( ! $this->checkout->admin_request) {
140
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
141
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
+							$template_args['ticket_count'][$registration->ticket()->ID()]
143
+						)
144
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145
+							: 1;
146
+						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147
+							$this->checkout->cart->get_grand_total(),
148
+							'Ticket',
149
+							array($registration->ticket()->ID())
150
+						);
151
+						$ticket_line_item = is_array($ticket_line_item)
152
+							? reset($ticket_line_item)
153
+							: $ticket_line_item;
154
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] =
155
+							$Line_Item_Display->display_line_item($ticket_line_item);
156
+					}
157
+					if ($registration->is_primary_registrant()) {
158
+						$primary_registrant = $registration->reg_url_link();
159
+					}
160 160
 				}
161 161
 			}
162 162
 			// print_copy_info ?
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 				// generate hidden input
169 169
 				if (
170 170
 					isset( $subsections[ $primary_registrant ] )
171
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
171
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
172 172
 				) {
173 173
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
174 174
 				}
@@ -196,42 +196,42 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 
199
-    /**
199
+	/**
200 200
 	 * @param EE_Registration $registration
201 201
 	 * @return EE_Form_Section_Base
202 202
 	 * @throws \EE_Error
203 203
 	 */
204 204
 	private function _registrations_reg_form( EE_Registration $registration ) {
205 205
 		static $attendee_nmbr = 1;
206
-        $form_args = array();
206
+		$form_args = array();
207 207
 		// verify that registration has valid event
208 208
 		if ( $registration->event() instanceof EE_Event ) {
209 209
 			$question_groups = $registration->event()->question_groups(
210
-                array(
211
-                    array(
212
-                        'Event.EVT_ID'                     => $registration->event()->ID(),
213
-                        'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
214
-                    ),
215
-                    'order_by' => array('QSG_order' => 'ASC')
216
-                )
217
-            );
210
+				array(
211
+					array(
212
+						'Event.EVT_ID'                     => $registration->event()->ID(),
213
+						'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
214
+					),
215
+					'order_by' => array('QSG_order' => 'ASC')
216
+				)
217
+			);
218 218
 			if ( $question_groups ) {
219
-                // array of params to pass to parent constructor
220
-                $form_args = array(
221
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
222
-                    'html_class'      => 'ee-reg-form-attendee-dv',
223
-                    'html_style'      => $this->checkout->admin_request
224
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
225
-                        : '',
226
-                    'subsections'     => array(),
227
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
228
-                        array(
229
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
230
-                            'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
231
-                        )
232
-                    )
233
-                );
234
-                foreach ( $question_groups as $question_group ) {
219
+				// array of params to pass to parent constructor
220
+				$form_args = array(
221
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
222
+					'html_class'      => 'ee-reg-form-attendee-dv',
223
+					'html_style'      => $this->checkout->admin_request
224
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
225
+						: '',
226
+					'subsections'     => array(),
227
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
228
+						array(
229
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
230
+							'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
231
+						)
232
+					)
233
+				);
234
+				foreach ( $question_groups as $question_group ) {
235 235
 					if ( $question_group instanceof EE_Question_Group ) {
236 236
 						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
237 237
 							$registration,
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
 						);
240 240
 					}
241 241
 				}
242
-                // add hidden input
243
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
244
-                    $registration
245
-                );
246
-                // if we have question groups for additional attendees, then display the copy options
242
+				// add hidden input
243
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
244
+					$registration
245
+				);
246
+				// if we have question groups for additional attendees, then display the copy options
247 247
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
248
-                if ($registration->is_primary_registrant()) {
249
-                    // generate hidden input
250
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
251
-                }
252
-            }
248
+				if ($registration->is_primary_registrant()) {
249
+					// generate hidden input
250
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
251
+				}
252
+			}
253 253
 		}
254
-        $attendee_nmbr++;
254
+		$attendee_nmbr++;
255 255
 		return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML();
256 256
 	}
257 257
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
885 885
 						// do we need to copy basic info from primary attendee ?
886 886
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
887
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
887
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
888 888
 							? true
889 889
 							: false;
890 890
 						// filter form input data for this registration
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 			? $form_input
1060 1060
 			: $form_input . '-' . $registration->reg_url_link();
1061 1061
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1062
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1062
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1063 1063
 			? true
1064 1064
 			: false;
1065 1065
 		//rename form_inputs if they are EE_Attendee properties
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 		// then attempt to copy them from the primary attendee
1180 1180
 		if (
1181 1181
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1182
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1182
+			&& ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1183 1183
 		) {
1184 1184
 			return $this->checkout->primary_attendee_obj;
1185 1185
 		}
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 		}
1298 1298
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1299 1299
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1300
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1300
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1301 1301
 			) {
1302 1302
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1303 1303
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +211 added lines, -212 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	 * @access    public
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 */
44
-	public function __construct( EE_Checkout $checkout ) {
44
+	public function __construct(EE_Checkout $checkout) {
45 45
 		$this->_slug = 'attendee_information';
46 46
 		$this->_name = __('Attendee Information', 'event_espresso');
47
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
47
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
48 48
 		$this->checkout = $checkout;
49 49
 		$this->_reset_success_message();
50 50
 		$this->set_instructions(
51
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
51
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
52 52
 		);
53 53
 	}
54 54
 
55 55
 
56 56
 
57 57
 	public function translate_js_strings() {
58
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
58
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
59 59
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
60 60
 			' is a required question. Please enter a value for at least one of the options.',
61 61
 			'event_espresso'
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		// calculate taxes
116 116
 		$Line_Item_Display->display_line_item(
117 117
 			$this->checkout->cart->get_grand_total(),
118
-			array( 'set_tax_rate' => true )
118
+			array('set_tax_rate' => true)
119 119
 		);
120 120
 		/** @var $subsections EE_Form_Section_Proper[] */
121 121
 		$subsections = array(
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 			'ticket_count' 	=> array()
128 128
 		);
129 129
 		// grab the saved registrations from the transaction
130
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
131
-		if ( $registrations ) {
132
-			foreach ( $registrations as $registration ) {
130
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
131
+		if ($registrations) {
132
+			foreach ($registrations as $registration) {
133 133
 				// can this registration be processed during this visit ?
134 134
 				if (
135 135
 					$registration instanceof EE_Registration
136
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
136
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
137 137
 				) {
138 138
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139 139
                     if ( ! $this->checkout->admin_request) {
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 				}
161 161
 			}
162 162
 			// print_copy_info ?
163
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
163
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
164 164
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
165 165
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
166 166
 					? $this->_copy_attendee_info_form()
167 167
 					: $this->_auto_copy_attendee_info();
168 168
 				// generate hidden input
169 169
 				if (
170
-					isset( $subsections[ $primary_registrant ] )
171
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
170
+					isset($subsections[$primary_registrant])
171
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
172 172
 				) {
173
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
173
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
174 174
 				}
175 175
 			}
176 176
 
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
 				'html_id' 					=> $this->reg_form_name(),
183 183
 				'subsections' 			=> $subsections,
184 184
 				'layout_strategy'		=> $this->checkout->admin_request ?
185
-					new EE_Div_Per_Section_Layout() :
186
-					new EE_Template_Layout(
185
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
187 186
 						array(
188 187
 							'layout_template_file' 	=> $this->_template, // layout_template
189 188
 							'template_args' 				=> $template_args
@@ -201,11 +200,11 @@  discard block
 block discarded – undo
201 200
 	 * @return EE_Form_Section_Base
202 201
 	 * @throws \EE_Error
203 202
 	 */
204
-	private function _registrations_reg_form( EE_Registration $registration ) {
203
+	private function _registrations_reg_form(EE_Registration $registration) {
205 204
 		static $attendee_nmbr = 1;
206 205
         $form_args = array();
207 206
 		// verify that registration has valid event
208
-		if ( $registration->event() instanceof EE_Event ) {
207
+		if ($registration->event() instanceof EE_Event) {
209 208
 			$question_groups = $registration->event()->question_groups(
210 209
                 array(
211 210
                     array(
@@ -215,10 +214,10 @@  discard block
 block discarded – undo
215 214
                     'order_by' => array('QSG_order' => 'ASC')
216 215
                 )
217 216
             );
218
-			if ( $question_groups ) {
217
+			if ($question_groups) {
219 218
                 // array of params to pass to parent constructor
220 219
                 $form_args = array(
221
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
220
+                    'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
222 221
                     'html_class'      => 'ee-reg-form-attendee-dv',
223 222
                     'html_style'      => $this->checkout->admin_request
224 223
                         ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -231,9 +230,9 @@  discard block
 block discarded – undo
231 230
                         )
232 231
                     )
233 232
                 );
234
-                foreach ( $question_groups as $question_group ) {
235
-					if ( $question_group instanceof EE_Question_Group ) {
236
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
233
+                foreach ($question_groups as $question_group) {
234
+					if ($question_group instanceof EE_Question_Group) {
235
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
237 236
 							$registration,
238 237
 							$question_group
239 238
 						);
@@ -252,7 +251,7 @@  discard block
 block discarded – undo
252 251
             }
253 252
 		}
254 253
         $attendee_nmbr++;
255
-		return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML();
254
+		return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
256 255
 	}
257 256
 
258 257
 
@@ -273,7 +272,7 @@  discard block
 block discarded – undo
273 272
 		// generate hidden input
274 273
 		return new EE_Hidden_Input(
275 274
 			array(
276
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
275
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
277 276
 				'default' => $additional_attendee_reg_info
278 277
 			)
279 278
 		);
@@ -287,26 +286,26 @@  discard block
 block discarded – undo
287 286
 	 * @return EE_Form_Section_Proper
288 287
 	 * @throws \EE_Error
289 288
 	 */
290
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
289
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
291 290
 		// array of params to pass to parent constructor
292 291
 		$form_args = array(
293
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
292
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
294 293
 			'html_class'      => $this->checkout->admin_request
295 294
 				? 'form-table ee-reg-form-qstn-grp-dv'
296 295
 				: 'ee-reg-form-qstn-grp-dv',
297
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
296
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
298 297
 			'subsections'     => array(
299
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
298
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
300 299
 			),
301 300
 			'layout_strategy' => $this->checkout->admin_request
302 301
 				? new EE_Admin_Two_Column_Layout()
303 302
 				: new EE_Div_Per_Section_Layout()
304 303
 		);
305 304
 		// where params
306
-		$query_params = array( 'QST_deleted' => 0 );
305
+		$query_params = array('QST_deleted' => 0);
307 306
 		// don't load admin only questions on the frontend
308
-		if ( ! $this->checkout->admin_request ) {
309
-			$query_params['QST_admin_only'] = array( '!=', true );
307
+		if ( ! $this->checkout->admin_request) {
308
+			$query_params['QST_admin_only'] = array('!=', true);
310 309
 		}
311 310
 		$questions = $question_group->get_many_related(
312 311
 			'Question',
@@ -328,10 +327,10 @@  discard block
 block discarded – undo
328 327
 			)
329 328
 		);
330 329
 		// loop thru questions
331
-		foreach ( $questions as $question ) {
332
-			if( $question instanceof EE_Question ){
330
+		foreach ($questions as $question) {
331
+			if ($question instanceof EE_Question) {
333 332
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
334
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
333
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
335 334
 			}
336 335
 		}
337 336
 		$form_args['subsections'] = apply_filters(
@@ -352,7 +351,7 @@  discard block
 block discarded – undo
352 351
 			)
353 352
 		);
354 353
 //		d( $form_args );
355
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
354
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
356 355
 		return apply_filters(
357 356
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
358 357
 			$question_group_reg_form,
@@ -369,11 +368,11 @@  discard block
 block discarded – undo
369 368
 	 * @param EE_Question_Group $question_group
370 369
 	 * @return 	EE_Form_Section_HTML
371 370
 	 */
372
-	private function _question_group_header( EE_Question_Group $question_group ){
371
+	private function _question_group_header(EE_Question_Group $question_group) {
373 372
 		$html = '';
374 373
 		// group_name
375
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
376
-			if ( $this->checkout->admin_request ) {
374
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
375
+			if ($this->checkout->admin_request) {
377 376
 				$html .= EEH_HTML::br();
378 377
 				$html .= EEH_HTML::h3(
379 378
 					$question_group->name(),
@@ -387,7 +386,7 @@  discard block
 block discarded – undo
387 386
 			}
388 387
 		}
389 388
 		// group_desc
390
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
389
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
391 390
 			$html .= EEH_HTML::p(
392 391
 				$question_group->desc(),
393 392
 				'',
@@ -397,7 +396,7 @@  discard block
 block discarded – undo
397 396
 			);
398 397
 
399 398
 		}
400
-		return new EE_Form_Section_HTML( $html );
399
+		return new EE_Form_Section_HTML($html);
401 400
 	}
402 401
 
403 402
 
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 	 * @return    EE_Form_Section_Proper
408 407
 	 * @throws \EE_Error
409 408
 	 */
410
-	private function _copy_attendee_info_form(){
409
+	private function _copy_attendee_info_form() {
411 410
 		// array of params to pass to parent constructor
412 411
 		return new EE_Form_Section_Proper(
413 412
 			array(
@@ -436,7 +435,7 @@  discard block
 block discarded – undo
436 435
 	private function _auto_copy_attendee_info() {
437 436
 		return new EE_Form_Section_HTML(
438 437
 			EEH_Template::locate_template(
439
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
438
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
440 439
 				apply_filters(
441 440
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
442 441
 					array()
@@ -460,32 +459,32 @@  discard block
 block discarded – undo
460 459
 		$copy_attendee_info_inputs = array();
461 460
 		$prev_ticket = NULL;
462 461
 		// grab the saved registrations from the transaction
463
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
464
-		foreach ( $registrations as $registration ) {
462
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
463
+		foreach ($registrations as $registration) {
465 464
 			// for all  attendees other than the primary attendee
466
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
465
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
467 466
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
468
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
467
+				if ($registration->ticket()->ID() !== $prev_ticket) {
469 468
 					$item_name = $registration->ticket()->name();
470 469
 					$item_name .= $registration->ticket()->description() !== ''
471
-						? ' - ' . $registration->ticket()->description()
470
+						? ' - '.$registration->ticket()->description()
472 471
 						: '';
473
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
474
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
472
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
473
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
475 474
 					);
476 475
 					$prev_ticket = $registration->ticket()->ID();
477 476
 				}
478 477
 
479
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
478
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
480 479
 				EE_Checkbox_Multi_Input(
481 480
 					array(
482 481
 						$registration->ID() => sprintf(
483
-							__( 'Attendee #%s', 'event_espresso' ),
482
+							__('Attendee #%s', 'event_espresso'),
484 483
 							$registration->count()
485 484
 						)
486 485
 					),
487 486
 					array(
488
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
487
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
489 488
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
490 489
 						'display_html_label_text' => false
491 490
 					)
@@ -505,7 +504,7 @@  discard block
 block discarded – undo
505 504
 	 * @return    EE_Form_Input_Base
506 505
 	 * @throws \EE_Error
507 506
 	 */
508
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
507
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
509 508
 		// generate hidden input
510 509
 		return new EE_Hidden_Input(
511 510
 			array(
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 	 * @return    EE_Form_Input_Base
525 524
 	 * @throws \EE_Error
526 525
 	 */
527
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
526
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
528 527
 
529 528
 		// if this question was for an attendee detail, then check for that answer
530 529
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -533,32 +532,32 @@  discard block
 block discarded – undo
533 532
 		);
534 533
 		$answer = $answer_value === null
535 534
 			? EEM_Answer::instance()->get_one(
536
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
535
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
537 536
 			)
538 537
 			: null;
539 538
 		// if NOT returning to edit an existing registration
540 539
 		// OR if this question is for an attendee property
541 540
 		// OR we still don't have an EE_Answer object
542
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
541
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
543 542
 			// create an EE_Answer object for storing everything in
544
-			$answer = EE_Answer::new_instance ( array(
543
+			$answer = EE_Answer::new_instance(array(
545 544
 				'QST_ID'=> $question->ID(),
546 545
 				'REG_ID'=> $registration->ID()
547 546
 			));
548 547
 		}
549 548
 		// verify instance
550
-		if( $answer instanceof EE_Answer ){
551
-			if ( ! empty( $answer_value )) {
552
-				$answer->set( 'ANS_value', $answer_value );
549
+		if ($answer instanceof EE_Answer) {
550
+			if ( ! empty($answer_value)) {
551
+				$answer->set('ANS_value', $answer_value);
553 552
 			}
554
-			$answer->cache( 'Question', $question );
553
+			$answer->cache('Question', $question);
555 554
 			//remember system ID had a bug where sometimes it could be null
556
-			$answer_cache_id =$question->is_system_question()
557
-				? $question->system_ID() . '-' . $registration->reg_url_link()
558
-				: $question->ID() . '-' . $registration->reg_url_link();
559
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
555
+			$answer_cache_id = $question->is_system_question()
556
+				? $question->system_ID().'-'.$registration->reg_url_link()
557
+				: $question->ID().'-'.$registration->reg_url_link();
558
+			$registration->cache('Answer', $answer, $answer_cache_id);
560 559
 		}
561
-		return $this->_generate_question_input( $registration, $question, $answer );
560
+		return $this->_generate_question_input($registration, $question, $answer);
562 561
 
563 562
 	}
564 563
 
@@ -571,46 +570,46 @@  discard block
 block discarded – undo
571 570
 	 * @return EE_Form_Input_Base
572 571
 	 * @throws \EE_Error
573 572
 	 */
574
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
573
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
575 574
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
576
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
575
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
577 576
 		add_filter(
578 577
 			'FHEE__EE_Question__generate_form_input__country_options',
579
-			array( $this, 'use_cached_countries_for_form_input' ),
578
+			array($this, 'use_cached_countries_for_form_input'),
580 579
 			10,
581 580
 			4
582 581
 		);
583 582
 		add_filter(
584 583
 			'FHEE__EE_Question__generate_form_input__state_options',
585
-			array( $this, 'use_cached_states_for_form_input' ),
584
+			array($this, 'use_cached_states_for_form_input'),
586 585
 			10,
587 586
 			4
588 587
 		);
589 588
 		$input_constructor_args = array(
590
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
591
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
592
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
593
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
589
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
590
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
591
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
592
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
594 593
 			'html_label_class'	=> 'ee-reg-qstn',
595 594
 		);
596
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
597
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
598
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
599
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
600
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
595
+		$input_constructor_args['html_label_id'] .= '-lbl';
596
+		if ($answer instanceof EE_Answer && $answer->ID()) {
597
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
598
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
599
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
601 600
 		}
602
-		$form_input =  $question->generate_form_input(
601
+		$form_input = $question->generate_form_input(
603 602
 			$registration,
604 603
 			$answer,
605 604
 			$input_constructor_args
606 605
 		);
607 606
 		remove_filter(
608 607
 			'FHEE__EE_Question__generate_form_input__country_options',
609
-			array( $this, 'use_cached_countries_for_form_input' )
608
+			array($this, 'use_cached_countries_for_form_input')
610 609
 		);
611 610
 		remove_filter(
612 611
 			'FHEE__EE_Question__generate_form_input__state_options',
613
-			array( $this, 'use_cached_states_for_form_input' )
612
+			array($this, 'use_cached_states_for_form_input')
614 613
 		);
615 614
 		return $form_input;
616 615
 	}
@@ -632,22 +631,22 @@  discard block
 block discarded – undo
632 631
 		\EE_Registration $registration = null,
633 632
 		\EE_Answer $answer = null
634 633
 	) {
635
-		$country_options = array( '' => '' );
634
+		$country_options = array('' => '');
636 635
 		// get possibly cached list of countries
637 636
 		$countries = $this->checkout->action === 'process_reg_step'
638 637
 			? EEM_Country::instance()->get_all_countries()
639 638
 			: EEM_Country::instance()->get_all_active_countries();
640
-		if ( ! empty( $countries )) {
641
-			foreach( $countries as $country ){
642
-				if ( $country instanceof EE_Country ) {
643
-					$country_options[ $country->ID() ] = $country->name();
639
+		if ( ! empty($countries)) {
640
+			foreach ($countries as $country) {
641
+				if ($country instanceof EE_Country) {
642
+					$country_options[$country->ID()] = $country->name();
644 643
 				}
645 644
 			}
646 645
 		}
647
-		if( $question instanceof EE_Question
648
-			&& $registration instanceof EE_Registration ) {
646
+		if ($question instanceof EE_Question
647
+			&& $registration instanceof EE_Registration) {
649 648
 			$answer = EEM_Answer::instance()->get_one(
650
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
649
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
651 650
 			);
652 651
 		} else {
653 652
 			$answer = EE_Answer::new_instance();
@@ -680,14 +679,14 @@  discard block
 block discarded – undo
680 679
 		\EE_Registration $registration = null,
681 680
 		\EE_Answer $answer = null
682 681
 	) {
683
-		$state_options = array( '' => array( '' => ''));
682
+		$state_options = array('' => array('' => ''));
684 683
 		$states = $this->checkout->action === 'process_reg_step'
685 684
 			? EEM_State::instance()->get_all_states()
686 685
 			: EEM_State::instance()->get_all_active_states();
687
-		if ( ! empty( $states )) {
688
-			foreach( $states as $state ){
689
-				if ( $state instanceof EE_State ) {
690
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
686
+		if ( ! empty($states)) {
687
+			foreach ($states as $state) {
688
+				if ($state instanceof EE_State) {
689
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
691 690
 				}
692 691
 			}
693 692
 		}
@@ -715,24 +714,24 @@  discard block
 block discarded – undo
715 714
 	 * @throws \EE_Error
716 715
 	 */
717 716
 	public function process_reg_step() {
718
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
717
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719 718
 		// grab validated data from form
720 719
 		$valid_data = $this->checkout->current_step->valid_data();
721 720
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
722 721
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
723 722
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
724
-		if ( empty( $valid_data ))  {
723
+		if (empty($valid_data)) {
725 724
 			EE_Error::add_error(
726
-				__( 'No valid question responses were received.', 'event_espresso' ),
725
+				__('No valid question responses were received.', 'event_espresso'),
727 726
 				__FILE__,
728 727
 				__FUNCTION__,
729 728
 				__LINE__
730 729
 			);
731 730
 			return false;
732 731
 		}
733
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
732
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
734 733
 			EE_Error::add_error(
735
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
734
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
736 735
 				__FILE__,
737 736
 				__FUNCTION__,
738 737
 				__LINE__
@@ -740,11 +739,11 @@  discard block
 block discarded – undo
740 739
 			return false;
741 740
 		}
742 741
 		// get cached registrations
743
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
742
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
744 743
 		// verify we got the goods
745
-		if ( empty( $registrations )) {
744
+		if (empty($registrations)) {
746 745
 			EE_Error::add_error(
747
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
746
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
748 747
 				__FILE__,
749 748
 				__FUNCTION__,
750 749
 				__LINE__
@@ -752,15 +751,15 @@  discard block
 block discarded – undo
752 751
 			return false;
753 752
 		}
754 753
 		// extract attendee info from form data and save to model objects
755
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
754
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
756 755
 		// if first pass thru SPCO,
757 756
 		// then let's check processed registrations against the total number of tickets in the cart
758
-		if ( $registrations_processed === false ) {
757
+		if ($registrations_processed === false) {
759 758
 			// but return immediately if the previous step exited early due to errors
760 759
 			return false;
761
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
760
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
762 761
 			// generate a correctly translated string for all possible singular/plural combinations
763
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
762
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
764 763
 				$error_msg = sprintf(
765 764
 					__(
766 765
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -769,7 +768,7 @@  discard block
 block discarded – undo
769 768
 					$this->checkout->total_ticket_count,
770 769
 					$registrations_processed
771 770
 				);
772
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
771
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
773 772
 				$error_msg = sprintf(
774 773
 					__(
775 774
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -788,17 +787,17 @@  discard block
 block discarded – undo
788 787
 					$registrations_processed
789 788
 				);
790 789
 			}
791
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
790
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
792 791
 			return false;
793 792
 		}
794 793
 		// mark this reg step as completed
795 794
 		$this->set_completed();
796 795
 		$this->_set_success_message(
797
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
796
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
798 797
 		);
799 798
 		//do action in case a plugin wants to do something with the data submitted in step 1.
800 799
 		//passes EE_Single_Page_Checkout, and it's posted data
801
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
800
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
802 801
 		return true;
803 802
 	}
804 803
 
@@ -812,9 +811,9 @@  discard block
 block discarded – undo
812 811
 	 * @return boolean | int
813 812
 	 * @throws \EE_Error
814 813
 	 */
815
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
814
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
816 815
 		// load resources and set some defaults
817
-		EE_Registry::instance()->load_model( 'Attendee' );
816
+		EE_Registry::instance()->load_model('Attendee');
818 817
 		// holder for primary registrant attendee object
819 818
 		$this->checkout->primary_attendee_obj = NULL;
820 819
 		// array for tracking reg form data for the primary registrant
@@ -831,9 +830,9 @@  discard block
 block discarded – undo
831 830
 		// attendee counter
832 831
 		$att_nmbr = 0;
833 832
 		// grab the saved registrations from the transaction
834
-		foreach ( $registrations  as $registration ) {
833
+		foreach ($registrations  as $registration) {
835 834
 			// verify EE_Registration object
836
-			if ( ! $registration instanceof EE_Registration ) {
835
+			if ( ! $registration instanceof EE_Registration) {
837 836
 				EE_Error::add_error(
838 837
 					__(
839 838
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -848,12 +847,12 @@  discard block
 block discarded – undo
848 847
 			/** @var string $reg_url_link */
849 848
 			$reg_url_link = $registration->reg_url_link();
850 849
 			// reg_url_link exists ?
851
-			if ( ! empty( $reg_url_link ) ) {
850
+			if ( ! empty($reg_url_link)) {
852 851
 				// should this registration be processed during this visit ?
853
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
852
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
854 853
 					// if NOT revisiting, then let's save the registration now,
855 854
 					// so that we have a REG_ID to use when generating other objects
856
-					if ( ! $this->checkout->revisit ) {
855
+					if ( ! $this->checkout->revisit) {
857 856
 						$registration->save();
858 857
 					}
859 858
 					/**
@@ -863,7 +862,7 @@  discard block
 block discarded – undo
863 862
 					 * @var bool   if true is returned by the plugin then the
864 863
 					 *      		registration processing is halted.
865 864
 					 */
866
-					if ( apply_filters(
865
+					if (apply_filters(
867 866
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
868 867
 						false,
869 868
 						$att_nmbr,
@@ -871,38 +870,38 @@  discard block
 block discarded – undo
871 870
 						$registrations,
872 871
 						$valid_data,
873 872
 						$this
874
-					) ) {
873
+					)) {
875 874
 						return false;
876 875
 					}
877 876
 
878 877
 					// Houston, we have a registration!
879 878
 					$att_nmbr++;
880
-					$this->_attendee_data[ $reg_url_link ] = array();
879
+					$this->_attendee_data[$reg_url_link] = array();
881 880
 					// grab any existing related answer objects
882 881
 					$this->_registration_answers = $registration->answers();
883 882
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
884
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
883
+					if (isset($valid_data[$reg_url_link])) {
885 884
 						// do we need to copy basic info from primary attendee ?
886
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
887
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
885
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
886
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
888 887
 							? true
889 888
 							: false;
890 889
 						// filter form input data for this registration
891
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
890
+						$valid_data[$reg_url_link] = (array) apply_filters(
892 891
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
893
-							$valid_data[ $reg_url_link ]
892
+							$valid_data[$reg_url_link]
894 893
 						);
895 894
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
896
-						if ( isset( $valid_data['primary_attendee'] )) {
897
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
895
+						if (isset($valid_data['primary_attendee'])) {
896
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
898 897
 								? $valid_data['primary_attendee']
899 898
 								: false;
900
-							unset( $valid_data['primary_attendee'] );
899
+							unset($valid_data['primary_attendee']);
901 900
 						}
902 901
 						// now loop through our array of valid post data && process attendee reg forms
903
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
904
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
905
-								foreach ( $form_inputs as $form_input => $input_value ) {
902
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
903
+							if ( ! in_array($form_section, $non_input_form_sections)) {
904
+								foreach ($form_inputs as $form_input => $input_value) {
906 905
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
907 906
 									// check for critical inputs
908 907
 									if (
@@ -916,16 +915,16 @@  discard block
 block discarded – undo
916 915
 									// store a bit of data about the primary attendee
917 916
 									if (
918 917
 										$att_nmbr === 1
919
-										&& ! empty( $input_value )
918
+										&& ! empty($input_value)
920 919
 										&& $reg_url_link === $primary_registrant['line_item_id']
921 920
 									) {
922
-										$primary_registrant[ $form_input ] = $input_value;
921
+										$primary_registrant[$form_input] = $input_value;
923 922
 									} else if (
924 923
 										$copy_primary
925 924
 										&& $input_value === null
926
-										&& isset( $primary_registrant[ $form_input ] )
925
+										&& isset($primary_registrant[$form_input])
927 926
 									) {
928
-										$input_value = $primary_registrant[ $form_input ];
927
+										$input_value = $primary_registrant[$form_input];
929 928
 									}
930 929
 									// now attempt to save the input data
931 930
 									if (
@@ -967,55 +966,55 @@  discard block
 block discarded – undo
967 966
 						// have we met before?
968 967
 						$attendee = $this->_find_existing_attendee(
969 968
 							$registration,
970
-							$this->_attendee_data[ $reg_url_link ]
969
+							$this->_attendee_data[$reg_url_link]
971 970
 						);
972 971
 						// did we find an already existing record for this attendee ?
973
-						if ( $attendee instanceof EE_Attendee ) {
972
+						if ($attendee instanceof EE_Attendee) {
974 973
 							$attendee = $this->_update_existing_attendee_data(
975 974
 								$attendee,
976
-								$this->_attendee_data[ $reg_url_link ]
975
+								$this->_attendee_data[$reg_url_link]
977 976
 							);
978 977
 						} else {
979 978
 							// ensure critical details are set for additional attendees
980
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
979
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
981 980
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
982
-									$this->_attendee_data[ $reg_url_link ]
981
+									$this->_attendee_data[$reg_url_link]
983 982
 								)
984
-								: $this->_attendee_data[ $reg_url_link ];
983
+								: $this->_attendee_data[$reg_url_link];
985 984
 							$attendee = $this->_create_new_attendee(
986 985
 								$registration,
987
-								$this->_attendee_data[ $reg_url_link ]
986
+								$this->_attendee_data[$reg_url_link]
988 987
 							);
989 988
 						}
990 989
 						// who's #1 ?
991
-						if ( $att_nmbr === 1 ) {
990
+						if ($att_nmbr === 1) {
992 991
 							$this->checkout->primary_attendee_obj = $attendee;
993 992
 						}
994 993
 					}
995 994
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
996 995
 					// add relation to registration, set attendee ID, and cache attendee
997
-					$this->_associate_attendee_with_registration( $registration, $attendee );
996
+					$this->_associate_attendee_with_registration($registration, $attendee);
998 997
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
999
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1000
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
998
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
999
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1001 1000
 						return false;
1002 1001
 					}
1003 1002
 					/** @type EE_Registration_Processor $registration_processor */
1004
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1003
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1005 1004
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1006
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1005
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1007 1006
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1008 1007
 					$this->checkout->transaction->toggle_failed_transaction_status();
1009 1008
 					// if we've gotten this far, then let's save what we have
1010 1009
 					$registration->save();
1011 1010
 					// add relation between TXN and registration
1012
-					$this->_associate_registration_with_transaction( $registration );
1011
+					$this->_associate_registration_with_transaction($registration);
1013 1012
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1014 1013
 
1015
-			}  else {
1016
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1014
+			} else {
1015
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1017 1016
 				// remove malformed data
1018
-				unset( $valid_data[ $reg_url_link ] );
1017
+				unset($valid_data[$reg_url_link]);
1019 1018
 				return false;
1020 1019
 			}
1021 1020
 
@@ -1044,26 +1043,26 @@  discard block
 block discarded – undo
1044 1043
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1045 1044
 		// allow for plugins to hook in and do their own processing of the form input.
1046 1045
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1047
-		if ( apply_filters(
1046
+		if (apply_filters(
1048 1047
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1049 1048
 			false,
1050 1049
 			$registration,
1051 1050
 			$form_input,
1052 1051
 			$input_value,
1053 1052
 			$this
1054
-		) ) {
1053
+		)) {
1055 1054
 			return true;
1056 1055
 		}
1057 1056
 		// $answer_cache_id is the key used to find the EE_Answer we want
1058 1057
 		$answer_cache_id = $this->checkout->reg_url_link
1059 1058
 			? $form_input
1060
-			: $form_input . '-' . $registration->reg_url_link();
1061
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1062
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1059
+			: $form_input.'-'.$registration->reg_url_link();
1060
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1061
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1063 1062
 			? true
1064 1063
 			: false;
1065 1064
 		//rename form_inputs if they are EE_Attendee properties
1066
-		switch( (string)$form_input ) {
1065
+		switch ((string) $form_input) {
1067 1066
 
1068 1067
 			case 'state' :
1069 1068
 			case 'STA_ID' :
@@ -1078,32 +1077,32 @@  discard block
 block discarded – undo
1078 1077
 				break;
1079 1078
 
1080 1079
 			default :
1081
-				$ATT_input = 'ATT_' . $form_input;
1080
+				$ATT_input = 'ATT_'.$form_input;
1082 1081
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1083
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1084
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1082
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1083
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1085 1084
 		}
1086 1085
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1087 1086
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1088 1087
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1089 1088
 		// if this form input has a corresponding attendee property
1090
-		if ( $attendee_property ) {
1091
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1092
-			if ( $answer_is_obj ) {
1089
+		if ($attendee_property) {
1090
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1091
+			if ($answer_is_obj) {
1093 1092
 				// and delete the corresponding answer since we won't be storing this data in that object
1094
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1095
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1093
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1094
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1096 1095
 			}
1097 1096
 			return true;
1098
-		} elseif ( $answer_is_obj ) {
1097
+		} elseif ($answer_is_obj) {
1099 1098
 			// save this data to the answer object
1100
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1101
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1099
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1100
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1102 1101
 			return $result !== false ? true : false;
1103 1102
 		} else {
1104
-			foreach ( $this->_registration_answers as $answer ) {
1105
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1106
-					$answer->set_value( $input_value );
1103
+			foreach ($this->_registration_answers as $answer) {
1104
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1105
+					$answer->set_value($input_value);
1107 1106
 					$result = $answer->save();
1108 1107
 					return $result !== false ? true : false;
1109 1108
 				}
@@ -1125,15 +1124,15 @@  discard block
 block discarded – undo
1125 1124
 		$form_input = '',
1126 1125
 		$input_value = ''
1127 1126
 	) {
1128
-		if ( empty( $input_value ) ) {
1127
+		if (empty($input_value)) {
1129 1128
 			// if the form input isn't marked as being required, then just return
1130
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1129
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1131 1130
 				return true;
1132 1131
 			}
1133
-			switch ( $form_input ) {
1132
+			switch ($form_input) {
1134 1133
 				case 'fname' :
1135 1134
 					EE_Error::add_error(
1136
-						__( 'First Name is a required value.', 'event_espresso' ),
1135
+						__('First Name is a required value.', 'event_espresso'),
1137 1136
 						__FILE__,
1138 1137
 						__FUNCTION__,
1139 1138
 						__LINE__
@@ -1142,7 +1141,7 @@  discard block
 block discarded – undo
1142 1141
 					break;
1143 1142
 				case 'lname' :
1144 1143
 					EE_Error::add_error(
1145
-						__( 'Last Name is a required value.', 'event_espresso' ),
1144
+						__('Last Name is a required value.', 'event_espresso'),
1146 1145
 						__FILE__,
1147 1146
 						__FUNCTION__,
1148 1147
 						__LINE__
@@ -1151,7 +1150,7 @@  discard block
 block discarded – undo
1151 1150
 					break;
1152 1151
 				case 'email' :
1153 1152
 					EE_Error::add_error(
1154
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1153
+						__('Please enter a valid email address.', 'event_espresso'),
1155 1154
 						__FILE__,
1156 1155
 						__FUNCTION__,
1157 1156
 						__LINE__
@@ -1173,30 +1172,30 @@  discard block
 block discarded – undo
1173 1172
 	 * @return boolean|EE_Attendee
1174 1173
 	 * @throws \EE_Error
1175 1174
 	 */
1176
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1175
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1177 1176
 		$existing_attendee = null;
1178 1177
 		// if none of the critical properties are set in the incoming attendee data...
1179 1178
 		// then attempt to copy them from the primary attendee
1180 1179
 		if (
1181 1180
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1182
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1181
+            && ! isset($attendee_data['ATT_fname'], $attendee_data['ATT_email'])
1183 1182
 		) {
1184 1183
 			return $this->checkout->primary_attendee_obj;
1185 1184
 		}
1186 1185
 		// does this attendee already exist in the db ?
1187 1186
 		// we're searching using a combination of first name, last name, AND email address
1188
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1187
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1189 1188
 			? $attendee_data['ATT_fname']
1190 1189
 			: '';
1191
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1190
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1192 1191
 			? $attendee_data['ATT_lname']
1193 1192
 			: '';
1194
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1193
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1195 1194
 			? $attendee_data['ATT_email']
1196 1195
 			: '';
1197 1196
 		// but only if those have values
1198
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1199
-			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee( array(
1197
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1198
+			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee(array(
1200 1199
 				'ATT_fname' => $ATT_fname,
1201 1200
 				'ATT_lname' => $ATT_lname,
1202 1201
 				'ATT_email' => $ATT_email
@@ -1220,13 +1219,13 @@  discard block
 block discarded – undo
1220 1219
 	 * @return \EE_Attendee
1221 1220
 	 * @throws \EE_Error
1222 1221
 	 */
1223
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1222
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1224 1223
 		// first remove fname, lname, and email from attendee data
1225
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1224
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1226 1225
 		// now loop thru what's left and add to attendee CPT
1227
-		foreach ( $attendee_data as $property_name => $property_value ) {
1228
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1229
-				$existing_attendee->set( $property_name, $property_value );
1226
+		foreach ($attendee_data as $property_name => $property_value) {
1227
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1228
+				$existing_attendee->set($property_name, $property_value);
1230 1229
 			}
1231 1230
 		}
1232 1231
 		// better save that now
@@ -1244,11 +1243,11 @@  discard block
 block discarded – undo
1244 1243
 	 * @return void
1245 1244
 	 * @throws \EE_Error
1246 1245
 	 */
1247
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1246
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1248 1247
 		// add relation to attendee
1249
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1250
-		$registration->set_attendee_id( $attendee->ID() );
1251
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1248
+		$registration->_add_relation_to($attendee, 'Attendee');
1249
+		$registration->set_attendee_id($attendee->ID());
1250
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1252 1251
 	}
1253 1252
 
1254 1253
 
@@ -1260,10 +1259,10 @@  discard block
 block discarded – undo
1260 1259
 	 * @return void
1261 1260
 	 * @throws \EE_Error
1262 1261
 	 */
1263
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1262
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1264 1263
 		// add relation to attendee
1265
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1266
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1264
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1265
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1267 1266
 	}
1268 1267
 
1269 1268
 
@@ -1276,14 +1275,14 @@  discard block
 block discarded – undo
1276 1275
 	 * @return array
1277 1276
 	 * @throws \EE_Error
1278 1277
 	 */
1279
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1278
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1280 1279
 		// bare minimum critical details include first name, last name, email address
1281
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1280
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1282 1281
 		// add address info to critical details?
1283
-		if ( apply_filters(
1282
+		if (apply_filters(
1284 1283
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1285 1284
 			false
1286
-		) ) {
1285
+		)) {
1287 1286
 			$address_details = array(
1288 1287
 				'ATT_address',
1289 1288
 				'ATT_address2',
@@ -1293,13 +1292,13 @@  discard block
 block discarded – undo
1293 1292
 				'ATT_zip',
1294 1293
 				'ATT_phone'
1295 1294
 			);
1296
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1295
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1297 1296
 		}
1298
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1299
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1300
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1297
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1298
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1299
+			     || empty($attendee_data[$critical_attendee_detail])
1301 1300
 			) {
1302
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1301
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1303 1302
 					$critical_attendee_detail
1304 1303
 				);
1305 1304
 			}
@@ -1317,11 +1316,11 @@  discard block
 block discarded – undo
1317 1316
 	 * @return \EE_Attendee
1318 1317
 	 * @throws \EE_Error
1319 1318
 	 */
1320
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1319
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1321 1320
 		// create new attendee object
1322
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1321
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1323 1322
 		// set author to event creator
1324
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1323
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1325 1324
 		$new_attendee->save();
1326 1325
 		return $new_attendee;
1327 1326
 	}
@@ -1338,7 +1337,7 @@  discard block
 block discarded – undo
1338 1337
 	 */
1339 1338
 	public function update_reg_step() {
1340 1339
 		// save everything
1341
-		if ( $this->process_reg_step() ) {
1340
+		if ($this->process_reg_step()) {
1342 1341
 			$this->checkout->redirect = true;
1343 1342
 			$this->checkout->redirect_url = add_query_arg(
1344 1343
 				array(
@@ -1347,7 +1346,7 @@  discard block
 block discarded – undo
1347 1346
 				),
1348 1347
 				$this->checkout->thank_you_page_url
1349 1348
 			);
1350
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1349
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1351 1350
 			return true;
1352 1351
 		}
1353 1352
 		return false;
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Field_Base.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      * @param string $table_column
16 16
      * @param string $nicename
17 17
      * @param bool   $nullable
18
-     * @param null   $default_value
18
+     * @param string|null   $default_value
19 19
      */
20 20
     public function __construct($table_column, $nicename, $nullable, $default_value = null)
21 21
     {
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@
 block discarded – undo
11 11
 abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param string $table_column
16
-     * @param string $nicename
17
-     * @param bool   $nullable
18
-     * @param null   $default_value
19
-     */
20
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
-    {
22
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
23
-        $this->setSchemaReadOnly(true);
24
-    }
14
+	/**
15
+	 * @param string $table_column
16
+	 * @param string $nicename
17
+	 * @param bool   $nullable
18
+	 * @param null   $default_value
19
+	 */
20
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
+	{
22
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
23
+		$this->setSchemaReadOnly(true);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * All these children classes are for the db-only (meaning, we should select them
29
-     * on get_all queries, update, delete, and will still want to set their default value
30
-     * on inserts, but the model object won't have reference to these fields)
31
-     *
32
-     * @return boolean
33
-     */
34
-    function is_db_only_field()
35
-    {
36
-        return true;
37
-    }
27
+	/**
28
+	 * All these children classes are for the db-only (meaning, we should select them
29
+	 * on get_all queries, update, delete, and will still want to set their default value
30
+	 * on inserts, but the model object won't have reference to these fields)
31
+	 *
32
+	 * @return boolean
33
+	 */
34
+	function is_db_only_field()
35
+	{
36
+		return true;
37
+	}
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      * @param string $table_column
14 14
      * @param string $nicename
15 15
      * @param bool   $nullable
16
-     * @param null   $default_value
16
+     * @param string   $default_value
17 17
      */
18 18
     public function __construct($table_column, $nicename, $nullable, $default_value = null)
19 19
     {
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,48 +9,48 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Email_Field extends EE_Text_Field_Base
11 11
 {
12
-    /**
13
-     * @param string $table_column
14
-     * @param string $nicename
15
-     * @param bool   $nullable
16
-     * @param null   $default_value
17
-     */
18
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
-    {
20
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
21
-        $this->setSchemaFormat('email');
22
-    }
12
+	/**
13
+	 * @param string $table_column
14
+	 * @param string $nicename
15
+	 * @param bool   $nullable
16
+	 * @param null   $default_value
17
+	 */
18
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
+	{
20
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
21
+		$this->setSchemaFormat('email');
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * In form inputs, we should have called htmlentities and addslashes() on form inputs,
27
-     * so we need to undo that on setting of these fields
28
-     *
29
-     * @param string $email_address
30
-     * @return string
31
-     */
32
-    function prepare_for_set($email_address)
33
-    {
34
-        $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
35
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
36
-            : 'wp_default';
37
-        if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
38
-            // email not even in correct {string}@{string} format
39
-            return '';
40
-        } else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
41
-            //not a valid email.
42
-            return '';
43
-        } else if (
44
-            ($validation_level === 'i18n' || $validation_level === 'i18n_dns')
45
-            // plz see http://stackoverflow.com/a/24817336 re: the following regex
46
-            && ! preg_match(
47
-                '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
48
-                $email_address
49
-            )
50
-        ) {
51
-            //not a valid email.
52
-            return '';
53
-        }
54
-        return $email_address;
55
-    }
25
+	/**
26
+	 * In form inputs, we should have called htmlentities and addslashes() on form inputs,
27
+	 * so we need to undo that on setting of these fields
28
+	 *
29
+	 * @param string $email_address
30
+	 * @return string
31
+	 */
32
+	function prepare_for_set($email_address)
33
+	{
34
+		$validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
35
+			? EE_Registry::instance()->CFG->registration->email_validation_level
36
+			: 'wp_default';
37
+		if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
38
+			// email not even in correct {string}@{string} format
39
+			return '';
40
+		} else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
41
+			//not a valid email.
42
+			return '';
43
+		} else if (
44
+			($validation_level === 'i18n' || $validation_level === 'i18n_dns')
45
+			// plz see http://stackoverflow.com/a/24817336 re: the following regex
46
+			&& ! preg_match(
47
+				'/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
48
+				$email_address
49
+			)
50
+		) {
51
+			//not a valid email.
52
+			return '';
53
+		}
54
+		return $email_address;
55
+	}
56 56
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * @param string $table_column
13 13
      * @param string $nicename
14 14
      * @param bool   $nullable
15
-     * @param null   $default_value
15
+     * @param integer|null   $default_value
16 16
      */
17 17
     public function __construct($table_column, $nicename, $nullable, $default_value = null)
18 18
     {
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
28 28
      * Returns a float
29 29
      *
30
-     * @param type $value_inputted_for_field_on_model_object
30
+     * @param string $value_inputted_for_field_on_model_object
31 31
      * @return float
32 32
      */
33 33
     function prepare_for_set($value_inputted_for_field_on_model_object)
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,64 +8,64 @@
 block discarded – undo
8 8
 class EE_Float_Field extends EE_Model_Field_Base
9 9
 {
10 10
 
11
-    /**
12
-     * @param string $table_column
13
-     * @param string $nicename
14
-     * @param bool   $nullable
15
-     * @param null   $default_value
16
-     */
17
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
-    {
19
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
20
-        $this->setSchemaType('number');
21
-    }
11
+	/**
12
+	 * @param string $table_column
13
+	 * @param string $nicename
14
+	 * @param bool   $nullable
15
+	 * @param null   $default_value
16
+	 */
17
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
18
+	{
19
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
20
+		$this->setSchemaType('number');
21
+	}
22 22
 
23 23
 
24
-    /**
25
-     * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
26
-     * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
27
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
28
-     * Returns a float
29
-     *
30
-     * @param type $value_inputted_for_field_on_model_object
31
-     * @return float
32
-     */
33
-    function prepare_for_set($value_inputted_for_field_on_model_object)
34
-    {
24
+	/**
25
+	 * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
26
+	 * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
27
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
28
+	 * Returns a float
29
+	 *
30
+	 * @param type $value_inputted_for_field_on_model_object
31
+	 * @return float
32
+	 */
33
+	function prepare_for_set($value_inputted_for_field_on_model_object)
34
+	{
35 35
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
36
-        //remove whitespaces and thousands separators
37
-        if (is_string($value_inputted_for_field_on_model_object)) {
38
-            $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds),
39
-                "", $value_inputted_for_field_on_model_object);
36
+		//remove whitespaces and thousands separators
37
+		if (is_string($value_inputted_for_field_on_model_object)) {
38
+			$value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds),
39
+				"", $value_inputted_for_field_on_model_object);
40 40
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
41 41
 //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
42
-            $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".",
43
-                $value_inputted_for_field_on_model_object);
42
+			$value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".",
43
+				$value_inputted_for_field_on_model_object);
44 44
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
45 45
 //double-check there's absolutely nothing left on this string besides numbers
46
-            $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "",
47
-                $value_inputted_for_field_on_model_object);
48
-        }
46
+			$value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "",
47
+				$value_inputted_for_field_on_model_object);
48
+		}
49 49
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
50
-        return floatval($value_inputted_for_field_on_model_object);
51
-    }
50
+		return floatval($value_inputted_for_field_on_model_object);
51
+	}
52 52
 
53
-    /**
54
-     * Returns the number formatted according to local custom (set by the country of the blog).
55
-     *
56
-     * @param float $value_on_field_to_be_outputted
57
-     * @return string
58
-     */
59
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
60
-    {
61
-        $EE = EE_Registry::instance();
62
-        return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk,
63
-            $EE->CFG->currency->thsnds);
64
-    }
53
+	/**
54
+	 * Returns the number formatted according to local custom (set by the country of the blog).
55
+	 *
56
+	 * @param float $value_on_field_to_be_outputted
57
+	 * @return string
58
+	 */
59
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
60
+	{
61
+		$EE = EE_Registry::instance();
62
+		return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk,
63
+			$EE->CFG->currency->thsnds);
64
+	}
65 65
 
66
-    function prepare_for_set_from_db($value_found_in_db_for_model_object)
67
-    {
66
+	function prepare_for_set_from_db($value_found_in_db_for_model_object)
67
+	{
68 68
 //		echo "prepare for set from db of ";d($value_found_in_db_for_model_object);
69
-        return floatval($value_found_in_db_for_model_object);
70
-    }
69
+		return floatval($value_found_in_db_for_model_object);
70
+	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.