Completed
Branch fix-dummy-related-question-qst... (e5efcf)
by
unknown
07:49 queued 03:45
created
modules/single_page_checkout/inc/EE_Checkout.class.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public function reg_status_updated($REG_ID)
316 316
     {
317
-        return isset($this->reg_status_updated[ $REG_ID ]) ? $this->reg_status_updated[ $REG_ID ] : false;
317
+        return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false;
318 318
     }
319 319
 
320 320
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function set_reg_status_updated($REG_ID, $reg_status)
326 326
     {
327
-        $this->reg_status_updated[ $REG_ID ] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
327
+        $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
328 328
     }
329 329
 
330 330
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj)
386 386
     {
387
-        $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj;
387
+        $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj;
388 388
     }
389 389
 
390 390
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
      */
431 431
     public function remove_reg_step($reg_step_slug = '', $reset = true)
432 432
     {
433
-        unset($this->reg_steps[ $reg_step_slug ]);
433
+        unset($this->reg_steps[$reg_step_slug]);
434 434
         if ($this->transaction instanceof EE_Transaction) {
435 435
             // now remove reg step from TXN and save
436 436
             $this->transaction->remove_reg_step($reg_step_slug);
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
      */
453 453
     public function set_reg_step_order($reg_step_slug = '', $order = 100)
454 454
     {
455
-        if (isset($this->reg_steps[ $reg_step_slug ])) {
456
-            $this->reg_steps[ $reg_step_slug ]->set_order($order);
455
+        if (isset($this->reg_steps[$reg_step_slug])) {
456
+            $this->reg_steps[$reg_step_slug]->set_order($order);
457 457
         }
458 458
     }
459 459
 
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
     public function set_current_step($current_step)
469 469
     {
470 470
         // grab what step we're on
471
-        $this->current_step = isset($this->reg_steps[ $current_step ])
472
-            ? $this->reg_steps[ $current_step ]
471
+        $this->current_step = isset($this->reg_steps[$current_step])
472
+            ? $this->reg_steps[$current_step]
473 473
             : reset(
474 474
                 $this->reg_steps
475 475
             );
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
      */
581 581
     public function find_reg_step($reg_step_slug = '')
582 582
     {
583
-        if (! empty($reg_step_slug)) {
583
+        if ( ! empty($reg_step_slug)) {
584 584
             // copy reg step array
585 585
             $reg_steps = $this->reg_steps;
586 586
             // set pointer to start of array
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
             )
643 643
         ) {
644 644
             // set the start time for this reg step
645
-            if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
645
+            if ( ! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
646 646
                 if (WP_DEBUG) {
647 647
                     EE_Error::add_error(
648 648
                         sprintf(
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
         $session = EE_Registry::instance()->load_core('Session');
746 746
         $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
747 747
         // verify cart
748
-        if (! $cart instanceof EE_Cart) {
748
+        if ( ! $cart instanceof EE_Cart) {
749 749
             $cart = EE_Registry::instance()->load_core('Cart');
750 750
         }
751 751
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
     {
764 764
         $txn_reg_steps_array = array();
765 765
         foreach ($this->reg_steps as $reg_step) {
766
-            $txn_reg_steps_array[ $reg_step->slug() ] = false;
766
+            $txn_reg_steps_array[$reg_step->slug()] = false;
767 767
         }
768 768
         return $txn_reg_steps_array;
769 769
     }
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
      */
803 803
     public function stash_transaction_and_checkout()
804 804
     {
805
-        if (! $this->revisit) {
805
+        if ( ! $this->revisit) {
806 806
             $this->update_txn_reg_steps_array();
807 807
         }
808 808
         $this->track_transaction_and_registration_status_updates();
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
             // should this registration be processed during this visit ?
930 930
             if ($this->visit_allows_processing_of_this_registration($registration)) {
931 931
                 // set TXN ID
932
-                if (! $registration->transaction_ID()) {
932
+                if ( ! $registration->transaction_ID()) {
933 933
                     $registration->set_transaction_id($this->transaction->ID());
934 934
                 }
935 935
                 // verify and save the attendee
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
                 // save changes
940 940
                 $registration->save();
941 941
                 // update txn cache
942
-                if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
942
+                if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
943 943
                     if ($show_errors) {
944 944
                         EE_Error::add_error(
945 945
                             esc_html__(
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
         if ($registration->attendee() instanceof EE_Attendee) {
983 983
             // save so that ATT has ID
984 984
             $registration->attendee()->save();
985
-            if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
985
+            if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
986 986
                 if ($show_errors) {
987 987
                     EE_Error::add_error(
988 988
                         esc_html__(
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
             if ($answer instanceof EE_Answer) {
1032 1032
                 $answer->set_registration($registration->ID());
1033 1033
                 $answer->save();
1034
-                if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1034
+                if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1035 1035
                     if ($show_errors) {
1036 1036
                         EE_Error::add_error(
1037 1037
                             esc_html__(
@@ -1352,11 +1352,11 @@  discard block
 block discarded – undo
1352 1352
      */
1353 1353
     public function __wakeup()
1354 1354
     {
1355
-        if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1355
+        if ( ! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1356 1356
             // $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1357 1357
             $this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1358 1358
         }
1359
-        if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1359
+        if ( ! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1360 1360
             // $this->transaction is actually just an ID, so use it to get the object from the db
1361 1361
             $this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1362 1362
         }
@@ -1380,9 +1380,9 @@  discard block
 block discarded – undo
1380 1380
     {
1381 1381
         $disabled = true;
1382 1382
         if (WP_DEBUG && ! $disabled) {
1383
-            $debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1383
+            $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array());
1384 1384
             $default_data = array(
1385
-                $class                    => $func . '() : ' . $line,
1385
+                $class                    => $func.'() : '.$line,
1386 1386
                 'request->step'           => $this->step,
1387 1387
                 'request->action'         => $this->action,
1388 1388
                 'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
@@ -1397,20 +1397,20 @@  discard block
 block discarded – undo
1397 1397
                 $default_data['TXN_status'] = $this->transaction->status_ID();
1398 1398
                 $default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1399 1399
                 foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1400
-                    $default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1400
+                    $default_data['registrations'][$REG_ID] = $registration->status_ID();
1401 1401
                 }
1402 1402
                 if ($this->transaction->ID()) {
1403
-                    $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1403
+                    $TXN_ID = 'EE_Transaction: '.$this->transaction->ID();
1404 1404
                     // don't serialize objects
1405 1405
                     $info = $this->_strip_objects($info);
1406
-                    if (! isset($debug_data[ $TXN_ID ])) {
1407
-                        $debug_data[ $TXN_ID ] = array();
1406
+                    if ( ! isset($debug_data[$TXN_ID])) {
1407
+                        $debug_data[$TXN_ID] = array();
1408 1408
                     }
1409
-                    $debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1409
+                    $debug_data[$TXN_ID][microtime()] = array_merge(
1410 1410
                         $default_data,
1411 1411
                         $info
1412 1412
                     );
1413
-                    update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1413
+                    update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data);
1414 1414
                 }
1415 1415
             }
1416 1416
         }
@@ -1427,17 +1427,17 @@  discard block
 block discarded – undo
1427 1427
     {
1428 1428
         foreach ((array) $info as $key => $value) {
1429 1429
             if (is_array($value)) {
1430
-                $info[ $key ] = $this->_strip_objects($value);
1430
+                $info[$key] = $this->_strip_objects($value);
1431 1431
             } elseif (is_object($value)) {
1432 1432
                 $object_class = get_class($value);
1433
-                $info[ $object_class ] = array();
1434
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1433
+                $info[$object_class] = array();
1434
+                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1435 1435
                 if (method_exists($value, 'status')) {
1436
-                    $info[ $object_class ]['status'] = $value->status();
1436
+                    $info[$object_class]['status'] = $value->status();
1437 1437
                 } elseif (method_exists($value, 'status_ID')) {
1438
-                    $info[ $object_class ]['status'] = $value->status_ID();
1438
+                    $info[$object_class]['status'] = $value->status_ID();
1439 1439
                 }
1440
-                unset($info[ $key ]);
1440
+                unset($info[$key]);
1441 1441
             }
1442 1442
         }
1443 1443
         return (array) $info;
Please login to merge, or discard this patch.
Indentation   +1427 added lines, -1427 removed lines patch added patch discarded remove patch
@@ -14,1432 +14,1432 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Checkout
16 16
 {
17
-    /**
18
-     *    whether current request originated from the EE admin
19
-     *
20
-     * @type bool
21
-     */
22
-    public $admin_request = false;
23
-
24
-    /**
25
-     * whether returning to edit attendee information or to retry a payment
26
-     *
27
-     * @type bool
28
-     */
29
-    public $revisit = false;
30
-
31
-    /**
32
-     * whether the primary registrant is returning to edit attendee information or to retry a payment
33
-     *
34
-     * @type bool
35
-     */
36
-    public $primary_revisit = false;
37
-
38
-    /**
39
-     * is registration allowed to progress or halted for some reason such as failing to pass recaptcha?
40
-     *
41
-     * @type bool
42
-     */
43
-    public $continue_reg = true;
44
-
45
-    /**
46
-     * redirect to thank you page ?
47
-     *
48
-     * @type bool
49
-     */
50
-    public $redirect = false;
51
-
52
-    /**
53
-     * generate the reg form or not ?
54
-     *
55
-     * @type bool
56
-     */
57
-    public $generate_reg_form = true;
58
-
59
-    /**
60
-     * process a reg form submission or not ?
61
-     *
62
-     * @type bool
63
-     */
64
-    public $process_form_submission = false;
65
-
66
-    /**
67
-     * tracks whether the TXN status modified during this checkout
68
-     *
69
-     * @type bool
70
-     */
71
-    public $txn_status_updated = false;
72
-
73
-    /**
74
-     * only triggered to true after absolutely everything has finished.
75
-     *
76
-     * @type bool
77
-     */
78
-    protected $exit_spco = false;
79
-
80
-    /**
81
-     * tracks whether any of the TXN's Registrations statuses modified during this checkout
82
-     * indexed by registration ID
83
-     *
84
-     * @type array
85
-     */
86
-    protected $reg_status_updated = array();
87
-
88
-    /**
89
-     * timestamp when redirected from Ticket Selector to the checkout
90
-     *
91
-     * @type int
92
-     */
93
-    public $uts = 0;
94
-
95
-    /**
96
-     * total number of tickets that were in the cart
97
-     *
98
-     * @type int
99
-     */
100
-    public $total_ticket_count = 0;
101
-
102
-    /**
103
-     * corresponds loosely to EE_Transaction::remaining()
104
-     * but can be modified by SPCO
105
-     *
106
-     * @type float
107
-     */
108
-    public $amount_owing = 0;
109
-
110
-    /**
111
-     * the reg step slug from the incoming request
112
-     *
113
-     * @type string
114
-     */
115
-    public $step = '';
116
-
117
-    /**
118
-     * the reg step slug for a step being edited
119
-     *
120
-     * @type string
121
-     */
122
-    public $edit_step = '';
123
-
124
-    /**
125
-     * the action being performed on the current step
126
-     *
127
-     * @type string
128
-     */
129
-    public $action = '';
130
-
131
-    /**
132
-     * reg_url_link for a previously saved registration
133
-     *
134
-     * @type string
135
-     */
136
-    public $reg_url_link = '';
137
-
138
-    /**
139
-     * string slug for the payment method that was selected during the payment options step
140
-     *
141
-     * @type string
142
-     */
143
-    public $selected_method_of_payment = '';
144
-
145
-    /**
146
-     * base url for the site's registration checkout page - additional url params will be added to this
147
-     *
148
-     * @type string
149
-     */
150
-    public $reg_page_base_url = '';
151
-
152
-    /**
153
-     * base url for the site's registration cancelled page - additional url params will be added to this
154
-     *
155
-     * @type string
156
-     */
157
-    public $cancel_page_url = '';
158
-
159
-    /**
160
-     * base url for the site's thank you page - additional url params will be added to this
161
-     *
162
-     * @type string
163
-     */
164
-    public $thank_you_page_url = '';
165
-
166
-    /**
167
-     * base url for any redirects - additional url params will be added to this
168
-     *
169
-     * @type string
170
-     */
171
-    public $redirect_url = '';
172
-
173
-    /**
174
-     * form of POST data for use with off-site gateways
175
-     *
176
-     * @type string
177
-     */
178
-    public $redirect_form = '';
179
-
180
-    /**
181
-     * array of query where params to use when retrieving cached registrations from $this->checkout->transaction
182
-     *
183
-     * @type array
184
-     */
185
-    public $reg_cache_where_params = array();
186
-
187
-    /**
188
-     * a class for managing and creating the JSON encoded array of data that gets passed back to the client during AJAX
189
-     * requests
190
-     *
191
-     * @type EE_SPCO_JSON_Response
192
-     */
193
-    public $json_response;
194
-
195
-    /**
196
-     * where we are going next in the reg process
197
-     *
198
-     * @type EE_SPCO_Reg_Step
199
-     */
200
-    public $next_step;
201
-
202
-    /**
203
-     * where we are in the reg process
204
-     *
205
-     * @type EE_SPCO_Reg_Step
206
-     */
207
-    public $current_step;
208
-
209
-    /**
210
-     *    $_cart - the current cart object
211
-     *
212
-     * @var EE_CART
213
-     */
214
-    public $cart;
215
-
216
-    /**
217
-     *    $_transaction - the current transaction object
218
-     *
219
-     * @var EE_Transaction
220
-     */
221
-    public $transaction;
222
-
223
-    /**
224
-     *    the related attendee object for the primary registrant
225
-     *
226
-     * @type EE_Attendee
227
-     */
228
-    public $primary_attendee_obj;
229
-
230
-    /**
231
-     *    $payment_method - the payment method object for the selected method of payment
232
-     *
233
-     * @type EE_Payment_Method
234
-     */
235
-    public $payment_method;
236
-
237
-    /**
238
-     *    $payment - if a payment was successfully made during the reg process,
239
-     *    then here it is !!!
240
-     *
241
-     * @type EE_Payment
242
-     */
243
-    public $payment;
244
-
245
-    /**
246
-     *    if a payment method was selected that uses an on-site gateway, then this is the billing form
247
-     *
248
-     * @type EE_Billing_Info_Form | EE_Billing_Attendee_Info_Form
249
-     */
250
-    public $billing_form;
251
-
252
-    /**
253
-     *    the entire registration form composed of ALL of the subsections generated by the various reg steps
254
-     *
255
-     * @type EE_Form_Section_Proper
256
-     */
257
-    public $registration_form;
258
-
259
-    /**
260
-     * array of EE_SPCO_Reg_Step objects
261
-     *
262
-     * @type EE_SPCO_Reg_Step[]
263
-     */
264
-    public $reg_steps = array();
265
-
266
-    /**
267
-     * array of EE_Payment_Method objects
268
-     *
269
-     * @type EE_Payment_Method[]
270
-     */
271
-    public $available_payment_methods = array();
272
-
273
-
274
-    /**
275
-     *    class constructor
276
-     *
277
-     * @access    public
278
-     */
279
-    public function __construct()
280
-    {
281
-        $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url();
282
-        $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url();
283
-        $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url();
284
-        $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
285
-
286
-        $this->admin_request = is_admin() && ! EED_Single_Page_Checkout::getRequest()->isAjax();
287
-        $this->reg_cache_where_params = array(
288
-            0          => array('REG_deleted' => false),
289
-            'order_by' => array('REG_count' => 'ASC'),
290
-        );
291
-    }
292
-
293
-
294
-    /**
295
-     * returns true if ANY reg status was updated during checkout
296
-     *
297
-     * @return boolean
298
-     */
299
-    public function any_reg_status_updated()
300
-    {
301
-        foreach ($this->reg_status_updated as $reg_status) {
302
-            if ($reg_status) {
303
-                return true;
304
-            }
305
-        }
306
-        return false;
307
-    }
308
-
309
-
310
-    /**
311
-     * @param $REG_ID
312
-     * @return boolean
313
-     */
314
-    public function reg_status_updated($REG_ID)
315
-    {
316
-        return isset($this->reg_status_updated[ $REG_ID ]) ? $this->reg_status_updated[ $REG_ID ] : false;
317
-    }
318
-
319
-
320
-    /**
321
-     * @param $REG_ID
322
-     * @param $reg_status
323
-     */
324
-    public function set_reg_status_updated($REG_ID, $reg_status)
325
-    {
326
-        $this->reg_status_updated[ $REG_ID ] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
327
-    }
328
-
329
-
330
-    /**
331
-     * exit_spco
332
-     *
333
-     * @return bool
334
-     */
335
-    public function exit_spco()
336
-    {
337
-        return $this->exit_spco;
338
-    }
339
-
340
-
341
-    /**
342
-     * set_exit_spco
343
-     * can ONLY be set by the  Finalize_Registration reg step
344
-     */
345
-    public function set_exit_spco()
346
-    {
347
-        if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
348
-            $this->exit_spco = true;
349
-        }
350
-    }
351
-
352
-
353
-    /**
354
-     *    reset_for_current_request
355
-     *
356
-     * @access    public
357
-     * @return    void
358
-     */
359
-    public function reset_for_current_request()
360
-    {
361
-        $this->process_form_submission = false;
362
-        $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
363
-        $this->admin_request = is_admin() && ! EED_Single_Page_Checkout::getRequest()->isFrontAjax();
364
-        $this->continue_reg = true;
365
-        $this->redirect = false;
366
-        // don't reset the cached redirect form if we're about to be asked to display it !!!
367
-        $action = EED_Single_Page_Checkout::getRequest()->getRequestParam('action', 'display_spco_reg_step');
368
-        if ($action !== 'redirect_form') {
369
-            $this->redirect_form = '';
370
-        }
371
-        $this->redirect_url = '';
372
-        $this->json_response = new EE_SPCO_JSON_Response();
373
-        EE_Form_Section_Proper::reset_js_localization();
374
-    }
375
-
376
-
377
-    /**
378
-     *    add_reg_step
379
-     *
380
-     * @access    public
381
-     * @param EE_SPCO_Reg_Step $reg_step_obj
382
-     * @return    void
383
-     */
384
-    public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj)
385
-    {
386
-        $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj;
387
-    }
388
-
389
-
390
-    /**
391
-     * skip_reg_step
392
-     * if the current reg step does not need to run for some reason,
393
-     * then this will advance SPCO to the next reg step,
394
-     * and mark the skipped step as completed
395
-     *
396
-     * @access    public
397
-     * @param string $reg_step_slug
398
-     * @return    void
399
-     * @throws \EE_Error
400
-     */
401
-    public function skip_reg_step($reg_step_slug = '')
402
-    {
403
-        $step_to_skip = $this->find_reg_step($reg_step_slug);
404
-        if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) {
405
-            $step_to_skip->set_is_current_step(false);
406
-            $step_to_skip->set_completed();
407
-            // advance to the next step
408
-            $this->set_current_step($this->next_step->slug());
409
-            // also reset the step param in the request in case any other code references that directly
410
-            EED_Single_Page_Checkout::getRequest()->setRequestParam('step', $this->current_step->slug());
411
-            // since we are skipping a step and setting the current step to be what was previously the next step,
412
-            // we need to check that the next step is now correct, and not still set to the current step.
413
-            if ($this->current_step->slug() === $this->next_step->slug()) {
414
-                // correctly setup the next step
415
-                $this->set_next_step();
416
-            }
417
-            $this->set_reg_step_initiated($this->current_step);
418
-        }
419
-    }
420
-
421
-
422
-    /**
423
-     *    remove_reg_step
424
-     *
425
-     * @access    public
426
-     * @param string $reg_step_slug
427
-     * @param bool   $reset whether to reset reg steps after removal
428
-     * @throws EE_Error
429
-     */
430
-    public function remove_reg_step($reg_step_slug = '', $reset = true)
431
-    {
432
-        unset($this->reg_steps[ $reg_step_slug ]);
433
-        if ($this->transaction instanceof EE_Transaction) {
434
-            // now remove reg step from TXN and save
435
-            $this->transaction->remove_reg_step($reg_step_slug);
436
-            $this->transaction->save();
437
-        }
438
-        if ($reset) {
439
-            $this->reset_reg_steps();
440
-        }
441
-    }
442
-
443
-
444
-    /**
445
-     *    set_reg_step_order
446
-     *
447
-     * @access    public
448
-     * @param string $reg_step_slug
449
-     * @param int    $order
450
-     * @return    void
451
-     */
452
-    public function set_reg_step_order($reg_step_slug = '', $order = 100)
453
-    {
454
-        if (isset($this->reg_steps[ $reg_step_slug ])) {
455
-            $this->reg_steps[ $reg_step_slug ]->set_order($order);
456
-        }
457
-    }
458
-
459
-
460
-    /**
461
-     *    set_current_step
462
-     *
463
-     * @access    public
464
-     * @param string $current_step
465
-     * @return    void
466
-     */
467
-    public function set_current_step($current_step)
468
-    {
469
-        // grab what step we're on
470
-        $this->current_step = isset($this->reg_steps[ $current_step ])
471
-            ? $this->reg_steps[ $current_step ]
472
-            : reset(
473
-                $this->reg_steps
474
-            );
475
-        // verify instance
476
-        if ($this->current_step instanceof EE_SPCO_Reg_Step) {
477
-            // we don't want to repeat completed steps if this is the first time through SPCO
478
-            if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) {
479
-                // so advance to the next step
480
-                $this->set_next_step();
481
-                if ($this->next_step instanceof EE_SPCO_Reg_Step) {
482
-                    // and attempt to set it as the current step
483
-                    $this->set_current_step($this->next_step->slug());
484
-                }
485
-                return;
486
-            }
487
-            $this->current_step->set_is_current_step(true);
488
-        } else {
489
-            EE_Error::add_error(
490
-                esc_html__('The current step could not be set.', 'event_espresso'),
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-    }
497
-
498
-
499
-    /**
500
-     *    set_next_step
501
-     * advances the reg_steps array pointer and sets the next step, then reverses pointer back to the current step
502
-     *
503
-     * @access    public
504
-     * @return    void
505
-     */
506
-    public function set_next_step()
507
-    {
508
-        // set pointer to start of array
509
-        reset($this->reg_steps);
510
-        // if there is more than one step
511
-        if (count($this->reg_steps) > 1) {
512
-            // advance to the current step and set pointer
513
-            while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') {
514
-                next($this->reg_steps);
515
-            }
516
-        }
517
-        // advance one more spot ( if it exists )
518
-        $this->next_step = next($this->reg_steps);
519
-        // verify instance
520
-        $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : null;
521
-        // then back to current step to reset
522
-        prev($this->reg_steps);
523
-    }
524
-
525
-
526
-    /**
527
-     *    get_next_reg_step
528
-     *    this simply returns the next step from reg_steps array
529
-     *
530
-     * @access    public
531
-     * @return    EE_SPCO_Reg_Step | null
532
-     */
533
-    public function get_next_reg_step()
534
-    {
535
-        $next = next($this->reg_steps);
536
-        prev($this->reg_steps);
537
-        return $next instanceof EE_SPCO_Reg_Step ? $next : null;
538
-    }
539
-
540
-
541
-    /**
542
-     * get_prev_reg_step
543
-     *    this simply returns the previous step from reg_steps array
544
-     *
545
-     * @access    public
546
-     * @return    EE_SPCO_Reg_Step | null
547
-     */
548
-    public function get_prev_reg_step()
549
-    {
550
-        $prev = prev($this->reg_steps);
551
-        next($this->reg_steps);
552
-        return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
553
-    }
554
-
555
-
556
-    /**
557
-     * sort_reg_steps
558
-     *
559
-     * @access public
560
-     * @return void
561
-     */
562
-    public function sort_reg_steps()
563
-    {
564
-        $reg_step_sorting_callback = apply_filters(
565
-            'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback',
566
-            'reg_step_sorting_callback'
567
-        );
568
-        uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
569
-    }
570
-
571
-
572
-    /**
573
-     * find_reg_step
574
-     * finds a reg step by the given slug
575
-     *
576
-     * @access    public
577
-     * @param string $reg_step_slug
578
-     * @return EE_SPCO_Reg_Step|null
579
-     */
580
-    public function find_reg_step($reg_step_slug = '')
581
-    {
582
-        if (! empty($reg_step_slug)) {
583
-            // copy reg step array
584
-            $reg_steps = $this->reg_steps;
585
-            // set pointer to start of array
586
-            reset($reg_steps);
587
-            // if there is more than one step
588
-            if (count($reg_steps) > 1) {
589
-                // advance to the current step and set pointer
590
-                while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') {
591
-                    next($reg_steps);
592
-                }
593
-                return current($reg_steps);
594
-            }
595
-        }
596
-        return null;
597
-    }
598
-
599
-
600
-    /**
601
-     * reg_step_sorting_callback
602
-     *
603
-     * @access public
604
-     * @param EE_SPCO_Reg_Step $reg_step_A
605
-     * @param EE_SPCO_Reg_Step $reg_step_B
606
-     * @return int
607
-     */
608
-    public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B)
609
-    {
610
-        // send finalize_registration step to the end of the array
611
-        if ($reg_step_A->slug() === 'finalize_registration') {
612
-            return 1;
613
-        } elseif ($reg_step_B->slug() === 'finalize_registration') {
614
-            return -1;
615
-        }
616
-        if ($reg_step_A->order() === $reg_step_B->order()) {
617
-            return 0;
618
-        }
619
-        return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
620
-    }
621
-
622
-
623
-    /**
624
-     * set_reg_step_initiated
625
-     *
626
-     * @access    public
627
-     * @param    EE_SPCO_Reg_Step $reg_step
628
-     * @throws \EE_Error
629
-     */
630
-    public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step)
631
-    {
632
-        // call set_reg_step_initiated ???
633
-        if (
17
+	/**
18
+	 *    whether current request originated from the EE admin
19
+	 *
20
+	 * @type bool
21
+	 */
22
+	public $admin_request = false;
23
+
24
+	/**
25
+	 * whether returning to edit attendee information or to retry a payment
26
+	 *
27
+	 * @type bool
28
+	 */
29
+	public $revisit = false;
30
+
31
+	/**
32
+	 * whether the primary registrant is returning to edit attendee information or to retry a payment
33
+	 *
34
+	 * @type bool
35
+	 */
36
+	public $primary_revisit = false;
37
+
38
+	/**
39
+	 * is registration allowed to progress or halted for some reason such as failing to pass recaptcha?
40
+	 *
41
+	 * @type bool
42
+	 */
43
+	public $continue_reg = true;
44
+
45
+	/**
46
+	 * redirect to thank you page ?
47
+	 *
48
+	 * @type bool
49
+	 */
50
+	public $redirect = false;
51
+
52
+	/**
53
+	 * generate the reg form or not ?
54
+	 *
55
+	 * @type bool
56
+	 */
57
+	public $generate_reg_form = true;
58
+
59
+	/**
60
+	 * process a reg form submission or not ?
61
+	 *
62
+	 * @type bool
63
+	 */
64
+	public $process_form_submission = false;
65
+
66
+	/**
67
+	 * tracks whether the TXN status modified during this checkout
68
+	 *
69
+	 * @type bool
70
+	 */
71
+	public $txn_status_updated = false;
72
+
73
+	/**
74
+	 * only triggered to true after absolutely everything has finished.
75
+	 *
76
+	 * @type bool
77
+	 */
78
+	protected $exit_spco = false;
79
+
80
+	/**
81
+	 * tracks whether any of the TXN's Registrations statuses modified during this checkout
82
+	 * indexed by registration ID
83
+	 *
84
+	 * @type array
85
+	 */
86
+	protected $reg_status_updated = array();
87
+
88
+	/**
89
+	 * timestamp when redirected from Ticket Selector to the checkout
90
+	 *
91
+	 * @type int
92
+	 */
93
+	public $uts = 0;
94
+
95
+	/**
96
+	 * total number of tickets that were in the cart
97
+	 *
98
+	 * @type int
99
+	 */
100
+	public $total_ticket_count = 0;
101
+
102
+	/**
103
+	 * corresponds loosely to EE_Transaction::remaining()
104
+	 * but can be modified by SPCO
105
+	 *
106
+	 * @type float
107
+	 */
108
+	public $amount_owing = 0;
109
+
110
+	/**
111
+	 * the reg step slug from the incoming request
112
+	 *
113
+	 * @type string
114
+	 */
115
+	public $step = '';
116
+
117
+	/**
118
+	 * the reg step slug for a step being edited
119
+	 *
120
+	 * @type string
121
+	 */
122
+	public $edit_step = '';
123
+
124
+	/**
125
+	 * the action being performed on the current step
126
+	 *
127
+	 * @type string
128
+	 */
129
+	public $action = '';
130
+
131
+	/**
132
+	 * reg_url_link for a previously saved registration
133
+	 *
134
+	 * @type string
135
+	 */
136
+	public $reg_url_link = '';
137
+
138
+	/**
139
+	 * string slug for the payment method that was selected during the payment options step
140
+	 *
141
+	 * @type string
142
+	 */
143
+	public $selected_method_of_payment = '';
144
+
145
+	/**
146
+	 * base url for the site's registration checkout page - additional url params will be added to this
147
+	 *
148
+	 * @type string
149
+	 */
150
+	public $reg_page_base_url = '';
151
+
152
+	/**
153
+	 * base url for the site's registration cancelled page - additional url params will be added to this
154
+	 *
155
+	 * @type string
156
+	 */
157
+	public $cancel_page_url = '';
158
+
159
+	/**
160
+	 * base url for the site's thank you page - additional url params will be added to this
161
+	 *
162
+	 * @type string
163
+	 */
164
+	public $thank_you_page_url = '';
165
+
166
+	/**
167
+	 * base url for any redirects - additional url params will be added to this
168
+	 *
169
+	 * @type string
170
+	 */
171
+	public $redirect_url = '';
172
+
173
+	/**
174
+	 * form of POST data for use with off-site gateways
175
+	 *
176
+	 * @type string
177
+	 */
178
+	public $redirect_form = '';
179
+
180
+	/**
181
+	 * array of query where params to use when retrieving cached registrations from $this->checkout->transaction
182
+	 *
183
+	 * @type array
184
+	 */
185
+	public $reg_cache_where_params = array();
186
+
187
+	/**
188
+	 * a class for managing and creating the JSON encoded array of data that gets passed back to the client during AJAX
189
+	 * requests
190
+	 *
191
+	 * @type EE_SPCO_JSON_Response
192
+	 */
193
+	public $json_response;
194
+
195
+	/**
196
+	 * where we are going next in the reg process
197
+	 *
198
+	 * @type EE_SPCO_Reg_Step
199
+	 */
200
+	public $next_step;
201
+
202
+	/**
203
+	 * where we are in the reg process
204
+	 *
205
+	 * @type EE_SPCO_Reg_Step
206
+	 */
207
+	public $current_step;
208
+
209
+	/**
210
+	 *    $_cart - the current cart object
211
+	 *
212
+	 * @var EE_CART
213
+	 */
214
+	public $cart;
215
+
216
+	/**
217
+	 *    $_transaction - the current transaction object
218
+	 *
219
+	 * @var EE_Transaction
220
+	 */
221
+	public $transaction;
222
+
223
+	/**
224
+	 *    the related attendee object for the primary registrant
225
+	 *
226
+	 * @type EE_Attendee
227
+	 */
228
+	public $primary_attendee_obj;
229
+
230
+	/**
231
+	 *    $payment_method - the payment method object for the selected method of payment
232
+	 *
233
+	 * @type EE_Payment_Method
234
+	 */
235
+	public $payment_method;
236
+
237
+	/**
238
+	 *    $payment - if a payment was successfully made during the reg process,
239
+	 *    then here it is !!!
240
+	 *
241
+	 * @type EE_Payment
242
+	 */
243
+	public $payment;
244
+
245
+	/**
246
+	 *    if a payment method was selected that uses an on-site gateway, then this is the billing form
247
+	 *
248
+	 * @type EE_Billing_Info_Form | EE_Billing_Attendee_Info_Form
249
+	 */
250
+	public $billing_form;
251
+
252
+	/**
253
+	 *    the entire registration form composed of ALL of the subsections generated by the various reg steps
254
+	 *
255
+	 * @type EE_Form_Section_Proper
256
+	 */
257
+	public $registration_form;
258
+
259
+	/**
260
+	 * array of EE_SPCO_Reg_Step objects
261
+	 *
262
+	 * @type EE_SPCO_Reg_Step[]
263
+	 */
264
+	public $reg_steps = array();
265
+
266
+	/**
267
+	 * array of EE_Payment_Method objects
268
+	 *
269
+	 * @type EE_Payment_Method[]
270
+	 */
271
+	public $available_payment_methods = array();
272
+
273
+
274
+	/**
275
+	 *    class constructor
276
+	 *
277
+	 * @access    public
278
+	 */
279
+	public function __construct()
280
+	{
281
+		$this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url();
282
+		$this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url();
283
+		$this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url();
284
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
285
+
286
+		$this->admin_request = is_admin() && ! EED_Single_Page_Checkout::getRequest()->isAjax();
287
+		$this->reg_cache_where_params = array(
288
+			0          => array('REG_deleted' => false),
289
+			'order_by' => array('REG_count' => 'ASC'),
290
+		);
291
+	}
292
+
293
+
294
+	/**
295
+	 * returns true if ANY reg status was updated during checkout
296
+	 *
297
+	 * @return boolean
298
+	 */
299
+	public function any_reg_status_updated()
300
+	{
301
+		foreach ($this->reg_status_updated as $reg_status) {
302
+			if ($reg_status) {
303
+				return true;
304
+			}
305
+		}
306
+		return false;
307
+	}
308
+
309
+
310
+	/**
311
+	 * @param $REG_ID
312
+	 * @return boolean
313
+	 */
314
+	public function reg_status_updated($REG_ID)
315
+	{
316
+		return isset($this->reg_status_updated[ $REG_ID ]) ? $this->reg_status_updated[ $REG_ID ] : false;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @param $REG_ID
322
+	 * @param $reg_status
323
+	 */
324
+	public function set_reg_status_updated($REG_ID, $reg_status)
325
+	{
326
+		$this->reg_status_updated[ $REG_ID ] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
327
+	}
328
+
329
+
330
+	/**
331
+	 * exit_spco
332
+	 *
333
+	 * @return bool
334
+	 */
335
+	public function exit_spco()
336
+	{
337
+		return $this->exit_spco;
338
+	}
339
+
340
+
341
+	/**
342
+	 * set_exit_spco
343
+	 * can ONLY be set by the  Finalize_Registration reg step
344
+	 */
345
+	public function set_exit_spco()
346
+	{
347
+		if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
348
+			$this->exit_spco = true;
349
+		}
350
+	}
351
+
352
+
353
+	/**
354
+	 *    reset_for_current_request
355
+	 *
356
+	 * @access    public
357
+	 * @return    void
358
+	 */
359
+	public function reset_for_current_request()
360
+	{
361
+		$this->process_form_submission = false;
362
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
363
+		$this->admin_request = is_admin() && ! EED_Single_Page_Checkout::getRequest()->isFrontAjax();
364
+		$this->continue_reg = true;
365
+		$this->redirect = false;
366
+		// don't reset the cached redirect form if we're about to be asked to display it !!!
367
+		$action = EED_Single_Page_Checkout::getRequest()->getRequestParam('action', 'display_spco_reg_step');
368
+		if ($action !== 'redirect_form') {
369
+			$this->redirect_form = '';
370
+		}
371
+		$this->redirect_url = '';
372
+		$this->json_response = new EE_SPCO_JSON_Response();
373
+		EE_Form_Section_Proper::reset_js_localization();
374
+	}
375
+
376
+
377
+	/**
378
+	 *    add_reg_step
379
+	 *
380
+	 * @access    public
381
+	 * @param EE_SPCO_Reg_Step $reg_step_obj
382
+	 * @return    void
383
+	 */
384
+	public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj)
385
+	{
386
+		$this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj;
387
+	}
388
+
389
+
390
+	/**
391
+	 * skip_reg_step
392
+	 * if the current reg step does not need to run for some reason,
393
+	 * then this will advance SPCO to the next reg step,
394
+	 * and mark the skipped step as completed
395
+	 *
396
+	 * @access    public
397
+	 * @param string $reg_step_slug
398
+	 * @return    void
399
+	 * @throws \EE_Error
400
+	 */
401
+	public function skip_reg_step($reg_step_slug = '')
402
+	{
403
+		$step_to_skip = $this->find_reg_step($reg_step_slug);
404
+		if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) {
405
+			$step_to_skip->set_is_current_step(false);
406
+			$step_to_skip->set_completed();
407
+			// advance to the next step
408
+			$this->set_current_step($this->next_step->slug());
409
+			// also reset the step param in the request in case any other code references that directly
410
+			EED_Single_Page_Checkout::getRequest()->setRequestParam('step', $this->current_step->slug());
411
+			// since we are skipping a step and setting the current step to be what was previously the next step,
412
+			// we need to check that the next step is now correct, and not still set to the current step.
413
+			if ($this->current_step->slug() === $this->next_step->slug()) {
414
+				// correctly setup the next step
415
+				$this->set_next_step();
416
+			}
417
+			$this->set_reg_step_initiated($this->current_step);
418
+		}
419
+	}
420
+
421
+
422
+	/**
423
+	 *    remove_reg_step
424
+	 *
425
+	 * @access    public
426
+	 * @param string $reg_step_slug
427
+	 * @param bool   $reset whether to reset reg steps after removal
428
+	 * @throws EE_Error
429
+	 */
430
+	public function remove_reg_step($reg_step_slug = '', $reset = true)
431
+	{
432
+		unset($this->reg_steps[ $reg_step_slug ]);
433
+		if ($this->transaction instanceof EE_Transaction) {
434
+			// now remove reg step from TXN and save
435
+			$this->transaction->remove_reg_step($reg_step_slug);
436
+			$this->transaction->save();
437
+		}
438
+		if ($reset) {
439
+			$this->reset_reg_steps();
440
+		}
441
+	}
442
+
443
+
444
+	/**
445
+	 *    set_reg_step_order
446
+	 *
447
+	 * @access    public
448
+	 * @param string $reg_step_slug
449
+	 * @param int    $order
450
+	 * @return    void
451
+	 */
452
+	public function set_reg_step_order($reg_step_slug = '', $order = 100)
453
+	{
454
+		if (isset($this->reg_steps[ $reg_step_slug ])) {
455
+			$this->reg_steps[ $reg_step_slug ]->set_order($order);
456
+		}
457
+	}
458
+
459
+
460
+	/**
461
+	 *    set_current_step
462
+	 *
463
+	 * @access    public
464
+	 * @param string $current_step
465
+	 * @return    void
466
+	 */
467
+	public function set_current_step($current_step)
468
+	{
469
+		// grab what step we're on
470
+		$this->current_step = isset($this->reg_steps[ $current_step ])
471
+			? $this->reg_steps[ $current_step ]
472
+			: reset(
473
+				$this->reg_steps
474
+			);
475
+		// verify instance
476
+		if ($this->current_step instanceof EE_SPCO_Reg_Step) {
477
+			// we don't want to repeat completed steps if this is the first time through SPCO
478
+			if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) {
479
+				// so advance to the next step
480
+				$this->set_next_step();
481
+				if ($this->next_step instanceof EE_SPCO_Reg_Step) {
482
+					// and attempt to set it as the current step
483
+					$this->set_current_step($this->next_step->slug());
484
+				}
485
+				return;
486
+			}
487
+			$this->current_step->set_is_current_step(true);
488
+		} else {
489
+			EE_Error::add_error(
490
+				esc_html__('The current step could not be set.', 'event_espresso'),
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+	}
497
+
498
+
499
+	/**
500
+	 *    set_next_step
501
+	 * advances the reg_steps array pointer and sets the next step, then reverses pointer back to the current step
502
+	 *
503
+	 * @access    public
504
+	 * @return    void
505
+	 */
506
+	public function set_next_step()
507
+	{
508
+		// set pointer to start of array
509
+		reset($this->reg_steps);
510
+		// if there is more than one step
511
+		if (count($this->reg_steps) > 1) {
512
+			// advance to the current step and set pointer
513
+			while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') {
514
+				next($this->reg_steps);
515
+			}
516
+		}
517
+		// advance one more spot ( if it exists )
518
+		$this->next_step = next($this->reg_steps);
519
+		// verify instance
520
+		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : null;
521
+		// then back to current step to reset
522
+		prev($this->reg_steps);
523
+	}
524
+
525
+
526
+	/**
527
+	 *    get_next_reg_step
528
+	 *    this simply returns the next step from reg_steps array
529
+	 *
530
+	 * @access    public
531
+	 * @return    EE_SPCO_Reg_Step | null
532
+	 */
533
+	public function get_next_reg_step()
534
+	{
535
+		$next = next($this->reg_steps);
536
+		prev($this->reg_steps);
537
+		return $next instanceof EE_SPCO_Reg_Step ? $next : null;
538
+	}
539
+
540
+
541
+	/**
542
+	 * get_prev_reg_step
543
+	 *    this simply returns the previous step from reg_steps array
544
+	 *
545
+	 * @access    public
546
+	 * @return    EE_SPCO_Reg_Step | null
547
+	 */
548
+	public function get_prev_reg_step()
549
+	{
550
+		$prev = prev($this->reg_steps);
551
+		next($this->reg_steps);
552
+		return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
553
+	}
554
+
555
+
556
+	/**
557
+	 * sort_reg_steps
558
+	 *
559
+	 * @access public
560
+	 * @return void
561
+	 */
562
+	public function sort_reg_steps()
563
+	{
564
+		$reg_step_sorting_callback = apply_filters(
565
+			'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback',
566
+			'reg_step_sorting_callback'
567
+		);
568
+		uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
569
+	}
570
+
571
+
572
+	/**
573
+	 * find_reg_step
574
+	 * finds a reg step by the given slug
575
+	 *
576
+	 * @access    public
577
+	 * @param string $reg_step_slug
578
+	 * @return EE_SPCO_Reg_Step|null
579
+	 */
580
+	public function find_reg_step($reg_step_slug = '')
581
+	{
582
+		if (! empty($reg_step_slug)) {
583
+			// copy reg step array
584
+			$reg_steps = $this->reg_steps;
585
+			// set pointer to start of array
586
+			reset($reg_steps);
587
+			// if there is more than one step
588
+			if (count($reg_steps) > 1) {
589
+				// advance to the current step and set pointer
590
+				while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') {
591
+					next($reg_steps);
592
+				}
593
+				return current($reg_steps);
594
+			}
595
+		}
596
+		return null;
597
+	}
598
+
599
+
600
+	/**
601
+	 * reg_step_sorting_callback
602
+	 *
603
+	 * @access public
604
+	 * @param EE_SPCO_Reg_Step $reg_step_A
605
+	 * @param EE_SPCO_Reg_Step $reg_step_B
606
+	 * @return int
607
+	 */
608
+	public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B)
609
+	{
610
+		// send finalize_registration step to the end of the array
611
+		if ($reg_step_A->slug() === 'finalize_registration') {
612
+			return 1;
613
+		} elseif ($reg_step_B->slug() === 'finalize_registration') {
614
+			return -1;
615
+		}
616
+		if ($reg_step_A->order() === $reg_step_B->order()) {
617
+			return 0;
618
+		}
619
+		return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
620
+	}
621
+
622
+
623
+	/**
624
+	 * set_reg_step_initiated
625
+	 *
626
+	 * @access    public
627
+	 * @param    EE_SPCO_Reg_Step $reg_step
628
+	 * @throws \EE_Error
629
+	 */
630
+	public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step)
631
+	{
632
+		// call set_reg_step_initiated ???
633
+		if (
634 634
 // first time visiting SPCO ?
635
-            ! $this->revisit
636
-            && (
637
-                // and displaying the reg step form for the first time ?
638
-                $this->action === 'display_spco_reg_step'
639
-                // or initializing the final step
640
-                || $reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration
641
-            )
642
-        ) {
643
-            // set the start time for this reg step
644
-            if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
645
-                if (WP_DEBUG) {
646
-                    EE_Error::add_error(
647
-                        sprintf(
648
-                            esc_html__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
649
-                            $reg_step->name()
650
-                        ),
651
-                        __FILE__,
652
-                        __FUNCTION__,
653
-                        __LINE__
654
-                    );
655
-                }
656
-            }
657
-        }
658
-    }
659
-
660
-
661
-    /**
662
-     *    set_reg_step_JSON_info
663
-     *
664
-     * @access public
665
-     * @return    void
666
-     */
667
-    public function set_reg_step_JSON_info()
668
-    {
669
-        EE_Registry::$i18n_js_strings['reg_steps'] = array();
670
-        // pass basic reg step data to JS
671
-        foreach ($this->reg_steps as $reg_step) {
672
-            EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
673
-        }
674
-        // reset reg step html
675
-        // $this->json_response->set_reg_step_html('');
676
-    }
677
-
678
-
679
-    /**
680
-     *    reset_reg_steps
681
-     *
682
-     * @access public
683
-     * @return void
684
-     */
685
-    public function reset_reg_steps()
686
-    {
687
-        $this->sort_reg_steps();
688
-        $this->set_current_step(EED_Single_Page_Checkout::getRequest()->getRequestParam('step'));
689
-        $this->set_next_step();
690
-        // the text that appears on the reg step form submit button
691
-        $this->current_step->set_submit_button_text();
692
-        $this->set_reg_step_JSON_info();
693
-    }
694
-
695
-
696
-    /**
697
-     *    get_registration_time_limit
698
-     *
699
-     * @access    public
700
-     * @return        string
701
-     */
702
-    public function get_registration_time_limit()
703
-    {
704
-
705
-        $registration_time_limit = (float) (EE_Registry::instance()->SSN->expiration() - time());
706
-        $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
707
-        $registration_time_limit = date($time_limit_format, $registration_time_limit);
708
-        return apply_filters(
709
-            'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
710
-            $registration_time_limit
711
-        );
712
-    }
713
-
714
-
715
-    /**
716
-     * payment_required
717
-     *
718
-     * @return boolean
719
-     */
720
-    public function payment_required()
721
-    {
722
-        // if NOT:
723
-        //     registration via admin
724
-        //      completed TXN
725
-        //      overpaid TXN
726
-        //      free TXN(total = 0.00)
727
-        //      then payment required is TRUE
728
-        return ! ($this->admin_request
729
-                  || $this->transaction->is_completed()
730
-                  || $this->transaction->is_overpaid()
731
-                  || $this->transaction->is_free()) ? true : false;
732
-    }
733
-
734
-
735
-    /**
736
-     * get_cart_for_transaction
737
-     *
738
-     * @access public
739
-     * @param EE_Transaction $transaction
740
-     * @return EE_Cart
741
-     */
742
-    public function get_cart_for_transaction($transaction)
743
-    {
744
-        $session = EE_Registry::instance()->load_core('Session');
745
-        $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
746
-        // verify cart
747
-        if (! $cart instanceof EE_Cart) {
748
-            $cart = EE_Registry::instance()->load_core('Cart');
749
-        }
750
-
751
-        return $cart;
752
-    }
753
-
754
-
755
-    /**
756
-     *    initialize_txn_reg_steps_array
757
-     *
758
-     * @access public
759
-     * @return    array
760
-     */
761
-    public function initialize_txn_reg_steps_array()
762
-    {
763
-        $txn_reg_steps_array = array();
764
-        foreach ($this->reg_steps as $reg_step) {
765
-            $txn_reg_steps_array[ $reg_step->slug() ] = false;
766
-        }
767
-        return $txn_reg_steps_array;
768
-    }
769
-
770
-
771
-    /**
772
-     *    update_txn_reg_steps_array
773
-     *
774
-     * @access public
775
-     * @return    bool
776
-     * @throws \EE_Error
777
-     */
778
-    public function update_txn_reg_steps_array()
779
-    {
780
-        $updated = false;
781
-        foreach ($this->reg_steps as $reg_step) {
782
-            if ($reg_step->completed()) {
783
-                $updated = $this->transaction->set_reg_step_completed($reg_step->slug())
784
-                    ? true
785
-                    : $updated;
786
-            }
787
-        }
788
-        if ($updated) {
789
-            $this->transaction->save();
790
-        }
791
-        return $updated;
792
-    }
793
-
794
-
795
-    /**
796
-     *    stash_transaction_and_checkout
797
-     *
798
-     * @access public
799
-     * @return    void
800
-     * @throws \EE_Error
801
-     */
802
-    public function stash_transaction_and_checkout()
803
-    {
804
-        if (! $this->revisit) {
805
-            $this->update_txn_reg_steps_array();
806
-        }
807
-        $this->track_transaction_and_registration_status_updates();
808
-        // save all data to the db, but suppress errors
809
-        // $this->save_all_data( FALSE );
810
-        // cache the checkout in the session
811
-        EE_Registry::instance()->SSN->set_checkout($this);
812
-    }
813
-
814
-
815
-    /**
816
-     *    track_transaction_and_registration_status_updates
817
-     *    stores whether any updates were made to the TXN or it's related registrations
818
-     *
819
-     * @access public
820
-     * @return void
821
-     * @throws \EE_Error
822
-     */
823
-    public function track_transaction_and_registration_status_updates()
824
-    {
825
-        // verify the transaction
826
-        if ($this->transaction instanceof EE_Transaction) {
827
-            // has there been a TXN status change during this checkout?
828
-            $this->txn_status_updated = $this->transaction->txn_status_updated();
829
-            /** @type EE_Registration_Processor $registration_processor */
830
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
831
-            // grab the saved registrations from the transaction
832
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
833
-                if ($registration_processor->reg_status_updated($registration->ID())) {
834
-                    $this->set_reg_status_updated($registration->ID(), true);
835
-                }
836
-            }
837
-        }
838
-    }
839
-
840
-
841
-    /**
842
-     *    visit_allows_processing_of_this_registration
843
-     *    determines if the current SPCO visit should allow the passed EE_Registration to be used in processing.
844
-     *    one of the following conditions must be met:
845
-     *        EITHER:    A) first time thru SPCO -> process ALL registrations ( NOT a revisit )
846
-     *        OR :        B) primary registrant is editing info -> process ALL registrations ( primary_revisit )
847
-     *        OR :        C) another registrant is editing info -> ONLY process their registration ( revisit AND their
848
-     *        reg_url_link matches )
849
-     *
850
-     * @access public
851
-     * @param    EE_Registration $registration
852
-     * @return    bool
853
-     * @throws \EE_Error
854
-     */
855
-    public function visit_allows_processing_of_this_registration(EE_Registration $registration)
856
-    {
857
-        return ! $this->revisit
858
-               || $this->primary_revisit
859
-               || (
860
-                   $this->revisit && $this->reg_url_link === $registration->reg_url_link()
861
-               )
862
-            ? true
863
-            : false;
864
-    }
865
-
866
-
867
-    /**
868
-     *    _transaction_has_primary_registration
869
-     *
870
-     * @access        private
871
-     * @return        bool
872
-     */
873
-    public function transaction_has_primary_registrant()
874
-    {
875
-        return $this->primary_attendee_obj instanceof EE_Attendee ? true : false;
876
-    }
877
-
878
-
879
-    /**
880
-     *    save_all_data
881
-     *    simply loops through the current transaction and saves all data for each registration
882
-     *
883
-     * @access public
884
-     * @param bool $show_errors
885
-     * @return bool
886
-     * @throws \EE_Error
887
-     */
888
-    public function save_all_data($show_errors = true)
889
-    {
890
-        // verify the transaction
891
-        if ($this->transaction instanceof EE_Transaction) {
892
-            // save to ensure that TXN has ID
893
-            $this->transaction->save();
894
-            // grab the saved registrations from the transaction
895
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
896
-                $this->_save_registration($registration, $show_errors);
897
-            }
898
-        } else {
899
-            if ($show_errors) {
900
-                EE_Error::add_error(
901
-                    esc_html__(
902
-                        'A valid Transaction was not found when attempting to save your registration information.',
903
-                        'event_espresso'
904
-                    ),
905
-                    __FILE__,
906
-                    __FUNCTION__,
907
-                    __LINE__
908
-                );
909
-            }
910
-            return false;
911
-        }
912
-        return true;
913
-    }
914
-
915
-
916
-    /**
917
-     * _save_registration_attendee
918
-     *
919
-     * @param    EE_Registration $registration
920
-     * @param bool               $show_errors
921
-     * @return void
922
-     * @throws \EE_Error
923
-     */
924
-    private function _save_registration($registration, $show_errors = true)
925
-    {
926
-        // verify object
927
-        if ($registration instanceof EE_Registration) {
928
-            // should this registration be processed during this visit ?
929
-            if ($this->visit_allows_processing_of_this_registration($registration)) {
930
-                // set TXN ID
931
-                if (! $registration->transaction_ID()) {
932
-                    $registration->set_transaction_id($this->transaction->ID());
933
-                }
934
-                // verify and save the attendee
935
-                $this->_save_registration_attendee($registration, $show_errors);
936
-                // save answers to reg form questions
937
-                $this->_save_registration_answers($registration, $show_errors);
938
-                // save changes
939
-                $registration->save();
940
-                // update txn cache
941
-                if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
942
-                    if ($show_errors) {
943
-                        EE_Error::add_error(
944
-                            esc_html__(
945
-                                'The newly saved Registration object could not be cached on the Transaction.',
946
-                                'event_espresso'
947
-                            ),
948
-                            __FILE__,
949
-                            __FUNCTION__,
950
-                            __LINE__
951
-                        );
952
-                    }
953
-                }
954
-            }
955
-        } else {
956
-            if ($show_errors) {
957
-                EE_Error::add_error(
958
-                    esc_html__(
959
-                        'An invalid Registration object was discovered when attempting to save your registration information.',
960
-                        'event_espresso'
961
-                    ),
962
-                    __FILE__,
963
-                    __FUNCTION__,
964
-                    __LINE__
965
-                );
966
-            }
967
-        }
968
-    }
969
-
970
-
971
-    /**
972
-     * _save_registration_attendee
973
-     *
974
-     * @param    EE_Registration $registration
975
-     * @param bool               $show_errors
976
-     * @return void
977
-     * @throws \EE_Error
978
-     */
979
-    private function _save_registration_attendee($registration, $show_errors = true)
980
-    {
981
-        if ($registration->attendee() instanceof EE_Attendee) {
982
-            // save so that ATT has ID
983
-            $registration->attendee()->save();
984
-            if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
985
-                if ($show_errors) {
986
-                    EE_Error::add_error(
987
-                        esc_html__(
988
-                            'The newly saved Attendee object could not be cached on the registration.',
989
-                            'event_espresso'
990
-                        ),
991
-                        __FILE__,
992
-                        __FUNCTION__,
993
-                        __LINE__
994
-                    );
995
-                }
996
-            }
997
-        } else {
998
-            if ($show_errors) {
999
-                EE_Error::add_error(
1000
-                    sprintf(
1001
-                        '%1$s||%1$s $attendee = %2$s',
1002
-                        esc_html__(
1003
-                            'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.',
1004
-                            'event_espresso'
1005
-                        ),
1006
-                        var_export($registration->attendee(), true)
1007
-                    ),
1008
-                    __FILE__,
1009
-                    __FUNCTION__,
1010
-                    __LINE__
1011
-                );
1012
-            }
1013
-        }
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * _save_question_answers
1019
-     *
1020
-     * @param    EE_Registration $registration
1021
-     * @param bool               $show_errors
1022
-     * @return void
1023
-     * @throws \EE_Error
1024
-     */
1025
-    private function _save_registration_answers($registration, $show_errors = true)
1026
-    {
1027
-        // now save the answers
1028
-        foreach ($registration->answers() as $cache_key => $answer) {
1029
-            // verify object
1030
-            if ($answer instanceof EE_Answer) {
1031
-                $answer->set_registration($registration->ID());
1032
-                $answer->save();
1033
-                if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1034
-                    if ($show_errors) {
1035
-                        EE_Error::add_error(
1036
-                            esc_html__(
1037
-                                'The newly saved Answer object could not be cached on the registration.',
1038
-                                'event_espresso'
1039
-                            ),
1040
-                            __FILE__,
1041
-                            __FUNCTION__,
1042
-                            __LINE__
1043
-                        );
1044
-                    }
1045
-                }
1046
-            } else {
1047
-                if ($show_errors) {
1048
-                    EE_Error::add_error(
1049
-                        esc_html__(
1050
-                            'An invalid Answer object was discovered when attempting to save your registration information.',
1051
-                            'event_espresso'
1052
-                        ),
1053
-                        __FILE__,
1054
-                        __FUNCTION__,
1055
-                        __LINE__
1056
-                    );
1057
-                }
1058
-            }
1059
-        }
1060
-    }
1061
-
1062
-
1063
-    /**
1064
-     *    refresh_all_entities
1065
-     *   will either refresh the entity map with objects form the db or from the checkout cache
1066
-     *
1067
-     * @access public
1068
-     * @param bool $from_db
1069
-     * @return bool
1070
-     * @throws \EE_Error
1071
-     */
1072
-    public function refresh_all_entities($from_db = false)
1073
-    {
1074
-        $this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
1075
-        $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response'
1076
-            ? true
1077
-            : $from_db;
1078
-        // $this->log(
1079
-        //     __CLASS__,
1080
-        //     __FUNCTION__,
1081
-        //     __LINE__,
1082
-        //     array('from_db' => $from_db)
1083
-        // );
1084
-        return $from_db ? $this->refresh_from_db() : $this->refresh_entity_map();
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     *  refresh_entity_map
1090
-     *  simply loops through the current transaction and updates each
1091
-     *  model's entity map using EEM_Base::refresh_entity_map_from_db()
1092
-     *
1093
-     * @access public
1094
-     * @return bool
1095
-     * @throws \EE_Error
1096
-     */
1097
-    protected function refresh_from_db()
1098
-    {
1099
-        // verify the transaction
1100
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1101
-            // pull fresh TXN data from the db
1102
-            $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
1103
-            // update EE_Checkout's cached primary_attendee object
1104
-            $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
1105
-            // update EE_Checkout's cached payment object
1106
-            $payment = $this->transaction->last_payment();
1107
-            $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
1108
-            // update EE_Checkout's cached payment_method object
1109
-            $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
1110
-            $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method
1111
-                : $this->payment_method;
1112
-            // now refresh the cart, based on the TXN
1113
-            $this->cart = $this->get_cart_for_transaction($this->transaction);
1114
-        } else {
1115
-            EE_Error::add_error(
1116
-                esc_html__(
1117
-                    'A valid Transaction was not found when attempting to update the model entity mapper.',
1118
-                    'event_espresso'
1119
-                ),
1120
-                __FILE__,
1121
-                __FUNCTION__,
1122
-                __LINE__
1123
-            );
1124
-            return false;
1125
-        }
1126
-        return true;
1127
-    }
1128
-
1129
-
1130
-    /**
1131
-     * _refresh_primary_attendee_obj_from_db
1132
-     *
1133
-     * @param   EE_Transaction $transaction
1134
-     * @return  EE_Attendee | null
1135
-     * @throws \EE_Error
1136
-     */
1137
-    protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction)
1138
-    {
1139
-
1140
-        $primary_attendee_obj = null;
1141
-        // grab the saved registrations from the transaction
1142
-        foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1143
-            // verify object
1144
-            if ($registration instanceof EE_Registration) {
1145
-                $attendee = $registration->attendee();
1146
-                // verify object && maybe cache primary_attendee_obj ?
1147
-                if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) {
1148
-                    $primary_attendee_obj = $attendee;
1149
-                }
1150
-            } else {
1151
-                EE_Error::add_error(
1152
-                    esc_html__(
1153
-                        'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1154
-                        'event_espresso'
1155
-                    ),
1156
-                    __FILE__,
1157
-                    __FUNCTION__,
1158
-                    __LINE__
1159
-                );
1160
-            }
1161
-        }
1162
-        return $primary_attendee_obj;
1163
-    }
1164
-
1165
-
1166
-    /**
1167
-     *  refresh_entity_map
1168
-     *  simply loops through the current transaction and updates
1169
-     *  each model's entity map using EEM_Base::refresh_entity_map_with()
1170
-     *
1171
-     * @access public
1172
-     * @return bool
1173
-     * @throws \EE_Error
1174
-     */
1175
-    protected function refresh_entity_map()
1176
-    {
1177
-        // verify the transaction
1178
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1179
-            // never cache payment info
1180
-            $this->transaction->clear_cache('Payment');
1181
-            // is the Payment Options Reg Step completed ?
1182
-            if ($this->transaction->reg_step_completed('payment_options')) {
1183
-                // then check for payments and update TXN accordingly
1184
-                /** @type EE_Transaction_Payments $transaction_payments */
1185
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1186
-                $transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1187
-            }
1188
-            // grab the saved registrations from the transaction
1189
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1190
-                $this->_refresh_registration($reg_cache_ID, $registration);
1191
-            }
1192
-            // make sure our cached TXN is added to the model entity mapper
1193
-            $this->transaction = $this->transaction->get_model()->refresh_entity_map_with(
1194
-                $this->transaction->ID(),
1195
-                $this->transaction
1196
-            );
1197
-        } else {
1198
-            EE_Error::add_error(
1199
-                esc_html__(
1200
-                    'A valid Transaction was not found when attempting to update the model entity mapper.',
1201
-                    'event_espresso'
1202
-                ),
1203
-                __FILE__,
1204
-                __FUNCTION__,
1205
-                __LINE__
1206
-            );
1207
-            return false;
1208
-        }
1209
-        // verify and update the cart because inaccurate totals are not so much fun
1210
-        if ($this->cart instanceof EE_Cart) {
1211
-            $grand_total = $this->cart->get_grand_total();
1212
-            if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1213
-                $grand_total->recalculate_total_including_taxes();
1214
-                $grand_total = $grand_total->get_model()->refresh_entity_map_with(
1215
-                    $this->cart->get_grand_total()->ID(),
1216
-                    $this->cart->get_grand_total()
1217
-                );
1218
-            }
1219
-            if ($grand_total instanceof EE_Line_Item) {
1220
-                $this->cart = EE_Cart::instance($grand_total);
1221
-            } else {
1222
-                EE_Error::add_error(
1223
-                    esc_html__(
1224
-                        'A valid Cart was not found when attempting to update the model entity mapper.',
1225
-                        'event_espresso'
1226
-                    ),
1227
-                    __FILE__,
1228
-                    __FUNCTION__,
1229
-                    __LINE__
1230
-                );
1231
-                return false;
1232
-            }
1233
-        }
1234
-        return true;
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     * _refresh_registration
1240
-     *
1241
-     * @param    string | int    $reg_cache_ID
1242
-     * @param    EE_Registration $registration
1243
-     * @return void
1244
-     * @throws \EE_Error
1245
-     */
1246
-    protected function _refresh_registration($reg_cache_ID, $registration)
1247
-    {
1248
-
1249
-        // verify object
1250
-        if ($registration instanceof EE_Registration) {
1251
-            // update the entity mapper attendee
1252
-            $this->_refresh_registration_attendee($registration);
1253
-            // update the entity mapper answers for reg form questions
1254
-            $this->_refresh_registration_answers($registration);
1255
-            // make sure the cached registration is added to the model entity mapper
1256
-            $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1257
-        } else {
1258
-            EE_Error::add_error(
1259
-                esc_html__(
1260
-                    'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1261
-                    'event_espresso'
1262
-                ),
1263
-                __FILE__,
1264
-                __FUNCTION__,
1265
-                __LINE__
1266
-            );
1267
-        }
1268
-    }
1269
-
1270
-
1271
-    /**
1272
-     * _save_registration_attendee
1273
-     *
1274
-     * @param    EE_Registration $registration
1275
-     * @return void
1276
-     * @throws \EE_Error
1277
-     */
1278
-    protected function _refresh_registration_attendee($registration)
1279
-    {
1280
-
1281
-        $attendee = $registration->attendee();
1282
-        // verify object
1283
-        if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1284
-            // make sure the cached attendee is added to the model entity mapper
1285
-            $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1286
-            // maybe cache primary_attendee_obj ?
1287
-            if ($registration->is_primary_registrant()) {
1288
-                $this->primary_attendee_obj = $attendee;
1289
-            }
1290
-        }
1291
-    }
1292
-
1293
-
1294
-    /**
1295
-     * _refresh_registration_answers
1296
-     *
1297
-     * @param    EE_Registration $registration
1298
-     * @return void
1299
-     * @throws \EE_Error
1300
-     */
1301
-    protected function _refresh_registration_answers($registration)
1302
-    {
1303
-
1304
-        // now update the answers
1305
-        foreach ($registration->answers() as $cache_key => $answer) {
1306
-            // verify object
1307
-            if ($answer instanceof EE_Answer) {
1308
-                if ($answer->ID()) {
1309
-                    // make sure the cached answer is added to the model entity mapper
1310
-                    $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1311
-                }
1312
-            } else {
1313
-                EE_Error::add_error(
1314
-                    esc_html__(
1315
-                        'An invalid Answer object was discovered when attempting to update the model entity mapper.',
1316
-                        'event_espresso'
1317
-                    ),
1318
-                    __FILE__,
1319
-                    __FUNCTION__,
1320
-                    __LINE__
1321
-                );
1322
-            }
1323
-        }
1324
-    }
1325
-
1326
-
1327
-    /**
1328
-     *    __sleep
1329
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
1330
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
1331
-     * reg form, because if needed, it will be regenerated anyways
1332
-     *
1333
-     * @return array
1334
-     * @throws \EE_Error
1335
-     */
1336
-    public function __sleep()
1337
-    {
1338
-        if ($this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID()) {
1339
-            $this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1340
-        }        // remove the reg form and the checkout
1341
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1342
-            $this->transaction = $this->transaction->ID();
1343
-        }        // remove the reg form and the checkout
1344
-        return array_diff(array_keys(get_object_vars($this)), array('billing_form', 'registration_form'));
1345
-    }
1346
-
1347
-
1348
-    /**
1349
-     *    __wakeup
1350
-     * to conserve db space, we are removing the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
1351
-     * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1352
-     */
1353
-    public function __wakeup()
1354
-    {
1355
-        if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1356
-            // $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1357
-            $this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1358
-        }
1359
-        if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1360
-            // $this->transaction is actually just an ID, so use it to get the object from the db
1361
-            $this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1362
-        }
1363
-        foreach ($this->reg_steps as $reg_step) {
1364
-            $reg_step->checkout = $this;
1365
-        }
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * debug
1371
-     *
1372
-     * @param string $class
1373
-     * @param string $func
1374
-     * @param string $line
1375
-     * @param array  $info
1376
-     * @param bool   $display_request
1377
-     * @throws \EE_Error
1378
-     */
1379
-    public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false)
1380
-    {
1381
-        $disabled = true;
1382
-        if (WP_DEBUG && ! $disabled) {
1383
-            $debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1384
-            $default_data = array(
1385
-                $class                    => $func . '() : ' . $line,
1386
-                'request->step'           => $this->step,
1387
-                'request->action'         => $this->action,
1388
-                'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
1389
-                    $this->current_step->slug() : '',
1390
-                'current_step->completed' => $this->current_step instanceof EE_SPCO_Reg_Step ?
1391
-                    $this->current_step->completed() : '',
1392
-                'txn_status_updated'      => $this->transaction->txn_status_updated(),
1393
-                'reg_status_updated'      => $this->reg_status_updated,
1394
-                'reg_url_link'            => $this->reg_url_link,
1395
-            );
1396
-            if ($this->transaction instanceof EE_Transaction) {
1397
-                $default_data['TXN_status'] = $this->transaction->status_ID();
1398
-                $default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1399
-                foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1400
-                    $default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1401
-                }
1402
-                if ($this->transaction->ID()) {
1403
-                    $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1404
-                    // don't serialize objects
1405
-                    $info = $this->_strip_objects($info);
1406
-                    if (! isset($debug_data[ $TXN_ID ])) {
1407
-                        $debug_data[ $TXN_ID ] = array();
1408
-                    }
1409
-                    $debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1410
-                        $default_data,
1411
-                        $info
1412
-                    );
1413
-                    update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1414
-                }
1415
-            }
1416
-        }
1417
-    }
1418
-
1419
-
1420
-    /**
1421
-     * _strip_objects
1422
-     *
1423
-     * @param array $info
1424
-     * @return array
1425
-     */
1426
-    public function _strip_objects($info = array())
1427
-    {
1428
-        foreach ((array) $info as $key => $value) {
1429
-            if (is_array($value)) {
1430
-                $info[ $key ] = $this->_strip_objects($value);
1431
-            } elseif (is_object($value)) {
1432
-                $object_class = get_class($value);
1433
-                $info[ $object_class ] = array();
1434
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1435
-                if (method_exists($value, 'status')) {
1436
-                    $info[ $object_class ]['status'] = $value->status();
1437
-                } elseif (method_exists($value, 'status_ID')) {
1438
-                    $info[ $object_class ]['status'] = $value->status_ID();
1439
-                }
1440
-                unset($info[ $key ]);
1441
-            }
1442
-        }
1443
-        return (array) $info;
1444
-    }
635
+			! $this->revisit
636
+			&& (
637
+				// and displaying the reg step form for the first time ?
638
+				$this->action === 'display_spco_reg_step'
639
+				// or initializing the final step
640
+				|| $reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration
641
+			)
642
+		) {
643
+			// set the start time for this reg step
644
+			if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
645
+				if (WP_DEBUG) {
646
+					EE_Error::add_error(
647
+						sprintf(
648
+							esc_html__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
649
+							$reg_step->name()
650
+						),
651
+						__FILE__,
652
+						__FUNCTION__,
653
+						__LINE__
654
+					);
655
+				}
656
+			}
657
+		}
658
+	}
659
+
660
+
661
+	/**
662
+	 *    set_reg_step_JSON_info
663
+	 *
664
+	 * @access public
665
+	 * @return    void
666
+	 */
667
+	public function set_reg_step_JSON_info()
668
+	{
669
+		EE_Registry::$i18n_js_strings['reg_steps'] = array();
670
+		// pass basic reg step data to JS
671
+		foreach ($this->reg_steps as $reg_step) {
672
+			EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
673
+		}
674
+		// reset reg step html
675
+		// $this->json_response->set_reg_step_html('');
676
+	}
677
+
678
+
679
+	/**
680
+	 *    reset_reg_steps
681
+	 *
682
+	 * @access public
683
+	 * @return void
684
+	 */
685
+	public function reset_reg_steps()
686
+	{
687
+		$this->sort_reg_steps();
688
+		$this->set_current_step(EED_Single_Page_Checkout::getRequest()->getRequestParam('step'));
689
+		$this->set_next_step();
690
+		// the text that appears on the reg step form submit button
691
+		$this->current_step->set_submit_button_text();
692
+		$this->set_reg_step_JSON_info();
693
+	}
694
+
695
+
696
+	/**
697
+	 *    get_registration_time_limit
698
+	 *
699
+	 * @access    public
700
+	 * @return        string
701
+	 */
702
+	public function get_registration_time_limit()
703
+	{
704
+
705
+		$registration_time_limit = (float) (EE_Registry::instance()->SSN->expiration() - time());
706
+		$time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
707
+		$registration_time_limit = date($time_limit_format, $registration_time_limit);
708
+		return apply_filters(
709
+			'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
710
+			$registration_time_limit
711
+		);
712
+	}
713
+
714
+
715
+	/**
716
+	 * payment_required
717
+	 *
718
+	 * @return boolean
719
+	 */
720
+	public function payment_required()
721
+	{
722
+		// if NOT:
723
+		//     registration via admin
724
+		//      completed TXN
725
+		//      overpaid TXN
726
+		//      free TXN(total = 0.00)
727
+		//      then payment required is TRUE
728
+		return ! ($this->admin_request
729
+				  || $this->transaction->is_completed()
730
+				  || $this->transaction->is_overpaid()
731
+				  || $this->transaction->is_free()) ? true : false;
732
+	}
733
+
734
+
735
+	/**
736
+	 * get_cart_for_transaction
737
+	 *
738
+	 * @access public
739
+	 * @param EE_Transaction $transaction
740
+	 * @return EE_Cart
741
+	 */
742
+	public function get_cart_for_transaction($transaction)
743
+	{
744
+		$session = EE_Registry::instance()->load_core('Session');
745
+		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
746
+		// verify cart
747
+		if (! $cart instanceof EE_Cart) {
748
+			$cart = EE_Registry::instance()->load_core('Cart');
749
+		}
750
+
751
+		return $cart;
752
+	}
753
+
754
+
755
+	/**
756
+	 *    initialize_txn_reg_steps_array
757
+	 *
758
+	 * @access public
759
+	 * @return    array
760
+	 */
761
+	public function initialize_txn_reg_steps_array()
762
+	{
763
+		$txn_reg_steps_array = array();
764
+		foreach ($this->reg_steps as $reg_step) {
765
+			$txn_reg_steps_array[ $reg_step->slug() ] = false;
766
+		}
767
+		return $txn_reg_steps_array;
768
+	}
769
+
770
+
771
+	/**
772
+	 *    update_txn_reg_steps_array
773
+	 *
774
+	 * @access public
775
+	 * @return    bool
776
+	 * @throws \EE_Error
777
+	 */
778
+	public function update_txn_reg_steps_array()
779
+	{
780
+		$updated = false;
781
+		foreach ($this->reg_steps as $reg_step) {
782
+			if ($reg_step->completed()) {
783
+				$updated = $this->transaction->set_reg_step_completed($reg_step->slug())
784
+					? true
785
+					: $updated;
786
+			}
787
+		}
788
+		if ($updated) {
789
+			$this->transaction->save();
790
+		}
791
+		return $updated;
792
+	}
793
+
794
+
795
+	/**
796
+	 *    stash_transaction_and_checkout
797
+	 *
798
+	 * @access public
799
+	 * @return    void
800
+	 * @throws \EE_Error
801
+	 */
802
+	public function stash_transaction_and_checkout()
803
+	{
804
+		if (! $this->revisit) {
805
+			$this->update_txn_reg_steps_array();
806
+		}
807
+		$this->track_transaction_and_registration_status_updates();
808
+		// save all data to the db, but suppress errors
809
+		// $this->save_all_data( FALSE );
810
+		// cache the checkout in the session
811
+		EE_Registry::instance()->SSN->set_checkout($this);
812
+	}
813
+
814
+
815
+	/**
816
+	 *    track_transaction_and_registration_status_updates
817
+	 *    stores whether any updates were made to the TXN or it's related registrations
818
+	 *
819
+	 * @access public
820
+	 * @return void
821
+	 * @throws \EE_Error
822
+	 */
823
+	public function track_transaction_and_registration_status_updates()
824
+	{
825
+		// verify the transaction
826
+		if ($this->transaction instanceof EE_Transaction) {
827
+			// has there been a TXN status change during this checkout?
828
+			$this->txn_status_updated = $this->transaction->txn_status_updated();
829
+			/** @type EE_Registration_Processor $registration_processor */
830
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
831
+			// grab the saved registrations from the transaction
832
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
833
+				if ($registration_processor->reg_status_updated($registration->ID())) {
834
+					$this->set_reg_status_updated($registration->ID(), true);
835
+				}
836
+			}
837
+		}
838
+	}
839
+
840
+
841
+	/**
842
+	 *    visit_allows_processing_of_this_registration
843
+	 *    determines if the current SPCO visit should allow the passed EE_Registration to be used in processing.
844
+	 *    one of the following conditions must be met:
845
+	 *        EITHER:    A) first time thru SPCO -> process ALL registrations ( NOT a revisit )
846
+	 *        OR :        B) primary registrant is editing info -> process ALL registrations ( primary_revisit )
847
+	 *        OR :        C) another registrant is editing info -> ONLY process their registration ( revisit AND their
848
+	 *        reg_url_link matches )
849
+	 *
850
+	 * @access public
851
+	 * @param    EE_Registration $registration
852
+	 * @return    bool
853
+	 * @throws \EE_Error
854
+	 */
855
+	public function visit_allows_processing_of_this_registration(EE_Registration $registration)
856
+	{
857
+		return ! $this->revisit
858
+			   || $this->primary_revisit
859
+			   || (
860
+				   $this->revisit && $this->reg_url_link === $registration->reg_url_link()
861
+			   )
862
+			? true
863
+			: false;
864
+	}
865
+
866
+
867
+	/**
868
+	 *    _transaction_has_primary_registration
869
+	 *
870
+	 * @access        private
871
+	 * @return        bool
872
+	 */
873
+	public function transaction_has_primary_registrant()
874
+	{
875
+		return $this->primary_attendee_obj instanceof EE_Attendee ? true : false;
876
+	}
877
+
878
+
879
+	/**
880
+	 *    save_all_data
881
+	 *    simply loops through the current transaction and saves all data for each registration
882
+	 *
883
+	 * @access public
884
+	 * @param bool $show_errors
885
+	 * @return bool
886
+	 * @throws \EE_Error
887
+	 */
888
+	public function save_all_data($show_errors = true)
889
+	{
890
+		// verify the transaction
891
+		if ($this->transaction instanceof EE_Transaction) {
892
+			// save to ensure that TXN has ID
893
+			$this->transaction->save();
894
+			// grab the saved registrations from the transaction
895
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
896
+				$this->_save_registration($registration, $show_errors);
897
+			}
898
+		} else {
899
+			if ($show_errors) {
900
+				EE_Error::add_error(
901
+					esc_html__(
902
+						'A valid Transaction was not found when attempting to save your registration information.',
903
+						'event_espresso'
904
+					),
905
+					__FILE__,
906
+					__FUNCTION__,
907
+					__LINE__
908
+				);
909
+			}
910
+			return false;
911
+		}
912
+		return true;
913
+	}
914
+
915
+
916
+	/**
917
+	 * _save_registration_attendee
918
+	 *
919
+	 * @param    EE_Registration $registration
920
+	 * @param bool               $show_errors
921
+	 * @return void
922
+	 * @throws \EE_Error
923
+	 */
924
+	private function _save_registration($registration, $show_errors = true)
925
+	{
926
+		// verify object
927
+		if ($registration instanceof EE_Registration) {
928
+			// should this registration be processed during this visit ?
929
+			if ($this->visit_allows_processing_of_this_registration($registration)) {
930
+				// set TXN ID
931
+				if (! $registration->transaction_ID()) {
932
+					$registration->set_transaction_id($this->transaction->ID());
933
+				}
934
+				// verify and save the attendee
935
+				$this->_save_registration_attendee($registration, $show_errors);
936
+				// save answers to reg form questions
937
+				$this->_save_registration_answers($registration, $show_errors);
938
+				// save changes
939
+				$registration->save();
940
+				// update txn cache
941
+				if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
942
+					if ($show_errors) {
943
+						EE_Error::add_error(
944
+							esc_html__(
945
+								'The newly saved Registration object could not be cached on the Transaction.',
946
+								'event_espresso'
947
+							),
948
+							__FILE__,
949
+							__FUNCTION__,
950
+							__LINE__
951
+						);
952
+					}
953
+				}
954
+			}
955
+		} else {
956
+			if ($show_errors) {
957
+				EE_Error::add_error(
958
+					esc_html__(
959
+						'An invalid Registration object was discovered when attempting to save your registration information.',
960
+						'event_espresso'
961
+					),
962
+					__FILE__,
963
+					__FUNCTION__,
964
+					__LINE__
965
+				);
966
+			}
967
+		}
968
+	}
969
+
970
+
971
+	/**
972
+	 * _save_registration_attendee
973
+	 *
974
+	 * @param    EE_Registration $registration
975
+	 * @param bool               $show_errors
976
+	 * @return void
977
+	 * @throws \EE_Error
978
+	 */
979
+	private function _save_registration_attendee($registration, $show_errors = true)
980
+	{
981
+		if ($registration->attendee() instanceof EE_Attendee) {
982
+			// save so that ATT has ID
983
+			$registration->attendee()->save();
984
+			if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
985
+				if ($show_errors) {
986
+					EE_Error::add_error(
987
+						esc_html__(
988
+							'The newly saved Attendee object could not be cached on the registration.',
989
+							'event_espresso'
990
+						),
991
+						__FILE__,
992
+						__FUNCTION__,
993
+						__LINE__
994
+					);
995
+				}
996
+			}
997
+		} else {
998
+			if ($show_errors) {
999
+				EE_Error::add_error(
1000
+					sprintf(
1001
+						'%1$s||%1$s $attendee = %2$s',
1002
+						esc_html__(
1003
+							'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.',
1004
+							'event_espresso'
1005
+						),
1006
+						var_export($registration->attendee(), true)
1007
+					),
1008
+					__FILE__,
1009
+					__FUNCTION__,
1010
+					__LINE__
1011
+				);
1012
+			}
1013
+		}
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * _save_question_answers
1019
+	 *
1020
+	 * @param    EE_Registration $registration
1021
+	 * @param bool               $show_errors
1022
+	 * @return void
1023
+	 * @throws \EE_Error
1024
+	 */
1025
+	private function _save_registration_answers($registration, $show_errors = true)
1026
+	{
1027
+		// now save the answers
1028
+		foreach ($registration->answers() as $cache_key => $answer) {
1029
+			// verify object
1030
+			if ($answer instanceof EE_Answer) {
1031
+				$answer->set_registration($registration->ID());
1032
+				$answer->save();
1033
+				if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1034
+					if ($show_errors) {
1035
+						EE_Error::add_error(
1036
+							esc_html__(
1037
+								'The newly saved Answer object could not be cached on the registration.',
1038
+								'event_espresso'
1039
+							),
1040
+							__FILE__,
1041
+							__FUNCTION__,
1042
+							__LINE__
1043
+						);
1044
+					}
1045
+				}
1046
+			} else {
1047
+				if ($show_errors) {
1048
+					EE_Error::add_error(
1049
+						esc_html__(
1050
+							'An invalid Answer object was discovered when attempting to save your registration information.',
1051
+							'event_espresso'
1052
+						),
1053
+						__FILE__,
1054
+						__FUNCTION__,
1055
+						__LINE__
1056
+					);
1057
+				}
1058
+			}
1059
+		}
1060
+	}
1061
+
1062
+
1063
+	/**
1064
+	 *    refresh_all_entities
1065
+	 *   will either refresh the entity map with objects form the db or from the checkout cache
1066
+	 *
1067
+	 * @access public
1068
+	 * @param bool $from_db
1069
+	 * @return bool
1070
+	 * @throws \EE_Error
1071
+	 */
1072
+	public function refresh_all_entities($from_db = false)
1073
+	{
1074
+		$this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
1075
+		$from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response'
1076
+			? true
1077
+			: $from_db;
1078
+		// $this->log(
1079
+		//     __CLASS__,
1080
+		//     __FUNCTION__,
1081
+		//     __LINE__,
1082
+		//     array('from_db' => $from_db)
1083
+		// );
1084
+		return $from_db ? $this->refresh_from_db() : $this->refresh_entity_map();
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 *  refresh_entity_map
1090
+	 *  simply loops through the current transaction and updates each
1091
+	 *  model's entity map using EEM_Base::refresh_entity_map_from_db()
1092
+	 *
1093
+	 * @access public
1094
+	 * @return bool
1095
+	 * @throws \EE_Error
1096
+	 */
1097
+	protected function refresh_from_db()
1098
+	{
1099
+		// verify the transaction
1100
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1101
+			// pull fresh TXN data from the db
1102
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
1103
+			// update EE_Checkout's cached primary_attendee object
1104
+			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
1105
+			// update EE_Checkout's cached payment object
1106
+			$payment = $this->transaction->last_payment();
1107
+			$this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
1108
+			// update EE_Checkout's cached payment_method object
1109
+			$payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
1110
+			$this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method
1111
+				: $this->payment_method;
1112
+			// now refresh the cart, based on the TXN
1113
+			$this->cart = $this->get_cart_for_transaction($this->transaction);
1114
+		} else {
1115
+			EE_Error::add_error(
1116
+				esc_html__(
1117
+					'A valid Transaction was not found when attempting to update the model entity mapper.',
1118
+					'event_espresso'
1119
+				),
1120
+				__FILE__,
1121
+				__FUNCTION__,
1122
+				__LINE__
1123
+			);
1124
+			return false;
1125
+		}
1126
+		return true;
1127
+	}
1128
+
1129
+
1130
+	/**
1131
+	 * _refresh_primary_attendee_obj_from_db
1132
+	 *
1133
+	 * @param   EE_Transaction $transaction
1134
+	 * @return  EE_Attendee | null
1135
+	 * @throws \EE_Error
1136
+	 */
1137
+	protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction)
1138
+	{
1139
+
1140
+		$primary_attendee_obj = null;
1141
+		// grab the saved registrations from the transaction
1142
+		foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1143
+			// verify object
1144
+			if ($registration instanceof EE_Registration) {
1145
+				$attendee = $registration->attendee();
1146
+				// verify object && maybe cache primary_attendee_obj ?
1147
+				if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) {
1148
+					$primary_attendee_obj = $attendee;
1149
+				}
1150
+			} else {
1151
+				EE_Error::add_error(
1152
+					esc_html__(
1153
+						'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1154
+						'event_espresso'
1155
+					),
1156
+					__FILE__,
1157
+					__FUNCTION__,
1158
+					__LINE__
1159
+				);
1160
+			}
1161
+		}
1162
+		return $primary_attendee_obj;
1163
+	}
1164
+
1165
+
1166
+	/**
1167
+	 *  refresh_entity_map
1168
+	 *  simply loops through the current transaction and updates
1169
+	 *  each model's entity map using EEM_Base::refresh_entity_map_with()
1170
+	 *
1171
+	 * @access public
1172
+	 * @return bool
1173
+	 * @throws \EE_Error
1174
+	 */
1175
+	protected function refresh_entity_map()
1176
+	{
1177
+		// verify the transaction
1178
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1179
+			// never cache payment info
1180
+			$this->transaction->clear_cache('Payment');
1181
+			// is the Payment Options Reg Step completed ?
1182
+			if ($this->transaction->reg_step_completed('payment_options')) {
1183
+				// then check for payments and update TXN accordingly
1184
+				/** @type EE_Transaction_Payments $transaction_payments */
1185
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1186
+				$transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1187
+			}
1188
+			// grab the saved registrations from the transaction
1189
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1190
+				$this->_refresh_registration($reg_cache_ID, $registration);
1191
+			}
1192
+			// make sure our cached TXN is added to the model entity mapper
1193
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with(
1194
+				$this->transaction->ID(),
1195
+				$this->transaction
1196
+			);
1197
+		} else {
1198
+			EE_Error::add_error(
1199
+				esc_html__(
1200
+					'A valid Transaction was not found when attempting to update the model entity mapper.',
1201
+					'event_espresso'
1202
+				),
1203
+				__FILE__,
1204
+				__FUNCTION__,
1205
+				__LINE__
1206
+			);
1207
+			return false;
1208
+		}
1209
+		// verify and update the cart because inaccurate totals are not so much fun
1210
+		if ($this->cart instanceof EE_Cart) {
1211
+			$grand_total = $this->cart->get_grand_total();
1212
+			if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1213
+				$grand_total->recalculate_total_including_taxes();
1214
+				$grand_total = $grand_total->get_model()->refresh_entity_map_with(
1215
+					$this->cart->get_grand_total()->ID(),
1216
+					$this->cart->get_grand_total()
1217
+				);
1218
+			}
1219
+			if ($grand_total instanceof EE_Line_Item) {
1220
+				$this->cart = EE_Cart::instance($grand_total);
1221
+			} else {
1222
+				EE_Error::add_error(
1223
+					esc_html__(
1224
+						'A valid Cart was not found when attempting to update the model entity mapper.',
1225
+						'event_espresso'
1226
+					),
1227
+					__FILE__,
1228
+					__FUNCTION__,
1229
+					__LINE__
1230
+				);
1231
+				return false;
1232
+			}
1233
+		}
1234
+		return true;
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 * _refresh_registration
1240
+	 *
1241
+	 * @param    string | int    $reg_cache_ID
1242
+	 * @param    EE_Registration $registration
1243
+	 * @return void
1244
+	 * @throws \EE_Error
1245
+	 */
1246
+	protected function _refresh_registration($reg_cache_ID, $registration)
1247
+	{
1248
+
1249
+		// verify object
1250
+		if ($registration instanceof EE_Registration) {
1251
+			// update the entity mapper attendee
1252
+			$this->_refresh_registration_attendee($registration);
1253
+			// update the entity mapper answers for reg form questions
1254
+			$this->_refresh_registration_answers($registration);
1255
+			// make sure the cached registration is added to the model entity mapper
1256
+			$registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1257
+		} else {
1258
+			EE_Error::add_error(
1259
+				esc_html__(
1260
+					'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1261
+					'event_espresso'
1262
+				),
1263
+				__FILE__,
1264
+				__FUNCTION__,
1265
+				__LINE__
1266
+			);
1267
+		}
1268
+	}
1269
+
1270
+
1271
+	/**
1272
+	 * _save_registration_attendee
1273
+	 *
1274
+	 * @param    EE_Registration $registration
1275
+	 * @return void
1276
+	 * @throws \EE_Error
1277
+	 */
1278
+	protected function _refresh_registration_attendee($registration)
1279
+	{
1280
+
1281
+		$attendee = $registration->attendee();
1282
+		// verify object
1283
+		if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1284
+			// make sure the cached attendee is added to the model entity mapper
1285
+			$registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1286
+			// maybe cache primary_attendee_obj ?
1287
+			if ($registration->is_primary_registrant()) {
1288
+				$this->primary_attendee_obj = $attendee;
1289
+			}
1290
+		}
1291
+	}
1292
+
1293
+
1294
+	/**
1295
+	 * _refresh_registration_answers
1296
+	 *
1297
+	 * @param    EE_Registration $registration
1298
+	 * @return void
1299
+	 * @throws \EE_Error
1300
+	 */
1301
+	protected function _refresh_registration_answers($registration)
1302
+	{
1303
+
1304
+		// now update the answers
1305
+		foreach ($registration->answers() as $cache_key => $answer) {
1306
+			// verify object
1307
+			if ($answer instanceof EE_Answer) {
1308
+				if ($answer->ID()) {
1309
+					// make sure the cached answer is added to the model entity mapper
1310
+					$answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1311
+				}
1312
+			} else {
1313
+				EE_Error::add_error(
1314
+					esc_html__(
1315
+						'An invalid Answer object was discovered when attempting to update the model entity mapper.',
1316
+						'event_espresso'
1317
+					),
1318
+					__FILE__,
1319
+					__FUNCTION__,
1320
+					__LINE__
1321
+				);
1322
+			}
1323
+		}
1324
+	}
1325
+
1326
+
1327
+	/**
1328
+	 *    __sleep
1329
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
1330
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
1331
+	 * reg form, because if needed, it will be regenerated anyways
1332
+	 *
1333
+	 * @return array
1334
+	 * @throws \EE_Error
1335
+	 */
1336
+	public function __sleep()
1337
+	{
1338
+		if ($this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID()) {
1339
+			$this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1340
+		}        // remove the reg form and the checkout
1341
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1342
+			$this->transaction = $this->transaction->ID();
1343
+		}        // remove the reg form and the checkout
1344
+		return array_diff(array_keys(get_object_vars($this)), array('billing_form', 'registration_form'));
1345
+	}
1346
+
1347
+
1348
+	/**
1349
+	 *    __wakeup
1350
+	 * to conserve db space, we are removing the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
1351
+	 * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1352
+	 */
1353
+	public function __wakeup()
1354
+	{
1355
+		if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1356
+			// $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1357
+			$this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1358
+		}
1359
+		if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1360
+			// $this->transaction is actually just an ID, so use it to get the object from the db
1361
+			$this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1362
+		}
1363
+		foreach ($this->reg_steps as $reg_step) {
1364
+			$reg_step->checkout = $this;
1365
+		}
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * debug
1371
+	 *
1372
+	 * @param string $class
1373
+	 * @param string $func
1374
+	 * @param string $line
1375
+	 * @param array  $info
1376
+	 * @param bool   $display_request
1377
+	 * @throws \EE_Error
1378
+	 */
1379
+	public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false)
1380
+	{
1381
+		$disabled = true;
1382
+		if (WP_DEBUG && ! $disabled) {
1383
+			$debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1384
+			$default_data = array(
1385
+				$class                    => $func . '() : ' . $line,
1386
+				'request->step'           => $this->step,
1387
+				'request->action'         => $this->action,
1388
+				'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
1389
+					$this->current_step->slug() : '',
1390
+				'current_step->completed' => $this->current_step instanceof EE_SPCO_Reg_Step ?
1391
+					$this->current_step->completed() : '',
1392
+				'txn_status_updated'      => $this->transaction->txn_status_updated(),
1393
+				'reg_status_updated'      => $this->reg_status_updated,
1394
+				'reg_url_link'            => $this->reg_url_link,
1395
+			);
1396
+			if ($this->transaction instanceof EE_Transaction) {
1397
+				$default_data['TXN_status'] = $this->transaction->status_ID();
1398
+				$default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1399
+				foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1400
+					$default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1401
+				}
1402
+				if ($this->transaction->ID()) {
1403
+					$TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1404
+					// don't serialize objects
1405
+					$info = $this->_strip_objects($info);
1406
+					if (! isset($debug_data[ $TXN_ID ])) {
1407
+						$debug_data[ $TXN_ID ] = array();
1408
+					}
1409
+					$debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1410
+						$default_data,
1411
+						$info
1412
+					);
1413
+					update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1414
+				}
1415
+			}
1416
+		}
1417
+	}
1418
+
1419
+
1420
+	/**
1421
+	 * _strip_objects
1422
+	 *
1423
+	 * @param array $info
1424
+	 * @return array
1425
+	 */
1426
+	public function _strip_objects($info = array())
1427
+	{
1428
+		foreach ((array) $info as $key => $value) {
1429
+			if (is_array($value)) {
1430
+				$info[ $key ] = $this->_strip_objects($value);
1431
+			} elseif (is_object($value)) {
1432
+				$object_class = get_class($value);
1433
+				$info[ $object_class ] = array();
1434
+				$info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1435
+				if (method_exists($value, 'status')) {
1436
+					$info[ $object_class ]['status'] = $value->status();
1437
+				} elseif (method_exists($value, 'status_ID')) {
1438
+					$info[ $object_class ]['status'] = $value->status_ID();
1439
+				}
1440
+				unset($info[ $key ]);
1441
+			}
1442
+		}
1443
+		return (array) $info;
1444
+	}
1445 1445
 }
