Completed
Branch master (24c3eb)
by
unknown
34:49 queued 28:57
created
modules/single_page_checkout/inc/EE_Checkout.class.php 2 patches
Indentation   +1417 added lines, -1417 removed lines patch added patch discarded remove patch
@@ -14,1422 +14,1422 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Checkout
16 16
 {
17
-    /**
18
-     *    whether current request originated from the EE admin
19
-     *
20
-     * @var bool
21
-     */
22
-    public $admin_request = false;
23
-
24
-    /**
25
-     * whether returning to edit attendee information or to retry a payment
26
-     *
27
-     * @var 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
-     * @var 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
-     * @var bool
42
-     */
43
-    public $continue_reg = true;
44
-
45
-    /**
46
-     * redirect to thank you page ?
47
-     *
48
-     * @var bool
49
-     */
50
-    public $redirect = false;
51
-
52
-    /**
53
-     * generate the reg form or not ?
54
-     *
55
-     * @var bool
56
-     */
57
-    public $generate_reg_form = true;
58
-
59
-    /**
60
-     * process a reg form submission or not ?
61
-     *
62
-     * @var bool
63
-     */
64
-    public $process_form_submission = false;
65
-
66
-    /**
67
-     * tracks whether the TXN status modified during this checkout
68
-     *
69
-     * @var bool
70
-     */
71
-    public $txn_status_updated = false;
72
-
73
-    /**
74
-     * only triggered to true after absolutely everything has finished.
75
-     *
76
-     * @var 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
-     * @var array
85
-     */
86
-    protected $reg_status_updated = array();
87
-
88
-    /**
89
-     * timestamp when redirected from Ticket Selector to the checkout
90
-     *
91
-     * @var int
92
-     */
93
-    public $uts = 0;
94
-
95
-    /**
96
-     * total number of tickets that were in the cart
97
-     *
98
-     * @var 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
-     * @var float
107
-     */
108
-    public $amount_owing = 0;
109
-
110
-    /**
111
-     * the reg step slug from the incoming request
112
-     *
113
-     * @var string
114
-     */
115
-    public $step = '';
116
-
117
-    /**
118
-     * the reg step slug for a step being edited
119
-     *
120
-     * @var string
121
-     */
122
-    public $edit_step = '';
123
-
124
-    /**
125
-     * the action being performed on the current step
126
-     *
127
-     * @var string
128
-     */
129
-    public $action = '';
130
-
131
-    /**
132
-     * reg_url_link for a previously saved registration
133
-     *
134
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var string
170
-     */
171
-    public $redirect_url = '';
172
-
173
-    /**
174
-     * form of POST data for use with off-site gateways
175
-     *
176
-     * @var 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
-     * @var 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
-     * @var EE_SPCO_JSON_Response
192
-     */
193
-    public $json_response;
194
-
195
-    /**
196
-     * where we are going next in the reg process
197
-     *
198
-     * @var EE_SPCO_Reg_Step
199
-     */
200
-    public $next_step;
201
-
202
-    /**
203
-     * where we are in the reg process
204
-     *
205
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var 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
-     * @var EE_Form_Section_Proper
256
-     */
257
-    public $registration_form;
258
-
259
-    /**
260
-     * array of EE_SPCO_Reg_Step objects
261
-     *
262
-     * @var EE_SPCO_Reg_Step[]
263
-     */
264
-    public $reg_steps = array();
265
-
266
-    /**
267
-     * array of EE_Payment_Method objects
268
-     *
269
-     * @var 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
-     * @param string $current_step
462
-     * @return void
463
-     */
464
-    public function set_current_step(string $current_step)
465
-    {
466
-        // grab what step we're on
467
-        $this->current_step = $this->reg_steps[ $current_step ] ?? reset($this->reg_steps);
468
-        // verify instance
469
-        if (! $this->current_step instanceof EE_SPCO_Reg_Step) {
470
-            EE_Error::add_error(
471
-                esc_html__('The current step could not be set.', 'event_espresso'),
472
-                __FILE__,
473
-                __FUNCTION__,
474
-                __LINE__
475
-            );
476
-        }
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
-        $this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
489
-    }
490
-
491
-
492
-    /**
493
-     *    set_next_step
494
-     * advances the reg_steps array pointer and sets the next step, then reverses pointer back to the current step
495
-     *
496
-     * @access    public
497
-     * @return    void
498
-     */
499
-    public function set_next_step()
500
-    {
501
-        // set pointer to start of array
502
-        reset($this->reg_steps);
503
-        // if there is more than one step
504
-        if (count($this->reg_steps) > 1) {
505
-            // advance to the current step and set pointer
506
-            while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') {
507
-                next($this->reg_steps);
508
-            }
509
-        }
510
-        // advance one more spot ( if it exists )
511
-        $this->next_step = next($this->reg_steps);
512
-        // verify instance
513
-        $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : null;
514
-        // then back to current step to reset
515
-        prev($this->reg_steps);
516
-    }
517
-
518
-
519
-    /**
520
-     *    get_next_reg_step
521
-     *    this simply returns the next step from reg_steps array
522
-     *
523
-     * @access    public
524
-     * @return    EE_SPCO_Reg_Step | null
525
-     */
526
-    public function get_next_reg_step()
527
-    {
528
-        $next = next($this->reg_steps);
529
-        prev($this->reg_steps);
530
-        return $next instanceof EE_SPCO_Reg_Step ? $next : null;
531
-    }
532
-
533
-
534
-    /**
535
-     * get_prev_reg_step
536
-     *    this simply returns the previous step from reg_steps array
537
-     *
538
-     * @access    public
539
-     * @return    EE_SPCO_Reg_Step | null
540
-     */
541
-    public function get_prev_reg_step()
542
-    {
543
-        $prev = prev($this->reg_steps);
544
-        next($this->reg_steps);
545
-        return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
546
-    }
547
-
548
-
549
-    /**
550
-     * sort_reg_steps
551
-     *
552
-     * @access public
553
-     * @return void
554
-     */
555
-    public function sort_reg_steps()
556
-    {
557
-        $reg_step_sorting_callback = apply_filters(
558
-            'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback',
559
-            'reg_step_sorting_callback'
560
-        );
561
-        uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
562
-    }
563
-
564
-
565
-    /**
566
-     * find_reg_step
567
-     * finds a reg step by the given slug
568
-     *
569
-     * @access    public
570
-     * @param string $reg_step_slug
571
-     * @return EE_SPCO_Reg_Step|null
572
-     */
573
-    public function find_reg_step($reg_step_slug = '')
574
-    {
575
-        if (! empty($reg_step_slug)) {
576
-            // copy reg step array
577
-            $reg_steps = $this->reg_steps;
578
-            // set pointer to start of array
579
-            reset($reg_steps);
580
-            // if there is more than one step
581
-            if (count($reg_steps) > 1) {
582
-                // advance to the current step and set pointer
583
-                while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') {
584
-                    next($reg_steps);
585
-                }
586
-                return current($reg_steps);
587
-            }
588
-        }
589
-        return null;
590
-    }
591
-
592
-
593
-    /**
594
-     * reg_step_sorting_callback
595
-     *
596
-     * @access public
597
-     * @param EE_SPCO_Reg_Step $reg_step_A
598
-     * @param EE_SPCO_Reg_Step $reg_step_B
599
-     * @return int
600
-     */
601
-    public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B)
602
-    {
603
-        // send finalize_registration step to the end of the array
604
-        if ($reg_step_A->slug() === 'finalize_registration') {
605
-            return 1;
606
-        } elseif ($reg_step_B->slug() === 'finalize_registration') {
607
-            return -1;
608
-        }
609
-        if ($reg_step_A->order() === $reg_step_B->order()) {
610
-            return 0;
611
-        }
612
-        return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
613
-    }
614
-
615
-
616
-    /**
617
-     * set_reg_step_initiated
618
-     *
619
-     * @access    public
620
-     * @param    EE_SPCO_Reg_Step $reg_step
621
-     * @throws \EE_Error
622
-     */
623
-    public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step)
624
-    {
625
-        // call set_reg_step_initiated ???
626
-        if (
17
+	/**
18
+	 *    whether current request originated from the EE admin
19
+	 *
20
+	 * @var bool
21
+	 */
22
+	public $admin_request = false;
23
+
24
+	/**
25
+	 * whether returning to edit attendee information or to retry a payment
26
+	 *
27
+	 * @var 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
+	 * @var 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
+	 * @var bool
42
+	 */
43
+	public $continue_reg = true;
44
+
45
+	/**
46
+	 * redirect to thank you page ?
47
+	 *
48
+	 * @var bool
49
+	 */
50
+	public $redirect = false;
51
+
52
+	/**
53
+	 * generate the reg form or not ?
54
+	 *
55
+	 * @var bool
56
+	 */
57
+	public $generate_reg_form = true;
58
+
59
+	/**
60
+	 * process a reg form submission or not ?
61
+	 *
62
+	 * @var bool
63
+	 */
64
+	public $process_form_submission = false;
65
+
66
+	/**
67
+	 * tracks whether the TXN status modified during this checkout
68
+	 *
69
+	 * @var bool
70
+	 */
71
+	public $txn_status_updated = false;
72
+
73
+	/**
74
+	 * only triggered to true after absolutely everything has finished.
75
+	 *
76
+	 * @var 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
+	 * @var array
85
+	 */
86
+	protected $reg_status_updated = array();
87
+
88
+	/**
89
+	 * timestamp when redirected from Ticket Selector to the checkout
90
+	 *
91
+	 * @var int
92
+	 */
93
+	public $uts = 0;
94
+
95
+	/**
96
+	 * total number of tickets that were in the cart
97
+	 *
98
+	 * @var 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
+	 * @var float
107
+	 */
108
+	public $amount_owing = 0;
109
+
110
+	/**
111
+	 * the reg step slug from the incoming request
112
+	 *
113
+	 * @var string
114
+	 */
115
+	public $step = '';
116
+
117
+	/**
118
+	 * the reg step slug for a step being edited
119
+	 *
120
+	 * @var string
121
+	 */
122
+	public $edit_step = '';
123
+
124
+	/**
125
+	 * the action being performed on the current step
126
+	 *
127
+	 * @var string
128
+	 */
129
+	public $action = '';
130
+
131
+	/**
132
+	 * reg_url_link for a previously saved registration
133
+	 *
134
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var string
170
+	 */
171
+	public $redirect_url = '';
172
+
173
+	/**
174
+	 * form of POST data for use with off-site gateways
175
+	 *
176
+	 * @var 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
+	 * @var 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
+	 * @var EE_SPCO_JSON_Response
192
+	 */
193
+	public $json_response;
194
+
195
+	/**
196
+	 * where we are going next in the reg process
197
+	 *
198
+	 * @var EE_SPCO_Reg_Step
199
+	 */
200
+	public $next_step;
201
+
202
+	/**
203
+	 * where we are in the reg process
204
+	 *
205
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var 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
+	 * @var EE_Form_Section_Proper
256
+	 */
257
+	public $registration_form;
258
+
259
+	/**
260
+	 * array of EE_SPCO_Reg_Step objects
261
+	 *
262
+	 * @var EE_SPCO_Reg_Step[]
263
+	 */
264
+	public $reg_steps = array();
265
+
266
+	/**
267
+	 * array of EE_Payment_Method objects
268
+	 *
269
+	 * @var 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
+	 * @param string $current_step
462
+	 * @return void
463
+	 */
464
+	public function set_current_step(string $current_step)
465
+	{
466
+		// grab what step we're on
467
+		$this->current_step = $this->reg_steps[ $current_step ] ?? reset($this->reg_steps);
468
+		// verify instance
469
+		if (! $this->current_step instanceof EE_SPCO_Reg_Step) {
470
+			EE_Error::add_error(
471
+				esc_html__('The current step could not be set.', 'event_espresso'),
472
+				__FILE__,
473
+				__FUNCTION__,
474
+				__LINE__
475
+			);
476
+		}
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
+		$this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
489
+	}
490
+
491
+
492
+	/**
493
+	 *    set_next_step
494
+	 * advances the reg_steps array pointer and sets the next step, then reverses pointer back to the current step
495
+	 *
496
+	 * @access    public
497
+	 * @return    void
498
+	 */
499
+	public function set_next_step()
500
+	{
501
+		// set pointer to start of array
502
+		reset($this->reg_steps);
503
+		// if there is more than one step
504
+		if (count($this->reg_steps) > 1) {
505
+			// advance to the current step and set pointer
506
+			while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') {
507
+				next($this->reg_steps);
508
+			}
509
+		}
510
+		// advance one more spot ( if it exists )
511
+		$this->next_step = next($this->reg_steps);
512
+		// verify instance
513
+		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : null;
514
+		// then back to current step to reset
515
+		prev($this->reg_steps);
516
+	}
517
+
518
+
519
+	/**
520
+	 *    get_next_reg_step
521
+	 *    this simply returns the next step from reg_steps array
522
+	 *
523
+	 * @access    public
524
+	 * @return    EE_SPCO_Reg_Step | null
525
+	 */
526
+	public function get_next_reg_step()
527
+	{
528
+		$next = next($this->reg_steps);
529
+		prev($this->reg_steps);
530
+		return $next instanceof EE_SPCO_Reg_Step ? $next : null;
531
+	}
532
+
533
+
534
+	/**
535
+	 * get_prev_reg_step
536
+	 *    this simply returns the previous step from reg_steps array
537
+	 *
538
+	 * @access    public
539
+	 * @return    EE_SPCO_Reg_Step | null
540
+	 */
541
+	public function get_prev_reg_step()
542
+	{
543
+		$prev = prev($this->reg_steps);
544
+		next($this->reg_steps);
545
+		return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
546
+	}
547
+
548
+
549
+	/**
550
+	 * sort_reg_steps
551
+	 *
552
+	 * @access public
553
+	 * @return void
554
+	 */
555
+	public function sort_reg_steps()
556
+	{
557
+		$reg_step_sorting_callback = apply_filters(
558
+			'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback',
559
+			'reg_step_sorting_callback'
560
+		);
561
+		uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
562
+	}
563
+
564
+
565
+	/**
566
+	 * find_reg_step
567
+	 * finds a reg step by the given slug
568
+	 *
569
+	 * @access    public
570
+	 * @param string $reg_step_slug
571
+	 * @return EE_SPCO_Reg_Step|null
572
+	 */
573
+	public function find_reg_step($reg_step_slug = '')
574
+	{
575
+		if (! empty($reg_step_slug)) {
576
+			// copy reg step array
577
+			$reg_steps = $this->reg_steps;
578
+			// set pointer to start of array
579
+			reset($reg_steps);
580
+			// if there is more than one step
581
+			if (count($reg_steps) > 1) {
582
+				// advance to the current step and set pointer
583
+				while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') {
584
+					next($reg_steps);
585
+				}
586
+				return current($reg_steps);
587
+			}
588
+		}
589
+		return null;
590
+	}
591
+
592
+
593
+	/**
594
+	 * reg_step_sorting_callback
595
+	 *
596
+	 * @access public
597
+	 * @param EE_SPCO_Reg_Step $reg_step_A
598
+	 * @param EE_SPCO_Reg_Step $reg_step_B
599
+	 * @return int
600
+	 */
601
+	public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B)
602
+	{
603
+		// send finalize_registration step to the end of the array
604
+		if ($reg_step_A->slug() === 'finalize_registration') {
605
+			return 1;
606
+		} elseif ($reg_step_B->slug() === 'finalize_registration') {
607
+			return -1;
608
+		}
609
+		if ($reg_step_A->order() === $reg_step_B->order()) {
610
+			return 0;
611
+		}
612
+		return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
613
+	}
614
+
615
+
616
+	/**
617
+	 * set_reg_step_initiated
618
+	 *
619
+	 * @access    public
620
+	 * @param    EE_SPCO_Reg_Step $reg_step
621
+	 * @throws \EE_Error
622
+	 */
623
+	public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step)
624
+	{
625
+		// call set_reg_step_initiated ???
626
+		if (
627 627
 // first time visiting SPCO ?
628
-            ! $this->revisit
629
-            && (
630
-                // and displaying the reg step form for the first time ?
631
-                $this->action === 'display_spco_reg_step'
632
-                // or initializing the final step
633
-                || $reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration
634
-            )
635
-        ) {
636
-            // set the start time for this reg step
637
-            if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
638
-                if (WP_DEBUG) {
639
-                    EE_Error::add_error(
640
-                        sprintf(
641
-                            esc_html__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
642
-                            $reg_step->name()
643
-                        ),
644
-                        __FILE__,
645
-                        __FUNCTION__,
646
-                        __LINE__
647
-                    );
648
-                }
649
-            }
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     *    set_reg_step_JSON_info
656
-     *
657
-     * @access public
658
-     * @return    void
659
-     */
660
-    public function set_reg_step_JSON_info()
661
-    {
662
-        EE_Registry::$i18n_js_strings['reg_steps'] = array();
663
-        // pass basic reg step data to JS
664
-        foreach ($this->reg_steps as $reg_step) {
665
-            EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
666
-        }
667
-        // reset reg step html
668
-        // $this->json_response->set_reg_step_html('');
669
-    }
670
-
671
-
672
-    /**
673
-     *    reset_reg_steps
674
-     *
675
-     * @access public
676
-     * @return void
677
-     */
678
-    public function reset_reg_steps()
679
-    {
680
-        $this->sort_reg_steps();
681
-        $this->set_current_step(EED_Single_Page_Checkout::getRequest()->getRequestParam('step'));
682
-        $this->set_next_step();
683
-        // the text that appears on the reg step form submit button
684
-        $this->current_step->set_submit_button_text();
685
-        $this->set_reg_step_JSON_info();
686
-    }
687
-
688
-
689
-    /**
690
-     *    get_registration_time_limit
691
-     *
692
-     * @access    public
693
-     * @return        string
694
-     */
695
-    public function get_registration_time_limit()
696
-    {
697
-        $registration_time_limit = (float) (EE_Registry::instance()->SSN->expiration() - time());
698
-        $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
699
-        $registration_time_limit = date($time_limit_format, $registration_time_limit);
700
-        return apply_filters(
701
-            'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
702
-            $registration_time_limit
703
-        );
704
-    }
705
-
706
-
707
-    /**
708
-     * payment_required
709
-     *
710
-     * @return boolean
711
-     */
712
-    public function payment_required()
713
-    {
714
-        // if NOT:
715
-        //     registration via admin
716
-        //      completed TXN
717
-        //      overpaid TXN
718
-        //      free TXN(total = 0.00)
719
-        //      then payment required is TRUE
720
-        return ! ($this->admin_request
721
-                  || $this->transaction->is_completed()
722
-                  || $this->transaction->is_overpaid()
723
-                  || $this->transaction->is_free()) ? true : false;
724
-    }
725
-
726
-
727
-    /**
728
-     * get_cart_for_transaction
729
-     *
730
-     * @access public
731
-     * @param EE_Transaction $transaction
732
-     * @return EE_Cart
733
-     */
734
-    public function get_cart_for_transaction($transaction)
735
-    {
736
-        $session = EE_Registry::instance()->load_core('Session');
737
-        $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
738
-        // verify cart
739
-        if (! $cart instanceof EE_Cart) {
740
-            $cart = EE_Registry::instance()->load_core('Cart');
741
-        }
742
-
743
-        return $cart;
744
-    }
745
-
746
-
747
-    /**
748
-     *    initialize_txn_reg_steps_array
749
-     *
750
-     * @access public
751
-     * @return    array
752
-     */
753
-    public function initialize_txn_reg_steps_array()
754
-    {
755
-        $txn_reg_steps_array = array();
756
-        foreach ($this->reg_steps as $reg_step) {
757
-            $txn_reg_steps_array[ $reg_step->slug() ] = false;
758
-        }
759
-        return $txn_reg_steps_array;
760
-    }
761
-
762
-
763
-    /**
764
-     *    update_txn_reg_steps_array
765
-     *
766
-     * @access public
767
-     * @return    bool
768
-     * @throws \EE_Error
769
-     */
770
-    public function update_txn_reg_steps_array()
771
-    {
772
-        $updated = false;
773
-        foreach ($this->reg_steps as $reg_step) {
774
-            if ($reg_step->completed()) {
775
-                $updated = $this->transaction->set_reg_step_completed($reg_step->slug())
776
-                    ? true
777
-                    : $updated;
778
-            }
779
-        }
780
-        if ($updated) {
781
-            $this->transaction->save();
782
-        }
783
-        return $updated;
784
-    }
785
-
786
-
787
-    /**
788
-     *    stash_transaction_and_checkout
789
-     *
790
-     * @access public
791
-     * @return    void
792
-     * @throws \EE_Error
793
-     */
794
-    public function stash_transaction_and_checkout()
795
-    {
796
-        if (! $this->revisit) {
797
-            $this->update_txn_reg_steps_array();
798
-        }
799
-        $this->track_transaction_and_registration_status_updates();
800
-        // save all data to the db, but suppress errors
801
-        // $this->save_all_data( FALSE );
802
-        // cache the checkout in the session
803
-        EE_Registry::instance()->SSN->set_checkout($this);
804
-    }
805
-
806
-
807
-    /**
808
-     *    track_transaction_and_registration_status_updates
809
-     *    stores whether any updates were made to the TXN or it's related registrations
810
-     *
811
-     * @access public
812
-     * @return void
813
-     * @throws \EE_Error
814
-     */
815
-    public function track_transaction_and_registration_status_updates()
816
-    {
817
-        // verify the transaction
818
-        if ($this->transaction instanceof EE_Transaction) {
819
-            // has there been a TXN status change during this checkout?
820
-            $this->txn_status_updated = $this->transaction->txn_status_updated();
821
-            /** @type EE_Registration_Processor $registration_processor */
822
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
823
-            // grab the saved registrations from the transaction
824
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
825
-                if ($registration_processor->reg_status_updated($registration->ID())) {
826
-                    $this->set_reg_status_updated($registration->ID(), true);
827
-                }
828
-            }
829
-        }
830
-    }
831
-
832
-
833
-    /**
834
-     *    visit_allows_processing_of_this_registration
835
-     *    determines if the current SPCO visit should allow the passed EE_Registration to be used in processing.
836
-     *    one of the following conditions must be met:
837
-     *        EITHER:    A) first time thru SPCO -> process ALL registrations ( NOT a revisit )
838
-     *        OR :        B) primary registrant is editing info -> process ALL registrations ( primary_revisit )
839
-     *        OR :        C) another registrant is editing info -> ONLY process their registration ( revisit AND their
840
-     *        reg_url_link matches )
841
-     *
842
-     * @access public
843
-     * @param    EE_Registration $registration
844
-     * @return    bool
845
-     * @throws \EE_Error
846
-     */
847
-    public function visit_allows_processing_of_this_registration(EE_Registration $registration)
848
-    {
849
-        return ! $this->revisit
850
-               || $this->primary_revisit
851
-               || (
852
-                   $this->revisit && $this->reg_url_link === $registration->reg_url_link()
853
-               )
854
-            ? true
855
-            : false;
856
-    }
857
-
858
-
859
-    /**
860
-     *    _transaction_has_primary_registration
861
-     *
862
-     * @access        private
863
-     * @return        bool
864
-     */
865
-    public function transaction_has_primary_registrant()
866
-    {
867
-        return $this->primary_attendee_obj instanceof EE_Attendee ? true : false;
868
-    }
869
-
870
-
871
-    /**
872
-     *    save_all_data
873
-     *    simply loops through the current transaction and saves all data for each registration
874
-     *
875
-     * @access public
876
-     * @param bool $show_errors
877
-     * @return bool
878
-     * @throws \EE_Error
879
-     */
880
-    public function save_all_data($show_errors = true)
881
-    {
882
-        // verify the transaction
883
-        if ($this->transaction instanceof EE_Transaction) {
884
-            // save to ensure that TXN has ID
885
-            $this->transaction->save();
886
-            // grab the saved registrations from the transaction
887
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
888
-                $this->_save_registration($registration, $show_errors);
889
-            }
890
-        } else {
891
-            if ($show_errors) {
892
-                EE_Error::add_error(
893
-                    esc_html__(
894
-                        'A valid Transaction was not found when attempting to save your registration information.',
895
-                        'event_espresso'
896
-                    ),
897
-                    __FILE__,
898
-                    __FUNCTION__,
899
-                    __LINE__
900
-                );
901
-            }
902
-            return false;
903
-        }
904
-        return true;
905
-    }
906
-
907
-
908
-    /**
909
-     * _save_registration_attendee
910
-     *
911
-     * @param    EE_Registration $registration
912
-     * @param bool               $show_errors
913
-     * @return void
914
-     * @throws \EE_Error
915
-     */
916
-    private function _save_registration($registration, $show_errors = true)
917
-    {
918
-        // verify object
919
-        if ($registration instanceof EE_Registration) {
920
-            // should this registration be processed during this visit ?
921
-            if ($this->visit_allows_processing_of_this_registration($registration)) {
922
-                // set TXN ID
923
-                if (! $registration->transaction_ID()) {
924
-                    $registration->set_transaction_id($this->transaction->ID());
925
-                }
926
-                // verify and save the attendee
927
-                $this->_save_registration_attendee($registration, $show_errors);
928
-                // save answers to reg form questions
929
-                $this->_save_registration_answers($registration, $show_errors);
930
-                // save changes
931
-                $registration->save();
932
-                // update txn cache
933
-                if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
934
-                    if ($show_errors) {
935
-                        EE_Error::add_error(
936
-                            esc_html__(
937
-                                'The newly saved Registration object could not be cached on the Transaction.',
938
-                                'event_espresso'
939
-                            ),
940
-                            __FILE__,
941
-                            __FUNCTION__,
942
-                            __LINE__
943
-                        );
944
-                    }
945
-                }
946
-            }
947
-        } else {
948
-            if ($show_errors) {
949
-                EE_Error::add_error(
950
-                    esc_html__(
951
-                        'An invalid Registration object was discovered when attempting to save your registration information.',
952
-                        'event_espresso'
953
-                    ),
954
-                    __FILE__,
955
-                    __FUNCTION__,
956
-                    __LINE__
957
-                );
958
-            }
959
-        }
960
-    }
961
-
962
-
963
-    /**
964
-     * _save_registration_attendee
965
-     *
966
-     * @param    EE_Registration $registration
967
-     * @param bool               $show_errors
968
-     * @return void
969
-     * @throws \EE_Error
970
-     */
971
-    private function _save_registration_attendee($registration, $show_errors = true)
972
-    {
973
-        if ($registration->attendee() instanceof EE_Attendee) {
974
-            // save so that ATT has ID
975
-            $registration->attendee()->save();
976
-            if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
977
-                if ($show_errors) {
978
-                    EE_Error::add_error(
979
-                        esc_html__(
980
-                            'The newly saved Attendee object could not be cached on the registration.',
981
-                            'event_espresso'
982
-                        ),
983
-                        __FILE__,
984
-                        __FUNCTION__,
985
-                        __LINE__
986
-                    );
987
-                }
988
-            }
989
-        } else {
990
-            if ($show_errors) {
991
-                EE_Error::add_error(
992
-                    sprintf(
993
-                        '%1$s||%1$s $attendee = %2$s',
994
-                        esc_html__(
995
-                            'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.',
996
-                            'event_espresso'
997
-                        ),
998
-                        var_export($registration->attendee(), true)
999
-                    ),
1000
-                    __FILE__,
1001
-                    __FUNCTION__,
1002
-                    __LINE__
1003
-                );
1004
-            }
1005
-        }
1006
-    }
1007
-
1008
-
1009
-    /**
1010
-     * _save_question_answers
1011
-     *
1012
-     * @param    EE_Registration $registration
1013
-     * @param bool               $show_errors
1014
-     * @return void
1015
-     * @throws \EE_Error
1016
-     */
1017
-    private function _save_registration_answers($registration, $show_errors = true)
1018
-    {
1019
-        // now save the answers
1020
-        foreach ($registration->answers() as $cache_key => $answer) {
1021
-            // verify object
1022
-            if ($answer instanceof EE_Answer) {
1023
-                $answer->set_registration($registration->ID());
1024
-                $answer->save();
1025
-                if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1026
-                    if ($show_errors) {
1027
-                        EE_Error::add_error(
1028
-                            esc_html__(
1029
-                                'The newly saved Answer object could not be cached on the registration.',
1030
-                                'event_espresso'
1031
-                            ),
1032
-                            __FILE__,
1033
-                            __FUNCTION__,
1034
-                            __LINE__
1035
-                        );
1036
-                    }
1037
-                }
1038
-            } else {
1039
-                if ($show_errors) {
1040
-                    EE_Error::add_error(
1041
-                        esc_html__(
1042
-                            'An invalid Answer object was discovered when attempting to save your registration information.',
1043
-                            'event_espresso'
1044
-                        ),
1045
-                        __FILE__,
1046
-                        __FUNCTION__,
1047
-                        __LINE__
1048
-                    );
1049
-                }
1050
-            }
1051
-        }
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     *    refresh_all_entities
1057
-     *   will either refresh the entity map with objects form the db or from the checkout cache
1058
-     *
1059
-     * @access public
1060
-     * @param bool $from_db
1061
-     * @return bool
1062
-     * @throws \EE_Error
1063
-     */
1064
-    public function refresh_all_entities($from_db = false)
1065
-    {
1066
-        $this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
1067
-        $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response'
1068
-            ? true
1069
-            : $from_db;
1070
-        // $this->log(
1071
-        //     __CLASS__,
1072
-        //     __FUNCTION__,
1073
-        //     __LINE__,
1074
-        //     array('from_db' => $from_db)
1075
-        // );
1076
-        return $from_db ? $this->refresh_from_db() : $this->refresh_entity_map();
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     *  refresh_entity_map
1082
-     *  simply loops through the current transaction and updates each
1083
-     *  model's entity map using EEM_Base::refresh_entity_map_from_db()
1084
-     *
1085
-     * @access public
1086
-     * @return bool
1087
-     * @throws \EE_Error
1088
-     */
1089
-    protected function refresh_from_db()
1090
-    {
1091
-        // verify the transaction
1092
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1093
-            // pull fresh TXN data from the db
1094
-            $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
1095
-            // update EE_Checkout's cached primary_attendee object
1096
-            $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
1097
-            // update EE_Checkout's cached payment object
1098
-            $payment = $this->transaction->last_payment();
1099
-            $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
1100
-            // update EE_Checkout's cached payment_method object
1101
-            $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
1102
-            $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method
1103
-                : $this->payment_method;
1104
-            // now refresh the cart, based on the TXN
1105
-            $this->cart = $this->get_cart_for_transaction($this->transaction);
1106
-        } else {
1107
-            EE_Error::add_error(
1108
-                esc_html__(
1109
-                    'A valid Transaction was not found when attempting to update the model entity mapper.',
1110
-                    'event_espresso'
1111
-                ),
1112
-                __FILE__,
1113
-                __FUNCTION__,
1114
-                __LINE__
1115
-            );
1116
-            return false;
1117
-        }
1118
-        return true;
1119
-    }
1120
-
1121
-
1122
-    /**
1123
-     * _refresh_primary_attendee_obj_from_db
1124
-     *
1125
-     * @param   EE_Transaction $transaction
1126
-     * @return  EE_Attendee | null
1127
-     * @throws \EE_Error
1128
-     */
1129
-    protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction)
1130
-    {
1131
-        $primary_attendee_obj = null;
1132
-        // grab the saved registrations from the transaction
1133
-        foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1134
-            // verify object
1135
-            if ($registration instanceof EE_Registration) {
1136
-                $attendee = $registration->attendee();
1137
-                // verify object && maybe cache primary_attendee_obj ?
1138
-                if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) {
1139
-                    $primary_attendee_obj = $attendee;
1140
-                }
1141
-            } else {
1142
-                EE_Error::add_error(
1143
-                    esc_html__(
1144
-                        'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1145
-                        'event_espresso'
1146
-                    ),
1147
-                    __FILE__,
1148
-                    __FUNCTION__,
1149
-                    __LINE__
1150
-                );
1151
-            }
1152
-        }
1153
-        return $primary_attendee_obj;
1154
-    }
1155
-
1156
-
1157
-    /**
1158
-     *  refresh_entity_map
1159
-     *  simply loops through the current transaction and updates
1160
-     *  each model's entity map using EEM_Base::refresh_entity_map_with()
1161
-     *
1162
-     * @access public
1163
-     * @return bool
1164
-     * @throws \EE_Error
1165
-     */
1166
-    protected function refresh_entity_map()
1167
-    {
1168
-        // verify the transaction
1169
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1170
-            // never cache payment info
1171
-            $this->transaction->clear_cache('Payment');
1172
-            // is the Payment Options Reg Step completed ?
1173
-            if ($this->transaction->reg_step_completed('payment_options')) {
1174
-                // then check for payments and update TXN accordingly
1175
-                /** @type EE_Transaction_Payments $transaction_payments */
1176
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1177
-                $transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1178
-            }
1179
-            // grab the saved registrations from the transaction
1180
-            foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1181
-                $this->_refresh_registration($reg_cache_ID, $registration);
1182
-            }
1183
-            // make sure our cached TXN is added to the model entity mapper
1184
-            $this->transaction = $this->transaction->get_model()->refresh_entity_map_with(
1185
-                $this->transaction->ID(),
1186
-                $this->transaction
1187
-            );
1188
-        } else {
1189
-            EE_Error::add_error(
1190
-                esc_html__(
1191
-                    'A valid Transaction was not found when attempting to update the model entity mapper.',
1192
-                    'event_espresso'
1193
-                ),
1194
-                __FILE__,
1195
-                __FUNCTION__,
1196
-                __LINE__
1197
-            );
1198
-            return false;
1199
-        }
1200
-        // verify and update the cart because inaccurate totals are not so much fun
1201
-        if ($this->cart instanceof EE_Cart) {
1202
-            $grand_total = $this->cart->get_grand_total();
1203
-            if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1204
-                $grand_total->recalculate_total_including_taxes();
1205
-                $grand_total = $grand_total->get_model()->refresh_entity_map_with(
1206
-                    $this->cart->get_grand_total()->ID(),
1207
-                    $this->cart->get_grand_total()
1208
-                );
1209
-            }
1210
-            if ($grand_total instanceof EE_Line_Item) {
1211
-                $this->cart = EE_Cart::instance($grand_total);
1212
-            } else {
1213
-                EE_Error::add_error(
1214
-                    esc_html__(
1215
-                        'A valid Cart was not found when attempting to update the model entity mapper.',
1216
-                        'event_espresso'
1217
-                    ),
1218
-                    __FILE__,
1219
-                    __FUNCTION__,
1220
-                    __LINE__
1221
-                );
1222
-                return false;
1223
-            }
1224
-        }
1225
-        return true;
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * _refresh_registration
1231
-     *
1232
-     * @param    string | int    $reg_cache_ID
1233
-     * @param    EE_Registration $registration
1234
-     * @return void
1235
-     * @throws \EE_Error
1236
-     */
1237
-    protected function _refresh_registration($reg_cache_ID, $registration)
1238
-    {
1239
-
1240
-        // verify object
1241
-        if ($registration instanceof EE_Registration) {
1242
-            // update the entity mapper attendee
1243
-            $this->_refresh_registration_attendee($registration);
1244
-            // update the entity mapper answers for reg form questions
1245
-            $this->_refresh_registration_answers($registration);
1246
-            // make sure the cached registration is added to the model entity mapper
1247
-            $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1248
-        } else {
1249
-            EE_Error::add_error(
1250
-                esc_html__(
1251
-                    'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1252
-                    'event_espresso'
1253
-                ),
1254
-                __FILE__,
1255
-                __FUNCTION__,
1256
-                __LINE__
1257
-            );
1258
-        }
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * _save_registration_attendee
1264
-     *
1265
-     * @param    EE_Registration $registration
1266
-     * @return void
1267
-     * @throws \EE_Error
1268
-     */
1269
-    protected function _refresh_registration_attendee($registration)
1270
-    {
1271
-        $attendee = $registration->attendee();
1272
-        // verify object
1273
-        if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1274
-            // make sure the cached attendee is added to the model entity mapper
1275
-            $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1276
-            // maybe cache primary_attendee_obj ?
1277
-            if ($registration->is_primary_registrant()) {
1278
-                $this->primary_attendee_obj = $attendee;
1279
-            }
1280
-        }
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * _refresh_registration_answers
1286
-     *
1287
-     * @param    EE_Registration $registration
1288
-     * @return void
1289
-     * @throws \EE_Error
1290
-     */
1291
-    protected function _refresh_registration_answers($registration)
1292
-    {
1293
-
1294
-        // now update the answers
1295
-        foreach ($registration->answers() as $cache_key => $answer) {
1296
-            // verify object
1297
-            if ($answer instanceof EE_Answer) {
1298
-                if ($answer->ID()) {
1299
-                    // make sure the cached answer is added to the model entity mapper
1300
-                    $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1301
-                }
1302
-            } else {
1303
-                EE_Error::add_error(
1304
-                    esc_html__(
1305
-                        'An invalid Answer object was discovered when attempting to update the model entity mapper.',
1306
-                        'event_espresso'
1307
-                    ),
1308
-                    __FILE__,
1309
-                    __FUNCTION__,
1310
-                    __LINE__
1311
-                );
1312
-            }
1313
-        }
1314
-    }
1315
-
1316
-
1317
-    /**
1318
-     *    __sleep
1319
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
1320
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
1321
-     * reg form, because if needed, it will be regenerated anyways
1322
-     *
1323
-     * @return array
1324
-     * @throws \EE_Error
1325
-     */
1326
-    public function __sleep()
1327
-    {
1328
-        if ($this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID()) {
1329
-            $this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1330
-        }        // remove the reg form and the checkout
1331
-        if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1332
-            $this->transaction = $this->transaction->ID();
1333
-        }        // remove the reg form and the checkout
1334
-        return array_diff(array_keys(get_object_vars($this)), array('billing_form', 'registration_form'));
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     *    __wakeup
1340
-     * to conserve db space, we are removing the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
1341
-     * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1342
-     */
1343
-    public function __wakeup()
1344
-    {
1345
-        if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1346
-            // $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1347
-            $this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1348
-        }
1349
-        if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1350
-            // $this->transaction is actually just an ID, so use it to get the object from the db
1351
-            $this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1352
-        }
1353
-        foreach ($this->reg_steps as $reg_step) {
1354
-            $reg_step->checkout = $this;
1355
-        }
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * debug
1361
-     *
1362
-     * @param string $class
1363
-     * @param string $func
1364
-     * @param string $line
1365
-     * @param array  $info
1366
-     * @param bool   $display_request
1367
-     * @throws \EE_Error
1368
-     */
1369
-    public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false)
1370
-    {
1371
-        $disabled = true;
1372
-        if (WP_DEBUG && ! $disabled) {
1373
-            $debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1374
-            $default_data = array(
1375
-                $class                    => $func . '() : ' . $line,
1376
-                'request->step'           => $this->step,
1377
-                'request->action'         => $this->action,
1378
-                'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
1379
-                    $this->current_step->slug() : '',
1380
-                'current_step->completed' => $this->current_step instanceof EE_SPCO_Reg_Step ?
1381
-                    $this->current_step->completed() : '',
1382
-                'txn_status_updated'      => $this->transaction->txn_status_updated(),
1383
-                'reg_status_updated'      => $this->reg_status_updated,
1384
-                'reg_url_link'            => $this->reg_url_link,
1385
-            );
1386
-            if ($this->transaction instanceof EE_Transaction) {
1387
-                $default_data['TXN_status'] = $this->transaction->status_ID();
1388
-                $default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1389
-                foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1390
-                    $default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1391
-                }
1392
-                if ($this->transaction->ID()) {
1393
-                    $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1394
-                    // don't serialize objects
1395
-                    $info = $this->_strip_objects($info);
1396
-                    if (! isset($debug_data[ $TXN_ID ])) {
1397
-                        $debug_data[ $TXN_ID ] = array();
1398
-                    }
1399
-                    $debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1400
-                        $default_data,
1401
-                        $info
1402
-                    );
1403
-                    update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1404
-                }
1405
-            }
1406
-        }
1407
-    }
1408
-
1409
-
1410
-    /**
1411
-     * _strip_objects
1412
-     *
1413
-     * @param array $info
1414
-     * @return array
1415
-     */
1416
-    public function _strip_objects($info = array())
1417
-    {
1418
-        foreach ((array) $info as $key => $value) {
1419
-            if (is_array($value)) {
1420
-                $info[ $key ] = $this->_strip_objects($value);
1421
-            } elseif (is_object($value)) {
1422
-                $object_class = get_class($value);
1423
-                $info[ $object_class ] = array();
1424
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1425
-                if (method_exists($value, 'status')) {
1426
-                    $info[ $object_class ]['status'] = $value->status();
1427
-                } elseif (method_exists($value, 'status_ID')) {
1428
-                    $info[ $object_class ]['status'] = $value->status_ID();
1429
-                }
1430
-                unset($info[ $key ]);
1431
-            }
1432
-        }
1433
-        return (array) $info;
1434
-    }
628
+			! $this->revisit
629
+			&& (
630
+				// and displaying the reg step form for the first time ?
631
+				$this->action === 'display_spco_reg_step'
632
+				// or initializing the final step
633
+				|| $reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration
634
+			)
635
+		) {
636
+			// set the start time for this reg step
637
+			if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
638
+				if (WP_DEBUG) {
639
+					EE_Error::add_error(
640
+						sprintf(
641
+							esc_html__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
642
+							$reg_step->name()
643
+						),
644
+						__FILE__,
645
+						__FUNCTION__,
646
+						__LINE__
647
+					);
648
+				}
649
+			}
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 *    set_reg_step_JSON_info
656
+	 *
657
+	 * @access public
658
+	 * @return    void
659
+	 */
660
+	public function set_reg_step_JSON_info()
661
+	{
662
+		EE_Registry::$i18n_js_strings['reg_steps'] = array();
663
+		// pass basic reg step data to JS
664
+		foreach ($this->reg_steps as $reg_step) {
665
+			EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
666
+		}
667
+		// reset reg step html
668
+		// $this->json_response->set_reg_step_html('');
669
+	}
670
+
671
+
672
+	/**
673
+	 *    reset_reg_steps
674
+	 *
675
+	 * @access public
676
+	 * @return void
677
+	 */
678
+	public function reset_reg_steps()
679
+	{
680
+		$this->sort_reg_steps();
681
+		$this->set_current_step(EED_Single_Page_Checkout::getRequest()->getRequestParam('step'));
682
+		$this->set_next_step();
683
+		// the text that appears on the reg step form submit button
684
+		$this->current_step->set_submit_button_text();
685
+		$this->set_reg_step_JSON_info();
686
+	}
687
+
688
+
689
+	/**
690
+	 *    get_registration_time_limit
691
+	 *
692
+	 * @access    public
693
+	 * @return        string
694
+	 */
695
+	public function get_registration_time_limit()
696
+	{
697
+		$registration_time_limit = (float) (EE_Registry::instance()->SSN->expiration() - time());
698
+		$time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
699
+		$registration_time_limit = date($time_limit_format, $registration_time_limit);
700
+		return apply_filters(
701
+			'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
702
+			$registration_time_limit
703
+		);
704
+	}
705
+
706
+
707
+	/**
708
+	 * payment_required
709
+	 *
710
+	 * @return boolean
711
+	 */
712
+	public function payment_required()
713
+	{
714
+		// if NOT:
715
+		//     registration via admin
716
+		//      completed TXN
717
+		//      overpaid TXN
718
+		//      free TXN(total = 0.00)
719
+		//      then payment required is TRUE
720
+		return ! ($this->admin_request
721
+				  || $this->transaction->is_completed()
722
+				  || $this->transaction->is_overpaid()
723
+				  || $this->transaction->is_free()) ? true : false;
724
+	}
725
+
726
+
727
+	/**
728
+	 * get_cart_for_transaction
729
+	 *
730
+	 * @access public
731
+	 * @param EE_Transaction $transaction
732
+	 * @return EE_Cart
733
+	 */
734
+	public function get_cart_for_transaction($transaction)
735
+	{
736
+		$session = EE_Registry::instance()->load_core('Session');
737
+		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
738
+		// verify cart
739
+		if (! $cart instanceof EE_Cart) {
740
+			$cart = EE_Registry::instance()->load_core('Cart');
741
+		}
742
+
743
+		return $cart;
744
+	}
745
+
746
+
747
+	/**
748
+	 *    initialize_txn_reg_steps_array
749
+	 *
750
+	 * @access public
751
+	 * @return    array
752
+	 */
753
+	public function initialize_txn_reg_steps_array()
754
+	{
755
+		$txn_reg_steps_array = array();
756
+		foreach ($this->reg_steps as $reg_step) {
757
+			$txn_reg_steps_array[ $reg_step->slug() ] = false;
758
+		}
759
+		return $txn_reg_steps_array;
760
+	}
761
+
762
+
763
+	/**
764
+	 *    update_txn_reg_steps_array
765
+	 *
766
+	 * @access public
767
+	 * @return    bool
768
+	 * @throws \EE_Error
769
+	 */
770
+	public function update_txn_reg_steps_array()
771
+	{
772
+		$updated = false;
773
+		foreach ($this->reg_steps as $reg_step) {
774
+			if ($reg_step->completed()) {
775
+				$updated = $this->transaction->set_reg_step_completed($reg_step->slug())
776
+					? true
777
+					: $updated;
778
+			}
779
+		}
780
+		if ($updated) {
781
+			$this->transaction->save();
782
+		}
783
+		return $updated;
784
+	}
785
+
786
+
787
+	/**
788
+	 *    stash_transaction_and_checkout
789
+	 *
790
+	 * @access public
791
+	 * @return    void
792
+	 * @throws \EE_Error
793
+	 */
794
+	public function stash_transaction_and_checkout()
795
+	{
796
+		if (! $this->revisit) {
797
+			$this->update_txn_reg_steps_array();
798
+		}
799
+		$this->track_transaction_and_registration_status_updates();
800
+		// save all data to the db, but suppress errors
801
+		// $this->save_all_data( FALSE );
802
+		// cache the checkout in the session
803
+		EE_Registry::instance()->SSN->set_checkout($this);
804
+	}
805
+
806
+
807
+	/**
808
+	 *    track_transaction_and_registration_status_updates
809
+	 *    stores whether any updates were made to the TXN or it's related registrations
810
+	 *
811
+	 * @access public
812
+	 * @return void
813
+	 * @throws \EE_Error
814
+	 */
815
+	public function track_transaction_and_registration_status_updates()
816
+	{
817
+		// verify the transaction
818
+		if ($this->transaction instanceof EE_Transaction) {
819
+			// has there been a TXN status change during this checkout?
820
+			$this->txn_status_updated = $this->transaction->txn_status_updated();
821
+			/** @type EE_Registration_Processor $registration_processor */
822
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
823
+			// grab the saved registrations from the transaction
824
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
825
+				if ($registration_processor->reg_status_updated($registration->ID())) {
826
+					$this->set_reg_status_updated($registration->ID(), true);
827
+				}
828
+			}
829
+		}
830
+	}
831
+
832
+
833
+	/**
834
+	 *    visit_allows_processing_of_this_registration
835
+	 *    determines if the current SPCO visit should allow the passed EE_Registration to be used in processing.
836
+	 *    one of the following conditions must be met:
837
+	 *        EITHER:    A) first time thru SPCO -> process ALL registrations ( NOT a revisit )
838
+	 *        OR :        B) primary registrant is editing info -> process ALL registrations ( primary_revisit )
839
+	 *        OR :        C) another registrant is editing info -> ONLY process their registration ( revisit AND their
840
+	 *        reg_url_link matches )
841
+	 *
842
+	 * @access public
843
+	 * @param    EE_Registration $registration
844
+	 * @return    bool
845
+	 * @throws \EE_Error
846
+	 */
847
+	public function visit_allows_processing_of_this_registration(EE_Registration $registration)
848
+	{
849
+		return ! $this->revisit
850
+			   || $this->primary_revisit
851
+			   || (
852
+				   $this->revisit && $this->reg_url_link === $registration->reg_url_link()
853
+			   )
854
+			? true
855
+			: false;
856
+	}
857
+
858
+
859
+	/**
860
+	 *    _transaction_has_primary_registration
861
+	 *
862
+	 * @access        private
863
+	 * @return        bool
864
+	 */
865
+	public function transaction_has_primary_registrant()
866
+	{
867
+		return $this->primary_attendee_obj instanceof EE_Attendee ? true : false;
868
+	}
869
+
870
+
871
+	/**
872
+	 *    save_all_data
873
+	 *    simply loops through the current transaction and saves all data for each registration
874
+	 *
875
+	 * @access public
876
+	 * @param bool $show_errors
877
+	 * @return bool
878
+	 * @throws \EE_Error
879
+	 */
880
+	public function save_all_data($show_errors = true)
881
+	{
882
+		// verify the transaction
883
+		if ($this->transaction instanceof EE_Transaction) {
884
+			// save to ensure that TXN has ID
885
+			$this->transaction->save();
886
+			// grab the saved registrations from the transaction
887
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
888
+				$this->_save_registration($registration, $show_errors);
889
+			}
890
+		} else {
891
+			if ($show_errors) {
892
+				EE_Error::add_error(
893
+					esc_html__(
894
+						'A valid Transaction was not found when attempting to save your registration information.',
895
+						'event_espresso'
896
+					),
897
+					__FILE__,
898
+					__FUNCTION__,
899
+					__LINE__
900
+				);
901
+			}
902
+			return false;
903
+		}
904
+		return true;
905
+	}
906
+
907
+
908
+	/**
909
+	 * _save_registration_attendee
910
+	 *
911
+	 * @param    EE_Registration $registration
912
+	 * @param bool               $show_errors
913
+	 * @return void
914
+	 * @throws \EE_Error
915
+	 */
916
+	private function _save_registration($registration, $show_errors = true)
917
+	{
918
+		// verify object
919
+		if ($registration instanceof EE_Registration) {
920
+			// should this registration be processed during this visit ?
921
+			if ($this->visit_allows_processing_of_this_registration($registration)) {
922
+				// set TXN ID
923
+				if (! $registration->transaction_ID()) {
924
+					$registration->set_transaction_id($this->transaction->ID());
925
+				}
926
+				// verify and save the attendee
927
+				$this->_save_registration_attendee($registration, $show_errors);
928
+				// save answers to reg form questions
929
+				$this->_save_registration_answers($registration, $show_errors);
930
+				// save changes
931
+				$registration->save();
932
+				// update txn cache
933
+				if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
934
+					if ($show_errors) {
935
+						EE_Error::add_error(
936
+							esc_html__(
937
+								'The newly saved Registration object could not be cached on the Transaction.',
938
+								'event_espresso'
939
+							),
940
+							__FILE__,
941
+							__FUNCTION__,
942
+							__LINE__
943
+						);
944
+					}
945
+				}
946
+			}
947
+		} else {
948
+			if ($show_errors) {
949
+				EE_Error::add_error(
950
+					esc_html__(
951
+						'An invalid Registration object was discovered when attempting to save your registration information.',
952
+						'event_espresso'
953
+					),
954
+					__FILE__,
955
+					__FUNCTION__,
956
+					__LINE__
957
+				);
958
+			}
959
+		}
960
+	}
961
+
962
+
963
+	/**
964
+	 * _save_registration_attendee
965
+	 *
966
+	 * @param    EE_Registration $registration
967
+	 * @param bool               $show_errors
968
+	 * @return void
969
+	 * @throws \EE_Error
970
+	 */
971
+	private function _save_registration_attendee($registration, $show_errors = true)
972
+	{
973
+		if ($registration->attendee() instanceof EE_Attendee) {
974
+			// save so that ATT has ID
975
+			$registration->attendee()->save();
976
+			if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
977
+				if ($show_errors) {
978
+					EE_Error::add_error(
979
+						esc_html__(
980
+							'The newly saved Attendee object could not be cached on the registration.',
981
+							'event_espresso'
982
+						),
983
+						__FILE__,
984
+						__FUNCTION__,
985
+						__LINE__
986
+					);
987
+				}
988
+			}
989
+		} else {
990
+			if ($show_errors) {
991
+				EE_Error::add_error(
992
+					sprintf(
993
+						'%1$s||%1$s $attendee = %2$s',
994
+						esc_html__(
995
+							'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.',
996
+							'event_espresso'
997
+						),
998
+						var_export($registration->attendee(), true)
999
+					),
1000
+					__FILE__,
1001
+					__FUNCTION__,
1002
+					__LINE__
1003
+				);
1004
+			}
1005
+		}
1006
+	}
1007
+
1008
+
1009
+	/**
1010
+	 * _save_question_answers
1011
+	 *
1012
+	 * @param    EE_Registration $registration
1013
+	 * @param bool               $show_errors
1014
+	 * @return void
1015
+	 * @throws \EE_Error
1016
+	 */
1017
+	private function _save_registration_answers($registration, $show_errors = true)
1018
+	{
1019
+		// now save the answers
1020
+		foreach ($registration->answers() as $cache_key => $answer) {
1021
+			// verify object
1022
+			if ($answer instanceof EE_Answer) {
1023
+				$answer->set_registration($registration->ID());
1024
+				$answer->save();
1025
+				if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1026
+					if ($show_errors) {
1027
+						EE_Error::add_error(
1028
+							esc_html__(
1029
+								'The newly saved Answer object could not be cached on the registration.',
1030
+								'event_espresso'
1031
+							),
1032
+							__FILE__,
1033
+							__FUNCTION__,
1034
+							__LINE__
1035
+						);
1036
+					}
1037
+				}
1038
+			} else {
1039
+				if ($show_errors) {
1040
+					EE_Error::add_error(
1041
+						esc_html__(
1042
+							'An invalid Answer object was discovered when attempting to save your registration information.',
1043
+							'event_espresso'
1044
+						),
1045
+						__FILE__,
1046
+						__FUNCTION__,
1047
+						__LINE__
1048
+					);
1049
+				}
1050
+			}
1051
+		}
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 *    refresh_all_entities
1057
+	 *   will either refresh the entity map with objects form the db or from the checkout cache
1058
+	 *
1059
+	 * @access public
1060
+	 * @param bool $from_db
1061
+	 * @return bool
1062
+	 * @throws \EE_Error
1063
+	 */
1064
+	public function refresh_all_entities($from_db = false)
1065
+	{
1066
+		$this->current_step->setRequest(EED_Single_Page_Checkout::getRequest());
1067
+		$from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response'
1068
+			? true
1069
+			: $from_db;
1070
+		// $this->log(
1071
+		//     __CLASS__,
1072
+		//     __FUNCTION__,
1073
+		//     __LINE__,
1074
+		//     array('from_db' => $from_db)
1075
+		// );
1076
+		return $from_db ? $this->refresh_from_db() : $this->refresh_entity_map();
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 *  refresh_entity_map
1082
+	 *  simply loops through the current transaction and updates each
1083
+	 *  model's entity map using EEM_Base::refresh_entity_map_from_db()
1084
+	 *
1085
+	 * @access public
1086
+	 * @return bool
1087
+	 * @throws \EE_Error
1088
+	 */
1089
+	protected function refresh_from_db()
1090
+	{
1091
+		// verify the transaction
1092
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1093
+			// pull fresh TXN data from the db
1094
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
1095
+			// update EE_Checkout's cached primary_attendee object
1096
+			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
1097
+			// update EE_Checkout's cached payment object
1098
+			$payment = $this->transaction->last_payment();
1099
+			$this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
1100
+			// update EE_Checkout's cached payment_method object
1101
+			$payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
1102
+			$this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method
1103
+				: $this->payment_method;
1104
+			// now refresh the cart, based on the TXN
1105
+			$this->cart = $this->get_cart_for_transaction($this->transaction);
1106
+		} else {
1107
+			EE_Error::add_error(
1108
+				esc_html__(
1109
+					'A valid Transaction was not found when attempting to update the model entity mapper.',
1110
+					'event_espresso'
1111
+				),
1112
+				__FILE__,
1113
+				__FUNCTION__,
1114
+				__LINE__
1115
+			);
1116
+			return false;
1117
+		}
1118
+		return true;
1119
+	}
1120
+
1121
+
1122
+	/**
1123
+	 * _refresh_primary_attendee_obj_from_db
1124
+	 *
1125
+	 * @param   EE_Transaction $transaction
1126
+	 * @return  EE_Attendee | null
1127
+	 * @throws \EE_Error
1128
+	 */
1129
+	protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction)
1130
+	{
1131
+		$primary_attendee_obj = null;
1132
+		// grab the saved registrations from the transaction
1133
+		foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1134
+			// verify object
1135
+			if ($registration instanceof EE_Registration) {
1136
+				$attendee = $registration->attendee();
1137
+				// verify object && maybe cache primary_attendee_obj ?
1138
+				if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) {
1139
+					$primary_attendee_obj = $attendee;
1140
+				}
1141
+			} else {
1142
+				EE_Error::add_error(
1143
+					esc_html__(
1144
+						'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1145
+						'event_espresso'
1146
+					),
1147
+					__FILE__,
1148
+					__FUNCTION__,
1149
+					__LINE__
1150
+				);
1151
+			}
1152
+		}
1153
+		return $primary_attendee_obj;
1154
+	}
1155
+
1156
+
1157
+	/**
1158
+	 *  refresh_entity_map
1159
+	 *  simply loops through the current transaction and updates
1160
+	 *  each model's entity map using EEM_Base::refresh_entity_map_with()
1161
+	 *
1162
+	 * @access public
1163
+	 * @return bool
1164
+	 * @throws \EE_Error
1165
+	 */
1166
+	protected function refresh_entity_map()
1167
+	{
1168
+		// verify the transaction
1169
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1170
+			// never cache payment info
1171
+			$this->transaction->clear_cache('Payment');
1172
+			// is the Payment Options Reg Step completed ?
1173
+			if ($this->transaction->reg_step_completed('payment_options')) {
1174
+				// then check for payments and update TXN accordingly
1175
+				/** @type EE_Transaction_Payments $transaction_payments */
1176
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1177
+				$transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1178
+			}
1179
+			// grab the saved registrations from the transaction
1180
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1181
+				$this->_refresh_registration($reg_cache_ID, $registration);
1182
+			}
1183
+			// make sure our cached TXN is added to the model entity mapper
1184
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with(
1185
+				$this->transaction->ID(),
1186
+				$this->transaction
1187
+			);
1188
+		} else {
1189
+			EE_Error::add_error(
1190
+				esc_html__(
1191
+					'A valid Transaction was not found when attempting to update the model entity mapper.',
1192
+					'event_espresso'
1193
+				),
1194
+				__FILE__,
1195
+				__FUNCTION__,
1196
+				__LINE__
1197
+			);
1198
+			return false;
1199
+		}
1200
+		// verify and update the cart because inaccurate totals are not so much fun
1201
+		if ($this->cart instanceof EE_Cart) {
1202
+			$grand_total = $this->cart->get_grand_total();
1203
+			if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1204
+				$grand_total->recalculate_total_including_taxes();
1205
+				$grand_total = $grand_total->get_model()->refresh_entity_map_with(
1206
+					$this->cart->get_grand_total()->ID(),
1207
+					$this->cart->get_grand_total()
1208
+				);
1209
+			}
1210
+			if ($grand_total instanceof EE_Line_Item) {
1211
+				$this->cart = EE_Cart::instance($grand_total);
1212
+			} else {
1213
+				EE_Error::add_error(
1214
+					esc_html__(
1215
+						'A valid Cart was not found when attempting to update the model entity mapper.',
1216
+						'event_espresso'
1217
+					),
1218
+					__FILE__,
1219
+					__FUNCTION__,
1220
+					__LINE__
1221
+				);
1222
+				return false;
1223
+			}
1224
+		}
1225
+		return true;
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * _refresh_registration
1231
+	 *
1232
+	 * @param    string | int    $reg_cache_ID
1233
+	 * @param    EE_Registration $registration
1234
+	 * @return void
1235
+	 * @throws \EE_Error
1236
+	 */
1237
+	protected function _refresh_registration($reg_cache_ID, $registration)
1238
+	{
1239
+
1240
+		// verify object
1241
+		if ($registration instanceof EE_Registration) {
1242
+			// update the entity mapper attendee
1243
+			$this->_refresh_registration_attendee($registration);
1244
+			// update the entity mapper answers for reg form questions
1245
+			$this->_refresh_registration_answers($registration);
1246
+			// make sure the cached registration is added to the model entity mapper
1247
+			$registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1248
+		} else {
1249
+			EE_Error::add_error(
1250
+				esc_html__(
1251
+					'An invalid Registration object was discovered when attempting to update the model entity mapper.',
1252
+					'event_espresso'
1253
+				),
1254
+				__FILE__,
1255
+				__FUNCTION__,
1256
+				__LINE__
1257
+			);
1258
+		}
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * _save_registration_attendee
1264
+	 *
1265
+	 * @param    EE_Registration $registration
1266
+	 * @return void
1267
+	 * @throws \EE_Error
1268
+	 */
1269
+	protected function _refresh_registration_attendee($registration)
1270
+	{
1271
+		$attendee = $registration->attendee();
1272
+		// verify object
1273
+		if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1274
+			// make sure the cached attendee is added to the model entity mapper
1275
+			$registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1276
+			// maybe cache primary_attendee_obj ?
1277
+			if ($registration->is_primary_registrant()) {
1278
+				$this->primary_attendee_obj = $attendee;
1279
+			}
1280
+		}
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * _refresh_registration_answers
1286
+	 *
1287
+	 * @param    EE_Registration $registration
1288
+	 * @return void
1289
+	 * @throws \EE_Error
1290
+	 */
1291
+	protected function _refresh_registration_answers($registration)
1292
+	{
1293
+
1294
+		// now update the answers
1295
+		foreach ($registration->answers() as $cache_key => $answer) {
1296
+			// verify object
1297
+			if ($answer instanceof EE_Answer) {
1298
+				if ($answer->ID()) {
1299
+					// make sure the cached answer is added to the model entity mapper
1300
+					$answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1301
+				}
1302
+			} else {
1303
+				EE_Error::add_error(
1304
+					esc_html__(
1305
+						'An invalid Answer object was discovered when attempting to update the model entity mapper.',
1306
+						'event_espresso'
1307
+					),
1308
+					__FILE__,
1309
+					__FUNCTION__,
1310
+					__LINE__
1311
+				);
1312
+			}
1313
+		}
1314
+	}
1315
+
1316
+
1317
+	/**
1318
+	 *    __sleep
1319
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
1320
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
1321
+	 * reg form, because if needed, it will be regenerated anyways
1322
+	 *
1323
+	 * @return array
1324
+	 * @throws \EE_Error
1325
+	 */
1326
+	public function __sleep()
1327
+	{
1328
+		if ($this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID()) {
1329
+			$this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1330
+		}        // remove the reg form and the checkout
1331
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1332
+			$this->transaction = $this->transaction->ID();
1333
+		}        // remove the reg form and the checkout
1334
+		return array_diff(array_keys(get_object_vars($this)), array('billing_form', 'registration_form'));
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 *    __wakeup
1340
+	 * to conserve db space, we are removing the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
1341
+	 * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1342
+	 */
1343
+	public function __wakeup()
1344
+	{
1345
+		if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1346
+			// $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1347
+			$this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1348
+		}
1349
+		if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1350
+			// $this->transaction is actually just an ID, so use it to get the object from the db
1351
+			$this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1352
+		}
1353
+		foreach ($this->reg_steps as $reg_step) {
1354
+			$reg_step->checkout = $this;
1355
+		}
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * debug
1361
+	 *
1362
+	 * @param string $class
1363
+	 * @param string $func
1364
+	 * @param string $line
1365
+	 * @param array  $info
1366
+	 * @param bool   $display_request
1367
+	 * @throws \EE_Error
1368
+	 */
1369
+	public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false)
1370
+	{
1371
+		$disabled = true;
1372
+		if (WP_DEBUG && ! $disabled) {
1373
+			$debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1374
+			$default_data = array(
1375
+				$class                    => $func . '() : ' . $line,
1376
+				'request->step'           => $this->step,
1377
+				'request->action'         => $this->action,
1378
+				'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
1379
+					$this->current_step->slug() : '',
1380
+				'current_step->completed' => $this->current_step instanceof EE_SPCO_Reg_Step ?
1381
+					$this->current_step->completed() : '',
1382
+				'txn_status_updated'      => $this->transaction->txn_status_updated(),
1383
+				'reg_status_updated'      => $this->reg_status_updated,
1384
+				'reg_url_link'            => $this->reg_url_link,
1385
+			);
1386
+			if ($this->transaction instanceof EE_Transaction) {
1387
+				$default_data['TXN_status'] = $this->transaction->status_ID();
1388
+				$default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1389
+				foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1390
+					$default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1391
+				}
1392
+				if ($this->transaction->ID()) {
1393
+					$TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1394
+					// don't serialize objects
1395
+					$info = $this->_strip_objects($info);
1396
+					if (! isset($debug_data[ $TXN_ID ])) {
1397
+						$debug_data[ $TXN_ID ] = array();
1398
+					}
1399
+					$debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1400
+						$default_data,
1401
+						$info
1402
+					);
1403
+					update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1404
+				}
1405
+			}
1406
+		}
1407
+	}
1408
+
1409
+
1410
+	/**
1411
+	 * _strip_objects
1412
+	 *
1413
+	 * @param array $info
1414
+	 * @return array
1415
+	 */
1416
+	public function _strip_objects($info = array())
1417
+	{
1418
+		foreach ((array) $info as $key => $value) {
1419
+			if (is_array($value)) {
1420
+				$info[ $key ] = $this->_strip_objects($value);
1421
+			} elseif (is_object($value)) {
1422
+				$object_class = get_class($value);
1423
+				$info[ $object_class ] = array();
1424
+				$info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1425
+				if (method_exists($value, 'status')) {
1426
+					$info[ $object_class ]['status'] = $value->status();
1427
+				} elseif (method_exists($value, 'status_ID')) {
1428
+					$info[ $object_class ]['status'] = $value->status_ID();
1429
+				}
1430
+				unset($info[ $key ]);
1431
+			}
1432
+		}
1433
+		return (array) $info;
1434
+	}
1435 1435
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function reg_status_updated($REG_ID)
315 315
     {
316
-        return isset($this->reg_status_updated[ $REG_ID ]) ? $this->reg_status_updated[ $REG_ID ] : false;
316
+        return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false;
317 317
     }
318 318
 
319 319
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      */
324 324
     public function set_reg_status_updated($REG_ID, $reg_status)
325 325
     {
326
-        $this->reg_status_updated[ $REG_ID ] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
326
+        $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
327 327
     }
328 328
 
329 329
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj)
385 385
     {
386
-        $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj;
386
+        $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj;
387 387
     }
388 388
 
389 389
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      */
430 430
     public function remove_reg_step($reg_step_slug = '', $reset = true)
431 431
     {
432
-        unset($this->reg_steps[ $reg_step_slug ]);
432
+        unset($this->reg_steps[$reg_step_slug]);
433 433
         if ($this->transaction instanceof EE_Transaction) {
434 434
             // now remove reg step from TXN and save
435 435
             $this->transaction->remove_reg_step($reg_step_slug);
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
      */
452 452
     public function set_reg_step_order($reg_step_slug = '', $order = 100)
453 453
     {
454
-        if (isset($this->reg_steps[ $reg_step_slug ])) {
455
-            $this->reg_steps[ $reg_step_slug ]->set_order($order);
454
+        if (isset($this->reg_steps[$reg_step_slug])) {
455
+            $this->reg_steps[$reg_step_slug]->set_order($order);
456 456
         }
457 457
     }
458 458
 
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
     public function set_current_step(string $current_step)
465 465
     {
466 466
         // grab what step we're on
467
-        $this->current_step = $this->reg_steps[ $current_step ] ?? reset($this->reg_steps);
467
+        $this->current_step = $this->reg_steps[$current_step] ?? reset($this->reg_steps);
468 468
         // verify instance
469
-        if (! $this->current_step instanceof EE_SPCO_Reg_Step) {
469
+        if ( ! $this->current_step instanceof EE_SPCO_Reg_Step) {
470 470
             EE_Error::add_error(
471 471
                 esc_html__('The current step could not be set.', 'event_espresso'),
472 472
                 __FILE__,
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
      */
573 573
     public function find_reg_step($reg_step_slug = '')
574 574
     {
575
-        if (! empty($reg_step_slug)) {
575
+        if ( ! empty($reg_step_slug)) {
576 576
             // copy reg step array
577 577
             $reg_steps = $this->reg_steps;
578 578
             // set pointer to start of array
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
             )
635 635
         ) {
636 636
             // set the start time for this reg step
637
-            if (! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
637
+            if ( ! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
638 638
                 if (WP_DEBUG) {
639 639
                     EE_Error::add_error(
640 640
                         sprintf(
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
         $session = EE_Registry::instance()->load_core('Session');
737 737
         $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
738 738
         // verify cart
739
-        if (! $cart instanceof EE_Cart) {
739
+        if ( ! $cart instanceof EE_Cart) {
740 740
             $cart = EE_Registry::instance()->load_core('Cart');
741 741
         }
742 742
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
     {
755 755
         $txn_reg_steps_array = array();
756 756
         foreach ($this->reg_steps as $reg_step) {
757
-            $txn_reg_steps_array[ $reg_step->slug() ] = false;
757
+            $txn_reg_steps_array[$reg_step->slug()] = false;
758 758
         }
759 759
         return $txn_reg_steps_array;
760 760
     }
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
      */
794 794
     public function stash_transaction_and_checkout()
795 795
     {
796
-        if (! $this->revisit) {
796
+        if ( ! $this->revisit) {
797 797
             $this->update_txn_reg_steps_array();
798 798
         }
799 799
         $this->track_transaction_and_registration_status_updates();
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
             // should this registration be processed during this visit ?
921 921
             if ($this->visit_allows_processing_of_this_registration($registration)) {
922 922
                 // set TXN ID
923
-                if (! $registration->transaction_ID()) {
923
+                if ( ! $registration->transaction_ID()) {
924 924
                     $registration->set_transaction_id($this->transaction->ID());
925 925
                 }
926 926
                 // verify and save the attendee
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                 // save changes
931 931
                 $registration->save();
932 932
                 // update txn cache
933
-                if (! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
933
+                if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
934 934
                     if ($show_errors) {
935 935
                         EE_Error::add_error(
936 936
                             esc_html__(
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
         if ($registration->attendee() instanceof EE_Attendee) {
974 974
             // save so that ATT has ID
975 975
             $registration->attendee()->save();
976
-            if (! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
976
+            if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
977 977
                 if ($show_errors) {
978 978
                     EE_Error::add_error(
979 979
                         esc_html__(
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
             if ($answer instanceof EE_Answer) {
1023 1023
                 $answer->set_registration($registration->ID());
1024 1024
                 $answer->save();
1025
-                if (! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1025
+                if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
1026 1026
                     if ($show_errors) {
1027 1027
                         EE_Error::add_error(
1028 1028
                             esc_html__(
@@ -1342,11 +1342,11 @@  discard block
 block discarded – undo
1342 1342
      */
1343 1343
     public function __wakeup()
1344 1344
     {
1345
-        if (! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1345
+        if ( ! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1346 1346
             // $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1347 1347
             $this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1348 1348
         }
1349
-        if (! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1349
+        if ( ! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1350 1350
             // $this->transaction is actually just an ID, so use it to get the object from the db
1351 1351
             $this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1352 1352
         }
@@ -1370,9 +1370,9 @@  discard block
 block discarded – undo
1370 1370
     {
1371 1371
         $disabled = true;
1372 1372
         if (WP_DEBUG && ! $disabled) {
1373
-            $debug_data = get_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array());
1373
+            $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array());
1374 1374
             $default_data = array(
1375
-                $class                    => $func . '() : ' . $line,
1375
+                $class                    => $func.'() : '.$line,
1376 1376
                 'request->step'           => $this->step,
1377 1377
                 'request->action'         => $this->action,
1378 1378
                 'current_step->slug'      => $this->current_step instanceof EE_SPCO_Reg_Step ?
@@ -1387,20 +1387,20 @@  discard block
 block discarded – undo
1387 1387
                 $default_data['TXN_status'] = $this->transaction->status_ID();
1388 1388
                 $default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1389 1389
                 foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1390
-                    $default_data['registrations'][ $REG_ID ] = $registration->status_ID();
1390
+                    $default_data['registrations'][$REG_ID] = $registration->status_ID();
1391 1391
                 }
1392 1392
                 if ($this->transaction->ID()) {
1393
-                    $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1393
+                    $TXN_ID = 'EE_Transaction: '.$this->transaction->ID();
1394 1394
                     // don't serialize objects
1395 1395
                     $info = $this->_strip_objects($info);
1396
-                    if (! isset($debug_data[ $TXN_ID ])) {
1397
-                        $debug_data[ $TXN_ID ] = array();
1396
+                    if ( ! isset($debug_data[$TXN_ID])) {
1397
+                        $debug_data[$TXN_ID] = array();
1398 1398
                     }
1399
-                    $debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1399
+                    $debug_data[$TXN_ID][microtime()] = array_merge(
1400 1400
                         $default_data,
1401 1401
                         $info
1402 1402
                     );
1403
-                    update_option('EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data);
1403
+                    update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data);
1404 1404
                 }
1405 1405
             }
1406 1406
         }
@@ -1417,17 +1417,17 @@  discard block
 block discarded – undo
1417 1417
     {
1418 1418
         foreach ((array) $info as $key => $value) {
1419 1419
             if (is_array($value)) {
1420
-                $info[ $key ] = $this->_strip_objects($value);
1420
+                $info[$key] = $this->_strip_objects($value);
1421 1421
             } elseif (is_object($value)) {
1422 1422
                 $object_class = get_class($value);
1423
-                $info[ $object_class ] = array();
1424
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1423
+                $info[$object_class] = array();
1424
+                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1425 1425
                 if (method_exists($value, 'status')) {
1426
-                    $info[ $object_class ]['status'] = $value->status();
1426
+                    $info[$object_class]['status'] = $value->status();
1427 1427
                 } elseif (method_exists($value, 'status_ID')) {
1428
-                    $info[ $object_class ]['status'] = $value->status_ID();
1428
+                    $info[$object_class]['status'] = $value->status_ID();
1429 1429
                 }
1430
-                unset($info[ $key ]);
1430
+                unset($info[$key]);
1431 1431
             }
1432 1432
         }
1433 1433
         return (array) $info;
Please login to merge, or discard this patch.
modules/venues_archive/EED_Venues_Archive.module.php 2 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -29,178 +29,178 @@
 block discarded – undo
29 29
  */
30 30
 class EED_Venues_Archive extends EED_Module
31 31
 {
32
-    /**
33
-     * @return EED_Venues_Archive
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EED_Module::registerRoute(
57
-            $custom_post_types[ EspressoPostType::VENUES ]['plural_slug'],
58
-            'Venues_Archive',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (
99
-            EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
100
-                                   ->get_selected_template() != 'archive-espresso_venues.php'
101
-        ) {
102
-            EEH_Template::load_espresso_theme_functions();
103
-            // then add extra event data via hooks
104
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
105
-            // don't know if theme uses the_excerpt
106
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
107
-            // or the_content
108
-            add_filter('the_content', array($this, 'venue_details'), 100);
109
-            // don't display entry meta because the existing theme will take care of that
110
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
111
-        }
112
-        return $template;
113
-    }
114
-
115
-
116
-    /**
117
-     * the_title
118
-     *
119
-     * @access public
120
-     * @param  string $title
121
-     * @return string
122
-     */
123
-    public function the_title($title = '')
124
-    {
125
-        return $title;
126
-    }
127
-
128
-
129
-    /**
130
-     *    venue_details
131
-     *
132
-     * @access public
133
-     * @param  string $content
134
-     * @return string
135
-     */
136
-    public function venue_details($content)
137
-    {
138
-        global $post;
139
-        if (
140
-            $post->post_type == EspressoPostType::VENUES
141
-            && ! post_password_required()
142
-        ) {
143
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
144
-            // it uses the_content() for displaying the $post->post_content
145
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
146
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
147
-            remove_filter('the_excerpt', array($this, 'venue_details'), 100);
148
-            remove_filter('the_content', array($this, 'venue_details'), 100);
149
-            // add filters we want
150
-            add_filter('the_content', array($this, 'venue_location'), 110);
151
-            add_filter('the_excerpt', array($this, 'venue_location'), 110);
152
-            // now load our template
153
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
154
-            // now add our filter back in, plus some others
155
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
156
-            add_filter('the_content', array($this, 'venue_details'), 100);
157
-            // remove other filters we added so they won't get applied to the next post
158
-            remove_filter('the_content', array($this, 'venue_location'), 110);
159
-            remove_filter('the_excerpt', array($this, 'venue_location'), 110);
160
-            // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
161
-        }
162
-        return ! empty($template) ? $template : $content;
163
-    }
164
-
165
-
166
-    /**
167
-     * venue_location
168
-     *
169
-     * @access public
170
-     * @param  string $content
171
-     * @return string
172
-     */
173
-    public function venue_location($content)
174
-    {
175
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
176
-    }
177
-
178
-
179
-    /**
180
-     *    wp_enqueue_scripts
181
-     *
182
-     * @access    public
183
-     * @return    void
184
-     */
185
-    public function wp_enqueue_scripts()
186
-    {
187
-        // get some style
188
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
189
-            // first check theme folder
190
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
191
-                wp_register_style(
192
-                    $this->theme,
193
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
194
-                    array('dashicons', 'espresso_default')
195
-                );
196
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
197
-                wp_register_style(
198
-                    $this->theme,
199
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
200
-                    array('dashicons', 'espresso_default')
201
-                );
202
-            }
203
-            wp_enqueue_style($this->theme);
204
-        }
205
-    }
32
+	/**
33
+	 * @return EED_Venues_Archive
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EED_Module::registerRoute(
57
+			$custom_post_types[ EspressoPostType::VENUES ]['plural_slug'],
58
+			'Venues_Archive',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (
99
+			EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
100
+								   ->get_selected_template() != 'archive-espresso_venues.php'
101
+		) {
102
+			EEH_Template::load_espresso_theme_functions();
103
+			// then add extra event data via hooks
104
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
105
+			// don't know if theme uses the_excerpt
106
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
107
+			// or the_content
108
+			add_filter('the_content', array($this, 'venue_details'), 100);
109
+			// don't display entry meta because the existing theme will take care of that
110
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
111
+		}
112
+		return $template;
113
+	}
114
+
115
+
116
+	/**
117
+	 * the_title
118
+	 *
119
+	 * @access public
120
+	 * @param  string $title
121
+	 * @return string
122
+	 */
123
+	public function the_title($title = '')
124
+	{
125
+		return $title;
126
+	}
127
+
128
+
129
+	/**
130
+	 *    venue_details
131
+	 *
132
+	 * @access public
133
+	 * @param  string $content
134
+	 * @return string
135
+	 */
136
+	public function venue_details($content)
137
+	{
138
+		global $post;
139
+		if (
140
+			$post->post_type == EspressoPostType::VENUES
141
+			&& ! post_password_required()
142
+		) {
143
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
144
+			// it uses the_content() for displaying the $post->post_content
145
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
146
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
147
+			remove_filter('the_excerpt', array($this, 'venue_details'), 100);
148
+			remove_filter('the_content', array($this, 'venue_details'), 100);
149
+			// add filters we want
150
+			add_filter('the_content', array($this, 'venue_location'), 110);
151
+			add_filter('the_excerpt', array($this, 'venue_location'), 110);
152
+			// now load our template
153
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
154
+			// now add our filter back in, plus some others
155
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
156
+			add_filter('the_content', array($this, 'venue_details'), 100);
157
+			// remove other filters we added so they won't get applied to the next post
158
+			remove_filter('the_content', array($this, 'venue_location'), 110);
159
+			remove_filter('the_excerpt', array($this, 'venue_location'), 110);
160
+			// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
161
+		}
162
+		return ! empty($template) ? $template : $content;
163
+	}
164
+
165
+
166
+	/**
167
+	 * venue_location
168
+	 *
169
+	 * @access public
170
+	 * @param  string $content
171
+	 * @return string
172
+	 */
173
+	public function venue_location($content)
174
+	{
175
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
176
+	}
177
+
178
+
179
+	/**
180
+	 *    wp_enqueue_scripts
181
+	 *
182
+	 * @access    public
183
+	 * @return    void
184
+	 */
185
+	public function wp_enqueue_scripts()
186
+	{
187
+		// get some style
188
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
189
+			// first check theme folder
190
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
191
+				wp_register_style(
192
+					$this->theme,
193
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
194
+					array('dashicons', 'espresso_default')
195
+				);
196
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
197
+				wp_register_style(
198
+					$this->theme,
199
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
200
+					array('dashicons', 'espresso_default')
201
+				);
202
+			}
203
+			wp_enqueue_style($this->theme);
204
+		}
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         );
55 55
         $custom_post_types = $custom_post_type_definitions->getDefinitions();
56 56
         EED_Module::registerRoute(
57
-            $custom_post_types[ EspressoPostType::VENUES ]['plural_slug'],
57
+            $custom_post_types[EspressoPostType::VENUES]['plural_slug'],
58 58
             'Venues_Archive',
59 59
             'run'
60 60
         );
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function venue_location($content)
174 174
     {
175
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
175
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
176 176
     }
177 177
 
178 178
 
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
         // get some style
188 188
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
189 189
             // first check theme folder
190
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
190
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
191 191
                 wp_register_style(
192 192
                     $this->theme,
193
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
193
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
194 194
                     array('dashicons', 'espresso_default')
195 195
                 );
196
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
196
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
197 197
                 wp_register_style(
198 198
                     $this->theme,
199
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
199
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
200 200
                     array('dashicons', 'espresso_default')
201 201
                 );
202 202
             }
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +1052 added lines, -1052 removed lines patch added patch discarded remove patch
@@ -17,1047 +17,1047 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class EED_Events_Archive extends EED_Module
19 19
 {
20
-    const EVENT_DETAILS_PRIORITY   = 100;
21
-
22
-    const EVENT_DATETIMES_PRIORITY = 110;
23
-
24
-    const EVENT_TICKETS_PRIORITY   = 120;
25
-
26
-    const EVENT_VENUES_PRIORITY    = 130;
27
-
28
-
29
-    public static $espresso_event_list_ID    = 0;
30
-
31
-    public static $espresso_grid_event_lists = [];
32
-
33
-    /**
34
-     * @type bool $using_get_the_excerpt
35
-     */
36
-    protected static $using_get_the_excerpt = false;
37
-
38
-    /**
39
-     * Used to flag when the event list is being called from an external iframe.
40
-     *
41
-     * @var bool $iframe
42
-     */
43
-    protected static $iframe = false;
44
-
45
-    /**
46
-     * @var EventListIframeEmbedButton $_iframe_embed_button
47
-     */
48
-    private static $_iframe_embed_button;
49
-
50
-    /**
51
-     * @type EE_Template_Part_Manager $template_parts
52
-     */
53
-    protected $template_parts;
54
-
55
-
56
-    /**
57
-     * @return EED_Events_Archive
58
-     * @throws EE_Error
59
-     * @throws ReflectionException
60
-     */
61
-    public static function instance()
62
-    {
63
-        return parent::get_instance(__CLASS__);
64
-    }
65
-
66
-
67
-    /**
68
-     * for hooking into EE Core, other modules, etc
69
-     *
70
-     * @return void
71
-     * @throws InvalidArgumentException
72
-     * @throws InvalidDataTypeException
73
-     * @throws InvalidInterfaceException
74
-     */
75
-    public static function set_hooks()
76
-    {
77
-        /** @var CustomPostTypeDefinitions $custom_post_type_definitions */
78
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(CustomPostTypeDefinitions::class);
79
-        $custom_post_types            = $custom_post_type_definitions->getDefinitions();
80
-        EED_Module::registerRoute(
81
-            $custom_post_types[ EspressoPostType::EVENTS ]['plural_slug'],
82
-            'Events_Archive',
83
-            'run'
84
-        );
85
-        EED_Module::registerRoute(
86
-            'event_list',
87
-            'Events_Archive',
88
-            'event_list'
89
-        );
90
-        EED_Module::registerRoute(
91
-            'iframe',
92
-            'Events_Archive',
93
-            'event_list_iframe',
94
-            'event_list'
95
-        );
96
-        add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2);
97
-    }
98
-
99
-
100
-    /**
101
-     * for hooking into EE Admin Core, other modules, etc
102
-     *
103
-     * @return void
104
-     */
105
-    public static function set_hooks_admin()
106
-    {
107
-        add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2);
108
-        // hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
-        // to load assets for "espresso_events" page on the "default" route (action)
110
-        add_action(
111
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
-            ['EED_Events_Archive', 'event_list_iframe_embed_button'],
113
-            10
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * @return void
120
-     */
121
-    public static function set_definitions()
122
-    {
123
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
125
-    }
126
-
127
-
128
-    /**
129
-     * set up EE_Events_Archive_Config
130
-     */
131
-    protected function set_config()
132
-    {
133
-        $this->set_config_section('template_settings');
134
-        $this->set_config_class('EE_Events_Archive_Config');
135
-        $this->set_config_name('EED_Events_Archive');
136
-    }
137
-
138
-
139
-    /**
140
-     * @return EventListIframeEmbedButton
141
-     */
142
-    public static function get_iframe_embed_button()
143
-    {
144
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
145
-            self::$_iframe_embed_button = new EventListIframeEmbedButton();
146
-        }
147
-        return self::$_iframe_embed_button;
148
-    }
149
-
150
-
151
-    /**
152
-     * @return void
153
-     */
154
-    public static function event_list_iframe_embed_button()
155
-    {
156
-        $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
157
-        $iframe_embed_button->addEmbedButton();
158
-    }
159
-
160
-
161
-    /**
162
-     * @param EE_Events_Archive_Config|null $config
163
-     * @return EE_Template_Part_Manager
164
-     * @throws EE_Error
165
-     */
166
-    public function initialize_template_parts(EE_Events_Archive_Config $config = null)
167
-    {
168
-        $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
169
-        EEH_Autoloader::register_template_part_autoloaders();
170
-        $template_parts = new EE_Template_Part_Manager();
171
-        $template_parts->add_template_part(
172
-            'tickets',
173
-            esc_html__('Ticket Selector', 'event_espresso'),
174
-            'content-espresso_events-tickets.php',
175
-            $config->display_order_tickets
176
-        );
177
-        $template_parts->add_template_part(
178
-            'datetimes',
179
-            esc_html__('Dates and Times', 'event_espresso'),
180
-            'content-espresso_events-datetimes.php',
181
-            $config->display_order_datetimes
182
-        );
183
-        $template_parts->add_template_part(
184
-            'event',
185
-            esc_html__('Event Description', 'event_espresso'),
186
-            'content-espresso_events-details.php',
187
-            $config->display_order_event
188
-        );
189
-        $template_parts->add_template_part(
190
-            'venue',
191
-            esc_html__('Venue Information', 'event_espresso'),
192
-            'content-espresso_events-venues.php',
193
-            $config->display_order_venue
194
-        );
195
-        do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
196
-        return $template_parts;
197
-    }
198
-
199
-
200
-    /**
201
-     * initial module setup
202
-     * this gets called by the EE_Front_Controller if the module route is found in the incoming request
203
-     *
204
-     * @param WP $WP
205
-     * @return void
206
-     */
207
-    public function run($WP)
208
-    {
209
-        do_action('AHEE__EED_Events_Archive__before_run');
210
-        // ensure valid EE_Events_Archive_Config() object exists
211
-        $this->set_config();
212
-        /** @type EE_Events_Archive_Config $config */
213
-        $config = $this->config();
214
-        // load other required components
215
-        $this->load_event_list_assets();
216
-        // filter the WP posts_join, posts_where, and posts_orderby SQL clauses
217
-        // add query filters
218
-        EEH_Event_Query::add_query_filters();
219
-        // set params that will get used by the filters
220
-        EEH_Event_Query::set_query_params(
221
-            '',                             // month
222
-            '',                             // category
223
-            $config->display_expired_events // show_expired
224
-        );
225
-        // check what template is loaded
226
-        add_filter('template_include', [$this, 'template_include'], 999, 1);
227
-    }
228
-
229
-
230
-    /**
231
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
232
-     *
233
-     * @return void
234
-     */
235
-    public function event_list()
236
-    {
237
-        // ensure valid EE_Events_Archive_Config() object exists
238
-        $this->set_config();
239
-        // load other required components
240
-        $this->load_event_list_assets();
241
-    }
242
-
243
-
244
-    /**
245
-     * @return void
246
-     * @throws EE_Error
247
-     * @throws ReflectionException
248
-     */
249
-    public function event_list_iframe()
250
-    {
251
-        EED_Events_Archive::$iframe = true;
252
-        $event_list_iframe          = new EventsArchiveIframe($this);
253
-        $event_list_iframe->display();
254
-    }
255
-
256
-
257
-    /**
258
-     * @return bool
259
-     */
260
-    public static function is_iframe()
261
-    {
262
-        return EED_Events_Archive::$iframe;
263
-    }
264
-
265
-
266
-    /**
267
-     * @return string
268
-     */
269
-    public static function link_target()
270
-    {
271
-        return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
272
-    }
273
-
274
-
275
-    /**
276
-     * @param string $template
277
-     * @return string
278
-     * @throws EE_Error
279
-     * @throws ReflectionException
280
-     */
281
-    public function template_include($template = '')
282
-    {
283
-        // don't add content filter for dedicated EE child themes or private posts
284
-        if (! EEH_Template::is_espresso_theme()) {
285
-            /** @type EE_Events_Archive_Config $config */
286
-            $config = $this->config();
287
-            // add status banner ?
288
-            if ($config->display_status_banner) {
289
-                add_filter('the_title', ['EED_Events_Archive', 'the_title'], 100, 2);
290
-            }
291
-            // if NOT a custom template
292
-            if (
293
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
294
-                || EE_Registry::instance()
295
-                              ->load_core('Front_Controller')
296
-                              ->get_selected_template() !== 'archive-espresso_events.php'
297
-            ) {
298
-                add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
299
-                // load functions.php file for the theme (loaded by WP if using child theme)
300
-                EEH_Template::load_espresso_theme_functions();
301
-                EED_Events_Archive::addEventDetailsFilters();
302
-                // don't display entry meta because the existing theme will take care of that
303
-                add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
304
-            }
305
-        }
306
-        return $template;
307
-    }
308
-
309
-
310
-    /**
311
-     * kinda hacky, but if a theme is using get_the_excerpt(),
312
-     * then we need to remove our filters on the_content()
313
-     *
314
-     * @param string $excerpt
315
-     * @return string
316
-     * @throws EE_Error
317
-     * @throws ReflectionException
318
-     */
319
-    public static function get_the_excerpt($excerpt = '')
320
-    {
321
-        if (post_password_required()) {
322
-            return $excerpt;
323
-        }
324
-        if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
325
-            EED_Events_Archive::removeEventDetailsFilters(false);
326
-            $excerpt = EED_Events_Archive::event_details($excerpt);
327
-        } else {
328
-            EED_Events_Archive::$using_get_the_excerpt = true;
329
-            add_filter('wp_trim_excerpt', ['EED_Events_Archive', 'end_get_the_excerpt'], 999, 1);
330
-        }
331
-        return $excerpt;
332
-    }
333
-
334
-
335
-    /**
336
-     * @param string $text
337
-     * @return string
338
-     */
339
-    public static function end_get_the_excerpt($text = '')
340
-    {
341
-        EED_Events_Archive::$using_get_the_excerpt = false;
342
-        return $text;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $title
348
-     * @param string $id
349
-     * @return string
350
-     * @throws EE_Error
351
-     * @throws ReflectionException
352
-     */
353
-    public static function the_title($title = '', $id = '')
354
-    {
355
-        global $post;
356
-        if ($post instanceof WP_Post) {
357
-            return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id
358
-                ? espresso_event_status_banner($post->ID) . $title
359
-                : $title;
360
-        }
361
-        return $title;
362
-    }
363
-
364
-
365
-    /**
366
-     * @param string $content
367
-     * @return string
368
-     * @throws EE_Error
369
-     * @throws ReflectionException
370
-     */
371
-    public static function event_details($content)
372
-    {
373
-        global $post;
374
-        static $current_post_ID = 0;
375
-        if (
376
-            $current_post_ID !== $post->ID
377
-            && $post->post_type === EspressoPostType::EVENTS
378
-            && ! EED_Events_Archive::$using_get_the_excerpt
379
-            && ! post_password_required()
380
-            && (
381
-                apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
382
-                || ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
383
-            )
384
-        ) {
385
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
386
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
387
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
388
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
389
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
390
-            // so the following allows this filter to be applied multiple times, but only once for real
391
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
392
-            if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
393
-                $content = EED_Events_Archive::use_sortable_display_order();
394
-            } else {
395
-                $content = EED_Events_Archive::use_filterable_display_order();
396
-            }
397
-        }
398
-        return $content;
399
-    }
400
-
401
-
402
-    /**
403
-     * @return string
404
-     * @throws EE_Error
405
-     * @throws ReflectionException
406
-     */
407
-    protected static function use_sortable_display_order()
408
-    {
409
-        // no further password checks required atm
410
-        add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
411
-        // remove this callback from being applied to the_content()
412
-        EED_Events_Archive::removeEventDetailsFilters();
413
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
414
-        EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
415
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
416
-        $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
417
-        // re-add our main filters (or else the next event won't have them)
418
-        EED_Events_Archive::addEventDetailsFilters();
419
-        remove_filter(
420
-            'FHEE__EED_Events_Archive__event_details__no_post_password_required',
421
-            '__return_true'
422
-        );
423
-        return $content;
424
-    }
425
-
426
-
427
-    /**
428
-     * @return string
429
-     */
430
-    protected static function use_filterable_display_order()
431
-    {
432
-        // remove this callback from being applied to the_content()
433
-        EED_Events_Archive::removeEventDetailsFilters();
434
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
435
-        EED_Events_Archive::_add_additional_excerpt_filters();
436
-        EED_Events_Archive::_add_additional_content_filters();
437
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
438
-        // now load our template
439
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
440
-        // re-add our main filters (or else the next event won't have them)
441
-        EED_Events_Archive::addEventDetailsFilters();
442
-        // but remove the other filters so that they don't get applied to the next post
443
-        EED_Events_Archive::_remove_additional_events_archive_filters();
444
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
445
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
446
-        // return ! empty( $template ) ? $template : $content;
447
-        return $content;
448
-    }
449
-
450
-
451
-    /**
452
-     * adds datetimes ABOVE content
453
-     *
454
-     * @param string $content
455
-     * @return string
456
-     */
457
-    public static function event_datetimes($content)
458
-    {
459
-        if (post_password_required()) {
460
-            return $content;
461
-        }
462
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
463
-    }
464
-
465
-
466
-    /**
467
-     * adds tickets ABOVE content (which includes datetimes)
468
-     *
469
-     * @param string $content
470
-     * @return string
471
-     */
472
-    public static function event_tickets($content)
473
-    {
474
-        if (post_password_required()) {
475
-            return $content;
476
-        }
477
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
478
-    }
479
-
480
-
481
-    /**
482
-     * adds venues BELOW content
483
-     *
484
-     * @param string $content
485
-     * @return string
486
-     */
487
-    public static function event_venue($content)
488
-    {
489
-        return EED_Events_Archive::event_venues($content);
490
-    }
491
-
492
-
493
-    /**
494
-     * adds venues BELOW content
495
-     *
496
-     * @param string $content
497
-     * @return string
498
-     */
499
-    public static function event_venues($content)
500
-    {
501
-        if (post_password_required()) {
502
-            return $content;
503
-        }
504
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
505
-    }
506
-
507
-
508
-    /**
509
-     * @return bool
510
-     * @since 4.10.33.p
511
-     */
512
-    public static function isBlockTheme()
513
-    {
514
-        return function_exists('wp_is_block_theme') && wp_is_block_theme();
515
-    }
516
-
517
-
518
-    /**
519
-     * @return string
520
-     * @since 4.10.33.p
521
-     */
522
-    public static function getExcerptFilter()
523
-    {
524
-        static $excerpt_filter = null;
525
-        if ($excerpt_filter === null) {
526
-            $excerpt_filter = EED_Events_Archive::isBlockTheme() ? 'get_the_excerpt' : 'the_excerpt';
527
-        }
528
-        return $excerpt_filter;
529
-    }
530
-
531
-
532
-    /**
533
-     * @since 4.10.33.p
534
-     */
535
-    protected static function addEventDetailsFilters()
536
-    {
537
-        add_filter(
538
-            'the_content',
539
-            ['EED_Events_Archive', 'event_details'],
540
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
541
-        );
542
-        // but because we don't know if the theme is using the_excerpt()
543
-        add_filter(
544
-            EED_Events_Archive::getExcerptFilter(),
545
-            ['EED_Events_Archive', 'event_details'],
546
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
547
-        );
548
-        // and just in case they are running get_the_excerpt() which DESTROYS things
549
-        add_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1, 1);
550
-    }
551
-
552
-
553
-    /**
554
-     * @param bool $and_get_the_excerpt
555
-     * @since 4.10.33.p
556
-     */
557
-    protected static function removeEventDetailsFilters($and_get_the_excerpt = true)
558
-    {
559
-        // we need to first remove all callbacks from being applied to the_content()
560
-        // (otherwise it will recurse and blow up the interweb)
561
-        remove_filter(
562
-            'the_content',
563
-            ['EED_Events_Archive', 'event_details'],
564
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
565
-        );
566
-        remove_filter(
567
-            EED_Events_Archive::getExcerptFilter(),
568
-            ['EED_Events_Archive', 'event_details'],
569
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
570
-        );
571
-        if ($and_get_the_excerpt) {
572
-            remove_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1);
573
-        }
574
-    }
575
-
576
-
577
-    /**
578
-     * @return void
579
-     */
580
-    private static function _add_additional_excerpt_filters()
581
-    {
582
-        add_filter(
583
-            EED_Events_Archive::getExcerptFilter(),
584
-            ['EED_Events_Archive', 'event_datetimes'],
585
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
586
-        );
587
-        add_filter(
588
-            EED_Events_Archive::getExcerptFilter(),
589
-            ['EED_Events_Archive', 'event_tickets'],
590
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
591
-        );
592
-        add_filter(
593
-            EED_Events_Archive::getExcerptFilter(),
594
-            ['EED_Events_Archive', 'event_venues'],
595
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
596
-        );
597
-    }
598
-
599
-
600
-    /**
601
-     * @return void
602
-     */
603
-    private static function _add_additional_content_filters()
604
-    {
605
-        add_filter(
606
-            'the_content',
607
-            ['EED_Events_Archive', 'event_datetimes'],
608
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
609
-        );
610
-        add_filter(
611
-            'the_content',
612
-            ['EED_Events_Archive', 'event_tickets'],
613
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
614
-        );
615
-        add_filter(
616
-            'the_content',
617
-            ['EED_Events_Archive', 'event_venues'],
618
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
619
-        );
620
-    }
621
-
622
-
623
-    /**
624
-     * @return void
625
-     */
626
-    private static function _remove_additional_events_archive_filters()
627
-    {
628
-        remove_filter(
629
-            EED_Events_Archive::getExcerptFilter(),
630
-            ['EED_Events_Archive', 'event_datetimes'],
631
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
-        );
633
-        remove_filter(
634
-            EED_Events_Archive::getExcerptFilter(),
635
-            ['EED_Events_Archive', 'event_tickets'],
636
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
-        );
638
-        remove_filter(
639
-            EED_Events_Archive::getExcerptFilter(),
640
-            ['EED_Events_Archive', 'event_venues'],
641
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
642
-        );
643
-        remove_filter(
644
-            'the_content',
645
-            ['EED_Events_Archive', 'event_datetimes'],
646
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
-        );
648
-        remove_filter(
649
-            'the_content',
650
-            ['EED_Events_Archive', 'event_tickets'],
651
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
-        );
653
-        remove_filter(
654
-            'the_content',
655
-            ['EED_Events_Archive', 'event_venues'],
656
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
657
-        );
658
-    }
659
-
660
-
661
-    /**
662
-     * @return void
663
-     */
664
-    public static function remove_all_events_archive_filters()
665
-    {
666
-        // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
667
-        remove_filter('the_title', ['EED_Events_Archive', 'the_title'], 1);
668
-        remove_filter(
669
-            EED_Events_Archive::getExcerptFilter(),
670
-            ['EED_Events_Archive', 'event_details'],
671
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
672
-        );
673
-        remove_filter(
674
-            EED_Events_Archive::getExcerptFilter(),
675
-            ['EED_Events_Archive', 'event_datetimes'],
676
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
677
-        );
678
-        remove_filter(
679
-            EED_Events_Archive::getExcerptFilter(),
680
-            ['EED_Events_Archive', 'event_tickets'],
681
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
682
-        );
683
-        remove_filter(
684
-            EED_Events_Archive::getExcerptFilter(),
685
-            ['EED_Events_Archive', 'event_venues'],
686
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
687
-        );
688
-        remove_filter(
689
-            'the_content',
690
-            ['EED_Events_Archive', 'event_details'],
691
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
692
-        );
693
-        remove_filter(
694
-            'the_content',
695
-            ['EED_Events_Archive', 'event_datetimes'],
696
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
697
-        );
698
-        remove_filter(
699
-            'the_content',
700
-            ['EED_Events_Archive', 'event_tickets'],
701
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
702
-        );
703
-        remove_filter(
704
-            'the_content',
705
-            ['EED_Events_Archive', 'event_venues'],
706
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
707
-        );
708
-        // don't display entry meta because the existing theme will take care of that
709
-        remove_filter(
710
-            'FHEE__content_espresso_events_details_template__display_entry_meta',
711
-            '__return_false'
712
-        );
713
-    }
714
-
715
-
716
-    /**
717
-     * @return void
718
-     */
719
-    public function load_event_list_assets()
720
-    {
721
-        do_action('AHEE__EED_Events_Archive__before_load_assets');
722
-        add_filter('FHEE_load_EE_Session', '__return_true');
723
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
724
-        add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts'], 10);
725
-        if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
726
-            add_action('wp_enqueue_scripts', ['EEH_Maps', 'espresso_google_map_js'], 11);
727
-        }
728
-    }
729
-
730
-
731
-    /**
732
-     * @return void
733
-     * @throws EE_Error
734
-     */
735
-    public function wp_enqueue_scripts()
736
-    {
737
-        // get some style
738
-        if (apply_filters('FHEE_enable_default_espresso_css', false)) {
739
-            // first check uploads folder
740
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
741
-                wp_register_style(
742
-                    $this->theme,
743
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
744
-                    ['dashicons', 'espresso_default']
745
-                );
746
-            }
747
-            wp_enqueue_style($this->theme);
748
-        }
749
-    }
750
-
751
-
752
-    /**
753
-     * @static
754
-     * @return void
755
-     */
756
-    public static function template_settings_form()
757
-    {
758
-        $template_settings                     = EE_Registry::instance()->CFG->template_settings;
759
-        $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
760
-            ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
761
-        $template_settings->EED_Events_Archive = apply_filters(
762
-            'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
763
-            $template_settings->EED_Events_Archive
764
-        );
765
-        $events_archive_settings               = [
766
-            'display_status_banner'   => 0,
767
-            'display_description'     => 1,
768
-            'display_ticket_selector' => 0,
769
-            'display_datetimes'       => 1,
770
-            'display_venue'           => 0,
771
-            'display_expired_events'  => 0,
772
-        ];
773
-        $events_archive_settings               = array_merge(
774
-            $events_archive_settings,
775
-            (array) $template_settings->EED_Events_Archive
776
-        );
777
-        EEH_Template::display_template(
778
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
779
-            $events_archive_settings
780
-        );
781
-    }
782
-
783
-
784
-    /**
785
-     * @param EE_Template_Config $CFG
786
-     * @param array              $REQ
787
-     * @return EE_Template_Config
788
-     */
789
-    public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config
790
-    {
791
-        $CFG->EED_Events_Archive = new EE_Events_Archive_Config();
792
-        // unless we are resetting the config...
793
-        if (
794
-            ! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
795
-            || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
796
-        ) {
797
-            $CFG->EED_Events_Archive->display_status_banner   = isset($REQ['EED_Events_Archive_display_status_banner'])
798
-                ? absint($REQ['EED_Events_Archive_display_status_banner'])
799
-                : 0;
800
-            $CFG->EED_Events_Archive->display_description     = isset($REQ['EED_Events_Archive_display_description'])
801
-                ? absint($REQ['EED_Events_Archive_display_description'])
802
-                : 1;
803
-            $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
804
-                ? absint($REQ['EED_Events_Archive_display_ticket_selector'])
805
-                : 0;
806
-            $CFG->EED_Events_Archive->display_datetimes       = isset($REQ['EED_Events_Archive_display_datetimes'])
807
-                ? absint($REQ['EED_Events_Archive_display_datetimes'])
808
-                : 1;
809
-            $CFG->EED_Events_Archive->display_venue           = isset($REQ['EED_Events_Archive_display_venue'])
810
-                ? absint($REQ['EED_Events_Archive_display_venue'])
811
-                : 0;
812
-            $CFG->EED_Events_Archive->display_expired_events  = isset($REQ['EED_Events_Archive_display_expired_events'])
813
-                ? absint($REQ['EED_Events_Archive_display_expired_events'])
814
-                : 0;
815
-        }
816
-        return $CFG;
817
-    }
818
-
819
-
820
-    /**
821
-     * @param string $extra_class
822
-     * @return string
823
-     */
824
-    public static function event_list_css($extra_class = '')
825
-    {
826
-        $event_list_css   = ! empty($extra_class) ? [$extra_class] : [];
827
-        $event_list_css[] = 'espresso-event-list-event';
828
-        return implode(' ', $event_list_css);
829
-    }
830
-
831
-
832
-    /**
833
-     * @return array
834
-     * @throws EE_Error
835
-     * @throws ReflectionException
836
-     */
837
-    public static function event_categories()
838
-    {
839
-        return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
840
-    }
841
-
842
-
843
-    /**
844
-     * @param $value
845
-     * @return bool
846
-     */
847
-    public static function display_description($value)
848
-    {
849
-        $config              = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
850
-        $display_description = isset($config->display_description) ? $config->display_description : 1;
851
-        return $display_description === $value;
852
-    }
853
-
854
-
855
-    /**
856
-     * @return bool
857
-     */
858
-    public static function display_ticket_selector()
859
-    {
860
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
861
-        return isset($config->display_ticket_selector) && $config->display_ticket_selector;
862
-    }
863
-
864
-
865
-    /**
866
-     * @return bool
867
-     * @throws EE_Error
868
-     * @throws ReflectionException
869
-     */
870
-    public static function display_venue()
871
-    {
872
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
873
-        return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name();
874
-    }
875
-
876
-
877
-    /**
878
-     * @return bool
879
-     */
880
-    public static function display_datetimes()
881
-    {
882
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
883
-        return isset($config->display_datetimes) && $config->display_datetimes;
884
-    }
885
-
886
-
887
-    /**
888
-     * @return string
889
-     */
890
-    public static function event_list_title()
891
-    {
892
-        return apply_filters(
893
-            'FHEE__archive_espresso_events_template__upcoming_events_h1',
894
-            esc_html__('Upcoming Events', 'event_espresso')
895
-        );
896
-    }
897
-
898
-
899
-    // GRAVEYARD
900
-
901
-
902
-    /**
903
-     * @since 4.4.0
904
-     */
905
-    public static function _doing_it_wrong_notice($function = '')
906
-    {
907
-        EE_Error::doing_it_wrong(
908
-            __FUNCTION__,
909
-            sprintf(
910
-                esc_html__(
911
-                    'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s',
912
-                    'event_espresso'
913
-                ),
914
-                $function,
915
-                '<br />',
916
-                '4.6.0'
917
-            ),
918
-            '4.4.0'
919
-        );
920
-    }
921
-
922
-
923
-    /**
924
-     * @deprecated
925
-     * @since 4.4.0
926
-     */
927
-    public function get_post_data()
928
-    {
929
-        EEH_Event_Query::set_query_params();
930
-    }
931
-
932
-
933
-    /**
934
-     * @throws EE_Error
935
-     * @since 4.4.0
936
-     * @deprecated
937
-     */
938
-    public function posts_fields($SQL, WP_Query $wp_query)
939
-    {
940
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
941
-        return EEH_Event_Query::posts_fields($SQL, $wp_query);
942
-    }
943
-
944
-
945
-    /**
946
-     * @throws EE_Error
947
-     * @since 4.4.0
948
-     * @deprecated
949
-     */
950
-    public static function posts_fields_sql_for_orderby($orderby_params = [])
951
-    {
952
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
953
-        return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
954
-    }
955
-
956
-
957
-    /**
958
-     * @throws EE_Error
959
-     * @since 4.4.0
960
-     * @deprecated
961
-     */
962
-    public function posts_join($SQL, WP_Query $wp_query)
963
-    {
964
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
965
-        return EEH_Event_Query::posts_join($SQL, $wp_query);
966
-    }
967
-
968
-
969
-    /**
970
-     * @deprecated
971
-     * @since 4.4.0
972
-     */
973
-    public static function posts_join_sql_for_terms($join_terms = null)
974
-    {
975
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
976
-        return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
977
-    }
978
-
979
-
980
-    /**
981
-     * @throws EE_Error
982
-     * @since 4.4.0
983
-     * @deprecated
984
-     */
985
-    public static function posts_join_for_orderby($orderby_params = [])
986
-    {
987
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
988
-        return EEH_Event_Query::posts_join_for_orderby($orderby_params);
989
-    }
990
-
991
-
992
-    /**
993
-     * @throws EE_Error
994
-     * @since 4.4.0
995
-     * @deprecated
996
-     */
997
-    public function posts_where($SQL, WP_Query $wp_query)
998
-    {
999
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1000
-        return EEH_Event_Query::posts_where($SQL, $wp_query);
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * @throws EE_Error
1006
-     * @since 4.4.0
1007
-     * @deprecated
1008
-     */
1009
-    public static function posts_where_sql_for_show_expired($show_expired = false)
1010
-    {
1011
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1012
-        return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1013
-    }
1014
-
1015
-
1016
-    /**
1017
-     * @deprecated
1018
-     * @since 4.4.0
1019
-     */
1020
-    public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1021
-    {
1022
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1023
-        return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1024
-    }
1025
-
1026
-
1027
-    /**
1028
-     * @throws EE_Error
1029
-     * @since 4.4.0
1030
-     * @deprecated
1031
-     */
1032
-    public static function posts_where_sql_for_event_list_month($month = null)
1033
-    {
1034
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1035
-        return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * @throws EE_Error
1041
-     * @since 4.4.0
1042
-     * @deprecated
1043
-     */
1044
-    public function posts_orderby($SQL, WP_Query $wp_query)
1045
-    {
1046
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1047
-        return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1048
-    }
1049
-
1050
-
1051
-    /**
1052
-     * @throws EE_Error
1053
-     * @since 4.4.0
1054
-     * @deprecated
1055
-     */
1056
-    public static function posts_orderby_sql($orderby_params = [], $sort = 'ASC')
1057
-    {
1058
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1059
-        return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1060
-    }
20
+	const EVENT_DETAILS_PRIORITY   = 100;
21
+
22
+	const EVENT_DATETIMES_PRIORITY = 110;
23
+
24
+	const EVENT_TICKETS_PRIORITY   = 120;
25
+
26
+	const EVENT_VENUES_PRIORITY    = 130;
27
+
28
+
29
+	public static $espresso_event_list_ID    = 0;
30
+
31
+	public static $espresso_grid_event_lists = [];
32
+
33
+	/**
34
+	 * @type bool $using_get_the_excerpt
35
+	 */
36
+	protected static $using_get_the_excerpt = false;
37
+
38
+	/**
39
+	 * Used to flag when the event list is being called from an external iframe.
40
+	 *
41
+	 * @var bool $iframe
42
+	 */
43
+	protected static $iframe = false;
44
+
45
+	/**
46
+	 * @var EventListIframeEmbedButton $_iframe_embed_button
47
+	 */
48
+	private static $_iframe_embed_button;
49
+
50
+	/**
51
+	 * @type EE_Template_Part_Manager $template_parts
52
+	 */
53
+	protected $template_parts;
54
+
55
+
56
+	/**
57
+	 * @return EED_Events_Archive
58
+	 * @throws EE_Error
59
+	 * @throws ReflectionException
60
+	 */
61
+	public static function instance()
62
+	{
63
+		return parent::get_instance(__CLASS__);
64
+	}
65
+
66
+
67
+	/**
68
+	 * for hooking into EE Core, other modules, etc
69
+	 *
70
+	 * @return void
71
+	 * @throws InvalidArgumentException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws InvalidInterfaceException
74
+	 */
75
+	public static function set_hooks()
76
+	{
77
+		/** @var CustomPostTypeDefinitions $custom_post_type_definitions */
78
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(CustomPostTypeDefinitions::class);
79
+		$custom_post_types            = $custom_post_type_definitions->getDefinitions();
80
+		EED_Module::registerRoute(
81
+			$custom_post_types[ EspressoPostType::EVENTS ]['plural_slug'],
82
+			'Events_Archive',
83
+			'run'
84
+		);
85
+		EED_Module::registerRoute(
86
+			'event_list',
87
+			'Events_Archive',
88
+			'event_list'
89
+		);
90
+		EED_Module::registerRoute(
91
+			'iframe',
92
+			'Events_Archive',
93
+			'event_list_iframe',
94
+			'event_list'
95
+		);
96
+		add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2);
97
+	}
98
+
99
+
100
+	/**
101
+	 * for hooking into EE Admin Core, other modules, etc
102
+	 *
103
+	 * @return void
104
+	 */
105
+	public static function set_hooks_admin()
106
+	{
107
+		add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2);
108
+		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
+		// to load assets for "espresso_events" page on the "default" route (action)
110
+		add_action(
111
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
+			['EED_Events_Archive', 'event_list_iframe_embed_button'],
113
+			10
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return void
120
+	 */
121
+	public static function set_definitions()
122
+	{
123
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
125
+	}
126
+
127
+
128
+	/**
129
+	 * set up EE_Events_Archive_Config
130
+	 */
131
+	protected function set_config()
132
+	{
133
+		$this->set_config_section('template_settings');
134
+		$this->set_config_class('EE_Events_Archive_Config');
135
+		$this->set_config_name('EED_Events_Archive');
136
+	}
137
+
138
+
139
+	/**
140
+	 * @return EventListIframeEmbedButton
141
+	 */
142
+	public static function get_iframe_embed_button()
143
+	{
144
+		if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
145
+			self::$_iframe_embed_button = new EventListIframeEmbedButton();
146
+		}
147
+		return self::$_iframe_embed_button;
148
+	}
149
+
150
+
151
+	/**
152
+	 * @return void
153
+	 */
154
+	public static function event_list_iframe_embed_button()
155
+	{
156
+		$iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
157
+		$iframe_embed_button->addEmbedButton();
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param EE_Events_Archive_Config|null $config
163
+	 * @return EE_Template_Part_Manager
164
+	 * @throws EE_Error
165
+	 */
166
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null)
167
+	{
168
+		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
169
+		EEH_Autoloader::register_template_part_autoloaders();
170
+		$template_parts = new EE_Template_Part_Manager();
171
+		$template_parts->add_template_part(
172
+			'tickets',
173
+			esc_html__('Ticket Selector', 'event_espresso'),
174
+			'content-espresso_events-tickets.php',
175
+			$config->display_order_tickets
176
+		);
177
+		$template_parts->add_template_part(
178
+			'datetimes',
179
+			esc_html__('Dates and Times', 'event_espresso'),
180
+			'content-espresso_events-datetimes.php',
181
+			$config->display_order_datetimes
182
+		);
183
+		$template_parts->add_template_part(
184
+			'event',
185
+			esc_html__('Event Description', 'event_espresso'),
186
+			'content-espresso_events-details.php',
187
+			$config->display_order_event
188
+		);
189
+		$template_parts->add_template_part(
190
+			'venue',
191
+			esc_html__('Venue Information', 'event_espresso'),
192
+			'content-espresso_events-venues.php',
193
+			$config->display_order_venue
194
+		);
195
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
196
+		return $template_parts;
197
+	}
198
+
199
+
200
+	/**
201
+	 * initial module setup
202
+	 * this gets called by the EE_Front_Controller if the module route is found in the incoming request
203
+	 *
204
+	 * @param WP $WP
205
+	 * @return void
206
+	 */
207
+	public function run($WP)
208
+	{
209
+		do_action('AHEE__EED_Events_Archive__before_run');
210
+		// ensure valid EE_Events_Archive_Config() object exists
211
+		$this->set_config();
212
+		/** @type EE_Events_Archive_Config $config */
213
+		$config = $this->config();
214
+		// load other required components
215
+		$this->load_event_list_assets();
216
+		// filter the WP posts_join, posts_where, and posts_orderby SQL clauses
217
+		// add query filters
218
+		EEH_Event_Query::add_query_filters();
219
+		// set params that will get used by the filters
220
+		EEH_Event_Query::set_query_params(
221
+			'',                             // month
222
+			'',                             // category
223
+			$config->display_expired_events // show_expired
224
+		);
225
+		// check what template is loaded
226
+		add_filter('template_include', [$this, 'template_include'], 999, 1);
227
+	}
228
+
229
+
230
+	/**
231
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
232
+	 *
233
+	 * @return void
234
+	 */
235
+	public function event_list()
236
+	{
237
+		// ensure valid EE_Events_Archive_Config() object exists
238
+		$this->set_config();
239
+		// load other required components
240
+		$this->load_event_list_assets();
241
+	}
242
+
243
+
244
+	/**
245
+	 * @return void
246
+	 * @throws EE_Error
247
+	 * @throws ReflectionException
248
+	 */
249
+	public function event_list_iframe()
250
+	{
251
+		EED_Events_Archive::$iframe = true;
252
+		$event_list_iframe          = new EventsArchiveIframe($this);
253
+		$event_list_iframe->display();
254
+	}
255
+
256
+
257
+	/**
258
+	 * @return bool
259
+	 */
260
+	public static function is_iframe()
261
+	{
262
+		return EED_Events_Archive::$iframe;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @return string
268
+	 */
269
+	public static function link_target()
270
+	{
271
+		return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param string $template
277
+	 * @return string
278
+	 * @throws EE_Error
279
+	 * @throws ReflectionException
280
+	 */
281
+	public function template_include($template = '')
282
+	{
283
+		// don't add content filter for dedicated EE child themes or private posts
284
+		if (! EEH_Template::is_espresso_theme()) {
285
+			/** @type EE_Events_Archive_Config $config */
286
+			$config = $this->config();
287
+			// add status banner ?
288
+			if ($config->display_status_banner) {
289
+				add_filter('the_title', ['EED_Events_Archive', 'the_title'], 100, 2);
290
+			}
291
+			// if NOT a custom template
292
+			if (
293
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
294
+				|| EE_Registry::instance()
295
+							  ->load_core('Front_Controller')
296
+							  ->get_selected_template() !== 'archive-espresso_events.php'
297
+			) {
298
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
299
+				// load functions.php file for the theme (loaded by WP if using child theme)
300
+				EEH_Template::load_espresso_theme_functions();
301
+				EED_Events_Archive::addEventDetailsFilters();
302
+				// don't display entry meta because the existing theme will take care of that
303
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
304
+			}
305
+		}
306
+		return $template;
307
+	}
308
+
309
+
310
+	/**
311
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
312
+	 * then we need to remove our filters on the_content()
313
+	 *
314
+	 * @param string $excerpt
315
+	 * @return string
316
+	 * @throws EE_Error
317
+	 * @throws ReflectionException
318
+	 */
319
+	public static function get_the_excerpt($excerpt = '')
320
+	{
321
+		if (post_password_required()) {
322
+			return $excerpt;
323
+		}
324
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
325
+			EED_Events_Archive::removeEventDetailsFilters(false);
326
+			$excerpt = EED_Events_Archive::event_details($excerpt);
327
+		} else {
328
+			EED_Events_Archive::$using_get_the_excerpt = true;
329
+			add_filter('wp_trim_excerpt', ['EED_Events_Archive', 'end_get_the_excerpt'], 999, 1);
330
+		}
331
+		return $excerpt;
332
+	}
333
+
334
+
335
+	/**
336
+	 * @param string $text
337
+	 * @return string
338
+	 */
339
+	public static function end_get_the_excerpt($text = '')
340
+	{
341
+		EED_Events_Archive::$using_get_the_excerpt = false;
342
+		return $text;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $title
348
+	 * @param string $id
349
+	 * @return string
350
+	 * @throws EE_Error
351
+	 * @throws ReflectionException
352
+	 */
353
+	public static function the_title($title = '', $id = '')
354
+	{
355
+		global $post;
356
+		if ($post instanceof WP_Post) {
357
+			return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id
358
+				? espresso_event_status_banner($post->ID) . $title
359
+				: $title;
360
+		}
361
+		return $title;
362
+	}
363
+
364
+
365
+	/**
366
+	 * @param string $content
367
+	 * @return string
368
+	 * @throws EE_Error
369
+	 * @throws ReflectionException
370
+	 */
371
+	public static function event_details($content)
372
+	{
373
+		global $post;
374
+		static $current_post_ID = 0;
375
+		if (
376
+			$current_post_ID !== $post->ID
377
+			&& $post->post_type === EspressoPostType::EVENTS
378
+			&& ! EED_Events_Archive::$using_get_the_excerpt
379
+			&& ! post_password_required()
380
+			&& (
381
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
382
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
383
+			)
384
+		) {
385
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
386
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
387
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
388
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
389
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
390
+			// so the following allows this filter to be applied multiple times, but only once for real
391
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
392
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
393
+				$content = EED_Events_Archive::use_sortable_display_order();
394
+			} else {
395
+				$content = EED_Events_Archive::use_filterable_display_order();
396
+			}
397
+		}
398
+		return $content;
399
+	}
400
+
401
+
402
+	/**
403
+	 * @return string
404
+	 * @throws EE_Error
405
+	 * @throws ReflectionException
406
+	 */
407
+	protected static function use_sortable_display_order()
408
+	{
409
+		// no further password checks required atm
410
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
411
+		// remove this callback from being applied to the_content()
412
+		EED_Events_Archive::removeEventDetailsFilters();
413
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
414
+		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
415
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
416
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
417
+		// re-add our main filters (or else the next event won't have them)
418
+		EED_Events_Archive::addEventDetailsFilters();
419
+		remove_filter(
420
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
421
+			'__return_true'
422
+		);
423
+		return $content;
424
+	}
425
+
426
+
427
+	/**
428
+	 * @return string
429
+	 */
430
+	protected static function use_filterable_display_order()
431
+	{
432
+		// remove this callback from being applied to the_content()
433
+		EED_Events_Archive::removeEventDetailsFilters();
434
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
435
+		EED_Events_Archive::_add_additional_excerpt_filters();
436
+		EED_Events_Archive::_add_additional_content_filters();
437
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
438
+		// now load our template
439
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
440
+		// re-add our main filters (or else the next event won't have them)
441
+		EED_Events_Archive::addEventDetailsFilters();
442
+		// but remove the other filters so that they don't get applied to the next post
443
+		EED_Events_Archive::_remove_additional_events_archive_filters();
444
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
445
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
446
+		// return ! empty( $template ) ? $template : $content;
447
+		return $content;
448
+	}
449
+
450
+
451
+	/**
452
+	 * adds datetimes ABOVE content
453
+	 *
454
+	 * @param string $content
455
+	 * @return string
456
+	 */
457
+	public static function event_datetimes($content)
458
+	{
459
+		if (post_password_required()) {
460
+			return $content;
461
+		}
462
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
463
+	}
464
+
465
+
466
+	/**
467
+	 * adds tickets ABOVE content (which includes datetimes)
468
+	 *
469
+	 * @param string $content
470
+	 * @return string
471
+	 */
472
+	public static function event_tickets($content)
473
+	{
474
+		if (post_password_required()) {
475
+			return $content;
476
+		}
477
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
478
+	}
479
+
480
+
481
+	/**
482
+	 * adds venues BELOW content
483
+	 *
484
+	 * @param string $content
485
+	 * @return string
486
+	 */
487
+	public static function event_venue($content)
488
+	{
489
+		return EED_Events_Archive::event_venues($content);
490
+	}
491
+
492
+
493
+	/**
494
+	 * adds venues BELOW content
495
+	 *
496
+	 * @param string $content
497
+	 * @return string
498
+	 */
499
+	public static function event_venues($content)
500
+	{
501
+		if (post_password_required()) {
502
+			return $content;
503
+		}
504
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
505
+	}
506
+
507
+
508
+	/**
509
+	 * @return bool
510
+	 * @since 4.10.33.p
511
+	 */
512
+	public static function isBlockTheme()
513
+	{
514
+		return function_exists('wp_is_block_theme') && wp_is_block_theme();
515
+	}
516
+
517
+
518
+	/**
519
+	 * @return string
520
+	 * @since 4.10.33.p
521
+	 */
522
+	public static function getExcerptFilter()
523
+	{
524
+		static $excerpt_filter = null;
525
+		if ($excerpt_filter === null) {
526
+			$excerpt_filter = EED_Events_Archive::isBlockTheme() ? 'get_the_excerpt' : 'the_excerpt';
527
+		}
528
+		return $excerpt_filter;
529
+	}
530
+
531
+
532
+	/**
533
+	 * @since 4.10.33.p
534
+	 */
535
+	protected static function addEventDetailsFilters()
536
+	{
537
+		add_filter(
538
+			'the_content',
539
+			['EED_Events_Archive', 'event_details'],
540
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
541
+		);
542
+		// but because we don't know if the theme is using the_excerpt()
543
+		add_filter(
544
+			EED_Events_Archive::getExcerptFilter(),
545
+			['EED_Events_Archive', 'event_details'],
546
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
547
+		);
548
+		// and just in case they are running get_the_excerpt() which DESTROYS things
549
+		add_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1, 1);
550
+	}
551
+
552
+
553
+	/**
554
+	 * @param bool $and_get_the_excerpt
555
+	 * @since 4.10.33.p
556
+	 */
557
+	protected static function removeEventDetailsFilters($and_get_the_excerpt = true)
558
+	{
559
+		// we need to first remove all callbacks from being applied to the_content()
560
+		// (otherwise it will recurse and blow up the interweb)
561
+		remove_filter(
562
+			'the_content',
563
+			['EED_Events_Archive', 'event_details'],
564
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
565
+		);
566
+		remove_filter(
567
+			EED_Events_Archive::getExcerptFilter(),
568
+			['EED_Events_Archive', 'event_details'],
569
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
570
+		);
571
+		if ($and_get_the_excerpt) {
572
+			remove_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1);
573
+		}
574
+	}
575
+
576
+
577
+	/**
578
+	 * @return void
579
+	 */
580
+	private static function _add_additional_excerpt_filters()
581
+	{
582
+		add_filter(
583
+			EED_Events_Archive::getExcerptFilter(),
584
+			['EED_Events_Archive', 'event_datetimes'],
585
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
586
+		);
587
+		add_filter(
588
+			EED_Events_Archive::getExcerptFilter(),
589
+			['EED_Events_Archive', 'event_tickets'],
590
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
591
+		);
592
+		add_filter(
593
+			EED_Events_Archive::getExcerptFilter(),
594
+			['EED_Events_Archive', 'event_venues'],
595
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
596
+		);
597
+	}
598
+
599
+
600
+	/**
601
+	 * @return void
602
+	 */
603
+	private static function _add_additional_content_filters()
604
+	{
605
+		add_filter(
606
+			'the_content',
607
+			['EED_Events_Archive', 'event_datetimes'],
608
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
609
+		);
610
+		add_filter(
611
+			'the_content',
612
+			['EED_Events_Archive', 'event_tickets'],
613
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
614
+		);
615
+		add_filter(
616
+			'the_content',
617
+			['EED_Events_Archive', 'event_venues'],
618
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
619
+		);
620
+	}
621
+
622
+
623
+	/**
624
+	 * @return void
625
+	 */
626
+	private static function _remove_additional_events_archive_filters()
627
+	{
628
+		remove_filter(
629
+			EED_Events_Archive::getExcerptFilter(),
630
+			['EED_Events_Archive', 'event_datetimes'],
631
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
+		);
633
+		remove_filter(
634
+			EED_Events_Archive::getExcerptFilter(),
635
+			['EED_Events_Archive', 'event_tickets'],
636
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
+		);
638
+		remove_filter(
639
+			EED_Events_Archive::getExcerptFilter(),
640
+			['EED_Events_Archive', 'event_venues'],
641
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
642
+		);
643
+		remove_filter(
644
+			'the_content',
645
+			['EED_Events_Archive', 'event_datetimes'],
646
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
+		);
648
+		remove_filter(
649
+			'the_content',
650
+			['EED_Events_Archive', 'event_tickets'],
651
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
+		);
653
+		remove_filter(
654
+			'the_content',
655
+			['EED_Events_Archive', 'event_venues'],
656
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
657
+		);
658
+	}
659
+
660
+
661
+	/**
662
+	 * @return void
663
+	 */
664
+	public static function remove_all_events_archive_filters()
665
+	{
666
+		// remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
667
+		remove_filter('the_title', ['EED_Events_Archive', 'the_title'], 1);
668
+		remove_filter(
669
+			EED_Events_Archive::getExcerptFilter(),
670
+			['EED_Events_Archive', 'event_details'],
671
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
672
+		);
673
+		remove_filter(
674
+			EED_Events_Archive::getExcerptFilter(),
675
+			['EED_Events_Archive', 'event_datetimes'],
676
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
677
+		);
678
+		remove_filter(
679
+			EED_Events_Archive::getExcerptFilter(),
680
+			['EED_Events_Archive', 'event_tickets'],
681
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
682
+		);
683
+		remove_filter(
684
+			EED_Events_Archive::getExcerptFilter(),
685
+			['EED_Events_Archive', 'event_venues'],
686
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
687
+		);
688
+		remove_filter(
689
+			'the_content',
690
+			['EED_Events_Archive', 'event_details'],
691
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
692
+		);
693
+		remove_filter(
694
+			'the_content',
695
+			['EED_Events_Archive', 'event_datetimes'],
696
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
697
+		);
698
+		remove_filter(
699
+			'the_content',
700
+			['EED_Events_Archive', 'event_tickets'],
701
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
702
+		);
703
+		remove_filter(
704
+			'the_content',
705
+			['EED_Events_Archive', 'event_venues'],
706
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
707
+		);
708
+		// don't display entry meta because the existing theme will take care of that
709
+		remove_filter(
710
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
711
+			'__return_false'
712
+		);
713
+	}
714
+
715
+
716
+	/**
717
+	 * @return void
718
+	 */
719
+	public function load_event_list_assets()
720
+	{
721
+		do_action('AHEE__EED_Events_Archive__before_load_assets');
722
+		add_filter('FHEE_load_EE_Session', '__return_true');
723
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
724
+		add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts'], 10);
725
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
726
+			add_action('wp_enqueue_scripts', ['EEH_Maps', 'espresso_google_map_js'], 11);
727
+		}
728
+	}
729
+
730
+
731
+	/**
732
+	 * @return void
733
+	 * @throws EE_Error
734
+	 */
735
+	public function wp_enqueue_scripts()
736
+	{
737
+		// get some style
738
+		if (apply_filters('FHEE_enable_default_espresso_css', false)) {
739
+			// first check uploads folder
740
+			if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
741
+				wp_register_style(
742
+					$this->theme,
743
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
744
+					['dashicons', 'espresso_default']
745
+				);
746
+			}
747
+			wp_enqueue_style($this->theme);
748
+		}
749
+	}
750
+
751
+
752
+	/**
753
+	 * @static
754
+	 * @return void
755
+	 */
756
+	public static function template_settings_form()
757
+	{
758
+		$template_settings                     = EE_Registry::instance()->CFG->template_settings;
759
+		$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
760
+			? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
761
+		$template_settings->EED_Events_Archive = apply_filters(
762
+			'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
763
+			$template_settings->EED_Events_Archive
764
+		);
765
+		$events_archive_settings               = [
766
+			'display_status_banner'   => 0,
767
+			'display_description'     => 1,
768
+			'display_ticket_selector' => 0,
769
+			'display_datetimes'       => 1,
770
+			'display_venue'           => 0,
771
+			'display_expired_events'  => 0,
772
+		];
773
+		$events_archive_settings               = array_merge(
774
+			$events_archive_settings,
775
+			(array) $template_settings->EED_Events_Archive
776
+		);
777
+		EEH_Template::display_template(
778
+			EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
779
+			$events_archive_settings
780
+		);
781
+	}
782
+
783
+
784
+	/**
785
+	 * @param EE_Template_Config $CFG
786
+	 * @param array              $REQ
787
+	 * @return EE_Template_Config
788
+	 */
789
+	public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config
790
+	{
791
+		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
792
+		// unless we are resetting the config...
793
+		if (
794
+			! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
795
+			|| absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
796
+		) {
797
+			$CFG->EED_Events_Archive->display_status_banner   = isset($REQ['EED_Events_Archive_display_status_banner'])
798
+				? absint($REQ['EED_Events_Archive_display_status_banner'])
799
+				: 0;
800
+			$CFG->EED_Events_Archive->display_description     = isset($REQ['EED_Events_Archive_display_description'])
801
+				? absint($REQ['EED_Events_Archive_display_description'])
802
+				: 1;
803
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
804
+				? absint($REQ['EED_Events_Archive_display_ticket_selector'])
805
+				: 0;
806
+			$CFG->EED_Events_Archive->display_datetimes       = isset($REQ['EED_Events_Archive_display_datetimes'])
807
+				? absint($REQ['EED_Events_Archive_display_datetimes'])
808
+				: 1;
809
+			$CFG->EED_Events_Archive->display_venue           = isset($REQ['EED_Events_Archive_display_venue'])
810
+				? absint($REQ['EED_Events_Archive_display_venue'])
811
+				: 0;
812
+			$CFG->EED_Events_Archive->display_expired_events  = isset($REQ['EED_Events_Archive_display_expired_events'])
813
+				? absint($REQ['EED_Events_Archive_display_expired_events'])
814
+				: 0;
815
+		}
816
+		return $CFG;
817
+	}
818
+
819
+
820
+	/**
821
+	 * @param string $extra_class
822
+	 * @return string
823
+	 */
824
+	public static function event_list_css($extra_class = '')
825
+	{
826
+		$event_list_css   = ! empty($extra_class) ? [$extra_class] : [];
827
+		$event_list_css[] = 'espresso-event-list-event';
828
+		return implode(' ', $event_list_css);
829
+	}
830
+
831
+
832
+	/**
833
+	 * @return array
834
+	 * @throws EE_Error
835
+	 * @throws ReflectionException
836
+	 */
837
+	public static function event_categories()
838
+	{
839
+		return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
840
+	}
841
+
842
+
843
+	/**
844
+	 * @param $value
845
+	 * @return bool
846
+	 */
847
+	public static function display_description($value)
848
+	{
849
+		$config              = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
850
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
851
+		return $display_description === $value;
852
+	}
853
+
854
+
855
+	/**
856
+	 * @return bool
857
+	 */
858
+	public static function display_ticket_selector()
859
+	{
860
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
861
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector;
862
+	}
863
+
864
+
865
+	/**
866
+	 * @return bool
867
+	 * @throws EE_Error
868
+	 * @throws ReflectionException
869
+	 */
870
+	public static function display_venue()
871
+	{
872
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
873
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name();
874
+	}
875
+
876
+
877
+	/**
878
+	 * @return bool
879
+	 */
880
+	public static function display_datetimes()
881
+	{
882
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
883
+		return isset($config->display_datetimes) && $config->display_datetimes;
884
+	}
885
+
886
+
887
+	/**
888
+	 * @return string
889
+	 */
890
+	public static function event_list_title()
891
+	{
892
+		return apply_filters(
893
+			'FHEE__archive_espresso_events_template__upcoming_events_h1',
894
+			esc_html__('Upcoming Events', 'event_espresso')
895
+		);
896
+	}
897
+
898
+
899
+	// GRAVEYARD
900
+
901
+
902
+	/**
903
+	 * @since 4.4.0
904
+	 */
905
+	public static function _doing_it_wrong_notice($function = '')
906
+	{
907
+		EE_Error::doing_it_wrong(
908
+			__FUNCTION__,
909
+			sprintf(
910
+				esc_html__(
911
+					'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s',
912
+					'event_espresso'
913
+				),
914
+				$function,
915
+				'<br />',
916
+				'4.6.0'
917
+			),
918
+			'4.4.0'
919
+		);
920
+	}
921
+
922
+
923
+	/**
924
+	 * @deprecated
925
+	 * @since 4.4.0
926
+	 */
927
+	public function get_post_data()
928
+	{
929
+		EEH_Event_Query::set_query_params();
930
+	}
931
+
932
+
933
+	/**
934
+	 * @throws EE_Error
935
+	 * @since 4.4.0
936
+	 * @deprecated
937
+	 */
938
+	public function posts_fields($SQL, WP_Query $wp_query)
939
+	{
940
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
941
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
942
+	}
943
+
944
+
945
+	/**
946
+	 * @throws EE_Error
947
+	 * @since 4.4.0
948
+	 * @deprecated
949
+	 */
950
+	public static function posts_fields_sql_for_orderby($orderby_params = [])
951
+	{
952
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
953
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
954
+	}
955
+
956
+
957
+	/**
958
+	 * @throws EE_Error
959
+	 * @since 4.4.0
960
+	 * @deprecated
961
+	 */
962
+	public function posts_join($SQL, WP_Query $wp_query)
963
+	{
964
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
965
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
966
+	}
967
+
968
+
969
+	/**
970
+	 * @deprecated
971
+	 * @since 4.4.0
972
+	 */
973
+	public static function posts_join_sql_for_terms($join_terms = null)
974
+	{
975
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
976
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
977
+	}
978
+
979
+
980
+	/**
981
+	 * @throws EE_Error
982
+	 * @since 4.4.0
983
+	 * @deprecated
984
+	 */
985
+	public static function posts_join_for_orderby($orderby_params = [])
986
+	{
987
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
988
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
989
+	}
990
+
991
+
992
+	/**
993
+	 * @throws EE_Error
994
+	 * @since 4.4.0
995
+	 * @deprecated
996
+	 */
997
+	public function posts_where($SQL, WP_Query $wp_query)
998
+	{
999
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1000
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * @throws EE_Error
1006
+	 * @since 4.4.0
1007
+	 * @deprecated
1008
+	 */
1009
+	public static function posts_where_sql_for_show_expired($show_expired = false)
1010
+	{
1011
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1012
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1013
+	}
1014
+
1015
+
1016
+	/**
1017
+	 * @deprecated
1018
+	 * @since 4.4.0
1019
+	 */
1020
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1021
+	{
1022
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1023
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1024
+	}
1025
+
1026
+
1027
+	/**
1028
+	 * @throws EE_Error
1029
+	 * @since 4.4.0
1030
+	 * @deprecated
1031
+	 */
1032
+	public static function posts_where_sql_for_event_list_month($month = null)
1033
+	{
1034
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1035
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * @throws EE_Error
1041
+	 * @since 4.4.0
1042
+	 * @deprecated
1043
+	 */
1044
+	public function posts_orderby($SQL, WP_Query $wp_query)
1045
+	{
1046
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1047
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1048
+	}
1049
+
1050
+
1051
+	/**
1052
+	 * @throws EE_Error
1053
+	 * @since 4.4.0
1054
+	 * @deprecated
1055
+	 */
1056
+	public static function posts_orderby_sql($orderby_params = [], $sort = 'ASC')
1057
+	{
1058
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1059
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1060
+	}
1061 1061
 }
1062 1062
 
1063 1063
 
@@ -1066,9 +1066,9 @@  discard block
 block discarded – undo
1066 1066
  */
1067 1067
 function espresso_get_event_list_ID()
1068 1068
 {
1069
-    EED_Events_Archive::$espresso_event_list_ID++;
1070
-    EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1071
-    return EED_Events_Archive::$espresso_event_list_ID;
1069
+	EED_Events_Archive::$espresso_event_list_ID++;
1070
+	EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1071
+	return EED_Events_Archive::$espresso_event_list_ID;
1072 1072
 }
1073 1073
 
1074 1074
 
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
  */
1078 1078
 function espresso_event_list_title()
1079 1079
 {
1080
-    return EED_Events_Archive::event_list_title();
1080
+	return EED_Events_Archive::event_list_title();
1081 1081
 }
1082 1082
 
1083 1083
 
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
  */
1088 1088
 function espresso_event_list_css($extra_class = '')
1089 1089
 {
1090
-    return EED_Events_Archive::event_list_css($extra_class);
1090
+	return EED_Events_Archive::event_list_css($extra_class);
1091 1091
 }
1092 1092
 
1093 1093
 
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
  */
1099 1099
 function espresso_get_event_categories()
1100 1100
 {
1101
-    return EED_Events_Archive::event_categories();
1101
+	return EED_Events_Archive::event_categories();
1102 1102
 }
1103 1103
 
1104 1104
 
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
  */
1108 1108
 function espresso_display_full_description_in_event_list()
1109 1109
 {
1110
-    return EED_Events_Archive::display_description(2);
1110
+	return EED_Events_Archive::display_description(2);
1111 1111
 }
1112 1112
 
1113 1113
 
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
  */
1117 1117
 function espresso_display_excerpt_in_event_list()
1118 1118
 {
1119
-    return EED_Events_Archive::display_description(1);
1119
+	return EED_Events_Archive::display_description(1);
1120 1120
 }
1121 1121
 
1122 1122
 
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
  */
1126 1126
 function espresso_display_ticket_selector_in_event_list()
1127 1127
 {
1128
-    return EED_Events_Archive::display_ticket_selector();
1128
+	return EED_Events_Archive::display_ticket_selector();
1129 1129
 }
1130 1130
 
1131 1131
 
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
  */
1137 1137
 function espresso_display_venue_in_event_list()
1138 1138
 {
1139
-    return EED_Events_Archive::display_venue();
1139
+	return EED_Events_Archive::display_venue();
1140 1140
 }
1141 1141
 
1142 1142
 
@@ -1145,5 +1145,5 @@  discard block
 block discarded – undo
1145 1145
  */
1146 1146
 function espresso_display_datetimes_in_event_list()
1147 1147
 {
1148
-    return EED_Events_Archive::display_datetimes();
1148
+	return EED_Events_Archive::display_datetimes();
1149 1149
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(CustomPostTypeDefinitions::class);
79 79
         $custom_post_types            = $custom_post_type_definitions->getDefinitions();
80 80
         EED_Module::registerRoute(
81
-            $custom_post_types[ EspressoPostType::EVENTS ]['plural_slug'],
81
+            $custom_post_types[EspressoPostType::EVENTS]['plural_slug'],
82 82
             'Events_Archive',
83 83
             'run'
84 84
         );
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function set_definitions()
122 122
     {
123
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
123
+        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
124
+        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
125 125
     }
126 126
 
127 127
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public static function get_iframe_embed_button()
143 143
     {
144
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
144
+        if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
145 145
             self::$_iframe_embed_button = new EventListIframeEmbedButton();
146 146
         }
147 147
         return self::$_iframe_embed_button;
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
         EEH_Event_Query::add_query_filters();
219 219
         // set params that will get used by the filters
220 220
         EEH_Event_Query::set_query_params(
221
-            '',                             // month
222
-            '',                             // category
221
+            '', // month
222
+            '', // category
223 223
             $config->display_expired_events // show_expired
224 224
         );
225 225
         // check what template is loaded
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     public function template_include($template = '')
282 282
     {
283 283
         // don't add content filter for dedicated EE child themes or private posts
284
-        if (! EEH_Template::is_espresso_theme()) {
284
+        if ( ! EEH_Template::is_espresso_theme()) {
285 285
             /** @type EE_Events_Archive_Config $config */
286 286
             $config = $this->config();
287 287
             // add status banner ?
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         global $post;
356 356
         if ($post instanceof WP_Post) {
357 357
             return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id
358
-                ? espresso_event_status_banner($post->ID) . $title
358
+                ? espresso_event_status_banner($post->ID).$title
359 359
                 : $title;
360 360
         }
361 361
         return $title;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         if (post_password_required()) {
460 460
             return $content;
461 461
         }
462
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
462
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
463 463
     }
464 464
 
465 465
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         if (post_password_required()) {
475 475
             return $content;
476 476
         }
477
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
477
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
478 478
     }
479 479
 
480 480
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
         if (post_password_required()) {
502 502
             return $content;
503 503
         }
504
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
504
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
505 505
     }
506 506
 
507 507
 
@@ -737,10 +737,10 @@  discard block
 block discarded – undo
737 737
         // get some style
738 738
         if (apply_filters('FHEE_enable_default_espresso_css', false)) {
739 739
             // first check uploads folder
740
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
740
+            if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
741 741
                 wp_register_style(
742 742
                     $this->theme,
743
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
743
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
744 744
                     ['dashicons', 'espresso_default']
745 745
                 );
746 746
             }
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
             'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
763 763
             $template_settings->EED_Events_Archive
764 764
         );
765
-        $events_archive_settings               = [
765
+        $events_archive_settings = [
766 766
             'display_status_banner'   => 0,
767 767
             'display_description'     => 1,
768 768
             'display_ticket_selector' => 0,
@@ -770,12 +770,12 @@  discard block
 block discarded – undo
770 770
             'display_venue'           => 0,
771 771
             'display_expired_events'  => 0,
772 772
         ];
773
-        $events_archive_settings               = array_merge(
773
+        $events_archive_settings = array_merge(
774 774
             $events_archive_settings,
775 775
             (array) $template_settings->EED_Events_Archive
776 776
         );
777 777
         EEH_Template::display_template(
778
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
778
+            EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php',
779 779
             $events_archive_settings
780 780
         );
781 781
     }
Please login to merge, or discard this patch.
modules/venue_single/EED_Venue_Single.module.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -29,173 +29,173 @@
 block discarded – undo
29 29
  */
30 30
 class EED_Venue_Single extends EED_Module
31 31
 {
32
-    /**
33
-     * @return EED_Venue_Single
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EED_Module::registerRoute(
57
-            $custom_post_types[ EspressoPostType::VENUES ]['singular_slug'],
58
-            'Venue_Single',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (
99
-            EE_Registry::instance()
100
-                       ->load_core('Front_Controller', array(), false, true)
101
-                       ->get_selected_template() != 'single-espresso_venues.php'
102
-        ) {
103
-            EEH_Template::load_espresso_theme_functions();
104
-            // then add extra event data via hooks
105
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
106
-            add_filter('the_content', array($this, 'venue_details'), 100);
107
-            // don't display entry meta because the existing theme will take car of that
108
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
-        }
110
-        return $template;
111
-    }
112
-
113
-
114
-    /**
115
-     * the_title
116
-     *
117
-     * @access public
118
-     * @param  string $title
119
-     * @return string
120
-     */
121
-    public function the_title($title = '')
122
-    {
123
-        return $title;
124
-    }
125
-
126
-
127
-    /**
128
-     *    venue_details
129
-     *
130
-     * @access public
131
-     * @param  string $content
132
-     * @return string
133
-     */
134
-    public function venue_details($content)
135
-    {
136
-        global $post;
137
-        if (
138
-            $post->post_type == EspressoPostType::VENUES
139
-            && ! post_password_required()
140
-        ) {
141
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
-            // it uses the_content() for displaying the $post->post_content
143
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
-            remove_filter('the_content', array($this, 'venue_details'), 100);
146
-            // add filters we want
147
-            add_filter('the_content', array($this, 'venue_location'), 110);
148
-            // now load our template
149
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
-            // remove other filters we added so they won't get applied to the next post
151
-            remove_filter('the_content', array($this, 'venue_location'), 110);
152
-        }
153
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
-        return ! empty($template) ? $template : $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * venue_location
160
-     *
161
-     * @access public
162
-     * @param  string $content
163
-     * @return string
164
-     */
165
-    public function venue_location($content)
166
-    {
167
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
-    }
169
-
170
-
171
-    /**
172
-     *    wp_enqueue_scripts
173
-     *
174
-     * @access public
175
-     * @return void
176
-     */
177
-    public function wp_enqueue_scripts()
178
-    {
179
-        // get some style
180
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
-            // first check theme folder
182
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
-                wp_register_style(
184
-                    $this->theme,
185
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
-                    array('dashicons', 'espresso_default')
187
-                );
188
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
-                wp_register_style(
190
-                    $this->theme,
191
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
192
-                    array('dashicons', 'espresso_default')
193
-                );
194
-            }
195
-            wp_enqueue_style($this->theme);
196
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
-            }
199
-        }
200
-    }
32
+	/**
33
+	 * @return EED_Venue_Single
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EED_Module::registerRoute(
57
+			$custom_post_types[ EspressoPostType::VENUES ]['singular_slug'],
58
+			'Venue_Single',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (
99
+			EE_Registry::instance()
100
+					   ->load_core('Front_Controller', array(), false, true)
101
+					   ->get_selected_template() != 'single-espresso_venues.php'
102
+		) {
103
+			EEH_Template::load_espresso_theme_functions();
104
+			// then add extra event data via hooks
105
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
106
+			add_filter('the_content', array($this, 'venue_details'), 100);
107
+			// don't display entry meta because the existing theme will take car of that
108
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
+		}
110
+		return $template;
111
+	}
112
+
113
+
114
+	/**
115
+	 * the_title
116
+	 *
117
+	 * @access public
118
+	 * @param  string $title
119
+	 * @return string
120
+	 */
121
+	public function the_title($title = '')
122
+	{
123
+		return $title;
124
+	}
125
+
126
+
127
+	/**
128
+	 *    venue_details
129
+	 *
130
+	 * @access public
131
+	 * @param  string $content
132
+	 * @return string
133
+	 */
134
+	public function venue_details($content)
135
+	{
136
+		global $post;
137
+		if (
138
+			$post->post_type == EspressoPostType::VENUES
139
+			&& ! post_password_required()
140
+		) {
141
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
+			// it uses the_content() for displaying the $post->post_content
143
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
+			remove_filter('the_content', array($this, 'venue_details'), 100);
146
+			// add filters we want
147
+			add_filter('the_content', array($this, 'venue_location'), 110);
148
+			// now load our template
149
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
+			// remove other filters we added so they won't get applied to the next post
151
+			remove_filter('the_content', array($this, 'venue_location'), 110);
152
+		}
153
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
+		return ! empty($template) ? $template : $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * venue_location
160
+	 *
161
+	 * @access public
162
+	 * @param  string $content
163
+	 * @return string
164
+	 */
165
+	public function venue_location($content)
166
+	{
167
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
+	}
169
+
170
+
171
+	/**
172
+	 *    wp_enqueue_scripts
173
+	 *
174
+	 * @access public
175
+	 * @return void
176
+	 */
177
+	public function wp_enqueue_scripts()
178
+	{
179
+		// get some style
180
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
+			// first check theme folder
182
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
+				wp_register_style(
184
+					$this->theme,
185
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
+					array('dashicons', 'espresso_default')
187
+				);
188
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
+				wp_register_style(
190
+					$this->theme,
191
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
192
+					array('dashicons', 'espresso_default')
193
+				);
194
+			}
195
+			wp_enqueue_style($this->theme);
196
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
+			}
199
+		}
200
+	}
201 201
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         );
55 55
         $custom_post_types = $custom_post_type_definitions->getDefinitions();
56 56
         EED_Module::registerRoute(
57
-            $custom_post_types[ EspressoPostType::VENUES ]['singular_slug'],
57
+            $custom_post_types[EspressoPostType::VENUES]['singular_slug'],
58 58
             'Venue_Single',
59 59
             'run'
60 60
         );
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function venue_location($content)
166 166
     {
167
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
167
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
168 168
     }
169 169
 
170 170
 
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
         // get some style
180 180
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181 181
             // first check theme folder
182
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
182
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
183 183
                 wp_register_style(
184 184
                     $this->theme,
185
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
185
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
186 186
                     array('dashicons', 'espresso_default')
187 187
                 );
188
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
188
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
189 189
                 wp_register_style(
190 190
                     $this->theme,
191
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
191
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
192 192
                     array('dashicons', 'espresso_default')
193 193
                 );
194 194
             }
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 2 patches
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -14,475 +14,475 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EED_Event_Single extends EED_Module
16 16
 {
17
-    const EVENT_DETAILS_PRIORITY = 100;
18
-    const EVENT_DATETIMES_PRIORITY = 110;
19
-    const EVENT_TICKETS_PRIORITY = 120;
20
-    const EVENT_VENUES_PRIORITY = 130;
21
-
22
-    /**
23
-     * @type bool $using_get_the_excerpt
24
-     */
25
-    protected static $using_get_the_excerpt = false;
26
-
27
-
28
-    /**
29
-     * @type EE_Template_Part_Manager $template_parts
30
-     */
31
-    protected $template_parts;
32
-
33
-
34
-    /**
35
-     * @return EED_Module|EED_Event_Single
36
-     */
37
-    public static function instance()
38
-    {
39
-        return parent::get_instance(__CLASS__);
40
-    }
41
-
42
-
43
-    /**
44
-     * set_hooks - for hooking into EE Core, other modules, etc
45
-     *
46
-     * @return void
47
-     * @throws InvalidArgumentException
48
-     * @throws InvalidDataTypeException
49
-     * @throws InvalidInterfaceException
50
-     */
51
-    public static function set_hooks()
52
-    {
53
-        add_filter('FHEE_run_EE_wp', '__return_true');
54
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
-        );
59
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
60
-        EED_Module::registerRoute(
61
-            $custom_post_types[ EspressoPostType::EVENTS ]['singular_slug'],
62
-            'Event_Single',
63
-            'run'
64
-        );
65
-    }
66
-
67
-    /**
68
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
-     *
70
-     * @return    void
71
-     */
72
-    public static function set_hooks_admin()
73
-    {
74
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
-    }
76
-
77
-
78
-    /**
79
-     * set_definitions
80
-     *
81
-     * @static
82
-     * @return void
83
-     */
84
-    public static function set_definitions()
85
-    {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
-    }
89
-
90
-
91
-    /**
92
-     * set_config
93
-     *
94
-     * @void
95
-     */
96
-    protected function set_config()
97
-    {
98
-        $this->set_config_section('template_settings');
99
-        $this->set_config_class('EE_Event_Single_Config');
100
-        $this->set_config_name('EED_Event_Single');
101
-    }
102
-
103
-
104
-    /**
105
-     * initialize_template_parts
106
-     *
107
-     * @param EE_Config_Base|EE_Event_Single_Config $config
108
-     * @return EE_Template_Part_Manager
109
-     * @throws EE_Error
110
-     */
111
-    public function initialize_template_parts(EE_Event_Single_Config $config = null)
112
-    {
113
-        /** @type EE_Event_Single_Config $config */
114
-        $config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
115
-        EEH_Autoloader::register_template_part_autoloaders();
116
-        $template_parts = new EE_Template_Part_Manager();
117
-        $template_parts->add_template_part(
118
-            'tickets',
119
-            esc_html__('Ticket Selector', 'event_espresso'),
120
-            'content-espresso_events-tickets.php',
121
-            $config->display_order_tickets
122
-        );
123
-        $template_parts->add_template_part(
124
-            'datetimes',
125
-            esc_html__('Dates and Times', 'event_espresso'),
126
-            'content-espresso_events-datetimes.php',
127
-            $config->display_order_datetimes
128
-        );
129
-        $template_parts->add_template_part(
130
-            'event',
131
-            esc_html__('Event Description', 'event_espresso'),
132
-            'content-espresso_events-details.php',
133
-            $config->display_order_event
134
-        );
135
-        $template_parts->add_template_part(
136
-            'venue',
137
-            esc_html__('Venue Information', 'event_espresso'),
138
-            'content-espresso_events-venues.php',
139
-            $config->display_order_venue
140
-        );
141
-        do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
142
-        return $template_parts;
143
-    }
144
-
145
-
146
-    /**
147
-     * run - initial module setup
148
-     *
149
-     * @param WP $WP
150
-     * @return    void
151
-     */
152
-    public function run($WP)
153
-    {
154
-        // ensure valid EE_Events_Single_Config() object exists
155
-        $this->set_config();
156
-        // check what template is loaded
157
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
158
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
159
-        // load css
160
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
161
-    }
162
-
163
-
164
-    /**
165
-     * template_include
166
-     *
167
-     * @param    string $template
168
-     * @return    string
169
-     */
170
-    public function template_include($template)
171
-    {
172
-        global $post;
173
-        /** @type EE_Event_Single_Config $config */
174
-        $config = $this->config();
175
-        if ($config->display_status_banner_single) {
176
-            add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
177
-        }
178
-        // not a custom template?
179
-        if (
180
-            ! post_password_required($post)
181
-            && (
182
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
183
-                || EE_Registry::instance()
184
-                              ->load_core('Front_Controller')
185
-                              ->get_selected_template() !== 'single-espresso_events.php'
186
-            )
187
-        ) {
188
-            EEH_Template::load_espresso_theme_functions();
189
-            // then add extra event data via hooks
190
-            add_action('loop_start', array('EED_Event_Single', 'loop_start'));
191
-            add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
192
-            add_filter(
193
-                'the_content',
194
-                array('EED_Event_Single', 'event_details'),
195
-                EED_Event_Single::EVENT_DETAILS_PRIORITY
196
-            );
197
-            add_action('loop_end', array('EED_Event_Single', 'loop_end'));
198
-            // don't display entry meta because the existing theme will take car of that
199
-            add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
200
-        }
201
-        return $template;
202
-    }
203
-
204
-
205
-    /**
206
-     * loop_start
207
-     *
208
-     * @param    array $wp_query_array an array containing the WP_Query object
209
-     * @return    void
210
-     */
211
-    public static function loop_start($wp_query_array)
212
-    {
213
-        global $post;
214
-        do_action('AHEE_event_details_before_post', $post, $wp_query_array);
215
-    }
216
-
217
-
218
-    /**
219
-     * the_title
220
-     *
221
-     * @param    string $title
222
-     * @param    int    $id
223
-     * @return    string
224
-     */
225
-    public static function the_title($title = '', $id = 0)
226
-    {
227
-        global $post;
228
-        return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
229
-            ? espresso_event_status_banner($post->ID) . $title
230
-            : $title;
231
-    }
232
-
233
-
234
-    /**
235
-     * get_the_excerpt
236
-     * kinda hacky, but if a theme is using get_the_excerpt(),
237
-     * then we need to remove our filters on the_content()
238
-     *
239
-     * @param        string $excerpt
240
-     * @return        string
241
-     */
242
-    public static function get_the_excerpt($excerpt = '')
243
-    {
244
-        EED_Event_Single::$using_get_the_excerpt = true;
245
-        add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
246
-        return $excerpt;
247
-    }
248
-
249
-
250
-    /**
251
-     * end_get_the_excerpt
252
-     *
253
-     * @param  string $text
254
-     * @return string
255
-     */
256
-    public static function end_get_the_excerpt($text = '')
257
-    {
258
-        EED_Event_Single::$using_get_the_excerpt = false;
259
-        return $text;
260
-    }
261
-
262
-
263
-    /**
264
-     * event_details
265
-     *
266
-     * @param    string $content
267
-     * @return    string
268
-     */
269
-    public static function event_details($content)
270
-    {
271
-        global $post;
272
-        static $current_post_ID = 0;
273
-        if (
274
-            $current_post_ID !== $post->ID
275
-            && $post->post_type === EspressoPostType::EVENTS
276
-            && ! EED_Event_Single::$using_get_the_excerpt
277
-            && ! post_password_required()
278
-        ) {
279
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
280
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
281
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
282
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
283
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
284
-            // so the following allows this filter to be applied multiple times, but only once for real
285
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
286
-            if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
287
-                // we need to first remove this callback from being applied to the_content()
288
-                // (otherwise it will recurse and blow up the interweb)
289
-                remove_filter(
290
-                    'the_content',
291
-                    array('EED_Event_Single', 'event_details'),
292
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
293
-                );
294
-                EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
295
-                );
296
-                $content = EEH_Template::locate_template('content-espresso_events-details.php');
297
-                $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
298
-                add_filter(
299
-                    'the_content',
300
-                    array('EED_Event_Single', 'event_details'),
301
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
302
-                );
303
-            } else {
304
-                $content = EED_Event_Single::use_filterable_display_order();
305
-            }
306
-        }
307
-        return $content;
308
-    }
309
-
310
-
311
-    /**
312
-     * use_filterable_display_order
313
-     *
314
-     * @return string
315
-     */
316
-    protected static function use_filterable_display_order()
317
-    {
318
-        // since the 'content-espresso_events-details.php' template might be used directly from within a theme,
319
-        // it uses the_content() for displaying the $post->post_content
320
-        // so in order to load a template that uses the_content()
321
-        // from within a callback being used to filter the_content(),
322
-        // we need to first remove this callback from being applied to the_content()
323
-        // (otherwise it will recurse and blow up the interweb)
324
-        remove_filter(
325
-            'the_content',
326
-            array('EED_Event_Single', 'event_details'),
327
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
328
-        );
329
-        // now add additional content
330
-        add_filter(
331
-            'the_content',
332
-            array('EED_Event_Single', 'event_datetimes'),
333
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY,
334
-            1
335
-        );
336
-        add_filter(
337
-            'the_content',
338
-            array('EED_Event_Single', 'event_tickets'),
339
-            EED_Event_Single::EVENT_TICKETS_PRIORITY,
340
-            1
341
-        );
342
-        add_filter(
343
-            'the_content',
344
-            array('EED_Event_Single', 'event_venues'),
345
-            EED_Event_Single::EVENT_VENUES_PRIORITY,
346
-            1
347
-        );
348
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
349
-        // now load our template
350
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
351
-        // now add our filter back in, plus some others
352
-        add_filter(
353
-            'the_content',
354
-            array('EED_Event_Single', 'event_details'),
355
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
356
-        );
357
-        remove_filter(
358
-            'the_content',
359
-            array('EED_Event_Single', 'event_datetimes'),
360
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY
361
-        );
362
-        remove_filter(
363
-            'the_content',
364
-            array('EED_Event_Single', 'event_tickets'),
365
-            EED_Event_Single::EVENT_TICKETS_PRIORITY
366
-        );
367
-        remove_filter(
368
-            'the_content',
369
-            array('EED_Event_Single', 'event_venues'),
370
-            EED_Event_Single::EVENT_VENUES_PRIORITY
371
-        );
372
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
373
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
374
-        return $content;
375
-    }
376
-
377
-
378
-    /**
379
-     * event_datetimes - adds datetimes ABOVE content
380
-     *
381
-     * @param        string $content
382
-     * @return        string
383
-     */
384
-    public static function event_datetimes($content)
385
-    {
386
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
387
-    }
388
-
389
-
390
-    /**
391
-     * event_tickets - adds tickets ABOVE content (which includes datetimes)
392
-     *
393
-     * @param        string $content
394
-     * @return        string
395
-     */
396
-    public static function event_tickets($content)
397
-    {
398
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
399
-    }
400
-
401
-
402
-    /**
403
-     * event_venues
404
-     *
405
-     * @param    string $content
406
-     * @return    string
407
-     */
408
-    public static function event_venue($content)
409
-    {
410
-        return EED_Event_Single::event_venues($content);
411
-    }
412
-
413
-
414
-    /**
415
-     * event_venues - adds venues BELOW content
416
-     *
417
-     * @param        string $content
418
-     * @return        string
419
-     */
420
-    public static function event_venues($content)
421
-    {
422
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
423
-    }
424
-
425
-
426
-    /**
427
-     * loop_end
428
-     *
429
-     * @param        array $wp_query_array an array containing the WP_Query object
430
-     * @return        void
431
-     */
432
-    public static function loop_end($wp_query_array)
433
-    {
434
-        global $post;
435
-        do_action('AHEE_event_details_after_post', $post, $wp_query_array);
436
-    }
437
-
438
-
439
-    /**
440
-     * wp_enqueue_scripts
441
-     *
442
-     * @return    void
443
-     */
444
-    public function wp_enqueue_scripts()
445
-    {
446
-        // get some style
447
-        if (
448
-            apply_filters('FHEE_enable_default_espresso_css', true)
449
-            && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
450
-        ) {
451
-            // first check uploads folder
452
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
453
-                wp_register_style(
454
-                    $this->theme,
455
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
456
-                    array('dashicons', 'espresso_default')
457
-                );
458
-            } else {
459
-                wp_register_style(
460
-                    $this->theme,
461
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
462
-                    array('dashicons', 'espresso_default')
463
-                );
464
-            }
465
-            wp_enqueue_script($this->theme);
466
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
467
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
468
-            }
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     * display_venue
475
-     *
476
-     * @return    bool
477
-     */
478
-    public static function display_venue()
479
-    {
480
-        /** @type EE_Event_Single_Config $config */
481
-        $config = EED_Event_Single::instance()->config();
482
-        $display_venue = $config->display_venue === null ? true : $config->display_venue;
483
-        $venue_name = EEH_Venue_View::venue_name();
484
-        return $display_venue && ! empty($venue_name);
485
-    }
17
+	const EVENT_DETAILS_PRIORITY = 100;
18
+	const EVENT_DATETIMES_PRIORITY = 110;
19
+	const EVENT_TICKETS_PRIORITY = 120;
20
+	const EVENT_VENUES_PRIORITY = 130;
21
+
22
+	/**
23
+	 * @type bool $using_get_the_excerpt
24
+	 */
25
+	protected static $using_get_the_excerpt = false;
26
+
27
+
28
+	/**
29
+	 * @type EE_Template_Part_Manager $template_parts
30
+	 */
31
+	protected $template_parts;
32
+
33
+
34
+	/**
35
+	 * @return EED_Module|EED_Event_Single
36
+	 */
37
+	public static function instance()
38
+	{
39
+		return parent::get_instance(__CLASS__);
40
+	}
41
+
42
+
43
+	/**
44
+	 * set_hooks - for hooking into EE Core, other modules, etc
45
+	 *
46
+	 * @return void
47
+	 * @throws InvalidArgumentException
48
+	 * @throws InvalidDataTypeException
49
+	 * @throws InvalidInterfaceException
50
+	 */
51
+	public static function set_hooks()
52
+	{
53
+		add_filter('FHEE_run_EE_wp', '__return_true');
54
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
+		);
59
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
60
+		EED_Module::registerRoute(
61
+			$custom_post_types[ EspressoPostType::EVENTS ]['singular_slug'],
62
+			'Event_Single',
63
+			'run'
64
+		);
65
+	}
66
+
67
+	/**
68
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
+	 *
70
+	 * @return    void
71
+	 */
72
+	public static function set_hooks_admin()
73
+	{
74
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
+	}
76
+
77
+
78
+	/**
79
+	 * set_definitions
80
+	 *
81
+	 * @static
82
+	 * @return void
83
+	 */
84
+	public static function set_definitions()
85
+	{
86
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
+	}
89
+
90
+
91
+	/**
92
+	 * set_config
93
+	 *
94
+	 * @void
95
+	 */
96
+	protected function set_config()
97
+	{
98
+		$this->set_config_section('template_settings');
99
+		$this->set_config_class('EE_Event_Single_Config');
100
+		$this->set_config_name('EED_Event_Single');
101
+	}
102
+
103
+
104
+	/**
105
+	 * initialize_template_parts
106
+	 *
107
+	 * @param EE_Config_Base|EE_Event_Single_Config $config
108
+	 * @return EE_Template_Part_Manager
109
+	 * @throws EE_Error
110
+	 */
111
+	public function initialize_template_parts(EE_Event_Single_Config $config = null)
112
+	{
113
+		/** @type EE_Event_Single_Config $config */
114
+		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
115
+		EEH_Autoloader::register_template_part_autoloaders();
116
+		$template_parts = new EE_Template_Part_Manager();
117
+		$template_parts->add_template_part(
118
+			'tickets',
119
+			esc_html__('Ticket Selector', 'event_espresso'),
120
+			'content-espresso_events-tickets.php',
121
+			$config->display_order_tickets
122
+		);
123
+		$template_parts->add_template_part(
124
+			'datetimes',
125
+			esc_html__('Dates and Times', 'event_espresso'),
126
+			'content-espresso_events-datetimes.php',
127
+			$config->display_order_datetimes
128
+		);
129
+		$template_parts->add_template_part(
130
+			'event',
131
+			esc_html__('Event Description', 'event_espresso'),
132
+			'content-espresso_events-details.php',
133
+			$config->display_order_event
134
+		);
135
+		$template_parts->add_template_part(
136
+			'venue',
137
+			esc_html__('Venue Information', 'event_espresso'),
138
+			'content-espresso_events-venues.php',
139
+			$config->display_order_venue
140
+		);
141
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
142
+		return $template_parts;
143
+	}
144
+
145
+
146
+	/**
147
+	 * run - initial module setup
148
+	 *
149
+	 * @param WP $WP
150
+	 * @return    void
151
+	 */
152
+	public function run($WP)
153
+	{
154
+		// ensure valid EE_Events_Single_Config() object exists
155
+		$this->set_config();
156
+		// check what template is loaded
157
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
158
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
159
+		// load css
160
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
161
+	}
162
+
163
+
164
+	/**
165
+	 * template_include
166
+	 *
167
+	 * @param    string $template
168
+	 * @return    string
169
+	 */
170
+	public function template_include($template)
171
+	{
172
+		global $post;
173
+		/** @type EE_Event_Single_Config $config */
174
+		$config = $this->config();
175
+		if ($config->display_status_banner_single) {
176
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
177
+		}
178
+		// not a custom template?
179
+		if (
180
+			! post_password_required($post)
181
+			&& (
182
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
183
+				|| EE_Registry::instance()
184
+							  ->load_core('Front_Controller')
185
+							  ->get_selected_template() !== 'single-espresso_events.php'
186
+			)
187
+		) {
188
+			EEH_Template::load_espresso_theme_functions();
189
+			// then add extra event data via hooks
190
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
191
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
192
+			add_filter(
193
+				'the_content',
194
+				array('EED_Event_Single', 'event_details'),
195
+				EED_Event_Single::EVENT_DETAILS_PRIORITY
196
+			);
197
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
198
+			// don't display entry meta because the existing theme will take car of that
199
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
200
+		}
201
+		return $template;
202
+	}
203
+
204
+
205
+	/**
206
+	 * loop_start
207
+	 *
208
+	 * @param    array $wp_query_array an array containing the WP_Query object
209
+	 * @return    void
210
+	 */
211
+	public static function loop_start($wp_query_array)
212
+	{
213
+		global $post;
214
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
215
+	}
216
+
217
+
218
+	/**
219
+	 * the_title
220
+	 *
221
+	 * @param    string $title
222
+	 * @param    int    $id
223
+	 * @return    string
224
+	 */
225
+	public static function the_title($title = '', $id = 0)
226
+	{
227
+		global $post;
228
+		return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
229
+			? espresso_event_status_banner($post->ID) . $title
230
+			: $title;
231
+	}
232
+
233
+
234
+	/**
235
+	 * get_the_excerpt
236
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
237
+	 * then we need to remove our filters on the_content()
238
+	 *
239
+	 * @param        string $excerpt
240
+	 * @return        string
241
+	 */
242
+	public static function get_the_excerpt($excerpt = '')
243
+	{
244
+		EED_Event_Single::$using_get_the_excerpt = true;
245
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
246
+		return $excerpt;
247
+	}
248
+
249
+
250
+	/**
251
+	 * end_get_the_excerpt
252
+	 *
253
+	 * @param  string $text
254
+	 * @return string
255
+	 */
256
+	public static function end_get_the_excerpt($text = '')
257
+	{
258
+		EED_Event_Single::$using_get_the_excerpt = false;
259
+		return $text;
260
+	}
261
+
262
+
263
+	/**
264
+	 * event_details
265
+	 *
266
+	 * @param    string $content
267
+	 * @return    string
268
+	 */
269
+	public static function event_details($content)
270
+	{
271
+		global $post;
272
+		static $current_post_ID = 0;
273
+		if (
274
+			$current_post_ID !== $post->ID
275
+			&& $post->post_type === EspressoPostType::EVENTS
276
+			&& ! EED_Event_Single::$using_get_the_excerpt
277
+			&& ! post_password_required()
278
+		) {
279
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
280
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
281
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
282
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
283
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
284
+			// so the following allows this filter to be applied multiple times, but only once for real
285
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
286
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
287
+				// we need to first remove this callback from being applied to the_content()
288
+				// (otherwise it will recurse and blow up the interweb)
289
+				remove_filter(
290
+					'the_content',
291
+					array('EED_Event_Single', 'event_details'),
292
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
293
+				);
294
+				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
295
+				);
296
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
297
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
298
+				add_filter(
299
+					'the_content',
300
+					array('EED_Event_Single', 'event_details'),
301
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
302
+				);
303
+			} else {
304
+				$content = EED_Event_Single::use_filterable_display_order();
305
+			}
306
+		}
307
+		return $content;
308
+	}
309
+
310
+
311
+	/**
312
+	 * use_filterable_display_order
313
+	 *
314
+	 * @return string
315
+	 */
316
+	protected static function use_filterable_display_order()
317
+	{
318
+		// since the 'content-espresso_events-details.php' template might be used directly from within a theme,
319
+		// it uses the_content() for displaying the $post->post_content
320
+		// so in order to load a template that uses the_content()
321
+		// from within a callback being used to filter the_content(),
322
+		// we need to first remove this callback from being applied to the_content()
323
+		// (otherwise it will recurse and blow up the interweb)
324
+		remove_filter(
325
+			'the_content',
326
+			array('EED_Event_Single', 'event_details'),
327
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
328
+		);
329
+		// now add additional content
330
+		add_filter(
331
+			'the_content',
332
+			array('EED_Event_Single', 'event_datetimes'),
333
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY,
334
+			1
335
+		);
336
+		add_filter(
337
+			'the_content',
338
+			array('EED_Event_Single', 'event_tickets'),
339
+			EED_Event_Single::EVENT_TICKETS_PRIORITY,
340
+			1
341
+		);
342
+		add_filter(
343
+			'the_content',
344
+			array('EED_Event_Single', 'event_venues'),
345
+			EED_Event_Single::EVENT_VENUES_PRIORITY,
346
+			1
347
+		);
348
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
349
+		// now load our template
350
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
351
+		// now add our filter back in, plus some others
352
+		add_filter(
353
+			'the_content',
354
+			array('EED_Event_Single', 'event_details'),
355
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
356
+		);
357
+		remove_filter(
358
+			'the_content',
359
+			array('EED_Event_Single', 'event_datetimes'),
360
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY
361
+		);
362
+		remove_filter(
363
+			'the_content',
364
+			array('EED_Event_Single', 'event_tickets'),
365
+			EED_Event_Single::EVENT_TICKETS_PRIORITY
366
+		);
367
+		remove_filter(
368
+			'the_content',
369
+			array('EED_Event_Single', 'event_venues'),
370
+			EED_Event_Single::EVENT_VENUES_PRIORITY
371
+		);
372
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
373
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
374
+		return $content;
375
+	}
376
+
377
+
378
+	/**
379
+	 * event_datetimes - adds datetimes ABOVE content
380
+	 *
381
+	 * @param        string $content
382
+	 * @return        string
383
+	 */
384
+	public static function event_datetimes($content)
385
+	{
386
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
387
+	}
388
+
389
+
390
+	/**
391
+	 * event_tickets - adds tickets ABOVE content (which includes datetimes)
392
+	 *
393
+	 * @param        string $content
394
+	 * @return        string
395
+	 */
396
+	public static function event_tickets($content)
397
+	{
398
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
399
+	}
400
+
401
+
402
+	/**
403
+	 * event_venues
404
+	 *
405
+	 * @param    string $content
406
+	 * @return    string
407
+	 */
408
+	public static function event_venue($content)
409
+	{
410
+		return EED_Event_Single::event_venues($content);
411
+	}
412
+
413
+
414
+	/**
415
+	 * event_venues - adds venues BELOW content
416
+	 *
417
+	 * @param        string $content
418
+	 * @return        string
419
+	 */
420
+	public static function event_venues($content)
421
+	{
422
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
423
+	}
424
+
425
+
426
+	/**
427
+	 * loop_end
428
+	 *
429
+	 * @param        array $wp_query_array an array containing the WP_Query object
430
+	 * @return        void
431
+	 */
432
+	public static function loop_end($wp_query_array)
433
+	{
434
+		global $post;
435
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
436
+	}
437
+
438
+
439
+	/**
440
+	 * wp_enqueue_scripts
441
+	 *
442
+	 * @return    void
443
+	 */
444
+	public function wp_enqueue_scripts()
445
+	{
446
+		// get some style
447
+		if (
448
+			apply_filters('FHEE_enable_default_espresso_css', true)
449
+			&& apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
450
+		) {
451
+			// first check uploads folder
452
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
453
+				wp_register_style(
454
+					$this->theme,
455
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
456
+					array('dashicons', 'espresso_default')
457
+				);
458
+			} else {
459
+				wp_register_style(
460
+					$this->theme,
461
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
462
+					array('dashicons', 'espresso_default')
463
+				);
464
+			}
465
+			wp_enqueue_script($this->theme);
466
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
467
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
468
+			}
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 * display_venue
475
+	 *
476
+	 * @return    bool
477
+	 */
478
+	public static function display_venue()
479
+	{
480
+		/** @type EE_Event_Single_Config $config */
481
+		$config = EED_Event_Single::instance()->config();
482
+		$display_venue = $config->display_venue === null ? true : $config->display_venue;
483
+		$venue_name = EEH_Venue_View::venue_name();
484
+		return $display_venue && ! empty($venue_name);
485
+	}
486 486
 }
487 487
 
488 488
 
@@ -494,5 +494,5 @@  discard block
 block discarded – undo
494 494
  */
495 495
 function espresso_display_venue_in_event_details()
496 496
 {
497
-    return EED_Event_Single::display_venue();
497
+	return EED_Event_Single::display_venue();
498 498
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         );
59 59
         $custom_post_types = $custom_post_type_definitions->getDefinitions();
60 60
         EED_Module::registerRoute(
61
-            $custom_post_types[ EspressoPostType::EVENTS ]['singular_slug'],
61
+            $custom_post_types[EspressoPostType::EVENTS]['singular_slug'],
62 62
             'Event_Single',
63 63
             'run'
64 64
         );
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function set_definitions()
85 85
     {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
86
+        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
87
+        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/');
88 88
     }
89 89
 
90 90
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     {
227 227
         global $post;
228 228
         return ((function_exists('wp_is_block_theme') && wp_is_block_theme()) || in_the_loop()) && $post->ID === (int) $id
229
-            ? espresso_event_status_banner($post->ID) . $title
229
+            ? espresso_event_status_banner($post->ID).$title
230 230
             : $title;
231 231
     }
232 232
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public static function event_datetimes($content)
385 385
     {
386
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
387 387
     }
388 388
 
389 389
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public static function event_tickets($content)
397 397
     {
398
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
399 399
     }
400 400
 
401 401
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public static function event_venues($content)
421 421
     {
422
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
423 423
     }
424 424
 
425 425
 
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
             && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
450 450
         ) {
451 451
             // first check uploads folder
452
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
453 453
                 wp_register_style(
454 454
                     $this->theme,
455
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
456 456
                     array('dashicons', 'espresso_default')
457 457
                 );
458 458
             } else {
459 459
                 wp_register_style(
460 460
                     $this->theme,
461
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
461
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
462 462
                     array('dashicons', 'espresso_default')
463 463
                 );
464 464
             }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page.core.php 2 patches
Indentation   +1548 added lines, -1548 removed lines patch added patch discarded remove patch
@@ -14,1558 +14,1558 @@
 block discarded – undo
14 14
  */
15 15
 class Venues_Admin_Page extends EE_Admin_Page_CPT
16 16
 {
17
-    /**
18
-     * primary key for the venue model
19
-     */
20
-    private int $VNU_ID = 0;
21
-
22
-    /**
23
-     * This will hold the venue object for venue_details screen.
24
-     *
25
-     * @var EE_Venue|EE_CPT_Base|null $_cpt_model_obj
26
-     */
27
-    protected $_cpt_model_obj;
28
-
29
-
30
-    /**
31
-     * This will hold the category object for category_details screen.
32
-     *
33
-     * @var stdClass|null $_category
34
-     */
35
-    protected ?stdClass $_category = null;
36
-
37
-
38
-    /**
39
-     * This property will hold the venue model instance
40
-     *
41
-     * @var EEM_Venue|null $_venue_model
42
-     */
43
-    protected ?EEM_Venue $_venue_model = null;
44
-
45
-
46
-    /**
47
-     * @throws EE_Error
48
-     * @throws ReflectionException
49
-     */
50
-    protected function _init_page_props()
51
-    {
52
-        // is there a vnu_id in the request?
53
-        $this->VNU_ID = $this->request->getRequestParam('VNU_ID', 0, DataType::INT);
54
-        $this->VNU_ID = $this->request->getRequestParam('post', $this->VNU_ID, DataType::INT);
55
-        $this->VNU_ID = $this->request->getRequestParam('post_ID', $this->VNU_ID, DataType::INT);
56
-
57
-        $this->page_slug        = EE_VENUES_PG_SLUG;
58
-        $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
59
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
60
-        $this->page_label       = esc_html__('Event Venues', 'event_espresso');
61
-        $this->_cpt_model_names = [
62
-            'create_new' => 'EEM_Venue',
63
-            'edit'       => 'EEM_Venue',
64
-        ];
65
-        $this->_cpt_edit_routes = [
66
-            'espresso_venues' => 'edit',
67
-        ];
68
-        $this->_venue_model     = EEM_Venue::instance();
69
-    }
70
-
71
-
72
-    protected function _ajax_hooks()
73
-    {
74
-        // todo: all hooks for ee_venues ajax goes in here.
75
-    }
76
-
77
-
78
-    protected function _define_page_props()
79
-    {
80
-        $this->_admin_page_title = $this->page_label;
81
-        $this->_labels           = [
82
-            'buttons'      => [
83
-                'add'             => esc_html__('Add New Venue', 'event_espresso'),
84
-                'edit'            => esc_html__('Edit Venue', 'event_espresso'),
85
-                'delete'          => esc_html__('Delete Venue', 'event_espresso'),
86
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
87
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
88
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
89
-            ],
90
-            'editor_title' => [
91
-                'espresso_venues' => esc_html__('Edit Venue', 'event_espresso'),
92
-            ],
93
-            'publishbox'   => [
94
-                'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
95
-                'edit'                => esc_html__('Update Venue', 'event_espresso'),
96
-                'add_category'        => esc_html__('Save New Category', 'event_espresso'),
97
-                'edit_category'       => esc_html__('Update Category', 'event_espresso'),
98
-                'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
99
-            ],
100
-        ];
101
-    }
102
-
103
-
104
-    protected function _set_page_routes()
105
-    {
106
-        // load formatter helper
107
-        // load field generator helper
108
-
109
-
110
-        $this->_page_routes = [
111
-            'default'                    => [
112
-                'func'       => [$this, '_overview_list_table'],
113
-                'capability' => 'ee_read_venues',
114
-            ],
115
-            'create_new'                 => [
116
-                'func'       => [$this, '_create_new_cpt_item'],
117
-                'capability' => 'ee_edit_venues',
118
-            ],
119
-            'edit'                       => [
120
-                'func'       => [$this, '_edit_cpt_item'],
121
-                'capability' => 'ee_edit_venue',
122
-                'obj_id'     => $this->VNU_ID,
123
-            ],
124
-            'trash_venue'                => [
125
-                'func'       => [$this, '_trash_or_restore_venue'],
126
-                'args'       => ['venue_status' => 'trash'],
127
-                'noheader'   => true,
128
-                'capability' => 'ee_delete_venue',
129
-                'obj_id'     => $this->VNU_ID,
130
-            ],
131
-            'trash_venues'               => [
132
-                'func'       => [$this, '_trash_or_restore_venues'],
133
-                'args'       => ['venue_status' => 'trash'],
134
-                'noheader'   => true,
135
-                'capability' => 'ee_delete_venues',
136
-            ],
137
-            'restore_venue'              => [
138
-                'func'       => [$this, '_trash_or_restore_venue'],
139
-                'args'       => ['venue_status' => 'draft'],
140
-                'noheader'   => true,
141
-                'capability' => 'ee_delete_venue',
142
-                'obj_id'     => $this->VNU_ID,
143
-            ],
144
-            'restore_venues'             => [
145
-                'func'       => [$this, '_trash_or_restore_venues'],
146
-                'args'       => ['venue_status' => 'draft'],
147
-                'noheader'   => true,
148
-                'capability' => 'ee_delete_venues',
149
-            ],
150
-            'delete_venues'              => [
151
-                'func'       => [$this, '_delete_venues'],
152
-                'noheader'   => true,
153
-                'capability' => 'ee_delete_venues',
154
-            ],
155
-            'delete_venue'               => [
156
-                'func'       => [$this, '_delete_venue'],
157
-                'args'       => ['redirect_after' => true],
158
-                'noheader'   => true,
159
-                'capability' => 'ee_delete_venue',
160
-                'obj_id'     => $this->VNU_ID,
161
-            ],
162
-            // settings related
163
-            'google_map_settings'        => [
164
-                'func'       => [$this, '_google_map_settings'],
165
-                'capability' => 'manage_options',
166
-            ],
167
-            'update_google_map_settings' => [
168
-                'func'       => [$this, '_update_google_map_settings'],
169
-                'capability' => 'manage_options',
170
-                'noheader'   => true,
171
-            ],
172
-            // venue category tab related
173
-            'add_category'               => [
174
-                'func'       => [$this, '_category_details'],
175
-                'args'       => ['add'],
176
-                'capability' => 'ee_edit_venue_category',
177
-            ],
178
-            'edit_category'              => [
179
-                'func'       => [$this, '_category_details'],
180
-                'args'       => ['edit'],
181
-                'capability' => 'ee_edit_venue_category',
182
-            ],
183
-            'delete_categories'          => [
184
-                'func'       => [$this, '_delete_categories'],
185
-                'noheader'   => true,
186
-                'capability' => 'ee_delete_venue_category',
187
-            ],
188
-
189
-            'delete_category' => [
190
-                'func'       => [$this, '_delete_categories'],
191
-                'noheader'   => true,
192
-                'capability' => 'ee_delete_venue_category',
193
-            ],
194
-
195
-            'insert_category' => [
196
-                'func'       => [$this, '_insert_or_update_category'],
197
-                'args'       => ['new_category' => true],
198
-                'noheader'   => true,
199
-                'capability' => 'ee_edit_venue_category',
200
-            ],
201
-
202
-            'update_category'   => [
203
-                'func'       => [$this, '_insert_or_update_category'],
204
-                'args'       => ['new_category' => false],
205
-                'noheader'   => true,
206
-                'capability' => 'ee_edit_venue_category',
207
-            ],
208
-            'export_categories' => [
209
-                'func'       => [$this, '_categories_export'],
210
-                'noheader'   => true,
211
-                'capability' => 'export',
212
-            ],
213
-            'import_categories' => [
214
-                'func'       => [$this, '_import_categories'],
215
-                'capability' => 'import',
216
-            ],
217
-            'category_list'     => [
218
-                'func'       => [$this, '_category_list_table'],
219
-                'capability' => 'ee_manage_venue_categories',
220
-            ],
221
-        ];
222
-    }
223
-
224
-
225
-    protected function _set_page_config()
226
-    {
227
-        $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
228
-        $help_tabs  = [
229
-            'venues_editor_help_tab'                                               => [
230
-                'title'    => esc_html__('Venue Editor', 'event_espresso'),
231
-                'filename' => 'venues_editor',
232
-            ],
233
-            'venues_editor_title_richtexteditor_help_tab'                          => [
234
-                'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
235
-                'filename' => 'venues_editor_title_richtexteditor',
236
-            ],
237
-            'venues_editor_tags_categories_help_tab'                               => [
238
-                'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
239
-                'filename' => 'venues_editor_tags_categories',
240
-            ],
241
-            'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
242
-                'title'    => esc_html__(
243
-                    'Venue Editor Physical Location & Google Map & Virtual Location',
244
-                    'event_espresso'
245
-                ),
246
-                'filename' => 'venues_editor_physical_location_google_map_virtual_location',
247
-            ],
248
-            'venues_editor_save_new_venue_help_tab'                                => [
249
-                'title'    => esc_html__('Save New Venue', 'event_espresso'),
250
-                'filename' => 'venues_editor_save_new_venue',
251
-            ],
252
-            'venues_editor_other_help_tab'                                         => [
253
-                'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
254
-                'filename' => 'venues_editor_other',
255
-            ],
256
-        ];
257
-
258
-        $this->_page_config = [
259
-            'default'             => [
260
-                'nav'           => [
261
-                    'label' => esc_html__('Overview', 'event_espresso'),
262
-                    'icon'  => 'dashicons-list-view',
263
-                    'order' => 10,
264
-                ],
265
-                'list_table'    => 'Venues_Admin_List_Table',
266
-                'help_tabs'     => [
267
-                    'venues_overview_help_tab'                           => [
268
-                        'title'    => esc_html__('Venues Overview', 'event_espresso'),
269
-                        'filename' => 'venues_overview',
270
-                    ],
271
-                    'venues_overview_table_column_headings_help_tab'     => [
272
-                        'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
273
-                        'filename' => 'venues_overview_table_column_headings',
274
-                    ],
275
-                    'venues_overview_views_bulk_actions_search_help_tab' => [
276
-                        'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
277
-                        'filename' => 'venues_overview_views_bulk_actions_search',
278
-                    ],
279
-                ],
280
-                'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
281
-                'require_nonce' => false,
282
-            ],
283
-            'create_new'          => [
284
-                'nav'           => [
285
-                    'label'      => esc_html__('Add Venue', 'event_espresso'),
286
-                    'icon'       => 'dashicons-plus-alt',
287
-                    'order'      => 15,
288
-                    'persistent' => false,
289
-                ],
290
-                'help_tabs'     => $help_tabs,
291
-                'metaboxes'     => ['_venue_editor_metaboxes'],
292
-                'require_nonce' => false,
293
-            ],
294
-            'edit'                => [
295
-                'nav'           => [
296
-                    'label'      => esc_html__('Edit Venue', 'event_espresso'),
297
-                    'icon'       => 'dashicons-edit-large',
298
-                    'order'      => 15,
299
-                    'persistent' => false,
300
-                    'url'        => $this->VNU_ID
301
-                        ? add_query_arg(['post' => $this->VNU_ID], $this->_current_page_view_url)
302
-                        : $this->_admin_base_url,
303
-                ],
304
-                'help_tabs'     => $help_tabs,
305
-                'metaboxes'     => ['_venue_editor_metaboxes'],
306
-                'require_nonce' => false,
307
-            ],
308
-            'google_map_settings' => [
309
-                'nav'           => [
310
-                    'label' => esc_html__('Google Maps', 'event_espresso'),
311
-                    'icon'  => 'dashicons-location-alt',
312
-                    'order' => 40,
313
-                ],
314
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
315
-                'help_tabs'     => [
316
-                    'general_settings_google_maps_help_tab' => [
317
-                        'title'    => esc_html__('Google Maps', 'event_espresso'),
318
-                        'filename' => 'general_settings_google_maps',
319
-                    ],
320
-                ],
321
-                'require_nonce' => false,
322
-            ],
323
-            // venue category stuff
324
-            'add_category'        => [
325
-                'nav'           => [
326
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
327
-                    'icon'       => 'dashicons-plus-alt',
328
-                    'order'      => 25,
329
-                    'persistent' => false,
330
-                ],
331
-                'metaboxes'     => ['_publish_post_box'],
332
-                'help_tabs'     => [
333
-                    'venues_add_category_help_tab' => [
334
-                        'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
335
-                        'filename' => 'venues_add_category',
336
-                    ],
337
-                ],
338
-                'require_nonce' => false,
339
-            ],
340
-            'edit_category'       => [
341
-                'nav'           => [
342
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
343
-                    'icon'       => 'dashicons-edit-large',
344
-                    'order'      => 25,
345
-                    'persistent' => false,
346
-                    'url'        => $EVT_CAT_ID
347
-                        ? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
348
-                        : $this->_admin_base_url,
349
-                ],
350
-                'metaboxes'     => ['_publish_post_box'],
351
-                'help_tabs'     => [
352
-                    'venues_edit_category_help_tab' => [
353
-                        'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
354
-                        'filename' => 'venues_edit_category',
355
-                    ],
356
-                ],
357
-                'require_nonce' => false,
358
-            ],
359
-            'category_list'       => [
360
-                'nav'           => [
361
-                    'label' => esc_html__('Categories', 'event_espresso'),
362
-                    'icon'  => 'dashicons-networking',
363
-                    'order' => 20,
364
-                ],
365
-                'list_table'    => 'Venue_Categories_Admin_List_Table',
366
-                'help_tabs'     => [
367
-                    'venues_categories_help_tab'                       => [
368
-                        'title'    => esc_html__('Venue Categories', 'event_espresso'),
369
-                        'filename' => 'venues_categories',
370
-                    ],
371
-                    'venues_categories_table_column_headings_help_tab' => [
372
-                        'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
373
-                        'filename' => 'venues_categories_table_column_headings',
374
-                    ],
375
-                    'venues_categories_views_help_tab'                 => [
376
-                        'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
377
-                        'filename' => 'venues_categories_views',
378
-                    ],
379
-                    'venues_categories_other_help_tab'                 => [
380
-                        'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
381
-                        'filename' => 'venues_categories_other',
382
-                    ],
383
-                ],
384
-                'metaboxes'     => $this->_default_espresso_metaboxes,
385
-                'require_nonce' => false,
386
-            ],
387
-        ];
388
-    }
389
-
390
-
391
-    protected function _add_screen_options()
392
-    {
393
-        // todo
394
-    }
395
-
396
-
397
-    protected function _add_screen_options_default()
398
-    {
399
-        $this->_per_page_screen_option();
400
-    }
401
-
402
-
403
-    protected function _add_screen_options_category_list()
404
-    {
405
-        $page_title              = $this->_admin_page_title;
406
-        $this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
407
-        $this->_per_page_screen_option();
408
-        $this->_admin_page_title = $page_title;
409
-    }
410
-
411
-
412
-    // none of the below group are currently used for Event Venues
413
-    protected function _add_feature_pointers()
414
-    {
415
-    }
416
-
417
-
418
-    public function admin_init()
419
-    {
420
-    }
421
-
422
-
423
-    public function admin_notices()
424
-    {
425
-    }
426
-
427
-
428
-    public function admin_footer_scripts()
429
-    {
430
-    }
431
-
432
-
433
-    public function load_scripts_styles_create_new()
434
-    {
435
-        $this->load_scripts_styles_edit();
436
-    }
437
-
438
-
439
-    public function load_scripts_styles()
440
-    {
441
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
442
-        wp_enqueue_style('ee-cat-admin');
443
-    }
444
-
445
-
446
-    public function load_scripts_styles_add_category()
447
-    {
448
-        $this->load_scripts_styles_edit_category();
449
-    }
450
-
451
-
452
-    public function load_scripts_styles_edit_category()
453
-    {
454
-        wp_enqueue_style('editor-buttons');
455
-    }
456
-
457
-
458
-    public function load_scripts_styles_edit()
459
-    {
460
-        // styles
461
-        wp_enqueue_style('espresso-ui-theme');
462
-        wp_register_style(
463
-            'espresso_venues',
464
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
465
-            [],
466
-            EVENT_ESPRESSO_VERSION
467
-        );
468
-        wp_enqueue_style('espresso_venues');
469
-    }
470
-
471
-
472
-    protected function _set_list_table_views_default()
473
-    {
474
-        $this->_views = [
475
-            'all' => [
476
-                'slug'        => 'all',
477
-                'label'       => esc_html__('View All Venues', 'event_espresso'),
478
-                'count'       => 0,
479
-                'bulk_action' => [],
480
-            ],
481
-        ];
482
-
483
-        if ($this->capabilities->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
484
-            $this->_views['all']['bulk_action'] = [
485
-                'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
486
-            ];
487
-            $this->_views['trash']              = [
488
-                'slug'        => 'trash',
489
-                'label'       => esc_html__('Trash', 'event_espresso'),
490
-                'count'       => 0,
491
-                'bulk_action' => [
492
-                    'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
493
-                    'delete_venues'  => esc_html__('Delete', 'event_espresso'),
494
-                ],
495
-            ];
496
-        }
497
-    }
498
-
499
-
500
-    protected function _set_list_table_views_category_list()
501
-    {
502
-        $this->_views = [
503
-            'all' => [
504
-                'slug'        => 'all',
505
-                'label'       => esc_html__('All', 'event_espresso'),
506
-                'count'       => 0,
507
-                'bulk_action' => [
508
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
509
-                ],
510
-            ],
511
-        ];
512
-    }
513
-
514
-
515
-    /**
516
-     * @throws EE_Error
517
-     */
518
-    protected function _overview_list_table()
519
-    {
520
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
521
-        $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
522
-            get_post_type_archive_link(EspressoPostType::VENUES),
523
-            esc_html__("View Venue Archive Page", "event_espresso"),
524
-            'button'
525
-        );
526
-
527
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
528
-            'create_new',
529
-            'add',
530
-            [],
531
-            'add-new-h2'
532
-        );
533
-
534
-        $this->_search_btn_label = esc_html__('Venues', 'event_espresso');
535
-        $this->display_admin_list_table_page_with_sidebar();
536
-    }
537
-
538
-
539
-    /**
540
-     * @throws EE_Error
541
-     * @throws ReflectionException
542
-     */
543
-    public function extra_misc_actions_publish_box()
544
-    {
545
-        $extra_rows = [
546
-            'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
547
-            'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
548
-            'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
549
-        ];
550
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
551
-        EEH_Template::display_template($template, $extra_rows);
552
-    }
553
-
554
-
555
-    /*************        Google Maps        *************
17
+	/**
18
+	 * primary key for the venue model
19
+	 */
20
+	private int $VNU_ID = 0;
21
+
22
+	/**
23
+	 * This will hold the venue object for venue_details screen.
24
+	 *
25
+	 * @var EE_Venue|EE_CPT_Base|null $_cpt_model_obj
26
+	 */
27
+	protected $_cpt_model_obj;
28
+
29
+
30
+	/**
31
+	 * This will hold the category object for category_details screen.
32
+	 *
33
+	 * @var stdClass|null $_category
34
+	 */
35
+	protected ?stdClass $_category = null;
36
+
37
+
38
+	/**
39
+	 * This property will hold the venue model instance
40
+	 *
41
+	 * @var EEM_Venue|null $_venue_model
42
+	 */
43
+	protected ?EEM_Venue $_venue_model = null;
44
+
45
+
46
+	/**
47
+	 * @throws EE_Error
48
+	 * @throws ReflectionException
49
+	 */
50
+	protected function _init_page_props()
51
+	{
52
+		// is there a vnu_id in the request?
53
+		$this->VNU_ID = $this->request->getRequestParam('VNU_ID', 0, DataType::INT);
54
+		$this->VNU_ID = $this->request->getRequestParam('post', $this->VNU_ID, DataType::INT);
55
+		$this->VNU_ID = $this->request->getRequestParam('post_ID', $this->VNU_ID, DataType::INT);
56
+
57
+		$this->page_slug        = EE_VENUES_PG_SLUG;
58
+		$this->_admin_base_url  = EE_VENUES_ADMIN_URL;
59
+		$this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
60
+		$this->page_label       = esc_html__('Event Venues', 'event_espresso');
61
+		$this->_cpt_model_names = [
62
+			'create_new' => 'EEM_Venue',
63
+			'edit'       => 'EEM_Venue',
64
+		];
65
+		$this->_cpt_edit_routes = [
66
+			'espresso_venues' => 'edit',
67
+		];
68
+		$this->_venue_model     = EEM_Venue::instance();
69
+	}
70
+
71
+
72
+	protected function _ajax_hooks()
73
+	{
74
+		// todo: all hooks for ee_venues ajax goes in here.
75
+	}
76
+
77
+
78
+	protected function _define_page_props()
79
+	{
80
+		$this->_admin_page_title = $this->page_label;
81
+		$this->_labels           = [
82
+			'buttons'      => [
83
+				'add'             => esc_html__('Add New Venue', 'event_espresso'),
84
+				'edit'            => esc_html__('Edit Venue', 'event_espresso'),
85
+				'delete'          => esc_html__('Delete Venue', 'event_espresso'),
86
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
87
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
88
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
89
+			],
90
+			'editor_title' => [
91
+				'espresso_venues' => esc_html__('Edit Venue', 'event_espresso'),
92
+			],
93
+			'publishbox'   => [
94
+				'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
95
+				'edit'                => esc_html__('Update Venue', 'event_espresso'),
96
+				'add_category'        => esc_html__('Save New Category', 'event_espresso'),
97
+				'edit_category'       => esc_html__('Update Category', 'event_espresso'),
98
+				'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
99
+			],
100
+		];
101
+	}
102
+
103
+
104
+	protected function _set_page_routes()
105
+	{
106
+		// load formatter helper
107
+		// load field generator helper
108
+
109
+
110
+		$this->_page_routes = [
111
+			'default'                    => [
112
+				'func'       => [$this, '_overview_list_table'],
113
+				'capability' => 'ee_read_venues',
114
+			],
115
+			'create_new'                 => [
116
+				'func'       => [$this, '_create_new_cpt_item'],
117
+				'capability' => 'ee_edit_venues',
118
+			],
119
+			'edit'                       => [
120
+				'func'       => [$this, '_edit_cpt_item'],
121
+				'capability' => 'ee_edit_venue',
122
+				'obj_id'     => $this->VNU_ID,
123
+			],
124
+			'trash_venue'                => [
125
+				'func'       => [$this, '_trash_or_restore_venue'],
126
+				'args'       => ['venue_status' => 'trash'],
127
+				'noheader'   => true,
128
+				'capability' => 'ee_delete_venue',
129
+				'obj_id'     => $this->VNU_ID,
130
+			],
131
+			'trash_venues'               => [
132
+				'func'       => [$this, '_trash_or_restore_venues'],
133
+				'args'       => ['venue_status' => 'trash'],
134
+				'noheader'   => true,
135
+				'capability' => 'ee_delete_venues',
136
+			],
137
+			'restore_venue'              => [
138
+				'func'       => [$this, '_trash_or_restore_venue'],
139
+				'args'       => ['venue_status' => 'draft'],
140
+				'noheader'   => true,
141
+				'capability' => 'ee_delete_venue',
142
+				'obj_id'     => $this->VNU_ID,
143
+			],
144
+			'restore_venues'             => [
145
+				'func'       => [$this, '_trash_or_restore_venues'],
146
+				'args'       => ['venue_status' => 'draft'],
147
+				'noheader'   => true,
148
+				'capability' => 'ee_delete_venues',
149
+			],
150
+			'delete_venues'              => [
151
+				'func'       => [$this, '_delete_venues'],
152
+				'noheader'   => true,
153
+				'capability' => 'ee_delete_venues',
154
+			],
155
+			'delete_venue'               => [
156
+				'func'       => [$this, '_delete_venue'],
157
+				'args'       => ['redirect_after' => true],
158
+				'noheader'   => true,
159
+				'capability' => 'ee_delete_venue',
160
+				'obj_id'     => $this->VNU_ID,
161
+			],
162
+			// settings related
163
+			'google_map_settings'        => [
164
+				'func'       => [$this, '_google_map_settings'],
165
+				'capability' => 'manage_options',
166
+			],
167
+			'update_google_map_settings' => [
168
+				'func'       => [$this, '_update_google_map_settings'],
169
+				'capability' => 'manage_options',
170
+				'noheader'   => true,
171
+			],
172
+			// venue category tab related
173
+			'add_category'               => [
174
+				'func'       => [$this, '_category_details'],
175
+				'args'       => ['add'],
176
+				'capability' => 'ee_edit_venue_category',
177
+			],
178
+			'edit_category'              => [
179
+				'func'       => [$this, '_category_details'],
180
+				'args'       => ['edit'],
181
+				'capability' => 'ee_edit_venue_category',
182
+			],
183
+			'delete_categories'          => [
184
+				'func'       => [$this, '_delete_categories'],
185
+				'noheader'   => true,
186
+				'capability' => 'ee_delete_venue_category',
187
+			],
188
+
189
+			'delete_category' => [
190
+				'func'       => [$this, '_delete_categories'],
191
+				'noheader'   => true,
192
+				'capability' => 'ee_delete_venue_category',
193
+			],
194
+
195
+			'insert_category' => [
196
+				'func'       => [$this, '_insert_or_update_category'],
197
+				'args'       => ['new_category' => true],
198
+				'noheader'   => true,
199
+				'capability' => 'ee_edit_venue_category',
200
+			],
201
+
202
+			'update_category'   => [
203
+				'func'       => [$this, '_insert_or_update_category'],
204
+				'args'       => ['new_category' => false],
205
+				'noheader'   => true,
206
+				'capability' => 'ee_edit_venue_category',
207
+			],
208
+			'export_categories' => [
209
+				'func'       => [$this, '_categories_export'],
210
+				'noheader'   => true,
211
+				'capability' => 'export',
212
+			],
213
+			'import_categories' => [
214
+				'func'       => [$this, '_import_categories'],
215
+				'capability' => 'import',
216
+			],
217
+			'category_list'     => [
218
+				'func'       => [$this, '_category_list_table'],
219
+				'capability' => 'ee_manage_venue_categories',
220
+			],
221
+		];
222
+	}
223
+
224
+
225
+	protected function _set_page_config()
226
+	{
227
+		$EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
228
+		$help_tabs  = [
229
+			'venues_editor_help_tab'                                               => [
230
+				'title'    => esc_html__('Venue Editor', 'event_espresso'),
231
+				'filename' => 'venues_editor',
232
+			],
233
+			'venues_editor_title_richtexteditor_help_tab'                          => [
234
+				'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
235
+				'filename' => 'venues_editor_title_richtexteditor',
236
+			],
237
+			'venues_editor_tags_categories_help_tab'                               => [
238
+				'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
239
+				'filename' => 'venues_editor_tags_categories',
240
+			],
241
+			'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
242
+				'title'    => esc_html__(
243
+					'Venue Editor Physical Location & Google Map & Virtual Location',
244
+					'event_espresso'
245
+				),
246
+				'filename' => 'venues_editor_physical_location_google_map_virtual_location',
247
+			],
248
+			'venues_editor_save_new_venue_help_tab'                                => [
249
+				'title'    => esc_html__('Save New Venue', 'event_espresso'),
250
+				'filename' => 'venues_editor_save_new_venue',
251
+			],
252
+			'venues_editor_other_help_tab'                                         => [
253
+				'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
254
+				'filename' => 'venues_editor_other',
255
+			],
256
+		];
257
+
258
+		$this->_page_config = [
259
+			'default'             => [
260
+				'nav'           => [
261
+					'label' => esc_html__('Overview', 'event_espresso'),
262
+					'icon'  => 'dashicons-list-view',
263
+					'order' => 10,
264
+				],
265
+				'list_table'    => 'Venues_Admin_List_Table',
266
+				'help_tabs'     => [
267
+					'venues_overview_help_tab'                           => [
268
+						'title'    => esc_html__('Venues Overview', 'event_espresso'),
269
+						'filename' => 'venues_overview',
270
+					],
271
+					'venues_overview_table_column_headings_help_tab'     => [
272
+						'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
273
+						'filename' => 'venues_overview_table_column_headings',
274
+					],
275
+					'venues_overview_views_bulk_actions_search_help_tab' => [
276
+						'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
277
+						'filename' => 'venues_overview_views_bulk_actions_search',
278
+					],
279
+				],
280
+				'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
281
+				'require_nonce' => false,
282
+			],
283
+			'create_new'          => [
284
+				'nav'           => [
285
+					'label'      => esc_html__('Add Venue', 'event_espresso'),
286
+					'icon'       => 'dashicons-plus-alt',
287
+					'order'      => 15,
288
+					'persistent' => false,
289
+				],
290
+				'help_tabs'     => $help_tabs,
291
+				'metaboxes'     => ['_venue_editor_metaboxes'],
292
+				'require_nonce' => false,
293
+			],
294
+			'edit'                => [
295
+				'nav'           => [
296
+					'label'      => esc_html__('Edit Venue', 'event_espresso'),
297
+					'icon'       => 'dashicons-edit-large',
298
+					'order'      => 15,
299
+					'persistent' => false,
300
+					'url'        => $this->VNU_ID
301
+						? add_query_arg(['post' => $this->VNU_ID], $this->_current_page_view_url)
302
+						: $this->_admin_base_url,
303
+				],
304
+				'help_tabs'     => $help_tabs,
305
+				'metaboxes'     => ['_venue_editor_metaboxes'],
306
+				'require_nonce' => false,
307
+			],
308
+			'google_map_settings' => [
309
+				'nav'           => [
310
+					'label' => esc_html__('Google Maps', 'event_espresso'),
311
+					'icon'  => 'dashicons-location-alt',
312
+					'order' => 40,
313
+				],
314
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
315
+				'help_tabs'     => [
316
+					'general_settings_google_maps_help_tab' => [
317
+						'title'    => esc_html__('Google Maps', 'event_espresso'),
318
+						'filename' => 'general_settings_google_maps',
319
+					],
320
+				],
321
+				'require_nonce' => false,
322
+			],
323
+			// venue category stuff
324
+			'add_category'        => [
325
+				'nav'           => [
326
+					'label'      => esc_html__('Add Category', 'event_espresso'),
327
+					'icon'       => 'dashicons-plus-alt',
328
+					'order'      => 25,
329
+					'persistent' => false,
330
+				],
331
+				'metaboxes'     => ['_publish_post_box'],
332
+				'help_tabs'     => [
333
+					'venues_add_category_help_tab' => [
334
+						'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
335
+						'filename' => 'venues_add_category',
336
+					],
337
+				],
338
+				'require_nonce' => false,
339
+			],
340
+			'edit_category'       => [
341
+				'nav'           => [
342
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
343
+					'icon'       => 'dashicons-edit-large',
344
+					'order'      => 25,
345
+					'persistent' => false,
346
+					'url'        => $EVT_CAT_ID
347
+						? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
348
+						: $this->_admin_base_url,
349
+				],
350
+				'metaboxes'     => ['_publish_post_box'],
351
+				'help_tabs'     => [
352
+					'venues_edit_category_help_tab' => [
353
+						'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
354
+						'filename' => 'venues_edit_category',
355
+					],
356
+				],
357
+				'require_nonce' => false,
358
+			],
359
+			'category_list'       => [
360
+				'nav'           => [
361
+					'label' => esc_html__('Categories', 'event_espresso'),
362
+					'icon'  => 'dashicons-networking',
363
+					'order' => 20,
364
+				],
365
+				'list_table'    => 'Venue_Categories_Admin_List_Table',
366
+				'help_tabs'     => [
367
+					'venues_categories_help_tab'                       => [
368
+						'title'    => esc_html__('Venue Categories', 'event_espresso'),
369
+						'filename' => 'venues_categories',
370
+					],
371
+					'venues_categories_table_column_headings_help_tab' => [
372
+						'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
373
+						'filename' => 'venues_categories_table_column_headings',
374
+					],
375
+					'venues_categories_views_help_tab'                 => [
376
+						'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
377
+						'filename' => 'venues_categories_views',
378
+					],
379
+					'venues_categories_other_help_tab'                 => [
380
+						'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
381
+						'filename' => 'venues_categories_other',
382
+					],
383
+				],
384
+				'metaboxes'     => $this->_default_espresso_metaboxes,
385
+				'require_nonce' => false,
386
+			],
387
+		];
388
+	}
389
+
390
+
391
+	protected function _add_screen_options()
392
+	{
393
+		// todo
394
+	}
395
+
396
+
397
+	protected function _add_screen_options_default()
398
+	{
399
+		$this->_per_page_screen_option();
400
+	}
401
+
402
+
403
+	protected function _add_screen_options_category_list()
404
+	{
405
+		$page_title              = $this->_admin_page_title;
406
+		$this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
407
+		$this->_per_page_screen_option();
408
+		$this->_admin_page_title = $page_title;
409
+	}
410
+
411
+
412
+	// none of the below group are currently used for Event Venues
413
+	protected function _add_feature_pointers()
414
+	{
415
+	}
416
+
417
+
418
+	public function admin_init()
419
+	{
420
+	}
421
+
422
+
423
+	public function admin_notices()
424
+	{
425
+	}
426
+
427
+
428
+	public function admin_footer_scripts()
429
+	{
430
+	}
431
+
432
+
433
+	public function load_scripts_styles_create_new()
434
+	{
435
+		$this->load_scripts_styles_edit();
436
+	}
437
+
438
+
439
+	public function load_scripts_styles()
440
+	{
441
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
442
+		wp_enqueue_style('ee-cat-admin');
443
+	}
444
+
445
+
446
+	public function load_scripts_styles_add_category()
447
+	{
448
+		$this->load_scripts_styles_edit_category();
449
+	}
450
+
451
+
452
+	public function load_scripts_styles_edit_category()
453
+	{
454
+		wp_enqueue_style('editor-buttons');
455
+	}
456
+
457
+
458
+	public function load_scripts_styles_edit()
459
+	{
460
+		// styles
461
+		wp_enqueue_style('espresso-ui-theme');
462
+		wp_register_style(
463
+			'espresso_venues',
464
+			EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
465
+			[],
466
+			EVENT_ESPRESSO_VERSION
467
+		);
468
+		wp_enqueue_style('espresso_venues');
469
+	}
470
+
471
+
472
+	protected function _set_list_table_views_default()
473
+	{
474
+		$this->_views = [
475
+			'all' => [
476
+				'slug'        => 'all',
477
+				'label'       => esc_html__('View All Venues', 'event_espresso'),
478
+				'count'       => 0,
479
+				'bulk_action' => [],
480
+			],
481
+		];
482
+
483
+		if ($this->capabilities->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
484
+			$this->_views['all']['bulk_action'] = [
485
+				'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
486
+			];
487
+			$this->_views['trash']              = [
488
+				'slug'        => 'trash',
489
+				'label'       => esc_html__('Trash', 'event_espresso'),
490
+				'count'       => 0,
491
+				'bulk_action' => [
492
+					'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
493
+					'delete_venues'  => esc_html__('Delete', 'event_espresso'),
494
+				],
495
+			];
496
+		}
497
+	}
498
+
499
+
500
+	protected function _set_list_table_views_category_list()
501
+	{
502
+		$this->_views = [
503
+			'all' => [
504
+				'slug'        => 'all',
505
+				'label'       => esc_html__('All', 'event_espresso'),
506
+				'count'       => 0,
507
+				'bulk_action' => [
508
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
509
+				],
510
+			],
511
+		];
512
+	}
513
+
514
+
515
+	/**
516
+	 * @throws EE_Error
517
+	 */
518
+	protected function _overview_list_table()
519
+	{
520
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
521
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
522
+			get_post_type_archive_link(EspressoPostType::VENUES),
523
+			esc_html__("View Venue Archive Page", "event_espresso"),
524
+			'button'
525
+		);
526
+
527
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
528
+			'create_new',
529
+			'add',
530
+			[],
531
+			'add-new-h2'
532
+		);
533
+
534
+		$this->_search_btn_label = esc_html__('Venues', 'event_espresso');
535
+		$this->display_admin_list_table_page_with_sidebar();
536
+	}
537
+
538
+
539
+	/**
540
+	 * @throws EE_Error
541
+	 * @throws ReflectionException
542
+	 */
543
+	public function extra_misc_actions_publish_box()
544
+	{
545
+		$extra_rows = [
546
+			'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
547
+			'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
548
+			'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
549
+		];
550
+		$template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
551
+		EEH_Template::display_template($template, $extra_rows);
552
+	}
553
+
554
+
555
+	/*************        Google Maps        *************
556 556
      *
557 557
      * @throws EE_Error
558 558
      * @throws EE_Error
559 559
      */
560 560
 
561 561
 
562
-    protected function _google_map_settings()
563
-    {
564
-        $this->_template_args['values']           = $this->_yes_no_values;
565
-        $default_map_settings                     = new stdClass();
566
-        $default_map_settings->use_google_maps    = true;
567
-        $default_map_settings->google_map_api_key = '';
568
-        // for event details pages (reg page)
569
-        $default_map_settings->event_details_map_width = 585;
570
-        // ee_map_width_single
571
-        $default_map_settings->event_details_map_height = 362;
572
-        // ee_map_height_single
573
-        $default_map_settings->event_details_map_zoom = 14;
574
-        // ee_map_zoom_single
575
-        $default_map_settings->event_details_display_nav = true;
576
-        // ee_map_nav_display_single
577
-        $default_map_settings->event_details_nav_size = false;
578
-        // ee_map_nav_size_single
579
-        $default_map_settings->event_details_control_type = 'default';
580
-        // ee_map_type_control_single
581
-        $default_map_settings->event_details_map_align = 'center';
582
-        // ee_map_align_single
583
-
584
-        // for event list pages
585
-        $default_map_settings->event_list_map_width = 300;
586
-        // ee_map_width
587
-        $default_map_settings->event_list_map_height = 185;
588
-        // ee_map_height
589
-        $default_map_settings->event_list_map_zoom = 12;
590
-        // ee_map_zoom
591
-        $default_map_settings->event_list_display_nav = false;
592
-        // ee_map_nav_display
593
-        $default_map_settings->event_list_nav_size = true;
594
-        // ee_map_nav_size
595
-        $default_map_settings->event_list_control_type = 'dropdown';
596
-        // ee_map_type_control
597
-        $default_map_settings->event_list_map_align = 'center';
598
-        // ee_map_align
599
-
600
-        $this->_template_args['map_settings'] =
601
-            isset(EE_Registry::instance()->CFG->map_settings)
602
-            && ! empty(EE_Registry::instance()->CFG->map_settings)
603
-                ? (object) array_merge(
604
-                    (array) $default_map_settings,
605
-                    (array) EE_Registry::instance()->CFG->map_settings
606
-                )
607
-                : $default_map_settings;
608
-
609
-        $this->_set_add_edit_form_tags('update_google_map_settings');
610
-        $this->_set_publish_post_box_vars();
611
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
612
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
613
-            $this->_template_args,
614
-            true
615
-        );
616
-        $this->display_admin_page_with_sidebar();
617
-    }
618
-
619
-
620
-    /**
621
-     * @throws EE_Error
622
-     */
623
-    protected function _update_google_map_settings()
624
-    {
625
-        $map_settings = EE_Registry::instance()->CFG->map_settings;
626
-
627
-        $settings = [
628
-            'use_google_maps'            => 'int',
629
-            'google_map_api_key'         => 'string',
630
-            'event_details_map_width'    => 'int',
631
-            'event_details_map_zoom'     => 'int',
632
-            'event_details_display_nav'  => 'int',
633
-            'event_details_nav_size'     => 'int',
634
-            'event_details_control_type' => 'string',
635
-            'event_details_map_align'    => 'string',
636
-            'event_list_map_width'       => 'int',
637
-            'event_list_map_height'      => 'int',
638
-            'event_list_map_zoom'        => 'int',
639
-            'event_list_display_nav'     => 'int',
640
-            'event_list_nav_size'        => 'int',
641
-            'event_list_control_type'    => 'string',
642
-            'event_list_map_align'       => 'string',
643
-        ];
644
-
645
-        foreach ($settings as $setting => $type) {
646
-            $map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
647
-        }
648
-
649
-        EE_Registry::instance()->CFG->map_settings = apply_filters(
650
-            'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
651
-            $map_settings
652
-        );
653
-
654
-        $what    = 'Google Map Settings';
655
-        $success = $this->_update_espresso_configuration(
656
-            $what,
657
-            EE_Registry::instance()->CFG->map_settings,
658
-            __FILE__,
659
-            __FUNCTION__,
660
-            __LINE__
661
-        );
662
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
663
-    }
664
-
665
-
666
-    /**
667
-     * @throws EE_Error
668
-     * @throws ReflectionException
669
-     */
670
-    protected function _venue_editor_metaboxes()
671
-    {
672
-        $this->verify_cpt_object();
673
-
674
-        $this->addMetaBox(
675
-            'espresso_venue_address_options',
676
-            esc_html__('Physical Location', 'event_espresso'),
677
-            [$this, 'venue_address_metabox'],
678
-            $this->page_slug,
679
-            'side',
680
-            'core'
681
-        );
682
-        $this->addMetaBox(
683
-            'espresso_venue_gmap_options',
684
-            esc_html__('Google Map', 'event_espresso'),
685
-            [$this, 'venue_gmap_metabox'],
686
-            $this->page_slug,
687
-            'side'
688
-        );
689
-        $this->addMetaBox(
690
-            'espresso_venue_virtual_loc_options',
691
-            esc_html__('Virtual Location', 'event_espresso'),
692
-            [$this, 'venue_virtual_loc_metabox'],
693
-            $this->page_slug,
694
-            'side'
695
-        );
696
-    }
697
-
698
-
699
-    /**
700
-     * @throws EE_Error
701
-     * @throws ReflectionException
702
-     */
703
-    public function venue_gmap_metabox()
704
-    {
705
-        $template_args = [
706
-            'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
707
-                'vnu_enable_for_gmap',
708
-                $this->get_yes_no_values(),
709
-                $this->_cpt_model_obj instanceof EE_Venue && $this->_cpt_model_obj->enable_for_gmap()
710
-            ),
711
-            'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
712
-        ];
713
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
714
-        EEH_Template::display_template($template, $template_args);
715
-    }
716
-
717
-
718
-    /**
719
-     * @throws EE_Error
720
-     * @throws ReflectionException
721
-     */
722
-    public function venue_address_metabox()
723
-    {
724
-        $template_args['_venue'] = $this->_cpt_model_obj;
725
-
726
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
727
-            new EE_Question_Form_Input(
728
-                EE_Question::new_instance(
729
-                    ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
730
-                ),
731
-                EE_Answer::new_instance(
732
-                    [
733
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
734
-                            ? $this->_cpt_model_obj->state_ID()
735
-                            : 0,
736
-                    ]
737
-                ),
738
-                [
739
-                    'input_name'     => 'sta_id',
740
-                    'input_id'       => 'sta_id',
741
-                    'input_class'    => '',
742
-                    'input_prefix'   => '',
743
-                    'append_qstn_id' => false,
744
-                ]
745
-            )
746
-        );
747
-        $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
748
-            new EE_Question_Form_Input(
749
-                EE_Question::new_instance(
750
-                    ['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
751
-                ),
752
-                EE_Answer::new_instance(
753
-                    [
754
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
755
-                            ? $this->_cpt_model_obj->country_ID()
756
-                            : 0,
757
-                    ]
758
-                ),
759
-                [
760
-                    'input_name'     => 'cnt_iso',
761
-                    'input_id'       => 'cnt_iso',
762
-                    'input_class'    => '',
763
-                    'input_prefix'   => '',
764
-                    'append_qstn_id' => false,
765
-                ]
766
-            )
767
-        );
768
-
769
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
770
-        EEH_Template::display_template($template, $template_args);
771
-    }
772
-
773
-
774
-    public function venue_virtual_loc_metabox()
775
-    {
776
-        $template_args = [
777
-            '_venue' => $this->_cpt_model_obj,
778
-        ];
779
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
780
-        EEH_Template::display_template($template, $template_args);
781
-    }
782
-
783
-
784
-    /**
785
-     * @throws EE_Error
786
-     * @throws ReflectionException
787
-     */
788
-    protected function _restore_cpt_item($post_id, $revision_id)
789
-    {
790
-        $this->_cpt_model_obj = $this->_venue_model->get_one_by_ID($post_id);
791
-        // meta revision restore
792
-        $this->_cpt_model_obj->restore_revision($revision_id);
793
-    }
794
-
795
-
796
-    /**
797
-     * Handles updates for venue cpts
798
-     *
799
-     * @param int     $post_id ID of Venue CPT
800
-     * @param WP_Post $post    Post object (with "blessed" WP properties)
801
-     * @return void
802
-     * @throws EE_Error
803
-     * @throws ReflectionException
804
-     */
805
-    protected function _insert_update_cpt_item($post_id, $post)
806
-    {
807
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
808
-            return;// get out we're not processing the saving of venues.
809
-        }
810
-
811
-        $wheres = [$this->_venue_model->primary_key_name() => $post_id];
812
-
813
-        $venue_values = [
814
-            'VNU_address'         => $this->request->getRequestParam('vnu_address'),
815
-            'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
816
-            'VNU_city'            => $this->request->getRequestParam('vnu_city'),
817
-            'STA_ID'              => $this->request->getRequestParam('sta_id'),
818
-            'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
819
-            'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
820
-            'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
821
-            'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
822
-                ? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
823
-                : EE_INF,
824
-            'VNU_url'             => $this->request->getRequestParam('vnu_url'),
825
-            'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
826
-            'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
827
-            'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
828
-            'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
829
-        ];
830
-
831
-        // update venue
832
-        $success = $this->_venue_model->update($venue_values, [$wheres]);
833
-
834
-        // get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
835
-        $get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
836
-        $venue         = $this->_venue_model->get_one([$get_one_where]);
837
-
838
-        // notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
839
-        $venue_update_callbacks = apply_filters(
840
-            'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
841
-            []
842
-        );
843
-        $att_success            = true;
844
-        foreach ($venue_update_callbacks as $v_callback) {
845
-            // if ANY of these updates fail then we want the appropriate global error message
846
-            $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
847
-                ? $att_success
848
-                : false;
849
-        }
850
-
851
-        // any errors?
852
-        if ($success && ! $att_success) {
853
-            EE_Error::add_error(
854
-                esc_html__(
855
-                    'Venue Details saved successfully but something went wrong with saving attachments.',
856
-                    'event_espresso'
857
-                ),
858
-                __FILE__,
859
-                __FUNCTION__,
860
-                __LINE__
861
-            );
862
-        } elseif ($success === false) {
863
-            EE_Error::add_error(
864
-                esc_html__('Venue Details did not save successfully.', 'event_espresso'),
865
-                __FILE__,
866
-                __FUNCTION__,
867
-                __LINE__
868
-            );
869
-        }
870
-    }
871
-
872
-
873
-    /**
874
-     * @param int $post_id
875
-     * @throws EE_Error
876
-     * @throws ReflectionException
877
-     */
878
-    public function trash_cpt_item($post_id)
879
-    {
880
-        $this->request->setRequestParam('VNU_ID', $post_id);
881
-        $this->_trash_or_restore_venue('trash', false);
882
-    }
883
-
884
-
885
-    /**
886
-     * @param int $post_id
887
-     * @throws EE_Error
888
-     * @throws ReflectionException
889
-     */
890
-    public function restore_cpt_item($post_id)
891
-    {
892
-        $this->request->setRequestParam('VNU_ID', $post_id);
893
-        $this->_trash_or_restore_venue('draft', false);
894
-    }
895
-
896
-
897
-    /**
898
-     * @param int $post_id
899
-     * @throws EE_Error
900
-     * @throws ReflectionException
901
-     */
902
-    public function delete_cpt_item($post_id)
903
-    {
904
-        $this->request->setRequestParam('VNU_ID', $post_id);
905
-        $this->_delete_venue(false);
906
-    }
907
-
908
-
909
-    public function get_venue_object()
910
-    {
911
-        return $this->_cpt_model_obj;
912
-    }
913
-
914
-
915
-    /**
916
-     * @param string    $venue_status
917
-     * @param bool|null $redirect_after
918
-     * @throws EE_Error
919
-     * @throws ReflectionException
920
-     */
921
-    protected function _trash_or_restore_venue(string $venue_status = 'trash', ?bool $redirect_after = true)
922
-    {
923
-        // loop thru venues
924
-        if ($this->VNU_ID) {
925
-            // clean status
926
-            $venue_status = sanitize_key($venue_status);
927
-            // grab status
928
-            if (! empty($venue_status)) {
929
-                $success = $this->_change_venue_status($this->VNU_ID, $venue_status);
930
-            } else {
931
-                $success = false;
932
-                $msg     = esc_html__(
933
-                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
934
-                    'event_espresso'
935
-                );
936
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
937
-            }
938
-        } else {
939
-            $success = false;
940
-            $msg     = esc_html__(
941
-                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
942
-                'event_espresso'
943
-            );
944
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
945
-        }
946
-        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
947
-
948
-        if ($redirect_after) {
949
-            $this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
950
-        }
951
-    }
952
-
953
-
954
-    /**
955
-     * @param string $venue_status
956
-     * @throws EE_Error
957
-     * @throws ReflectionException
958
-     */
959
-    protected function _trash_or_restore_venues(string $venue_status = 'trash')
960
-    {
961
-        // clean status
962
-        $venue_status = sanitize_key($venue_status);
963
-        // grab status
964
-        if (! empty($venue_status)) {
965
-            $success = true;
966
-            // determine the event id and set to array.
967
-            $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
968
-            // loop thru events
969
-            foreach ($VNU_IDs as $VNU_ID) {
970
-                if ($VNU_ID = absint($VNU_ID)) {
971
-                    $results = $this->_change_venue_status($VNU_ID, $venue_status);
972
-                    $success = $results !== false ? $success : false;
973
-                } else {
974
-                    $msg = sprintf(
975
-                        esc_html__(
976
-                            'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
977
-                            'event_espresso'
978
-                        ),
979
-                        $VNU_ID
980
-                    );
981
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
982
-                    $success = false;
983
-                }
984
-            }
985
-        } else {
986
-            $success = false;
987
-            $msg     = esc_html__(
988
-                'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
989
-                'event_espresso'
990
-            );
991
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
992
-        }
993
-        // in order to force a pluralized result message we need to send back a success status greater than 1
994
-        $success = $success ? 2 : false;
995
-        $action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
996
-        $this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
997
-    }
998
-
999
-
1000
-    /**
1001
-     * _trash_or_restore_venues
1002
-     * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1003
-     * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1004
-     * accepting a certain number of params.
1005
-     *
1006
-     * @param int|null $VNU_ID
1007
-     * @param string   $venue_status
1008
-     * @return bool
1009
-     * @throws EE_Error
1010
-     * @throws ReflectionException
1011
-     */
1012
-    private function _change_venue_status(?int $VNU_ID = 0, string $venue_status = ''): bool
1013
-    {
1014
-        // grab venue id
1015
-        if (! $VNU_ID) {
1016
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1017
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1018
-            return false;
1019
-        }
1020
-
1021
-        $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1022
-
1023
-        // clean status
1024
-        $venue_status = sanitize_key($venue_status);
1025
-        // grab status
1026
-        if (! $venue_status) {
1027
-            $msg = esc_html__(
1028
-                'An error occurred. No Venue Status or an invalid Venue Status was received.',
1029
-                'event_espresso'
1030
-            );
1031
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1032
-            return false;
1033
-        }
1034
-
1035
-        // was event trashed or restored ?
1036
-        switch ($venue_status) {
1037
-            case 'draft':
1038
-                $action = 'restored from the trash';
1039
-                $hook   = 'AHEE_venue_restored_from_trash';
1040
-                break;
1041
-            case 'trash':
1042
-                $action = 'moved to the trash';
1043
-                $hook   = 'AHEE_venue_moved_to_trash';
1044
-                break;
1045
-            default:
1046
-                $action = 'updated';
1047
-                $hook   = false;
1048
-        }
1049
-        // use class to change status
1050
-        $this->_cpt_model_obj->set_status($venue_status);
1051
-        $success = $this->_cpt_model_obj->save();
1052
-
1053
-        if ($success === false) {
1054
-            $msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1055
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1056
-            return false;
1057
-        }
1058
-        if ($hook) {
1059
-            do_action($hook);
1060
-        }
1061
-        return true;
1062
-    }
1063
-
1064
-
1065
-    /**
1066
-     * @param bool $redirect_after
1067
-     * @return void
1068
-     * @throws EE_Error
1069
-     * @throws ReflectionException
1070
-     */
1071
-    protected function _delete_venue(bool $redirect_after = true)
1072
-    {
1073
-        // loop thru venues
1074
-        if ($this->VNU_ID) {
1075
-            $success = $this->_delete_or_trash_venue($this->VNU_ID);
1076
-        } else {
1077
-            $success = false;
1078
-            $msg     = esc_html__(
1079
-                'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1080
-                'event_espresso'
1081
-            );
1082
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1083
-        }
1084
-        if ($redirect_after) {
1085
-            $this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1086
-        }
1087
-    }
1088
-
1089
-
1090
-    /**
1091
-     * @throws EE_Error
1092
-     * @throws ReflectionException
1093
-     */
1094
-    protected function _delete_venues()
1095
-    {
1096
-        $success = true;
1097
-        // determine the event id and set to array.
1098
-        $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1099
-        // loop thru events
1100
-        foreach ($VNU_IDs as $VNU_ID) {
1101
-            if ($VNU_ID = absint($VNU_ID)) {
1102
-                $results = $this->_delete_or_trash_venue($VNU_ID);
1103
-                $success = $results !== false ? $success : false;
1104
-            } else {
1105
-                $success = false;
1106
-                $msg     = esc_html__(
1107
-                    'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1108
-                    'event_espresso'
1109
-                );
1110
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1111
-            }
1112
-        }
1113
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1114
-        $success = $success ? 2 : false;
1115
-        $this->_redirect_after_action(
1116
-            $success,
1117
-            esc_html__('Venues', 'event_espresso'),
1118
-            esc_html__('deleted', 'event_espresso'),
1119
-            ['action' => 'default']
1120
-        );
1121
-    }
1122
-
1123
-
1124
-    // todo: put in parent
1125
-
1126
-
1127
-    /**
1128
-     * @param int|null $VNU_ID
1129
-     * @return bool
1130
-     * @throws EE_Error
1131
-     * @throws ReflectionException
1132
-     */
1133
-    private function _delete_or_trash_venue(?int $VNU_ID = 0): bool
1134
-    {
1135
-        // grab event id
1136
-        if (! $VNU_ID = absint($VNU_ID)) {
1137
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1138
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1139
-            return false;
1140
-        }
1141
-
1142
-
1143
-        $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1144
-        // first need to remove all term relationships
1145
-        $venue->_remove_relations('Term_Taxonomy');
1146
-        $success = $venue->delete_permanently();
1147
-        // did it all go as planned ?
1148
-        if (! $success) {
1149
-            EE_Error::add_error(
1150
-                sprintf(
1151
-                    esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1152
-                    $VNU_ID
1153
-                ),
1154
-                __FILE__,
1155
-                __FUNCTION__,
1156
-                __LINE__
1157
-            );
1158
-            return false;
1159
-        }
1160
-        EE_Error::add_success(
1161
-            sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID)
1162
-        );
1163
-        do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1164
-        return true;
1165
-    }
1166
-
1167
-
1168
-
1169
-
1170
-    /***********/
1171
-    /* QUERIES */
1172
-
1173
-
1174
-    /**
1175
-     * @throws EE_Error
1176
-     * @throws ReflectionException
1177
-     */
1178
-    public function get_venues($per_page = 10, $count = false)
1179
-    {
1180
-        $orderby = $this->request->getRequestParam('orderby', '');
1181
-
1182
-        switch ($orderby) {
1183
-            case 'id':
1184
-                $orderby = 'VNU_ID';
1185
-                break;
1186
-
1187
-            case 'capacity':
1188
-                $orderby = 'VNU_capacity';
1189
-                break;
1190
-
1191
-            case 'city':
1192
-                $orderby = 'VNU_city';
1193
-                break;
1194
-
1195
-            default:
1196
-                $orderby = 'VNU_name';
1197
-        }
1198
-
1199
-        $sort         = $this->request->getRequestParam('order', 'ASC');
1200
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1201
-        $per_page     = ! empty($per_page) ? $per_page : 10;
1202
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1203
-
1204
-        $offset = ($current_page - 1) * $per_page;
1205
-        $limit  = [$offset, $per_page];
1206
-
1207
-        $category = $this->request->getRequestParam('category');
1208
-        $category = $category > 0 ? $category : null;
1209
-
1210
-        $where = [];
1211
-
1212
-        // only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1213
-        $status = $this->request->getRequestParam('status');
1214
-        if ($status && $status !== 'all') {
1215
-            $where['status'] = $status;
1216
-        }
1217
-
1218
-        $venue_status = $this->request->getRequestParam('venue_status');
1219
-        if ($venue_status) {
1220
-            $where['status'] = $venue_status;
1221
-        }
1222
-
1223
-
1224
-        if ($category) {
1225
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1226
-            $where['Term_Taxonomy.term_id']  = $category;
1227
-        }
1228
-
1229
-
1230
-        if (! $this->capabilities->current_user_can('ee_read_others_venues', 'get_venues')) {
1231
-            $where['VNU_wp_user'] = get_current_user_id();
1232
-        } else {
1233
-            if (! $this->capabilities->current_user_can('ee_read_private_venues', 'get_venues')) {
1234
-                $where['OR'] = [
1235
-                    'status*restrict_private' => ['!=', 'private'],
1236
-                    'AND'                     => [
1237
-                        'status*inclusive' => ['=', 'private'],
1238
-                        'VNU_wp_user'      => get_current_user_id(),
1239
-                    ],
1240
-                ];
1241
-            }
1242
-        }
1243
-
1244
-        $search_term = $this->request->getRequestParam('s');
1245
-        if ($search_term) {
1246
-            $search_term = '%' . $search_term . '%';
1247
-            $where['OR'] = [
1248
-                'VNU_name'               => ['LIKE', $search_term],
1249
-                'VNU_desc'               => ['LIKE', $search_term],
1250
-                'VNU_short_desc'         => ['LIKE', $search_term],
1251
-                'VNU_address'            => ['LIKE', $search_term],
1252
-                'VNU_address2'           => ['LIKE', $search_term],
1253
-                'VNU_city'               => ['LIKE', $search_term],
1254
-                'VNU_zip'                => ['LIKE', $search_term],
1255
-                'VNU_phone'              => ['LIKE', $search_term],
1256
-                'VNU_url'                => ['LIKE', $search_term],
1257
-                'VNU_virtual_phone'      => ['LIKE', $search_term],
1258
-                'VNU_virtual_url'        => ['LIKE', $search_term],
1259
-                'VNU_google_map_link'    => ['LIKE', $search_term],
1260
-                'Event.EVT_name'         => ['LIKE', $search_term],
1261
-                'Event.EVT_desc'         => ['LIKE', $search_term],
1262
-                'Event.EVT_phone'        => ['LIKE', $search_term],
1263
-                'Event.EVT_external_URL' => ['LIKE', $search_term],
1264
-            ];
1265
-        }
1266
-
1267
-
1268
-        return $count
1269
-            ? $this->_venue_model->count([$where], 'VNU_ID')
1270
-            : $this->_venue_model->get_all(
1271
-                [$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1272
-            );
1273
-    }
1274
-
1275
-
1276
-
1277
-
1278
-    /** Venue Category Stuff **/
1279
-
1280
-    /**
1281
-     * set the _category property with the category object for the loaded page.
1282
-     *
1283
-     * @access private
1284
-     * @return void
1285
-     */
1286
-    private function _set_category_object()
1287
-    {
1288
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
1289
-            return;
1290
-        } // already have the category object so get out.
1291
-
1292
-        // set default category object
1293
-        $this->_set_empty_category_object();
1294
-
1295
-        // only set if we've got an id
1296
-        $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1297
-        if (! $category_ID) {
1298
-            return;
1299
-        }
1300
-
1301
-        $term = get_term($category_ID, 'espresso_venue_categories');
1302
-
1303
-
1304
-        if (! empty($term)) {
1305
-            $this->_category->category_name       = $term->name;
1306
-            $this->_category->category_identifier = $term->slug;
1307
-            $this->_category->category_desc       = $term->description;
1308
-            $this->_category->id                  = $term->term_id;
1309
-            $this->_category->parent              = $term->parent;
1310
-        }
1311
-    }
1312
-
1313
-
1314
-    private function _set_empty_category_object()
1315
-    {
1316
-        $this->_category                = new stdClass();
1317
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1318
-        $this->_category->id            = $this->_category->parent = 0;
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     * @throws EE_Error
1324
-     */
1325
-    protected function _category_list_table()
1326
-    {
1327
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1328
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1329
-            'add_category',
1330
-            'add_category',
1331
-            [],
1332
-            'add-new-h2'
1333
-        );
1334
-        $this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1335
-        $this->display_admin_list_table_page_with_sidebar();
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * @throws EE_Error
1341
-     */
1342
-    protected function _category_details($view)
1343
-    {
1344
-        // load formatter helper
1345
-        // load field generator helper
1346
-
1347
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
1348
-        $this->_set_add_edit_form_tags($route);
1349
-
1350
-        $this->_set_category_object();
1351
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
1352
-
1353
-        $delete_action = 'delete_category';
1354
-
1355
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1356
-
1357
-        $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1358
-
1359
-        // take care of contents
1360
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
1361
-        $this->display_admin_page_with_sidebar();
1362
-    }
1363
-
1364
-
1365
-    protected function _category_details_content(): string
1366
-    {
1367
-        $editor_args['category_desc'] = [
1368
-            'type'          => 'wp_editor',
1369
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1370
-            'class'         => 'my_editor_custom',
1371
-            'wpeditor_args' => ['media_buttons' => false],
1372
-        ];
1373
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1374
-
1375
-        $all_terms = get_terms(
1376
-            ['espresso_venue_categories'],
1377
-            ['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1378
-        );
1379
-
1380
-        // setup category select for term parents.
1381
-        $category_select_values[] = [
1382
-            'text' => esc_html__('No Parent', 'event_espresso'),
1383
-            'id'   => 0,
1384
-        ];
1385
-        foreach ($all_terms as $term) {
1386
-            $category_select_values[] = [
1387
-                'text' => $term->name,
1388
-                'id'   => $term->term_id,
1389
-            ];
1390
-        }
1391
-
1392
-        $category_select = EEH_Form_Fields::select_input(
1393
-            'category_parent',
1394
-            $category_select_values,
1395
-            $this->_category->parent
1396
-        );
1397
-        $template_args   = [
1398
-            'category'                 => $this->_category,
1399
-            'category_select'          => $category_select,
1400
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1401
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1402
-            'disable'                  => '',
1403
-            'disabled_message'         => false,
1404
-        ];
1405
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1406
-        return EEH_Template::display_template($template, $template_args, true);
1407
-    }
1408
-
1409
-
1410
-    /**
1411
-     * @throws EE_Error
1412
-     */
1413
-    protected function _delete_categories()
1414
-    {
1415
-        $category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1416
-        $category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1417
-
1418
-        foreach ($category_IDs as $cat_id) {
1419
-            $this->_delete_category($cat_id);
1420
-        }
1421
-
1422
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
1423
-        $query_args = [
1424
-            'action' => 'category_list',
1425
-        ];
1426
-        $this->_redirect_after_action(0, '', '', $query_args);
1427
-    }
1428
-
1429
-
1430
-    protected function _delete_category($cat_id)
1431
-    {
1432
-        $cat_id = absint($cat_id);
1433
-        wp_delete_term($cat_id, 'espresso_venue_categories');
1434
-    }
1435
-
1436
-
1437
-    /**
1438
-     * @throws EE_Error
1439
-     */
1440
-    protected function _insert_or_update_category($new_category)
1441
-    {
1442
-        $cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1443
-        $success = 0; // we already have a success message so lets not send another.
1444
-        if ($cat_id) {
1445
-            $query_args = [
1446
-                'action'     => 'edit_category',
1447
-                'VEN_CAT_ID' => $cat_id,
1448
-            ];
1449
-        } else {
1450
-            $query_args = ['action' => 'add_category'];
1451
-        }
1452
-        $this->_redirect_after_action($success, '', '', $query_args, true);
1453
-    }
1454
-
1455
-
1456
-    private function _insert_category($update = false)
1457
-    {
1458
-        $category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1459
-        $category_name   = $this->request->getRequestParam('category_name', '');
1460
-        $category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1461
-        $category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1462
-
1463
-        if (empty($category_name)) {
1464
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
1465
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1466
-            return false;
1467
-        }
1468
-
1469
-
1470
-        $term_args = [
1471
-            'name'        => $category_name,
1472
-            'description' => $category_desc,
1473
-            'parent'      => $category_parent,
1474
-        ];
1475
-
1476
-        $insert_ids = $update
1477
-            ? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1478
-            : wp_insert_term(
1479
-                $category_name,
1480
-                'espresso_venue_categories',
1481
-                $term_args
1482
-            );
1483
-
1484
-        if (! is_array($insert_ids)) {
1485
-            EE_Error::add_error(
1486
-                esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1487
-                __FILE__,
1488
-                __FUNCTION__,
1489
-                __LINE__
1490
-            );
1491
-        } else {
1492
-            $category_ID = $insert_ids['term_id'];
1493
-            EE_Error::add_success(
1494
-                sprintf(
1495
-                    esc_html__('The category %s was successfully created', 'event_espresso'),
1496
-                    $category_name
1497
-                )
1498
-            );
1499
-        }
1500
-
1501
-        return $category_ID;
1502
-    }
1503
-
1504
-
1505
-    /**
1506
-     * TODO handle category exports()
1507
-     *
1508
-     * @return void
1509
-     */
1510
-    protected function _categories_export()
1511
-    {
1512
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
1513
-        $this->request->mergeRequestParams(
1514
-            [
1515
-                'export'       => 'report',
1516
-                'action'       => 'categories',
1517
-                'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1518
-            ]
1519
-        );
1520
-
1521
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1522
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1523
-            $EE_Export = EE_Export::instance($this->request->requestParams());
1524
-            $EE_Export->export();
1525
-        }
1526
-    }
1527
-
1528
-
1529
-    protected function _import_categories()
1530
-    {
1531
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1532
-        EE_Import::instance()->import();
1533
-    }
1534
-
1535
-
1536
-    /**
1537
-     * @throws EE_Error
1538
-     * @throws ReflectionException
1539
-     */
1540
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
1541
-    {
1542
-        // testing term stuff
1543
-        $orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1544
-        $order       = $this->request->getRequestParam('order', 'DESC');
1545
-        $limit       = ($current_page - 1) * $per_page;
1546
-        $where       = ['taxonomy' => 'espresso_venue_categories'];
1547
-        $search_term = $this->request->getRequestParam('s');
1548
-        if ($search_term) {
1549
-            $search_term = '%' . $search_term . '%';
1550
-            $where['OR'] = [
1551
-                'Term.name'   => ['LIKE', $search_term],
1552
-                'description' => ['LIKE', $search_term],
1553
-            ];
1554
-        }
1555
-
1556
-        $query_params = [
1557
-            $where,
1558
-            'order_by'   => [$orderby => $order],
1559
-            'limit'      => $limit . ',' . $per_page,
1560
-            'force_join' => ['Term'],
1561
-        ];
1562
-
1563
-        return $count
1564
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1565
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
1566
-    }
1567
-
1568
-
1569
-    /* end category stuff */
1570
-    /**************/
562
+	protected function _google_map_settings()
563
+	{
564
+		$this->_template_args['values']           = $this->_yes_no_values;
565
+		$default_map_settings                     = new stdClass();
566
+		$default_map_settings->use_google_maps    = true;
567
+		$default_map_settings->google_map_api_key = '';
568
+		// for event details pages (reg page)
569
+		$default_map_settings->event_details_map_width = 585;
570
+		// ee_map_width_single
571
+		$default_map_settings->event_details_map_height = 362;
572
+		// ee_map_height_single
573
+		$default_map_settings->event_details_map_zoom = 14;
574
+		// ee_map_zoom_single
575
+		$default_map_settings->event_details_display_nav = true;
576
+		// ee_map_nav_display_single
577
+		$default_map_settings->event_details_nav_size = false;
578
+		// ee_map_nav_size_single
579
+		$default_map_settings->event_details_control_type = 'default';
580
+		// ee_map_type_control_single
581
+		$default_map_settings->event_details_map_align = 'center';
582
+		// ee_map_align_single
583
+
584
+		// for event list pages
585
+		$default_map_settings->event_list_map_width = 300;
586
+		// ee_map_width
587
+		$default_map_settings->event_list_map_height = 185;
588
+		// ee_map_height
589
+		$default_map_settings->event_list_map_zoom = 12;
590
+		// ee_map_zoom
591
+		$default_map_settings->event_list_display_nav = false;
592
+		// ee_map_nav_display
593
+		$default_map_settings->event_list_nav_size = true;
594
+		// ee_map_nav_size
595
+		$default_map_settings->event_list_control_type = 'dropdown';
596
+		// ee_map_type_control
597
+		$default_map_settings->event_list_map_align = 'center';
598
+		// ee_map_align
599
+
600
+		$this->_template_args['map_settings'] =
601
+			isset(EE_Registry::instance()->CFG->map_settings)
602
+			&& ! empty(EE_Registry::instance()->CFG->map_settings)
603
+				? (object) array_merge(
604
+					(array) $default_map_settings,
605
+					(array) EE_Registry::instance()->CFG->map_settings
606
+				)
607
+				: $default_map_settings;
608
+
609
+		$this->_set_add_edit_form_tags('update_google_map_settings');
610
+		$this->_set_publish_post_box_vars();
611
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
612
+			EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
613
+			$this->_template_args,
614
+			true
615
+		);
616
+		$this->display_admin_page_with_sidebar();
617
+	}
618
+
619
+
620
+	/**
621
+	 * @throws EE_Error
622
+	 */
623
+	protected function _update_google_map_settings()
624
+	{
625
+		$map_settings = EE_Registry::instance()->CFG->map_settings;
626
+
627
+		$settings = [
628
+			'use_google_maps'            => 'int',
629
+			'google_map_api_key'         => 'string',
630
+			'event_details_map_width'    => 'int',
631
+			'event_details_map_zoom'     => 'int',
632
+			'event_details_display_nav'  => 'int',
633
+			'event_details_nav_size'     => 'int',
634
+			'event_details_control_type' => 'string',
635
+			'event_details_map_align'    => 'string',
636
+			'event_list_map_width'       => 'int',
637
+			'event_list_map_height'      => 'int',
638
+			'event_list_map_zoom'        => 'int',
639
+			'event_list_display_nav'     => 'int',
640
+			'event_list_nav_size'        => 'int',
641
+			'event_list_control_type'    => 'string',
642
+			'event_list_map_align'       => 'string',
643
+		];
644
+
645
+		foreach ($settings as $setting => $type) {
646
+			$map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
647
+		}
648
+
649
+		EE_Registry::instance()->CFG->map_settings = apply_filters(
650
+			'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
651
+			$map_settings
652
+		);
653
+
654
+		$what    = 'Google Map Settings';
655
+		$success = $this->_update_espresso_configuration(
656
+			$what,
657
+			EE_Registry::instance()->CFG->map_settings,
658
+			__FILE__,
659
+			__FUNCTION__,
660
+			__LINE__
661
+		);
662
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
663
+	}
664
+
665
+
666
+	/**
667
+	 * @throws EE_Error
668
+	 * @throws ReflectionException
669
+	 */
670
+	protected function _venue_editor_metaboxes()
671
+	{
672
+		$this->verify_cpt_object();
673
+
674
+		$this->addMetaBox(
675
+			'espresso_venue_address_options',
676
+			esc_html__('Physical Location', 'event_espresso'),
677
+			[$this, 'venue_address_metabox'],
678
+			$this->page_slug,
679
+			'side',
680
+			'core'
681
+		);
682
+		$this->addMetaBox(
683
+			'espresso_venue_gmap_options',
684
+			esc_html__('Google Map', 'event_espresso'),
685
+			[$this, 'venue_gmap_metabox'],
686
+			$this->page_slug,
687
+			'side'
688
+		);
689
+		$this->addMetaBox(
690
+			'espresso_venue_virtual_loc_options',
691
+			esc_html__('Virtual Location', 'event_espresso'),
692
+			[$this, 'venue_virtual_loc_metabox'],
693
+			$this->page_slug,
694
+			'side'
695
+		);
696
+	}
697
+
698
+
699
+	/**
700
+	 * @throws EE_Error
701
+	 * @throws ReflectionException
702
+	 */
703
+	public function venue_gmap_metabox()
704
+	{
705
+		$template_args = [
706
+			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
707
+				'vnu_enable_for_gmap',
708
+				$this->get_yes_no_values(),
709
+				$this->_cpt_model_obj instanceof EE_Venue && $this->_cpt_model_obj->enable_for_gmap()
710
+			),
711
+			'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
712
+		];
713
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
714
+		EEH_Template::display_template($template, $template_args);
715
+	}
716
+
717
+
718
+	/**
719
+	 * @throws EE_Error
720
+	 * @throws ReflectionException
721
+	 */
722
+	public function venue_address_metabox()
723
+	{
724
+		$template_args['_venue'] = $this->_cpt_model_obj;
725
+
726
+		$template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
727
+			new EE_Question_Form_Input(
728
+				EE_Question::new_instance(
729
+					['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
730
+				),
731
+				EE_Answer::new_instance(
732
+					[
733
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
734
+							? $this->_cpt_model_obj->state_ID()
735
+							: 0,
736
+					]
737
+				),
738
+				[
739
+					'input_name'     => 'sta_id',
740
+					'input_id'       => 'sta_id',
741
+					'input_class'    => '',
742
+					'input_prefix'   => '',
743
+					'append_qstn_id' => false,
744
+				]
745
+			)
746
+		);
747
+		$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
748
+			new EE_Question_Form_Input(
749
+				EE_Question::new_instance(
750
+					['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
751
+				),
752
+				EE_Answer::new_instance(
753
+					[
754
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
755
+							? $this->_cpt_model_obj->country_ID()
756
+							: 0,
757
+					]
758
+				),
759
+				[
760
+					'input_name'     => 'cnt_iso',
761
+					'input_id'       => 'cnt_iso',
762
+					'input_class'    => '',
763
+					'input_prefix'   => '',
764
+					'append_qstn_id' => false,
765
+				]
766
+			)
767
+		);
768
+
769
+		$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
770
+		EEH_Template::display_template($template, $template_args);
771
+	}
772
+
773
+
774
+	public function venue_virtual_loc_metabox()
775
+	{
776
+		$template_args = [
777
+			'_venue' => $this->_cpt_model_obj,
778
+		];
779
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
780
+		EEH_Template::display_template($template, $template_args);
781
+	}
782
+
783
+
784
+	/**
785
+	 * @throws EE_Error
786
+	 * @throws ReflectionException
787
+	 */
788
+	protected function _restore_cpt_item($post_id, $revision_id)
789
+	{
790
+		$this->_cpt_model_obj = $this->_venue_model->get_one_by_ID($post_id);
791
+		// meta revision restore
792
+		$this->_cpt_model_obj->restore_revision($revision_id);
793
+	}
794
+
795
+
796
+	/**
797
+	 * Handles updates for venue cpts
798
+	 *
799
+	 * @param int     $post_id ID of Venue CPT
800
+	 * @param WP_Post $post    Post object (with "blessed" WP properties)
801
+	 * @return void
802
+	 * @throws EE_Error
803
+	 * @throws ReflectionException
804
+	 */
805
+	protected function _insert_update_cpt_item($post_id, $post)
806
+	{
807
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
808
+			return;// get out we're not processing the saving of venues.
809
+		}
810
+
811
+		$wheres = [$this->_venue_model->primary_key_name() => $post_id];
812
+
813
+		$venue_values = [
814
+			'VNU_address'         => $this->request->getRequestParam('vnu_address'),
815
+			'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
816
+			'VNU_city'            => $this->request->getRequestParam('vnu_city'),
817
+			'STA_ID'              => $this->request->getRequestParam('sta_id'),
818
+			'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
819
+			'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
820
+			'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
821
+			'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
822
+				? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
823
+				: EE_INF,
824
+			'VNU_url'             => $this->request->getRequestParam('vnu_url'),
825
+			'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
826
+			'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
827
+			'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
828
+			'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
829
+		];
830
+
831
+		// update venue
832
+		$success = $this->_venue_model->update($venue_values, [$wheres]);
833
+
834
+		// get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
835
+		$get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
836
+		$venue         = $this->_venue_model->get_one([$get_one_where]);
837
+
838
+		// notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
839
+		$venue_update_callbacks = apply_filters(
840
+			'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
841
+			[]
842
+		);
843
+		$att_success            = true;
844
+		foreach ($venue_update_callbacks as $v_callback) {
845
+			// if ANY of these updates fail then we want the appropriate global error message
846
+			$att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
847
+				? $att_success
848
+				: false;
849
+		}
850
+
851
+		// any errors?
852
+		if ($success && ! $att_success) {
853
+			EE_Error::add_error(
854
+				esc_html__(
855
+					'Venue Details saved successfully but something went wrong with saving attachments.',
856
+					'event_espresso'
857
+				),
858
+				__FILE__,
859
+				__FUNCTION__,
860
+				__LINE__
861
+			);
862
+		} elseif ($success === false) {
863
+			EE_Error::add_error(
864
+				esc_html__('Venue Details did not save successfully.', 'event_espresso'),
865
+				__FILE__,
866
+				__FUNCTION__,
867
+				__LINE__
868
+			);
869
+		}
870
+	}
871
+
872
+
873
+	/**
874
+	 * @param int $post_id
875
+	 * @throws EE_Error
876
+	 * @throws ReflectionException
877
+	 */
878
+	public function trash_cpt_item($post_id)
879
+	{
880
+		$this->request->setRequestParam('VNU_ID', $post_id);
881
+		$this->_trash_or_restore_venue('trash', false);
882
+	}
883
+
884
+
885
+	/**
886
+	 * @param int $post_id
887
+	 * @throws EE_Error
888
+	 * @throws ReflectionException
889
+	 */
890
+	public function restore_cpt_item($post_id)
891
+	{
892
+		$this->request->setRequestParam('VNU_ID', $post_id);
893
+		$this->_trash_or_restore_venue('draft', false);
894
+	}
895
+
896
+
897
+	/**
898
+	 * @param int $post_id
899
+	 * @throws EE_Error
900
+	 * @throws ReflectionException
901
+	 */
902
+	public function delete_cpt_item($post_id)
903
+	{
904
+		$this->request->setRequestParam('VNU_ID', $post_id);
905
+		$this->_delete_venue(false);
906
+	}
907
+
908
+
909
+	public function get_venue_object()
910
+	{
911
+		return $this->_cpt_model_obj;
912
+	}
913
+
914
+
915
+	/**
916
+	 * @param string    $venue_status
917
+	 * @param bool|null $redirect_after
918
+	 * @throws EE_Error
919
+	 * @throws ReflectionException
920
+	 */
921
+	protected function _trash_or_restore_venue(string $venue_status = 'trash', ?bool $redirect_after = true)
922
+	{
923
+		// loop thru venues
924
+		if ($this->VNU_ID) {
925
+			// clean status
926
+			$venue_status = sanitize_key($venue_status);
927
+			// grab status
928
+			if (! empty($venue_status)) {
929
+				$success = $this->_change_venue_status($this->VNU_ID, $venue_status);
930
+			} else {
931
+				$success = false;
932
+				$msg     = esc_html__(
933
+					'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
934
+					'event_espresso'
935
+				);
936
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
937
+			}
938
+		} else {
939
+			$success = false;
940
+			$msg     = esc_html__(
941
+				'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
942
+				'event_espresso'
943
+			);
944
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
945
+		}
946
+		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
947
+
948
+		if ($redirect_after) {
949
+			$this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
950
+		}
951
+	}
952
+
953
+
954
+	/**
955
+	 * @param string $venue_status
956
+	 * @throws EE_Error
957
+	 * @throws ReflectionException
958
+	 */
959
+	protected function _trash_or_restore_venues(string $venue_status = 'trash')
960
+	{
961
+		// clean status
962
+		$venue_status = sanitize_key($venue_status);
963
+		// grab status
964
+		if (! empty($venue_status)) {
965
+			$success = true;
966
+			// determine the event id and set to array.
967
+			$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
968
+			// loop thru events
969
+			foreach ($VNU_IDs as $VNU_ID) {
970
+				if ($VNU_ID = absint($VNU_ID)) {
971
+					$results = $this->_change_venue_status($VNU_ID, $venue_status);
972
+					$success = $results !== false ? $success : false;
973
+				} else {
974
+					$msg = sprintf(
975
+						esc_html__(
976
+							'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
977
+							'event_espresso'
978
+						),
979
+						$VNU_ID
980
+					);
981
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
982
+					$success = false;
983
+				}
984
+			}
985
+		} else {
986
+			$success = false;
987
+			$msg     = esc_html__(
988
+				'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
989
+				'event_espresso'
990
+			);
991
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
992
+		}
993
+		// in order to force a pluralized result message we need to send back a success status greater than 1
994
+		$success = $success ? 2 : false;
995
+		$action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
996
+		$this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * _trash_or_restore_venues
1002
+	 * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1003
+	 * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1004
+	 * accepting a certain number of params.
1005
+	 *
1006
+	 * @param int|null $VNU_ID
1007
+	 * @param string   $venue_status
1008
+	 * @return bool
1009
+	 * @throws EE_Error
1010
+	 * @throws ReflectionException
1011
+	 */
1012
+	private function _change_venue_status(?int $VNU_ID = 0, string $venue_status = ''): bool
1013
+	{
1014
+		// grab venue id
1015
+		if (! $VNU_ID) {
1016
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1017
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1018
+			return false;
1019
+		}
1020
+
1021
+		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1022
+
1023
+		// clean status
1024
+		$venue_status = sanitize_key($venue_status);
1025
+		// grab status
1026
+		if (! $venue_status) {
1027
+			$msg = esc_html__(
1028
+				'An error occurred. No Venue Status or an invalid Venue Status was received.',
1029
+				'event_espresso'
1030
+			);
1031
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1032
+			return false;
1033
+		}
1034
+
1035
+		// was event trashed or restored ?
1036
+		switch ($venue_status) {
1037
+			case 'draft':
1038
+				$action = 'restored from the trash';
1039
+				$hook   = 'AHEE_venue_restored_from_trash';
1040
+				break;
1041
+			case 'trash':
1042
+				$action = 'moved to the trash';
1043
+				$hook   = 'AHEE_venue_moved_to_trash';
1044
+				break;
1045
+			default:
1046
+				$action = 'updated';
1047
+				$hook   = false;
1048
+		}
1049
+		// use class to change status
1050
+		$this->_cpt_model_obj->set_status($venue_status);
1051
+		$success = $this->_cpt_model_obj->save();
1052
+
1053
+		if ($success === false) {
1054
+			$msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1055
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1056
+			return false;
1057
+		}
1058
+		if ($hook) {
1059
+			do_action($hook);
1060
+		}
1061
+		return true;
1062
+	}
1063
+
1064
+
1065
+	/**
1066
+	 * @param bool $redirect_after
1067
+	 * @return void
1068
+	 * @throws EE_Error
1069
+	 * @throws ReflectionException
1070
+	 */
1071
+	protected function _delete_venue(bool $redirect_after = true)
1072
+	{
1073
+		// loop thru venues
1074
+		if ($this->VNU_ID) {
1075
+			$success = $this->_delete_or_trash_venue($this->VNU_ID);
1076
+		} else {
1077
+			$success = false;
1078
+			$msg     = esc_html__(
1079
+				'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1080
+				'event_espresso'
1081
+			);
1082
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1083
+		}
1084
+		if ($redirect_after) {
1085
+			$this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1086
+		}
1087
+	}
1088
+
1089
+
1090
+	/**
1091
+	 * @throws EE_Error
1092
+	 * @throws ReflectionException
1093
+	 */
1094
+	protected function _delete_venues()
1095
+	{
1096
+		$success = true;
1097
+		// determine the event id and set to array.
1098
+		$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1099
+		// loop thru events
1100
+		foreach ($VNU_IDs as $VNU_ID) {
1101
+			if ($VNU_ID = absint($VNU_ID)) {
1102
+				$results = $this->_delete_or_trash_venue($VNU_ID);
1103
+				$success = $results !== false ? $success : false;
1104
+			} else {
1105
+				$success = false;
1106
+				$msg     = esc_html__(
1107
+					'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1108
+					'event_espresso'
1109
+				);
1110
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1111
+			}
1112
+		}
1113
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1114
+		$success = $success ? 2 : false;
1115
+		$this->_redirect_after_action(
1116
+			$success,
1117
+			esc_html__('Venues', 'event_espresso'),
1118
+			esc_html__('deleted', 'event_espresso'),
1119
+			['action' => 'default']
1120
+		);
1121
+	}
1122
+
1123
+
1124
+	// todo: put in parent
1125
+
1126
+
1127
+	/**
1128
+	 * @param int|null $VNU_ID
1129
+	 * @return bool
1130
+	 * @throws EE_Error
1131
+	 * @throws ReflectionException
1132
+	 */
1133
+	private function _delete_or_trash_venue(?int $VNU_ID = 0): bool
1134
+	{
1135
+		// grab event id
1136
+		if (! $VNU_ID = absint($VNU_ID)) {
1137
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1138
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1139
+			return false;
1140
+		}
1141
+
1142
+
1143
+		$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1144
+		// first need to remove all term relationships
1145
+		$venue->_remove_relations('Term_Taxonomy');
1146
+		$success = $venue->delete_permanently();
1147
+		// did it all go as planned ?
1148
+		if (! $success) {
1149
+			EE_Error::add_error(
1150
+				sprintf(
1151
+					esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1152
+					$VNU_ID
1153
+				),
1154
+				__FILE__,
1155
+				__FUNCTION__,
1156
+				__LINE__
1157
+			);
1158
+			return false;
1159
+		}
1160
+		EE_Error::add_success(
1161
+			sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID)
1162
+		);
1163
+		do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1164
+		return true;
1165
+	}
1166
+
1167
+
1168
+
1169
+
1170
+	/***********/
1171
+	/* QUERIES */
1172
+
1173
+
1174
+	/**
1175
+	 * @throws EE_Error
1176
+	 * @throws ReflectionException
1177
+	 */
1178
+	public function get_venues($per_page = 10, $count = false)
1179
+	{
1180
+		$orderby = $this->request->getRequestParam('orderby', '');
1181
+
1182
+		switch ($orderby) {
1183
+			case 'id':
1184
+				$orderby = 'VNU_ID';
1185
+				break;
1186
+
1187
+			case 'capacity':
1188
+				$orderby = 'VNU_capacity';
1189
+				break;
1190
+
1191
+			case 'city':
1192
+				$orderby = 'VNU_city';
1193
+				break;
1194
+
1195
+			default:
1196
+				$orderby = 'VNU_name';
1197
+		}
1198
+
1199
+		$sort         = $this->request->getRequestParam('order', 'ASC');
1200
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1201
+		$per_page     = ! empty($per_page) ? $per_page : 10;
1202
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1203
+
1204
+		$offset = ($current_page - 1) * $per_page;
1205
+		$limit  = [$offset, $per_page];
1206
+
1207
+		$category = $this->request->getRequestParam('category');
1208
+		$category = $category > 0 ? $category : null;
1209
+
1210
+		$where = [];
1211
+
1212
+		// only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1213
+		$status = $this->request->getRequestParam('status');
1214
+		if ($status && $status !== 'all') {
1215
+			$where['status'] = $status;
1216
+		}
1217
+
1218
+		$venue_status = $this->request->getRequestParam('venue_status');
1219
+		if ($venue_status) {
1220
+			$where['status'] = $venue_status;
1221
+		}
1222
+
1223
+
1224
+		if ($category) {
1225
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1226
+			$where['Term_Taxonomy.term_id']  = $category;
1227
+		}
1228
+
1229
+
1230
+		if (! $this->capabilities->current_user_can('ee_read_others_venues', 'get_venues')) {
1231
+			$where['VNU_wp_user'] = get_current_user_id();
1232
+		} else {
1233
+			if (! $this->capabilities->current_user_can('ee_read_private_venues', 'get_venues')) {
1234
+				$where['OR'] = [
1235
+					'status*restrict_private' => ['!=', 'private'],
1236
+					'AND'                     => [
1237
+						'status*inclusive' => ['=', 'private'],
1238
+						'VNU_wp_user'      => get_current_user_id(),
1239
+					],
1240
+				];
1241
+			}
1242
+		}
1243
+
1244
+		$search_term = $this->request->getRequestParam('s');
1245
+		if ($search_term) {
1246
+			$search_term = '%' . $search_term . '%';
1247
+			$where['OR'] = [
1248
+				'VNU_name'               => ['LIKE', $search_term],
1249
+				'VNU_desc'               => ['LIKE', $search_term],
1250
+				'VNU_short_desc'         => ['LIKE', $search_term],
1251
+				'VNU_address'            => ['LIKE', $search_term],
1252
+				'VNU_address2'           => ['LIKE', $search_term],
1253
+				'VNU_city'               => ['LIKE', $search_term],
1254
+				'VNU_zip'                => ['LIKE', $search_term],
1255
+				'VNU_phone'              => ['LIKE', $search_term],
1256
+				'VNU_url'                => ['LIKE', $search_term],
1257
+				'VNU_virtual_phone'      => ['LIKE', $search_term],
1258
+				'VNU_virtual_url'        => ['LIKE', $search_term],
1259
+				'VNU_google_map_link'    => ['LIKE', $search_term],
1260
+				'Event.EVT_name'         => ['LIKE', $search_term],
1261
+				'Event.EVT_desc'         => ['LIKE', $search_term],
1262
+				'Event.EVT_phone'        => ['LIKE', $search_term],
1263
+				'Event.EVT_external_URL' => ['LIKE', $search_term],
1264
+			];
1265
+		}
1266
+
1267
+
1268
+		return $count
1269
+			? $this->_venue_model->count([$where], 'VNU_ID')
1270
+			: $this->_venue_model->get_all(
1271
+				[$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1272
+			);
1273
+	}
1274
+
1275
+
1276
+
1277
+
1278
+	/** Venue Category Stuff **/
1279
+
1280
+	/**
1281
+	 * set the _category property with the category object for the loaded page.
1282
+	 *
1283
+	 * @access private
1284
+	 * @return void
1285
+	 */
1286
+	private function _set_category_object()
1287
+	{
1288
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
1289
+			return;
1290
+		} // already have the category object so get out.
1291
+
1292
+		// set default category object
1293
+		$this->_set_empty_category_object();
1294
+
1295
+		// only set if we've got an id
1296
+		$category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1297
+		if (! $category_ID) {
1298
+			return;
1299
+		}
1300
+
1301
+		$term = get_term($category_ID, 'espresso_venue_categories');
1302
+
1303
+
1304
+		if (! empty($term)) {
1305
+			$this->_category->category_name       = $term->name;
1306
+			$this->_category->category_identifier = $term->slug;
1307
+			$this->_category->category_desc       = $term->description;
1308
+			$this->_category->id                  = $term->term_id;
1309
+			$this->_category->parent              = $term->parent;
1310
+		}
1311
+	}
1312
+
1313
+
1314
+	private function _set_empty_category_object()
1315
+	{
1316
+		$this->_category                = new stdClass();
1317
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1318
+		$this->_category->id            = $this->_category->parent = 0;
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 * @throws EE_Error
1324
+	 */
1325
+	protected function _category_list_table()
1326
+	{
1327
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1328
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1329
+			'add_category',
1330
+			'add_category',
1331
+			[],
1332
+			'add-new-h2'
1333
+		);
1334
+		$this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1335
+		$this->display_admin_list_table_page_with_sidebar();
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * @throws EE_Error
1341
+	 */
1342
+	protected function _category_details($view)
1343
+	{
1344
+		// load formatter helper
1345
+		// load field generator helper
1346
+
1347
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
1348
+		$this->_set_add_edit_form_tags($route);
1349
+
1350
+		$this->_set_category_object();
1351
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
1352
+
1353
+		$delete_action = 'delete_category';
1354
+
1355
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1356
+
1357
+		$this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1358
+
1359
+		// take care of contents
1360
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
1361
+		$this->display_admin_page_with_sidebar();
1362
+	}
1363
+
1364
+
1365
+	protected function _category_details_content(): string
1366
+	{
1367
+		$editor_args['category_desc'] = [
1368
+			'type'          => 'wp_editor',
1369
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1370
+			'class'         => 'my_editor_custom',
1371
+			'wpeditor_args' => ['media_buttons' => false],
1372
+		];
1373
+		$_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1374
+
1375
+		$all_terms = get_terms(
1376
+			['espresso_venue_categories'],
1377
+			['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1378
+		);
1379
+
1380
+		// setup category select for term parents.
1381
+		$category_select_values[] = [
1382
+			'text' => esc_html__('No Parent', 'event_espresso'),
1383
+			'id'   => 0,
1384
+		];
1385
+		foreach ($all_terms as $term) {
1386
+			$category_select_values[] = [
1387
+				'text' => $term->name,
1388
+				'id'   => $term->term_id,
1389
+			];
1390
+		}
1391
+
1392
+		$category_select = EEH_Form_Fields::select_input(
1393
+			'category_parent',
1394
+			$category_select_values,
1395
+			$this->_category->parent
1396
+		);
1397
+		$template_args   = [
1398
+			'category'                 => $this->_category,
1399
+			'category_select'          => $category_select,
1400
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1401
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1402
+			'disable'                  => '',
1403
+			'disabled_message'         => false,
1404
+		];
1405
+		$template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1406
+		return EEH_Template::display_template($template, $template_args, true);
1407
+	}
1408
+
1409
+
1410
+	/**
1411
+	 * @throws EE_Error
1412
+	 */
1413
+	protected function _delete_categories()
1414
+	{
1415
+		$category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1416
+		$category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1417
+
1418
+		foreach ($category_IDs as $cat_id) {
1419
+			$this->_delete_category($cat_id);
1420
+		}
1421
+
1422
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
1423
+		$query_args = [
1424
+			'action' => 'category_list',
1425
+		];
1426
+		$this->_redirect_after_action(0, '', '', $query_args);
1427
+	}
1428
+
1429
+
1430
+	protected function _delete_category($cat_id)
1431
+	{
1432
+		$cat_id = absint($cat_id);
1433
+		wp_delete_term($cat_id, 'espresso_venue_categories');
1434
+	}
1435
+
1436
+
1437
+	/**
1438
+	 * @throws EE_Error
1439
+	 */
1440
+	protected function _insert_or_update_category($new_category)
1441
+	{
1442
+		$cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1443
+		$success = 0; // we already have a success message so lets not send another.
1444
+		if ($cat_id) {
1445
+			$query_args = [
1446
+				'action'     => 'edit_category',
1447
+				'VEN_CAT_ID' => $cat_id,
1448
+			];
1449
+		} else {
1450
+			$query_args = ['action' => 'add_category'];
1451
+		}
1452
+		$this->_redirect_after_action($success, '', '', $query_args, true);
1453
+	}
1454
+
1455
+
1456
+	private function _insert_category($update = false)
1457
+	{
1458
+		$category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1459
+		$category_name   = $this->request->getRequestParam('category_name', '');
1460
+		$category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1461
+		$category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1462
+
1463
+		if (empty($category_name)) {
1464
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
1465
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1466
+			return false;
1467
+		}
1468
+
1469
+
1470
+		$term_args = [
1471
+			'name'        => $category_name,
1472
+			'description' => $category_desc,
1473
+			'parent'      => $category_parent,
1474
+		];
1475
+
1476
+		$insert_ids = $update
1477
+			? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1478
+			: wp_insert_term(
1479
+				$category_name,
1480
+				'espresso_venue_categories',
1481
+				$term_args
1482
+			);
1483
+
1484
+		if (! is_array($insert_ids)) {
1485
+			EE_Error::add_error(
1486
+				esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1487
+				__FILE__,
1488
+				__FUNCTION__,
1489
+				__LINE__
1490
+			);
1491
+		} else {
1492
+			$category_ID = $insert_ids['term_id'];
1493
+			EE_Error::add_success(
1494
+				sprintf(
1495
+					esc_html__('The category %s was successfully created', 'event_espresso'),
1496
+					$category_name
1497
+				)
1498
+			);
1499
+		}
1500
+
1501
+		return $category_ID;
1502
+	}
1503
+
1504
+
1505
+	/**
1506
+	 * TODO handle category exports()
1507
+	 *
1508
+	 * @return void
1509
+	 */
1510
+	protected function _categories_export()
1511
+	{
1512
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
1513
+		$this->request->mergeRequestParams(
1514
+			[
1515
+				'export'       => 'report',
1516
+				'action'       => 'categories',
1517
+				'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1518
+			]
1519
+		);
1520
+
1521
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1522
+			require_once(EE_CLASSES . 'EE_Export.class.php');
1523
+			$EE_Export = EE_Export::instance($this->request->requestParams());
1524
+			$EE_Export->export();
1525
+		}
1526
+	}
1527
+
1528
+
1529
+	protected function _import_categories()
1530
+	{
1531
+		require_once(EE_CLASSES . 'EE_Import.class.php');
1532
+		EE_Import::instance()->import();
1533
+	}
1534
+
1535
+
1536
+	/**
1537
+	 * @throws EE_Error
1538
+	 * @throws ReflectionException
1539
+	 */
1540
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
1541
+	{
1542
+		// testing term stuff
1543
+		$orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1544
+		$order       = $this->request->getRequestParam('order', 'DESC');
1545
+		$limit       = ($current_page - 1) * $per_page;
1546
+		$where       = ['taxonomy' => 'espresso_venue_categories'];
1547
+		$search_term = $this->request->getRequestParam('s');
1548
+		if ($search_term) {
1549
+			$search_term = '%' . $search_term . '%';
1550
+			$where['OR'] = [
1551
+				'Term.name'   => ['LIKE', $search_term],
1552
+				'description' => ['LIKE', $search_term],
1553
+			];
1554
+		}
1555
+
1556
+		$query_params = [
1557
+			$where,
1558
+			'order_by'   => [$orderby => $order],
1559
+			'limit'      => $limit . ',' . $per_page,
1560
+			'force_join' => ['Term'],
1561
+		];
1562
+
1563
+		return $count
1564
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1565
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
1566
+	}
1567
+
1568
+
1569
+	/* end category stuff */
1570
+	/**************/
1571 1571
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         $this->page_slug        = EE_VENUES_PG_SLUG;
58 58
         $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
59
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
59
+        $this->_admin_base_path = EE_ADMIN_PAGES.'venues';
60 60
         $this->page_label       = esc_html__('Event Venues', 'event_espresso');
61 61
         $this->_cpt_model_names = [
62 62
             'create_new' => 'EEM_Venue',
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
     public function load_scripts_styles()
440 440
     {
441
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
441
+        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
442 442
         wp_enqueue_style('ee-cat-admin');
443 443
     }
444 444
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
         wp_enqueue_style('espresso-ui-theme');
462 462
         wp_register_style(
463 463
             'espresso_venues',
464
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
464
+            EE_VENUES_ASSETS_URL.'ee-venues-admin.css',
465 465
             [],
466 466
             EVENT_ESPRESSO_VERSION
467 467
         );
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             'button'
525 525
         );
526 526
 
527
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
527
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
528 528
             'create_new',
529 529
             'add',
530 530
             [],
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
             'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
548 548
             'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
549 549
         ];
550
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
550
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_publish_box_extras.template.php';
551 551
         EEH_Template::display_template($template, $extra_rows);
552 552
     }
553 553
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         $this->_set_add_edit_form_tags('update_google_map_settings');
610 610
         $this->_set_publish_post_box_vars();
611 611
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
612
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
612
+            EE_VENUES_TEMPLATE_PATH.'google_map.template.php',
613 613
             $this->_template_args,
614 614
             true
615 615
         );
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
             ),
711 711
             'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
712 712
         ];
713
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
713
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_gmap_metabox_content.template.php';
714 714
         EEH_Template::display_template($template, $template_args);
715 715
     }
716 716
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     {
724 724
         $template_args['_venue'] = $this->_cpt_model_obj;
725 725
 
726
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
726
+        $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input(
727 727
             new EE_Question_Form_Input(
728 728
                 EE_Question::new_instance(
729 729
                     ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             )
767 767
         );
768 768
 
769
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
769
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_address_metabox_content.template.php';
770 770
         EEH_Template::display_template($template, $template_args);
771 771
     }
772 772
 
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
         $template_args = [
777 777
             '_venue' => $this->_cpt_model_obj,
778 778
         ];
779
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
779
+        $template      = EE_VENUES_TEMPLATE_PATH.'venue_virtual_location_metabox_content.template.php';
780 780
         EEH_Template::display_template($template, $template_args);
781 781
     }
782 782
 
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
     protected function _insert_update_cpt_item($post_id, $post)
806 806
     {
807 807
         if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
808
-            return;// get out we're not processing the saving of venues.
808
+            return; // get out we're not processing the saving of venues.
809 809
         }
810 810
 
811 811
         $wheres = [$this->_venue_model->primary_key_name() => $post_id];
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
             'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
841 841
             []
842 842
         );
843
-        $att_success            = true;
843
+        $att_success = true;
844 844
         foreach ($venue_update_callbacks as $v_callback) {
845 845
             // if ANY of these updates fail then we want the appropriate global error message
846 846
             $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
             // clean status
926 926
             $venue_status = sanitize_key($venue_status);
927 927
             // grab status
928
-            if (! empty($venue_status)) {
928
+            if ( ! empty($venue_status)) {
929 929
                 $success = $this->_change_venue_status($this->VNU_ID, $venue_status);
930 930
             } else {
931 931
                 $success = false;
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
         // clean status
962 962
         $venue_status = sanitize_key($venue_status);
963 963
         // grab status
964
-        if (! empty($venue_status)) {
964
+        if ( ! empty($venue_status)) {
965 965
             $success = true;
966 966
             // determine the event id and set to array.
967 967
             $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
     private function _change_venue_status(?int $VNU_ID = 0, string $venue_status = ''): bool
1013 1013
     {
1014 1014
         // grab venue id
1015
-        if (! $VNU_ID) {
1015
+        if ( ! $VNU_ID) {
1016 1016
             $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1017 1017
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1018 1018
             return false;
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
         // clean status
1024 1024
         $venue_status = sanitize_key($venue_status);
1025 1025
         // grab status
1026
-        if (! $venue_status) {
1026
+        if ( ! $venue_status) {
1027 1027
             $msg = esc_html__(
1028 1028
                 'An error occurred. No Venue Status or an invalid Venue Status was received.',
1029 1029
                 'event_espresso'
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
     private function _delete_or_trash_venue(?int $VNU_ID = 0): bool
1134 1134
     {
1135 1135
         // grab event id
1136
-        if (! $VNU_ID = absint($VNU_ID)) {
1136
+        if ( ! $VNU_ID = absint($VNU_ID)) {
1137 1137
             $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1138 1138
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1139 1139
             return false;
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
         $venue->_remove_relations('Term_Taxonomy');
1146 1146
         $success = $venue->delete_permanently();
1147 1147
         // did it all go as planned ?
1148
-        if (! $success) {
1148
+        if ( ! $success) {
1149 1149
             EE_Error::add_error(
1150 1150
                 sprintf(
1151 1151
                     esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
@@ -1227,10 +1227,10 @@  discard block
 block discarded – undo
1227 1227
         }
1228 1228
 
1229 1229
 
1230
-        if (! $this->capabilities->current_user_can('ee_read_others_venues', 'get_venues')) {
1230
+        if ( ! $this->capabilities->current_user_can('ee_read_others_venues', 'get_venues')) {
1231 1231
             $where['VNU_wp_user'] = get_current_user_id();
1232 1232
         } else {
1233
-            if (! $this->capabilities->current_user_can('ee_read_private_venues', 'get_venues')) {
1233
+            if ( ! $this->capabilities->current_user_can('ee_read_private_venues', 'get_venues')) {
1234 1234
                 $where['OR'] = [
1235 1235
                     'status*restrict_private' => ['!=', 'private'],
1236 1236
                     'AND'                     => [
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 
1244 1244
         $search_term = $this->request->getRequestParam('s');
1245 1245
         if ($search_term) {
1246
-            $search_term = '%' . $search_term . '%';
1246
+            $search_term = '%'.$search_term.'%';
1247 1247
             $where['OR'] = [
1248 1248
                 'VNU_name'               => ['LIKE', $search_term],
1249 1249
                 'VNU_desc'               => ['LIKE', $search_term],
@@ -1294,14 +1294,14 @@  discard block
 block discarded – undo
1294 1294
 
1295 1295
         // only set if we've got an id
1296 1296
         $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1297
-        if (! $category_ID) {
1297
+        if ( ! $category_ID) {
1298 1298
             return;
1299 1299
         }
1300 1300
 
1301 1301
         $term = get_term($category_ID, 'espresso_venue_categories');
1302 1302
 
1303 1303
 
1304
-        if (! empty($term)) {
1304
+        if ( ! empty($term)) {
1305 1305
             $this->_category->category_name       = $term->name;
1306 1306
             $this->_category->category_identifier = $term->slug;
1307 1307
             $this->_category->category_desc       = $term->description;
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
     protected function _category_list_table()
1326 1326
     {
1327 1327
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1328
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1328
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1329 1329
             'add_category',
1330 1330
             'add_category',
1331 1331
             [],
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
             'class'         => 'my_editor_custom',
1371 1371
             'wpeditor_args' => ['media_buttons' => false],
1372 1372
         ];
1373
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1373
+        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
1374 1374
 
1375 1375
         $all_terms = get_terms(
1376 1376
             ['espresso_venue_categories'],
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
             $category_select_values,
1395 1395
             $this->_category->parent
1396 1396
         );
1397
-        $template_args   = [
1397
+        $template_args = [
1398 1398
             'category'                 => $this->_category,
1399 1399
             'category_select'          => $category_select,
1400 1400
             'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
             'disable'                  => '',
1403 1403
             'disabled_message'         => false,
1404 1404
         ];
1405
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1405
+        $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
1406 1406
         return EEH_Template::display_template($template, $template_args, true);
1407 1407
     }
1408 1408
 
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
                 $term_args
1482 1482
             );
1483 1483
 
1484
-        if (! is_array($insert_ids)) {
1484
+        if ( ! is_array($insert_ids)) {
1485 1485
             EE_Error::add_error(
1486 1486
                 esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1487 1487
                 __FILE__,
@@ -1518,8 +1518,8 @@  discard block
 block discarded – undo
1518 1518
             ]
1519 1519
         );
1520 1520
 
1521
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1522
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1521
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
1522
+            require_once(EE_CLASSES.'EE_Export.class.php');
1523 1523
             $EE_Export = EE_Export::instance($this->request->requestParams());
1524 1524
             $EE_Export->export();
1525 1525
         }
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 
1529 1529
     protected function _import_categories()
1530 1530
     {
1531
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1531
+        require_once(EE_CLASSES.'EE_Import.class.php');
1532 1532
         EE_Import::instance()->import();
1533 1533
     }
1534 1534
 
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
         $where       = ['taxonomy' => 'espresso_venue_categories'];
1547 1547
         $search_term = $this->request->getRequestParam('s');
1548 1548
         if ($search_term) {
1549
-            $search_term = '%' . $search_term . '%';
1549
+            $search_term = '%'.$search_term.'%';
1550 1550
             $where['OR'] = [
1551 1551
                 'Term.name'   => ['LIKE', $search_term],
1552 1552
                 'description' => ['LIKE', $search_term],
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
         $query_params = [
1557 1557
             $where,
1558 1558
             'order_by'   => [$orderby => $order],
1559
-            'limit'      => $limit . ',' . $per_page,
1559
+            'limit'      => $limit.','.$per_page,
1560 1560
             'force_join' => ['Term'],
1561 1561
         ];
1562 1562
 
Please login to merge, or discard this patch.
admin_pages/payments/templates/payment_log_details.template.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,14 +75,17 @@
 block discarded – undo
75 75
     </table>
76 76
 </div>
77 77
 
78
-<?php else : ?>
78
+<?php else {
79
+	: ?>
79 80
 <div class="padding">
80 81
     <table class="ee-payment-log-details widefat">
81 82
         <tbody>
82 83
             <tr>
83 84
                 <td>
84 85
                     <p class="ee-status-outline ee-status-bg--attention">
85
-                        <?php esc_html_e("Payment Log No Longer Exists", 'event_espresso'); ?>
86
+                        <?php esc_html_e("Payment Log No Longer Exists", 'event_espresso');
87
+}
88
+?>
86 89
                     </p>
87 90
                 </td>
88 91
             </tr>
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Indentation   +1295 added lines, -1295 removed lines patch added patch discarded remove patch
@@ -18,286 +18,286 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Payments_Admin_Page extends EE_Admin_Page
20 20
 {
21
-    /**
22
-     * Variables used for when we're re-sorting the logs results,
23
-     * in case we needed to do two queries, and we need to resort
24
-     *
25
-     * @var string
26
-     */
27
-    private $_sort_logs_again_direction;
28
-
29
-
30
-    /**
31
-     * @Constructor
32
-     * @access public
33
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
34
-     * @throws EE_Error
35
-     * @throws InvalidArgumentException
36
-     * @throws InvalidDataTypeException
37
-     * @throws InvalidInterfaceException
38
-     * @throws ReflectionException
39
-     */
40
-    public function __construct($routing = true)
41
-    {
42
-        parent::__construct($routing);
43
-    }
44
-
45
-
46
-    protected function _init_page_props()
47
-    {
48
-        $this->page_slug        = EE_PAYMENTS_PG_SLUG;
49
-        $this->page_label       = esc_html__('Payment Methods', 'event_espresso');
50
-        $this->_admin_base_url  = EE_PAYMENTS_ADMIN_URL;
51
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
52
-    }
53
-
54
-
55
-    protected function _ajax_hooks()
56
-    {
57
-        // todo: all hooks for ajax goes here.
58
-    }
59
-
60
-
61
-    protected function _define_page_props()
62
-    {
63
-        $this->_admin_page_title = $this->page_label;
64
-        $this->_labels           = [
65
-            'publishbox' => esc_html__('Update Settings', 'event_espresso'),
66
-        ];
67
-    }
68
-
69
-
70
-    /**
71
-     * @param string $sort_logs_again_direction
72
-     */
73
-    public function setSortLogsAgainDirection(string $sort_logs_again_direction): void
74
-    {
75
-        $this->_sort_logs_again_direction = $sort_logs_again_direction;
76
-    }
77
-
78
-
79
-    protected function _set_page_routes()
80
-    {
81
-        /**
82
-         * note that with payment method capabilities, although we've implemented
83
-         * capability mapping which will be used for accessing payment methods owned by
84
-         * other users.  This is not fully implemented yet in the payment method ui.
85
-         * Currently, only the "plural" caps are in active use.
86
-         * When cap mapping is implemented, some routes will need to use the singular form of
87
-         * capability method and also include the $id of the payment method for the route.
88
-         **/
89
-        $this->_page_routes = [
90
-            'default'                   => [
91
-                'func'       => '_payment_methods_list',
92
-                'capability' => 'ee_edit_payment_methods',
93
-            ],
94
-            'payment_settings'          => [
95
-                'func'       => '_payment_settings',
96
-                'capability' => 'ee_manage_gateways',
97
-            ],
98
-            'activate_payment_method'   => [
99
-                'func'       => '_activate_payment_method',
100
-                'noheader'   => true,
101
-                'capability' => 'ee_edit_payment_methods',
102
-            ],
103
-            'deactivate_payment_method' => [
104
-                'func'       => '_deactivate_payment_method',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_delete_payment_methods',
107
-            ],
108
-            'update_payment_method'     => [
109
-                'func'               => '_update_payment_method',
110
-                'noheader'           => true,
111
-                'headers_sent_route' => 'default',
112
-                'capability'         => 'ee_edit_payment_methods',
113
-            ],
114
-            'update_payment_settings'   => [
115
-                'func'       => '_update_payment_settings',
116
-                'noheader'   => true,
117
-                'capability' => 'ee_manage_gateways',
118
-            ],
119
-            'payment_log'               => [
120
-                'func'       => '_payment_log_overview_list_table',
121
-                'capability' => 'ee_read_payment_methods',
122
-            ],
123
-            'payment_log_details'       => [
124
-                'func'       => '_payment_log_details',
125
-                'capability' => 'ee_read_payment_methods',
126
-            ],
127
-        ];
128
-    }
129
-
130
-
131
-    /**
132
-     * @throws EE_Error
133
-     * @throws ReflectionException
134
-     */
135
-    protected function _set_page_config()
136
-    {
137
-        $payment_method_list_config = [
138
-            'nav'           => [
139
-                'label' => esc_html__('Payment Methods', 'event_espresso'),
140
-                'icon'  => 'dashicons-bank',
141
-                'order' => 10,
142
-            ],
143
-            'metaboxes'     => $this->_default_espresso_metaboxes,
144
-            'help_tabs'     => array_merge(
145
-                [
146
-                    'payment_methods_overview_help_tab' => [
147
-                        'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
148
-                        'filename' => 'payment_methods_overview',
149
-                    ],
150
-                ],
151
-                $this->_add_payment_method_help_tabs()
152
-            ),
153
-            'require_nonce' => false,
154
-        ];
155
-        $this->_page_config         = [
156
-            'default'          => $payment_method_list_config,
157
-            'payment_settings' => [
158
-                'nav'           => [
159
-                    'label' => esc_html__('Settings', 'event_espresso'),
160
-                    'icon'  => 'dashicons-admin-generic',
161
-                    'order' => 20,
162
-                ],
163
-                'help_tabs'     => [
164
-                    'payment_methods_settings_help_tab' => [
165
-                        'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
166
-                        'filename' => 'payment_methods_settings',
167
-                    ],
168
-                ],
169
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
170
-                'require_nonce' => false,
171
-            ],
172
-            'payment_log'      => [
173
-                'nav'           => [
174
-                    'label' => esc_html__("Logs", 'event_espresso'),
175
-                    'icon'  => 'dashicons-text-page',
176
-                    'order' => 30,
177
-                ],
178
-                'list_table'    => 'Payment_Log_Admin_List_Table',
179
-                'metaboxes'     => $this->_default_espresso_metaboxes,
180
-                'require_nonce' => false,
181
-            ],
182
-        ];
183
-    }
184
-
185
-
186
-    /**
187
-     * @return array
188
-     * @throws DomainException
189
-     * @throws EE_Error
190
-     * @throws InvalidArgumentException
191
-     * @throws InvalidDataTypeException
192
-     * @throws InvalidInterfaceException
193
-     * @throws ReflectionException
194
-     */
195
-    protected function _add_payment_method_help_tabs(): array
196
-    {
197
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
198
-        $payment_method_types     = EE_Payment_Method_Manager::instance()->payment_method_types();
199
-        $all_pmt_help_tabs_config = [];
200
-        foreach ($payment_method_types as $payment_method_type) {
201
-            if (
202
-                ! $this->capabilities->current_user_can(
203
-                    $payment_method_type->cap_name(),
204
-                    'specific_payment_method_type_access'
205
-                )
206
-            ) {
207
-                continue;
208
-            }
209
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
210
-                $template_args                              = $config['template_args'] ?? [];
211
-                $template_args['admin_page_obj']            = $this;
212
-                $all_pmt_help_tabs_config[ $help_tab_name ] = [
213
-                    'title'   => $config['title'],
214
-                    'content' => EEH_Template::display_template(
215
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
216
-                        $template_args,
217
-                        true
218
-                    ),
219
-                ];
220
-            }
221
-        }
222
-        return $all_pmt_help_tabs_config;
223
-    }
224
-
225
-
226
-    // none of the below group are currently used for Gateway Settings
227
-    protected function _add_screen_options()
228
-    {
229
-    }
230
-
231
-
232
-    protected function _add_feature_pointers()
233
-    {
234
-    }
235
-
236
-
237
-    public function admin_init()
238
-    {
239
-    }
240
-
241
-
242
-    public function admin_notices()
243
-    {
244
-    }
245
-
246
-
247
-    public function admin_footer_scripts()
248
-    {
249
-    }
250
-
251
-
252
-    public function load_scripts_styles()
253
-    {
254
-        // styles
255
-        wp_enqueue_style('espresso-ui-theme');
256
-        wp_register_style(
257
-            'espresso_payments',
258
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
259
-            [],
260
-            EVENT_ESPRESSO_VERSION
261
-        );
262
-        // scripts
263
-        wp_enqueue_script('ee_admin_js');
264
-        wp_enqueue_script('ee-text-links');
265
-        wp_enqueue_script(
266
-            'espresso_payments',
267
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
268
-            ['ee-datepicker'],
269
-            EVENT_ESPRESSO_VERSION,
270
-            true
271
-        );
272
-    }
273
-
274
-
275
-    public function load_scripts_styles_default()
276
-    {
277
-        wp_enqueue_style('espresso_payments');
278
-        wp_enqueue_style('ee-text-links');
279
-    }
280
-
281
-
282
-    public function load_scripts_styles_payment_log_details()
283
-    {
284
-        wp_enqueue_style('espresso_payments');
285
-    }
286
-
287
-
288
-    /**
289
-     * @throws EE_Error
290
-     */
291
-    private function veryifyTablesExist()
292
-    {
293
-        /** @var TableAnalysis $table_analysis */
294
-        $table_analysis = LoaderFactory::getShared(TableAnalysis::class);
295
-        /** @var TableManager $table_manager */
296
-        $table_manager = LoaderFactory::getShared(TableManager::class);
297
-        if (! $table_analysis->tableExists('esp_payment_method')) {
298
-            $table_manager->createTable(
299
-                'esp_payment_method',
300
-                "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
21
+	/**
22
+	 * Variables used for when we're re-sorting the logs results,
23
+	 * in case we needed to do two queries, and we need to resort
24
+	 *
25
+	 * @var string
26
+	 */
27
+	private $_sort_logs_again_direction;
28
+
29
+
30
+	/**
31
+	 * @Constructor
32
+	 * @access public
33
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
34
+	 * @throws EE_Error
35
+	 * @throws InvalidArgumentException
36
+	 * @throws InvalidDataTypeException
37
+	 * @throws InvalidInterfaceException
38
+	 * @throws ReflectionException
39
+	 */
40
+	public function __construct($routing = true)
41
+	{
42
+		parent::__construct($routing);
43
+	}
44
+
45
+
46
+	protected function _init_page_props()
47
+	{
48
+		$this->page_slug        = EE_PAYMENTS_PG_SLUG;
49
+		$this->page_label       = esc_html__('Payment Methods', 'event_espresso');
50
+		$this->_admin_base_url  = EE_PAYMENTS_ADMIN_URL;
51
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
52
+	}
53
+
54
+
55
+	protected function _ajax_hooks()
56
+	{
57
+		// todo: all hooks for ajax goes here.
58
+	}
59
+
60
+
61
+	protected function _define_page_props()
62
+	{
63
+		$this->_admin_page_title = $this->page_label;
64
+		$this->_labels           = [
65
+			'publishbox' => esc_html__('Update Settings', 'event_espresso'),
66
+		];
67
+	}
68
+
69
+
70
+	/**
71
+	 * @param string $sort_logs_again_direction
72
+	 */
73
+	public function setSortLogsAgainDirection(string $sort_logs_again_direction): void
74
+	{
75
+		$this->_sort_logs_again_direction = $sort_logs_again_direction;
76
+	}
77
+
78
+
79
+	protected function _set_page_routes()
80
+	{
81
+		/**
82
+		 * note that with payment method capabilities, although we've implemented
83
+		 * capability mapping which will be used for accessing payment methods owned by
84
+		 * other users.  This is not fully implemented yet in the payment method ui.
85
+		 * Currently, only the "plural" caps are in active use.
86
+		 * When cap mapping is implemented, some routes will need to use the singular form of
87
+		 * capability method and also include the $id of the payment method for the route.
88
+		 **/
89
+		$this->_page_routes = [
90
+			'default'                   => [
91
+				'func'       => '_payment_methods_list',
92
+				'capability' => 'ee_edit_payment_methods',
93
+			],
94
+			'payment_settings'          => [
95
+				'func'       => '_payment_settings',
96
+				'capability' => 'ee_manage_gateways',
97
+			],
98
+			'activate_payment_method'   => [
99
+				'func'       => '_activate_payment_method',
100
+				'noheader'   => true,
101
+				'capability' => 'ee_edit_payment_methods',
102
+			],
103
+			'deactivate_payment_method' => [
104
+				'func'       => '_deactivate_payment_method',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_delete_payment_methods',
107
+			],
108
+			'update_payment_method'     => [
109
+				'func'               => '_update_payment_method',
110
+				'noheader'           => true,
111
+				'headers_sent_route' => 'default',
112
+				'capability'         => 'ee_edit_payment_methods',
113
+			],
114
+			'update_payment_settings'   => [
115
+				'func'       => '_update_payment_settings',
116
+				'noheader'   => true,
117
+				'capability' => 'ee_manage_gateways',
118
+			],
119
+			'payment_log'               => [
120
+				'func'       => '_payment_log_overview_list_table',
121
+				'capability' => 'ee_read_payment_methods',
122
+			],
123
+			'payment_log_details'       => [
124
+				'func'       => '_payment_log_details',
125
+				'capability' => 'ee_read_payment_methods',
126
+			],
127
+		];
128
+	}
129
+
130
+
131
+	/**
132
+	 * @throws EE_Error
133
+	 * @throws ReflectionException
134
+	 */
135
+	protected function _set_page_config()
136
+	{
137
+		$payment_method_list_config = [
138
+			'nav'           => [
139
+				'label' => esc_html__('Payment Methods', 'event_espresso'),
140
+				'icon'  => 'dashicons-bank',
141
+				'order' => 10,
142
+			],
143
+			'metaboxes'     => $this->_default_espresso_metaboxes,
144
+			'help_tabs'     => array_merge(
145
+				[
146
+					'payment_methods_overview_help_tab' => [
147
+						'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
148
+						'filename' => 'payment_methods_overview',
149
+					],
150
+				],
151
+				$this->_add_payment_method_help_tabs()
152
+			),
153
+			'require_nonce' => false,
154
+		];
155
+		$this->_page_config         = [
156
+			'default'          => $payment_method_list_config,
157
+			'payment_settings' => [
158
+				'nav'           => [
159
+					'label' => esc_html__('Settings', 'event_espresso'),
160
+					'icon'  => 'dashicons-admin-generic',
161
+					'order' => 20,
162
+				],
163
+				'help_tabs'     => [
164
+					'payment_methods_settings_help_tab' => [
165
+						'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
166
+						'filename' => 'payment_methods_settings',
167
+					],
168
+				],
169
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
170
+				'require_nonce' => false,
171
+			],
172
+			'payment_log'      => [
173
+				'nav'           => [
174
+					'label' => esc_html__("Logs", 'event_espresso'),
175
+					'icon'  => 'dashicons-text-page',
176
+					'order' => 30,
177
+				],
178
+				'list_table'    => 'Payment_Log_Admin_List_Table',
179
+				'metaboxes'     => $this->_default_espresso_metaboxes,
180
+				'require_nonce' => false,
181
+			],
182
+		];
183
+	}
184
+
185
+
186
+	/**
187
+	 * @return array
188
+	 * @throws DomainException
189
+	 * @throws EE_Error
190
+	 * @throws InvalidArgumentException
191
+	 * @throws InvalidDataTypeException
192
+	 * @throws InvalidInterfaceException
193
+	 * @throws ReflectionException
194
+	 */
195
+	protected function _add_payment_method_help_tabs(): array
196
+	{
197
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
198
+		$payment_method_types     = EE_Payment_Method_Manager::instance()->payment_method_types();
199
+		$all_pmt_help_tabs_config = [];
200
+		foreach ($payment_method_types as $payment_method_type) {
201
+			if (
202
+				! $this->capabilities->current_user_can(
203
+					$payment_method_type->cap_name(),
204
+					'specific_payment_method_type_access'
205
+				)
206
+			) {
207
+				continue;
208
+			}
209
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
210
+				$template_args                              = $config['template_args'] ?? [];
211
+				$template_args['admin_page_obj']            = $this;
212
+				$all_pmt_help_tabs_config[ $help_tab_name ] = [
213
+					'title'   => $config['title'],
214
+					'content' => EEH_Template::display_template(
215
+						$payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
216
+						$template_args,
217
+						true
218
+					),
219
+				];
220
+			}
221
+		}
222
+		return $all_pmt_help_tabs_config;
223
+	}
224
+
225
+
226
+	// none of the below group are currently used for Gateway Settings
227
+	protected function _add_screen_options()
228
+	{
229
+	}
230
+
231
+
232
+	protected function _add_feature_pointers()
233
+	{
234
+	}
235
+
236
+
237
+	public function admin_init()
238
+	{
239
+	}
240
+
241
+
242
+	public function admin_notices()
243
+	{
244
+	}
245
+
246
+
247
+	public function admin_footer_scripts()
248
+	{
249
+	}
250
+
251
+
252
+	public function load_scripts_styles()
253
+	{
254
+		// styles
255
+		wp_enqueue_style('espresso-ui-theme');
256
+		wp_register_style(
257
+			'espresso_payments',
258
+			EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
259
+			[],
260
+			EVENT_ESPRESSO_VERSION
261
+		);
262
+		// scripts
263
+		wp_enqueue_script('ee_admin_js');
264
+		wp_enqueue_script('ee-text-links');
265
+		wp_enqueue_script(
266
+			'espresso_payments',
267
+			EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
268
+			['ee-datepicker'],
269
+			EVENT_ESPRESSO_VERSION,
270
+			true
271
+		);
272
+	}
273
+
274
+
275
+	public function load_scripts_styles_default()
276
+	{
277
+		wp_enqueue_style('espresso_payments');
278
+		wp_enqueue_style('ee-text-links');
279
+	}
280
+
281
+
282
+	public function load_scripts_styles_payment_log_details()
283
+	{
284
+		wp_enqueue_style('espresso_payments');
285
+	}
286
+
287
+
288
+	/**
289
+	 * @throws EE_Error
290
+	 */
291
+	private function veryifyTablesExist()
292
+	{
293
+		/** @var TableAnalysis $table_analysis */
294
+		$table_analysis = LoaderFactory::getShared(TableAnalysis::class);
295
+		/** @var TableManager $table_manager */
296
+		$table_manager = LoaderFactory::getShared(TableManager::class);
297
+		if (! $table_analysis->tableExists('esp_payment_method')) {
298
+			$table_manager->createTable(
299
+				'esp_payment_method',
300
+				"PMD_ID int(11) NOT NULL AUTO_INCREMENT,
301 301
 				PMD_type varchar(124) DEFAULT NULL,
302 302
 				PMD_name varchar(255) DEFAULT NULL,
303 303
 				PMD_desc text,
@@ -313,1023 +313,1023 @@  discard block
 block discarded – undo
313 313
 				PRIMARY KEY  (PMD_ID),
314 314
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
315 315
 				KEY PMD_type (PMD_type)",
316
-                'InnoDB'
317
-            );
318
-        }
319
-        if (! $table_analysis->tableExists('esp_currency_payment_method')) {
320
-            $table_manager->createTable(
321
-                'esp_currency_payment_method',
322
-                "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
316
+				'InnoDB'
317
+			);
318
+		}
319
+		if (! $table_analysis->tableExists('esp_currency_payment_method')) {
320
+			$table_manager->createTable(
321
+				'esp_currency_payment_method',
322
+				"CPM_ID int(11) NOT NULL AUTO_INCREMENT,
323 323
 				CUR_code varchar(6) NOT NULL,
324 324
 				PMD_ID int(11) NOT NULL,
325 325
 				PRIMARY KEY  (CPM_ID),
326 326
 				KEY PMD_ID (PMD_ID)",
327
-                'InnoDB'
328
-            );
329
-        }
330
-    }
331
-
332
-
333
-    /**
334
-     * @throws EE_Error
335
-     * @throws ReflectionException
336
-     */
337
-    protected function _payment_methods_list()
338
-    {
339
-        $this->veryifyTablesExist();
340
-        /**
341
-         * first let's ensure payment methods have been set up.
342
-         * We do this here because when people activate a payment method for the first time (as an addon),
343
-         * it may not set up its capabilities or get registered correctly due to the loading process.
344
-         * However, people MUST set up the details for the payment method,
345
-         * so it's safe to do a recheck here.
346
-         */
347
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
348
-        EEM_Payment_Method::instance()->verify_button_urls();
349
-        // set up tabs, one for each payment method type
350
-        $tabs            = [];
351
-        $payment_methods = [];
352
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
353
-            // we don't want to show admin-only PMTs for now
354
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
355
-                continue;
356
-            }
357
-            // check access
358
-            if (
359
-                ! $this->capabilities->current_user_can(
360
-                    $pmt_obj->cap_name(),
361
-                    'specific_payment_method_type_access'
362
-                )
363
-            ) {
364
-                continue;
365
-            }
366
-            // check for any active pms of that type
367
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
368
-            if (! $payment_method instanceof EE_Payment_Method) {
369
-                $payment_method = EE_Payment_Method::new_instance(
370
-                    [
371
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
372
-                        'PMD_type'       => $pmt_obj->system_name(),
373
-                        'PMD_name'       => $pmt_obj->pretty_name(),
374
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
375
-                    ]
376
-                );
377
-            }
378
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
379
-        }
380
-        $payment_methods = apply_filters(
381
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
382
-            $payment_methods
383
-        );
384
-        foreach ($payment_methods as $payment_method) {
385
-            if ($payment_method instanceof EE_Payment_Method) {
386
-                $this->addMetaBox(
387
-                // html id
388
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
389
-                    // title
390
-                    sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
391
-                    // callback
392
-                    [$this, 'payment_method_settings_meta_box'],
393
-                    // post type
394
-                    null,
395
-                    // context
396
-                    'normal',
397
-                    // priority
398
-                    'default',
399
-                    // callback args
400
-                    ['payment_method' => $payment_method]
401
-                );
402
-                // setup for tabbed content
403
-                $tabs[ $payment_method->slug() ] = [
404
-                    'label' => $payment_method->admin_name(),
405
-                    'class' => $payment_method->active()
406
-                        ? 'gateway-active'
407
-                        : '',
408
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
409
-                    'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
410
-                    'slug'  => $payment_method->slug(),
411
-                    'icon'  => $payment_method->active()
412
-                        ? '<span class="dashicons dashicons-yes-alt"></span>'
413
-                        : '<span class="dashicons dashicons-remove"></span>',
414
-                ];
415
-            }
416
-        }
417
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
418
-            $tabs,
419
-            'payment_method_links',
420
-            '',
421
-            $this->_get_active_payment_method_slug()
422
-        );
423
-        $this->display_admin_page_with_sidebar();
424
-    }
425
-
426
-
427
-    /**
428
-     *   _get_active_payment_method_slug
429
-     *
430
-     * @return string
431
-     * @throws EE_Error
432
-     * @throws ReflectionException
433
-     */
434
-    protected function _get_active_payment_method_slug()
435
-    {
436
-        $payment_method_slug = false;
437
-        // decide which payment method tab to open first, as dictated by the request's 'payment_method'
438
-        if (isset($this->_req_data['payment_method'])) {
439
-            // if they provided the current payment method, use it
440
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
441
-        }
442
-        /** @var EE_Payment_Method $payment_method */
443
-        $payment_method = EEM_Payment_Method::instance()->get_one([['PMD_slug' => $payment_method_slug]]);
444
-        // if that didn't work or wasn't provided, find another way to select the current pm
445
-        if (! $this->_verify_payment_method($payment_method)) {
446
-            // like, looking for an active one
447
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
448
-            // test that one as well
449
-            if ($this->_verify_payment_method($payment_method)) {
450
-                $payment_method_slug = $payment_method->slug();
451
-            } else {
452
-                $payment_method_slug = 'paypal_standard';
453
-            }
454
-        }
455
-        return $payment_method_slug;
456
-    }
457
-
458
-
459
-    /**
460
-     *    payment_method_settings_meta_box
461
-     *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
462
-     *    capabilities to access it
463
-     *
464
-     * @param EE_Payment_Method|null $payment_method
465
-     * @return boolean
466
-     * @throws EE_Error
467
-     */
468
-    protected function _verify_payment_method(?EE_Payment_Method $payment_method): bool
469
-    {
470
-        return $payment_method instanceof EE_Payment_Method
471
-               && $payment_method->type_obj() instanceof EE_PMT_Base
472
-               && $this->capabilities->current_user_can(
473
-                   $payment_method->type_obj()->cap_name(),
474
-                   'specific_payment_method_type_access'
475
-               );
476
-    }
477
-
478
-
479
-    /**
480
-     *    payment_method_settings_meta_box
481
-     *
482
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
483
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
484
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
485
-     * @return void
486
-     * @throws EE_Error
487
-     * @throws ReflectionException
488
-     */
489
-    public function payment_method_settings_meta_box($post_obj_which_is_null, array $metabox)
490
-    {
491
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
492
-            ? $metabox['args']['payment_method']
493
-            : null;
494
-        if (! $payment_method instanceof EE_Payment_Method) {
495
-            throw new EE_Error(
496
-                esc_html__(
497
-                    'Payment method metabox setup incorrectly. No Payment method object was supplied',
498
-                    'event_espresso'
499
-                )
500
-            );
501
-        }
502
-        $payment_method_scopes = $payment_method->active();
503
-        // if the payment method really exists show its form, otherwise the activation template
504
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
505
-            $form = $this->_generate_payment_method_settings_form($payment_method);
506
-            if ($form->form_data_present_in($this->_req_data)) {
507
-                $form->receive_form_submission($this->_req_data);
508
-            }
509
-            echo wp_kses(
510
-                $form->form_open() . $form->get_html_and_js() . $form->form_close(),
511
-                AllowedTags::getWithFormTags()
512
-            );
513
-        } else {
514
-            echo wp_kses(
515
-                $this->_activate_payment_method_button($payment_method)->get_html_and_js(),
516
-                AllowedTags::getWithFormTags()
517
-            );
518
-        }
519
-    }
520
-
521
-
522
-    /**
523
-     * Gets the form for all the settings related to this payment method type
524
-     *
525
-     * @access protected
526
-     * @param EE_Payment_Method|null $payment_method
527
-     * @return EE_Form_Section_Proper
528
-     * @throws EE_Error
529
-     * @throws ReflectionException
530
-     */
531
-    protected function _generate_payment_method_settings_form(
532
-        ?EE_Payment_Method $payment_method
533
-    ): EE_Form_Section_Proper {
534
-        if (! $payment_method instanceof EE_Payment_Method) {
535
-            return new EE_Form_Section_Proper();
536
-        }
537
-        $subsections = apply_filters(
538
-            'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
539
-            [
540
-                'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
541
-                'currency_support'        => $this->_currency_support($payment_method),
542
-                'payment_method_settings' => $this->_payment_method_settings($payment_method),
543
-                'update'                  => $this->_update_payment_method_button($payment_method),
544
-                'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
545
-                'fine_print'              => $this->_fine_print(),
546
-            ],
547
-            $payment_method
548
-        );
549
-        return new EE_Form_Section_Proper(
550
-            [
551
-                'name'            => $payment_method->slug() . '_settings_form',
552
-                'html_id'         => $payment_method->slug() . '_settings_form',
553
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
554
-                    [
555
-                        'action'         => 'update_payment_method',
556
-                        'payment_method' => $payment_method->slug(),
557
-                    ],
558
-                    EE_PAYMENTS_ADMIN_URL
559
-                ),
560
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
561
-                'subsections'     => array_filter($subsections),
562
-            ]
563
-        );
564
-    }
565
-
566
-
567
-    /**
568
-     * _pci_dss_compliance
569
-     *
570
-     * @access protected
571
-     * @param EE_Payment_Method $payment_method
572
-     * @return EE_Form_Section_HTML|null
573
-     * @throws EE_Error
574
-     */
575
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
576
-    {
577
-        if (! $payment_method->type_obj()->requires_https()) {
578
-            return null;
579
-        }
580
-        return new EE_Form_Section_HTML(
581
-            EEH_HTML::tr(
582
-                EEH_HTML::th(
583
-                    EEH_HTML::label(
584
-                        EEH_HTML::strong(
585
-                            esc_html__('IMPORTANT', 'event_espresso'),
586
-                            '',
587
-                            'important-notice'
588
-                        )
589
-                    )
590
-                ) .
591
-                EEH_HTML::td(
592
-                    EEH_HTML::div(
593
-                        EEH_HTML::strong(
594
-                            esc_html__(
595
-                                'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
596
-                                'event_espresso'
597
-                            )
598
-                        ),
599
-                        '',
600
-                        'ee-status-outline ee-status-bg--warning'
601
-                    )
602
-                    . EEH_HTML::br()
603
-
604
-                    . EEH_HTML::div(
605
-                        esc_html__('Learn more about ', 'event_espresso')
606
-                        . EEH_HTML::link(
607
-                            'https://www.pcisecuritystandards.org/merchants/index.php',
608
-                            esc_html__('PCI DSS compliance', 'event_espresso')
609
-                        ),
610
-                        '',
611
-                        'ee-status-outline ee-status-bg--info'
612
-                    )
613
-                )
614
-            )
615
-        );
616
-    }
617
-
618
-
619
-    /**
620
-     * _currency_support
621
-     *
622
-     * @access protected
623
-     * @param EE_Payment_Method $payment_method
624
-     * @return EE_Form_Section_HTML|null
625
-     * @throws EE_Error
626
-     */
627
-    protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
628
-    {
629
-        if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
630
-            return null;
631
-        }
632
-        return new EE_Form_Section_HTML(
633
-            EEH_HTML::tr(
634
-                EEH_HTML::th(
635
-                    EEH_HTML::label(
636
-                        EEH_HTML::strong(
637
-                            esc_html__('IMPORTANT', 'event_espresso'),
638
-                            '',
639
-                            'important-notice'
640
-                        )
641
-                    )
642
-                ) .
643
-                EEH_HTML::td(
644
-                    EEH_HTML::div(
645
-                        EEH_HTML::strong(
646
-                            sprintf(
647
-                                esc_html__(
648
-                                    'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
649
-                                    'event_espresso'
650
-                                ),
651
-                                EE_Config::instance()->currency->code
652
-                            )
653
-                        ),
654
-                        '',
655
-                        'ee-status-outline ee-status-bg--warning'
656
-                    )
657
-                )
658
-            )
659
-        );
660
-    }
661
-
662
-
663
-    /**
664
-     * _update_payment_method_button
665
-     *
666
-     * @access protected
667
-     * @param EE_Payment_Method $payment_method
668
-     * @return EE_Payment_Method_Form
669
-     * @throws EE_Error
670
-     * @throws ReflectionException
671
-     */
672
-    protected function _payment_method_settings(EE_Payment_Method $payment_method): EE_Payment_Method_Form
673
-    {
674
-        // modify the form, so we only have/show fields that will be implemented for this version
675
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
676
-    }
677
-
678
-
679
-    /**
680
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
681
-     *
682
-     * @param EE_Form_Section_Proper $form_section
683
-     * @param string                 $payment_method_name
684
-     * @return EE_Payment_Method_Form
685
-     * @throws EE_Error
686
-     */
687
-    protected function _simplify_form(
688
-        EE_Form_Section_Proper $form_section,
689
-        string $payment_method_name = ''
690
-    ): EE_Payment_Method_Form {
691
-        if ($form_section instanceof EE_Payment_Method_Form) {
692
-            $form_section->exclude(
693
-                [
694
-                    'PMD_type', // don't want them changing the type
695
-                    'PMD_slug', // or the slug (probably never)
696
-                    'PMD_wp_user', // or the user's ID
697
-                    'Currency', // or the currency, until the rest of EE supports simultaneous currencies
698
-                ]
699
-            );
700
-            return $form_section;
701
-        }
702
-        throw new EE_Error(
703
-            sprintf(
704
-                esc_html__(
705
-                    'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
706
-                    'event_espresso'
707
-                ),
708
-                $payment_method_name
709
-            )
710
-        );
711
-    }
712
-
713
-
714
-    /**
715
-     * _update_payment_method_button
716
-     *
717
-     * @access protected
718
-     * @param EE_Payment_Method $payment_method
719
-     * @return EE_Form_Section_HTML
720
-     * @throws EE_Error
721
-     */
722
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_HTML
723
-    {
724
-        $update_button = new EE_Submit_Input(
725
-            [
726
-                'name'       => 'submit',
727
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
728
-                'default'    => sprintf(
729
-                    esc_html__('Update %s Payment Settings', 'event_espresso'),
730
-                    $payment_method->admin_name()
731
-                ),
732
-                'html_label' => EEH_HTML::nbsp(),
733
-            ]
734
-        );
735
-        return new EE_Form_Section_HTML(
736
-            EEH_HTML::tr(
737
-                EEH_HTML::th(
738
-                // esc_html__('Update Settings', 'event_espresso'),
739
-                    '&nbsp;',
740
-                    '',
741
-                    'ee-update-' . $payment_method->slug() . '-settings__label'
742
-                ) .
743
-                EEH_HTML::td(
744
-                    $update_button->get_html_for_input(),
745
-                    '',
746
-                    'ee-update-' . $payment_method->slug() . '-settings__input'
747
-                ),
748
-                '',
749
-                'ee-update-' . $payment_method->slug() . '-settings'
750
-            )
751
-        );
752
-    }
753
-
754
-
755
-    /**
756
-     * _deactivate_payment_method_button
757
-     *
758
-     * @access protected
759
-     * @param EE_Payment_Method $payment_method
760
-     * @return EE_Form_Section_HTML
761
-     */
762
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_HTML
763
-    {
764
-        $link_text_and_title = sprintf(
765
-            esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
766
-            $payment_method->admin_name()
767
-        );
768
-        return new EE_Form_Section_HTML(
769
-            EEH_HTML::tr(
770
-                EEH_HTML::th(
771
-                // esc_html__('Deactivate Payment Method', 'event_espresso'),
772
-                    '&nbsp;',
773
-                    '',
774
-                    'ee-deactivate-' . $payment_method->slug() . '-settings__label'
775
-                ) .
776
-                EEH_HTML::td(
777
-                    EEH_HTML::link(
778
-                        EE_Admin_Page::add_query_args_and_nonce(
779
-                            [
780
-                                'action'         => 'deactivate_payment_method',
781
-                                'payment_method' => $payment_method->slug(),
782
-                            ],
783
-                            EE_PAYMENTS_ADMIN_URL
784
-                        ),
785
-                        $link_text_and_title,
786
-                        $link_text_and_title,
787
-                        'deactivate_' . $payment_method->slug(),
788
-                        'button button--secondary'
789
-                    ),
790
-                    '',
791
-                    'ee-deactivate-' . $payment_method->slug() . '-settings__input'
792
-                ),
793
-                '',
794
-                'ee-deactivate-' . $payment_method->slug() . '-settings'
795
-            )
796
-        );
797
-    }
798
-
799
-
800
-    /**
801
-     * _activate_payment_method_button
802
-     *
803
-     * @access protected
804
-     * @param EE_Payment_Method $payment_method
805
-     * @return EE_Form_Section_Proper
806
-     * @throws EE_Error
807
-     */
808
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_Proper
809
-    {
810
-        $link_text_and_title = sprintf(
811
-            esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
812
-            $payment_method->admin_name()
813
-        );
814
-        return new EE_Form_Section_Proper(
815
-            [
816
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
817
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
818
-                'action'          => '#',
819
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
820
-                'subsections'     => apply_filters(
821
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
822
-                    [
823
-                        new EE_Form_Section_HTML(
824
-                            EEH_HTML::table(
825
-                                EEH_HTML::tr(
826
-                                    EEH_HTML::td(
827
-                                        $payment_method->type_obj()->introductory_html(),
828
-                                        '',
829
-                                        '',
830
-                                        '',
831
-                                        'colspan="2"'
832
-                                    )
833
-                                ) .
834
-                                EEH_HTML::tr(
835
-                                    EEH_HTML::th(
836
-                                        EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
837
-                                    ) .
838
-                                    EEH_HTML::td(
839
-                                        EEH_HTML::link(
840
-                                            EE_Admin_Page::add_query_args_and_nonce(
841
-                                                [
842
-                                                    'action'              => 'activate_payment_method',
843
-                                                    'payment_method_type' => $payment_method->type(),
844
-                                                ],
845
-                                                EE_PAYMENTS_ADMIN_URL
846
-                                            ),
847
-                                            $link_text_and_title,
848
-                                            $link_text_and_title,
849
-                                            'activate_' . $payment_method->slug(),
850
-                                            'button button--primary-alt'
851
-                                        )
852
-                                    )
853
-                                )
854
-                            )
855
-                        ),
856
-                    ],
857
-                    $payment_method
858
-                ),
859
-            ]
860
-        );
861
-    }
862
-
863
-
864
-    /**
865
-     * _fine_print
866
-     *
867
-     * @access protected
868
-     * @return EE_Form_Section_HTML
869
-     */
870
-    protected function _fine_print(): EE_Form_Section_HTML
871
-    {
872
-        return new EE_Form_Section_HTML(
873
-            EEH_HTML::tr(
874
-                EEH_HTML::th()
875
-                . EEH_HTML::thx()
876
-                . EEH_HTML::td(
877
-                    EEH_HTML::p(
878
-                        esc_html__('All fields marked with a * are required fields', 'event_espresso'),
879
-                        '',
880
-                        'grey-text'
881
-                    )
882
-                )
883
-            )
884
-        );
885
-    }
886
-
887
-
888
-    /**
889
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
890
-     *
891
-     * @throws EE_Error
892
-     * @throws ReflectionException
893
-     * @global WP_User $current_user
894
-     */
895
-    protected function _activate_payment_method()
896
-    {
897
-        if (isset($this->_req_data['payment_method_type'])) {
898
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
899
-            // see if one exists
900
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
901
-            $payment_method = EE_Payment_Method_Manager::instance()
902
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
903
-            $this->_redirect_after_action(
904
-                1,
905
-                'Payment Method',
906
-                'activated',
907
-                ['action' => 'default', 'payment_method' => $payment_method->slug()]
908
-            );
909
-        } else {
910
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', ['action' => 'default']);
911
-        }
912
-    }
913
-
914
-
915
-    /**
916
-     * @throws EE_Error
917
-     * @throws ReflectionException
918
-     */
919
-    protected function _deactivate_payment_method()
920
-    {
921
-        if (isset($this->_req_data['payment_method'])) {
922
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
923
-            // deactivate it
924
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
925
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
926
-            $this->_redirect_after_action(
927
-                $count_updated,
928
-                'Payment Method',
929
-                'deactivated',
930
-                ['action' => 'default', 'payment_method' => $payment_method_slug]
931
-            );
932
-        } else {
933
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', ['action' => 'default']);
934
-        }
935
-    }
936
-
937
-
938
-    /**
939
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
940
-     * processing because we first need to identify WHICH form was processed and which payment method
941
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
942
-     * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
943
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
944
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
945
-     *
946
-     * @return void
947
-     * @throws EE_Error
948
-     * @throws ReflectionException
949
-     */
950
-    protected function _update_payment_method()
951
-    {
952
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
953
-            // ok let's find which gateway form to use based on the form input
954
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
955
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
956
-            $correct_pmt_form_to_use = null;
957
-            $payment_method          = null;
958
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
959
-                if ($payment_method instanceof EE_Payment_Method) {
960
-                    // get the form and simplify it, like what we do when we display it
961
-                    $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
962
-                    if ($pmt_form->form_data_present_in($this->_req_data)) {
963
-                        $correct_pmt_form_to_use = $pmt_form;
964
-                        break;
965
-                    }
966
-                }
967
-            }
968
-            // if we couldn't find the correct payment method type...
969
-            if (! $correct_pmt_form_to_use) {
970
-                EE_Error::add_error(
971
-                    esc_html__(
972
-                        "We could not find which payment method type your form submission related to. Please contact support",
973
-                        'event_espresso'
974
-                    ),
975
-                    __FILE__,
976
-                    __FUNCTION__,
977
-                    __LINE__
978
-                );
979
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', ['action' => 'default']);
980
-            }
981
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
982
-            if ($correct_pmt_form_to_use->is_valid()) {
983
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
984
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
985
-                    throw new EE_Error(
986
-                        sprintf(
987
-                            esc_html__(
988
-                                'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
989
-                                'event_espresso'
990
-                            ),
991
-                            'payment_method_settings'
992
-                        )
993
-                    );
994
-                }
995
-                $payment_settings_subform->save();
996
-                /** @var $pm EE_Payment_Method */
997
-                $this->_redirect_after_action(
998
-                    true,
999
-                    'Payment Method',
1000
-                    'updated',
1001
-                    ['action' => 'default', 'payment_method' => $payment_method->slug()]
1002
-                );
1003
-            } else {
1004
-                EE_Error::add_error(
1005
-                    sprintf(
1006
-                        esc_html__(
1007
-                            'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
1008
-                            'event_espresso'
1009
-                        ),
1010
-                        $payment_method instanceof EE_Payment_Method
1011
-                            ? $payment_method->type_obj()->pretty_name()
1012
-                            : esc_html__('"(unknown)"', 'event_espresso')
1013
-                    ),
1014
-                    __FILE__,
1015
-                    __FUNCTION__,
1016
-                    __LINE__
1017
-                );
1018
-            }
1019
-        }
1020
-    }
1021
-
1022
-
1023
-    /**
1024
-     * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
1025
-     *
1026
-     * @throws DomainException
1027
-     * @throws EE_Error
1028
-     * @throws InvalidArgumentException
1029
-     * @throws InvalidDataTypeException
1030
-     * @throws InvalidInterfaceException
1031
-     */
1032
-    protected function _payment_settings()
1033
-    {
1034
-        $form = $this->getPaymentSettingsForm();
1035
-        $this->_set_add_edit_form_tags('update_payment_settings');
1036
-        $this->_set_publish_post_box_vars();
1037
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1038
-            $form->get_html_and_js(),
1039
-            '',
1040
-            'padding'
1041
-        );
1042
-        $this->display_admin_page_with_sidebar();
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     *        _update_payment_settings
1048
-     *
1049
-     * @access protected
1050
-     * @return void
1051
-     * @throws EE_Error
1052
-     * @throws InvalidArgumentException
1053
-     * @throws InvalidDataTypeException
1054
-     * @throws InvalidInterfaceException
1055
-     */
1056
-    protected function _update_payment_settings()
1057
-    {
1058
-        $form = $this->getPaymentSettingsForm();
1059
-        if ($form->was_submitted($this->_req_data)) {
1060
-            $form->receive_form_submission($this->_req_data);
1061
-            if ($form->is_valid()) {
1062
-                /**
1063
-                 * @var $reg_config EE_Registration_Config
1064
-                 */
1065
-                $loader                                   = LoaderFactory::getLoader();
1066
-                $reg_config                               = $loader->getShared('EE_Registration_Config');
1067
-                $valid_data                               = $form->valid_data();
1068
-                $show_pending_payment_options             = $valid_data['show_pending_payment_options'] ?? null;
1069
-                $reg_config->show_pending_payment_options = $show_pending_payment_options === 'ON';
1070
-                $reg_config->gateway_log_lifespan         = $valid_data['gateway_log_lifespan'];
1071
-            }
1072
-        }
1073
-        EE_Registry::instance()->CFG = apply_filters(
1074
-            'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
1075
-            EE_Registry::instance()->CFG
1076
-        );
1077
-
1078
-        $what    = esc_html__('Payment Settings', 'event_espresso');
1079
-        $success = $this->_update_espresso_configuration(
1080
-            $what,
1081
-            EE_Registry::instance()->CFG,
1082
-            __FILE__,
1083
-            __FUNCTION__,
1084
-            __LINE__
1085
-        );
1086
-        $this->_redirect_after_action(
1087
-            $success,
1088
-            $what,
1089
-            esc_html__('updated', 'event_espresso'),
1090
-            ['action' => 'payment_settings']
1091
-        );
1092
-    }
1093
-
1094
-
1095
-    /**
1096
-     * Gets the form used for updating payment settings
1097
-     *
1098
-     * @return EE_Form_Section_Proper
1099
-     * @throws EE_Error
1100
-     * @throws InvalidArgumentException
1101
-     * @throws InvalidDataTypeException
1102
-     * @throws InvalidInterfaceException
1103
-     */
1104
-    protected function getPaymentSettingsForm(): EE_Form_Section_Proper
1105
-    {
1106
-        /**
1107
-         * @var $reg_config EE_Registration_Config
1108
-         */
1109
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1110
-        return new EE_Form_Section_Proper(
1111
-            [
1112
-                'name'            => 'payment-settings',
1113
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1114
-                'subsections'     => [
1115
-                    'show_pending_payment_options' => new EE_Switch_Input(
1116
-                        [
1117
-                            'default'        => $reg_config->show_pending_payment_options
1118
-                                ? EE_Switch_Input::OPTION_ON
1119
-                                : EE_Switch_Input::OPTION_OFF,
1120
-                            'html_name'      => 'show_pending_payment_options',
1121
-                            'html_help_text' => esc_html__(
1122
-                                "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1123
-                                'event_espresso'
1124
-                            ),
1125
-                        ],
1126
-                        [
1127
-                            EE_Switch_Input::OPTION_OFF => esc_html__(
1128
-                                'pending payment options are NOT displayed',
1129
-                                'event_espresso'
1130
-                            ),
1131
-                            EE_Switch_Input::OPTION_ON  => esc_html__(
1132
-                                'pending payment options are displayed',
1133
-                                'event_espresso'
1134
-                            ),
1135
-                        ]
1136
-                    ),
1137
-                    'gateway_log_lifespan'         => new EE_Select_Input(
1138
-                        $reg_config->gatewayLogLifespanOptions(),
1139
-                        [
1140
-                            'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1141
-                            'html_help_text'  => esc_html__(
1142
-                                'If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.',
1143
-                                'event_espresso'
1144
-                            ),
1145
-                            'default'         => $reg_config->gateway_log_lifespan,
1146
-                        ]
1147
-                    ),
1148
-                ],
1149
-            ]
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * @throws EE_Error
1156
-     */
1157
-    protected function _payment_log_overview_list_table()
1158
-    {
1159
-        $this->display_admin_list_table_page_with_sidebar();
1160
-    }
1161
-
1162
-
1163
-    protected function _set_list_table_views_payment_log()
1164
-    {
1165
-        $this->_views = [
1166
-            'all' => [
1167
-                'slug'  => 'all',
1168
-                'label' => esc_html__('View All Logs', 'event_espresso'),
1169
-                'count' => 0,
1170
-            ],
1171
-        ];
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * @param int  $per_page
1177
-     * @param int  $current_page
1178
-     * @param bool $count
1179
-     * @return array|int
1180
-     * @throws EE_Error
1181
-     * @throws ReflectionException
1182
-     */
1183
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1184
-    {
1185
-        EE_Registry::instance()->load_model('Change_Log');
1186
-        // we may need to do multiple queries (joining differently), so we actually want an array of query params
1187
-        $query_params = [['LOG_type' => EEM_Change_Log::type_gateway]];
1188
-        // check if they've selected a specific payment method
1189
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1190
-            $query_params[0]['OR*pm_or_pay_pm'] = [
1191
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1192
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1193
-            ];
1194
-        }
1195
-        // take into account search
1196
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1197
-            $similarity_string                                                              =
1198
-                ['LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'];
1199
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1200
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1201
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1202
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name']                     = $similarity_string;
1203
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name']               = $similarity_string;
1204
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type']                     = $similarity_string;
1205
-            $query_params[0]['OR*s']['Payment_Method.PMD_name']                             = $similarity_string;
1206
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name']                       = $similarity_string;
1207
-            $query_params[0]['OR*s']['Payment_Method.PMD_type']                             = $similarity_string;
1208
-            $query_params[0]['OR*s']['LOG_message']                                         = $similarity_string;
1209
-        }
1210
-        if (
1211
-            isset($this->_req_data['payment-filter-start-date'])
1212
-            && isset($this->_req_data['payment-filter-end-date'])
1213
-        ) {
1214
-            // add date
1215
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1216
-            $end_date   = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1217
-            // make sure our timestamps start and end right at the boundaries for each day
1218
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1219
-            $end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1220
-            // convert to timestamps
1221
-            $start_date = strtotime($start_date);
1222
-            $end_date   = strtotime($end_date);
1223
-            // makes sure start date is the lowest value and vice versa
1224
-            $start_date = min($start_date, $end_date);
1225
-            $end_date   = max($start_date, $end_date);
1226
-            // convert for query
1227
-            $start_date                  = EEM_Change_Log::instance()->convert_datetime_for_query(
1228
-                'LOG_time',
1229
-                date('Y-m-d H:i:s', $start_date),
1230
-                'Y-m-d H:i:s'
1231
-            );
1232
-            $end_date                    = EEM_Change_Log::instance()->convert_datetime_for_query(
1233
-                'LOG_time',
1234
-                date('Y-m-d H:i:s', $end_date),
1235
-                'Y-m-d H:i:s'
1236
-            );
1237
-            $query_params[0]['LOG_time'] = ['BETWEEN', [$start_date, $end_date]];
1238
-        }
1239
-        if ($count) {
1240
-            return EEM_Change_Log::instance()->count($query_params);
1241
-        }
1242
-        if (isset($this->_req_data['order'])) {
1243
-            $sort                     = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1244
-                ? $this->_req_data['order']
1245
-                : 'DESC';
1246
-            $query_params['order_by'] = ['LOG_time' => $sort];
1247
-        } else {
1248
-            $query_params['order_by'] = ['LOG_time' => 'DESC'];
1249
-        }
1250
-        $offset = ($current_page - 1) * $per_page;
1251
-        if (! isset($this->_req_data['download_results'])) {
1252
-            $query_params['limit'] = [$offset, $per_page];
1253
-        }
1254
-        // now they've requested to instead just download the file instead of viewing it.
1255
-        if (isset($this->_req_data['download_results'])) {
1256
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1257
-            header('Content-Disposition: attachment');
1258
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1259
-            echo '<h1> '
1260
-                 . sprintf(
1261
-                     esc_html__('Payment Logs for %1$s', 'event_espresso'),
1262
-                     esc_url_raw(site_url())
1263
-                 )
1264
-                 . '</h1 >';
1265
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1266
-            echo esc_html(var_export($query_params, true));
1267
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1268
-            echo esc_html(var_export($wpdb_results, true));
1269
-            die;
1270
-        }
1271
-        return EEM_Change_Log::instance()->get_all($query_params);
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * Used by usort to RE-sort log query results, because we lose the ordering
1277
-     * because we're possibly combining the results from two queries
1278
-     *
1279
-     * @param EE_Change_Log $logA
1280
-     * @param EE_Change_Log $logB
1281
-     * @return int
1282
-     * @throws EE_Error
1283
-     * @throws ReflectionException
1284
-     */
1285
-    protected function _sort_logs_again($logA, $logB)
1286
-    {
1287
-        $timeA = $logA->get_raw('LOG_time');
1288
-        $timeB = $logB->get_raw('LOG_time');
1289
-        if ($timeA == $timeB) {
1290
-            return 0;
1291
-        }
1292
-        $comparison = $timeA < $timeB
1293
-            ? -1
1294
-            : 1;
1295
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1296
-            return $comparison * -1;
1297
-        }
1298
-        return $comparison;
1299
-    }
1300
-
1301
-
1302
-    /**
1303
-     * @throws EE_Error
1304
-     * @throws ReflectionException
1305
-     */
1306
-    protected function _payment_log_details()
1307
-    {
1308
-        EE_Registry::instance()->load_model('Change_Log');
1309
-        /** @var $payment_log EE_Change_Log */
1310
-        $payment_log    = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1311
-        $payment_method = null;
1312
-        $transaction    = null;
1313
-        if ($payment_log instanceof EE_Change_Log) {
1314
-            if ($payment_log->object() instanceof EE_Payment) {
1315
-                $payment_method = $payment_log->object()->payment_method();
1316
-                $transaction    = $payment_log->object()->transaction();
1317
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1318
-                $payment_method = $payment_log->object();
1319
-            } elseif ($payment_log->object() instanceof EE_Transaction) {
1320
-                $transaction    = $payment_log->object();
1321
-                $payment_method = $transaction->payment_method();
1322
-            }
1323
-        }
1324
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1325
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1326
-            [
1327
-                'payment_log'    => $payment_log,
1328
-                'payment_method' => $payment_method,
1329
-                'transaction'    => $transaction,
1330
-            ],
1331
-            true
1332
-        );
1333
-        $this->display_admin_page_with_no_sidebar();
1334
-    }
327
+				'InnoDB'
328
+			);
329
+		}
330
+	}
331
+
332
+
333
+	/**
334
+	 * @throws EE_Error
335
+	 * @throws ReflectionException
336
+	 */
337
+	protected function _payment_methods_list()
338
+	{
339
+		$this->veryifyTablesExist();
340
+		/**
341
+		 * first let's ensure payment methods have been set up.
342
+		 * We do this here because when people activate a payment method for the first time (as an addon),
343
+		 * it may not set up its capabilities or get registered correctly due to the loading process.
344
+		 * However, people MUST set up the details for the payment method,
345
+		 * so it's safe to do a recheck here.
346
+		 */
347
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
348
+		EEM_Payment_Method::instance()->verify_button_urls();
349
+		// set up tabs, one for each payment method type
350
+		$tabs            = [];
351
+		$payment_methods = [];
352
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
353
+			// we don't want to show admin-only PMTs for now
354
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
355
+				continue;
356
+			}
357
+			// check access
358
+			if (
359
+				! $this->capabilities->current_user_can(
360
+					$pmt_obj->cap_name(),
361
+					'specific_payment_method_type_access'
362
+				)
363
+			) {
364
+				continue;
365
+			}
366
+			// check for any active pms of that type
367
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
368
+			if (! $payment_method instanceof EE_Payment_Method) {
369
+				$payment_method = EE_Payment_Method::new_instance(
370
+					[
371
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
372
+						'PMD_type'       => $pmt_obj->system_name(),
373
+						'PMD_name'       => $pmt_obj->pretty_name(),
374
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
375
+					]
376
+				);
377
+			}
378
+			$payment_methods[ $payment_method->slug() ] = $payment_method;
379
+		}
380
+		$payment_methods = apply_filters(
381
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
382
+			$payment_methods
383
+		);
384
+		foreach ($payment_methods as $payment_method) {
385
+			if ($payment_method instanceof EE_Payment_Method) {
386
+				$this->addMetaBox(
387
+				// html id
388
+					'espresso_' . $payment_method->slug() . '_payment_settings',
389
+					// title
390
+					sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
391
+					// callback
392
+					[$this, 'payment_method_settings_meta_box'],
393
+					// post type
394
+					null,
395
+					// context
396
+					'normal',
397
+					// priority
398
+					'default',
399
+					// callback args
400
+					['payment_method' => $payment_method]
401
+				);
402
+				// setup for tabbed content
403
+				$tabs[ $payment_method->slug() ] = [
404
+					'label' => $payment_method->admin_name(),
405
+					'class' => $payment_method->active()
406
+						? 'gateway-active'
407
+						: '',
408
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
409
+					'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
410
+					'slug'  => $payment_method->slug(),
411
+					'icon'  => $payment_method->active()
412
+						? '<span class="dashicons dashicons-yes-alt"></span>'
413
+						: '<span class="dashicons dashicons-remove"></span>',
414
+				];
415
+			}
416
+		}
417
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
418
+			$tabs,
419
+			'payment_method_links',
420
+			'',
421
+			$this->_get_active_payment_method_slug()
422
+		);
423
+		$this->display_admin_page_with_sidebar();
424
+	}
425
+
426
+
427
+	/**
428
+	 *   _get_active_payment_method_slug
429
+	 *
430
+	 * @return string
431
+	 * @throws EE_Error
432
+	 * @throws ReflectionException
433
+	 */
434
+	protected function _get_active_payment_method_slug()
435
+	{
436
+		$payment_method_slug = false;
437
+		// decide which payment method tab to open first, as dictated by the request's 'payment_method'
438
+		if (isset($this->_req_data['payment_method'])) {
439
+			// if they provided the current payment method, use it
440
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
441
+		}
442
+		/** @var EE_Payment_Method $payment_method */
443
+		$payment_method = EEM_Payment_Method::instance()->get_one([['PMD_slug' => $payment_method_slug]]);
444
+		// if that didn't work or wasn't provided, find another way to select the current pm
445
+		if (! $this->_verify_payment_method($payment_method)) {
446
+			// like, looking for an active one
447
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
448
+			// test that one as well
449
+			if ($this->_verify_payment_method($payment_method)) {
450
+				$payment_method_slug = $payment_method->slug();
451
+			} else {
452
+				$payment_method_slug = 'paypal_standard';
453
+			}
454
+		}
455
+		return $payment_method_slug;
456
+	}
457
+
458
+
459
+	/**
460
+	 *    payment_method_settings_meta_box
461
+	 *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
462
+	 *    capabilities to access it
463
+	 *
464
+	 * @param EE_Payment_Method|null $payment_method
465
+	 * @return boolean
466
+	 * @throws EE_Error
467
+	 */
468
+	protected function _verify_payment_method(?EE_Payment_Method $payment_method): bool
469
+	{
470
+		return $payment_method instanceof EE_Payment_Method
471
+			   && $payment_method->type_obj() instanceof EE_PMT_Base
472
+			   && $this->capabilities->current_user_can(
473
+				   $payment_method->type_obj()->cap_name(),
474
+				   'specific_payment_method_type_access'
475
+			   );
476
+	}
477
+
478
+
479
+	/**
480
+	 *    payment_method_settings_meta_box
481
+	 *
482
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
483
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
484
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
485
+	 * @return void
486
+	 * @throws EE_Error
487
+	 * @throws ReflectionException
488
+	 */
489
+	public function payment_method_settings_meta_box($post_obj_which_is_null, array $metabox)
490
+	{
491
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
492
+			? $metabox['args']['payment_method']
493
+			: null;
494
+		if (! $payment_method instanceof EE_Payment_Method) {
495
+			throw new EE_Error(
496
+				esc_html__(
497
+					'Payment method metabox setup incorrectly. No Payment method object was supplied',
498
+					'event_espresso'
499
+				)
500
+			);
501
+		}
502
+		$payment_method_scopes = $payment_method->active();
503
+		// if the payment method really exists show its form, otherwise the activation template
504
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
505
+			$form = $this->_generate_payment_method_settings_form($payment_method);
506
+			if ($form->form_data_present_in($this->_req_data)) {
507
+				$form->receive_form_submission($this->_req_data);
508
+			}
509
+			echo wp_kses(
510
+				$form->form_open() . $form->get_html_and_js() . $form->form_close(),
511
+				AllowedTags::getWithFormTags()
512
+			);
513
+		} else {
514
+			echo wp_kses(
515
+				$this->_activate_payment_method_button($payment_method)->get_html_and_js(),
516
+				AllowedTags::getWithFormTags()
517
+			);
518
+		}
519
+	}
520
+
521
+
522
+	/**
523
+	 * Gets the form for all the settings related to this payment method type
524
+	 *
525
+	 * @access protected
526
+	 * @param EE_Payment_Method|null $payment_method
527
+	 * @return EE_Form_Section_Proper
528
+	 * @throws EE_Error
529
+	 * @throws ReflectionException
530
+	 */
531
+	protected function _generate_payment_method_settings_form(
532
+		?EE_Payment_Method $payment_method
533
+	): EE_Form_Section_Proper {
534
+		if (! $payment_method instanceof EE_Payment_Method) {
535
+			return new EE_Form_Section_Proper();
536
+		}
537
+		$subsections = apply_filters(
538
+			'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
539
+			[
540
+				'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
541
+				'currency_support'        => $this->_currency_support($payment_method),
542
+				'payment_method_settings' => $this->_payment_method_settings($payment_method),
543
+				'update'                  => $this->_update_payment_method_button($payment_method),
544
+				'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
545
+				'fine_print'              => $this->_fine_print(),
546
+			],
547
+			$payment_method
548
+		);
549
+		return new EE_Form_Section_Proper(
550
+			[
551
+				'name'            => $payment_method->slug() . '_settings_form',
552
+				'html_id'         => $payment_method->slug() . '_settings_form',
553
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
554
+					[
555
+						'action'         => 'update_payment_method',
556
+						'payment_method' => $payment_method->slug(),
557
+					],
558
+					EE_PAYMENTS_ADMIN_URL
559
+				),
560
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
561
+				'subsections'     => array_filter($subsections),
562
+			]
563
+		);
564
+	}
565
+
566
+
567
+	/**
568
+	 * _pci_dss_compliance
569
+	 *
570
+	 * @access protected
571
+	 * @param EE_Payment_Method $payment_method
572
+	 * @return EE_Form_Section_HTML|null
573
+	 * @throws EE_Error
574
+	 */
575
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
576
+	{
577
+		if (! $payment_method->type_obj()->requires_https()) {
578
+			return null;
579
+		}
580
+		return new EE_Form_Section_HTML(
581
+			EEH_HTML::tr(
582
+				EEH_HTML::th(
583
+					EEH_HTML::label(
584
+						EEH_HTML::strong(
585
+							esc_html__('IMPORTANT', 'event_espresso'),
586
+							'',
587
+							'important-notice'
588
+						)
589
+					)
590
+				) .
591
+				EEH_HTML::td(
592
+					EEH_HTML::div(
593
+						EEH_HTML::strong(
594
+							esc_html__(
595
+								'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
596
+								'event_espresso'
597
+							)
598
+						),
599
+						'',
600
+						'ee-status-outline ee-status-bg--warning'
601
+					)
602
+					. EEH_HTML::br()
603
+
604
+					. EEH_HTML::div(
605
+						esc_html__('Learn more about ', 'event_espresso')
606
+						. EEH_HTML::link(
607
+							'https://www.pcisecuritystandards.org/merchants/index.php',
608
+							esc_html__('PCI DSS compliance', 'event_espresso')
609
+						),
610
+						'',
611
+						'ee-status-outline ee-status-bg--info'
612
+					)
613
+				)
614
+			)
615
+		);
616
+	}
617
+
618
+
619
+	/**
620
+	 * _currency_support
621
+	 *
622
+	 * @access protected
623
+	 * @param EE_Payment_Method $payment_method
624
+	 * @return EE_Form_Section_HTML|null
625
+	 * @throws EE_Error
626
+	 */
627
+	protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
628
+	{
629
+		if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
630
+			return null;
631
+		}
632
+		return new EE_Form_Section_HTML(
633
+			EEH_HTML::tr(
634
+				EEH_HTML::th(
635
+					EEH_HTML::label(
636
+						EEH_HTML::strong(
637
+							esc_html__('IMPORTANT', 'event_espresso'),
638
+							'',
639
+							'important-notice'
640
+						)
641
+					)
642
+				) .
643
+				EEH_HTML::td(
644
+					EEH_HTML::div(
645
+						EEH_HTML::strong(
646
+							sprintf(
647
+								esc_html__(
648
+									'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
649
+									'event_espresso'
650
+								),
651
+								EE_Config::instance()->currency->code
652
+							)
653
+						),
654
+						'',
655
+						'ee-status-outline ee-status-bg--warning'
656
+					)
657
+				)
658
+			)
659
+		);
660
+	}
661
+
662
+
663
+	/**
664
+	 * _update_payment_method_button
665
+	 *
666
+	 * @access protected
667
+	 * @param EE_Payment_Method $payment_method
668
+	 * @return EE_Payment_Method_Form
669
+	 * @throws EE_Error
670
+	 * @throws ReflectionException
671
+	 */
672
+	protected function _payment_method_settings(EE_Payment_Method $payment_method): EE_Payment_Method_Form
673
+	{
674
+		// modify the form, so we only have/show fields that will be implemented for this version
675
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
676
+	}
677
+
678
+
679
+	/**
680
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
681
+	 *
682
+	 * @param EE_Form_Section_Proper $form_section
683
+	 * @param string                 $payment_method_name
684
+	 * @return EE_Payment_Method_Form
685
+	 * @throws EE_Error
686
+	 */
687
+	protected function _simplify_form(
688
+		EE_Form_Section_Proper $form_section,
689
+		string $payment_method_name = ''
690
+	): EE_Payment_Method_Form {
691
+		if ($form_section instanceof EE_Payment_Method_Form) {
692
+			$form_section->exclude(
693
+				[
694
+					'PMD_type', // don't want them changing the type
695
+					'PMD_slug', // or the slug (probably never)
696
+					'PMD_wp_user', // or the user's ID
697
+					'Currency', // or the currency, until the rest of EE supports simultaneous currencies
698
+				]
699
+			);
700
+			return $form_section;
701
+		}
702
+		throw new EE_Error(
703
+			sprintf(
704
+				esc_html__(
705
+					'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
706
+					'event_espresso'
707
+				),
708
+				$payment_method_name
709
+			)
710
+		);
711
+	}
712
+
713
+
714
+	/**
715
+	 * _update_payment_method_button
716
+	 *
717
+	 * @access protected
718
+	 * @param EE_Payment_Method $payment_method
719
+	 * @return EE_Form_Section_HTML
720
+	 * @throws EE_Error
721
+	 */
722
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_HTML
723
+	{
724
+		$update_button = new EE_Submit_Input(
725
+			[
726
+				'name'       => 'submit',
727
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
728
+				'default'    => sprintf(
729
+					esc_html__('Update %s Payment Settings', 'event_espresso'),
730
+					$payment_method->admin_name()
731
+				),
732
+				'html_label' => EEH_HTML::nbsp(),
733
+			]
734
+		);
735
+		return new EE_Form_Section_HTML(
736
+			EEH_HTML::tr(
737
+				EEH_HTML::th(
738
+				// esc_html__('Update Settings', 'event_espresso'),
739
+					'&nbsp;',
740
+					'',
741
+					'ee-update-' . $payment_method->slug() . '-settings__label'
742
+				) .
743
+				EEH_HTML::td(
744
+					$update_button->get_html_for_input(),
745
+					'',
746
+					'ee-update-' . $payment_method->slug() . '-settings__input'
747
+				),
748
+				'',
749
+				'ee-update-' . $payment_method->slug() . '-settings'
750
+			)
751
+		);
752
+	}
753
+
754
+
755
+	/**
756
+	 * _deactivate_payment_method_button
757
+	 *
758
+	 * @access protected
759
+	 * @param EE_Payment_Method $payment_method
760
+	 * @return EE_Form_Section_HTML
761
+	 */
762
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_HTML
763
+	{
764
+		$link_text_and_title = sprintf(
765
+			esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
766
+			$payment_method->admin_name()
767
+		);
768
+		return new EE_Form_Section_HTML(
769
+			EEH_HTML::tr(
770
+				EEH_HTML::th(
771
+				// esc_html__('Deactivate Payment Method', 'event_espresso'),
772
+					'&nbsp;',
773
+					'',
774
+					'ee-deactivate-' . $payment_method->slug() . '-settings__label'
775
+				) .
776
+				EEH_HTML::td(
777
+					EEH_HTML::link(
778
+						EE_Admin_Page::add_query_args_and_nonce(
779
+							[
780
+								'action'         => 'deactivate_payment_method',
781
+								'payment_method' => $payment_method->slug(),
782
+							],
783
+							EE_PAYMENTS_ADMIN_URL
784
+						),
785
+						$link_text_and_title,
786
+						$link_text_and_title,
787
+						'deactivate_' . $payment_method->slug(),
788
+						'button button--secondary'
789
+					),
790
+					'',
791
+					'ee-deactivate-' . $payment_method->slug() . '-settings__input'
792
+				),
793
+				'',
794
+				'ee-deactivate-' . $payment_method->slug() . '-settings'
795
+			)
796
+		);
797
+	}
798
+
799
+
800
+	/**
801
+	 * _activate_payment_method_button
802
+	 *
803
+	 * @access protected
804
+	 * @param EE_Payment_Method $payment_method
805
+	 * @return EE_Form_Section_Proper
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method): EE_Form_Section_Proper
809
+	{
810
+		$link_text_and_title = sprintf(
811
+			esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
812
+			$payment_method->admin_name()
813
+		);
814
+		return new EE_Form_Section_Proper(
815
+			[
816
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
817
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
818
+				'action'          => '#',
819
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
820
+				'subsections'     => apply_filters(
821
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
822
+					[
823
+						new EE_Form_Section_HTML(
824
+							EEH_HTML::table(
825
+								EEH_HTML::tr(
826
+									EEH_HTML::td(
827
+										$payment_method->type_obj()->introductory_html(),
828
+										'',
829
+										'',
830
+										'',
831
+										'colspan="2"'
832
+									)
833
+								) .
834
+								EEH_HTML::tr(
835
+									EEH_HTML::th(
836
+										EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
837
+									) .
838
+									EEH_HTML::td(
839
+										EEH_HTML::link(
840
+											EE_Admin_Page::add_query_args_and_nonce(
841
+												[
842
+													'action'              => 'activate_payment_method',
843
+													'payment_method_type' => $payment_method->type(),
844
+												],
845
+												EE_PAYMENTS_ADMIN_URL
846
+											),
847
+											$link_text_and_title,
848
+											$link_text_and_title,
849
+											'activate_' . $payment_method->slug(),
850
+											'button button--primary-alt'
851
+										)
852
+									)
853
+								)
854
+							)
855
+						),
856
+					],
857
+					$payment_method
858
+				),
859
+			]
860
+		);
861
+	}
862
+
863
+
864
+	/**
865
+	 * _fine_print
866
+	 *
867
+	 * @access protected
868
+	 * @return EE_Form_Section_HTML
869
+	 */
870
+	protected function _fine_print(): EE_Form_Section_HTML
871
+	{
872
+		return new EE_Form_Section_HTML(
873
+			EEH_HTML::tr(
874
+				EEH_HTML::th()
875
+				. EEH_HTML::thx()
876
+				. EEH_HTML::td(
877
+					EEH_HTML::p(
878
+						esc_html__('All fields marked with a * are required fields', 'event_espresso'),
879
+						'',
880
+						'grey-text'
881
+					)
882
+				)
883
+			)
884
+		);
885
+	}
886
+
887
+
888
+	/**
889
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
890
+	 *
891
+	 * @throws EE_Error
892
+	 * @throws ReflectionException
893
+	 * @global WP_User $current_user
894
+	 */
895
+	protected function _activate_payment_method()
896
+	{
897
+		if (isset($this->_req_data['payment_method_type'])) {
898
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
899
+			// see if one exists
900
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
901
+			$payment_method = EE_Payment_Method_Manager::instance()
902
+													   ->activate_a_payment_method_of_type($payment_method_type);
903
+			$this->_redirect_after_action(
904
+				1,
905
+				'Payment Method',
906
+				'activated',
907
+				['action' => 'default', 'payment_method' => $payment_method->slug()]
908
+			);
909
+		} else {
910
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', ['action' => 'default']);
911
+		}
912
+	}
913
+
914
+
915
+	/**
916
+	 * @throws EE_Error
917
+	 * @throws ReflectionException
918
+	 */
919
+	protected function _deactivate_payment_method()
920
+	{
921
+		if (isset($this->_req_data['payment_method'])) {
922
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
923
+			// deactivate it
924
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
925
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
926
+			$this->_redirect_after_action(
927
+				$count_updated,
928
+				'Payment Method',
929
+				'deactivated',
930
+				['action' => 'default', 'payment_method' => $payment_method_slug]
931
+			);
932
+		} else {
933
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', ['action' => 'default']);
934
+		}
935
+	}
936
+
937
+
938
+	/**
939
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
940
+	 * processing because we first need to identify WHICH form was processed and which payment method
941
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
942
+	 * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
943
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
944
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
945
+	 *
946
+	 * @return void
947
+	 * @throws EE_Error
948
+	 * @throws ReflectionException
949
+	 */
950
+	protected function _update_payment_method()
951
+	{
952
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
953
+			// ok let's find which gateway form to use based on the form input
954
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
955
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
956
+			$correct_pmt_form_to_use = null;
957
+			$payment_method          = null;
958
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
959
+				if ($payment_method instanceof EE_Payment_Method) {
960
+					// get the form and simplify it, like what we do when we display it
961
+					$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
962
+					if ($pmt_form->form_data_present_in($this->_req_data)) {
963
+						$correct_pmt_form_to_use = $pmt_form;
964
+						break;
965
+					}
966
+				}
967
+			}
968
+			// if we couldn't find the correct payment method type...
969
+			if (! $correct_pmt_form_to_use) {
970
+				EE_Error::add_error(
971
+					esc_html__(
972
+						"We could not find which payment method type your form submission related to. Please contact support",
973
+						'event_espresso'
974
+					),
975
+					__FILE__,
976
+					__FUNCTION__,
977
+					__LINE__
978
+				);
979
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', ['action' => 'default']);
980
+			}
981
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
982
+			if ($correct_pmt_form_to_use->is_valid()) {
983
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
984
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
985
+					throw new EE_Error(
986
+						sprintf(
987
+							esc_html__(
988
+								'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
989
+								'event_espresso'
990
+							),
991
+							'payment_method_settings'
992
+						)
993
+					);
994
+				}
995
+				$payment_settings_subform->save();
996
+				/** @var $pm EE_Payment_Method */
997
+				$this->_redirect_after_action(
998
+					true,
999
+					'Payment Method',
1000
+					'updated',
1001
+					['action' => 'default', 'payment_method' => $payment_method->slug()]
1002
+				);
1003
+			} else {
1004
+				EE_Error::add_error(
1005
+					sprintf(
1006
+						esc_html__(
1007
+							'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
1008
+							'event_espresso'
1009
+						),
1010
+						$payment_method instanceof EE_Payment_Method
1011
+							? $payment_method->type_obj()->pretty_name()
1012
+							: esc_html__('"(unknown)"', 'event_espresso')
1013
+					),
1014
+					__FILE__,
1015
+					__FUNCTION__,
1016
+					__LINE__
1017
+				);
1018
+			}
1019
+		}
1020
+	}
1021
+
1022
+
1023
+	/**
1024
+	 * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
1025
+	 *
1026
+	 * @throws DomainException
1027
+	 * @throws EE_Error
1028
+	 * @throws InvalidArgumentException
1029
+	 * @throws InvalidDataTypeException
1030
+	 * @throws InvalidInterfaceException
1031
+	 */
1032
+	protected function _payment_settings()
1033
+	{
1034
+		$form = $this->getPaymentSettingsForm();
1035
+		$this->_set_add_edit_form_tags('update_payment_settings');
1036
+		$this->_set_publish_post_box_vars();
1037
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1038
+			$form->get_html_and_js(),
1039
+			'',
1040
+			'padding'
1041
+		);
1042
+		$this->display_admin_page_with_sidebar();
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 *        _update_payment_settings
1048
+	 *
1049
+	 * @access protected
1050
+	 * @return void
1051
+	 * @throws EE_Error
1052
+	 * @throws InvalidArgumentException
1053
+	 * @throws InvalidDataTypeException
1054
+	 * @throws InvalidInterfaceException
1055
+	 */
1056
+	protected function _update_payment_settings()
1057
+	{
1058
+		$form = $this->getPaymentSettingsForm();
1059
+		if ($form->was_submitted($this->_req_data)) {
1060
+			$form->receive_form_submission($this->_req_data);
1061
+			if ($form->is_valid()) {
1062
+				/**
1063
+				 * @var $reg_config EE_Registration_Config
1064
+				 */
1065
+				$loader                                   = LoaderFactory::getLoader();
1066
+				$reg_config                               = $loader->getShared('EE_Registration_Config');
1067
+				$valid_data                               = $form->valid_data();
1068
+				$show_pending_payment_options             = $valid_data['show_pending_payment_options'] ?? null;
1069
+				$reg_config->show_pending_payment_options = $show_pending_payment_options === 'ON';
1070
+				$reg_config->gateway_log_lifespan         = $valid_data['gateway_log_lifespan'];
1071
+			}
1072
+		}
1073
+		EE_Registry::instance()->CFG = apply_filters(
1074
+			'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
1075
+			EE_Registry::instance()->CFG
1076
+		);
1077
+
1078
+		$what    = esc_html__('Payment Settings', 'event_espresso');
1079
+		$success = $this->_update_espresso_configuration(
1080
+			$what,
1081
+			EE_Registry::instance()->CFG,
1082
+			__FILE__,
1083
+			__FUNCTION__,
1084
+			__LINE__
1085
+		);
1086
+		$this->_redirect_after_action(
1087
+			$success,
1088
+			$what,
1089
+			esc_html__('updated', 'event_espresso'),
1090
+			['action' => 'payment_settings']
1091
+		);
1092
+	}
1093
+
1094
+
1095
+	/**
1096
+	 * Gets the form used for updating payment settings
1097
+	 *
1098
+	 * @return EE_Form_Section_Proper
1099
+	 * @throws EE_Error
1100
+	 * @throws InvalidArgumentException
1101
+	 * @throws InvalidDataTypeException
1102
+	 * @throws InvalidInterfaceException
1103
+	 */
1104
+	protected function getPaymentSettingsForm(): EE_Form_Section_Proper
1105
+	{
1106
+		/**
1107
+		 * @var $reg_config EE_Registration_Config
1108
+		 */
1109
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1110
+		return new EE_Form_Section_Proper(
1111
+			[
1112
+				'name'            => 'payment-settings',
1113
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1114
+				'subsections'     => [
1115
+					'show_pending_payment_options' => new EE_Switch_Input(
1116
+						[
1117
+							'default'        => $reg_config->show_pending_payment_options
1118
+								? EE_Switch_Input::OPTION_ON
1119
+								: EE_Switch_Input::OPTION_OFF,
1120
+							'html_name'      => 'show_pending_payment_options',
1121
+							'html_help_text' => esc_html__(
1122
+								"If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1123
+								'event_espresso'
1124
+							),
1125
+						],
1126
+						[
1127
+							EE_Switch_Input::OPTION_OFF => esc_html__(
1128
+								'pending payment options are NOT displayed',
1129
+								'event_espresso'
1130
+							),
1131
+							EE_Switch_Input::OPTION_ON  => esc_html__(
1132
+								'pending payment options are displayed',
1133
+								'event_espresso'
1134
+							),
1135
+						]
1136
+					),
1137
+					'gateway_log_lifespan'         => new EE_Select_Input(
1138
+						$reg_config->gatewayLogLifespanOptions(),
1139
+						[
1140
+							'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1141
+							'html_help_text'  => esc_html__(
1142
+								'If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.',
1143
+								'event_espresso'
1144
+							),
1145
+							'default'         => $reg_config->gateway_log_lifespan,
1146
+						]
1147
+					),
1148
+				],
1149
+			]
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * @throws EE_Error
1156
+	 */
1157
+	protected function _payment_log_overview_list_table()
1158
+	{
1159
+		$this->display_admin_list_table_page_with_sidebar();
1160
+	}
1161
+
1162
+
1163
+	protected function _set_list_table_views_payment_log()
1164
+	{
1165
+		$this->_views = [
1166
+			'all' => [
1167
+				'slug'  => 'all',
1168
+				'label' => esc_html__('View All Logs', 'event_espresso'),
1169
+				'count' => 0,
1170
+			],
1171
+		];
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * @param int  $per_page
1177
+	 * @param int  $current_page
1178
+	 * @param bool $count
1179
+	 * @return array|int
1180
+	 * @throws EE_Error
1181
+	 * @throws ReflectionException
1182
+	 */
1183
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1184
+	{
1185
+		EE_Registry::instance()->load_model('Change_Log');
1186
+		// we may need to do multiple queries (joining differently), so we actually want an array of query params
1187
+		$query_params = [['LOG_type' => EEM_Change_Log::type_gateway]];
1188
+		// check if they've selected a specific payment method
1189
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1190
+			$query_params[0]['OR*pm_or_pay_pm'] = [
1191
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1192
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1193
+			];
1194
+		}
1195
+		// take into account search
1196
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1197
+			$similarity_string                                                              =
1198
+				['LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'];
1199
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1200
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1201
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1202
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name']                     = $similarity_string;
1203
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name']               = $similarity_string;
1204
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type']                     = $similarity_string;
1205
+			$query_params[0]['OR*s']['Payment_Method.PMD_name']                             = $similarity_string;
1206
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name']                       = $similarity_string;
1207
+			$query_params[0]['OR*s']['Payment_Method.PMD_type']                             = $similarity_string;
1208
+			$query_params[0]['OR*s']['LOG_message']                                         = $similarity_string;
1209
+		}
1210
+		if (
1211
+			isset($this->_req_data['payment-filter-start-date'])
1212
+			&& isset($this->_req_data['payment-filter-end-date'])
1213
+		) {
1214
+			// add date
1215
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1216
+			$end_date   = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1217
+			// make sure our timestamps start and end right at the boundaries for each day
1218
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1219
+			$end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1220
+			// convert to timestamps
1221
+			$start_date = strtotime($start_date);
1222
+			$end_date   = strtotime($end_date);
1223
+			// makes sure start date is the lowest value and vice versa
1224
+			$start_date = min($start_date, $end_date);
1225
+			$end_date   = max($start_date, $end_date);
1226
+			// convert for query
1227
+			$start_date                  = EEM_Change_Log::instance()->convert_datetime_for_query(
1228
+				'LOG_time',
1229
+				date('Y-m-d H:i:s', $start_date),
1230
+				'Y-m-d H:i:s'
1231
+			);
1232
+			$end_date                    = EEM_Change_Log::instance()->convert_datetime_for_query(
1233
+				'LOG_time',
1234
+				date('Y-m-d H:i:s', $end_date),
1235
+				'Y-m-d H:i:s'
1236
+			);
1237
+			$query_params[0]['LOG_time'] = ['BETWEEN', [$start_date, $end_date]];
1238
+		}
1239
+		if ($count) {
1240
+			return EEM_Change_Log::instance()->count($query_params);
1241
+		}
1242
+		if (isset($this->_req_data['order'])) {
1243
+			$sort                     = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1244
+				? $this->_req_data['order']
1245
+				: 'DESC';
1246
+			$query_params['order_by'] = ['LOG_time' => $sort];
1247
+		} else {
1248
+			$query_params['order_by'] = ['LOG_time' => 'DESC'];
1249
+		}
1250
+		$offset = ($current_page - 1) * $per_page;
1251
+		if (! isset($this->_req_data['download_results'])) {
1252
+			$query_params['limit'] = [$offset, $per_page];
1253
+		}
1254
+		// now they've requested to instead just download the file instead of viewing it.
1255
+		if (isset($this->_req_data['download_results'])) {
1256
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1257
+			header('Content-Disposition: attachment');
1258
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1259
+			echo '<h1> '
1260
+				 . sprintf(
1261
+					 esc_html__('Payment Logs for %1$s', 'event_espresso'),
1262
+					 esc_url_raw(site_url())
1263
+				 )
1264
+				 . '</h1 >';
1265
+			echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1266
+			echo esc_html(var_export($query_params, true));
1267
+			echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1268
+			echo esc_html(var_export($wpdb_results, true));
1269
+			die;
1270
+		}
1271
+		return EEM_Change_Log::instance()->get_all($query_params);
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1277
+	 * because we're possibly combining the results from two queries
1278
+	 *
1279
+	 * @param EE_Change_Log $logA
1280
+	 * @param EE_Change_Log $logB
1281
+	 * @return int
1282
+	 * @throws EE_Error
1283
+	 * @throws ReflectionException
1284
+	 */
1285
+	protected function _sort_logs_again($logA, $logB)
1286
+	{
1287
+		$timeA = $logA->get_raw('LOG_time');
1288
+		$timeB = $logB->get_raw('LOG_time');
1289
+		if ($timeA == $timeB) {
1290
+			return 0;
1291
+		}
1292
+		$comparison = $timeA < $timeB
1293
+			? -1
1294
+			: 1;
1295
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1296
+			return $comparison * -1;
1297
+		}
1298
+		return $comparison;
1299
+	}
1300
+
1301
+
1302
+	/**
1303
+	 * @throws EE_Error
1304
+	 * @throws ReflectionException
1305
+	 */
1306
+	protected function _payment_log_details()
1307
+	{
1308
+		EE_Registry::instance()->load_model('Change_Log');
1309
+		/** @var $payment_log EE_Change_Log */
1310
+		$payment_log    = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1311
+		$payment_method = null;
1312
+		$transaction    = null;
1313
+		if ($payment_log instanceof EE_Change_Log) {
1314
+			if ($payment_log->object() instanceof EE_Payment) {
1315
+				$payment_method = $payment_log->object()->payment_method();
1316
+				$transaction    = $payment_log->object()->transaction();
1317
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1318
+				$payment_method = $payment_log->object();
1319
+			} elseif ($payment_log->object() instanceof EE_Transaction) {
1320
+				$transaction    = $payment_log->object();
1321
+				$payment_method = $transaction->payment_method();
1322
+			}
1323
+		}
1324
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1325
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1326
+			[
1327
+				'payment_log'    => $payment_log,
1328
+				'payment_method' => $payment_method,
1329
+				'transaction'    => $transaction,
1330
+			],
1331
+			true
1332
+		);
1333
+		$this->display_admin_page_with_no_sidebar();
1334
+	}
1335 1335
 }
Please login to merge, or discard this patch.
admin_pages/maintenance/templates/ee_migration_page.template.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -36,55 +36,55 @@  discard block
 block discarded – undo
36 36
             <h3 class="espresso-header ee-status-bg--info">
37 37
                 <span class="dashicons dashicons-flag ee-icon-size-22"></span>
38 38
                 <?php
39
-                echo esc_html(
40
-                    apply_filters(
41
-                        'FHEE__ee_migration_page__header',
42
-                        sprintf(
43
-                            __("Your Event Espresso data needs to be updated.", "event_espresso"),
44
-                            $current_db_state,
45
-                            $next_db_state
46
-                        ),
47
-                        $current_db_state,
48
-                        $next_db_state
49
-                    )
50
-                );
51
-                ?>
39
+				echo esc_html(
40
+					apply_filters(
41
+						'FHEE__ee_migration_page__header',
42
+						sprintf(
43
+							__("Your Event Espresso data needs to be updated.", "event_espresso"),
44
+							$current_db_state,
45
+							$next_db_state
46
+						),
47
+						$current_db_state,
48
+						$next_db_state
49
+					)
50
+				);
51
+				?>
52 52
             </h3>
53 53
         <?php } elseif ($show_most_recent_migration) { ?>
54 54
             <h3 class="espresso-header ee-status-bg--info">
55 55
                 <span class="dashicons dashicons-awards ee-icon-size-22"></span>
56 56
                 <?php echo esc_html(
57
-                    apply_filters(
58
-                        'FHEE__ee_migration_page__done_migration_header',
59
-                        sprintf(
60
-                            __(
61
-                                'Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
62
-                                "event_espresso"
63
-                            ),
64
-                            $ultimate_db_state
65
-                        )
66
-                    )
67
-                ); ?>
57
+					apply_filters(
58
+						'FHEE__ee_migration_page__done_migration_header',
59
+						sprintf(
60
+							__(
61
+								'Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
62
+								"event_espresso"
63
+							),
64
+							$ultimate_db_state
65
+						)
66
+					)
67
+				); ?>
68 68
             </h3>
69 69
             <p>
70 70
                 <?php echo esc_html(
71
-                    apply_filters(
72
-                        'FHEE__ee_migration_page__p_after_done_migration_header',
73
-                        sprintf(
74
-                            __(
75
-                                "Time to find out about all the great new features %s has to offer.",
76
-                                "event_espresso"
77
-                            ),
78
-                            $ultimate_db_state
79
-                        )
80
-                    )
81
-                ); ?> &nbsp;
71
+					apply_filters(
72
+						'FHEE__ee_migration_page__p_after_done_migration_header',
73
+						sprintf(
74
+							__(
75
+								"Time to find out about all the great new features %s has to offer.",
76
+								"event_espresso"
77
+							),
78
+							$ultimate_db_state
79
+						)
80
+					)
81
+				); ?> &nbsp;
82 82
                 <b>
83 83
                     <a class="button--primary"
84 84
                        id='get-started-after-migrate'
85 85
                        href="<?php
86
-                        echo esc_url_raw(add_query_arg(['page' => 'espresso_about'], admin_url('admin.php')));
87
-                        ?>"
86
+						echo esc_url_raw(add_query_arg(['page' => 'espresso_about'], admin_url('admin.php')));
87
+						?>"
88 88
                     >
89 89
                         <?php esc_html_e("Let's Get Started", "event_espresso"); ?>&nbsp;
90 90
                         <span class="dashicons dashicons-arrow-right ee-icon-size-22" style="margin:0;"></span>
@@ -95,46 +95,46 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
         <?php
98
-        if ($show_backup_db_text) {
99
-            echo wp_kses($migration_options_html, AllowedTags::getAllowedTags());
100
-        } ?>
98
+		if ($show_backup_db_text) {
99
+			echo wp_kses($migration_options_html, AllowedTags::getAllowedTags());
100
+		} ?>
101 101
 
102 102
         <?php
103
-        if ($show_most_recent_migration) {
104
-            if ($most_recent_migration instanceof EE_Data_Migration_Script_Base) {
105
-                if ($most_recent_migration->can_continue()) {
106
-                    // tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
103
+		if ($show_most_recent_migration) {
104
+			if ($most_recent_migration instanceof EE_Data_Migration_Script_Base) {
105
+				if ($most_recent_migration->can_continue()) {
106
+					// tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
107 107
                     <h3 class="espresso-header ee-status-bg--info">
108 108
                         <span class="dashicons dashicons-star-half ee-icon-size-22"></span>
109 109
                         <?php printf(
110
-                            esc_html__(
111
-                                "It appears that your previous Database Update (%s) is incomplete, and should be resumed",
112
-                                "event_espresso"
113
-                            ),
114
-                            $most_recent_migration->pretty_name()
115
-                        ); ?>
110
+							esc_html__(
111
+								"It appears that your previous Database Update (%s) is incomplete, and should be resumed",
112
+								"event_espresso"
113
+							),
114
+							$most_recent_migration->pretty_name()
115
+						); ?>
116 116
                     </h3>
117 117
                     <?php
118
-                } elseif ($most_recent_migration->is_broken()) {
119
-                    // tell the user the migration failed, and they should notify EE?>
118
+				} elseif ($most_recent_migration->is_broken()) {
119
+					// tell the user the migration failed, and they should notify EE?>
120 120
                     <h3 class="espresso-header ee-status-bg--info">
121 121
                         <span class="dashicons dashicons-no ee-icon-size-22"></span>
122 122
                         <?php echo esc_html($most_recent_migration->get_feedback_message()) ?>
123 123
                     </h3>
124 124
                     <?php
125
-                }
126
-                // display errors or not of the most recent migration ran
127
-                if ($most_recent_migration->get_errors()) {
128
-                    ?>
125
+				}
126
+				// display errors or not of the most recent migration ran
127
+				if ($most_recent_migration->get_errors()) {
128
+					?>
129 129
                     <div class="ee-attention">
130 130
                         <strong>
131 131
                             <?php printf(
132
-                                esc_html__(
133
-                                    "Warnings occurred during your last Database Update (%s):",
134
-                                    'event_espresso'
135
-                                ),
136
-                                $most_recent_migration->pretty_name()
137
-                            ); ?>
132
+								esc_html__(
133
+									"Warnings occurred during your last Database Update (%s):",
134
+									'event_espresso'
135
+								),
136
+								$most_recent_migration->pretty_name()
137
+							); ?>
138 138
                         </strong>
139 139
                         <a id="show-hide-migration-warnings" class="display-the-hidden">
140 140
                             <?php esc_html_e("Show Warnings", 'event_espresso'); ?>
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
                         </ul>
147 147
                     </div>
148 148
                     <?php
149
-                } else {
150
-                    // there were no errors during the last migration, just say so?>
149
+				} else {
150
+					// there were no errors during the last migration, just say so?>
151 151
                     <h2>
152 152
                         <?php printf(
153
-                            esc_html__(
154
-                                "The last Database Update (%s) ran successfully without errors.",
155
-                                "event_espresso"
156
-                            ),
157
-                            $most_recent_migration->pretty_name()
158
-                        ); ?>
153
+							esc_html__(
154
+								"The last Database Update (%s) ran successfully without errors.",
155
+								"event_espresso"
156
+							),
157
+							$most_recent_migration->pretty_name()
158
+						); ?>
159 159
                     </h2>
160 160
                     <?php
161
-                }
162
-            }
163
-        }
164
-        // end of: if ( $show_most_recent_migration )
165
-        ?>
161
+				}
162
+			}
163
+		}
164
+		// end of: if ( $show_most_recent_migration )
165
+		?>
166 166
 
167 167
     </div>
168 168
     <!--end of #migration-prep-->
169 169
 
170 170
     <?php
171
-    if ($show_migration_progress) { ?>
171
+	if ($show_migration_progress) { ?>
172 172
         <div id='migration-monitor' <?php if ($show_backup_db_text) :
173
-            ?>style="display:none"<?php
174
-                                    endif; ?>>
173
+			?>style="display:none"<?php
174
+									endif; ?>>
175 175
             <?php if ($show_backup_db_text) { ?>
176 176
                 <p>
177 177
                     <a class="toggle-migration-monitor small-text" style="cursor: pointer;">
@@ -182,19 +182,19 @@  discard block
 block discarded – undo
182 182
 
183 183
                 </p>
184 184
                 <?php
185
-            } ?>
185
+			} ?>
186 186
             <div id='progress-area'>
187 187
                 <h3 class="espresso-header ee-status-bg--info">
188 188
                     <?php
189
-                    echo sprintf(
190
-                        _n(
191
-                            "The following task needs to be performed:",
192
-                            "The following %s tasks need to be performed:",
193
-                            count($script_names),
194
-                            "event_espresso"
195
-                        ),
196
-                        count($script_names)
197
-                    ); ?>
189
+					echo sprintf(
190
+						_n(
191
+							"The following task needs to be performed:",
192
+							"The following %s tasks need to be performed:",
193
+							count($script_names),
194
+							"event_espresso"
195
+						),
196
+						count($script_names)
197
+					); ?>
198 198
                 </h3>
199 199
                 <ul style="list-style: inside;">
200 200
                     <?php foreach ($script_names as $script_name) { ?>
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
                 <?php if (count($script_names) > 1) { ?>
206 206
                     <p>
207 207
                         <?php esc_html_e(
208
-                            "Please note: after each task is completed you will need to continue the Database Update, or report an error to Event Espresso.",
209
-                            "event_espresso"
210
-                        ); ?>
208
+							"Please note: after each task is completed you will need to continue the Database Update, or report an error to Event Espresso.",
209
+							"event_espresso"
210
+						); ?>
211 211
                     </p>
212 212
                 <?php } ?>
213 213
 
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
                         </span>
219 219
                         <br />
220 220
                         <?php esc_html_e(
221
-                            "Depending on the number of events and the complexity of the information in your database, this could take a few minutes.",
222
-                            "event_espresso"
223
-                        ); ?>
221
+							"Depending on the number of events and the complexity of the information in your database, this could take a few minutes.",
222
+							"event_espresso"
223
+						); ?>
224 224
                     </p>
225 225
                     <p>
226 226
                         <?php printf(
227
-                            esc_html__(
228
-                                "%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.",
229
-                                "event_espresso"
230
-                            ),
231
-                            '<strong>',
232
-                            '</strong>'
233
-                        ); ?>
227
+							esc_html__(
228
+								"%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.",
229
+								"event_espresso"
230
+							),
231
+							'<strong>',
232
+							'</strong>'
233
+						); ?>
234 234
                     </p>
235 235
                     <p>
236 236
                         <?php esc_html_e("Click the button below to begin the migration process.", "event_espresso") ?>
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 
247 247
                 <button id='start-migration' class='button button--primary'>
248 248
                     <?php echo esc_html(
249
-                        $show_continue_current_migration_script
250
-                            ? __("Continue Database Update", "event_espresso")
251
-                            : __("Begin Database Update", "event_espresso")
252
-                    ); ?>
249
+						$show_continue_current_migration_script
250
+							? __("Continue Database Update", "event_espresso")
251
+							: __("Begin Database Update", "event_espresso")
252
+					); ?>
253 253
                 </button>
254 254
                 <br class="clear" />
255 255
 
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
         </div>
266 266
 
267 267
         <?php
268
-    }
269
-    if ($show_maintenance_switch) {
270
-        ?>
268
+	}
269
+	if ($show_maintenance_switch) {
270
+		?>
271 271
         <h2>
272 272
             <span class="dashicons dashicons-admin-tools"></span>
273 273
             <?php esc_html_e('Set Event Espresso Maintenance Mode', 'event_espresso'); ?>
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
                             </label>
291 291
                             <p class='description' style="font-weight: normal;">
292 292
                                 <?php esc_html_e(
293
-                                    "This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.",
294
-                                    "event_espresso"
295
-                                ); ?>
293
+									"This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.",
294
+									"event_espresso"
295
+								); ?>
296 296
                             </p>
297 297
                         </th>
298 298
                     </tr>
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
                             </label>
312 312
                             <p class='description' style="font-weight: normal;">
313 313
                                 <?php esc_html_e(
314
-                                    "This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.",
315
-                                    "event_espresso"
316
-                                ); ?>
314
+									"This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.",
315
+									"event_espresso"
316
+								); ?>
317 317
                             </p>
318 318
                         </th>
319 319
                     </tr>
@@ -327,6 +327,6 @@  discard block
 block discarded – undo
327 327
             </p>
328 328
         </form>
329 329
         <?php
330
-    } ?>
330
+	} ?>
331 331
 
332 332
 </div>
Please login to merge, or discard this patch.