Completed
Branch master (1e27e5)
by
unknown
21:34 queued 19:27
created
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +1788 added lines, -1788 removed lines patch added patch discarded remove patch
@@ -19,1792 +19,1792 @@
 block discarded – undo
19 19
  */
20 20
 class EED_Single_Page_Checkout extends EED_Module
21 21
 {
22
-    /**
23
-     * $_initialized - has the SPCO controller already been initialized ?
24
-     *
25
-     * @var bool $_initialized
26
-     */
27
-    private static $_initialized = false;
28
-
29
-
30
-    /**
31
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
32
-     *
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
-     * @var array $_reg_steps_array
41
-     */
42
-    private static $_reg_steps_array = array();
43
-
44
-    /**
45
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
46
-     *
47
-     * @var EE_Checkout $checkout
48
-     */
49
-    public $checkout;
50
-
51
-    /**
52
-     * @var RequestInterface $request
53
-     */
54
-    protected $request;
55
-
56
-
57
-    /**
58
-     * @return EED_Single_Page_Checkout|EED_Module
59
-     * @throws EE_Error
60
-     * @throws ReflectionException
61
-     */
62
-    public static function instance()
63
-    {
64
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
65
-        return parent::get_instance(__CLASS__);
66
-    }
67
-
68
-
69
-    /**
70
-     * @return EE_CART
71
-     */
72
-    public function cart()
73
-    {
74
-        return $this->checkout->cart;
75
-    }
76
-
77
-
78
-    /**
79
-     * @return RequestInterface
80
-     * @since   4.10.14.p
81
-     */
82
-    public static function getRequest()
83
-    {
84
-        return LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
-    }
86
-
87
-
88
-    /**
89
-     * @return EE_Transaction
90
-     */
91
-    public function transaction()
92
-    {
93
-        return $this->checkout->transaction;
94
-    }
95
-
96
-
97
-    /**
98
-     *    set_hooks - for hooking into EE Core, other modules, etc
99
-     *
100
-     * @return    void
101
-     * @throws EE_Error
102
-     */
103
-    public static function set_hooks()
104
-    {
105
-        EED_Single_Page_Checkout::set_definitions();
106
-    }
107
-
108
-
109
-    /**
110
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
111
-     *
112
-     * @return    void
113
-     * @throws EE_Error
114
-     */
115
-    public static function set_hooks_admin()
116
-    {
117
-        EED_Single_Page_Checkout::set_definitions();
118
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
119
-            return;
120
-        }
121
-        // going to start an output buffer in case anything gets accidentally output
122
-        // that might disrupt our JSON response
123
-        ob_start();
124
-        EED_Single_Page_Checkout::load_reg_steps();
125
-        // set ajax hooks
126
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
127
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
128
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
129
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
130
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
131
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
132
-    }
133
-
134
-
135
-    /**
136
-     *    process ajax request
137
-     *
138
-     * @param string $ajax_action
139
-     * @throws EE_Error
140
-     * @throws ReflectionException
141
-     */
142
-    public static function process_ajax_request($ajax_action)
143
-    {
144
-        $request = EED_Single_Page_Checkout::getRequest();
145
-        $request->setRequestParam('action', $ajax_action);
146
-        EED_Single_Page_Checkout::instance()->_initialize();
147
-    }
148
-
149
-
150
-    /**
151
-     * ajax display registration step
152
-     *
153
-     * @throws EE_Error
154
-     * @throws ReflectionException
155
-     */
156
-    public static function display_reg_step()
157
-    {
158
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
159
-    }
160
-
161
-
162
-    /**
163
-     * ajax process registration step
164
-     *
165
-     * @throws EE_Error
166
-     * @throws ReflectionException
167
-     */
168
-    public static function process_reg_step()
169
-    {
170
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
171
-    }
172
-
173
-
174
-    /**
175
-     * ajax process registration step
176
-     *
177
-     * @throws EE_Error
178
-     * @throws ReflectionException
179
-     */
180
-    public static function update_reg_step()
181
-    {
182
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
183
-    }
184
-
185
-
186
-    /**
187
-     * update_checkout
188
-     *
189
-     * @return void
190
-     * @throws ReflectionException
191
-     * @throws EE_Error
192
-     */
193
-    public static function update_checkout()
194
-    {
195
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
196
-    }
197
-
198
-
199
-    /**
200
-     * @return void
201
-     * @deprecated 4.10.14.p
202
-     */
203
-    public static function load_request_handler()
204
-    {
205
-    }
206
-
207
-
208
-    /**
209
-     *    set_definitions
210
-     *
211
-     * @return    void
212
-     * @throws EE_Error
213
-     */
214
-    public static function set_definitions()
215
-    {
216
-        if (defined('SPCO_BASE_PATH')) {
217
-            return;
218
-        }
219
-        define(
220
-            'SPCO_BASE_PATH',
221
-            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
222
-        );
223
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/');
224
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/');
225
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/');
226
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/');
227
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/');
228
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/');
229
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
230
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
231
-        );
232
-    }
233
-
234
-
235
-    /**
236
-     * load_reg_steps
237
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
238
-     *
239
-     * @throws EE_Error
240
-     */
241
-    public static function load_reg_steps()
242
-    {
243
-        static $reg_steps_loaded = false;
244
-        if ($reg_steps_loaded) {
245
-            return;
246
-        }
247
-        // filter list of reg_steps
248
-        $reg_steps_to_load = (array) apply_filters(
249
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
250
-            EED_Single_Page_Checkout::get_reg_steps()
251
-        );
252
-        // sort by key (order)
253
-        ksort($reg_steps_to_load);
254
-        // loop through folders
255
-        foreach ($reg_steps_to_load as $order => $reg_step) {
256
-            // we need a
257
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
258
-                // copy over to the reg_steps_array
259
-                EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
260
-                // register custom key route for each reg step
261
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
262
-                EE_Config::register_route(
263
-                    $reg_step['slug'],
264
-                    'EED_Single_Page_Checkout',
265
-                    'run',
266
-                    'step'
267
-                );
268
-                // add AJAX or other hooks
269
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
270
-                    // setup autoloaders if necessary
271
-                    if (! class_exists($reg_step['class_name'])) {
272
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
273
-                            $reg_step['file_path'],
274
-                            true
275
-                        );
276
-                    }
277
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
278
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
279
-                    }
280
-                }
281
-            }
282
-        }
283
-        $reg_steps_loaded = true;
284
-    }
285
-
286
-
287
-    /**
288
-     *    get_reg_steps
289
-     *
290
-     * @return    array
291
-     */
292
-    public static function get_reg_steps()
293
-    {
294
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
295
-        if (empty($reg_steps)) {
296
-            $reg_steps = array(
297
-                10  => array(
298
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
299
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
300
-                    'slug'       => 'attendee_information',
301
-                    'has_hooks'  => false,
302
-                ),
303
-                30  => array(
304
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
305
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
306
-                    'slug'       => 'payment_options',
307
-                    'has_hooks'  => true,
308
-                ),
309
-                999 => array(
310
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
311
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
312
-                    'slug'       => 'finalize_registration',
313
-                    'has_hooks'  => false,
314
-                ),
315
-            );
316
-        }
317
-        return $reg_steps;
318
-    }
319
-
320
-
321
-    /**
322
-     *    registration_checkout_for_admin
323
-     *
324
-     * @return    string
325
-     * @throws EE_Error
326
-     * @throws ReflectionException
327
-     */
328
-    public static function registration_checkout_for_admin()
329
-    {
330
-        $request = EED_Single_Page_Checkout::getRequest();
331
-        $request->setRequestParam('step', 'attendee_information');
332
-        $request->setRequestParam('action', 'display_spco_reg_step');
333
-        $request->setRequestParam('process_form_submission', false);
334
-        EED_Single_Page_Checkout::instance()->_initialize();
335
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
336
-        return EED_Single_Page_Checkout::getResponse()->getOutput();
337
-    }
338
-
339
-
340
-    /**
341
-     * process_registration_from_admin
342
-     *
343
-     * @return EE_Transaction
344
-     * @throws EE_Error
345
-     * @throws ReflectionException
346
-     */
347
-    public static function process_registration_from_admin()
348
-    {
349
-        $request = EED_Single_Page_Checkout::getRequest();
350
-        $request->setRequestParam('step', 'attendee_information');
351
-        $request->setRequestParam('action', 'process_reg_step');
352
-        $request->setRequestParam('process_form_submission', true);
353
-        EED_Single_Page_Checkout::instance()->_initialize();
354
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
355
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
356
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
357
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
358
-                if ($final_reg_step->process_reg_step()) {
359
-                    $final_reg_step->set_completed();
360
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
361
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
362
-                }
363
-            }
364
-        }
365
-        return null;
366
-    }
367
-
368
-
369
-    /**
370
-     *    run
371
-     *
372
-     * @param WP_Query $WP
373
-     * @return    void
374
-     */
375
-    public function run($WP)
376
-    {
377
-        if (
378
-            $WP instanceof WP_Query
379
-            && $WP->is_main_query()
380
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
381
-            && $this->_is_reg_checkout()
382
-        ) {
383
-            $this->_initialize();
384
-        }
385
-    }
386
-
387
-
388
-    /**
389
-     * determines whether current url matches reg page url
390
-     *
391
-     * @return bool
392
-     */
393
-    protected function _is_reg_checkout()
394
-    {
395
-        // get current permalink for reg page without any extra query args
396
-        $reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id);
397
-        // get request URI for current request, but without the scheme or host
398
-        $current_request_uri = EEH_URL::filter_input_server_url();
399
-        $current_request_uri = html_entity_decode($current_request_uri);
400
-        // get array of query args from the current request URI
401
-        $query_args = EEH_URL::get_query_string($current_request_uri);
402
-        // grab page id if it is set
403
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
404
-        // and remove the page id from the query args (we will re-add it later)
405
-        unset($query_args['page_id']);
406
-        // now strip all query args from current request URI
407
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
408
-        // and re-add the page id if it was set
409
-        if ($page_id) {
410
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
411
-        }
412
-        // remove slashes and ?
413
-        $current_request_uri = trim($current_request_uri, '?/');
414
-        // is current request URI part of the known full reg page URL ?
415
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
416
-    }
417
-
418
-
419
-    /**
420
-     * @param WP_Query $wp_query
421
-     * @return    void
422
-     * @throws EE_Error
423
-     * @throws ReflectionException
424
-     */
425
-    public static function init($wp_query)
426
-    {
427
-        EED_Single_Page_Checkout::instance()->run($wp_query);
428
-    }
429
-
430
-
431
-    /**
432
-     *    _initialize - initial module setup
433
-     *
434
-     * @return    void
435
-     */
436
-    private function _initialize()
437
-    {
438
-        // ensure SPCO doesn't run twice
439
-        if (EED_Single_Page_Checkout::$_initialized) {
440
-            return;
441
-        }
442
-        try {
443
-            $this->request = EED_Single_Page_Checkout::getRequest();
444
-            EED_Single_Page_Checkout::load_reg_steps();
445
-            $this->_verify_session();
446
-            // setup the EE_Checkout object
447
-            $this->checkout = $this->_initialize_checkout();
448
-            // filter checkout
449
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
450
-            // get the $_GET
451
-            $this->_get_request_vars();
452
-            if ($this->_block_bots()) {
453
-                return;
454
-            }
455
-            // filter continue_reg
456
-            $this->checkout->continue_reg = apply_filters(
457
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
458
-                true,
459
-                $this->checkout
460
-            );
461
-            // load the reg steps array
462
-            if (! $this->_load_and_instantiate_reg_steps()) {
463
-                EED_Single_Page_Checkout::$_initialized = true;
464
-                return;
465
-            }
466
-            // set the current step
467
-            $this->checkout->set_current_step($this->checkout->step);
468
-            // and the next step
469
-            $this->checkout->set_next_step();
470
-            // verify that everything has been setup correctly
471
-            if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
472
-                EED_Single_Page_Checkout::$_initialized = true;
473
-                return;
474
-            }
475
-            // lock the transaction
476
-            $this->checkout->transaction->lock();
477
-            // make sure all of our cached objects are added to their respective model entity mappers
478
-            $this->checkout->refresh_all_entities();
479
-            // set amount owing
480
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
481
-            // initialize each reg step, which gives them the chance to potentially alter the process
482
-            $this->_initialize_reg_steps();
483
-            // DEBUG LOG
484
-            // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
485
-            // get reg form
486
-            if (! $this->_check_form_submission()) {
487
-                EED_Single_Page_Checkout::$_initialized = true;
488
-                return;
489
-            }
490
-            // checkout the action!!!
491
-            $this->_process_form_action();
492
-            // add some style and make it dance
493
-            $this->add_styles_and_scripts($this);
494
-            // kk... SPCO has successfully run
495
-            EED_Single_Page_Checkout::$_initialized = true;
496
-            // set no cache headers and constants
497
-            EE_System::do_not_cache();
498
-            // add anchor
499
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
500
-            // remove transaction lock
501
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
502
-        } catch (Exception $e) {
503
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
504
-        }
505
-    }
506
-
507
-
508
-    /**
509
-     *    _verify_session
510
-     * checks that the session is valid and not expired
511
-     *
512
-     * @throws EE_Error
513
-     * @throws ReflectionException
514
-     */
515
-    private function _verify_session()
516
-    {
517
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
518
-            throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
519
-        }
520
-        $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool');
521
-        // is session still valid ?
522
-        if (
523
-            $clear_session_requested
524
-            || (
525
-                EE_Registry::instance()->SSN->expired()
526
-                && $this->request->getRequestParam('e_reg_url_link') === ''
527
-            )
528
-        ) {
529
-            $this->checkout = new EE_Checkout();
530
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
531
-            // EE_Registry::instance()->SSN->reset_cart();
532
-            // EE_Registry::instance()->SSN->reset_checkout();
533
-            // EE_Registry::instance()->SSN->reset_transaction();
534
-            if (! $clear_session_requested) {
535
-                EE_Error::add_attention(
536
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
537
-                    __FILE__,
538
-                    __FUNCTION__,
539
-                    __LINE__
540
-                );
541
-            }
542
-            // EE_Registry::instance()->SSN->reset_expired();
543
-        }
544
-    }
545
-
546
-
547
-    /**
548
-     *    _initialize_checkout
549
-     * loads and instantiates EE_Checkout
550
-     *
551
-     * @return EE_Checkout
552
-     * @throws EE_Error
553
-     * @throws ReflectionException
554
-     */
555
-    private function _initialize_checkout()
556
-    {
557
-        // look in session for existing checkout
558
-        /** @type EE_Checkout $checkout */
559
-        $checkout = EE_Registry::instance()->SSN->checkout();
560
-        // verify
561
-        if (! $checkout instanceof EE_Checkout) {
562
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
563
-            $checkout = EE_Registry::instance()->load_file(
564
-                SPCO_INC_PATH,
565
-                'EE_Checkout',
566
-                'class',
567
-                array(),
568
-                false
569
-            );
570
-        } else {
571
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
572
-                $this->unlock_transaction();
573
-                wp_safe_redirect($checkout->redirect_url);
574
-                exit();
575
-            }
576
-        }
577
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
578
-        // verify again
579
-        if (! $checkout instanceof EE_Checkout) {
580
-            throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
581
-        }
582
-        // reset anything that needs a clean slate for each request
583
-        $checkout->reset_for_current_request();
584
-        return $checkout;
585
-    }
586
-
587
-
588
-    /**
589
-     *    _get_request_vars
590
-     *
591
-     * @return    void
592
-     */
593
-    private function _get_request_vars()
594
-    {
595
-        // make sure this request is marked as belonging to EE
596
-        /** @var CurrentPage $current_page */
597
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
598
-        $current_page->setEspressoPage(true);
599
-        // which step is being requested ?
600
-        $this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step());
601
-        // which step is being edited ?
602
-        $this->checkout->edit_step = $this->request->getRequestParam('edit_step');
603
-        // and what we're doing on the current step
604
-        $this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step');
605
-        // timestamp
606
-        $this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int');
607
-        // returning to edit ?
608
-        $this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link');
609
-        // add reg url link to registration query params
610
-        if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
611
-            $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
612
-        }
613
-        // or some other kind of revisit ?
614
-        $this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool');
615
-        // and whether or not to generate a reg form for this request
616
-        $this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool');
617
-        // and whether or not to process a reg form submission for this request
618
-        $this->checkout->process_form_submission = $this->request->getRequestParam(
619
-            'process_form_submission',
620
-            $this->checkout->action === 'process_reg_step',
621
-            'bool'
622
-        );
623
-        $this->checkout->process_form_submission = filter_var(
624
-            $this->checkout->action !== 'display_spco_reg_step'
625
-                ? $this->checkout->process_form_submission
626
-                : false,
627
-            FILTER_VALIDATE_BOOLEAN
628
-        );
629
-        // $this->_display_request_vars();
630
-    }
631
-
632
-
633
-    /**
634
-     *  _display_request_vars
635
-     *
636
-     * @return    void
637
-     */
638
-    protected function _display_request_vars()
639
-    {
640
-        if (! WP_DEBUG) {
641
-            return;
642
-        }
643
-        EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__);
644
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
645
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
646
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
647
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
648
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
649
-        EEH_Debug_Tools::printr(
650
-            $this->checkout->generate_reg_form,
651
-            '$this->checkout->generate_reg_form',
652
-            __FILE__,
653
-            __LINE__
654
-        );
655
-        EEH_Debug_Tools::printr(
656
-            $this->checkout->process_form_submission,
657
-            '$this->checkout->process_form_submission',
658
-            __FILE__,
659
-            __LINE__
660
-        );
661
-    }
662
-
663
-
664
-    /**
665
-     * _block_bots
666
-     * checks that the incoming request has either of the following set:
667
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
668
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
669
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
670
-     * then where you coming from man?
671
-     *
672
-     * @return boolean
673
-     */
674
-    private function _block_bots()
675
-    {
676
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
677
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
678
-            return true;
679
-        }
680
-        return false;
681
-    }
682
-
683
-
684
-    /**
685
-     *    _get_first_step
686
-     *  gets slug for first step in $_reg_steps_array
687
-     *
688
-     * @return    string
689
-     */
690
-    private function _get_first_step()
691
-    {
692
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
693
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
694
-    }
695
-
696
-
697
-    /**
698
-     * instantiates each reg step based on the loaded reg_steps array
699
-     *
700
-     * @return    bool
701
-     * @throws EE_Error
702
-     * @throws InvalidArgumentException
703
-     * @throws InvalidDataTypeException
704
-     * @throws InvalidInterfaceException
705
-     * @throws ReflectionException
706
-     */
707
-    private function _load_and_instantiate_reg_steps()
708
-    {
709
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
710
-        // have reg_steps already been instantiated ?
711
-        if (
712
-            empty($this->checkout->reg_steps)
713
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
714
-        ) {
715
-            // if not, then loop through raw reg steps array
716
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
717
-                if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
718
-                    return false;
719
-                }
720
-            }
721
-            if (isset($this->checkout->reg_steps['registration_confirmation'])) {
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
-                } elseif (
727
-                    EE_Registry::instance()->CFG->registration->reg_confirmation_last
728
-                ) {
729
-                    // set the order to something big like 100
730
-                    $this->checkout->set_reg_step_order('registration_confirmation');
731
-                }
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(
748
-                esc_html__('No Reg Steps were loaded..', 'event_espresso'),
749
-                __FILE__,
750
-                __FUNCTION__,
751
-                __LINE__
752
-            );
753
-            return false;
754
-        }
755
-        // make reg step details available to JS
756
-        $this->checkout->set_reg_step_JSON_info();
757
-        return true;
758
-    }
759
-
760
-
761
-    /**
762
-     *     _load_and_instantiate_reg_step
763
-     *
764
-     * @param array $reg_step
765
-     * @param int   $order
766
-     * @return bool
767
-     * @throws EE_Error
768
-     * @throws ReflectionException
769
-     */
770
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
771
-    {
772
-        // we need a file_path, class_name, and slug to add a reg step
773
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
774
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
775
-            if (
776
-                $this->checkout->reg_url_link
777
-                && $this->checkout->step !== $reg_step['slug']
778
-                && $reg_step['slug'] !== 'finalize_registration'
779
-                // normally at this point we would NOT load the reg step, but this filter can change that
780
-                && apply_filters(
781
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
782
-                    true,
783
-                    $reg_step,
784
-                    $this->checkout
785
-                )
786
-            ) {
787
-                return true;
788
-            }
789
-
790
-            // instantiate step class using file path and class name
791
-            $reg_step_obj = EE_Registry::instance()->load_file(
792
-                $reg_step['file_path'],
793
-                $reg_step['class_name'],
794
-                'class',
795
-                [$this->checkout],
796
-                false
797
-            );
798
-            // did we gets the goods ?
799
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
800
-                // set reg step order based on config
801
-                $reg_step_obj->set_order($order);
802
-                // add instantiated reg step object to the master reg steps array
803
-                $this->checkout->add_reg_step($reg_step_obj);
804
-            } else {
805
-                EE_Error::add_error(
806
-                    esc_html__('The current step could not be set.', 'event_espresso'),
807
-                    __FILE__,
808
-                    __FUNCTION__,
809
-                    __LINE__
810
-                );
811
-                return false;
812
-            }
813
-        } else {
814
-            if (WP_DEBUG) {
815
-                EE_Error::add_error(
816
-                    sprintf(
817
-                        esc_html__(
818
-                            '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',
819
-                            'event_espresso'
820
-                        ),
821
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
822
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
823
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
824
-                        '<ul>',
825
-                        '<li>',
826
-                        '</li>',
827
-                        '</ul>'
828
-                    ),
829
-                    __FILE__,
830
-                    __FUNCTION__,
831
-                    __LINE__
832
-                );
833
-            }
834
-            return false;
835
-        }
836
-        return true;
837
-    }
838
-
839
-
840
-    /**
841
-     * _verify_transaction_and_get_registrations
842
-     *
843
-     * @return bool
844
-     * @throws EE_Error
845
-     * @throws ReflectionException
846
-     */
847
-    private function _verify_transaction_and_get_registrations()
848
-    {
849
-        // was there already a valid transaction in the checkout from the session ?
850
-        if (! $this->checkout->transaction instanceof EE_Transaction) {
851
-            // get transaction from db or session
852
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
853
-                ? $this->_get_transaction_and_cart_for_previous_visit()
854
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
855
-            if (! $this->checkout->transaction instanceof EE_Transaction) {
856
-                EE_Error::add_error(
857
-                    esc_html__(
858
-                        'Your Registration and Transaction information could not be retrieved from the db.',
859
-                        'event_espresso'
860
-                    ),
861
-                    __FILE__,
862
-                    __FUNCTION__,
863
-                    __LINE__
864
-                );
865
-                $this->checkout->transaction = EE_Transaction::new_instance();
866
-                // add some style and make it dance
867
-                $this->add_styles_and_scripts($this);
868
-                EED_Single_Page_Checkout::$_initialized = true;
869
-                return false;
870
-            }
871
-            // and the registrations for the transaction
872
-            $this->_get_registrations($this->checkout->transaction);
873
-        }
874
-        return true;
875
-    }
876
-
877
-
878
-    /**
879
-     * _get_transaction_and_cart_for_previous_visit
880
-     *
881
-     * @return EE_Transaction|null
882
-     * @throws EE_Error
883
-     * @throws ReflectionException
884
-     */
885
-    private function _get_transaction_and_cart_for_previous_visit()
886
-    {
887
-        /** @var $TXN_model EEM_Transaction */
888
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
889
-        // because the reg_url_link is present in the request,
890
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
891
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
892
-        // verify transaction
893
-        if ($transaction instanceof EE_Transaction) {
894
-            // and get the cart that was used for that transaction
895
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
896
-            return $transaction;
897
-        }
898
-        EE_Error::add_error(
899
-            esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
900
-            __FILE__,
901
-            __FUNCTION__,
902
-            __LINE__
903
-        );
904
-        return null;
905
-    }
906
-
907
-
908
-    /**
909
-     * _get_cart_for_transaction
910
-     *
911
-     * @param EE_Transaction $transaction
912
-     * @return EE_Cart
913
-     */
914
-    private function _get_cart_for_transaction($transaction)
915
-    {
916
-        return $this->checkout->get_cart_for_transaction($transaction);
917
-    }
918
-
919
-
920
-    /**
921
-     * get_cart_for_transaction
922
-     *
923
-     * @param EE_Transaction $transaction
924
-     * @return EE_Cart
925
-     */
926
-    public function get_cart_for_transaction(EE_Transaction $transaction)
927
-    {
928
-        return $this->checkout->get_cart_for_transaction($transaction);
929
-    }
930
-
931
-
932
-    /**
933
-     * _get_transaction_and_cart_for_current_session
934
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
935
-     *
936
-     * @return EE_Transaction
937
-     * @throws EE_Error
938
-     * @throws ReflectionException
939
-     */
940
-    private function _get_cart_for_current_session_and_setup_new_transaction()
941
-    {
942
-        //  if there's no transaction, then this is the FIRST visit to SPCO
943
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
944
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
945
-        // and then create a new transaction
946
-        $transaction = $this->_initialize_transaction();
947
-        // verify transaction
948
-        if ($transaction instanceof EE_Transaction) {
949
-            // save it so that we have an ID for other objects to use
950
-            $transaction->save();
951
-            // and save TXN data to the cart
952
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
953
-        } else {
954
-            EE_Error::add_error(
955
-                esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'),
956
-                __FILE__,
957
-                __FUNCTION__,
958
-                __LINE__
959
-            );
960
-        }
961
-        return $transaction;
962
-    }
963
-
964
-
965
-    /**
966
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
967
-     *
968
-     * @return EE_Transaction|null
969
-     */
970
-    private function _initialize_transaction()
971
-    {
972
-        try {
973
-            // ensure cart totals have been calculated
974
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
975
-            // grab the cart grand total
976
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
977
-            // create new TXN
978
-            $transaction = EE_Transaction::new_instance(
979
-                array(
980
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
981
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
982
-                    'TXN_paid'      => 0,
983
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
984
-                )
985
-            );
986
-            // save it so that we have an ID for other objects to use
987
-            $transaction->save();
988
-            // set cron job for following up on TXNs after their session has expired
989
-            EE_Cron_Tasks::schedule_expired_transaction_check(
990
-                EE_Registry::instance()->SSN->expiration() + 1,
991
-                $transaction->ID()
992
-            );
993
-            return $transaction;
994
-        } catch (Exception $e) {
995
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
996
-        }
997
-        return null;
998
-    }
999
-
1000
-
1001
-    /**
1002
-     * _get_registrations
1003
-     *
1004
-     * @param EE_Transaction $transaction
1005
-     * @return void
1006
-     * @throws EE_Error
1007
-     * @throws ReflectionException
1008
-     */
1009
-    private function _get_registrations(EE_Transaction $transaction)
1010
-    {
1011
-        // first step: grab the registrants  { : o
1012
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params);
1013
-        $this->checkout->total_ticket_count = count($registrations);
1014
-        // verify registrations have been set
1015
-        if (empty($registrations)) {
1016
-            // if no cached registrations, then check the db
1017
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params);
1018
-            // still nothing ? well as long as this isn't a revisit
1019
-            if (empty($registrations) && ! $this->checkout->revisit) {
1020
-                // generate new registrations from scratch
1021
-                $registrations = $this->_initialize_registrations($transaction);
1022
-            }
1023
-        }
1024
-        // sort by their original registration order
1025
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1026
-        // then loop thru the array
1027
-        foreach ($registrations as $registration) {
1028
-            // verify each registration
1029
-            if ($registration instanceof EE_Registration) {
1030
-                // we display all attendee info for the primary registrant
1031
-                if (
1032
-                    $this->checkout->reg_url_link === $registration->reg_url_link()
1033
-                    && $registration->is_primary_registrant()
1034
-                ) {
1035
-                    $this->checkout->primary_revisit = true;
1036
-                    break;
1037
-                }
1038
-                if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1039
-                    // but hide info if it doesn't belong to you
1040
-                    $transaction->clear_cache('Registration', $registration->ID());
1041
-                    $this->checkout->total_ticket_count--;
1042
-                }
1043
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1044
-            }
1045
-        }
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1051
-     *
1052
-     * @param EE_Transaction $transaction
1053
-     * @return    array
1054
-     * @throws EE_Error
1055
-     * @throws ReflectionException
1056
-     */
1057
-    private function _initialize_registrations(EE_Transaction $transaction)
1058
-    {
1059
-        $att_nmbr = 0;
1060
-        $registrations = array();
1061
-        if ($transaction instanceof EE_Transaction) {
1062
-            /** @type EE_Registration_Processor $registration_processor */
1063
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1064
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1065
-            // now let's add the cart items to the $transaction
1066
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1067
-                // do the following for each ticket of this type they selected
1068
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1069
-                    $att_nmbr++;
1070
-                    /** @var CreateRegistrationCommand $CreateRegistrationCommand */
1071
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1072
-                        CreateRegistrationCommand::class,
1073
-                        [
1074
-                            $transaction,
1075
-                            $line_item,
1076
-                            $att_nmbr,
1077
-                            $this->checkout->total_ticket_count,
1078
-                        ]
1079
-                    );
1080
-                    // override capabilities for frontend registrations
1081
-                    if ($this->request->isFrontend()) {
1082
-                        $CreateRegistrationCommand->setCapCheck(
1083
-                            new PublicCapabilities('', 'create_new_registration')
1084
-                        );
1085
-                    }
1086
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1087
-                    if (! $registration instanceof EE_Registration) {
1088
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1089
-                    }
1090
-                    $registrations[ $registration->ID() ] = $registration;
1091
-                }
1092
-            }
1093
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1094
-        }
1095
-        return $registrations;
1096
-    }
1097
-
1098
-
1099
-    /**
1100
-     * sorts registrations by REG_count
1101
-     *
1102
-     * @param EE_Registration $reg_A
1103
-     * @param EE_Registration $reg_B
1104
-     * @return int
1105
-     */
1106
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1107
-    {
1108
-        // this shouldn't ever happen within the same TXN, but oh well
1109
-        if ($reg_A->count() === $reg_B->count()) {
1110
-            return 0;
1111
-        }
1112
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1113
-    }
1114
-
1115
-
1116
-    /**
1117
-     *    _final_verifications
1118
-     * just makes sure that everything is set up correctly before proceeding
1119
-     *
1120
-     * @return    bool
1121
-     * @throws EE_Error
1122
-     * @throws ReflectionException
1123
-     */
1124
-    private function _final_verifications()
1125
-    {
1126
-        // filter checkout
1127
-        $this->checkout = apply_filters(
1128
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1129
-            $this->checkout
1130
-        );
1131
-        // verify that current step is still set correctly
1132
-        if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1133
-            EE_Error::add_error(
1134
-                esc_html__(
1135
-                    '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.',
1136
-                    'event_espresso'
1137
-                ),
1138
-                __FILE__,
1139
-                __FUNCTION__,
1140
-                __LINE__
1141
-            );
1142
-            return false;
1143
-        }
1144
-        // if returning to SPCO, then verify that primary registrant is set
1145
-        if (! empty($this->checkout->reg_url_link)) {
1146
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1147
-            if (! $valid_registrant instanceof EE_Registration) {
1148
-                EE_Error::add_error(
1149
-                    esc_html__(
1150
-                        '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.',
1151
-                        'event_espresso'
1152
-                    ),
1153
-                    __FILE__,
1154
-                    __FUNCTION__,
1155
-                    __LINE__
1156
-                );
1157
-                return false;
1158
-            }
1159
-            $valid_registrant = null;
1160
-            foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1161
-                if (
1162
-                    $registration instanceof EE_Registration
1163
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1164
-                ) {
1165
-                    $valid_registrant = $registration;
1166
-                }
1167
-            }
1168
-            if (! $valid_registrant instanceof EE_Registration) {
1169
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1170
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1171
-                    // clear the session, mark the checkout as unverified, and try again
1172
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1173
-                    EED_Single_Page_Checkout::$_initialized = false;
1174
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1175
-                    $this->_initialize();
1176
-                    EE_Error::reset_notices();
1177
-                    return false;
1178
-                }
1179
-                EE_Error::add_error(
1180
-                    esc_html__(
1181
-                        '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.',
1182
-                        'event_espresso'
1183
-                    ),
1184
-                    __FILE__,
1185
-                    __FUNCTION__,
1186
-                    __LINE__
1187
-                );
1188
-                return false;
1189
-            }
1190
-        }
1191
-        // now that things have been kinda sufficiently verified,
1192
-        // let's add the checkout to the session so that it's available to other systems
1193
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1194
-        return true;
1195
-    }
1196
-
1197
-
1198
-    /**
1199
-     *    _initialize_reg_steps
1200
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1201
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1202
-     *
1203
-     * @param bool $reinitializing
1204
-     * @throws EE_Error
1205
-     */
1206
-    private function _initialize_reg_steps($reinitializing = false)
1207
-    {
1208
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1209
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1210
-        foreach ($this->checkout->reg_steps as $reg_step) {
1211
-            if (! $reg_step->initialize_reg_step()) {
1212
-                // if not initialized then maybe this step is being removed...
1213
-                if (! $reinitializing && $reg_step->is_current_step()) {
1214
-                    // if it was the current step, then we need to start over here
1215
-                    $this->_initialize_reg_steps(true);
1216
-                    return;
1217
-                }
1218
-                continue;
1219
-            }
1220
-            // add css and JS for current step
1221
-            $this->add_styles_and_scripts($reg_step);
1222
-            if ($reg_step->is_current_step()) {
1223
-                // the text that appears on the reg step form submit button
1224
-                $reg_step->set_submit_button_text();
1225
-            }
1226
-        }
1227
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1228
-        do_action(
1229
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1230
-            $this->checkout->current_step
1231
-        );
1232
-    }
1233
-
1234
-
1235
-    /**
1236
-     * _check_form_submission
1237
-     *
1238
-     * @return boolean
1239
-     * @throws EE_Error
1240
-     * @throws ReflectionException
1241
-     */
1242
-    private function _check_form_submission()
1243
-    {
1244
-        // does this request require the reg form to be generated ?
1245
-        if ($this->checkout->generate_reg_form) {
1246
-            // ever heard that song by Blue Rodeo ?
1247
-            try {
1248
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1249
-                // if not displaying a form, then check for form submission
1250
-                if (
1251
-                    $this->checkout->process_form_submission
1252
-                    && $this->checkout->current_step->reg_form->was_submitted()
1253
-                ) {
1254
-                    // clear out any old data in case this step is being run again
1255
-                    $this->checkout->current_step->set_valid_data(array());
1256
-                    // capture submitted form data
1257
-                    $request_data = $this->request->requestParams();
1258
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1259
-                        (array) apply_filters(
1260
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1261
-                            $request_data,
1262
-                            $this->checkout
1263
-                        )
1264
-                    );
1265
-                    // validate submitted form data
1266
-                    if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1267
-                        // thou shall not pass !!!
1268
-                        $this->checkout->continue_reg = false;
1269
-                        // any form validation errors?
1270
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1271
-                            EE_Error::add_error(
1272
-                                $this->checkout->current_step->reg_form->submission_error_message(),
1273
-                                __FILE__,
1274
-                                __FUNCTION__,
1275
-                                __LINE__
1276
-                            );
1277
-                        }
1278
-                        // well not really... what will happen is
1279
-                        // we'll just get redirected back to redo the current step
1280
-                        $this->go_to_next_step();
1281
-                        return false;
1282
-                    }
1283
-                }
1284
-            } catch (EE_Error $e) {
1285
-                $e->get_error();
1286
-            }
1287
-        }
1288
-        return true;
1289
-    }
1290
-
1291
-
1292
-    /**
1293
-     * _process_action
1294
-     *
1295
-     * @return void
1296
-     * @throws EE_Error
1297
-     * @throws ReflectionException
1298
-     */
1299
-    private function _process_form_action()
1300
-    {
1301
-        // what cha wanna do?
1302
-        switch ($this->checkout->action) {
1303
-            // AJAX next step reg form
1304
-            case 'display_spco_reg_step':
1305
-                $this->checkout->redirect = false;
1306
-                if ($this->request->isAjax()) {
1307
-                    $this->checkout->json_response->set_reg_step_html(
1308
-                        $this->checkout->current_step->display_reg_form()
1309
-                    );
1310
-                }
1311
-                break;
1312
-            default:
1313
-                // meh... do one of those other steps first
1314
-                if (
1315
-                    ! empty($this->checkout->action)
1316
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1317
-                ) {
1318
-                    // dynamically creates hook point like:
1319
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1320
-                    do_action(
1321
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1322
-                        $this->checkout->current_step
1323
-                    );
1324
-                    $process_reg_step = apply_filters(
1325
-                        "AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1326
-                        true,
1327
-                        $this->checkout->current_step,
1328
-                        $this
1329
-                    );
1330
-                    // call action on current step
1331
-                    if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) {
1332
-                        // good registrant, you get to proceed
1333
-                        if (
1334
-                            $this->checkout->current_step->success_message() !== ''
1335
-                            && apply_filters(
1336
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1337
-                                false
1338
-                            )
1339
-                        ) {
1340
-                            EE_Error::add_success(
1341
-                                $this->checkout->current_step->success_message()
1342
-                                . '<br />' . $this->checkout->next_step->_instructions()
1343
-                            );
1344
-                        }
1345
-                        // pack it up, pack it in...
1346
-                        $this->_setup_redirect();
1347
-                    }
1348
-                    // dynamically creates hook point like:
1349
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1350
-                    do_action(
1351
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1352
-                        $this->checkout->current_step
1353
-                    );
1354
-                } else {
1355
-                    EE_Error::add_error(
1356
-                        sprintf(
1357
-                            esc_html__(
1358
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1359
-                                'event_espresso'
1360
-                            ),
1361
-                            $this->checkout->action,
1362
-                            $this->checkout->current_step->name()
1363
-                        ),
1364
-                        __FILE__,
1365
-                        __FUNCTION__,
1366
-                        __LINE__
1367
-                    );
1368
-                }
1369
-            // end default
1370
-        }
1371
-        // store our progress so far
1372
-        $this->checkout->stash_transaction_and_checkout();
1373
-        // advance to the next step! If you pass GO, collect $200
1374
-        $this->go_to_next_step();
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and
1380
-     *                                                          `enqueue_styles_and_scripts`.
1381
-     * @return        void
1382
-     */
1383
-    public function add_styles_and_scripts($target)
1384
-    {
1385
-        // i18n
1386
-        $target->translate_js_strings();
1387
-        if ($this->checkout->admin_request) {
1388
-            add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10);
1389
-        } else {
1390
-            add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10);
1391
-        }
1392
-    }
1393
-
1394
-    /**
1395
-     *        translate_js_strings
1396
-     *
1397
-     * @return        void
1398
-     */
1399
-    public function translate_js_strings()
1400
-    {
1401
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1402
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1403
-        EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
1404
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1405
-            'event_espresso'
1406
-        );
1407
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__(
1408
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1409
-            'event_espresso'
1410
-        );
1411
-        EE_Registry::$i18n_js_strings['validation_error'] = esc_html__(
1412
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1413
-            'event_espresso'
1414
-        );
1415
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
1416
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1417
-            'event_espresso'
1418
-        );
1419
-        EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__(
1420
-            'This registration step could not be completed. Please refresh the page and try again.',
1421
-            'event_espresso'
1422
-        );
1423
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__(
1424
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1425
-            'event_espresso'
1426
-        );
1427
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1428
-            esc_html__(
1429
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1430
-                'event_espresso'
1431
-            ),
1432
-            '<br/>',
1433
-            '<br/>'
1434
-        );
1435
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1436
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1437
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1438
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1439
-        EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso');
1440
-        EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso');
1441
-        EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso');
1442
-        EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso');
1443
-        EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso');
1444
-        EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso');
1445
-        EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso');
1446
-        EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso');
1447
-        EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso');
1448
-        EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso');
1449
-        EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso');
1450
-        EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso');
1451
-        EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso');
1452
-        EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso');
1453
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
1454
-        );
1455
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1456
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1457
-            true
1458
-        );
1459
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1460
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1461
-        );
1462
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1463
-            'M d, Y H:i:s',
1464
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1465
-        );
1466
-    }
1467
-
1468
-
1469
-    /**
1470
-     *    enqueue_styles_and_scripts
1471
-     *
1472
-     * @return        void
1473
-     * @throws EE_Error
1474
-     */
1475
-    public function enqueue_styles_and_scripts()
1476
-    {
1477
-        // load css
1478
-        wp_register_style(
1479
-            'single_page_checkout',
1480
-            SPCO_CSS_URL . 'single_page_checkout.css',
1481
-            array('espresso_default'),
1482
-            EVENT_ESPRESSO_VERSION
1483
-        );
1484
-        wp_enqueue_style('single_page_checkout');
1485
-        // load JS
1486
-        wp_register_script(
1487
-            'jquery_plugin',
1488
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js',
1489
-            array('jquery'),
1490
-            '1.0.1',
1491
-            true
1492
-        );
1493
-        wp_register_script(
1494
-            'jquery_countdown',
1495
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js',
1496
-            array('jquery_plugin'),
1497
-            '2.1.0',
1498
-            true
1499
-        );
1500
-        wp_register_script(
1501
-            'single_page_checkout',
1502
-            SPCO_JS_URL . 'single_page_checkout.js',
1503
-            array('espresso_core', 'underscore', 'ee_form_section_validation'),
1504
-            EVENT_ESPRESSO_VERSION,
1505
-            true
1506
-        );
1507
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1508
-            $this->checkout->registration_form->enqueue_js();
1509
-        }
1510
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1511
-            $this->checkout->current_step->reg_form->enqueue_js();
1512
-        }
1513
-        wp_enqueue_script('single_page_checkout');
1514
-        if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) {
1515
-            wp_enqueue_script('jquery_countdown');
1516
-        }
1517
-        /**
1518
-         * global action hook for enqueueing styles and scripts with
1519
-         * spco calls.
1520
-         */
1521
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1522
-        /**
1523
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1524
-         * The hook will end up being something like:
1525
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1526
-         */
1527
-        do_action(
1528
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1529
-            $this
1530
-        );
1531
-    }
1532
-
1533
-
1534
-    /**
1535
-     *    display the Registration Single Page Checkout Form
1536
-     *
1537
-     * @return    void
1538
-     * @throws EE_Error
1539
-     * @throws ReflectionException
1540
-     */
1541
-    private function _display_spco_reg_form()
1542
-    {
1543
-        // if registering via the admin, just display the reg form for the current step
1544
-        if ($this->checkout->admin_request) {
1545
-            EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form());
1546
-        } else {
1547
-            // add powered by EE msg
1548
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1549
-            $empty_cart = count(
1550
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1551
-            ) < 1;
1552
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1553
-            $cookies_not_set_msg = '';
1554
-            if ($empty_cart) {
1555
-                $cookies_not_set_msg = apply_filters(
1556
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1557
-                    sprintf(
1558
-                        esc_html__(
1559
-                            '%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',
1560
-                            'event_espresso'
1561
-                        ),
1562
-                        '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1563
-                        '</div>',
1564
-                        '<h6 class="important-notice">',
1565
-                        '</h6>',
1566
-                        '<p>',
1567
-                        '</p>',
1568
-                        '<br />',
1569
-                        '<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">',
1570
-                        '</a>'
1571
-                    )
1572
-                );
1573
-            }
1574
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1575
-                array(
1576
-                    'name'            => 'single-page-checkout',
1577
-                    'html_id'         => 'ee-single-page-checkout-dv',
1578
-                    'layout_strategy' =>
1579
-                        new EE_Template_Layout(
1580
-                            array(
1581
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1582
-                                'template_args'        => array(
1583
-                                    'empty_cart'              => $empty_cart,
1584
-                                    'revisit'                 => $this->checkout->revisit,
1585
-                                    'reg_steps'               => $this->checkout->reg_steps,
1586
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1587
-                                        ? $this->checkout->next_step->slug()
1588
-                                        : '',
1589
-                                    'empty_msg'               => apply_filters(
1590
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1591
-                                        sprintf(
1592
-                                            esc_html__(
1593
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1594
-                                                'event_espresso'
1595
-                                            ),
1596
-                                            '<a href="'
1597
-                                            . get_post_type_archive_link('espresso_events')
1598
-                                            . '" title="',
1599
-                                            '">',
1600
-                                            '</a>'
1601
-                                        )
1602
-                                    ),
1603
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1604
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1605
-                                    'session_expiration'      => gmdate(
1606
-                                        'M d, Y H:i:s',
1607
-                                        EE_Registry::instance()->SSN->expiration()
1608
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1609
-                                    ),
1610
-                                ),
1611
-                            )
1612
-                        ),
1613
-                )
1614
-            );
1615
-            // load template and add to output sent that gets filtered into the_content()
1616
-            EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html());
1617
-        }
1618
-    }
1619
-
1620
-
1621
-    /**
1622
-     *    add_extra_finalize_registration_inputs
1623
-     *
1624
-     * @param $next_step
1625
-     * @internal  param string $label
1626
-     * @return void
1627
-     */
1628
-    public function add_extra_finalize_registration_inputs($next_step)
1629
-    {
1630
-        if ($next_step === 'finalize_registration') {
1631
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1632
-        }
1633
-    }
1634
-
1635
-
1636
-    /**
1637
-     *    display_registration_footer
1638
-     *
1639
-     * @return    string
1640
-     */
1641
-    public static function display_registration_footer()
1642
-    {
1643
-        if (
1644
-            apply_filters(
1645
-                'FHEE__EE_Front__Controller__show_reg_footer',
1646
-                EE_Registry::instance()->CFG->admin->show_reg_footer
1647
-            )
1648
-        ) {
1649
-            add_filter(
1650
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1651
-                function ($url) {
1652
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1653
-                }
1654
-            );
1655
-            echo apply_filters(
1656
-                'FHEE__EE_Front_Controller__display_registration_footer',
1657
-                EEH_Template::powered_by_event_espresso(
1658
-                    '',
1659
-                    'espresso-registration-footer-dv',
1660
-                    array('utm_content' => 'registration_checkout')
1661
-                )
1662
-            );
1663
-        }
1664
-        return '';
1665
-    }
1666
-
1667
-
1668
-    /**
1669
-     *    unlock_transaction
1670
-     *
1671
-     * @return    void
1672
-     * @throws EE_Error
1673
-     * @throws ReflectionException
1674
-     */
1675
-    public function unlock_transaction()
1676
-    {
1677
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1678
-            $this->checkout->transaction->unlock();
1679
-        }
1680
-    }
1681
-
1682
-
1683
-    /**
1684
-     *        _setup_redirect
1685
-     *
1686
-     * @return void
1687
-     */
1688
-    private function _setup_redirect()
1689
-    {
1690
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1691
-            $this->checkout->redirect = true;
1692
-            if (empty($this->checkout->redirect_url)) {
1693
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1694
-            }
1695
-            $this->checkout->redirect_url = apply_filters(
1696
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1697
-                $this->checkout->redirect_url,
1698
-                $this->checkout
1699
-            );
1700
-        }
1701
-    }
1702
-
1703
-
1704
-    /**
1705
-     *   handle ajax message responses and redirects
1706
-     *
1707
-     * @return void
1708
-     * @throws EE_Error
1709
-     * @throws ReflectionException
1710
-     */
1711
-    public function go_to_next_step()
1712
-    {
1713
-        if ($this->request->isAjax()) {
1714
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1715
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1716
-        }
1717
-        $this->unlock_transaction();
1718
-        // just return for these conditions
1719
-        if (
1720
-            $this->checkout->admin_request
1721
-            || $this->checkout->action === 'redirect_form'
1722
-            || $this->checkout->action === 'update_checkout'
1723
-        ) {
1724
-            return;
1725
-        }
1726
-        // AJAX response
1727
-        $this->_handle_json_response();
1728
-        // redirect to next step or the Thank You page
1729
-        $this->_handle_html_redirects();
1730
-        // hmmm... must be something wrong, so let's just display the form again !
1731
-        $this->_display_spco_reg_form();
1732
-    }
1733
-
1734
-
1735
-    /**
1736
-     *   _handle_json_response
1737
-     *
1738
-     * @return void
1739
-     * @throws EE_Error
1740
-     */
1741
-    protected function _handle_json_response()
1742
-    {
1743
-        // if this is an ajax request
1744
-        if ($this->request->isAjax()) {
1745
-            $this->checkout->json_response->set_registration_time_limit(
1746
-                $this->checkout->get_registration_time_limit()
1747
-            );
1748
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1749
-            // just send the ajax (
1750
-            $json_response = apply_filters(
1751
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1752
-                $this->checkout->json_response
1753
-            );
1754
-            echo ($json_response);
1755
-            exit();
1756
-        }
1757
-    }
1758
-
1759
-
1760
-    /**
1761
-     *   _handle_redirects
1762
-     *
1763
-     * @return void
1764
-     */
1765
-    protected function _handle_html_redirects()
1766
-    {
1767
-        // going somewhere ?
1768
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1769
-            // store notices in a transient
1770
-            EE_Error::get_notices(false, true);
1771
-            wp_safe_redirect($this->checkout->redirect_url);
1772
-            exit();
1773
-        }
1774
-    }
1775
-
1776
-
1777
-    /**
1778
-     *   set_checkout_anchor
1779
-     *
1780
-     * @return void
1781
-     */
1782
-    public function set_checkout_anchor()
1783
-    {
1784
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1785
-    }
1786
-
1787
-    /**
1788
-     *    getRegistrationExpirationNotice
1789
-     *
1790
-     * @since     4.9.59.p
1791
-     * @return    string
1792
-     */
1793
-    public static function getRegistrationExpirationNotice()
1794
-    {
1795
-        return sprintf(
1796
-            esc_html__(
1797
-                '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1798
-                'event_espresso'
1799
-            ),
1800
-            '<h4 class="important-notice">',
1801
-            '</h4>',
1802
-            '<br />',
1803
-            '<p>',
1804
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1805
-            '">',
1806
-            '</a>',
1807
-            '</p>'
1808
-        );
1809
-    }
22
+	/**
23
+	 * $_initialized - has the SPCO controller already been initialized ?
24
+	 *
25
+	 * @var bool $_initialized
26
+	 */
27
+	private static $_initialized = false;
28
+
29
+
30
+	/**
31
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
32
+	 *
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
+	 * @var array $_reg_steps_array
41
+	 */
42
+	private static $_reg_steps_array = array();
43
+
44
+	/**
45
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
46
+	 *
47
+	 * @var EE_Checkout $checkout
48
+	 */
49
+	public $checkout;
50
+
51
+	/**
52
+	 * @var RequestInterface $request
53
+	 */
54
+	protected $request;
55
+
56
+
57
+	/**
58
+	 * @return EED_Single_Page_Checkout|EED_Module
59
+	 * @throws EE_Error
60
+	 * @throws ReflectionException
61
+	 */
62
+	public static function instance()
63
+	{
64
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
65
+		return parent::get_instance(__CLASS__);
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return EE_CART
71
+	 */
72
+	public function cart()
73
+	{
74
+		return $this->checkout->cart;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return RequestInterface
80
+	 * @since   4.10.14.p
81
+	 */
82
+	public static function getRequest()
83
+	{
84
+		return LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return EE_Transaction
90
+	 */
91
+	public function transaction()
92
+	{
93
+		return $this->checkout->transaction;
94
+	}
95
+
96
+
97
+	/**
98
+	 *    set_hooks - for hooking into EE Core, other modules, etc
99
+	 *
100
+	 * @return    void
101
+	 * @throws EE_Error
102
+	 */
103
+	public static function set_hooks()
104
+	{
105
+		EED_Single_Page_Checkout::set_definitions();
106
+	}
107
+
108
+
109
+	/**
110
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
111
+	 *
112
+	 * @return    void
113
+	 * @throws EE_Error
114
+	 */
115
+	public static function set_hooks_admin()
116
+	{
117
+		EED_Single_Page_Checkout::set_definitions();
118
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
119
+			return;
120
+		}
121
+		// going to start an output buffer in case anything gets accidentally output
122
+		// that might disrupt our JSON response
123
+		ob_start();
124
+		EED_Single_Page_Checkout::load_reg_steps();
125
+		// set ajax hooks
126
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
127
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
128
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
129
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
130
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
131
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
132
+	}
133
+
134
+
135
+	/**
136
+	 *    process ajax request
137
+	 *
138
+	 * @param string $ajax_action
139
+	 * @throws EE_Error
140
+	 * @throws ReflectionException
141
+	 */
142
+	public static function process_ajax_request($ajax_action)
143
+	{
144
+		$request = EED_Single_Page_Checkout::getRequest();
145
+		$request->setRequestParam('action', $ajax_action);
146
+		EED_Single_Page_Checkout::instance()->_initialize();
147
+	}
148
+
149
+
150
+	/**
151
+	 * ajax display registration step
152
+	 *
153
+	 * @throws EE_Error
154
+	 * @throws ReflectionException
155
+	 */
156
+	public static function display_reg_step()
157
+	{
158
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
159
+	}
160
+
161
+
162
+	/**
163
+	 * ajax process registration step
164
+	 *
165
+	 * @throws EE_Error
166
+	 * @throws ReflectionException
167
+	 */
168
+	public static function process_reg_step()
169
+	{
170
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
171
+	}
172
+
173
+
174
+	/**
175
+	 * ajax process registration step
176
+	 *
177
+	 * @throws EE_Error
178
+	 * @throws ReflectionException
179
+	 */
180
+	public static function update_reg_step()
181
+	{
182
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
183
+	}
184
+
185
+
186
+	/**
187
+	 * update_checkout
188
+	 *
189
+	 * @return void
190
+	 * @throws ReflectionException
191
+	 * @throws EE_Error
192
+	 */
193
+	public static function update_checkout()
194
+	{
195
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
196
+	}
197
+
198
+
199
+	/**
200
+	 * @return void
201
+	 * @deprecated 4.10.14.p
202
+	 */
203
+	public static function load_request_handler()
204
+	{
205
+	}
206
+
207
+
208
+	/**
209
+	 *    set_definitions
210
+	 *
211
+	 * @return    void
212
+	 * @throws EE_Error
213
+	 */
214
+	public static function set_definitions()
215
+	{
216
+		if (defined('SPCO_BASE_PATH')) {
217
+			return;
218
+		}
219
+		define(
220
+			'SPCO_BASE_PATH',
221
+			rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
222
+		);
223
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/');
224
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/');
225
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/');
226
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/');
227
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/');
228
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/');
229
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
230
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
231
+		);
232
+	}
233
+
234
+
235
+	/**
236
+	 * load_reg_steps
237
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
238
+	 *
239
+	 * @throws EE_Error
240
+	 */
241
+	public static function load_reg_steps()
242
+	{
243
+		static $reg_steps_loaded = false;
244
+		if ($reg_steps_loaded) {
245
+			return;
246
+		}
247
+		// filter list of reg_steps
248
+		$reg_steps_to_load = (array) apply_filters(
249
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
250
+			EED_Single_Page_Checkout::get_reg_steps()
251
+		);
252
+		// sort by key (order)
253
+		ksort($reg_steps_to_load);
254
+		// loop through folders
255
+		foreach ($reg_steps_to_load as $order => $reg_step) {
256
+			// we need a
257
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
258
+				// copy over to the reg_steps_array
259
+				EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
260
+				// register custom key route for each reg step
261
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
262
+				EE_Config::register_route(
263
+					$reg_step['slug'],
264
+					'EED_Single_Page_Checkout',
265
+					'run',
266
+					'step'
267
+				);
268
+				// add AJAX or other hooks
269
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
270
+					// setup autoloaders if necessary
271
+					if (! class_exists($reg_step['class_name'])) {
272
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
273
+							$reg_step['file_path'],
274
+							true
275
+						);
276
+					}
277
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
278
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
279
+					}
280
+				}
281
+			}
282
+		}
283
+		$reg_steps_loaded = true;
284
+	}
285
+
286
+
287
+	/**
288
+	 *    get_reg_steps
289
+	 *
290
+	 * @return    array
291
+	 */
292
+	public static function get_reg_steps()
293
+	{
294
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
295
+		if (empty($reg_steps)) {
296
+			$reg_steps = array(
297
+				10  => array(
298
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
299
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
300
+					'slug'       => 'attendee_information',
301
+					'has_hooks'  => false,
302
+				),
303
+				30  => array(
304
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
305
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
306
+					'slug'       => 'payment_options',
307
+					'has_hooks'  => true,
308
+				),
309
+				999 => array(
310
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
311
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
312
+					'slug'       => 'finalize_registration',
313
+					'has_hooks'  => false,
314
+				),
315
+			);
316
+		}
317
+		return $reg_steps;
318
+	}
319
+
320
+
321
+	/**
322
+	 *    registration_checkout_for_admin
323
+	 *
324
+	 * @return    string
325
+	 * @throws EE_Error
326
+	 * @throws ReflectionException
327
+	 */
328
+	public static function registration_checkout_for_admin()
329
+	{
330
+		$request = EED_Single_Page_Checkout::getRequest();
331
+		$request->setRequestParam('step', 'attendee_information');
332
+		$request->setRequestParam('action', 'display_spco_reg_step');
333
+		$request->setRequestParam('process_form_submission', false);
334
+		EED_Single_Page_Checkout::instance()->_initialize();
335
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
336
+		return EED_Single_Page_Checkout::getResponse()->getOutput();
337
+	}
338
+
339
+
340
+	/**
341
+	 * process_registration_from_admin
342
+	 *
343
+	 * @return EE_Transaction
344
+	 * @throws EE_Error
345
+	 * @throws ReflectionException
346
+	 */
347
+	public static function process_registration_from_admin()
348
+	{
349
+		$request = EED_Single_Page_Checkout::getRequest();
350
+		$request->setRequestParam('step', 'attendee_information');
351
+		$request->setRequestParam('action', 'process_reg_step');
352
+		$request->setRequestParam('process_form_submission', true);
353
+		EED_Single_Page_Checkout::instance()->_initialize();
354
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
355
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
356
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
357
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
358
+				if ($final_reg_step->process_reg_step()) {
359
+					$final_reg_step->set_completed();
360
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
361
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
362
+				}
363
+			}
364
+		}
365
+		return null;
366
+	}
367
+
368
+
369
+	/**
370
+	 *    run
371
+	 *
372
+	 * @param WP_Query $WP
373
+	 * @return    void
374
+	 */
375
+	public function run($WP)
376
+	{
377
+		if (
378
+			$WP instanceof WP_Query
379
+			&& $WP->is_main_query()
380
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
381
+			&& $this->_is_reg_checkout()
382
+		) {
383
+			$this->_initialize();
384
+		}
385
+	}
386
+
387
+
388
+	/**
389
+	 * determines whether current url matches reg page url
390
+	 *
391
+	 * @return bool
392
+	 */
393
+	protected function _is_reg_checkout()
394
+	{
395
+		// get current permalink for reg page without any extra query args
396
+		$reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id);
397
+		// get request URI for current request, but without the scheme or host
398
+		$current_request_uri = EEH_URL::filter_input_server_url();
399
+		$current_request_uri = html_entity_decode($current_request_uri);
400
+		// get array of query args from the current request URI
401
+		$query_args = EEH_URL::get_query_string($current_request_uri);
402
+		// grab page id if it is set
403
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
404
+		// and remove the page id from the query args (we will re-add it later)
405
+		unset($query_args['page_id']);
406
+		// now strip all query args from current request URI
407
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
408
+		// and re-add the page id if it was set
409
+		if ($page_id) {
410
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
411
+		}
412
+		// remove slashes and ?
413
+		$current_request_uri = trim($current_request_uri, '?/');
414
+		// is current request URI part of the known full reg page URL ?
415
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
416
+	}
417
+
418
+
419
+	/**
420
+	 * @param WP_Query $wp_query
421
+	 * @return    void
422
+	 * @throws EE_Error
423
+	 * @throws ReflectionException
424
+	 */
425
+	public static function init($wp_query)
426
+	{
427
+		EED_Single_Page_Checkout::instance()->run($wp_query);
428
+	}
429
+
430
+
431
+	/**
432
+	 *    _initialize - initial module setup
433
+	 *
434
+	 * @return    void
435
+	 */
436
+	private function _initialize()
437
+	{
438
+		// ensure SPCO doesn't run twice
439
+		if (EED_Single_Page_Checkout::$_initialized) {
440
+			return;
441
+		}
442
+		try {
443
+			$this->request = EED_Single_Page_Checkout::getRequest();
444
+			EED_Single_Page_Checkout::load_reg_steps();
445
+			$this->_verify_session();
446
+			// setup the EE_Checkout object
447
+			$this->checkout = $this->_initialize_checkout();
448
+			// filter checkout
449
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
450
+			// get the $_GET
451
+			$this->_get_request_vars();
452
+			if ($this->_block_bots()) {
453
+				return;
454
+			}
455
+			// filter continue_reg
456
+			$this->checkout->continue_reg = apply_filters(
457
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
458
+				true,
459
+				$this->checkout
460
+			);
461
+			// load the reg steps array
462
+			if (! $this->_load_and_instantiate_reg_steps()) {
463
+				EED_Single_Page_Checkout::$_initialized = true;
464
+				return;
465
+			}
466
+			// set the current step
467
+			$this->checkout->set_current_step($this->checkout->step);
468
+			// and the next step
469
+			$this->checkout->set_next_step();
470
+			// verify that everything has been setup correctly
471
+			if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
472
+				EED_Single_Page_Checkout::$_initialized = true;
473
+				return;
474
+			}
475
+			// lock the transaction
476
+			$this->checkout->transaction->lock();
477
+			// make sure all of our cached objects are added to their respective model entity mappers
478
+			$this->checkout->refresh_all_entities();
479
+			// set amount owing
480
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
481
+			// initialize each reg step, which gives them the chance to potentially alter the process
482
+			$this->_initialize_reg_steps();
483
+			// DEBUG LOG
484
+			// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
485
+			// get reg form
486
+			if (! $this->_check_form_submission()) {
487
+				EED_Single_Page_Checkout::$_initialized = true;
488
+				return;
489
+			}
490
+			// checkout the action!!!
491
+			$this->_process_form_action();
492
+			// add some style and make it dance
493
+			$this->add_styles_and_scripts($this);
494
+			// kk... SPCO has successfully run
495
+			EED_Single_Page_Checkout::$_initialized = true;
496
+			// set no cache headers and constants
497
+			EE_System::do_not_cache();
498
+			// add anchor
499
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
500
+			// remove transaction lock
501
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
502
+		} catch (Exception $e) {
503
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
504
+		}
505
+	}
506
+
507
+
508
+	/**
509
+	 *    _verify_session
510
+	 * checks that the session is valid and not expired
511
+	 *
512
+	 * @throws EE_Error
513
+	 * @throws ReflectionException
514
+	 */
515
+	private function _verify_session()
516
+	{
517
+		if (! EE_Registry::instance()->SSN instanceof EE_Session) {
518
+			throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
519
+		}
520
+		$clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool');
521
+		// is session still valid ?
522
+		if (
523
+			$clear_session_requested
524
+			|| (
525
+				EE_Registry::instance()->SSN->expired()
526
+				&& $this->request->getRequestParam('e_reg_url_link') === ''
527
+			)
528
+		) {
529
+			$this->checkout = new EE_Checkout();
530
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
531
+			// EE_Registry::instance()->SSN->reset_cart();
532
+			// EE_Registry::instance()->SSN->reset_checkout();
533
+			// EE_Registry::instance()->SSN->reset_transaction();
534
+			if (! $clear_session_requested) {
535
+				EE_Error::add_attention(
536
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
537
+					__FILE__,
538
+					__FUNCTION__,
539
+					__LINE__
540
+				);
541
+			}
542
+			// EE_Registry::instance()->SSN->reset_expired();
543
+		}
544
+	}
545
+
546
+
547
+	/**
548
+	 *    _initialize_checkout
549
+	 * loads and instantiates EE_Checkout
550
+	 *
551
+	 * @return EE_Checkout
552
+	 * @throws EE_Error
553
+	 * @throws ReflectionException
554
+	 */
555
+	private function _initialize_checkout()
556
+	{
557
+		// look in session for existing checkout
558
+		/** @type EE_Checkout $checkout */
559
+		$checkout = EE_Registry::instance()->SSN->checkout();
560
+		// verify
561
+		if (! $checkout instanceof EE_Checkout) {
562
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
563
+			$checkout = EE_Registry::instance()->load_file(
564
+				SPCO_INC_PATH,
565
+				'EE_Checkout',
566
+				'class',
567
+				array(),
568
+				false
569
+			);
570
+		} else {
571
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
572
+				$this->unlock_transaction();
573
+				wp_safe_redirect($checkout->redirect_url);
574
+				exit();
575
+			}
576
+		}
577
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
578
+		// verify again
579
+		if (! $checkout instanceof EE_Checkout) {
580
+			throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
581
+		}
582
+		// reset anything that needs a clean slate for each request
583
+		$checkout->reset_for_current_request();
584
+		return $checkout;
585
+	}
586
+
587
+
588
+	/**
589
+	 *    _get_request_vars
590
+	 *
591
+	 * @return    void
592
+	 */
593
+	private function _get_request_vars()
594
+	{
595
+		// make sure this request is marked as belonging to EE
596
+		/** @var CurrentPage $current_page */
597
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
598
+		$current_page->setEspressoPage(true);
599
+		// which step is being requested ?
600
+		$this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step());
601
+		// which step is being edited ?
602
+		$this->checkout->edit_step = $this->request->getRequestParam('edit_step');
603
+		// and what we're doing on the current step
604
+		$this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step');
605
+		// timestamp
606
+		$this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int');
607
+		// returning to edit ?
608
+		$this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link');
609
+		// add reg url link to registration query params
610
+		if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
611
+			$this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
612
+		}
613
+		// or some other kind of revisit ?
614
+		$this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool');
615
+		// and whether or not to generate a reg form for this request
616
+		$this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool');
617
+		// and whether or not to process a reg form submission for this request
618
+		$this->checkout->process_form_submission = $this->request->getRequestParam(
619
+			'process_form_submission',
620
+			$this->checkout->action === 'process_reg_step',
621
+			'bool'
622
+		);
623
+		$this->checkout->process_form_submission = filter_var(
624
+			$this->checkout->action !== 'display_spco_reg_step'
625
+				? $this->checkout->process_form_submission
626
+				: false,
627
+			FILTER_VALIDATE_BOOLEAN
628
+		);
629
+		// $this->_display_request_vars();
630
+	}
631
+
632
+
633
+	/**
634
+	 *  _display_request_vars
635
+	 *
636
+	 * @return    void
637
+	 */
638
+	protected function _display_request_vars()
639
+	{
640
+		if (! WP_DEBUG) {
641
+			return;
642
+		}
643
+		EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__);
644
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
645
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
646
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
647
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
648
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
649
+		EEH_Debug_Tools::printr(
650
+			$this->checkout->generate_reg_form,
651
+			'$this->checkout->generate_reg_form',
652
+			__FILE__,
653
+			__LINE__
654
+		);
655
+		EEH_Debug_Tools::printr(
656
+			$this->checkout->process_form_submission,
657
+			'$this->checkout->process_form_submission',
658
+			__FILE__,
659
+			__LINE__
660
+		);
661
+	}
662
+
663
+
664
+	/**
665
+	 * _block_bots
666
+	 * checks that the incoming request has either of the following set:
667
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
668
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
669
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
670
+	 * then where you coming from man?
671
+	 *
672
+	 * @return boolean
673
+	 */
674
+	private function _block_bots()
675
+	{
676
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
677
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
678
+			return true;
679
+		}
680
+		return false;
681
+	}
682
+
683
+
684
+	/**
685
+	 *    _get_first_step
686
+	 *  gets slug for first step in $_reg_steps_array
687
+	 *
688
+	 * @return    string
689
+	 */
690
+	private function _get_first_step()
691
+	{
692
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
693
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
694
+	}
695
+
696
+
697
+	/**
698
+	 * instantiates each reg step based on the loaded reg_steps array
699
+	 *
700
+	 * @return    bool
701
+	 * @throws EE_Error
702
+	 * @throws InvalidArgumentException
703
+	 * @throws InvalidDataTypeException
704
+	 * @throws InvalidInterfaceException
705
+	 * @throws ReflectionException
706
+	 */
707
+	private function _load_and_instantiate_reg_steps()
708
+	{
709
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
710
+		// have reg_steps already been instantiated ?
711
+		if (
712
+			empty($this->checkout->reg_steps)
713
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
714
+		) {
715
+			// if not, then loop through raw reg steps array
716
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
717
+				if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
718
+					return false;
719
+				}
720
+			}
721
+			if (isset($this->checkout->reg_steps['registration_confirmation'])) {
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
+				} elseif (
727
+					EE_Registry::instance()->CFG->registration->reg_confirmation_last
728
+				) {
729
+					// set the order to something big like 100
730
+					$this->checkout->set_reg_step_order('registration_confirmation');
731
+				}
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(
748
+				esc_html__('No Reg Steps were loaded..', 'event_espresso'),
749
+				__FILE__,
750
+				__FUNCTION__,
751
+				__LINE__
752
+			);
753
+			return false;
754
+		}
755
+		// make reg step details available to JS
756
+		$this->checkout->set_reg_step_JSON_info();
757
+		return true;
758
+	}
759
+
760
+
761
+	/**
762
+	 *     _load_and_instantiate_reg_step
763
+	 *
764
+	 * @param array $reg_step
765
+	 * @param int   $order
766
+	 * @return bool
767
+	 * @throws EE_Error
768
+	 * @throws ReflectionException
769
+	 */
770
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
771
+	{
772
+		// we need a file_path, class_name, and slug to add a reg step
773
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
774
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
775
+			if (
776
+				$this->checkout->reg_url_link
777
+				&& $this->checkout->step !== $reg_step['slug']
778
+				&& $reg_step['slug'] !== 'finalize_registration'
779
+				// normally at this point we would NOT load the reg step, but this filter can change that
780
+				&& apply_filters(
781
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
782
+					true,
783
+					$reg_step,
784
+					$this->checkout
785
+				)
786
+			) {
787
+				return true;
788
+			}
789
+
790
+			// instantiate step class using file path and class name
791
+			$reg_step_obj = EE_Registry::instance()->load_file(
792
+				$reg_step['file_path'],
793
+				$reg_step['class_name'],
794
+				'class',
795
+				[$this->checkout],
796
+				false
797
+			);
798
+			// did we gets the goods ?
799
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
800
+				// set reg step order based on config
801
+				$reg_step_obj->set_order($order);
802
+				// add instantiated reg step object to the master reg steps array
803
+				$this->checkout->add_reg_step($reg_step_obj);
804
+			} else {
805
+				EE_Error::add_error(
806
+					esc_html__('The current step could not be set.', 'event_espresso'),
807
+					__FILE__,
808
+					__FUNCTION__,
809
+					__LINE__
810
+				);
811
+				return false;
812
+			}
813
+		} else {
814
+			if (WP_DEBUG) {
815
+				EE_Error::add_error(
816
+					sprintf(
817
+						esc_html__(
818
+							'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',
819
+							'event_espresso'
820
+						),
821
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
822
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
823
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
824
+						'<ul>',
825
+						'<li>',
826
+						'</li>',
827
+						'</ul>'
828
+					),
829
+					__FILE__,
830
+					__FUNCTION__,
831
+					__LINE__
832
+				);
833
+			}
834
+			return false;
835
+		}
836
+		return true;
837
+	}
838
+
839
+
840
+	/**
841
+	 * _verify_transaction_and_get_registrations
842
+	 *
843
+	 * @return bool
844
+	 * @throws EE_Error
845
+	 * @throws ReflectionException
846
+	 */
847
+	private function _verify_transaction_and_get_registrations()
848
+	{
849
+		// was there already a valid transaction in the checkout from the session ?
850
+		if (! $this->checkout->transaction instanceof EE_Transaction) {
851
+			// get transaction from db or session
852
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
853
+				? $this->_get_transaction_and_cart_for_previous_visit()
854
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
855
+			if (! $this->checkout->transaction instanceof EE_Transaction) {
856
+				EE_Error::add_error(
857
+					esc_html__(
858
+						'Your Registration and Transaction information could not be retrieved from the db.',
859
+						'event_espresso'
860
+					),
861
+					__FILE__,
862
+					__FUNCTION__,
863
+					__LINE__
864
+				);
865
+				$this->checkout->transaction = EE_Transaction::new_instance();
866
+				// add some style and make it dance
867
+				$this->add_styles_and_scripts($this);
868
+				EED_Single_Page_Checkout::$_initialized = true;
869
+				return false;
870
+			}
871
+			// and the registrations for the transaction
872
+			$this->_get_registrations($this->checkout->transaction);
873
+		}
874
+		return true;
875
+	}
876
+
877
+
878
+	/**
879
+	 * _get_transaction_and_cart_for_previous_visit
880
+	 *
881
+	 * @return EE_Transaction|null
882
+	 * @throws EE_Error
883
+	 * @throws ReflectionException
884
+	 */
885
+	private function _get_transaction_and_cart_for_previous_visit()
886
+	{
887
+		/** @var $TXN_model EEM_Transaction */
888
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
889
+		// because the reg_url_link is present in the request,
890
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
891
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
892
+		// verify transaction
893
+		if ($transaction instanceof EE_Transaction) {
894
+			// and get the cart that was used for that transaction
895
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
896
+			return $transaction;
897
+		}
898
+		EE_Error::add_error(
899
+			esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
900
+			__FILE__,
901
+			__FUNCTION__,
902
+			__LINE__
903
+		);
904
+		return null;
905
+	}
906
+
907
+
908
+	/**
909
+	 * _get_cart_for_transaction
910
+	 *
911
+	 * @param EE_Transaction $transaction
912
+	 * @return EE_Cart
913
+	 */
914
+	private function _get_cart_for_transaction($transaction)
915
+	{
916
+		return $this->checkout->get_cart_for_transaction($transaction);
917
+	}
918
+
919
+
920
+	/**
921
+	 * get_cart_for_transaction
922
+	 *
923
+	 * @param EE_Transaction $transaction
924
+	 * @return EE_Cart
925
+	 */
926
+	public function get_cart_for_transaction(EE_Transaction $transaction)
927
+	{
928
+		return $this->checkout->get_cart_for_transaction($transaction);
929
+	}
930
+
931
+
932
+	/**
933
+	 * _get_transaction_and_cart_for_current_session
934
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
935
+	 *
936
+	 * @return EE_Transaction
937
+	 * @throws EE_Error
938
+	 * @throws ReflectionException
939
+	 */
940
+	private function _get_cart_for_current_session_and_setup_new_transaction()
941
+	{
942
+		//  if there's no transaction, then this is the FIRST visit to SPCO
943
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
944
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
945
+		// and then create a new transaction
946
+		$transaction = $this->_initialize_transaction();
947
+		// verify transaction
948
+		if ($transaction instanceof EE_Transaction) {
949
+			// save it so that we have an ID for other objects to use
950
+			$transaction->save();
951
+			// and save TXN data to the cart
952
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
953
+		} else {
954
+			EE_Error::add_error(
955
+				esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'),
956
+				__FILE__,
957
+				__FUNCTION__,
958
+				__LINE__
959
+			);
960
+		}
961
+		return $transaction;
962
+	}
963
+
964
+
965
+	/**
966
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
967
+	 *
968
+	 * @return EE_Transaction|null
969
+	 */
970
+	private function _initialize_transaction()
971
+	{
972
+		try {
973
+			// ensure cart totals have been calculated
974
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
975
+			// grab the cart grand total
976
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
977
+			// create new TXN
978
+			$transaction = EE_Transaction::new_instance(
979
+				array(
980
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
981
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
982
+					'TXN_paid'      => 0,
983
+					'STS_ID'        => EEM_Transaction::failed_status_code,
984
+				)
985
+			);
986
+			// save it so that we have an ID for other objects to use
987
+			$transaction->save();
988
+			// set cron job for following up on TXNs after their session has expired
989
+			EE_Cron_Tasks::schedule_expired_transaction_check(
990
+				EE_Registry::instance()->SSN->expiration() + 1,
991
+				$transaction->ID()
992
+			);
993
+			return $transaction;
994
+		} catch (Exception $e) {
995
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
996
+		}
997
+		return null;
998
+	}
999
+
1000
+
1001
+	/**
1002
+	 * _get_registrations
1003
+	 *
1004
+	 * @param EE_Transaction $transaction
1005
+	 * @return void
1006
+	 * @throws EE_Error
1007
+	 * @throws ReflectionException
1008
+	 */
1009
+	private function _get_registrations(EE_Transaction $transaction)
1010
+	{
1011
+		// first step: grab the registrants  { : o
1012
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params);
1013
+		$this->checkout->total_ticket_count = count($registrations);
1014
+		// verify registrations have been set
1015
+		if (empty($registrations)) {
1016
+			// if no cached registrations, then check the db
1017
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params);
1018
+			// still nothing ? well as long as this isn't a revisit
1019
+			if (empty($registrations) && ! $this->checkout->revisit) {
1020
+				// generate new registrations from scratch
1021
+				$registrations = $this->_initialize_registrations($transaction);
1022
+			}
1023
+		}
1024
+		// sort by their original registration order
1025
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1026
+		// then loop thru the array
1027
+		foreach ($registrations as $registration) {
1028
+			// verify each registration
1029
+			if ($registration instanceof EE_Registration) {
1030
+				// we display all attendee info for the primary registrant
1031
+				if (
1032
+					$this->checkout->reg_url_link === $registration->reg_url_link()
1033
+					&& $registration->is_primary_registrant()
1034
+				) {
1035
+					$this->checkout->primary_revisit = true;
1036
+					break;
1037
+				}
1038
+				if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1039
+					// but hide info if it doesn't belong to you
1040
+					$transaction->clear_cache('Registration', $registration->ID());
1041
+					$this->checkout->total_ticket_count--;
1042
+				}
1043
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1044
+			}
1045
+		}
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1051
+	 *
1052
+	 * @param EE_Transaction $transaction
1053
+	 * @return    array
1054
+	 * @throws EE_Error
1055
+	 * @throws ReflectionException
1056
+	 */
1057
+	private function _initialize_registrations(EE_Transaction $transaction)
1058
+	{
1059
+		$att_nmbr = 0;
1060
+		$registrations = array();
1061
+		if ($transaction instanceof EE_Transaction) {
1062
+			/** @type EE_Registration_Processor $registration_processor */
1063
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1064
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1065
+			// now let's add the cart items to the $transaction
1066
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1067
+				// do the following for each ticket of this type they selected
1068
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1069
+					$att_nmbr++;
1070
+					/** @var CreateRegistrationCommand $CreateRegistrationCommand */
1071
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1072
+						CreateRegistrationCommand::class,
1073
+						[
1074
+							$transaction,
1075
+							$line_item,
1076
+							$att_nmbr,
1077
+							$this->checkout->total_ticket_count,
1078
+						]
1079
+					);
1080
+					// override capabilities for frontend registrations
1081
+					if ($this->request->isFrontend()) {
1082
+						$CreateRegistrationCommand->setCapCheck(
1083
+							new PublicCapabilities('', 'create_new_registration')
1084
+						);
1085
+					}
1086
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1087
+					if (! $registration instanceof EE_Registration) {
1088
+						throw new InvalidEntityException($registration, 'EE_Registration');
1089
+					}
1090
+					$registrations[ $registration->ID() ] = $registration;
1091
+				}
1092
+			}
1093
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1094
+		}
1095
+		return $registrations;
1096
+	}
1097
+
1098
+
1099
+	/**
1100
+	 * sorts registrations by REG_count
1101
+	 *
1102
+	 * @param EE_Registration $reg_A
1103
+	 * @param EE_Registration $reg_B
1104
+	 * @return int
1105
+	 */
1106
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1107
+	{
1108
+		// this shouldn't ever happen within the same TXN, but oh well
1109
+		if ($reg_A->count() === $reg_B->count()) {
1110
+			return 0;
1111
+		}
1112
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1113
+	}
1114
+
1115
+
1116
+	/**
1117
+	 *    _final_verifications
1118
+	 * just makes sure that everything is set up correctly before proceeding
1119
+	 *
1120
+	 * @return    bool
1121
+	 * @throws EE_Error
1122
+	 * @throws ReflectionException
1123
+	 */
1124
+	private function _final_verifications()
1125
+	{
1126
+		// filter checkout
1127
+		$this->checkout = apply_filters(
1128
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1129
+			$this->checkout
1130
+		);
1131
+		// verify that current step is still set correctly
1132
+		if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1133
+			EE_Error::add_error(
1134
+				esc_html__(
1135
+					'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.',
1136
+					'event_espresso'
1137
+				),
1138
+				__FILE__,
1139
+				__FUNCTION__,
1140
+				__LINE__
1141
+			);
1142
+			return false;
1143
+		}
1144
+		// if returning to SPCO, then verify that primary registrant is set
1145
+		if (! empty($this->checkout->reg_url_link)) {
1146
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1147
+			if (! $valid_registrant instanceof EE_Registration) {
1148
+				EE_Error::add_error(
1149
+					esc_html__(
1150
+						'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.',
1151
+						'event_espresso'
1152
+					),
1153
+					__FILE__,
1154
+					__FUNCTION__,
1155
+					__LINE__
1156
+				);
1157
+				return false;
1158
+			}
1159
+			$valid_registrant = null;
1160
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
1161
+				if (
1162
+					$registration instanceof EE_Registration
1163
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1164
+				) {
1165
+					$valid_registrant = $registration;
1166
+				}
1167
+			}
1168
+			if (! $valid_registrant instanceof EE_Registration) {
1169
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1170
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1171
+					// clear the session, mark the checkout as unverified, and try again
1172
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1173
+					EED_Single_Page_Checkout::$_initialized = false;
1174
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1175
+					$this->_initialize();
1176
+					EE_Error::reset_notices();
1177
+					return false;
1178
+				}
1179
+				EE_Error::add_error(
1180
+					esc_html__(
1181
+						'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.',
1182
+						'event_espresso'
1183
+					),
1184
+					__FILE__,
1185
+					__FUNCTION__,
1186
+					__LINE__
1187
+				);
1188
+				return false;
1189
+			}
1190
+		}
1191
+		// now that things have been kinda sufficiently verified,
1192
+		// let's add the checkout to the session so that it's available to other systems
1193
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1194
+		return true;
1195
+	}
1196
+
1197
+
1198
+	/**
1199
+	 *    _initialize_reg_steps
1200
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1201
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1202
+	 *
1203
+	 * @param bool $reinitializing
1204
+	 * @throws EE_Error
1205
+	 */
1206
+	private function _initialize_reg_steps($reinitializing = false)
1207
+	{
1208
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1209
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1210
+		foreach ($this->checkout->reg_steps as $reg_step) {
1211
+			if (! $reg_step->initialize_reg_step()) {
1212
+				// if not initialized then maybe this step is being removed...
1213
+				if (! $reinitializing && $reg_step->is_current_step()) {
1214
+					// if it was the current step, then we need to start over here
1215
+					$this->_initialize_reg_steps(true);
1216
+					return;
1217
+				}
1218
+				continue;
1219
+			}
1220
+			// add css and JS for current step
1221
+			$this->add_styles_and_scripts($reg_step);
1222
+			if ($reg_step->is_current_step()) {
1223
+				// the text that appears on the reg step form submit button
1224
+				$reg_step->set_submit_button_text();
1225
+			}
1226
+		}
1227
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1228
+		do_action(
1229
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1230
+			$this->checkout->current_step
1231
+		);
1232
+	}
1233
+
1234
+
1235
+	/**
1236
+	 * _check_form_submission
1237
+	 *
1238
+	 * @return boolean
1239
+	 * @throws EE_Error
1240
+	 * @throws ReflectionException
1241
+	 */
1242
+	private function _check_form_submission()
1243
+	{
1244
+		// does this request require the reg form to be generated ?
1245
+		if ($this->checkout->generate_reg_form) {
1246
+			// ever heard that song by Blue Rodeo ?
1247
+			try {
1248
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1249
+				// if not displaying a form, then check for form submission
1250
+				if (
1251
+					$this->checkout->process_form_submission
1252
+					&& $this->checkout->current_step->reg_form->was_submitted()
1253
+				) {
1254
+					// clear out any old data in case this step is being run again
1255
+					$this->checkout->current_step->set_valid_data(array());
1256
+					// capture submitted form data
1257
+					$request_data = $this->request->requestParams();
1258
+					$this->checkout->current_step->reg_form->receive_form_submission(
1259
+						(array) apply_filters(
1260
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1261
+							$request_data,
1262
+							$this->checkout
1263
+						)
1264
+					);
1265
+					// validate submitted form data
1266
+					if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1267
+						// thou shall not pass !!!
1268
+						$this->checkout->continue_reg = false;
1269
+						// any form validation errors?
1270
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1271
+							EE_Error::add_error(
1272
+								$this->checkout->current_step->reg_form->submission_error_message(),
1273
+								__FILE__,
1274
+								__FUNCTION__,
1275
+								__LINE__
1276
+							);
1277
+						}
1278
+						// well not really... what will happen is
1279
+						// we'll just get redirected back to redo the current step
1280
+						$this->go_to_next_step();
1281
+						return false;
1282
+					}
1283
+				}
1284
+			} catch (EE_Error $e) {
1285
+				$e->get_error();
1286
+			}
1287
+		}
1288
+		return true;
1289
+	}
1290
+
1291
+
1292
+	/**
1293
+	 * _process_action
1294
+	 *
1295
+	 * @return void
1296
+	 * @throws EE_Error
1297
+	 * @throws ReflectionException
1298
+	 */
1299
+	private function _process_form_action()
1300
+	{
1301
+		// what cha wanna do?
1302
+		switch ($this->checkout->action) {
1303
+			// AJAX next step reg form
1304
+			case 'display_spco_reg_step':
1305
+				$this->checkout->redirect = false;
1306
+				if ($this->request->isAjax()) {
1307
+					$this->checkout->json_response->set_reg_step_html(
1308
+						$this->checkout->current_step->display_reg_form()
1309
+					);
1310
+				}
1311
+				break;
1312
+			default:
1313
+				// meh... do one of those other steps first
1314
+				if (
1315
+					! empty($this->checkout->action)
1316
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1317
+				) {
1318
+					// dynamically creates hook point like:
1319
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1320
+					do_action(
1321
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1322
+						$this->checkout->current_step
1323
+					);
1324
+					$process_reg_step = apply_filters(
1325
+						"AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1326
+						true,
1327
+						$this->checkout->current_step,
1328
+						$this
1329
+					);
1330
+					// call action on current step
1331
+					if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) {
1332
+						// good registrant, you get to proceed
1333
+						if (
1334
+							$this->checkout->current_step->success_message() !== ''
1335
+							&& apply_filters(
1336
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1337
+								false
1338
+							)
1339
+						) {
1340
+							EE_Error::add_success(
1341
+								$this->checkout->current_step->success_message()
1342
+								. '<br />' . $this->checkout->next_step->_instructions()
1343
+							);
1344
+						}
1345
+						// pack it up, pack it in...
1346
+						$this->_setup_redirect();
1347
+					}
1348
+					// dynamically creates hook point like:
1349
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1350
+					do_action(
1351
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1352
+						$this->checkout->current_step
1353
+					);
1354
+				} else {
1355
+					EE_Error::add_error(
1356
+						sprintf(
1357
+							esc_html__(
1358
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1359
+								'event_espresso'
1360
+							),
1361
+							$this->checkout->action,
1362
+							$this->checkout->current_step->name()
1363
+						),
1364
+						__FILE__,
1365
+						__FUNCTION__,
1366
+						__LINE__
1367
+					);
1368
+				}
1369
+			// end default
1370
+		}
1371
+		// store our progress so far
1372
+		$this->checkout->stash_transaction_and_checkout();
1373
+		// advance to the next step! If you pass GO, collect $200
1374
+		$this->go_to_next_step();
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and
1380
+	 *                                                          `enqueue_styles_and_scripts`.
1381
+	 * @return        void
1382
+	 */
1383
+	public function add_styles_and_scripts($target)
1384
+	{
1385
+		// i18n
1386
+		$target->translate_js_strings();
1387
+		if ($this->checkout->admin_request) {
1388
+			add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10);
1389
+		} else {
1390
+			add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10);
1391
+		}
1392
+	}
1393
+
1394
+	/**
1395
+	 *        translate_js_strings
1396
+	 *
1397
+	 * @return        void
1398
+	 */
1399
+	public function translate_js_strings()
1400
+	{
1401
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1402
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1403
+		EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
1404
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1405
+			'event_espresso'
1406
+		);
1407
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__(
1408
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1409
+			'event_espresso'
1410
+		);
1411
+		EE_Registry::$i18n_js_strings['validation_error'] = esc_html__(
1412
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1413
+			'event_espresso'
1414
+		);
1415
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__(
1416
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1417
+			'event_espresso'
1418
+		);
1419
+		EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__(
1420
+			'This registration step could not be completed. Please refresh the page and try again.',
1421
+			'event_espresso'
1422
+		);
1423
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__(
1424
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1425
+			'event_espresso'
1426
+		);
1427
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1428
+			esc_html__(
1429
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1430
+				'event_espresso'
1431
+			),
1432
+			'<br/>',
1433
+			'<br/>'
1434
+		);
1435
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1436
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1437
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1438
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1439
+		EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso');
1440
+		EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso');
1441
+		EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso');
1442
+		EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso');
1443
+		EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso');
1444
+		EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso');
1445
+		EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso');
1446
+		EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso');
1447
+		EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso');
1448
+		EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso');
1449
+		EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso');
1450
+		EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso');
1451
+		EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso');
1452
+		EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso');
1453
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
1454
+		);
1455
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1456
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1457
+			true
1458
+		);
1459
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1460
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1461
+		);
1462
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1463
+			'M d, Y H:i:s',
1464
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1465
+		);
1466
+	}
1467
+
1468
+
1469
+	/**
1470
+	 *    enqueue_styles_and_scripts
1471
+	 *
1472
+	 * @return        void
1473
+	 * @throws EE_Error
1474
+	 */
1475
+	public function enqueue_styles_and_scripts()
1476
+	{
1477
+		// load css
1478
+		wp_register_style(
1479
+			'single_page_checkout',
1480
+			SPCO_CSS_URL . 'single_page_checkout.css',
1481
+			array('espresso_default'),
1482
+			EVENT_ESPRESSO_VERSION
1483
+		);
1484
+		wp_enqueue_style('single_page_checkout');
1485
+		// load JS
1486
+		wp_register_script(
1487
+			'jquery_plugin',
1488
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js',
1489
+			array('jquery'),
1490
+			'1.0.1',
1491
+			true
1492
+		);
1493
+		wp_register_script(
1494
+			'jquery_countdown',
1495
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js',
1496
+			array('jquery_plugin'),
1497
+			'2.1.0',
1498
+			true
1499
+		);
1500
+		wp_register_script(
1501
+			'single_page_checkout',
1502
+			SPCO_JS_URL . 'single_page_checkout.js',
1503
+			array('espresso_core', 'underscore', 'ee_form_section_validation'),
1504
+			EVENT_ESPRESSO_VERSION,
1505
+			true
1506
+		);
1507
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1508
+			$this->checkout->registration_form->enqueue_js();
1509
+		}
1510
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1511
+			$this->checkout->current_step->reg_form->enqueue_js();
1512
+		}
1513
+		wp_enqueue_script('single_page_checkout');
1514
+		if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) {
1515
+			wp_enqueue_script('jquery_countdown');
1516
+		}
1517
+		/**
1518
+		 * global action hook for enqueueing styles and scripts with
1519
+		 * spco calls.
1520
+		 */
1521
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1522
+		/**
1523
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1524
+		 * The hook will end up being something like:
1525
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1526
+		 */
1527
+		do_action(
1528
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1529
+			$this
1530
+		);
1531
+	}
1532
+
1533
+
1534
+	/**
1535
+	 *    display the Registration Single Page Checkout Form
1536
+	 *
1537
+	 * @return    void
1538
+	 * @throws EE_Error
1539
+	 * @throws ReflectionException
1540
+	 */
1541
+	private function _display_spco_reg_form()
1542
+	{
1543
+		// if registering via the admin, just display the reg form for the current step
1544
+		if ($this->checkout->admin_request) {
1545
+			EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form());
1546
+		} else {
1547
+			// add powered by EE msg
1548
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1549
+			$empty_cart = count(
1550
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1551
+			) < 1;
1552
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1553
+			$cookies_not_set_msg = '';
1554
+			if ($empty_cart) {
1555
+				$cookies_not_set_msg = apply_filters(
1556
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1557
+					sprintf(
1558
+						esc_html__(
1559
+							'%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',
1560
+							'event_espresso'
1561
+						),
1562
+						'<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1563
+						'</div>',
1564
+						'<h6 class="important-notice">',
1565
+						'</h6>',
1566
+						'<p>',
1567
+						'</p>',
1568
+						'<br />',
1569
+						'<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">',
1570
+						'</a>'
1571
+					)
1572
+				);
1573
+			}
1574
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1575
+				array(
1576
+					'name'            => 'single-page-checkout',
1577
+					'html_id'         => 'ee-single-page-checkout-dv',
1578
+					'layout_strategy' =>
1579
+						new EE_Template_Layout(
1580
+							array(
1581
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1582
+								'template_args'        => array(
1583
+									'empty_cart'              => $empty_cart,
1584
+									'revisit'                 => $this->checkout->revisit,
1585
+									'reg_steps'               => $this->checkout->reg_steps,
1586
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1587
+										? $this->checkout->next_step->slug()
1588
+										: '',
1589
+									'empty_msg'               => apply_filters(
1590
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1591
+										sprintf(
1592
+											esc_html__(
1593
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1594
+												'event_espresso'
1595
+											),
1596
+											'<a href="'
1597
+											. get_post_type_archive_link('espresso_events')
1598
+											. '" title="',
1599
+											'">',
1600
+											'</a>'
1601
+										)
1602
+									),
1603
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1604
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1605
+									'session_expiration'      => gmdate(
1606
+										'M d, Y H:i:s',
1607
+										EE_Registry::instance()->SSN->expiration()
1608
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1609
+									),
1610
+								),
1611
+							)
1612
+						),
1613
+				)
1614
+			);
1615
+			// load template and add to output sent that gets filtered into the_content()
1616
+			EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html());
1617
+		}
1618
+	}
1619
+
1620
+
1621
+	/**
1622
+	 *    add_extra_finalize_registration_inputs
1623
+	 *
1624
+	 * @param $next_step
1625
+	 * @internal  param string $label
1626
+	 * @return void
1627
+	 */
1628
+	public function add_extra_finalize_registration_inputs($next_step)
1629
+	{
1630
+		if ($next_step === 'finalize_registration') {
1631
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1632
+		}
1633
+	}
1634
+
1635
+
1636
+	/**
1637
+	 *    display_registration_footer
1638
+	 *
1639
+	 * @return    string
1640
+	 */
1641
+	public static function display_registration_footer()
1642
+	{
1643
+		if (
1644
+			apply_filters(
1645
+				'FHEE__EE_Front__Controller__show_reg_footer',
1646
+				EE_Registry::instance()->CFG->admin->show_reg_footer
1647
+			)
1648
+		) {
1649
+			add_filter(
1650
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1651
+				function ($url) {
1652
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1653
+				}
1654
+			);
1655
+			echo apply_filters(
1656
+				'FHEE__EE_Front_Controller__display_registration_footer',
1657
+				EEH_Template::powered_by_event_espresso(
1658
+					'',
1659
+					'espresso-registration-footer-dv',
1660
+					array('utm_content' => 'registration_checkout')
1661
+				)
1662
+			);
1663
+		}
1664
+		return '';
1665
+	}
1666
+
1667
+
1668
+	/**
1669
+	 *    unlock_transaction
1670
+	 *
1671
+	 * @return    void
1672
+	 * @throws EE_Error
1673
+	 * @throws ReflectionException
1674
+	 */
1675
+	public function unlock_transaction()
1676
+	{
1677
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1678
+			$this->checkout->transaction->unlock();
1679
+		}
1680
+	}
1681
+
1682
+
1683
+	/**
1684
+	 *        _setup_redirect
1685
+	 *
1686
+	 * @return void
1687
+	 */
1688
+	private function _setup_redirect()
1689
+	{
1690
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1691
+			$this->checkout->redirect = true;
1692
+			if (empty($this->checkout->redirect_url)) {
1693
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1694
+			}
1695
+			$this->checkout->redirect_url = apply_filters(
1696
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1697
+				$this->checkout->redirect_url,
1698
+				$this->checkout
1699
+			);
1700
+		}
1701
+	}
1702
+
1703
+
1704
+	/**
1705
+	 *   handle ajax message responses and redirects
1706
+	 *
1707
+	 * @return void
1708
+	 * @throws EE_Error
1709
+	 * @throws ReflectionException
1710
+	 */
1711
+	public function go_to_next_step()
1712
+	{
1713
+		if ($this->request->isAjax()) {
1714
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1715
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1716
+		}
1717
+		$this->unlock_transaction();
1718
+		// just return for these conditions
1719
+		if (
1720
+			$this->checkout->admin_request
1721
+			|| $this->checkout->action === 'redirect_form'
1722
+			|| $this->checkout->action === 'update_checkout'
1723
+		) {
1724
+			return;
1725
+		}
1726
+		// AJAX response
1727
+		$this->_handle_json_response();
1728
+		// redirect to next step or the Thank You page
1729
+		$this->_handle_html_redirects();
1730
+		// hmmm... must be something wrong, so let's just display the form again !
1731
+		$this->_display_spco_reg_form();
1732
+	}
1733
+
1734
+
1735
+	/**
1736
+	 *   _handle_json_response
1737
+	 *
1738
+	 * @return void
1739
+	 * @throws EE_Error
1740
+	 */
1741
+	protected function _handle_json_response()
1742
+	{
1743
+		// if this is an ajax request
1744
+		if ($this->request->isAjax()) {
1745
+			$this->checkout->json_response->set_registration_time_limit(
1746
+				$this->checkout->get_registration_time_limit()
1747
+			);
1748
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1749
+			// just send the ajax (
1750
+			$json_response = apply_filters(
1751
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1752
+				$this->checkout->json_response
1753
+			);
1754
+			echo ($json_response);
1755
+			exit();
1756
+		}
1757
+	}
1758
+
1759
+
1760
+	/**
1761
+	 *   _handle_redirects
1762
+	 *
1763
+	 * @return void
1764
+	 */
1765
+	protected function _handle_html_redirects()
1766
+	{
1767
+		// going somewhere ?
1768
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1769
+			// store notices in a transient
1770
+			EE_Error::get_notices(false, true);
1771
+			wp_safe_redirect($this->checkout->redirect_url);
1772
+			exit();
1773
+		}
1774
+	}
1775
+
1776
+
1777
+	/**
1778
+	 *   set_checkout_anchor
1779
+	 *
1780
+	 * @return void
1781
+	 */
1782
+	public function set_checkout_anchor()
1783
+	{
1784
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1785
+	}
1786
+
1787
+	/**
1788
+	 *    getRegistrationExpirationNotice
1789
+	 *
1790
+	 * @since     4.9.59.p
1791
+	 * @return    string
1792
+	 */
1793
+	public static function getRegistrationExpirationNotice()
1794
+	{
1795
+		return sprintf(
1796
+			esc_html__(
1797
+				'%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1798
+				'event_espresso'
1799
+			),
1800
+			'<h4 class="important-notice">',
1801
+			'</h4>',
1802
+			'<br />',
1803
+			'<p>',
1804
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1805
+			'">',
1806
+			'</a>',
1807
+			'</p>'
1808
+		);
1809
+	}
1810 1810
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     public static function set_hooks_admin()
116 116
     {
117 117
         EED_Single_Page_Checkout::set_definitions();
118
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
118
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
119 119
             return;
120 120
         }