Please login to merge, or discard this patch.
modules/ticket_selector/DisplayTicketSelector.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
             }
156 156
         } else {
157 157
             $user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso');
158
-            $dev_msg  = $user_msg . esc_html__(
158
+            $dev_msg  = $user_msg.esc_html__(
159 159
                 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
160 160
                 'event_espresso'
161 161
             );
162
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
162
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
163 163
             return false;
164 164
         }
165 165
         return true;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         // reset filter for displaying submit button
223 223
         remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
224 224
         // poke and prod incoming event till it tells us what it is
225
-        if (! $this->setEvent($event)) {
225
+        if ( ! $this->setEvent($event)) {
226 226
             return $this->handleMissingEvent();
227 227
         }
228 228
         // is the event expired ?
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             : $this->loadTicketSelector($tickets, $template_args);
266 266
         // now set up the form (but not for the admin)
267 267
         $ticket_selector = $this->display_full_ui()
268
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
268
+            ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector
269 269
             : $ticket_selector;
270 270
         // submit button and form close tag
271 271
         $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
      */
314 314
     protected function expiredEventMessage()
315 315
     {
316
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
316
+        return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__(
317 317
             'We\'re sorry, but all tickets sales have ended because the event is expired.',
318 318
             'event_espresso'
319
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
319
+        ).'</span></div><!-- .ee-event-expired-notice -->';
320 320
     }
321 321
 
322 322
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
         }
348 348
         return '
349 349
             <div class="ee-event-expired-notice">
350
-                <span class="important-notice">' . $no_ticket_available_msg . '</span>
350
+                <span class="important-notice">' . $no_ticket_available_msg.'</span>
351 351
             </div><!-- .ee-event-expired-notice -->';
352 352
     }