121 121
         // going to start an output buffer in case anything gets accidentally output
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         }
219 219
         define(
220 220
             'SPCO_BASE_PATH',
221
-            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
221
+            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/').'/'
222 222
         );
223
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/');
224
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/');
225
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/');
226
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/');
227
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/');
228
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/');
223
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css/');
224
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img/');
225
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js/');
226
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc/');
227
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps/');
228
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates/');
229 229
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
230 230
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(
231 231
         );
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             // we need a
257 257
             if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
258 258
                 // copy over to the reg_steps_array
259
-                EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
259
+                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
260 260
                 // register custom key route for each reg step
261 261
                 // ie: step=>"slug" - this is the entire reason we load the reg steps array now
262 262
                 EE_Config::register_route(
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                 // add AJAX or other hooks
269 269
                 if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
270 270
                     // setup autoloaders if necessary
271
-                    if (! class_exists($reg_step['class_name'])) {
271
+                    if ( ! class_exists($reg_step['class_name'])) {
272 272
                         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
273 273
                             $reg_step['file_path'],
274 274
                             true
@@ -295,19 +295,19 @@  discard block
 block discarded – undo
295 295
         if (empty($reg_steps)) {
296 296
             $reg_steps = array(
297 297
                 10  => array(
298
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
298
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
299 299
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
300 300
                     'slug'       => 'attendee_information',
301 301
                     'has_hooks'  => false,
302 302
                 ),
303 303
                 30  => array(
304
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
304
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
305 305
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
306 306
                     'slug'       => 'payment_options',
307 307
                     'has_hooks'  => true,
308 308
                 ),
309 309
                 999 => array(
310
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
310
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
311 311
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
312 312
                     'slug'       => 'finalize_registration',
313 313
                     'has_hooks'  => false,
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                 $this->checkout
460 460
             );
461 461
             // load the reg steps array
462
-            if (! $this->_load_and_instantiate_reg_steps()) {
462
+            if ( ! $this->_load_and_instantiate_reg_steps()) {
463 463
                 EED_Single_Page_Checkout::$_initialized = true;
464 464
                 return;
465 465
             }
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             // and the next step
469 469
             $this->checkout->set_next_step();
470 470
             // verify that everything has been setup correctly
471
-            if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
471
+            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
472 472
                 EED_Single_Page_Checkout::$_initialized = true;
473 473
                 return;
474 474
             }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
             // DEBUG LOG
484 484
             // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
485 485
             // get reg form
486
-            if (! $this->_check_form_submission()) {
486
+            if ( ! $this->_check_form_submission()) {
487 487
                 EED_Single_Page_Checkout::$_initialized = true;
488 488
                 return;
489 489
             }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      */
515 515
     private function _verify_session()
516 516
     {
517
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
517
+        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
518 518
             throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso'));
519 519
         }
520 520
         $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool');
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
             // EE_Registry::instance()->SSN->reset_cart();
532 532
             // EE_Registry::instance()->SSN->reset_checkout();
533 533
             // EE_Registry::instance()->SSN->reset_transaction();
534
-            if (! $clear_session_requested) {
534
+            if ( ! $clear_session_requested) {
535 535
                 EE_Error::add_attention(
536 536
                     EE_Registry::$i18n_js_strings['registration_expiration_notice'],
537 537
                     __FILE__,
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
         /** @type EE_Checkout $checkout */
559 559
         $checkout = EE_Registry::instance()->SSN->checkout();
560 560
         // verify
561
-        if (! $checkout instanceof EE_Checkout) {
561
+        if ( ! $checkout instanceof EE_Checkout) {
562 562
             // instantiate EE_Checkout object for handling the properties of the current checkout process
563 563
             $checkout = EE_Registry::instance()->load_file(
564 564
                 SPCO_INC_PATH,
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
         }
577 577
         $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
578 578
         // verify again
579
-        if (! $checkout instanceof EE_Checkout) {
579
+        if ( ! $checkout instanceof EE_Checkout) {
580 580
             throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso'));
581 581
         }
582 582
         // reset anything that needs a clean slate for each request
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
      */
638 638
     protected function _display_request_vars()
639 639
     {
640
-        if (! WP_DEBUG) {
640
+        if ( ! WP_DEBUG) {
641 641
             return;
642 642
         }
643 643
         EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__);
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         ) {
715 715
             // if not, then loop through raw reg steps array
716 716
             foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
717
-                if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
717
+                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
718 718
                     return false;
719 719
                 }
720 720
             }
@@ -847,12 +847,12 @@  discard block
 block discarded – undo
847 847
     private function _verify_transaction_and_get_registrations()
848 848
     {
849 849
         // was there already a valid transaction in the checkout from the session ?
850
-        if (! $this->checkout->transaction instanceof EE_Transaction) {
850
+        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
851 851
             // get transaction from db or session
852 852
             $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
853 853
                 ? $this->_get_transaction_and_cart_for_previous_visit()
854 854
                 : $this->_get_cart_for_current_session_and_setup_new_transaction();
855
-            if (! $this->checkout->transaction instanceof EE_Transaction) {
855
+            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
856 856
                 EE_Error::add_error(
857 857
                     esc_html__(
858 858
                         'Your Registration and Transaction information could not be retrieved from the db.',
@@ -1084,10 +1084,10 @@  discard block
 block discarded – undo
1084 1084
                         );
1085 1085
                     }
1086 1086
                     $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1087
-                    if (! $registration instanceof EE_Registration) {
1087
+                    if ( ! $registration instanceof EE_Registration) {
1088 1088
                         throw new InvalidEntityException($registration, 'EE_Registration');
1089 1089
                     }
1090
-                    $registrations[ $registration->ID() ] = $registration;
1090
+                    $registrations[$registration->ID()] = $registration;
1091 1091
                 }
1092 1092
             }
1093 1093
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
             $this->checkout
1130 1130
         );
1131 1131
         // verify that current step is still set correctly
1132
-        if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1132
+        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1133 1133
             EE_Error::add_error(
1134 1134
                 esc_html__(
1135 1135
                     '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.',
@@ -1142,9 +1142,9 @@  discard block
 block discarded – undo
1142 1142
             return false;
1143 1143
         }
1144 1144
         // if returning to SPCO, then verify that primary registrant is set
1145
-        if (! empty($this->checkout->reg_url_link)) {
1145
+        if ( ! empty($this->checkout->reg_url_link)) {
1146 1146
             $valid_registrant = $this->checkout->transaction->primary_registration();
1147
-            if (! $valid_registrant instanceof EE_Registration) {
1147
+            if ( ! $valid_registrant instanceof EE_Registration) {
1148 1148
                 EE_Error::add_error(
1149 1149
                     esc_html__(
1150 1150
                         '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.',
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
                     $valid_registrant = $registration;
1166 1166
                 }
1167 1167
             }
1168
-            if (! $valid_registrant instanceof EE_Registration) {
1168
+            if ( ! $valid_registrant instanceof EE_Registration) {
1169 1169
                 // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1170 1170
                 if (EED_Single_Page_Checkout::$_checkout_verified) {
1171 1171
                     // clear the session, mark the checkout as unverified, and try again
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
         $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1209 1209
         // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1210 1210
         foreach ($this->checkout->reg_steps as $reg_step) {
1211
-            if (! $reg_step->initialize_reg_step()) {
1211
+            if ( ! $reg_step->initialize_reg_step()) {
1212 1212
                 // if not initialized then maybe this step is being removed...
1213
-                if (! $reinitializing && $reg_step->is_current_step()) {
1213
+                if ( ! $reinitializing && $reg_step->is_current_step()) {
1214 1214
                     // if it was the current step, then we need to start over here
1215 1215
                     $this->_initialize_reg_steps(true);
1216 1216
                     return;
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
                         )
1264 1264
                     );
1265 1265
                     // validate submitted form data
1266
-                    if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1266
+                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1267 1267
                         // thou shall not pass !!!
1268 1268
                         $this->checkout->continue_reg = false;
1269 1269
                         // any form validation errors?
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
                         ) {
1340 1340
                             EE_Error::add_success(
1341 1341
                                 $this->checkout->current_step->success_message()
1342
-                                . '<br />' . $this->checkout->next_step->_instructions()
1342
+                                . '<br />'.$this->checkout->next_step->_instructions()
1343 1343
                             );
1344 1344
                         }
1345 1345
                         // pack it up, pack it in...
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
         // load css
1478 1478
         wp_register_style(
1479 1479
             'single_page_checkout',
1480
-            SPCO_CSS_URL . 'single_page_checkout.css',
1480
+            SPCO_CSS_URL.'single_page_checkout.css',
1481 1481
             array('espresso_default'),
1482 1482
             EVENT_ESPRESSO_VERSION
1483 1483
         );
@@ -1485,21 +1485,21 @@  discard block
 block discarded – undo
1485 1485
         // load JS
1486 1486
         wp_register_script(
1487 1487
             'jquery_plugin',
1488
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js',
1488
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.plugin.min.js',
1489 1489
             array('jquery'),
1490 1490
             '1.0.1',
1491 1491
             true
1492 1492
         );
1493 1493
         wp_register_script(
1494 1494
             'jquery_countdown',
1495
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js',
1495
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.countdown.min.js',
1496 1496
             array('jquery_plugin'),
1497 1497
             '2.1.0',
1498 1498
             true
1499 1499
         );
1500 1500
         wp_register_script(
1501 1501
             'single_page_checkout',
1502
-            SPCO_JS_URL . 'single_page_checkout.js',
1502
+            SPCO_JS_URL.'single_page_checkout.js',
1503 1503
             array('espresso_core', 'underscore', 'ee_form_section_validation'),
1504 1504
             EVENT_ESPRESSO_VERSION,
1505 1505
             true
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
          *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1526 1526
          */
1527 1527
         do_action(
1528
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1528
+            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(),
1529 1529
             $this
1530 1530
         );
1531 1531
     }
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
                     'layout_strategy' =>
1579 1579
                         new EE_Template_Layout(
1580 1580
                             array(
1581
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1581
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1582 1582
                                 'template_args'        => array(
1583 1583
                                     'empty_cart'              => $empty_cart,
1584 1584
                                     'revisit'                 => $this->checkout->revisit,
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
         ) {
1649 1649
             add_filter(
1650 1650
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1651
-                function ($url) {
1651
+                function($url) {
1652 1652
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1653 1653
                 }
1654 1654
             );
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
             '</h4>',
1802 1802
             '<br />',
1803 1803
             '<p>',
1804
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1804
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1805 1805
             '">',
1806 1806
             '</a>',
1807 1807
             '</p>'
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.010');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.010');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.