353 353
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                 '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
381 381
             );
382 382
         }
383
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
383
+        return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
384 384
     }
385 385
 
386 386
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 'Datetime.DTT_EVT_start' => 'DESC',
409 409
             ],
410 410
         ];
411
-        if (! $show_expired_tickets) {
411
+        if ( ! $show_expired_tickets) {
412 412
             // use the correct applicable time query depending on what version of core is being run.
413 413
             $current_time                         = method_exists('EEM_Datetime', 'current_time_for_query')
414 414
                 ? time()
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
          * @param int $EVT_ID The Event ID
446 446
          * @since 4.9.13
447 447
          */
448
-        $template_args['anchor_id']    = apply_filters(
448
+        $template_args['anchor_id'] = apply_filters(
449 449
             'FHEE__EE_Ticket_Selector__redirect_anchor_id',
450
-            '#tkt-slctr-tbl-' . $this->event->ID(),
450
+            '#tkt-slctr-tbl-'.$this->event->ID(),
451 451
             $this->event->ID()
452 452
         );
453 453
         $template_args['tickets']      = $tickets;
@@ -539,30 +539,30 @@  discard block
 block discarded – undo
539 539
         // if redirecting, we don't need any anything else
540 540
         if ($external_url) {
541 541
             $html = '<form method="GET" ';
542
-            $html .= 'action="' . EEH_URL::refactor_url($external_url) . '" ';
543
-            $html .= 'name="ticket-selector-form-' . $ID . '"';
542
+            $html .= 'action="'.EEH_URL::refactor_url($external_url).'" ';
543
+            $html .= 'name="ticket-selector-form-'.$ID.'"';
544 544
             // open link in new window ?
545
-            $html       .= apply_filters(
545
+            $html .= apply_filters(
546 546
                 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
547 547
                 $this->isIframe(),
548 548
                 $this
549 549
             )
550 550
                 ? ' target="_blank"'
551 551
                 : '';
552
-            $html       .= '>';
552
+            $html .= '>';
553 553
             $query_args = EEH_URL::get_query_string($external_url);
554 554
             foreach ((array) $query_args as $query_arg => $value) {
555
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
555
+                $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
556 556
             }
557 557
             return $html;
558 558
         }
559 559
         // if there is no submit button, then don't start building a form
560 560
         // because the "View Details" button will build its own form
561
-        if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
561
+        if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562 562
             return '';
563 563
         }
564 564
         $checkout_url = EEH_Event_View::event_link_url($ID);
565
-        if (! $checkout_url) {
565
+        if ( ! $checkout_url) {
566 566
             EE_Error::add_error(
567 567
                 esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
568 568
                 __FILE__,
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
         // set no cache headers and constants
574 574
         EE_System::do_not_cache();
575 575
         $html = '<form method="POST" ';
576
-        $html .= 'action="' . $checkout_url . '" ';
577
-        $html .= 'name="ticket-selector-form-' . $ID . '"';
576
+        $html .= 'action="'.$checkout_url.'" ';
577
+        $html .= 'name="ticket-selector-form-'.$ID.'"';
578 578
         $html .= $this->iframe ? ' target="_blank"' : '';
579 579
         $html .= '>';
580 580
         $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                 $html .= empty($external_url)
601 601
                     ? $this->ticketSelectorEndDiv()
602 602
                     : $this->clearTicketSelector();
603
-                $html .= '<br/>' . $this->formClose();
603
+                $html .= '<br/>'.$this->formClose();
604 604
             } elseif ($this->getMaxAttendees() === 1) {
605 605
                 // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
606 606
                 if ($this->event->is_sold_out()) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                 // no submit or view details button, and no additional content
659 659
                 $html .= $this->ticketSelectorEndDiv();
660 660
             }
661
-            if (! $this->iframe && ! is_archive()) {
661
+            if ( ! $this->iframe && ! is_archive()) {
662 662
                 $html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']);
663 663
             }
664 664
         }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
      */
679 679
     public function displayRegisterNowButton()
680 680
     {
681
-        $btn_text     = apply_filters(
681
+        $btn_text = apply_filters(
682 682
             'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
683 683
             esc_html__('Register Now', 'event_espresso'),
684 684
             $this->event
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
                         && $this->event->external_url() !== get_the_permalink()
688 688
             ? $this->event->external_url()
689 689
             : '';
690
-        $html         = EEH_HTML::div(
690
+        $html = EEH_HTML::div(
691 691
             '',
692
-            'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap',
692
+            'ticket-selector-submit-'.$this->event->ID().'-btn-wrap',
693 693
             'ticket-selector-submit-btn-wrap'
694 694
         );
695
-        $html         .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
695
+        $html         .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"';
696 696
         $html         .= ' class="ticket-selector-submit-btn ';
697 697
         $html         .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
698
-        $html         .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />';
699
-        $html         .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
698
+        $html         .= ' type="submit" value="'.$btn_text.'" data-ee-disable-after-recaptcha="true" />';
699
+        $html         .= EEH_HTML::divx().'<!-- .ticket-selector-submit-btn-wrap -->';
700 700
         $html         .= apply_filters(
701 701
             'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
702 702
             '',
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      */
721 721
     public function displayViewDetailsButton($DWMTS = false)
722 722
     {
723
-        if (! $this->event->get_permalink()) {
723
+        if ( ! $this->event->get_permalink()) {
724 724
             EE_Error::add_error(
725 725
                 esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
726 726
                 __FILE__,
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
             ? ' target="_blank"'
745 745
             : '';
746 746
         $view_details_btn .= '>';
747
-        $btn_text         = apply_filters(
747
+        $btn_text = apply_filters(
748 748
             'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
749 749
             esc_html__('View Details', 'event_espresso'),
750 750
             $this->event
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
      */
774 774
     public function ticketSelectorEndDiv()
775 775
     {
776
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
776
+        return $this->clearTicketSelector().'</div><!-- ticketSelectorEndDiv -->';
777 777
     }
778 778
 
779 779
 
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     protected function handleMissingEvent()
810 810
     {
811 811
         // If this is not an iFrame request, simply return false.
812
-        if (! $this->isIframe()) {
812
+        if ( ! $this->isIframe()) {
813 813
             return '';
814 814
         }
815 815
         // This is an iFrame so return an error.
Please login to merge, or discard this patch.
Indentation   +810 added lines, -810 removed lines patch added patch discarded remove patch
@@ -39,817 +39,817 @@
 block discarded – undo
39 39
  */
40 40
 class DisplayTicketSelector
41 41
 {
42
-    /**
43
-     * @var RequestInterface
44
-     */
45
-    protected $request;
46
-
47
-    /**
48
-     * @var EE_Ticket_Selector_Config
49
-     */
50
-    protected $config;
51
-
52
-    /**
53
-     * event that ticket selector is being generated for
54
-     *
55
-     * @access protected
56
-     * @var EE_Event $event
57
-     */
58
-    protected $event;
59
-
60
-    /**
61
-     * Used to flag when the ticket selector is being called from an external iframe.
62
-     *
63
-     * @var bool $iframe
64
-     */
65
-    protected $iframe = false;
66
-
67
-    /**
68
-     * max attendees that can register for event at one time
69
-     *
70
-     * @var int $max_attendees
71
-     */
72
-    private $max_attendees = EE_INF;
73
-
74
-    /**
75
-     * @var string $date_format
76
-     */
77
-    private $date_format;
78
-
79
-    /**
80
-     * @var string $time_format
81
-     */
82
-    private $time_format;
83
-
84
-    /**
85
-     * @var boolean $display_full_ui
86
-     */
87
-    private $display_full_ui;
88
-
89
-
90
-    /**
91
-     * DisplayTicketSelector constructor.
92
-     *
93
-     * @param RequestInterface          $request
94
-     * @param EE_Ticket_Selector_Config $config
95
-     * @param bool                      $iframe
96
-     */
97
-    public function __construct(RequestInterface $request, EE_Ticket_Selector_Config $config, $iframe = false)
98
-    {
99
-        $this->request     = $request;
100
-        $this->config      = $config;
101
-        $this->iframe      = $iframe;
102
-        $this->date_format = apply_filters(
103
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
104
-            get_option('date_format')
105
-        );
106
-        $this->time_format = apply_filters(
107
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
108
-            get_option('time_format')
109
-        );
110
-    }
111
-
112
-
113
-    /**
114
-     * @return bool
115
-     */
116
-    public function isIframe()
117
-    {
118
-        return $this->iframe;
119
-    }
120
-
121
-
122
-    /**
123
-     * @param boolean $iframe
124
-     */
125
-    public function setIframe($iframe = true)
126
-    {
127
-        $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN);
128
-    }
129
-
130
-
131
-    /**
132
-     * finds and sets the \EE_Event object for use throughout class
133
-     *
134
-     * @param mixed $event
135
-     * @return bool
136
-     * @throws EE_Error
137
-     * @throws InvalidDataTypeException
138
-     * @throws InvalidInterfaceException
139
-     * @throws InvalidArgumentException
140
-     */
141
-    protected function setEvent($event = null)
142
-    {
143
-        if ($event === null) {
144
-            global $post;
145
-            $event = $post;
146
-        }
147
-        if ($event instanceof EE_Event) {
148
-            $this->event = $event;
149
-        } elseif ($event instanceof WP_Post) {
150
-            if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
151
-                $this->event = $event->EE_Event;
152
-            } elseif ($event->post_type === 'espresso_events') {
153
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
154
-                $this->event     = $event->EE_Event;
155
-            }
156
-        } else {
157
-            $user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso');
158
-            $dev_msg  = $user_msg . esc_html__(
159
-                'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
160
-                'event_espresso'
161
-            );
162
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
163
-            return false;
164
-        }
165
-        return true;
166
-    }
167
-
168
-
169
-    /**
170
-     * @return int
171
-     */
172
-    public function getMaxAttendees()
173
-    {
174
-        return $this->max_attendees;
175
-    }
176
-
177
-
178
-    /**
179
-     * @param int $max_attendees
180
-     */
181
-    public function setMaxAttendees($max_attendees)
182
-    {
183
-        $this->max_attendees = absint(
184
-            apply_filters(
185
-                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
186
-                $max_attendees
187
-            )
188
-        );
189
-    }
190
-
191
-
192
-    /**
193
-     * Returns whether or not the full ticket selector should be shown or not.
194
-     * Currently, it displays on the frontend (including ajax requests) but not the backend
195
-     *
196
-     * @return bool
197
-     */
198
-    private function display_full_ui()
199
-    {
200
-        if ($this->display_full_ui === null) {
201
-            $this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX);
202
-        }
203
-        return $this->display_full_ui;
204
-    }
205
-
206
-
207
-    /**
208
-     * creates buttons for selecting number of attendees for an event
209
-     *
210
-     * @param WP_Post|int $event
211
-     * @param bool        $view_details
212
-     * @return string
213
-     * @throws EE_Error
214
-     * @throws InvalidArgumentException
215
-     * @throws InvalidDataTypeException
216
-     * @throws InvalidInterfaceException
217
-     * @throws ReflectionException
218
-     * @throws Exception
219
-     */
220
-    public function display($event = null, $view_details = false)
221
-    {
222
-        // reset filter for displaying submit button
223
-        remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
224
-        // poke and prod incoming event till it tells us what it is
225
-        if (! $this->setEvent($event)) {
226
-            return $this->handleMissingEvent();
227
-        }
228
-        // is the event expired ?
229
-        $template_args['event_is_expired'] = ! is_admin() && $this->event->is_expired();
230
-        if ($template_args['event_is_expired']) {
231
-            return is_single()
232
-                ? $this->expiredEventMessage()
233
-                : $this->expiredEventMessage()
234
-                  . $this->displayViewDetailsButton();
235
-        }
236
-        // begin gathering template arguments by getting event status
237
-        $template_args = ['event_status' => $this->event->get_active_status()];
238
-        if (
239
-            $this->activeEventAndShowTicketSelector(
240
-                $event,
241
-                $template_args['event_status'],
242
-                $view_details
243
-            )
244
-        ) {
245
-            return ! is_single() ? $this->displayViewDetailsButton() : '';
246
-        }
247
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
248
-        $this->setMaxAttendees($this->event->additional_limit());
249
-        if ($this->getMaxAttendees() < 1) {
250
-            return $this->ticketSalesClosedMessage();
251
-        }
252
-        // get all tickets for this event ordered by the datetime
253
-        $tickets = $this->getTickets();
254
-        if (count($tickets) < 1) {
255
-            return $this->noTicketAvailableMessage();
256
-        }
257
-        // redirecting to another site for registration ??
258
-        $external_url = (string) $this->event->external_url()
259
-                        && $this->event->external_url() !== get_the_permalink()
260
-            ? $this->event->external_url()
261
-            : '';
262
-        // if redirecting to another site for registration, then we don't load the TS
263
-        $ticket_selector = $external_url
264
-            ? $this->externalEventRegistration()
265
-            : $this->loadTicketSelector($tickets, $template_args);
266
-        // now set up the form (but not for the admin)
267
-        $ticket_selector = $this->display_full_ui()
268
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
269
-            : $ticket_selector;
270
-        // submit button and form close tag
271
-        $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
272
-        return $ticket_selector;
273
-    }
274
-
275
-
276
-    /**
277
-     * displayTicketSelector
278
-     * examines the event properties and determines whether a Ticket Selector should be displayed
279
-     *
280
-     * @param WP_Post|int $event
281
-     * @param string      $_event_active_status
282
-     * @param bool        $view_details
283
-     * @return bool
284
-     * @throws EE_Error
285
-     * @throws ReflectionException
286
-     */
287
-    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
288
-    {
289
-        $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
290
-        return $this->display_full_ui()
291
-               && (
292
-                   ! $this->event->display_ticket_selector()
293
-                   || $view_details
294
-                   || post_password_required($event_post)
295
-                   || (
296
-                       $_event_active_status !== EE_Datetime::active
297
-                       && $_event_active_status !== EE_Datetime::upcoming
298
-                       && $_event_active_status !== EE_Datetime::sold_out
299
-                       && ! (
300
-                           $_event_active_status === EE_Datetime::inactive
301
-                           && is_user_logged_in()
302
-                       )
303
-                   )
304
-               );
305
-    }
306
-
307
-
308
-    /**
309
-     * noTicketAvailableMessage
310
-     * notice displayed if event is expired
311
-     *
312
-     * @return string
313
-     */
314
-    protected function expiredEventMessage()
315
-    {
316
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
317
-            'We\'re sorry, but all tickets sales have ended because the event is expired.',
318
-            'event_espresso'
319
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
320
-    }
321
-
322
-
323
-    /**
324
-     * noTicketAvailableMessage
325
-     * notice displayed if event has no more tickets available
326
-     *
327
-     * @return string
328
-     * @throws EE_Error
329
-     * @throws ReflectionException
330
-     */
331
-    protected function noTicketAvailableMessage()
332
-    {
333
-        $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso');
334
-        if (current_user_can('edit_post', $this->event->ID())) {
335
-            $no_ticket_available_msg .= sprintf(
336
-                esc_html__(
337
-                    '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
338
-                    'event_espresso'
339
-                ),
340
-                '<div class="ee-attention" style="text-align: left;"><b>',
341
-                '</b><br />',
342
-                '<span class="edit-link"><a class="post-edit-link" href="'
343
-                . get_edit_post_link($this->event->ID())
344
-                . '">',
345
-                '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
346
-            );
347
-        }
348
-        return '
42
+	/**
43
+	 * @var RequestInterface
44
+	 */
45
+	protected $request;
46
+
47
+	/**
48
+	 * @var EE_Ticket_Selector_Config
49
+	 */
50
+	protected $config;
51
+
52
+	/**
53
+	 * event that ticket selector is being generated for
54
+	 *
55
+	 * @access protected
56
+	 * @var EE_Event $event
57
+	 */
58
+	protected $event;
59
+
60
+	/**
61
+	 * Used to flag when the ticket selector is being called from an external iframe.
62
+	 *
63
+	 * @var bool $iframe
64
+	 */
65
+	protected $iframe = false;
66
+
67
+	/**
68
+	 * max attendees that can register for event at one time
69
+	 *
70
+	 * @var int $max_attendees
71
+	 */
72
+	private $max_attendees = EE_INF;
73
+
74
+	/**
75
+	 * @var string $date_format
76
+	 */
77
+	private $date_format;
78
+
79
+	/**
80
+	 * @var string $time_format
81
+	 */
82
+	private $time_format;
83
+
84
+	/**
85
+	 * @var boolean $display_full_ui
86
+	 */
87
+	private $display_full_ui;
88
+
89
+
90
+	/**
91
+	 * DisplayTicketSelector constructor.
92
+	 *
93
+	 * @param RequestInterface          $request
94
+	 * @param EE_Ticket_Selector_Config $config
95
+	 * @param bool                      $iframe
96
+	 */
97
+	public function __construct(RequestInterface $request, EE_Ticket_Selector_Config $config, $iframe = false)
98
+	{
99
+		$this->request     = $request;
100
+		$this->config      = $config;
101
+		$this->iframe      = $iframe;
102
+		$this->date_format = apply_filters(
103
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
104
+			get_option('date_format')
105
+		);
106
+		$this->time_format = apply_filters(
107
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
108
+			get_option('time_format')
109
+		);
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return bool
115
+	 */
116
+	public function isIframe()
117
+	{
118
+		return $this->iframe;
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param boolean $iframe
124
+	 */
125
+	public function setIframe($iframe = true)
126
+	{
127
+		$this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN);
128
+	}
129
+
130
+
131
+	/**
132
+	 * finds and sets the \EE_Event object for use throughout class
133
+	 *
134
+	 * @param mixed $event
135
+	 * @return bool
136
+	 * @throws EE_Error
137
+	 * @throws InvalidDataTypeException
138
+	 * @throws InvalidInterfaceException
139
+	 * @throws InvalidArgumentException
140
+	 */
141
+	protected function setEvent($event = null)
142
+	{
143
+		if ($event === null) {
144
+			global $post;
145
+			$event = $post;
146
+		}
147
+		if ($event instanceof EE_Event) {
148
+			$this->event = $event;
149
+		} elseif ($event instanceof WP_Post) {
150
+			if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
151
+				$this->event = $event->EE_Event;
152
+			} elseif ($event->post_type === 'espresso_events') {
153
+				$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
154
+				$this->event     = $event->EE_Event;
155
+			}
156
+		} else {
157
+			$user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso');
158
+			$dev_msg  = $user_msg . esc_html__(
159
+				'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
160
+				'event_espresso'
161
+			);
162
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
163
+			return false;
164
+		}
165
+		return true;
166
+	}
167
+
168
+
169
+	/**
170
+	 * @return int
171
+	 */
172
+	public function getMaxAttendees()
173
+	{
174
+		return $this->max_attendees;
175
+	}
176
+
177
+
178
+	/**
179
+	 * @param int $max_attendees
180
+	 */
181
+	public function setMaxAttendees($max_attendees)
182
+	{
183
+		$this->max_attendees = absint(
184
+			apply_filters(
185
+				'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
186
+				$max_attendees
187
+			)
188
+		);
189
+	}
190
+
191
+
192
+	/**
193
+	 * Returns whether or not the full ticket selector should be shown or not.
194
+	 * Currently, it displays on the frontend (including ajax requests) but not the backend
195
+	 *
196
+	 * @return bool
197
+	 */
198
+	private function display_full_ui()
199
+	{
200
+		if ($this->display_full_ui === null) {
201
+			$this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX);
202
+		}
203
+		return $this->display_full_ui;
204
+	}
205
+
206
+
207
+	/**
208
+	 * creates buttons for selecting number of attendees for an event
209
+	 *
210
+	 * @param WP_Post|int $event
211
+	 * @param bool        $view_details
212
+	 * @return string
213
+	 * @throws EE_Error
214
+	 * @throws InvalidArgumentException
215
+	 * @throws InvalidDataTypeException
216
+	 * @throws InvalidInterfaceException
217
+	 * @throws ReflectionException
218
+	 * @throws Exception
219
+	 */
220
+	public function display($event = null, $view_details = false)
221
+	{
222
+		// reset filter for displaying submit button
223
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
224
+		// poke and prod incoming event till it tells us what it is
225
+		if (! $this->setEvent($event)) {
226
+			return $this->handleMissingEvent();
227
+		}
228
+		// is the event expired ?
229
+		$template_args['event_is_expired'] = ! is_admin() && $this->event->is_expired();
230
+		if ($template_args['event_is_expired']) {
231
+			return is_single()
232
+				? $this->expiredEventMessage()
233
+				: $this->expiredEventMessage()
234
+				  . $this->displayViewDetailsButton();
235
+		}
236
+		// begin gathering template arguments by getting event status
237
+		$template_args = ['event_status' => $this->event->get_active_status()];
238
+		if (
239
+			$this->activeEventAndShowTicketSelector(
240
+				$event,
241
+				$template_args['event_status'],
242
+				$view_details
243
+			)
244
+		) {
245
+			return ! is_single() ? $this->displayViewDetailsButton() : '';
246
+		}
247
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
248
+		$this->setMaxAttendees($this->event->additional_limit());
249
+		if ($this->getMaxAttendees() < 1) {
250
+			return $this->ticketSalesClosedMessage();
251
+		}
252
+		// get all tickets for this event ordered by the datetime
253
+		$tickets = $this->getTickets();
254
+		if (count($tickets) < 1) {
255
+			return $this->noTicketAvailableMessage();
256
+		}
257
+		// redirecting to another site for registration ??
258
+		$external_url = (string) $this->event->external_url()
259
+						&& $this->event->external_url() !== get_the_permalink()
260
+			? $this->event->external_url()
261
+			: '';
262
+		// if redirecting to another site for registration, then we don't load the TS
263
+		$ticket_selector = $external_url
264
+			? $this->externalEventRegistration()
265
+			: $this->loadTicketSelector($tickets, $template_args);
266
+		// now set up the form (but not for the admin)
267
+		$ticket_selector = $this->display_full_ui()
268
+			? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
269
+			: $ticket_selector;
270
+		// submit button and form close tag
271
+		$ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
272
+		return $ticket_selector;
273
+	}
274
+
275
+
276
+	/**
277
+	 * displayTicketSelector
278
+	 * examines the event properties and determines whether a Ticket Selector should be displayed
279
+	 *
280
+	 * @param WP_Post|int $event
281
+	 * @param string      $_event_active_status
282
+	 * @param bool        $view_details
283
+	 * @return bool
284
+	 * @throws EE_Error
285
+	 * @throws ReflectionException
286
+	 */
287
+	protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
288
+	{
289
+		$event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
290
+		return $this->display_full_ui()
291
+			   && (
292
+				   ! $this->event->display_ticket_selector()
293
+				   || $view_details
294
+				   || post_password_required($event_post)
295
+				   || (
296
+					   $_event_active_status !== EE_Datetime::active
297
+					   && $_event_active_status !== EE_Datetime::upcoming
298
+					   && $_event_active_status !== EE_Datetime::sold_out
299
+					   && ! (
300
+						   $_event_active_status === EE_Datetime::inactive
301
+						   && is_user_logged_in()
302
+					   )
303
+				   )
304
+			   );
305
+	}
306
+
307
+
308
+	/**
309
+	 * noTicketAvailableMessage
310
+	 * notice displayed if event is expired
311
+	 *
312
+	 * @return string
313
+	 */
314
+	protected function expiredEventMessage()
315
+	{
316
+		return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
317
+			'We\'re sorry, but all tickets sales have ended because the event is expired.',
318
+			'event_espresso'
319
+		) . '</span></div><!-- .ee-event-expired-notice -->';
320
+	}
321
+
322
+
323
+	/**
324
+	 * noTicketAvailableMessage
325
+	 * notice displayed if event has no more tickets available
326
+	 *
327
+	 * @return string
328
+	 * @throws EE_Error
329
+	 * @throws ReflectionException
330
+	 */
331
+	protected function noTicketAvailableMessage()
332
+	{
333
+		$no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso');
334
+		if (current_user_can('edit_post', $this->event->ID())) {
335
+			$no_ticket_available_msg .= sprintf(
336
+				esc_html__(
337
+					'%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
338
+					'event_espresso'
339
+				),
340
+				'<div class="ee-attention" style="text-align: left;"><b>',
341
+				'</b><br />',
342
+				'<span class="edit-link"><a class="post-edit-link" href="'
343
+				. get_edit_post_link($this->event->ID())
344
+				. '">',
345
+				'</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
346
+			);
347
+		}
348
+		return '
349 349
             <div class="ee-event-expired-notice">
350 350
                 <span class="important-notice">' . $no_ticket_available_msg . '</span>
351 351
             </div><!-- .ee-event-expired-notice -->';
352
-    }
353
-
354
-
355
-    /**
356
-     * ticketSalesClosed
357
-     * notice displayed if event ticket sales are turned off
358
-     *
359
-     * @return string
360
-     * @throws EE_Error
361
-     * @throws ReflectionException
362
-     */
363
-    protected function ticketSalesClosedMessage()
364
-    {
365
-        $sales_closed_msg = esc_html__(
366
-            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
367
-            'event_espresso'
368
-        );
369
-        if (current_user_can('edit_post', $this->event->ID())) {
370
-            $sales_closed_msg .= sprintf(
371
-                esc_html__(
372
-                    '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
373
-                    'event_espresso'
374
-                ),
375
-                '<div class="ee-attention" style="text-align: left;"><b>',
376
-                '</b><br />',
377
-                '<span class="edit-link"><a class="post-edit-link" href="'
378
-                . get_edit_post_link($this->event->ID())
379
-                . '">',
380
-                '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
381
-            );
382
-        }
383
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
384
-    }
385
-
386
-
387
-    /**
388
-     * getTickets
389
-     *
390
-     * @return EE_Base_Class[]|EE_Ticket[]
391
-     * @throws EE_Error
392
-     * @throws InvalidDataTypeException
393
-     * @throws InvalidInterfaceException
394
-     * @throws InvalidArgumentException
395
-     * @throws ReflectionException
396
-     */
397
-    protected function getTickets()
398
-    {
399
-        $show_expired_tickets = is_admin() || $this->config->show_expired_tickets;
400
-
401
-        $ticket_query_args = [
402
-            ['Datetime.EVT_ID' => $this->event->ID()],
403
-            'order_by' => [
404
-                'TKT_order'              => 'ASC',
405
-                'TKT_required'           => 'DESC',
406
-                'TKT_start_date'         => 'ASC',
407
-                'TKT_end_date'           => 'ASC',
408
-                'Datetime.DTT_EVT_start' => 'DESC',
409
-            ],
410
-        ];
411
-        if (! $show_expired_tickets) {
412
-            // use the correct applicable time query depending on what version of core is being run.
413
-            $current_time                         = method_exists('EEM_Datetime', 'current_time_for_query')
414
-                ? time()
415
-                : current_time('timestamp');
416
-            $ticket_query_args[0]['TKT_end_date'] = ['>', $current_time];
417
-        }
418
-        return EEM_Ticket::instance()->get_all($ticket_query_args);
419
-    }
420
-
421
-
422
-    /**
423
-     * loadTicketSelector
424
-     * begins to assemble template arguments
425
-     * and decides whether to load a "simple" ticket selector, or the standard
426
-     *
427
-     * @param EE_Ticket[] $tickets
428
-     * @param array       $template_args
429
-     * @return TicketSelectorSimple|TicketSelectorStandard
430
-     * @throws EE_Error
431
-     * @throws ReflectionException
432
-     */
433
-    protected function loadTicketSelector(array $tickets, array $template_args)
434
-    {
435
-        $template_args['event']            = $this->event;
436
-        $template_args['EVT_ID']           = $this->event->ID();
437
-        $template_args['event_is_expired'] = $this->event->is_expired();
438
-        $template_args['max_atndz']        = $this->getMaxAttendees();
439
-        $template_args['date_format']      = $this->date_format;
440
-        $template_args['time_format']      = $this->time_format;
441
-        /**
442
-         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
443
-         *
444
-         * @param string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
445
-         * @param int $EVT_ID The Event ID
446
-         * @since 4.9.13
447
-         */
448
-        $template_args['anchor_id']    = apply_filters(
449
-            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
450
-            '#tkt-slctr-tbl-' . $this->event->ID(),
451
-            $this->event->ID()
452
-        );
453
-        $template_args['tickets']      = $tickets;
454
-        $template_args['ticket_count'] = count($tickets);
455
-        $ticket_selector               = $this->simpleTicketSelector($tickets, $template_args);
456
-        if ($ticket_selector instanceof TicketSelectorSimple) {
457
-            return $ticket_selector;
458
-        }
459
-        return new TicketSelectorStandard(
460
-            $this->config,
461
-            $this->getTaxConfig(),
462
-            $this->event,
463
-            $tickets,
464
-            $this->getMaxAttendees(),
465
-            $template_args,
466
-            $this->date_format,
467
-            $this->time_format
468
-        );
469
-    }
470
-
471
-
472
-    /**
473
-     * simpleTicketSelector
474
-     * there's one ticket, and max attendees is set to one,
475
-     * so if the event is free, then this is a "simple" ticket selector
476
-     * a.k.a. "Dude Where's my Ticket Selector?"
477
-     *
478
-     * @param EE_Ticket[] $tickets
479
-     * @param array       $template_args
480
-     * @return string
481
-     * @throws EE_Error
482
-     * @throws ReflectionException
483
-     */
484
-    protected function simpleTicketSelector($tickets, array $template_args)
485
-    {
486
-        // if there is only ONE ticket with a max qty of ONE
487
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
488
-            return '';
489
-        }
490
-        /** @var EE_Ticket $ticket */
491
-        $ticket = reset($tickets);
492
-        // if the ticket is free... then not much need for the ticket selector
493
-        if (
494
-            apply_filters(
495
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
496
-                $ticket->is_free(),
497
-                $this->event->ID()
498
-            )
499
-        ) {
500
-            return new TicketSelectorSimple(
501
-                $this->event,
502
-                $ticket,
503
-                $this->getMaxAttendees(),
504
-                $template_args
505
-            );
506
-        }
507
-        return '';
508
-    }
509
-
510
-
511
-    /**
512
-     * externalEventRegistration
513
-     *
514
-     * @return string
515
-     */
516
-    public function externalEventRegistration()
517
-    {
518
-        // if not we still need to trigger the display of the submit button
519
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
520
-        // display notice to admin that registration is external
521
-        return $this->display_full_ui()
522
-            ? esc_html__(
523
-                'Registration is at an external URL for this event.',
524
-                'event_espresso'
525
-            )
526
-            : '';
527
-    }
528
-
529
-
530
-    /**
531
-     * formOpen
532
-     *
533
-     * @param int    $ID
534
-     * @param string $external_url
535
-     * @return        string
536
-     */
537
-    public function formOpen($ID = 0, $external_url = '')
538
-    {
539
-        // if redirecting, we don't need any anything else
540
-        if ($external_url) {
541
-            $html = '<form method="GET" ';
542
-            $html .= 'action="' . EEH_URL::refactor_url($external_url) . '" ';
543
-            $html .= 'name="ticket-selector-form-' . $ID . '"';
544
-            // open link in new window ?
545
-            $html       .= apply_filters(
546
-                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
547
-                $this->isIframe(),
548
-                $this
549
-            )
550
-                ? ' target="_blank"'
551
-                : '';
552
-            $html       .= '>';
553
-            $query_args = EEH_URL::get_query_string($external_url);
554
-            foreach ((array) $query_args as $query_arg => $value) {
555
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
556
-            }
557
-            return $html;
558
-        }
559
-        // if there is no submit button, then don't start building a form
560
-        // because the "View Details" button will build its own form
561
-        if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562
-            return '';
563
-        }
564
-        $checkout_url = EEH_Event_View::event_link_url($ID);
565
-        if (! $checkout_url) {
566
-            EE_Error::add_error(
567
-                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
568
-                __FILE__,
569
-                __FUNCTION__,
570
-                __LINE__
571
-            );
572
-        }
573
-        // set no cache headers and constants
574
-        EE_System::do_not_cache();
575
-        $html = '<form method="POST" ';
576
-        $html .= 'action="' . $checkout_url . '" ';
577
-        $html .= 'name="ticket-selector-form-' . $ID . '"';
578
-        $html .= $this->iframe ? ' target="_blank"' : '';
579
-        $html .= '>';
580
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
581
-        return apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event);
582
-    }
583
-
584
-
585
-    /**
586
-     * displaySubmitButton
587
-     *
588
-     * @param string $external_url
589
-     * @return string
590
-     * @throws EE_Error
591
-     * @throws ReflectionException
592
-     */
593
-    public function displaySubmitButton($external_url = '')
594
-    {
595
-        $html = '';
596
-        if ($this->display_full_ui()) {
597
-            // standard TS displayed with submit button, ie: "Register Now"
598
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
599
-                $html .= $this->displayRegisterNowButton();
600
-                $html .= empty($external_url)
601
-                    ? $this->ticketSelectorEndDiv()
602
-                    : $this->clearTicketSelector();
603
-                $html .= '<br/>' . $this->formClose();
604
-            } elseif ($this->getMaxAttendees() === 1) {
605
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
606
-                if ($this->event->is_sold_out()) {
607
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
608
-                    $html .= apply_filters(
609
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
610
-                        sprintf(
611
-                            esc_html__(
612
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
613
-                                'event_espresso'
614
-                            ),
615
-                            '<p class="no-ticket-selector-msg clear-float">',
616
-                            $this->event->name(),
617
-                            '</p>',
618
-                            '<br />'
619
-                        ),
620
-                        $this->event
621
-                    );
622
-                    if (
623
-                        apply_filters(
624
-                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
625
-                            false,
626
-                            $this->event
627
-                        )
628
-                    ) {
629
-                        $html .= $this->displayRegisterNowButton();
630
-                    }
631
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
632
-                    $html .= $this->ticketSelectorEndDiv();
633
-                } elseif (
634
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
635
-                          && ! is_single()
636
-                ) {
637
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
638
-                    // but no tickets are available, so display event's "View Details" button.
639
-                    // it is being viewed via somewhere other than a single post
640
-                    $html .= $this->displayViewDetailsButton(true);
641
-                } else {
642
-                    $html .= $this->ticketSelectorEndDiv();
643
-                }
644
-            } elseif (is_archive()) {
645
-                // event list, no tickets available so display event's "View Details" button
646
-                $html .= $this->ticketSelectorEndDiv();
647
-                $html .= $this->displayViewDetailsButton();
648
-            } else {
649
-                if (
650
-                    apply_filters(
651
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
652
-                        false,
653
-                        $this->event
654
-                    )
655
-                ) {
656
-                    $html .= $this->displayRegisterNowButton();
657
-                }
658
-                // no submit or view details button, and no additional content
659
-                $html .= $this->ticketSelectorEndDiv();
660
-            }
661
-            if (! $this->iframe && ! is_archive()) {
662
-                $html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']);
663
-            }
664
-        }
665
-        return apply_filters(
666
-            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html',
667
-            $html,
668
-            $this->event,
669
-            $this
670
-        );
671
-    }
672
-
673
-
674
-    /**
675
-     * @return string
676
-     * @throws EE_Error
677
-     * @throws ReflectionException
678
-     */
679
-    public function displayRegisterNowButton()
680
-    {
681
-        $btn_text     = apply_filters(
682
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
683
-            esc_html__('Register Now', 'event_espresso'),
684
-            $this->event
685
-        );
686
-        $external_url = (string) $this->event->external_url()
687
-                        && $this->event->external_url() !== get_the_permalink()
688
-            ? $this->event->external_url()
689
-            : '';
690
-        $html         = EEH_HTML::div(
691
-            '',
692
-            'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap',
693
-            'ticket-selector-submit-btn-wrap'
694
-        );
695
-        $html         .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
696
-        $html         .= ' class="ticket-selector-submit-btn ';
697
-        $html         .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
698
-        $html         .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />';
699
-        $html         .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
700
-        $html         .= apply_filters(
701
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
702
-            '',
703
-            $this->event,
704
-            $this->iframe
705
-        );
706
-        return $html;
707
-    }
708
-
709
-
710
-    /**
711
-     * displayViewDetailsButton
712
-     *
713
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
714
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
715
-     *                    either because they are sold out, expired, or not yet on sale.
716
-     *                    In this case, we need to close the form BEFORE adding any closing divs
717
-     * @return string
718
-     * @throws EE_Error
719
-     * @throws ReflectionException
720
-     */
721
-    public function displayViewDetailsButton($DWMTS = false)
722
-    {
723
-        if (! $this->event->get_permalink()) {
724
-            EE_Error::add_error(
725
-                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
726
-                __FILE__,
727
-                __FUNCTION__,
728
-                __LINE__
729
-            );
730
-        }
731
-        $view_details_btn = '<form method="GET" action="';
732
-        $view_details_btn .= apply_filters(
733
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
734
-            $this->event->get_permalink(),
735
-            $this->event
736
-        );
737
-        $view_details_btn .= '"';
738
-        // open link in new window ?
739
-        $view_details_btn .= apply_filters(
740
-            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
741
-            $this->isIframe(),
742
-            $this
743
-        )
744
-            ? ' target="_blank"'
745
-            : '';
746
-        $view_details_btn .= '>';
747
-        $btn_text         = apply_filters(
748
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
749
-            esc_html__('View Details', 'event_espresso'),
750
-            $this->event
751
-        );
752
-        $view_details_btn .= '<input id="ticket-selector-submit-'
753
-                             . $this->event->ID()
754
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
755
-                             . $btn_text
756
-                             . '" />';
757
-        $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event);
758
-        if ($DWMTS) {
759
-            $view_details_btn .= $this->formClose();
760
-            $view_details_btn .= $this->ticketSelectorEndDiv();
761
-            $view_details_btn .= '<br/>';
762
-        } else {
763
-            $view_details_btn .= $this->clearTicketSelector();
764
-            $view_details_btn .= '<br/>';
765
-            $view_details_btn .= $this->formClose();
766
-        }
767
-        return $view_details_btn;
768
-    }
769
-
770
-
771
-    /**
772
-     * @return string
773
-     */
774
-    public function ticketSelectorEndDiv()
775
-    {
776
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
777
-    }
778
-
779
-
780
-    /**
781
-     * @return string
782
-     */
783
-    public function clearTicketSelector()
784
-    {
785
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
786
-        return '<div class="clear"></div><!-- clearTicketSelector -->';
787
-    }
788
-
789
-
790
-    /**
791
-     * @access        public
792
-     * @return        string
793
-     */
794
-    public function formClose()
795
-    {
796
-        return '</form>';
797
-    }
798
-
799
-
800
-    /**
801
-     * handleMissingEvent
802
-     * Returns either false or an error to display when no valid event is passed.
803
-     *
804
-     * @return string
805
-     * @throws ExceptionStackTraceDisplay
806
-     * @throws InvalidInterfaceException
807
-     * @throws Exception
808
-     */
809
-    protected function handleMissingEvent()
810
-    {
811
-        // If this is not an iFrame request, simply return false.
812
-        if (! $this->isIframe()) {
813
-            return '';
814
-        }
815
-        // This is an iFrame so return an error.
816
-        // Display stack trace if WP_DEBUG is enabled.
817
-        if (WP_DEBUG === true && current_user_can('edit_pages')) {
818
-            $event_id = $this->request->getRequestParam('event', 0, 'int');
819
-            new ExceptionStackTraceDisplay(
820
-                new InvalidArgumentException(
821
-                    sprintf(
822
-                        esc_html__(
823
-                            'A valid Event ID is required to display the ticket selector.%3$sAn Event with an ID of "%1$s" could not be found.%3$sPlease verify that the embed code added to this post\'s content includes an "%2$s" argument and that its value corresponds to a valid Event ID.',
824
-                            'event_espresso'
825
-                        ),
826
-                        $event_id,
827
-                        'event',
828
-                        '<br />'
829
-                    )
830
-                )
831
-            );
832
-            return '';
833
-        }
834
-        // If WP_DEBUG is not enabled, display a message stating the event could not be found.
835
-        return EEH_HTML::p(
836
-            esc_html__(
837
-                'A valid Event could not be found. Please contact the event administrator for assistance.',
838
-                'event_espresso'
839
-            )
840
-        );
841
-    }
842
-
843
-
844
-    /**
845
-     * @return EE_Tax_Config
846
-     * @since   4.10.14.p
847
-     */
848
-    protected function getTaxConfig()
849
-    {
850
-        return isset(EE_Registry::instance()->CFG->tax_settings)
851
-               && EE_Registry::instance()->CFG->tax_settings instanceof EE_Tax_Config
852
-            ? EE_Registry::instance()->CFG->tax_settings
853
-            : new EE_Tax_Config();
854
-    }
352
+	}
353
+
354
+
355
+	/**
356
+	 * ticketSalesClosed
357
+	 * notice displayed if event ticket sales are turned off
358
+	 *
359
+	 * @return string
360
+	 * @throws EE_Error
361
+	 * @throws ReflectionException
362
+	 */
363
+	protected function ticketSalesClosedMessage()
364
+	{
365
+		$sales_closed_msg = esc_html__(
366
+			'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
367
+			'event_espresso'
368
+		);
369
+		if (current_user_can('edit_post', $this->event->ID())) {
370
+			$sales_closed_msg .= sprintf(
371
+				esc_html__(
372
+					'%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
373
+					'event_espresso'
374
+				),
375
+				'<div class="ee-attention" style="text-align: left;"><b>',
376
+				'</b><br />',
377
+				'<span class="edit-link"><a class="post-edit-link" href="'
378
+				. get_edit_post_link($this->event->ID())
379
+				. '">',
380
+				'</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
381
+			);
382
+		}
383
+		return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
384
+	}
385
+
386
+
387
+	/**
388
+	 * getTickets
389
+	 *
390
+	 * @return EE_Base_Class[]|EE_Ticket[]
391
+	 * @throws EE_Error
392
+	 * @throws InvalidDataTypeException
393
+	 * @throws InvalidInterfaceException
394
+	 * @throws InvalidArgumentException
395
+	 * @throws ReflectionException
396
+	 */
397
+	protected function getTickets()
398
+	{
399
+		$show_expired_tickets = is_admin() || $this->config->show_expired_tickets;
400
+
401
+		$ticket_query_args = [
402
+			['Datetime.EVT_ID' => $this->event->ID()],
403
+			'order_by' => [
404
+				'TKT_order'              => 'ASC',
405
+				'TKT_required'           => 'DESC',
406
+				'TKT_start_date'         => 'ASC',
407
+				'TKT_end_date'           => 'ASC',
408
+				'Datetime.DTT_EVT_start' => 'DESC',
409
+			],
410
+		];
411
+		if (! $show_expired_tickets) {
412
+			// use the correct applicable time query depending on what version of core is being run.
413
+			$current_time                         = method_exists('EEM_Datetime', 'current_time_for_query')
414
+				? time()
415
+				: current_time('timestamp');
416
+			$ticket_query_args[0]['TKT_end_date'] = ['>', $current_time];
417
+		}
418
+		return EEM_Ticket::instance()->get_all($ticket_query_args);
419
+	}
420
+
421
+
422
+	/**
423
+	 * loadTicketSelector
424
+	 * begins to assemble template arguments
425
+	 * and decides whether to load a "simple" ticket selector, or the standard
426
+	 *
427
+	 * @param EE_Ticket[] $tickets
428
+	 * @param array       $template_args
429
+	 * @return TicketSelectorSimple|TicketSelectorStandard
430
+	 * @throws EE_Error
431
+	 * @throws ReflectionException
432
+	 */
433
+	protected function loadTicketSelector(array $tickets, array $template_args)
434
+	{
435
+		$template_args['event']            = $this->event;
436
+		$template_args['EVT_ID']           = $this->event->ID();
437
+		$template_args['event_is_expired'] = $this->event->is_expired();
438
+		$template_args['max_atndz']        = $this->getMaxAttendees();
439
+		$template_args['date_format']      = $this->date_format;
440
+		$template_args['time_format']      = $this->time_format;
441
+		/**
442
+		 * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
443
+		 *
444
+		 * @param string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
445
+		 * @param int $EVT_ID The Event ID
446
+		 * @since 4.9.13
447
+		 */
448
+		$template_args['anchor_id']    = apply_filters(
449
+			'FHEE__EE_Ticket_Selector__redirect_anchor_id',
450
+			'#tkt-slctr-tbl-' . $this->event->ID(),
451
+			$this->event->ID()
452
+		);
453
+		$template_args['tickets']      = $tickets;
454
+		$template_args['ticket_count'] = count($tickets);
455
+		$ticket_selector               = $this->simpleTicketSelector($tickets, $template_args);
456
+		if ($ticket_selector instanceof TicketSelectorSimple) {
457
+			return $ticket_selector;
458
+		}
459
+		return new TicketSelectorStandard(
460
+			$this->config,
461
+			$this->getTaxConfig(),
462
+			$this->event,
463
+			$tickets,
464
+			$this->getMaxAttendees(),
465
+			$template_args,
466
+			$this->date_format,
467
+			$this->time_format
468
+		);
469
+	}
470
+
471
+
472
+	/**
473
+	 * simpleTicketSelector
474
+	 * there's one ticket, and max attendees is set to one,
475
+	 * so if the event is free, then this is a "simple" ticket selector
476
+	 * a.k.a. "Dude Where's my Ticket Selector?"
477
+	 *
478
+	 * @param EE_Ticket[] $tickets
479
+	 * @param array       $template_args
480
+	 * @return string
481
+	 * @throws EE_Error
482
+	 * @throws ReflectionException
483
+	 */
484
+	protected function simpleTicketSelector($tickets, array $template_args)
485
+	{
486
+		// if there is only ONE ticket with a max qty of ONE
487
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
488
+			return '';
489
+		}
490
+		/** @var EE_Ticket $ticket */
491
+		$ticket = reset($tickets);
492
+		// if the ticket is free... then not much need for the ticket selector
493
+		if (
494
+			apply_filters(
495
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
496
+				$ticket->is_free(),
497
+				$this->event->ID()
498
+			)
499
+		) {
500
+			return new TicketSelectorSimple(
501
+				$this->event,
502
+				$ticket,
503
+				$this->getMaxAttendees(),
504
+				$template_args
505
+			);
506
+		}
507
+		return '';
508
+	}
509
+
510
+
511
+	/**
512
+	 * externalEventRegistration
513
+	 *
514
+	 * @return string
515
+	 */
516
+	public function externalEventRegistration()
517
+	{
518
+		// if not we still need to trigger the display of the submit button
519
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
520
+		// display notice to admin that registration is external
521
+		return $this->display_full_ui()
522
+			? esc_html__(
523
+				'Registration is at an external URL for this event.',
524
+				'event_espresso'
525
+			)
526
+			: '';
527
+	}
528
+
529
+
530
+	/**
531
+	 * formOpen
532
+	 *
533
+	 * @param int    $ID
534
+	 * @param string $external_url
535
+	 * @return        string
536
+	 */
537
+	public function formOpen($ID = 0, $external_url = '')
538
+	{
539
+		// if redirecting, we don't need any anything else
540
+		if ($external_url) {
541
+			$html = '<form method="GET" ';
542
+			$html .= 'action="' . EEH_URL::refactor_url($external_url) . '" ';
543
+			$html .= 'name="ticket-selector-form-' . $ID . '"';
544
+			// open link in new window ?
545
+			$html       .= apply_filters(
546
+				'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
547
+				$this->isIframe(),
548
+				$this
549
+			)
550
+				? ' target="_blank"'
551
+				: '';
552
+			$html       .= '>';
553
+			$query_args = EEH_URL::get_query_string($external_url);
554
+			foreach ((array) $query_args as $query_arg => $value) {
555
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
556
+			}
557
+			return $html;
558
+		}
559
+		// if there is no submit button, then don't start building a form
560
+		// because the "View Details" button will build its own form
561
+		if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562
+			return '';
563
+		}
564
+		$checkout_url = EEH_Event_View::event_link_url($ID);
565
+		if (! $checkout_url) {
566
+			EE_Error::add_error(
567
+				esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
568
+				__FILE__,
569
+				__FUNCTION__,
570
+				__LINE__
571
+			);
572
+		}
573
+		// set no cache headers and constants
574
+		EE_System::do_not_cache();
575
+		$html = '<form method="POST" ';
576
+		$html .= 'action="' . $checkout_url . '" ';
577
+		$html .= 'name="ticket-selector-form-' . $ID . '"';
578
+		$html .= $this->iframe ? ' target="_blank"' : '';
579
+		$html .= '>';
580
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
581
+		return apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event);
582
+	}
583
+
584
+
585
+	/**
586
+	 * displaySubmitButton
587
+	 *
588
+	 * @param string $external_url
589
+	 * @return string
590
+	 * @throws EE_Error
591
+	 * @throws ReflectionException
592
+	 */
593
+	public function displaySubmitButton($external_url = '')
594
+	{
595
+		$html = '';
596
+		if ($this->display_full_ui()) {
597
+			// standard TS displayed with submit button, ie: "Register Now"
598
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
599
+				$html .= $this->displayRegisterNowButton();
600
+				$html .= empty($external_url)
601
+					? $this->ticketSelectorEndDiv()
602
+					: $this->clearTicketSelector();
603
+				$html .= '<br/>' . $this->formClose();
604
+			} elseif ($this->getMaxAttendees() === 1) {
605
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
606
+				if ($this->event->is_sold_out()) {
607
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
608
+					$html .= apply_filters(
609
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
610
+						sprintf(
611
+							esc_html__(
612
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
613
+								'event_espresso'
614
+							),
615
+							'<p class="no-ticket-selector-msg clear-float">',
616
+							$this->event->name(),
617
+							'</p>',
618
+							'<br />'
619
+						),
620
+						$this->event
621
+					);
622
+					if (
623
+						apply_filters(
624
+							'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
625
+							false,
626
+							$this->event
627
+						)
628
+					) {
629
+						$html .= $this->displayRegisterNowButton();
630
+					}
631
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
632
+					$html .= $this->ticketSelectorEndDiv();
633
+				} elseif (
634
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
635
+						  && ! is_single()
636
+				) {
637
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
638
+					// but no tickets are available, so display event's "View Details" button.
639
+					// it is being viewed via somewhere other than a single post
640
+					$html .= $this->displayViewDetailsButton(true);
641
+				} else {
642
+					$html .= $this->ticketSelectorEndDiv();
643
+				}
644
+			} elseif (is_archive()) {
645
+				// event list, no tickets available so display event's "View Details" button
646
+				$html .= $this->ticketSelectorEndDiv();
647
+				$html .= $this->displayViewDetailsButton();
648
+			} else {
649
+				if (
650
+					apply_filters(
651
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
652
+						false,
653
+						$this->event
654
+					)
655
+				) {
656
+					$html .= $this->displayRegisterNowButton();
657
+				}
658
+				// no submit or view details button, and no additional content
659
+				$html .= $this->ticketSelectorEndDiv();
660
+			}
661
+			if (! $this->iframe && ! is_archive()) {
662
+				$html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']);
663
+			}
664
+		}
665
+		return apply_filters(
666
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html',
667
+			$html,
668
+			$this->event,
669
+			$this
670
+		);
671
+	}
672
+
673
+
674
+	/**
675
+	 * @return string
676
+	 * @throws EE_Error
677
+	 * @throws ReflectionException
678
+	 */
679
+	public function displayRegisterNowButton()
680
+	{
681
+		$btn_text     = apply_filters(
682
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
683
+			esc_html__('Register Now', 'event_espresso'),
684
+			$this->event
685
+		);
686
+		$external_url = (string) $this->event->external_url()
687
+						&& $this->event->external_url() !== get_the_permalink()
688
+			? $this->event->external_url()
689
+			: '';
690
+		$html         = EEH_HTML::div(
691
+			'',
692
+			'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap',
693
+			'ticket-selector-submit-btn-wrap'
694
+		);
695
+		$html         .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
696
+		$html         .= ' class="ticket-selector-submit-btn ';
697
+		$html         .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
698
+		$html         .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />';
699
+		$html         .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
700
+		$html         .= apply_filters(
701
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
702
+			'',
703
+			$this->event,
704
+			$this->iframe
705
+		);
706
+		return $html;
707
+	}
708
+
709
+
710
+	/**
711
+	 * displayViewDetailsButton
712
+	 *
713
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
714
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
715
+	 *                    either because they are sold out, expired, or not yet on sale.
716
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
717
+	 * @return string
718
+	 * @throws EE_Error
719
+	 * @throws ReflectionException
720
+	 */
721
+	public function displayViewDetailsButton($DWMTS = false)
722
+	{
723
+		if (! $this->event->get_permalink()) {
724
+			EE_Error::add_error(
725
+				esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
726
+				__FILE__,
727
+				__FUNCTION__,
728
+				__LINE__
729
+			);
730
+		}
731
+		$view_details_btn = '<form method="GET" action="';
732
+		$view_details_btn .= apply_filters(
733
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
734
+			$this->event->get_permalink(),
735
+			$this->event
736
+		);
737
+		$view_details_btn .= '"';
738
+		// open link in new window ?
739
+		$view_details_btn .= apply_filters(
740
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
741
+			$this->isIframe(),
742
+			$this
743
+		)
744
+			? ' target="_blank"'
745
+			: '';
746
+		$view_details_btn .= '>';
747
+		$btn_text         = apply_filters(
748
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
749
+			esc_html__('View Details', 'event_espresso'),
750
+			$this->event
751
+		);
752
+		$view_details_btn .= '<input id="ticket-selector-submit-'
753
+							 . $this->event->ID()
754
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
755
+							 . $btn_text
756
+							 . '" />';
757
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event);
758
+		if ($DWMTS) {
759
+			$view_details_btn .= $this->formClose();
760
+			$view_details_btn .= $this->ticketSelectorEndDiv();
761
+			$view_details_btn .= '<br/>';
762
+		} else {
763
+			$view_details_btn .= $this->clearTicketSelector();
764
+			$view_details_btn .= '<br/>';
765
+			$view_details_btn .= $this->formClose();
766
+		}
767
+		return $view_details_btn;
768
+	}
769
+
770
+
771
+	/**
772
+	 * @return string
773
+	 */
774
+	public function ticketSelectorEndDiv()
775
+	{
776
+		return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
777
+	}
778
+
779
+
780
+	/**
781
+	 * @return string
782
+	 */
783
+	public function clearTicketSelector()
784
+	{
785
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
786
+		return '<div class="clear"></div><!-- clearTicketSelector -->';
787
+	}
788
+
789
+
790
+	/**
791
+	 * @access        public
792
+	 * @return        string
793
+	 */
794
+	public function formClose()
795
+	{
796
+		return '</form>';
797
+	}
798
+
799
+
800
+	/**
801
+	 * handleMissingEvent
802
+	 * Returns either false or an error to display when no valid event is passed.
803
+	 *
804
+	 * @return string
805
+	 * @throws ExceptionStackTraceDisplay
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws Exception
808
+	 */
809
+	protected function handleMissingEvent()
810
+	{
811
+		// If this is not an iFrame request, simply return false.
812
+		if (! $this->isIframe()) {
813
+			return '';
814
+		}
815
+		// This is an iFrame so return an error.
816
+		// Display stack trace if WP_DEBUG is enabled.
817
+		if (WP_DEBUG === true && current_user_can('edit_pages')) {
818
+			$event_id = $this->request->getRequestParam('event', 0, 'int');
819
+			new ExceptionStackTraceDisplay(
820
+				new InvalidArgumentException(
821
+					sprintf(
822
+						esc_html__(
823
+							'A valid Event ID is required to display the ticket selector.%3$sAn Event with an ID of "%1$s" could not be found.%3$sPlease verify that the embed code added to this post\'s content includes an "%2$s" argument and that its value corresponds to a valid Event ID.',
824
+							'event_espresso'
825
+						),
826
+						$event_id,
827
+						'event',
828
+						'<br />'
829
+					)
830
+				)
831
+			);
832
+			return '';
833
+		}
834
+		// If WP_DEBUG is not enabled, display a message stating the event could not be found.
835
+		return EEH_HTML::p(
836
+			esc_html__(
837
+				'A valid Event could not be found. Please contact the event administrator for assistance.',
838
+				'event_espresso'
839
+			)
840
+		);
841
+	}
842
+
843
+
844
+	/**
845
+	 * @return EE_Tax_Config
846
+	 * @since   4.10.14.p
847
+	 */
848
+	protected function getTaxConfig()
849
+	{
850
+		return isset(EE_Registry::instance()->CFG->tax_settings)
851
+			   && EE_Registry::instance()->CFG->tax_settings instanceof EE_Tax_Config
852
+			? EE_Registry::instance()->CFG->tax_settings
853
+			: new EE_Tax_Config();
854
+	}
855 855
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketDetails.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function getShowHideLinks()
113 113
     {
114
-        if (! $this->showTicketDetails()) {
114
+        if ( ! $this->showTicketDetails()) {
115 115
             return '';
116 116
         }
117 117
         return \EEH_HTML::link(
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
             "display-{$this->cssId()}",
127 127
             'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
128 128
             '',
129
-            'rel="' . $this->cssId() . '"'
130
-        ) . \EEH_HTML::link(
129
+            'rel="'.$this->cssId().'"'
130
+        ).\EEH_HTML::link(
131 131
             '',
132 132
             sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'),
133 133
             esc_attr(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             "hide-{$this->cssId()}",
140 140
             'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
141 141
             'display:none;',
142
-            'rel="' . $this->cssId() . '"'
142
+            'rel="'.$this->cssId().'"'
143 143
         );
144 144
     }
145 145
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         return \EEH_Template::locate_template(
192 192
             apply_filters(
193 193
                 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
194
-                TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
194
+                TICKET_SELECTOR_TEMPLATES_PATH.'ticket_details.template.php',
195 195
                 $this->ticket
196 196
             ),
197 197
             $template_args
Please login to merge, or discard this patch.
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -13,186 +13,186 @@
 block discarded – undo
13 13
  */
14 14
 class TicketDetails
15 15
 {
16
-    /**
17
-     * @var \EE_Ticket $ticket
18
-     */
19
-    protected $ticket;
20
-
21
-    /**
22
-     * @var \EE_Ticket_Selector_Config $template_settings
23
-     */
24
-    protected $template_settings;
25
-
26
-    /**
27
-     * @var string $date_format
28
-     */
29
-    protected $date_format;
30
-
31
-    /**
32
-     * @var string $time_format
33
-     */
34
-    protected $time_format;
35
-
36
-    /**
37
-     * @var boolean $event_is_expired
38
-     */
39
-    protected $event_is_expired;
40
-
41
-
42
-    /**
43
-     * TicketDetails constructor.
44
-     *
45
-     * @param \EE_Ticket                 $ticket
46
-     * @param \EE_Ticket_Selector_Config $template_settings
47
-     * @param array                      $template_args
48
-     */
49
-    public function __construct(
50
-        \EE_Ticket $ticket,
51
-        \EE_Ticket_Selector_Config $template_settings,
52
-        array $template_args
53
-    ) {
54
-        $this->ticket = $ticket;
55
-        $this->template_settings = $template_settings;
56
-        $this->date_format = $template_args['date_format'];
57
-        $this->time_format = $template_args['time_format'];
58
-        $this->event_is_expired = $template_args['event_is_expired'];
59
-    }
60
-
61
-
62
-    /**
63
-     * @return \EE_Ticket
64
-     */
65
-    public function getTicket()
66
-    {
67
-        return $this->ticket;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return bool
73
-     */
74
-    public function showTicketDetails()
75
-    {
76
-        return $this->template_settings->show_ticket_details;
77
-    }
78
-
79
-
80
-    /**
81
-     * @return \EE_Ticket_Selector_Config
82
-     */
83
-    public function getTemplateSettings()
84
-    {
85
-        return $this->template_settings;
86
-    }
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public function getDateFormat()
93
-    {
94
-        return $this->date_format;
95
-    }
96
-
97
-
98
-    /**
99
-     * @return string
100
-     */
101
-    public function getTimeFormat()
102
-    {
103
-        return $this->time_format;
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function getShowHideLinks()
111
-    {
112
-        if (! $this->showTicketDetails()) {
113
-            return '';
114
-        }
115
-        return \EEH_HTML::link(
116
-            '',
117
-            sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'),
118
-            esc_attr(
119
-                apply_filters(
120
-                    'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
121
-                    esc_html__('click to show additional ticket details', 'event_espresso')
122
-                )
123
-            ),
124
-            "display-{$this->cssId()}",
125
-            'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
126
-            '',
127
-            'rel="' . $this->cssId() . '"'
128
-        ) . \EEH_HTML::link(
129
-            '',
130
-            sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'),
131
-            esc_attr(
132
-                apply_filters(
133
-                    'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
134
-                    esc_html__('click to hide additional ticket details', 'event_espresso')
135
-                )
136
-            ),
137
-            "hide-{$this->cssId()}",
138
-            'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
139
-            'display:none;',
140
-            'rel="' . $this->cssId() . '"'
141
-        );
142
-    }
143
-
144
-
145
-    /**
146
-     * @return string
147
-     */
148
-    public function cssId()
149
-    {
150
-        return apply_filters(
151
-            'FHEE__ticket_selector_chart_template__ticket_details_css_id',
152
-            "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
153
-        );
154
-    }
155
-
156
-
157
-    /**
158
-     * @param float $ticket_price
159
-     * @param int   $remaining
160
-     * @param int   $cols
161
-     * @return string
162
-     */
163
-    public function display(
164
-        $ticket_price = 0.00,
165
-        $remaining,
166
-        $cols = 2
167
-    ) {
168
-        $template_args = array();
169
-        $template_args['ticket'] = $this->ticket;
170
-        $template_args['ticket_price'] = $ticket_price;
171
-        $template_args['remaining'] = $remaining;
172
-        $template_args['cols'] = $cols;
173
-        $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details;
174
-        $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
175
-        $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
176
-        $template_args['ticket_details_css_id'] = $this->cssId();
177
-        $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters(
178
-            'FHEE__ticket_selector_chart_template__display_ticket_price_details',
179
-            true
180
-        );
181
-        $template_args['price_breakdown_heading'] = apply_filters(
182
-            'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
183
-            esc_html__('Price', 'event_espresso')
184
-        );
185
-        $template_args['date_format'] = $this->date_format;
186
-        $template_args['time_format'] = $this->time_format;
187
-        $template_args['event_is_expired'] = $this->event_is_expired;
188
-
189
-        return \EEH_Template::locate_template(
190
-            apply_filters(
191
-                'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
192
-                TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
193
-                $this->ticket
194
-            ),
195
-            $template_args
196
-        );
197
-    }
16
+	/**
17
+	 * @var \EE_Ticket $ticket
18
+	 */
19
+	protected $ticket;
20
+
21
+	/**
22
+	 * @var \EE_Ticket_Selector_Config $template_settings
23
+	 */
24
+	protected $template_settings;
25
+
26
+	/**
27
+	 * @var string $date_format
28
+	 */
29
+	protected $date_format;
30
+
31
+	/**
32
+	 * @var string $time_format
33
+	 */
34
+	protected $time_format;
35
+
36
+	/**
37
+	 * @var boolean $event_is_expired
38
+	 */
39
+	protected $event_is_expired;
40
+
41
+
42
+	/**
43
+	 * TicketDetails constructor.
44
+	 *
45
+	 * @param \EE_Ticket                 $ticket
46
+	 * @param \EE_Ticket_Selector_Config $template_settings
47
+	 * @param array                      $template_args
48
+	 */
49
+	public function __construct(
50
+		\EE_Ticket $ticket,
51
+		\EE_Ticket_Selector_Config $template_settings,
52
+		array $template_args
53
+	) {
54
+		$this->ticket = $ticket;
55
+		$this->template_settings = $template_settings;
56
+		$this->date_format = $template_args['date_format'];
57
+		$this->time_format = $template_args['time_format'];
58
+		$this->event_is_expired = $template_args['event_is_expired'];
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return \EE_Ticket
64
+	 */
65
+	public function getTicket()
66
+	{
67
+		return $this->ticket;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return bool
73
+	 */
74
+	public function showTicketDetails()
75
+	{
76
+		return $this->template_settings->show_ticket_details;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @return \EE_Ticket_Selector_Config
82
+	 */
83
+	public function getTemplateSettings()
84
+	{
85
+		return $this->template_settings;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public function getDateFormat()
93
+	{
94
+		return $this->date_format;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return string
100
+	 */
101
+	public function getTimeFormat()
102
+	{
103
+		return $this->time_format;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function getShowHideLinks()
111
+	{
112
+		if (! $this->showTicketDetails()) {
113
+			return '';
114
+		}
115
+		return \EEH_HTML::link(
116
+			'',
117
+			sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'),
118
+			esc_attr(
119
+				apply_filters(
120
+					'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
121
+					esc_html__('click to show additional ticket details', 'event_espresso')
122
+				)
123
+			),
124
+			"display-{$this->cssId()}",
125
+			'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
126
+			'',
127
+			'rel="' . $this->cssId() . '"'
128
+		) . \EEH_HTML::link(
129
+			'',
130
+			sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'),
131
+			esc_attr(
132
+				apply_filters(
133
+					'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
134
+					esc_html__('click to hide additional ticket details', 'event_espresso')
135
+				)
136
+			),
137
+			"hide-{$this->cssId()}",
138
+			'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
139
+			'display:none;',
140
+			'rel="' . $this->cssId() . '"'
141
+		);
142
+	}
143
+
144
+
145
+	/**
146
+	 * @return string
147
+	 */
148
+	public function cssId()
149
+	{
150
+		return apply_filters(
151
+			'FHEE__ticket_selector_chart_template__ticket_details_css_id',
152
+			"tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
153
+		);
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param float $ticket_price
159
+	 * @param int   $remaining
160
+	 * @param int   $cols
161
+	 * @return string
162
+	 */
163
+	public function display(
164
+		$ticket_price = 0.00,
165
+		$remaining,
166
+		$cols = 2
167
+	) {
168
+		$template_args = array();
169
+		$template_args['ticket'] = $this->ticket;
170
+		$template_args['ticket_price'] = $ticket_price;
171
+		$template_args['remaining'] = $remaining;
172
+		$template_args['cols'] = $cols;
173
+		$template_args['show_ticket_details'] = $this->template_settings->show_ticket_details;
174
+		$template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
175
+		$template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
176
+		$template_args['ticket_details_css_id'] = $this->cssId();
177
+		$template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters(
178
+			'FHEE__ticket_selector_chart_template__display_ticket_price_details',
179
+			true
180
+		);
181
+		$template_args['price_breakdown_heading'] = apply_filters(
182
+			'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
183
+			esc_html__('Price', 'event_espresso')
184
+		);
185
+		$template_args['date_format'] = $this->date_format;
186
+		$template_args['time_format'] = $this->time_format;
187
+		$template_args['event_is_expired'] = $this->event_is_expired;
188
+
189
+		return \EEH_Template::locate_template(
190
+			apply_filters(
191
+				'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
192
+				TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
193
+				$this->ticket
194
+			),
195
+			$template_args
196
+		);
197
+	}
198 198
 }
Please login to merge, or discard this patch.
registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -20,198 +20,198 @@
 block discarded – undo
20 20
  */
21 21
 class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper
22 22
 {
23
-    /**
24
-     *
25
-     * @var EE_Registration
26
-     */
27
-    protected $_registration = null;
23
+	/**
24
+	 *
25
+	 * @var EE_Registration
26
+	 */
27
+	protected $_registration = null;
28 28
 
29 29
 
30
-    /**
31
-     *
32
-     * @param EE_Registration $reg
33
-     * @param array           $options
34
-     * @throws EE_Error
35
-     * @throws ReflectionException
36
-     */
37
-    public function __construct(EE_Registration $reg, $options = array())
38
-    {
39
-        $this->_registration = $reg;
40
-        if (! isset($options['layout_strategy'])) {
41
-            $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
42
-        }
43
-        if (! isset($options['html_id'])) {
44
-            $options['html_id'] = 'reg-admin-attendee-questions-frm';
45
-        }
46
-        $this->build_form_from_registration();
47
-        parent::__construct($options);
48
-    }
30
+	/**
31
+	 *
32
+	 * @param EE_Registration $reg
33
+	 * @param array           $options
34
+	 * @throws EE_Error
35
+	 * @throws ReflectionException
36
+	 */
37
+	public function __construct(EE_Registration $reg, $options = array())
38
+	{
39
+		$this->_registration = $reg;
40
+		if (! isset($options['layout_strategy'])) {
41
+			$options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
42
+		}
43
+		if (! isset($options['html_id'])) {
44
+			$options['html_id'] = 'reg-admin-attendee-questions-frm';
45
+		}
46
+		$this->build_form_from_registration();
47
+		parent::__construct($options);
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Gets the registration object this form is about
53
-     * @return EE_Registration
54
-     */
55
-    public function get_registration()
56
-    {
57
-        return $this->_registration;
58
-    }
51
+	/**
52
+	 * Gets the registration object this form is about
53
+	 * @return EE_Registration
54
+	 */
55
+	public function get_registration()
56
+	{
57
+		return $this->_registration;
58
+	}
59 59
 
60
-    /**
61
-     * @since 4.10.0.p
62
-     * @throws EE_Error
63
-     * @throws InvalidArgumentException
64
-     * @throws ReflectionException
65
-     * @throws InvalidDataTypeException
66
-     * @throws InvalidInterfaceException
67
-     */
68
-    public function build_form_from_registration()
69
-    {
70
-        $reg = $this->get_registration();
71
-        if (! $reg instanceof EE_Registration) {
72
-            throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
73
-        }
74
-        // we want to get all their question groups
75
-        $question_groups = EEM_Question_Group::instance()->get_all(
76
-            [
77
-                [
78
-                    'Event_Question_Group.EVT_ID' => $reg->event_ID(),
79
-                    'OR' => [
80
-                        'Question.QST_system*blank' =>  '',
81
-                        'Question.QST_system*null' => ['IS_NULL']
82
-                    ],
83
-                    'Event_Question_Group.'
84
-                    . EEM_Event_Question_Group::instance()->fieldNameForContext(
85
-                        $reg->is_primary_registrant()
86
-                    ) => true
87
-                ],
88
-                'order_by' => ['QSG_order' => 'ASC']
89
-            ]
90
-        );
91
-        // get each question groups questions
92
-        foreach ($question_groups as $question_group) {
93
-            if ($question_group instanceof EE_Question_Group) {
94
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
95
-                    $question_group,
96
-                    $reg
97
-                );
98
-            }
99
-        }
100
-    }
60
+	/**
61
+	 * @since 4.10.0.p
62
+	 * @throws EE_Error
63
+	 * @throws InvalidArgumentException
64
+	 * @throws ReflectionException
65
+	 * @throws InvalidDataTypeException
66
+	 * @throws InvalidInterfaceException
67
+	 */
68
+	public function build_form_from_registration()
69
+	{
70
+		$reg = $this->get_registration();
71
+		if (! $reg instanceof EE_Registration) {
72
+			throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
73
+		}
74
+		// we want to get all their question groups
75
+		$question_groups = EEM_Question_Group::instance()->get_all(
76
+			[
77
+				[
78
+					'Event_Question_Group.EVT_ID' => $reg->event_ID(),
79
+					'OR' => [
80
+						'Question.QST_system*blank' =>  '',
81
+						'Question.QST_system*null' => ['IS_NULL']
82
+					],
83
+					'Event_Question_Group.'
84
+					. EEM_Event_Question_Group::instance()->fieldNameForContext(
85
+						$reg->is_primary_registrant()
86
+					) => true
87
+				],
88
+				'order_by' => ['QSG_order' => 'ASC']
89
+			]
90
+		);
91
+		// get each question groups questions
92
+		foreach ($question_groups as $question_group) {
93
+			if ($question_group instanceof EE_Question_Group) {
94
+				$this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
95
+					$question_group,
96
+					$reg
97
+				);
98
+			}
99
+		}
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     *
105
-     * @param EE_Question_Group $question_group
106
-     * @param EE_Registration   $registration
107
-     * @return EE_Form_Section_Proper
108
-     * @throws EE_Error
109
-     * @throws ReflectionException
110
-     */
111
-    public function build_subform_from_question_group($question_group, $registration)
112
-    {
113
-        if (
114
-            ! $question_group instanceof EE_Question_Group ||
115
-            ! $registration instanceof EE_Registration
116
-        ) {
117
-            throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
118
-        }
119
-        $parts_of_subsection = array(
120
-            'title' => new EE_Form_Section_HTML(
121
-                EEH_HTML::h5(
122
-                    $question_group->name(),
123
-                    $question_group->identifier(),
124
-                    'espresso-question-group-title-h5 section-title'
125
-                )
126
-            )
127
-        );
128
-        $questions = $question_group->questions(
129
-            array(
130
-                array(
131
-                    'OR' => array(
132
-                        'QST_system*blank' => '',
133
-                        'QST_system*null' => array( 'IS_NULL' )
134
-                    )
135
-                )
136
-            )
137
-        );
138
-        foreach ($questions as $question) {
139
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
140
-        }
141
-        if (
142
-            EE_Registry::instance()->CAP->current_user_can(
143
-                'ee_edit_registration',
144
-                'edit-reg-questions-mbox',
145
-                $this->_registration->ID()
146
-            )
147
-        ) {
148
-            $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
149
-                EEH_HTML::table(
150
-                    EEH_HTML::tr(
151
-                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
103
+	/**
104
+	 *
105
+	 * @param EE_Question_Group $question_group
106
+	 * @param EE_Registration   $registration
107
+	 * @return EE_Form_Section_Proper
108
+	 * @throws EE_Error
109
+	 * @throws ReflectionException
110
+	 */
111
+	public function build_subform_from_question_group($question_group, $registration)
112
+	{
113
+		if (
114
+			! $question_group instanceof EE_Question_Group ||
115
+			! $registration instanceof EE_Registration
116
+		) {
117
+			throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
118
+		}
119
+		$parts_of_subsection = array(
120
+			'title' => new EE_Form_Section_HTML(
121
+				EEH_HTML::h5(
122
+					$question_group->name(),
123
+					$question_group->identifier(),
124
+					'espresso-question-group-title-h5 section-title'
125
+				)
126
+			)
127
+		);
128
+		$questions = $question_group->questions(
129
+			array(
130
+				array(
131
+					'OR' => array(
132
+						'QST_system*blank' => '',
133
+						'QST_system*null' => array( 'IS_NULL' )
134
+					)
135
+				)
136
+			)
137
+		);
138
+		foreach ($questions as $question) {
139
+			$parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
140
+		}
141
+		if (
142
+			EE_Registry::instance()->CAP->current_user_can(
143
+				'ee_edit_registration',
144
+				'edit-reg-questions-mbox',
145
+				$this->_registration->ID()
146
+			)
147
+		) {
148
+			$parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
149
+				EEH_HTML::table(
150
+					EEH_HTML::tr(
151
+						'<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
152 152
 		  			<span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span>
153 153
 		  			<div class="dashicons dashicons-edit"></div>
154 154
 		  		</a></td>'
155
-                    ) .
156
-                    EEH_HTML::no_row()
157
-                )
158
-            );
159
-        }
160
-        return new EE_Form_Section_Proper(
161
-            array(
162
-                'subsections' => $parts_of_subsection,
163
-                'html_class' => 'question-group-questions',
164
-            )
165
-        );
166
-    }
155
+					) .
156
+					EEH_HTML::no_row()
157
+				)
158
+			);
159
+		}
160
+		return new EE_Form_Section_Proper(
161
+			array(
162
+				'subsections' => $parts_of_subsection,
163
+				'html_class' => 'question-group-questions',
164
+			)
165
+		);
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * Overrides parent so if inputs were disabled, we leave those with their defaults
171
-     * from the answers in the DB
172
-     *
173
-     * @param array $req_data like $_POST
174
-     * @return void
175
-     * @throws EE_Error
176
-     */
177
-    protected function _normalize($req_data)
178
-    {
179
-        $this->_received_submission = true;
180
-        $this->_validation_errors = array();
181
-        foreach ($this->get_validatable_subsections() as $subsection) {
182
-            if ($subsection->form_data_present_in($req_data)) {
183
-                try {
184
-                    $subsection->_normalize($req_data);
185
-                } catch (EE_Validation_Error $e) {
186
-                    $subsection->add_validation_error($e);
187
-                }
188
-            }
189
-        }
190
-    }
169
+	/**
170
+	 * Overrides parent so if inputs were disabled, we leave those with their defaults
171
+	 * from the answers in the DB
172
+	 *
173
+	 * @param array $req_data like $_POST
174
+	 * @return void
175
+	 * @throws EE_Error
176
+	 */
177
+	protected function _normalize($req_data)
178
+	{
179
+		$this->_received_submission = true;
180
+		$this->_validation_errors = array();
181
+		foreach ($this->get_validatable_subsections() as $subsection) {
182
+			if ($subsection->form_data_present_in($req_data)) {
183
+				try {
184
+					$subsection->_normalize($req_data);
185
+				} catch (EE_Validation_Error $e) {
186
+					$subsection->add_validation_error($e);
187
+				}
188
+			}
189
+		}
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * Performs validation on this form section and its subsections. For each subsection,
195
-     * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls
196
-     * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple)
197
-     * you would be best to override this _validate method, calling parent::_validate() first.
198
-     *
199
-     * @throws EE_Error
200
-     */
201
-    protected function _validate()
202
-    {
203
-        /** @var RequestInterface $request */
204
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
205
-        $form_data = $request->requestParams();
206
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
207
-            if ($subsection->form_data_present_in($form_data)) {
208
-                if (method_exists($this, '_validate_' . $subsection_name)) {
209
-                    call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection));
210
-                }
211
-                $subsection->_validate();
212
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
213
-                $subsection->_received_submission = true;
214
-            }
215
-        }
216
-    }
193
+	/**
194
+	 * Performs validation on this form section and its subsections. For each subsection,
195
+	 * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls
196
+	 * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple)
197
+	 * you would be best to override this _validate method, calling parent::_validate() first.
198
+	 *
199
+	 * @throws EE_Error
200
+	 */
201
+	protected function _validate()
202
+	{
203
+		/** @var RequestInterface $request */
204
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
205
+		$form_data = $request->requestParams();
206
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
207
+			if ($subsection->form_data_present_in($form_data)) {
208
+				if (method_exists($this, '_validate_' . $subsection_name)) {
209
+					call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection));
210
+				}
211
+				$subsection->_validate();
212
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
213
+				$subsection->_received_submission = true;
214
+			}
215
+		}
216
+	}
217 217
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
     public function __construct(EE_Registration $reg, $options = array())
38 38
     {
39 39
         $this->_registration = $reg;
40
-        if (! isset($options['layout_strategy'])) {
40
+        if ( ! isset($options['layout_strategy'])) {
41 41
             $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
42 42
         }
43
-        if (! isset($options['html_id'])) {
43
+        if ( ! isset($options['html_id'])) {
44 44
             $options['html_id'] = 'reg-admin-attendee-questions-frm';
45 45
         }
46 46
         $this->build_form_from_registration();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function build_form_from_registration()
69 69
     {
70 70
         $reg = $this->get_registration();
71
-        if (! $reg instanceof EE_Registration) {
71
+        if ( ! $reg instanceof EE_Registration) {
72 72
             throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
73 73
         }
74 74
         // we want to get all their question groups
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         // get each question groups questions
92 92
         foreach ($question_groups as $question_group) {
93 93
             if ($question_group instanceof EE_Question_Group) {
94
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
94
+                $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group(
95 95
                     $question_group,
96 96
                     $reg
97 97
                 );
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
                 array(
131 131
                     'OR' => array(
132 132
                         'QST_system*blank' => '',
133
-                        'QST_system*null' => array( 'IS_NULL' )
133
+                        'QST_system*null' => array('IS_NULL')
134 134
                     )
135 135
                 )
136 136
             )
137 137
         );
138 138
         foreach ($questions as $question) {
139
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
139
+            $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration);
140 140
         }
141 141
         if (
142 142
             EE_Registry::instance()->CAP->current_user_can(
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
149 149
                 EEH_HTML::table(
150 150
                     EEH_HTML::tr(
151
-                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
152
-		  			<span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span>
151
+                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'">
152
+		  			<span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso').'</span>
153 153
 		  			<div class="dashicons dashicons-edit"></div>
154 154
 		  		</a></td>'
155
-                    ) .
155
+                    ).
156 156
                     EEH_HTML::no_row()
157 157
                 )
158 158
             );
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
         $form_data = $request->requestParams();
206 206
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
207 207
             if ($subsection->form_data_present_in($form_data)) {
208
-                if (method_exists($this, '_validate_' . $subsection_name)) {
209
-                    call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection));
208
+                if (method_exists($this, '_validate_'.$subsection_name)) {
209
+                    call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
210 210
                 }
211 211
                 $subsection->_validate();
212 212
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_PMT_Paypal_Standard.pm.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __construct($pm_instance = null)
31 31
     {
32
-        require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php');
32
+        require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php');
33 33
         $this->_gateway             = new EEG_Paypal_Standard();
34 34
         $this->_pretty_name         = esc_html__("PayPal Standard", 'event_espresso');
35 35
         $this->_default_description = sprintf(
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
             '</strong>'
42 42
         );
43 43
         parent::__construct($pm_instance);
44
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png';
44
+        $this->_default_button_url = $this->file_url().'lib/paypal-logo.png';
45 45
     }
46 46
 
47 47
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function generate_new_settings_form()
67 67
     {
68
-        require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
68
+        require_once($this->file_folder().'EE_Paypal_Standard_Form.form.php');
69 69
         $form = new EE_Paypal_Standard_Form($this);
70 70
         $form->get_input('PMD_debug_mode')->set_html_label_text(
71 71
             sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -15,105 +15,105 @@
 block discarded – undo
15 15
  */
16 16
 class EE_PMT_Paypal_Standard extends EE_PMT_Base
17 17
 {
18
-    const shipping_info_none     = 1;
18
+	const shipping_info_none     = 1;
19 19
 
20
-    const shipping_info_optional = 0;
20
+	const shipping_info_optional = 0;
21 21
 
22
-    const shipping_info_required = 2;
22
+	const shipping_info_required = 2;
23 23
 
24 24
 
25
-    /**
26
-     * @param null $pm_instance
27
-     * @throws EE_Error
28
-     */
29
-    public function __construct($pm_instance = null)
30
-    {
31
-        require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php');
32
-        $this->_gateway             = new EEG_Paypal_Standard();
33
-        $this->_pretty_name         = esc_html__("PayPal Standard", 'event_espresso');
34
-        $this->_default_description = sprintf(
35
-            esc_html__(
36
-                'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s',
37
-                'event_espresso'
38
-            ),
39
-            '<strong>',
40
-            '</strong>'
41
-        );
42
-        parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png';
44
-    }
25
+	/**
26
+	 * @param null $pm_instance
27
+	 * @throws EE_Error
28
+	 */
29
+	public function __construct($pm_instance = null)
30
+	{
31
+		require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php');
32
+		$this->_gateway             = new EEG_Paypal_Standard();
33
+		$this->_pretty_name         = esc_html__("PayPal Standard", 'event_espresso');
34
+		$this->_default_description = sprintf(
35
+			esc_html__(
36
+				'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s',
37
+				'event_espresso'
38
+			),
39
+			'<strong>',
40
+			'</strong>'
41
+		);
42
+		parent::__construct($pm_instance);
43
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png';
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Creates the billing form for this payment method type
49
-     *
50
-     * @param EE_Transaction $transaction
51
-     * @return NULL
52
-     */
53
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
54
-    {
55
-        return null;
56
-    }
47
+	/**
48
+	 * Creates the billing form for this payment method type
49
+	 *
50
+	 * @param EE_Transaction $transaction
51
+	 * @return NULL
52
+	 */
53
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
54
+	{
55
+		return null;
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * Gets the form for all the settings related to this payment method type
61
-     *
62
-     * @return EE_Payment_Method_Form
63
-     * @throws EE_Error
64
-     */
65
-    public function generate_new_settings_form()
66
-    {
67
-        require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
68
-        $form = new EE_Paypal_Standard_Form($this);
69
-        $form->get_input('PMD_debug_mode')->set_html_label_text(
70
-            sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
71
-        );
72
-        $form->get_input('shipping_details')->set_html_label_text(
73
-            sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link())
74
-        );
75
-        return $form;
76
-    }
59
+	/**
60
+	 * Gets the form for all the settings related to this payment method type
61
+	 *
62
+	 * @return EE_Payment_Method_Form
63
+	 * @throws EE_Error
64
+	 */
65
+	public function generate_new_settings_form()
66
+	{
67
+		require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
68
+		$form = new EE_Paypal_Standard_Form($this);
69
+		$form->get_input('PMD_debug_mode')->set_html_label_text(
70
+			sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
71
+		);
72
+		$form->get_input('shipping_details')->set_html_label_text(
73
+			sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link())
74
+		);
75
+		return $form;
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * Adds the help tab
81
-     *
82
-     * @return array
83
-     * @see EE_PMT_Base::help_tabs_config()
84
-     */
85
-    public function help_tabs_config()
86
-    {
87
-        return [
88
-            $this->get_help_tab_name() => [
89
-                'title'    => esc_html__("PayPal Standard Settings", 'event_espresso'),
90
-                'filename' => 'payment_methods_overview_paypalstandard',
91
-            ],
92
-        ];
93
-    }
79
+	/**
80
+	 * Adds the help tab
81
+	 *
82
+	 * @return array
83
+	 * @see EE_PMT_Base::help_tabs_config()
84
+	 */
85
+	public function help_tabs_config()
86
+	{
87
+		return [
88
+			$this->get_help_tab_name() => [
89
+				'title'    => esc_html__("PayPal Standard Settings", 'event_espresso'),
90
+				'filename' => 'payment_methods_overview_paypalstandard',
91
+			],
92
+		];
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * Logic to be accomplished when the payment attempt is complete.
98
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
99
-     * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from
100
-     * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
101
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
102
-     *
103
-     * @param EE_Transaction $transaction
104
-     * @return EE_Payment
105
-     * @throws EE_Error
106
-     */
107
-    public function finalize_payment_for($transaction)
108
-    {
109
-        /** @var RequestInterface $request */
110
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
111
-        // PayPal standard actually sends the IPN info along with the user when they return to our site
112
-        // so in case the IPN is arriving later, let's try to process an IPN!
113
-        if ($request->getServerParam('REQUEST_METHOD') === 'POST') {
114
-            return $this->handle_ipn($request->postParams(), $transaction);
115
-        } else {
116
-            return parent::finalize_payment_for($transaction);
117
-        }
118
-    }
96
+	/**
97
+	 * Logic to be accomplished when the payment attempt is complete.
98
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
99
+	 * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from
100
+	 * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
101
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
102
+	 *
103
+	 * @param EE_Transaction $transaction
104
+	 * @return EE_Payment
105
+	 * @throws EE_Error
106
+	 */
107
+	public function finalize_payment_for($transaction)
108
+	{
109
+		/** @var RequestInterface $request */
110
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
111
+		// PayPal standard actually sends the IPN info along with the user when they return to our site
112
+		// so in case the IPN is arriving later, let's try to process an IPN!
113
+		if ($request->getServerParam('REQUEST_METHOD') === 'POST') {
114
+			return $this->handle_ipn($request->postParams(), $transaction);
115
+		} else {
116
+			return parent::finalize_payment_for($transaction);
117
+		}
118
+	}
119 119
 }
Please login to merge, or discard this patch.
modules/invalid_checkout_access/InvalidCheckoutAccess.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,14 +59,14 @@
 block discarded – undo
59 59
                 $ee_bot_checkout = array();
60 60
                 add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
61 61
             }
62
-            if (! isset($ee_bot_checkout[ $ip_address ])) {
63
-                $ee_bot_checkout[ $ip_address ] = array();
62
+            if ( ! isset($ee_bot_checkout[$ip_address])) {
63
+                $ee_bot_checkout[$ip_address] = array();
64 64
             }
65 65
             $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0));
66
-            if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) {
67
-                $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
66
+            if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) {
67
+                $ee_bot_checkout[$ip_address][$http_referer] = 0;
68 68
             }
69
-            $ee_bot_checkout[ $ip_address ][ $http_referer ]++;
69
+            $ee_bot_checkout[$ip_address][$http_referer]++;
70 70
             update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
71 71
             if (WP_DEBUG) {
72 72
                 EE_Error::add_error(
Please login to merge, or discard this patch.
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -26,181 +26,181 @@
 block discarded – undo
26 26
  */
27 27
 class InvalidCheckoutAccess
28 28
 {
29
-    /**
30
-     * key used for saving invalid checkout access data to the wp_options table
31
-     */
32
-    const OPTION_KEY = 'ee_invalid_checkout_access';
29
+	/**
30
+	 * key used for saving invalid checkout access data to the wp_options table
31
+	 */
32
+	const OPTION_KEY = 'ee_invalid_checkout_access';
33 33
 
34 34
 
35
-    /**
36
-     * _block_bots
37
-     * checks that the incoming request has either of the following set:
38
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
39
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
40
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
41
-     * then where you coming from man?
42
-     *
43
-     * @param EE_Checkout $checkout
44
-     * @return bool true if access to registration checkout appears to be invalid
45
-     */
46
-    public function checkoutAccessIsInvalid(EE_Checkout $checkout)
47
-    {
48
-        if (
49
-            ! ($checkout->uts || $checkout->reg_url_link)
50
-            && ! (defined('DOING_AJAX') && DOING_AJAX)
51
-            && EE_Config::instance()->registration->track_invalid_checkout_access()
52
-        ) {
53
-            /** @var RequestInterface $request */
54
-            $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
55
-            $ip_address = $request->ipAddress();
56
-            $ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY);
57
-            if ($ee_bot_checkout === false) {
58
-                $ee_bot_checkout = array();
59
-                add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
60
-            }
61
-            if (! isset($ee_bot_checkout[ $ip_address ])) {
62
-                $ee_bot_checkout[ $ip_address ] = array();
63
-            }
64
-            $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0));
65
-            if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) {
66
-                $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
67
-            }
68
-            $ee_bot_checkout[ $ip_address ][ $http_referer ]++;
69
-            update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
70
-            if (WP_DEBUG) {
71
-                EE_Error::add_error(
72
-                    esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
73
-                    __FILE__,
74
-                    __FUNCTION__,
75
-                    __LINE__
76
-                );
77
-            }
78
-            return true;
79
-        }
80
-        return false;
81
-    }
35
+	/**
36
+	 * _block_bots
37
+	 * checks that the incoming request has either of the following set:
38
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
39
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
40
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
41
+	 * then where you coming from man?
42
+	 *
43
+	 * @param EE_Checkout $checkout
44
+	 * @return bool true if access to registration checkout appears to be invalid
45
+	 */
46
+	public function checkoutAccessIsInvalid(EE_Checkout $checkout)
47
+	{
48
+		if (
49
+			! ($checkout->uts || $checkout->reg_url_link)
50
+			&& ! (defined('DOING_AJAX') && DOING_AJAX)
51
+			&& EE_Config::instance()->registration->track_invalid_checkout_access()
52
+		) {
53
+			/** @var RequestInterface $request */
54
+			$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
55
+			$ip_address = $request->ipAddress();
56
+			$ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY);
57
+			if ($ee_bot_checkout === false) {
58
+				$ee_bot_checkout = array();
59
+				add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
60
+			}
61
+			if (! isset($ee_bot_checkout[ $ip_address ])) {
62
+				$ee_bot_checkout[ $ip_address ] = array();
63
+			}
64
+			$http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0));
65
+			if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) {
66
+				$ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
67
+			}
68
+			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
69
+			update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
70
+			if (WP_DEBUG) {
71
+				EE_Error::add_error(
72
+					esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
73
+					__FILE__,
74
+					__FUNCTION__,
75
+					__LINE__
76
+				);
77
+			}
78
+			return true;
79
+		}
80
+		return false;
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * _invalid_checkout_access_form
86
-     *
87
-     * @return EE_Form_Section_Proper
88
-     * @throws EE_Error
89
-     */
90
-    public function getForm()
91
-    {
92
-        return new EE_Form_Section_Proper(
93
-            array(
94
-                'name'            => 'invalid_checkout_access',
95
-                'html_id'         => 'invalid_checkout_access',
96
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
97
-                'subsections'     => array(
98
-                    'invalid_checkout_access_hdr'   => new EE_Form_Section_HTML(
99
-                        EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso'))
100
-                    ),
101
-                    'ee_bot_checkout_data'          => new EE_Text_Area_Input(
102
-                        array(
103
-                            'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'),
104
-                            'default'         => var_export(
105
-                                get_option(InvalidCheckoutAccess::OPTION_KEY, array()),
106
-                                true
107
-                            ),
108
-                            'required'        => false,
109
-                            'html_help_text'  => esc_html__(
110
-                                'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.',
111
-                                'event_espresso'
112
-                            ),
113
-                        )
114
-                    ),
115
-                    'track_invalid_checkout_access' => new EE_Yes_No_Input(
116
-                        array(
117
-                            'html_label_text'         => esc_html__('Track Invalid Checkout Access?', 'event_espresso'),
118
-                            'html_help_text'          => esc_html__(
119
-                                'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.',
120
-                                'event_espresso'
121
-                            ),
122
-                            'default'                 => EE_Config::instance()
123
-                                ->registration
124
-                                ->track_invalid_checkout_access(),
125
-                            'display_html_label_text' => false,
126
-                        )
127
-                    ),
128
-                    'delete_invalid_checkout_data'  => new EE_Yes_No_Input(
129
-                        array(
130
-                            'html_label_text'         => esc_html__('Reset Invalid Checkout Data', 'event_espresso'),
131
-                            'html_help_text'          => esc_html__(
132
-                                'Setting this to "Yes" will delete all existing invalid checkout access data.',
133
-                                'event_espresso'
134
-                            ),
135
-                            'default'                 => false,
136
-                            'display_html_label_text' => false,
137
-                        )
138
-                    ),
139
-                ),
140
-            )
141
-        );
142
-    }
84
+	/**
85
+	 * _invalid_checkout_access_form
86
+	 *
87
+	 * @return EE_Form_Section_Proper
88
+	 * @throws EE_Error
89
+	 */
90
+	public function getForm()
91
+	{
92
+		return new EE_Form_Section_Proper(
93
+			array(
94
+				'name'            => 'invalid_checkout_access',
95
+				'html_id'         => 'invalid_checkout_access',
96
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
97
+				'subsections'     => array(
98
+					'invalid_checkout_access_hdr'   => new EE_Form_Section_HTML(
99
+						EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso'))
100
+					),
101
+					'ee_bot_checkout_data'          => new EE_Text_Area_Input(
102
+						array(
103
+							'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'),
104
+							'default'         => var_export(
105
+								get_option(InvalidCheckoutAccess::OPTION_KEY, array()),
106
+								true
107
+							),
108
+							'required'        => false,
109
+							'html_help_text'  => esc_html__(
110
+								'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.',
111
+								'event_espresso'
112
+							),
113
+						)
114
+					),
115
+					'track_invalid_checkout_access' => new EE_Yes_No_Input(
116
+						array(
117
+							'html_label_text'         => esc_html__('Track Invalid Checkout Access?', 'event_espresso'),
118
+							'html_help_text'          => esc_html__(
119
+								'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.',
120
+								'event_espresso'
121
+							),
122
+							'default'                 => EE_Config::instance()
123
+								->registration
124
+								->track_invalid_checkout_access(),
125
+							'display_html_label_text' => false,
126
+						)
127
+					),
128
+					'delete_invalid_checkout_data'  => new EE_Yes_No_Input(
129
+						array(
130
+							'html_label_text'         => esc_html__('Reset Invalid Checkout Data', 'event_espresso'),
131
+							'html_help_text'          => esc_html__(
132
+								'Setting this to "Yes" will delete all existing invalid checkout access data.',
133
+								'event_espresso'
134
+							),
135
+							'default'                 => false,
136
+							'display_html_label_text' => false,
137
+						)
138
+					),
139
+				),
140
+			)
141
+		);
142
+	}
143 143
 
144 144
 
145
-    /**
146
-     * update_invalid_checkout_access_form
147
-     *
148
-     * @param EE_Registration_Config $EE_Registration_Config
149
-     * @return EE_Registration_Config
150
-     * @throws EE_Error
151
-     * @throws ReflectionException
152
-     */
153
-    public function processForm(EE_Registration_Config $EE_Registration_Config)
154
-    {
155
-        try {
156
-            $invalid_checkout_access_form = $this->getForm();
157
-            // if not displaying a form, then check for form submission
158
-            if ($invalid_checkout_access_form->was_submitted()) {
159
-                // capture form data
160
-                $invalid_checkout_access_form->receive_form_submission();
161
-                // validate form data
162
-                if ($invalid_checkout_access_form->is_valid()) {
163
-                    // grab validated data from form
164
-                    $valid_data = $invalid_checkout_access_form->valid_data();
165
-                    // ensure form inputs we want are set
166
-                    if (
167
-                        isset(
168
-                            $valid_data['track_invalid_checkout_access'],
169
-                            $valid_data['delete_invalid_checkout_data']
170
-                        )
171
-                    ) {
172
-                        $EE_Registration_Config->set_track_invalid_checkout_access(
173
-                            $valid_data['track_invalid_checkout_access']
174
-                        );
175
-                        // if deleting, then update option with empty array
176
-                        if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) {
177
-                            update_option(InvalidCheckoutAccess::OPTION_KEY, array());
178
-                        }
179
-                    } else {
180
-                        EE_Error::add_error(
181
-                            esc_html__(
182
-                                'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.',
183
-                                'event_espresso'
184
-                            ),
185
-                            __FILE__,
186
-                            __FUNCTION__,
187
-                            __LINE__
188
-                        );
189
-                    }
190
-                } else {
191
-                    if ($invalid_checkout_access_form->submission_error_message() !== '') {
192
-                        EE_Error::add_error(
193
-                            $invalid_checkout_access_form->submission_error_message(),
194
-                            __FILE__,
195
-                            __FUNCTION__,
196
-                            __LINE__
197
-                        );
198
-                    }
199
-                }
200
-            }
201
-        } catch (EE_Error $e) {
202
-            $e->get_error();
203
-        }
204
-        return $EE_Registration_Config;
205
-    }
145
+	/**
146
+	 * update_invalid_checkout_access_form
147
+	 *
148
+	 * @param EE_Registration_Config $EE_Registration_Config
149
+	 * @return EE_Registration_Config
150
+	 * @throws EE_Error
151
+	 * @throws ReflectionException
152
+	 */
153
+	public function processForm(EE_Registration_Config $EE_Registration_Config)
154
+	{
155
+		try {
156
+			$invalid_checkout_access_form = $this->getForm();
157
+			// if not displaying a form, then check for form submission
158
+			if ($invalid_checkout_access_form->was_submitted()) {
159
+				// capture form data
160
+				$invalid_checkout_access_form->receive_form_submission();
161
+				// validate form data
162
+				if ($invalid_checkout_access_form->is_valid()) {
163
+					// grab validated data from form
164
+					$valid_data = $invalid_checkout_access_form->valid_data();
165
+					// ensure form inputs we want are set
166
+					if (
167
+						isset(
168
+							$valid_data['track_invalid_checkout_access'],
169
+							$valid_data['delete_invalid_checkout_data']
170
+						)
171
+					) {
172
+						$EE_Registration_Config->set_track_invalid_checkout_access(
173
+							$valid_data['track_invalid_checkout_access']
174
+						);
175
+						// if deleting, then update option with empty array
176
+						if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) {
177
+							update_option(InvalidCheckoutAccess::OPTION_KEY, array());
178
+						}
179
+					} else {
180
+						EE_Error::add_error(
181
+							esc_html__(
182
+								'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.',
183
+								'event_espresso'
184
+							),
185
+							__FILE__,
186
+							__FUNCTION__,
187
+							__LINE__
188
+						);
189
+					}
190
+				} else {
191
+					if ($invalid_checkout_access_form->submission_error_message() !== '') {
192
+						EE_Error::add_error(
193
+							$invalid_checkout_access_form->submission_error_message(),
194
+							__FILE__,
195
+							__FUNCTION__,
196
+							__LINE__
197
+						);
198
+					}
199
+				}
200
+			}
201
+		} catch (EE_Error $e) {
202
+			$e->get_error();
203
+		}
204
+		return $EE_Registration_Config;
205
+	}
206 206
 }
Please login to merge, or discard this patch.
messages/defaults/default/html_receipt_ticket_line_item_no_pms.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 <tr class="item">
9 9
     <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td>
10 10
     <td colspan="2">[LINE_ITEM_DESCRIPTION]
11
-        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p>
11
+        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p>
12 12
     </td>
13 13
     <td class="item_c">[LINE_ITEM_QUANTITY]</td>
14 14
     <td class="item_c">[LINE_ITEM_AMOUNT]</td>
Please login to merge, or discard this patch.
caffeinated/modules/event_single_caff/EED_Event_Single_Caff.module.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
     {
93 93
         wp_register_style(
94 94
             'eed-event-single-sortable',
95
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
95
+            EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css',
96 96
             array(),
97 97
             EVENT_ESPRESSO_VERSION
98 98
         );
99 99
         wp_enqueue_style('eed-event-single-sortable');
100 100
         wp_register_script(
101 101
             'eed-event-single-sortable',
102
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
102
+            EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js',
103 103
             array('jquery-ui-sortable'),
104 104
             EVENT_ESPRESSO_VERSION,
105 105
             true
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public static function setDefinitions()
115 115
     {
116
-        if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
-            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
118
-            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
116
+        if ( ! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
+            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/');
118
+            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
119 119
         }
120 120
     }
121 121
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
         $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
138 138
 
139 139
         $event_single_order_array = array();
140
-        $event_single_order_array[ $config->display_order_tickets ] = 'tickets';
141
-        $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
142
-        $event_single_order_array[ $config->display_order_event ] = 'event';
143
-        $event_single_order_array[ $config->display_order_venue ] = 'venue';
140
+        $event_single_order_array[$config->display_order_tickets] = 'tickets';
141
+        $event_single_order_array[$config->display_order_datetimes] = 'datetimes';
142
+        $event_single_order_array[$config->display_order_event] = 'event';
143
+        $event_single_order_array[$config->display_order_venue] = 'venue';
144 144
         // get template parts
145 145
         $template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
146 146
         // convert to array so that we can add more properties
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             'single-sortable-li single-sortable-js'
152 152
         );
153 153
         EEH_Template::display_template(
154
-            EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
154
+            EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php',
155 155
             $config
156 156
         );
157 157
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public static function update_template_settings(EE_Template_Config $CFG, $REQ)
168 168
     {
169
-        if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
169
+        if ( ! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
170 170
             $CFG->EED_Event_Single = new EE_Event_Single_Config();
171 171
         }
172 172
         $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     {
216 216
         $config_saved = false;
217 217
         $template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements');
218
-        if (! empty($template_parts)) {
218
+        if ( ! empty($template_parts)) {
219 219
             $template_parts = explode(',', trim($template_parts, ','));
220 220
             foreach ($template_parts as $key => $template_part) {
221 221
                 $template_part = "display_order_$template_part";
Please login to merge, or discard this patch.
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -24,228 +24,228 @@
 block discarded – undo
24 24
  */
25 25
 class EED_Event_Single_Caff extends EED_Event_Single
26 26
 {
27
-    /**
28
-     * @return EED_Event_Single_Caff
29
-     */
30
-    public static function instance()
31
-    {
32
-        return parent::get_instance(__CLASS__);
33
-    }
34
-
35
-
36
-    /**
37
-     *    set_hooks - for hooking into EE Core, other modules, etc
38
-     *
39
-     * @access    public
40
-     * @return    void
41
-     */
42
-    public static function set_hooks()
43
-    {
44
-    }
45
-
46
-    /**
47
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
48
-     *
49
-     * @access    public
50
-     * @return    void
51
-     */
52
-    public static function set_hooks_admin()
53
-    {
54
-        self::setDefinitions();
55
-        add_action(
56
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
57
-            array('EED_Event_Single_Caff', 'load_scripts_styles'),
58
-            10
59
-        );
60
-        add_action(
61
-            'AHEE__template_settings__template__before_settings_form',
62
-            array('EED_Event_Single_Caff', 'template_settings_form'),
63
-            10
64
-        );
65
-        add_filter(
66
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
67
-            array('EED_Event_Single_Caff', 'update_template_settings'),
68
-            10,
69
-            2
70
-        );
71
-        // AJAX
72
-        add_action(
73
-            'wp_ajax_espresso_update_event_single_order',
74
-            array('EED_Event_Single_Caff', 'update_event_single_order')
75
-        );
76
-        add_action(
77
-            'wp_ajax_nopriv_espresso_update_event_single_order',
78
-            array('EED_Event_Single_Caff', 'update_event_single_order')
79
-        );
80
-    }
81
-
82
-
83
-    public static function load_scripts_styles()
84
-    {
85
-        add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
86
-    }
87
-
88
-
89
-    public static function enqueue_scripts_styles()
90
-    {
91
-        wp_register_style(
92
-            'eed-event-single-sortable',
93
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
94
-            array(),
95
-            EVENT_ESPRESSO_VERSION
96
-        );
97
-        wp_enqueue_style('eed-event-single-sortable');
98
-        wp_register_script(
99
-            'eed-event-single-sortable',
100
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
101
-            array('jquery-ui-sortable'),
102
-            EVENT_ESPRESSO_VERSION,
103
-            true
104
-        );
105
-        wp_enqueue_script('eed-event-single-sortable');
106
-    }
107
-
108
-
109
-    /**
110
-     * Set constants only if they haven't been set yet.
111
-     */
112
-    public static function setDefinitions()
113
-    {
114
-        if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
115
-            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
116
-            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
117
-        }
118
-    }
119
-
120
-
121
-    /**
122
-     *    template_settings_form
123
-     *
124
-     * @access    public
125
-     * @static
126
-     * @return    void
127
-     */
128
-    public static function template_settings_form()
129
-    {
130
-        $config = EE_Registry::instance()->CFG->template_settings;
131
-        $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config
132
-            ? $config->EED_Event_Single : new EE_Event_Single_Config();
133
-        $config->use_sortable_display_order = isset($config->use_sortable_display_order)
134
-            ? $config->use_sortable_display_order : false;
135
-        $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
136
-
137
-        $event_single_order_array = array();
138
-        $event_single_order_array[ $config->display_order_tickets ] = 'tickets';
139
-        $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
140
-        $event_single_order_array[ $config->display_order_event ] = 'event';
141
-        $event_single_order_array[ $config->display_order_venue ] = 'venue';
142
-        // get template parts
143
-        $template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
144
-        // convert to array so that we can add more properties
145
-        $config = get_object_vars($config);
146
-        $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
147
-            'event-single-sortable-js',
148
-            '',
149
-            'single-sortable-li single-sortable-js'
150
-        );
151
-        EEH_Template::display_template(
152
-            EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
153
-            $config
154
-        );
155
-    }
156
-
157
-
158
-    /**
159
-     * update_template_settings
160
-     *
161
-     * @param EE_Template_Config $CFG
162
-     * @param array              $REQ
163
-     * @return EE_Template_Config
164
-     */
165
-    public static function update_template_settings(EE_Template_Config $CFG, $REQ)
166
-    {
167
-        if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
168
-            $CFG->EED_Event_Single = new EE_Event_Single_Config();
169
-        }
170
-        $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
171
-            ? $CFG->EED_Event_Single->display_order_event
172
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
173
-        $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
174
-            ? $CFG->EED_Event_Single->display_order_datetimes
175
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
176
-        $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
177
-            ? $CFG->EED_Event_Single->display_order_tickets
178
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
179
-        $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
180
-            ? $CFG->EED_Event_Single->display_order_venue
181
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
182
-        $CFG->EED_Event_Single = new EE_Event_Single_Config();
183
-        $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
184
-                                                               && $REQ['display_status_banner_single'];
185
-        $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
186
-        $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
187
-            ? absint($REQ['EED_Events_Single_use_sortable_display_order'])
188
-            : 0;
189
-        $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
190
-            ? $display_order_event
191
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
192
-        $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
193
-            ? $display_order_datetimes
194
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
195
-        $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
196
-            ? $display_order_tickets
197
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
198
-        $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
199
-            ? $display_order_venue
200
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
201
-        do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
202
-        return $CFG;
203
-    }
204
-
205
-
206
-    /**
207
-     * update_event_single_order
208
-     *
209
-     * @access    public
210
-     * @return    void
211
-     */
212
-    public static function update_event_single_order()
213
-    {
214
-        $config_saved = false;
215
-        $template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements');
216
-        if (! empty($template_parts)) {
217
-            $template_parts = explode(',', trim($template_parts, ','));
218
-            foreach ($template_parts as $key => $template_part) {
219
-                $template_part = "display_order_$template_part";
220
-                $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
221
-                EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
222
-                do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
223
-            }
224
-            $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
225
-        }
226
-        if ($config_saved) {
227
-            EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
228
-        } else {
229
-            EE_Error::add_error(
230
-                esc_html__('Display Order was not updated.', 'event_espresso'),
231
-                __FILE__,
232
-                __FUNCTION__,
233
-                __LINE__
234
-            );
235
-        }
236
-        echo wp_json_encode(EE_Error::get_notices(false));
237
-        exit();
238
-    }
239
-
240
-
241
-    /**
242
-     *    run - initial module setup
243
-     *
244
-     * @access    public
245
-     * @param WP $WP
246
-     * @return    void
247
-     */
248
-    public function run($WP)
249
-    {
250
-    }
27
+	/**
28
+	 * @return EED_Event_Single_Caff
29
+	 */
30
+	public static function instance()
31
+	{
32
+		return parent::get_instance(__CLASS__);
33
+	}
34
+
35
+
36
+	/**
37
+	 *    set_hooks - for hooking into EE Core, other modules, etc
38
+	 *
39
+	 * @access    public
40
+	 * @return    void
41
+	 */
42
+	public static function set_hooks()
43
+	{
44
+	}
45
+
46
+	/**
47
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
48
+	 *
49
+	 * @access    public
50
+	 * @return    void
51
+	 */
52
+	public static function set_hooks_admin()
53
+	{
54
+		self::setDefinitions();
55
+		add_action(
56
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
57
+			array('EED_Event_Single_Caff', 'load_scripts_styles'),
58
+			10
59
+		);
60
+		add_action(
61
+			'AHEE__template_settings__template__before_settings_form',
62
+			array('EED_Event_Single_Caff', 'template_settings_form'),
63
+			10
64
+		);
65
+		add_filter(
66
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
67
+			array('EED_Event_Single_Caff', 'update_template_settings'),
68
+			10,
69
+			2
70
+		);
71
+		// AJAX
72
+		add_action(
73
+			'wp_ajax_espresso_update_event_single_order',
74
+			array('EED_Event_Single_Caff', 'update_event_single_order')
75
+		);
76
+		add_action(
77
+			'wp_ajax_nopriv_espresso_update_event_single_order',
78
+			array('EED_Event_Single_Caff', 'update_event_single_order')
79
+		);
80
+	}
81
+
82
+
83
+	public static function load_scripts_styles()
84
+	{
85
+		add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
86
+	}
87
+
88
+
89
+	public static function enqueue_scripts_styles()
90
+	{
91
+		wp_register_style(
92
+			'eed-event-single-sortable',
93
+			EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
94
+			array(),
95
+			EVENT_ESPRESSO_VERSION
96
+		);
97
+		wp_enqueue_style('eed-event-single-sortable');
98
+		wp_register_script(
99
+			'eed-event-single-sortable',
100
+			EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
101
+			array('jquery-ui-sortable'),
102
+			EVENT_ESPRESSO_VERSION,
103
+			true
104
+		);
105
+		wp_enqueue_script('eed-event-single-sortable');
106
+	}
107
+
108
+
109
+	/**
110
+	 * Set constants only if they haven't been set yet.
111
+	 */
112
+	public static function setDefinitions()
113
+	{
114
+		if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
115
+			define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
116
+			define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
117
+		}
118
+	}
119
+
120
+
121
+	/**
122
+	 *    template_settings_form
123
+	 *
124
+	 * @access    public
125
+	 * @static
126
+	 * @return    void
127
+	 */
128
+	public static function template_settings_form()
129
+	{
130
+		$config = EE_Registry::instance()->CFG->template_settings;
131
+		$config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config
132
+			? $config->EED_Event_Single : new EE_Event_Single_Config();
133
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
134
+			? $config->use_sortable_display_order : false;
135
+		$config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
136
+
137
+		$event_single_order_array = array();
138
+		$event_single_order_array[ $config->display_order_tickets ] = 'tickets';
139
+		$event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
140
+		$event_single_order_array[ $config->display_order_event ] = 'event';
141
+		$event_single_order_array[ $config->display_order_venue ] = 'venue';
142
+		// get template parts
143
+		$template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
144
+		// convert to array so that we can add more properties
145
+		$config = get_object_vars($config);
146
+		$config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
147
+			'event-single-sortable-js',
148
+			'',
149
+			'single-sortable-li single-sortable-js'
150
+		);
151
+		EEH_Template::display_template(
152
+			EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
153
+			$config
154
+		);
155
+	}
156
+
157
+
158
+	/**
159
+	 * update_template_settings
160
+	 *
161
+	 * @param EE_Template_Config $CFG
162
+	 * @param array              $REQ
163
+	 * @return EE_Template_Config
164
+	 */
165
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ)
166
+	{
167
+		if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
168
+			$CFG->EED_Event_Single = new EE_Event_Single_Config();
169
+		}
170
+		$display_order_event = $CFG->EED_Event_Single->display_order_event !== null
171
+			? $CFG->EED_Event_Single->display_order_event
172
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
173
+		$display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
174
+			? $CFG->EED_Event_Single->display_order_datetimes
175
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
176
+		$display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
177
+			? $CFG->EED_Event_Single->display_order_tickets
178
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
179
+		$display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
180
+			? $CFG->EED_Event_Single->display_order_venue
181
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
182
+		$CFG->EED_Event_Single = new EE_Event_Single_Config();
183
+		$CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
184
+															   && $REQ['display_status_banner_single'];
185
+		$CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
186
+		$CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
187
+			? absint($REQ['EED_Events_Single_use_sortable_display_order'])
188
+			: 0;
189
+		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
190
+			? $display_order_event
191
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
192
+		$CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
193
+			? $display_order_datetimes
194
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
195
+		$CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
196
+			? $display_order_tickets
197
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
198
+		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
199
+			? $display_order_venue
200
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
201
+		do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
202
+		return $CFG;
203
+	}
204
+
205
+
206
+	/**
207
+	 * update_event_single_order
208
+	 *
209
+	 * @access    public
210
+	 * @return    void
211
+	 */
212
+	public static function update_event_single_order()
213
+	{
214
+		$config_saved = false;
215
+		$template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements');
216
+		if (! empty($template_parts)) {
217
+			$template_parts = explode(',', trim($template_parts, ','));
218
+			foreach ($template_parts as $key => $template_part) {
219
+				$template_part = "display_order_$template_part";
220
+				$priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
221
+				EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
222
+				do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
223
+			}
224
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
225
+		}
226
+		if ($config_saved) {
227
+			EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
228
+		} else {
229
+			EE_Error::add_error(
230
+				esc_html__('Display Order was not updated.', 'event_espresso'),
231
+				__FILE__,
232
+				__FUNCTION__,
233
+				__LINE__
234
+			);
235
+		}
236
+		echo wp_json_encode(EE_Error::get_notices(false));
237
+		exit();
238
+	}
239
+
240
+
241
+	/**
242
+	 *    run - initial module setup
243
+	 *
244
+	 * @access    public
245
+	 * @param WP $WP
246
+	 * @return    void
247
+	 */
248
+	public function run($WP)
249
+	{
250
+	}
251 251
 }
Please login to merge, or discard this patch.
caffeinated/modules/events_archive_caff/EED_Events_Archive_Caff.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public static function setDefinitions()
81 81
     {
82
-        if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
82
+        if ( ! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
83 83
             define(
84 84
                 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH',
85
-                str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/'
85
+                str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates/'
86 86
             );
87
-            define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
+            define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
88 88
         }
89 89
     }
90 90
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             'archive-sortable-li archive-sortable-js'
163 163
         );
164 164
         EEH_Template::display_template(
165
-            EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
165
+            EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php',
166 166
             $config
167 167
         );
168 168
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         $config = EE_Registry::instance()->CFG;
241 241
         $config_saved = false;
242 242
         $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements');
243
-        if (! empty($template_parts)) {
243
+        if ( ! empty($template_parts)) {
244 244
             $template_parts = explode(',', trim($template_parts, ','));
245 245
             foreach ($template_parts as $key => $template_part) {
246 246
                 $template_part = "display_order_$template_part";
Please login to merge, or discard this patch.
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -13,268 +13,268 @@
 block discarded – undo
13 13
  */
14 14
 class EED_Events_Archive_Caff extends EED_Events_Archive
15 15
 {
16
-    /**
17
-     * @return EED_Events_Archive_Caff|EED_Module
18
-     */
19
-    public static function instance()
20
-    {
21
-        return parent::get_instance(__CLASS__);
22
-    }
16
+	/**
17
+	 * @return EED_Events_Archive_Caff|EED_Module
18
+	 */
19
+	public static function instance()
20
+	{
21
+		return parent::get_instance(__CLASS__);
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * set_hooks - for hooking into EE Core, other modules, etc
27
-     *
28
-     * @return    void
29
-     */
30
-    public static function set_hooks()
31
-    {
32
-    }
25
+	/**
26
+	 * set_hooks - for hooking into EE Core, other modules, etc
27
+	 *
28
+	 * @return    void
29
+	 */
30
+	public static function set_hooks()
31
+	{
32
+	}
33 33
 
34
-    /**
35
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
36
-     *
37
-     * @access    public
38
-     * @return    void
39
-     */
40
-    public static function set_hooks_admin()
41
-    {
42
-        self::setDefinitions();
43
-        add_action(
44
-            'AHEE__template_settings__template__before_settings_form',
45
-            array('EED_Events_Archive_Caff', 'template_settings_form'),
46
-            10
47
-        );
48
-        add_filter(
49
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
50
-            array('EED_Events_Archive_Caff', 'update_template_settings'),
51
-            10,
52
-            2
53
-        );
54
-        // AJAX
55
-        add_action(
56
-            'wp_ajax_espresso_update_event_archive_order',
57
-            array('EED_Events_Archive_Caff', 'update_event_archive_order')
58
-        );
59
-        add_action(
60
-            'wp_ajax_nopriv_espresso_update_event_archive_order',
61
-            array('EED_Events_Archive_Caff', 'update_event_archive_order')
62
-        );
63
-    }
34
+	/**
35
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
36
+	 *
37
+	 * @access    public
38
+	 * @return    void
39
+	 */
40
+	public static function set_hooks_admin()
41
+	{
42
+		self::setDefinitions();
43
+		add_action(
44
+			'AHEE__template_settings__template__before_settings_form',
45
+			array('EED_Events_Archive_Caff', 'template_settings_form'),
46
+			10
47
+		);
48
+		add_filter(
49
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
50
+			array('EED_Events_Archive_Caff', 'update_template_settings'),
51
+			10,
52
+			2
53
+		);
54
+		// AJAX
55
+		add_action(
56
+			'wp_ajax_espresso_update_event_archive_order',
57
+			array('EED_Events_Archive_Caff', 'update_event_archive_order')
58
+		);
59
+		add_action(
60
+			'wp_ajax_nopriv_espresso_update_event_archive_order',
61
+			array('EED_Events_Archive_Caff', 'update_event_archive_order')
62
+		);
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * run - initial module setup
68
-     *
69
-     * @param    WP $WP
70
-     * @return    void
71
-     */
72
-    public function run($WP)
73
-    {
74
-    }
66
+	/**
67
+	 * run - initial module setup
68
+	 *
69
+	 * @param    WP $WP
70
+	 * @return    void
71
+	 */
72
+	public function run($WP)
73
+	{
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * Conditionally set constants if they haven't been defined yet.
79
-     */
80
-    public static function setDefinitions()
81
-    {
82
-        if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
83
-            define(
84
-                'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH',
85
-                str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/'
86
-            );
87
-            define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
88
-        }
89
-    }
77
+	/**
78
+	 * Conditionally set constants if they haven't been defined yet.
79
+	 */
80
+	public static function setDefinitions()
81
+	{
82
+		if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) {
83
+			define(
84
+				'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH',
85
+				str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/'
86
+			);
87
+			define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
88
+		}
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * @return void
94
-     * @throws DomainException
95
-     * @throws InvalidArgumentException
96
-     * @throws InvalidDataTypeException
97
-     * @throws InvalidInterfaceException
98
-     */
99
-    public static function template_settings_form()
100
-    {
101
-        /** @var EE_Admin_Page_Loader $admin_page_loader */
102
-        $admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader');
103
-        // grab general settings admin page and remove the existing hook callback
104
-        $gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings');
105
-        if ($gen_set_admin instanceof General_Settings_Admin_Page) {
106
-            remove_action(
107
-                'AHEE__template_settings__template__before_settings_form',
108
-                array($gen_set_admin, 'template_settings_caff_features'),
109
-                100
110
-            );
111
-        }
112
-        // first just grab the template settings
113
-        $config = EE_Registry::instance()->CFG->template_settings;
114
-        // then if the Event Archive config is valid, use that, else create a new one
115
-        $config = $config instanceof EE_Template_Config
116
-                  && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
117
-            ? $config->EED_Events_Archive
118
-            : new EE_Events_Archive_Config();
119
-        $config = apply_filters(
120
-            'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
121
-            $config
122
-        );
123
-        $config->display_status_banner = isset($config->display_status_banner)
124
-            ? $config->display_status_banner
125
-            : 0;
126
-        $config->display_description = isset($config->display_description)
127
-            ? $config->display_description
128
-            : 1;
129
-        $config->display_ticket_selector = isset($config->display_ticket_selector)
130
-            ? $config->display_ticket_selector
131
-            : 0;
132
-        $config->display_datetimes = isset($config->display_datetimes)
133
-            ? $config->display_datetimes
134
-            : 1;
135
-        $config->display_venue = isset($config->display_venue)
136
-            ? $config->display_venue
137
-            : 0;
138
-        $config->display_expired_events = isset($config->display_expired_events)
139
-            ? $config->display_expired_events
140
-            : 0;
141
-        // display order options
142
-        $config->use_sortable_display_order = isset($config->use_sortable_display_order)
143
-            ? $config->use_sortable_display_order
144
-            : false;
145
-        $config->display_order_tickets = isset($config->display_order_tickets)
146
-            ? $config->display_order_tickets
147
-            : 120;
148
-        $config->display_order_datetimes = isset($config->display_order_datetimes)
149
-            ? $config->display_order_datetimes
150
-            : 110;
151
-        $config->display_order_event = isset($config->display_order_event)
152
-            ? $config->display_order_event
153
-            : 100;
154
-        $config->display_order_venue = isset($config->display_order_venue)
155
-            ? $config->display_order_venue
156
-            : 130;
157
-        // get template parts
158
-        $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
159
-        // convert to array so that we can add more properties
160
-        $config = get_object_vars($config);
161
-        $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
162
-            'event-archive-sortable-js',
163
-            '',
164
-            'archive-sortable-li archive-sortable-js'
165
-        );
166
-        EEH_Template::display_template(
167
-            EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
168
-            $config
169
-        );
170
-    }
92
+	/**
93
+	 * @return void
94
+	 * @throws DomainException
95
+	 * @throws InvalidArgumentException
96
+	 * @throws InvalidDataTypeException
97
+	 * @throws InvalidInterfaceException
98
+	 */
99
+	public static function template_settings_form()
100
+	{
101
+		/** @var EE_Admin_Page_Loader $admin_page_loader */
102
+		$admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader');
103
+		// grab general settings admin page and remove the existing hook callback
104
+		$gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings');
105
+		if ($gen_set_admin instanceof General_Settings_Admin_Page) {
106
+			remove_action(
107
+				'AHEE__template_settings__template__before_settings_form',
108
+				array($gen_set_admin, 'template_settings_caff_features'),
109
+				100
110
+			);
111
+		}
112
+		// first just grab the template settings
113
+		$config = EE_Registry::instance()->CFG->template_settings;
114
+		// then if the Event Archive config is valid, use that, else create a new one
115
+		$config = $config instanceof EE_Template_Config
116
+				  && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
117
+			? $config->EED_Events_Archive
118
+			: new EE_Events_Archive_Config();
119
+		$config = apply_filters(
120
+			'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
121
+			$config
122
+		);
123
+		$config->display_status_banner = isset($config->display_status_banner)
124
+			? $config->display_status_banner
125
+			: 0;
126
+		$config->display_description = isset($config->display_description)
127
+			? $config->display_description
128
+			: 1;
129
+		$config->display_ticket_selector = isset($config->display_ticket_selector)
130
+			? $config->display_ticket_selector
131
+			: 0;
132
+		$config->display_datetimes = isset($config->display_datetimes)
133
+			? $config->display_datetimes
134
+			: 1;
135
+		$config->display_venue = isset($config->display_venue)
136
+			? $config->display_venue
137
+			: 0;
138
+		$config->display_expired_events = isset($config->display_expired_events)
139
+			? $config->display_expired_events
140
+			: 0;
141
+		// display order options
142
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
143
+			? $config->use_sortable_display_order
144
+			: false;
145
+		$config->display_order_tickets = isset($config->display_order_tickets)
146
+			? $config->display_order_tickets
147
+			: 120;
148
+		$config->display_order_datetimes = isset($config->display_order_datetimes)
149
+			? $config->display_order_datetimes
150
+			: 110;
151
+		$config->display_order_event = isset($config->display_order_event)
152
+			? $config->display_order_event
153
+			: 100;
154
+		$config->display_order_venue = isset($config->display_order_venue)
155
+			? $config->display_order_venue
156
+			: 130;
157
+		// get template parts
158
+		$template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
159
+		// convert to array so that we can add more properties
160
+		$config = get_object_vars($config);
161
+		$config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
162
+			'event-archive-sortable-js',
163
+			'',
164
+			'archive-sortable-li archive-sortable-js'
165
+		);
166
+		EEH_Template::display_template(
167
+			EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
168
+			$config
169
+		);
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * @param EE_Template_Config $CFG
175
-     * @param array              $REQ
176
-     * @return EE_Template_Config
177
-     */
178
-    public static function update_template_settings($CFG, $REQ)
179
-    {
180
-        // unless we are resetting the config...
181
-        if (
182
-            ! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
183
-            || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
184
-        ) {
185
-            /** @var EE_Events_Archive_Config $config */
186
-            $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config
187
-                ? $CFG->EED_Events_Archive
188
-                : new EE_Events_Archive_Config();
173
+	/**
174
+	 * @param EE_Template_Config $CFG
175
+	 * @param array              $REQ
176
+	 * @return EE_Template_Config
177
+	 */
178
+	public static function update_template_settings($CFG, $REQ)
179
+	{
180
+		// unless we are resetting the config...
181
+		if (
182
+			! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
183
+			|| absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
184
+		) {
185
+			/** @var EE_Events_Archive_Config $config */
186
+			$config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config
187
+				? $CFG->EED_Events_Archive
188
+				: new EE_Events_Archive_Config();
189 189
 
190
-            $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
191
-                ? absint($REQ['EED_Events_Archive_display_status_banner'])
192
-                : 0;
193
-            $config->display_description = isset($REQ['EED_Events_Archive_display_description'])
194
-                ? absint($REQ['EED_Events_Archive_display_description'])
195
-                : 1;
196
-            $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
197
-                ? absint($REQ['EED_Events_Archive_display_ticket_selector'])
198
-                : 0;
199
-            $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes'])
200
-                ? absint($REQ['EED_Events_Archive_display_datetimes'])
201
-                : 1;
202
-            $config->display_venue = isset($REQ['EED_Events_Archive_display_venue'])
203
-                ? absint($REQ['EED_Events_Archive_display_venue'])
204
-                : 0;
205
-            $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
206
-                ? absint($REQ['EED_Events_Archive_display_expired_events'])
207
-                : 0;
208
-            $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order'])
209
-                ? absint($REQ['EED_Events_Archive_use_sortable_display_order'])
210
-                : 0;
211
-            $config->display_order_event = $config->display_order_event !== null
212
-                                           && $config->use_sortable_display_order
213
-                ? $config->display_order_event
214
-                : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
215
-            $config->display_order_datetimes = $config->display_order_datetimes !== null
216
-                                               && $config->use_sortable_display_order
217
-                ? $config->display_order_datetimes
218
-                : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
219
-            $config->display_order_tickets = $config->display_order_tickets !== null
220
-                                             && $config->use_sortable_display_order
221
-                ? $config->display_order_tickets
222
-                : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
223
-            $config->display_order_venue = $config->display_order_venue !== null
224
-                                           && $config->use_sortable_display_order
225
-                ? $config->display_order_venue
226
-                : EED_Events_Archive::EVENT_VENUES_PRIORITY;
227
-        } else {
228
-            $config = new EE_Events_Archive_Config();
229
-        }
190
+			$config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
191
+				? absint($REQ['EED_Events_Archive_display_status_banner'])
192
+				: 0;
193
+			$config->display_description = isset($REQ['EED_Events_Archive_display_description'])
194
+				? absint($REQ['EED_Events_Archive_display_description'])
195
+				: 1;
196
+			$config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
197
+				? absint($REQ['EED_Events_Archive_display_ticket_selector'])
198
+				: 0;
199
+			$config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes'])
200
+				? absint($REQ['EED_Events_Archive_display_datetimes'])
201
+				: 1;
202
+			$config->display_venue = isset($REQ['EED_Events_Archive_display_venue'])
203
+				? absint($REQ['EED_Events_Archive_display_venue'])
204
+				: 0;
205
+			$config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
206
+				? absint($REQ['EED_Events_Archive_display_expired_events'])
207
+				: 0;
208
+			$config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order'])
209
+				? absint($REQ['EED_Events_Archive_use_sortable_display_order'])
210
+				: 0;
211
+			$config->display_order_event = $config->display_order_event !== null
212
+										   && $config->use_sortable_display_order
213
+				? $config->display_order_event
214
+				: EED_Events_Archive::EVENT_DETAILS_PRIORITY;
215
+			$config->display_order_datetimes = $config->display_order_datetimes !== null
216
+											   && $config->use_sortable_display_order
217
+				? $config->display_order_datetimes
218
+				: EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
219
+			$config->display_order_tickets = $config->display_order_tickets !== null
220
+											 && $config->use_sortable_display_order
221
+				? $config->display_order_tickets
222
+				: EED_Events_Archive::EVENT_TICKETS_PRIORITY;
223
+			$config->display_order_venue = $config->display_order_venue !== null
224
+										   && $config->use_sortable_display_order
225
+				? $config->display_order_venue
226
+				: EED_Events_Archive::EVENT_VENUES_PRIORITY;
227
+		} else {
228
+			$config = new EE_Events_Archive_Config();
229
+		}
230 230
 
231
-        $CFG->EED_Events_Archive = $config;
232
-        do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
233
-        return $CFG;
234
-    }
231
+		$CFG->EED_Events_Archive = $config;
232
+		do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
233
+		return $CFG;
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * @return void
239
-     * @throws InvalidArgumentException
240
-     * @throws InvalidDataTypeException
241
-     * @throws InvalidInterfaceException
242
-     */
243
-    public static function update_event_archive_order()
244
-    {
245
-        /** @var EE_Config $config */
246
-        $config = EE_Registry::instance()->CFG;
247
-        $config_saved = false;
248
-        $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements');
249
-        if (! empty($template_parts)) {
250
-            $template_parts = explode(',', trim($template_parts, ','));
251
-            foreach ($template_parts as $key => $template_part) {
252
-                $template_part = "display_order_$template_part";
253
-                $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
254
-                if (
255
-                    $config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config
256
-                    && property_exists(
257
-                        $config->template_settings->EED_Events_Archive,
258
-                        $template_part
259
-                    )
260
-                ) {
261
-                    $config->template_settings->EED_Events_Archive->{$template_part} = $priority;
262
-                }
263
-                do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
264
-            }
265
-            $config_saved = $config->update_espresso_config(false, false);
266
-        }
267
-        if ($config_saved) {
268
-            EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
269
-        } else {
270
-            EE_Error::add_error(
271
-                esc_html__('Display Order was not updated.', 'event_espresso'),
272
-                __FILE__,
273
-                __FUNCTION__,
274
-                __LINE__
275
-            );
276
-        }
277
-        echo wp_json_encode(EE_Error::get_notices(false));
278
-        exit();
279
-    }
237
+	/**
238
+	 * @return void
239
+	 * @throws InvalidArgumentException
240
+	 * @throws InvalidDataTypeException
241
+	 * @throws InvalidInterfaceException
242
+	 */
243
+	public static function update_event_archive_order()
244
+	{
245
+		/** @var EE_Config $config */
246
+		$config = EE_Registry::instance()->CFG;
247
+		$config_saved = false;
248
+		$template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements');
249
+		if (! empty($template_parts)) {
250
+			$template_parts = explode(',', trim($template_parts, ','));
251
+			foreach ($template_parts as $key => $template_part) {
252
+				$template_part = "display_order_$template_part";
253
+				$priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
254
+				if (
255
+					$config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config
256
+					&& property_exists(
257
+						$config->template_settings->EED_Events_Archive,
258
+						$template_part
259
+					)
260
+				) {
261
+					$config->template_settings->EED_Events_Archive->{$template_part} = $priority;
262
+				}
263
+				do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
264
+			}
265
+			$config_saved = $config->update_espresso_config(false, false);
266
+		}
267
+		if ($config_saved) {
268
+			EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso'));
269
+		} else {
270
+			EE_Error::add_error(
271
+				esc_html__('Display Order was not updated.', 'event_espresso'),
272
+				__FILE__,
273
+				__FUNCTION__,
274
+				__LINE__
275
+			);
276
+		}
277
+		echo wp_json_encode(EE_Error::get_notices(false));
278
+		exit();
279
+	}
280 280
 }
Please login to merge, or discard this patch.