Completed
Branch add-cap-checks-to-routes (73eed8)
by
unknown
08:17 queued 10s
created
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Indentation   +1205 added lines, -1205 removed lines patch added patch discarded remove patch
@@ -16,1209 +16,1209 @@
 block discarded – undo
16 16
  */
17 17
 class Payments_Admin_Page extends EE_Admin_Page
18 18
 {
19
-    /**
20
-     * Variables used for when we're re-sorting the logs results,
21
-     * in case we needed to do two queries, and we need to resort
22
-     *
23
-     * @var string
24
-     */
25
-    private $_sort_logs_again_direction;
26
-
27
-
28
-    /**
29
-     * @Constructor
30
-     * @access public
31
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
-     * @throws EE_Error
33
-     * @throws InvalidArgumentException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     * @throws ReflectionException
37
-     */
38
-    public function __construct($routing = true)
39
-    {
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _init_page_props()
45
-    {
46
-        $this->page_slug = EE_PAYMENTS_PG_SLUG;
47
-        $this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
-        $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
-    }
51
-
52
-
53
-    protected function _ajax_hooks()
54
-    {
55
-        // todo: all hooks for ajax goes here.
56
-    }
57
-
58
-
59
-    protected function _define_page_props()
60
-    {
61
-        $this->_admin_page_title = $this->page_label;
62
-        $this->_labels = array(
63
-            'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
-        );
65
-    }
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        /**
71
-         * note that with payment method capabilities, although we've implemented
72
-         * capability mapping which will be used for accessing payment methods owned by
73
-         * other users.  This is not fully implemented yet in the payment method ui.
74
-         * Currently, only the "plural" caps are in active use.
75
-         * When cap mapping is implemented, some routes will need to use the singular form of
76
-         * capability method and also include the $id of the payment method for the route.
77
-         **/
78
-        $this->_page_routes = array(
79
-            'default'                   => array(
80
-                'func'       => '_payment_methods_list',
81
-                'capability' => 'ee_edit_payment_methods',
82
-            ),
83
-            'payment_settings'          => array(
84
-                'func'       => '_payment_settings',
85
-                'capability' => 'ee_manage_gateways',
86
-            ),
87
-            'activate_payment_method'   => array(
88
-                'func'       => '_activate_payment_method',
89
-                'noheader'   => true,
90
-                'capability' => 'ee_edit_payment_methods',
91
-            ),
92
-            'deactivate_payment_method' => array(
93
-                'func'       => '_deactivate_payment_method',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_payment_methods',
96
-            ),
97
-            'update_payment_method'     => array(
98
-                'func'               => '_update_payment_method',
99
-                'noheader'           => true,
100
-                'headers_sent_route' => 'default',
101
-                'capability'         => 'ee_edit_payment_methods',
102
-            ),
103
-            'update_payment_settings'   => array(
104
-                'func'       => '_update_payment_settings',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_manage_gateways',
107
-            ),
108
-            'payment_log'               => array(
109
-                'func'       => '_payment_log_overview_list_table',
110
-                'capability' => 'ee_read_payment_methods',
111
-            ),
112
-            'payment_log_details'       => array(
113
-                'func'       => '_payment_log_details',
114
-                'capability' => 'ee_read_payment_methods',
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    /**
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    protected function _set_page_config()
125
-    {
126
-        $payment_method_list_config = array(
127
-            'nav'           => array(
128
-                'label' => esc_html__('Payment Methods', 'event_espresso'),
129
-                'icon' => 'dashicons-bank',
130
-                'order' => 10,
131
-            ),
132
-            'metaboxes'     => $this->_default_espresso_metaboxes,
133
-            'help_tabs'     => array_merge(
134
-                array(
135
-                    'payment_methods_overview_help_tab' => array(
136
-                        'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
-                        'filename' => 'payment_methods_overview',
138
-                    ),
139
-                ),
140
-                $this->_add_payment_method_help_tabs()
141
-            ),
142
-            'require_nonce' => false,
143
-        );
144
-        $this->_page_config = array(
145
-            'default'          => $payment_method_list_config,
146
-            'payment_settings' => array(
147
-                'nav'           => array(
148
-                    'label' => esc_html__('Settings', 'event_espresso'),
149
-                    'icon' => 'dashicons-admin-generic',
150
-                    'order' => 20,
151
-                ),
152
-                'help_tabs'     => array(
153
-                    'payment_methods_settings_help_tab' => array(
154
-                        'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
-                        'filename' => 'payment_methods_settings',
156
-                    ),
157
-                ),
158
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
-                'require_nonce' => false,
160
-            ),
161
-            'payment_log'      => array(
162
-                'nav'           => array(
163
-                    'label' => esc_html__("Logs", 'event_espresso'),
164
-                    'icon' => 'dashicons-text-page',
165
-                    'order' => 30,
166
-                ),
167
-                'list_table'    => 'Payment_Log_Admin_List_Table',
168
-                'metaboxes'     => $this->_default_espresso_metaboxes,
169
-                'require_nonce' => false,
170
-            ),
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * @return array
177
-     * @throws DomainException
178
-     * @throws EE_Error
179
-     * @throws InvalidArgumentException
180
-     * @throws InvalidDataTypeException
181
-     * @throws InvalidInterfaceException
182
-     * @throws ReflectionException
183
-     */
184
-    protected function _add_payment_method_help_tabs()
185
-    {
186
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
-        $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
-        $all_pmt_help_tabs_config = array();
189
-        foreach ($payment_method_types as $payment_method_type) {
190
-            if (
191
-                ! EE_Registry::instance()->CAP->current_user_can(
192
-                    $payment_method_type->cap_name(),
193
-                    'specific_payment_method_type_access'
194
-                )
195
-            ) {
196
-                continue;
197
-            }
198
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
-                $template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
-                $template_args['admin_page_obj'] = $this;
201
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
-                    'title'   => $config['title'],
203
-                    'content' => EEH_Template::display_template(
204
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
-                        $template_args,
206
-                        true
207
-                    ),
208
-                );
209
-            }
210
-        }
211
-        return $all_pmt_help_tabs_config;
212
-    }
213
-
214
-
215
-    // none of the below group are currently used for Gateway Settings
216
-    protected function _add_screen_options()
217
-    {
218
-    }
219
-
220
-
221
-    protected function _add_feature_pointers()
222
-    {
223
-    }
224
-
225
-
226
-    public function admin_init()
227
-    {
228
-    }
229
-
230
-
231
-    public function admin_notices()
232
-    {
233
-    }
234
-
235
-
236
-    public function admin_footer_scripts()
237
-    {
238
-    }
239
-
240
-
241
-    public function load_scripts_styles()
242
-    {
243
-        // styles
244
-        wp_enqueue_style('espresso-ui-theme');
245
-        wp_register_style(
246
-            'espresso_payments',
247
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
248
-            [],
249
-            EVENT_ESPRESSO_VERSION
250
-        );
251
-        // scripts
252
-        wp_enqueue_script('ee_admin_js');
253
-        wp_enqueue_script('ee-text-links');
254
-        wp_enqueue_script(
255
-            'espresso_payments',
256
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
257
-            ['ee-datepicker'],
258
-            EVENT_ESPRESSO_VERSION,
259
-            true
260
-        );
261
-    }
262
-
263
-
264
-    public function load_scripts_styles_default()
265
-    {
266
-        wp_enqueue_style('espresso_payments');
267
-        wp_enqueue_style('ee-text-links');
268
-    }
269
-
270
-
271
-    public function load_scripts_styles_payment_log_details()
272
-    {
273
-        wp_enqueue_style('espresso_payments');
274
-    }
275
-
276
-
277
-    /**
278
-     * @throws EE_Error
279
-     * @throws ReflectionException
280
-     */
281
-    protected function _payment_methods_list()
282
-    {
283
-        /**
284
-         * first let's ensure payment methods have been set up.
285
-         * We do this here because when people activate a payment method for the first time (as an addon),
286
-         * it may not set up its capabilities or get registered correctly due to the loading process.
287
-         * However, people MUST set up the details for the payment method,
288
-         * so it's safe to do a recheck here.
289
-         */
290
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
291
-        EEM_Payment_Method::instance()->verify_button_urls();
292
-        // set up tabs, one for each payment method type
293
-        $tabs = array();
294
-        $payment_methods = array();
295
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
296
-            // we don't want to show admin-only PMTs for now
297
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
298
-                continue;
299
-            }
300
-            // check access
301
-            if (
302
-                ! EE_Registry::instance()->CAP->current_user_can(
303
-                    $pmt_obj->cap_name(),
304
-                    'specific_payment_method_type_access'
305
-                )
306
-            ) {
307
-                continue;
308
-            }
309
-            // check for any active pms of that type
310
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
311
-            if (! $payment_method instanceof EE_Payment_Method) {
312
-                $payment_method = EE_Payment_Method::new_instance(
313
-                    array(
314
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
315
-                        'PMD_type'       => $pmt_obj->system_name(),
316
-                        'PMD_name'       => $pmt_obj->pretty_name(),
317
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
318
-                    )
319
-                );
320
-            }
321
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
322
-        }
323
-        $payment_methods = apply_filters(
324
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
325
-            $payment_methods
326
-        );
327
-        foreach ($payment_methods as $payment_method) {
328
-            if ($payment_method instanceof EE_Payment_Method) {
329
-                $this->addMetaBox(
330
-                    // html id
331
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
332
-                    // title
333
-                    sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
334
-                    // callback
335
-                    array($this, 'payment_method_settings_meta_box'),
336
-                    // post type
337
-                    null,
338
-                    // context
339
-                    'normal',
340
-                    // priority
341
-                    'default',
342
-                    // callback args
343
-                    array('payment_method' => $payment_method)
344
-                );
345
-                // setup for tabbed content
346
-                $tabs[ $payment_method->slug() ] = array(
347
-                    'label' => $payment_method->admin_name(),
348
-                    'class' => $payment_method->active() ? 'gateway-active' : '',
349
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
350
-                    'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
351
-                    'slug'  => $payment_method->slug(),
352
-                    'icon'  => $payment_method->active()
353
-                        ? '<span class="dashicons dashicons-yes-alt"></span>'
354
-                        : '<span class="dashicons dashicons-remove"></span>',
355
-                );
356
-            }
357
-        }
358
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
359
-            $tabs,
360
-            'payment_method_links',
361
-            '',
362
-            $this->_get_active_payment_method_slug()
363
-        );
364
-        $this->display_admin_page_with_sidebar();
365
-    }
366
-
367
-
368
-    /**
369
-     *   _get_active_payment_method_slug
370
-     *
371
-     * @return string
372
-     * @throws EE_Error
373
-     */
374
-    protected function _get_active_payment_method_slug()
375
-    {
376
-        $payment_method_slug = false;
377
-        // decide which payment method tab to open first, as dictated by the request's 'payment_method'
378
-        if (isset($this->_req_data['payment_method'])) {
379
-            // if they provided the current payment method, use it
380
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
381
-        }
382
-        /** @var EE_Payment_Method $payment_method */
383
-        $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
384
-        // if that didn't work or wasn't provided, find another way to select the current pm
385
-        if (! $this->_verify_payment_method($payment_method)) {
386
-            // like, looking for an active one
387
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
388
-            // test that one as well
389
-            if ($this->_verify_payment_method($payment_method)) {
390
-                $payment_method_slug = $payment_method->slug();
391
-            } else {
392
-                $payment_method_slug = 'paypal_standard';
393
-            }
394
-        }
395
-        return $payment_method_slug;
396
-    }
397
-
398
-
399
-    /**
400
-     *    payment_method_settings_meta_box
401
-     *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
402
-     *    capabilities to access it
403
-     *
404
-     * @param EE_Payment_Method $payment_method
405
-     * @return boolean
406
-     * @throws EE_Error
407
-     */
408
-    protected function _verify_payment_method($payment_method)
409
-    {
410
-        if (
411
-            $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
412
-            && EE_Registry::instance()->CAP->current_user_can(
413
-                $payment_method->type_obj()->cap_name(),
414
-                'specific_payment_method_type_access'
415
-            )
416
-        ) {
417
-            return true;
418
-        }
419
-        return false;
420
-    }
421
-
422
-
423
-    /**
424
-     *    payment_method_settings_meta_box
425
-     *
426
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
427
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
428
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
429
-     * @return void
430
-     * @throws EE_Error
431
-     * @throws ReflectionException
432
-     */
433
-    public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
434
-    {
435
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
436
-            ? $metabox['args']['payment_method'] : null;
437
-        if (! $payment_method instanceof EE_Payment_Method) {
438
-            throw new EE_Error(
439
-                esc_html__(
440
-                    'Payment method metabox setup incorrectly. No Payment method object was supplied',
441
-                    'event_espresso'
442
-                )
443
-            );
444
-        }
445
-        $payment_method_scopes = $payment_method->active();
446
-        // if the payment method really exists show its form, otherwise the activation template
447
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
448
-            $form = $this->_generate_payment_method_settings_form($payment_method);
449
-            if ($form->form_data_present_in($this->_req_data)) {
450
-                $form->receive_form_submission($this->_req_data);
451
-            }
452
-            echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
453
-        } else {
454
-            echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
455
-        }
456
-    }
457
-
458
-
459
-    /**
460
-     * Gets the form for all the settings related to this payment method type
461
-     *
462
-     * @access protected
463
-     * @param EE_Payment_Method $payment_method
464
-     * @return EE_Form_Section_Proper
465
-     * @throws EE_Error
466
-     */
467
-    protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
468
-    {
469
-        if (! $payment_method instanceof EE_Payment_Method) {
470
-            return new EE_Form_Section_Proper();
471
-        }
472
-        return new EE_Form_Section_Proper(
473
-            array(
474
-                'name'            => $payment_method->slug() . '_settings_form',
475
-                'html_id'         => $payment_method->slug() . '_settings_form',
476
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
477
-                    array(
478
-                        'action'         => 'update_payment_method',
479
-                        'payment_method' => $payment_method->slug(),
480
-                    ),
481
-                    EE_PAYMENTS_ADMIN_URL
482
-                ),
483
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
484
-                'subsections'     => apply_filters(
485
-                    'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
486
-                    array(
487
-                        'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
488
-                        'currency_support'        => $this->_currency_support($payment_method),
489
-                        'payment_method_settings' => $this->_payment_method_settings($payment_method),
490
-                        'update'                  => $this->_update_payment_method_button($payment_method),
491
-                        'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
492
-                        'fine_print'              => $this->_fine_print(),
493
-                    ),
494
-                    $payment_method
495
-                ),
496
-            )
497
-        );
498
-    }
499
-
500
-
501
-    /**
502
-     * _pci_dss_compliance
503
-     *
504
-     * @access protected
505
-     * @param EE_Payment_Method $payment_method
506
-     * @return EE_Form_Section_HTML
507
-     * @throws EE_Error
508
-     */
509
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
510
-    {
511
-        if ($payment_method->type_obj()->requires_https()) {
512
-            return new EE_Form_Section_HTML(
513
-                EEH_HTML::table(
514
-                    EEH_HTML::tr(
515
-                        EEH_HTML::th(
516
-                            EEH_HTML::label(
517
-                                EEH_HTML::strong(
518
-                                    esc_html__('IMPORTANT', 'event_espresso'),
519
-                                    '',
520
-                                    'important-notice'
521
-                                )
522
-                            )
523
-                        ) .
524
-                        EEH_HTML::td(
525
-                            EEH_HTML::strong(
526
-                                esc_html__(
527
-                                    'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
528
-                                    'event_espresso'
529
-                                )
530
-                            )
531
-                            .
532
-                            EEH_HTML::br()
533
-                            .
534
-                            esc_html__('Learn more about ', 'event_espresso')
535
-                            . EEH_HTML::link(
536
-                                'https://www.pcisecuritystandards.org/merchants/index.php',
537
-                                esc_html__('PCI DSS compliance', 'event_espresso')
538
-                            )
539
-                        )
540
-                    )
541
-                )
542
-            );
543
-        }
544
-        return new EE_Form_Section_HTML('');
545
-    }
546
-
547
-
548
-    /**
549
-     * _currency_support
550
-     *
551
-     * @access protected
552
-     * @param EE_Payment_Method $payment_method
553
-     * @return EE_Form_Section_HTML
554
-     * @throws EE_Error
555
-     */
556
-    protected function _currency_support(EE_Payment_Method $payment_method)
557
-    {
558
-        if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
559
-            return new EE_Form_Section_HTML(
560
-                EEH_HTML::table(
561
-                    EEH_HTML::tr(
562
-                        EEH_HTML::th(
563
-                            EEH_HTML::label(
564
-                                EEH_HTML::strong(
565
-                                    esc_html__('IMPORTANT', 'event_espresso'),
566
-                                    '',
567
-                                    'important-notice'
568
-                                )
569
-                            )
570
-                        ) .
571
-                        EEH_HTML::td(
572
-                            EEH_HTML::strong(
573
-                                sprintf(
574
-                                    esc_html__(
575
-                                        '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.',
576
-                                        'event_espresso'
577
-                                    ),
578
-                                    EE_Config::instance()->currency->code
579
-                                )
580
-                            )
581
-                        )
582
-                    )
583
-                )
584
-            );
585
-        }
586
-        return new EE_Form_Section_HTML('');
587
-    }
588
-
589
-
590
-    /**
591
-     * _update_payment_method_button
592
-     *
593
-     * @access protected
594
-     * @param EE_Payment_Method $payment_method
595
-     * @return EE_Payment_Method_Form
596
-     * @throws EE_Error
597
-     */
598
-    protected function _payment_method_settings(EE_Payment_Method $payment_method)
599
-    {
600
-        // modify the form, so we only have/show fields that will be implemented for this version
601
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
602
-    }
603
-
604
-
605
-    /**
606
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
607
-     *
608
-     * @param EE_Form_Section_Proper $form_section
609
-     * @param string                 $payment_method_name
610
-     * @return EE_Payment_Method_Form
611
-     * @throws EE_Error
612
-     */
613
-    protected function _simplify_form($form_section, $payment_method_name = '')
614
-    {
615
-        if ($form_section instanceof EE_Payment_Method_Form) {
616
-            $form_section->exclude(
617
-                array(
618
-                    'PMD_type', // don't want them changing the type
619
-                    'PMD_slug', // or the slug (probably never)
620
-                    'PMD_wp_user', // or the user's ID
621
-                    'Currency' // or the currency, until the rest of EE supports simultaneous currencies
622
-                )
623
-            );
624
-            return $form_section;
625
-        } else {
626
-            throw new EE_Error(
627
-                sprintf(
628
-                    esc_html__(
629
-                        'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
630
-                        'event_espresso'
631
-                    ),
632
-                    $payment_method_name
633
-                )
634
-            );
635
-        }
636
-    }
637
-
638
-
639
-    /**
640
-     * _update_payment_method_button
641
-     *
642
-     * @access protected
643
-     * @param EE_Payment_Method $payment_method
644
-     * @return EE_Form_Section_HTML
645
-     * @throws EE_Error
646
-     */
647
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method)
648
-    {
649
-        $update_button = new EE_Submit_Input(
650
-            array(
651
-                'name'       => 'submit',
652
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
653
-                'default'    => sprintf(
654
-                    esc_html__('Update %s Payment Settings', 'event_espresso'),
655
-                    $payment_method->admin_name()
656
-                ),
657
-                'html_label' => EEH_HTML::nbsp(),
658
-            )
659
-        );
660
-        return new EE_Form_Section_HTML(
661
-            EEH_HTML::table(
662
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
663
-                EEH_HTML::tr(
664
-                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
665
-                    EEH_HTML::td(
666
-                        $update_button->get_html_for_input()
667
-                    )
668
-                )
669
-            )
670
-        );
671
-    }
672
-
673
-
674
-    /**
675
-     * _deactivate_payment_method_button
676
-     *
677
-     * @access protected
678
-     * @param EE_Payment_Method $payment_method
679
-     * @return EE_Form_Section_HTML
680
-     */
681
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
682
-    {
683
-        $link_text_and_title = sprintf(
684
-            esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
685
-            $payment_method->admin_name()
686
-        );
687
-        return new EE_Form_Section_HTML(
688
-            EEH_HTML::table(
689
-                EEH_HTML::tr(
690
-                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
691
-                    EEH_HTML::td(
692
-                        EEH_HTML::link(
693
-                            EE_Admin_Page::add_query_args_and_nonce(
694
-                                array(
695
-                                    'action'         => 'deactivate_payment_method',
696
-                                    'payment_method' => $payment_method->slug(),
697
-                                ),
698
-                                EE_PAYMENTS_ADMIN_URL
699
-                            ),
700
-                            $link_text_and_title,
701
-                            $link_text_and_title,
702
-                            'deactivate_' . $payment_method->slug(),
703
-                            'button button--secondary'
704
-                        )
705
-                    )
706
-                )
707
-            )
708
-        );
709
-    }
710
-
711
-
712
-    /**
713
-     * _activate_payment_method_button
714
-     *
715
-     * @access protected
716
-     * @param EE_Payment_Method $payment_method
717
-     * @return EE_Form_Section_Proper
718
-     * @throws EE_Error
719
-     */
720
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
721
-    {
722
-        $link_text_and_title = sprintf(
723
-            esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
724
-            $payment_method->admin_name()
725
-        );
726
-        return new EE_Form_Section_Proper(
727
-            array(
728
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
729
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
730
-                'action'          => '#',
731
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
732
-                'subsections'     => apply_filters(
733
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
734
-                    array(
735
-                        new EE_Form_Section_HTML(
736
-                            EEH_HTML::table(
737
-                                EEH_HTML::tr(
738
-                                    EEH_HTML::td(
739
-                                        $payment_method->type_obj()->introductory_html(),
740
-                                        '',
741
-                                        '',
742
-                                        '',
743
-                                        'colspan="2"'
744
-                                    )
745
-                                ) .
746
-                                EEH_HTML::tr(
747
-                                    EEH_HTML::th(
748
-                                        EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
749
-                                    ) .
750
-                                    EEH_HTML::td(
751
-                                        EEH_HTML::link(
752
-                                            EE_Admin_Page::add_query_args_and_nonce(
753
-                                                array(
754
-                                                    'action'              => 'activate_payment_method',
755
-                                                    'payment_method_type' => $payment_method->type(),
756
-                                                ),
757
-                                                EE_PAYMENTS_ADMIN_URL
758
-                                            ),
759
-                                            $link_text_and_title,
760
-                                            $link_text_and_title,
761
-                                            'activate_' . $payment_method->slug(),
762
-                                            'button button--primary-alt'
763
-                                        )
764
-                                    )
765
-                                )
766
-                            )
767
-                        ),
768
-                    ),
769
-                    $payment_method
770
-                ),
771
-            )
772
-        );
773
-    }
774
-
775
-
776
-    /**
777
-     * _fine_print
778
-     *
779
-     * @access protected
780
-     * @return EE_Form_Section_HTML
781
-     */
782
-    protected function _fine_print()
783
-    {
784
-        return new EE_Form_Section_HTML(
785
-            EEH_HTML::table(
786
-                EEH_HTML::tr(
787
-                    EEH_HTML::th() .
788
-                    EEH_HTML::td(
789
-                        EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
790
-                    )
791
-                )
792
-            )
793
-        );
794
-    }
795
-
796
-
797
-    /**
798
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
799
-     *
800
-     * @throws EE_Error
801
-     * @throws ReflectionException
802
-     * @global WP_User $current_user
803
-     */
804
-    protected function _activate_payment_method()
805
-    {
806
-        if (isset($this->_req_data['payment_method_type'])) {
807
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
808
-            // see if one exists
809
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
810
-            $payment_method = EE_Payment_Method_Manager::instance()
811
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
812
-            $this->_redirect_after_action(
813
-                1,
814
-                'Payment Method',
815
-                'activated',
816
-                array('action' => 'default', 'payment_method' => $payment_method->slug())
817
-            );
818
-        } else {
819
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
820
-        }
821
-    }
822
-
823
-
824
-    /**
825
-     * @throws EE_Error
826
-     * @throws ReflectionException
827
-     */
828
-    protected function _deactivate_payment_method()
829
-    {
830
-        if (isset($this->_req_data['payment_method'])) {
831
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
832
-            // deactivate it
833
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
834
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
835
-            $this->_redirect_after_action(
836
-                $count_updated,
837
-                'Payment Method',
838
-                'deactivated',
839
-                array('action' => 'default', 'payment_method' => $payment_method_slug)
840
-            );
841
-        } else {
842
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
843
-        }
844
-    }
845
-
846
-
847
-    /**
848
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
849
-     * processing because we first need to identify WHICH form was processed and which payment method
850
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
851
-     * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
852
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
853
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
854
-     *
855
-     * @return void
856
-     * @throws EE_Error
857
-     * @throws ReflectionException
858
-     */
859
-    protected function _update_payment_method()
860
-    {
861
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
862
-            // ok let's find which gateway form to use based on the form input
863
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
864
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
865
-            $correct_pmt_form_to_use = null;
866
-            $payment_method = null;
867
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
868
-                if ($payment_method instanceof EE_Payment_Method) {
869
-                    // get the form and simplify it, like what we do when we display it
870
-                    $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
871
-                    if ($pmt_form->form_data_present_in($this->_req_data)) {
872
-                        $correct_pmt_form_to_use = $pmt_form;
873
-                        break;
874
-                    }
875
-                }
876
-            }
877
-            // if we couldn't find the correct payment method type...
878
-            if (! $correct_pmt_form_to_use) {
879
-                EE_Error::add_error(
880
-                    esc_html__(
881
-                        "We could not find which payment method type your form submission related to. Please contact support",
882
-                        'event_espresso'
883
-                    ),
884
-                    __FILE__,
885
-                    __FUNCTION__,
886
-                    __LINE__
887
-                );
888
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
889
-            }
890
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
891
-            if ($correct_pmt_form_to_use->is_valid()) {
892
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
893
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
894
-                    throw new EE_Error(
895
-                        sprintf(
896
-                            esc_html__(
897
-                                'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
898
-                                'event_espresso'
899
-                            ),
900
-                            'payment_method_settings'
901
-                        )
902
-                    );
903
-                }
904
-                $payment_settings_subform->save();
905
-                /** @var $pm EE_Payment_Method */
906
-                $this->_redirect_after_action(
907
-                    true,
908
-                    'Payment Method',
909
-                    'updated',
910
-                    array('action' => 'default', 'payment_method' => $payment_method->slug())
911
-                );
912
-            } else {
913
-                EE_Error::add_error(
914
-                    sprintf(
915
-                        esc_html__(
916
-                            'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
917
-                            'event_espresso'
918
-                        ),
919
-                        $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
920
-                            : esc_html__('"(unknown)"', 'event_espresso')
921
-                    ),
922
-                    __FILE__,
923
-                    __FUNCTION__,
924
-                    __LINE__
925
-                );
926
-            }
927
-        }
928
-    }
929
-
930
-
931
-    /**
932
-     * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
933
-     * @throws DomainException
934
-     * @throws EE_Error
935
-     * @throws InvalidArgumentException
936
-     * @throws InvalidDataTypeException
937
-     * @throws InvalidInterfaceException
938
-     */
939
-    protected function _payment_settings()
940
-    {
941
-        $form = $this->getPaymentSettingsForm();
942
-        $this->_set_add_edit_form_tags('update_payment_settings');
943
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
944
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
945
-            $form->get_html_and_js(),
946
-            '',
947
-            'padding'
948
-        );
949
-        $this->display_admin_page_with_sidebar();
950
-    }
951
-
952
-
953
-    /**
954
-     *        _update_payment_settings
955
-     *
956
-     * @access protected
957
-     * @return void
958
-     * @throws EE_Error
959
-     * @throws InvalidArgumentException
960
-     * @throws InvalidDataTypeException
961
-     * @throws InvalidInterfaceException
962
-     */
963
-    protected function _update_payment_settings()
964
-    {
965
-        $form = $this->getPaymentSettingsForm();
966
-        if ($form->was_submitted($this->_req_data)) {
967
-            $form->receive_form_submission($this->_req_data);
968
-            if ($form->is_valid()) {
969
-                /**
970
-                 * @var $reg_config EE_Registration_Config
971
-                 */
972
-                $loader = LoaderFactory::getLoader();
973
-                $reg_config = $loader->getShared('EE_Registration_Config');
974
-                $valid_data = $form->valid_data();
975
-                $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
976
-                $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
977
-            }
978
-        }
979
-        EE_Registry::instance()->CFG = apply_filters(
980
-            'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
981
-            EE_Registry::instance()->CFG
982
-        );
983
-
984
-        $what = esc_html__('Payment Settings', 'event_espresso');
985
-        $success = $this->_update_espresso_configuration(
986
-            $what,
987
-            EE_Registry::instance()->CFG,
988
-            __FILE__,
989
-            __FUNCTION__,
990
-            __LINE__
991
-        );
992
-        $this->_redirect_after_action(
993
-            $success,
994
-            $what,
995
-            esc_html__('updated', 'event_espresso'),
996
-            array('action' => 'payment_settings')
997
-        );
998
-    }
999
-
1000
-
1001
-    /**
1002
-     * Gets the form used for updating payment settings
1003
-     *
1004
-     * @return EE_Form_Section_Proper
1005
-     * @throws EE_Error
1006
-     * @throws InvalidArgumentException
1007
-     * @throws InvalidDataTypeException
1008
-     * @throws InvalidInterfaceException
1009
-     */
1010
-    protected function getPaymentSettingsForm()
1011
-    {
1012
-        /**
1013
-         * @var $reg_config EE_Registration_Config
1014
-         */
1015
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1016
-        return new EE_Form_Section_Proper(
1017
-            array(
1018
-                'name' => 'payment-settings',
1019
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1020
-                'subsections' => array(
1021
-                    'show_pending_payment_options' => new EE_Yes_No_Input(
1022
-                        array(
1023
-                            'html_name' => 'show_pending_payment_options',
1024
-                            'default' => $reg_config->show_pending_payment_options,
1025
-                            'html_help_text' => esc_html__(
1026
-                                "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. ",
1027
-                                'event_espresso'
1028
-                            )
1029
-                        )
1030
-                    ),
1031
-                    'gateway_log_lifespan' => new EE_Select_Input(
1032
-                        $reg_config->gatewayLogLifespanOptions(),
1033
-                        array(
1034
-                            'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1035
-                            'html_help_text' => esc_html__('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.', 'event_espresso'),
1036
-                            'default' => $reg_config->gateway_log_lifespan,
1037
-                        )
1038
-                    )
1039
-                )
1040
-            )
1041
-        );
1042
-    }
1043
-
1044
-
1045
-    /**
1046
-     * @throws EE_Error
1047
-     */
1048
-    protected function _payment_log_overview_list_table()
1049
-    {
1050
-        $this->display_admin_list_table_page_with_sidebar();
1051
-    }
1052
-
1053
-
1054
-    protected function _set_list_table_views_payment_log()
1055
-    {
1056
-        $this->_views = array(
1057
-            'all' => array(
1058
-                'slug'  => 'all',
1059
-                'label' => esc_html__('View All Logs', 'event_espresso'),
1060
-                'count' => 0,
1061
-            ),
1062
-        );
1063
-    }
1064
-
1065
-
1066
-    /**
1067
-     * @param int  $per_page
1068
-     * @param int  $current_page
1069
-     * @param bool $count
1070
-     * @return array|int
1071
-     * @throws EE_Error
1072
-     * @throws ReflectionException
1073
-     */
1074
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1075
-    {
1076
-        EE_Registry::instance()->load_model('Change_Log');
1077
-        // we may need to do multiple queries (joining differently), so we actually want an array of query params
1078
-        $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1079
-        // check if they've selected a specific payment method
1080
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1081
-            $query_params[0]['OR*pm_or_pay_pm'] = array(
1082
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1083
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1084
-            );
1085
-        }
1086
-        // take into account search
1087
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1088
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1089
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1090
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1091
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1092
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1093
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1094
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1095
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1096
-            $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1097
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1098
-            $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1099
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1100
-        }
1101
-        if (
1102
-            isset($this->_req_data['payment-filter-start-date'])
1103
-            && isset($this->_req_data['payment-filter-end-date'])
1104
-        ) {
1105
-            // add date
1106
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1107
-            $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1108
-            // make sure our timestamps start and end right at the boundaries for each day
1109
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1110
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1111
-            // convert to timestamps
1112
-            $start_date = strtotime($start_date);
1113
-            $end_date = strtotime($end_date);
1114
-            // makes sure start date is the lowest value and vice versa
1115
-            $start_date = min($start_date, $end_date);
1116
-            $end_date = max($start_date, $end_date);
1117
-            // convert for query
1118
-            $start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1119
-                'LOG_time',
1120
-                date('Y-m-d H:i:s', $start_date),
1121
-                'Y-m-d H:i:s'
1122
-            );
1123
-            $end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1124
-                'LOG_time',
1125
-                date('Y-m-d H:i:s', $end_date),
1126
-                'Y-m-d H:i:s'
1127
-            );
1128
-            $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1129
-        }
1130
-        if ($count) {
1131
-            return EEM_Change_Log::instance()->count($query_params);
1132
-        }
1133
-        if (isset($this->_req_data['order'])) {
1134
-            $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1135
-                ? $this->_req_data['order']
1136
-                : 'DESC';
1137
-            $query_params['order_by'] = array('LOG_time' => $sort);
1138
-        } else {
1139
-            $query_params['order_by'] = array('LOG_time' => 'DESC');
1140
-        }
1141
-        $offset = ($current_page - 1) * $per_page;
1142
-        if (! isset($this->_req_data['download_results'])) {
1143
-            $query_params['limit'] = array($offset, $per_page);
1144
-        }
1145
-        // now they've requested to instead just download the file instead of viewing it.
1146
-        if (isset($this->_req_data['download_results'])) {
1147
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1148
-            header('Content-Disposition: attachment');
1149
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1150
-            echo '<h1> '
1151
-                . sprintf(
1152
-                    esc_html__('Payment Logs for %1$s', 'event_espresso'),
1153
-                    esc_url_raw(site_url())
1154
-                )
1155
-                . '</h1 >';
1156
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1157
-            echo esc_html(var_export($query_params, true));
1158
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1159
-            echo esc_html(var_export($wpdb_results, true));
1160
-            die;
1161
-        }
1162
-        return EEM_Change_Log::instance()->get_all($query_params);
1163
-    }
1164
-
1165
-
1166
-    /**
1167
-     * Used by usort to RE-sort log query results, because we lose the ordering
1168
-     * because we're possibly combining the results from two queries
1169
-     *
1170
-     * @param EE_Change_Log $logA
1171
-     * @param EE_Change_Log $logB
1172
-     * @return int
1173
-     * @throws EE_Error
1174
-     * @throws ReflectionException
1175
-     */
1176
-    protected function _sort_logs_again($logA, $logB)
1177
-    {
1178
-        $timeA = $logA->get_raw('LOG_time');
1179
-        $timeB = $logB->get_raw('LOG_time');
1180
-        if ($timeA == $timeB) {
1181
-            return 0;
1182
-        }
1183
-        $comparison = $timeA < $timeB ? -1 : 1;
1184
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1185
-            return $comparison * -1;
1186
-        }
1187
-        return $comparison;
1188
-    }
1189
-
1190
-
1191
-    /**
1192
-     * @throws EE_Error
1193
-     * @throws ReflectionException
1194
-     */
1195
-    protected function _payment_log_details()
1196
-    {
1197
-        EE_Registry::instance()->load_model('Change_Log');
1198
-        /** @var $payment_log EE_Change_Log */
1199
-        $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1200
-        $payment_method = null;
1201
-        $transaction = null;
1202
-        if ($payment_log instanceof EE_Change_Log) {
1203
-            if ($payment_log->object() instanceof EE_Payment) {
1204
-                $payment_method = $payment_log->object()->payment_method();
1205
-                $transaction = $payment_log->object()->transaction();
1206
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1207
-                $payment_method = $payment_log->object();
1208
-            } elseif ($payment_log->object() instanceof EE_Transaction) {
1209
-                $transaction = $payment_log->object();
1210
-                $payment_method = $transaction->payment_method();
1211
-            }
1212
-        }
1213
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1214
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1215
-            array(
1216
-                'payment_log'    => $payment_log,
1217
-                'payment_method' => $payment_method,
1218
-                'transaction'    => $transaction,
1219
-            ),
1220
-            true
1221
-        );
1222
-        $this->display_admin_page_with_no_sidebar();
1223
-    }
19
+	/**
20
+	 * Variables used for when we're re-sorting the logs results,
21
+	 * in case we needed to do two queries, and we need to resort
22
+	 *
23
+	 * @var string
24
+	 */
25
+	private $_sort_logs_again_direction;
26
+
27
+
28
+	/**
29
+	 * @Constructor
30
+	 * @access public
31
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
+	 * @throws EE_Error
33
+	 * @throws InvalidArgumentException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws ReflectionException
37
+	 */
38
+	public function __construct($routing = true)
39
+	{
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _init_page_props()
45
+	{
46
+		$this->page_slug = EE_PAYMENTS_PG_SLUG;
47
+		$this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
+		$this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
+	}
51
+
52
+
53
+	protected function _ajax_hooks()
54
+	{
55
+		// todo: all hooks for ajax goes here.
56
+	}
57
+
58
+
59
+	protected function _define_page_props()
60
+	{
61
+		$this->_admin_page_title = $this->page_label;
62
+		$this->_labels = array(
63
+			'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
+		);
65
+	}
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		/**
71
+		 * note that with payment method capabilities, although we've implemented
72
+		 * capability mapping which will be used for accessing payment methods owned by
73
+		 * other users.  This is not fully implemented yet in the payment method ui.
74
+		 * Currently, only the "plural" caps are in active use.
75
+		 * When cap mapping is implemented, some routes will need to use the singular form of
76
+		 * capability method and also include the $id of the payment method for the route.
77
+		 **/
78
+		$this->_page_routes = array(
79
+			'default'                   => array(
80
+				'func'       => '_payment_methods_list',
81
+				'capability' => 'ee_edit_payment_methods',
82
+			),
83
+			'payment_settings'          => array(
84
+				'func'       => '_payment_settings',
85
+				'capability' => 'ee_manage_gateways',
86
+			),
87
+			'activate_payment_method'   => array(
88
+				'func'       => '_activate_payment_method',
89
+				'noheader'   => true,
90
+				'capability' => 'ee_edit_payment_methods',
91
+			),
92
+			'deactivate_payment_method' => array(
93
+				'func'       => '_deactivate_payment_method',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_payment_methods',
96
+			),
97
+			'update_payment_method'     => array(
98
+				'func'               => '_update_payment_method',
99
+				'noheader'           => true,
100
+				'headers_sent_route' => 'default',
101
+				'capability'         => 'ee_edit_payment_methods',
102
+			),
103
+			'update_payment_settings'   => array(
104
+				'func'       => '_update_payment_settings',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_manage_gateways',
107
+			),
108
+			'payment_log'               => array(
109
+				'func'       => '_payment_log_overview_list_table',
110
+				'capability' => 'ee_read_payment_methods',
111
+			),
112
+			'payment_log_details'       => array(
113
+				'func'       => '_payment_log_details',
114
+				'capability' => 'ee_read_payment_methods',
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	/**
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	protected function _set_page_config()
125
+	{
126
+		$payment_method_list_config = array(
127
+			'nav'           => array(
128
+				'label' => esc_html__('Payment Methods', 'event_espresso'),
129
+				'icon' => 'dashicons-bank',
130
+				'order' => 10,
131
+			),
132
+			'metaboxes'     => $this->_default_espresso_metaboxes,
133
+			'help_tabs'     => array_merge(
134
+				array(
135
+					'payment_methods_overview_help_tab' => array(
136
+						'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
+						'filename' => 'payment_methods_overview',
138
+					),
139
+				),
140
+				$this->_add_payment_method_help_tabs()
141
+			),
142
+			'require_nonce' => false,
143
+		);
144
+		$this->_page_config = array(
145
+			'default'          => $payment_method_list_config,
146
+			'payment_settings' => array(
147
+				'nav'           => array(
148
+					'label' => esc_html__('Settings', 'event_espresso'),
149
+					'icon' => 'dashicons-admin-generic',
150
+					'order' => 20,
151
+				),
152
+				'help_tabs'     => array(
153
+					'payment_methods_settings_help_tab' => array(
154
+						'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
+						'filename' => 'payment_methods_settings',
156
+					),
157
+				),
158
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
+				'require_nonce' => false,
160
+			),
161
+			'payment_log'      => array(
162
+				'nav'           => array(
163
+					'label' => esc_html__("Logs", 'event_espresso'),
164
+					'icon' => 'dashicons-text-page',
165
+					'order' => 30,
166
+				),
167
+				'list_table'    => 'Payment_Log_Admin_List_Table',
168
+				'metaboxes'     => $this->_default_espresso_metaboxes,
169
+				'require_nonce' => false,
170
+			),
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @return array
177
+	 * @throws DomainException
178
+	 * @throws EE_Error
179
+	 * @throws InvalidArgumentException
180
+	 * @throws InvalidDataTypeException
181
+	 * @throws InvalidInterfaceException
182
+	 * @throws ReflectionException
183
+	 */
184
+	protected function _add_payment_method_help_tabs()
185
+	{
186
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
+		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
+		$all_pmt_help_tabs_config = array();
189
+		foreach ($payment_method_types as $payment_method_type) {
190
+			if (
191
+				! EE_Registry::instance()->CAP->current_user_can(
192
+					$payment_method_type->cap_name(),
193
+					'specific_payment_method_type_access'
194
+				)
195
+			) {
196
+				continue;
197
+			}
198
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
+				$template_args['admin_page_obj'] = $this;
201
+				$all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
+					'title'   => $config['title'],
203
+					'content' => EEH_Template::display_template(
204
+						$payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
+						$template_args,
206
+						true
207
+					),
208
+				);
209
+			}
210
+		}
211
+		return $all_pmt_help_tabs_config;
212
+	}
213
+
214
+
215
+	// none of the below group are currently used for Gateway Settings
216
+	protected function _add_screen_options()
217
+	{
218
+	}
219
+
220
+
221
+	protected function _add_feature_pointers()
222
+	{
223
+	}
224
+
225
+
226
+	public function admin_init()
227
+	{
228
+	}
229
+
230
+
231
+	public function admin_notices()
232
+	{
233
+	}
234
+
235
+
236
+	public function admin_footer_scripts()
237
+	{
238
+	}
239
+
240
+
241
+	public function load_scripts_styles()
242
+	{
243
+		// styles
244
+		wp_enqueue_style('espresso-ui-theme');
245
+		wp_register_style(
246
+			'espresso_payments',
247
+			EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
248
+			[],
249
+			EVENT_ESPRESSO_VERSION
250
+		);
251
+		// scripts
252
+		wp_enqueue_script('ee_admin_js');
253
+		wp_enqueue_script('ee-text-links');
254
+		wp_enqueue_script(
255
+			'espresso_payments',
256
+			EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
257
+			['ee-datepicker'],
258
+			EVENT_ESPRESSO_VERSION,
259
+			true
260
+		);
261
+	}
262
+
263
+
264
+	public function load_scripts_styles_default()
265
+	{
266
+		wp_enqueue_style('espresso_payments');
267
+		wp_enqueue_style('ee-text-links');
268
+	}
269
+
270
+
271
+	public function load_scripts_styles_payment_log_details()
272
+	{
273
+		wp_enqueue_style('espresso_payments');
274
+	}
275
+
276
+
277
+	/**
278
+	 * @throws EE_Error
279
+	 * @throws ReflectionException
280
+	 */
281
+	protected function _payment_methods_list()
282
+	{
283
+		/**
284
+		 * first let's ensure payment methods have been set up.
285
+		 * We do this here because when people activate a payment method for the first time (as an addon),
286
+		 * it may not set up its capabilities or get registered correctly due to the loading process.
287
+		 * However, people MUST set up the details for the payment method,
288
+		 * so it's safe to do a recheck here.
289
+		 */
290
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
291
+		EEM_Payment_Method::instance()->verify_button_urls();
292
+		// set up tabs, one for each payment method type
293
+		$tabs = array();
294
+		$payment_methods = array();
295
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
296
+			// we don't want to show admin-only PMTs for now
297
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
298
+				continue;
299
+			}
300
+			// check access
301
+			if (
302
+				! EE_Registry::instance()->CAP->current_user_can(
303
+					$pmt_obj->cap_name(),
304
+					'specific_payment_method_type_access'
305
+				)
306
+			) {
307
+				continue;
308
+			}
309
+			// check for any active pms of that type
310
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
311
+			if (! $payment_method instanceof EE_Payment_Method) {
312
+				$payment_method = EE_Payment_Method::new_instance(
313
+					array(
314
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
315
+						'PMD_type'       => $pmt_obj->system_name(),
316
+						'PMD_name'       => $pmt_obj->pretty_name(),
317
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
318
+					)
319
+				);
320
+			}
321
+			$payment_methods[ $payment_method->slug() ] = $payment_method;
322
+		}
323
+		$payment_methods = apply_filters(
324
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
325
+			$payment_methods
326
+		);
327
+		foreach ($payment_methods as $payment_method) {
328
+			if ($payment_method instanceof EE_Payment_Method) {
329
+				$this->addMetaBox(
330
+					// html id
331
+					'espresso_' . $payment_method->slug() . '_payment_settings',
332
+					// title
333
+					sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
334
+					// callback
335
+					array($this, 'payment_method_settings_meta_box'),
336
+					// post type
337
+					null,
338
+					// context
339
+					'normal',
340
+					// priority
341
+					'default',
342
+					// callback args
343
+					array('payment_method' => $payment_method)
344
+				);
345
+				// setup for tabbed content
346
+				$tabs[ $payment_method->slug() ] = array(
347
+					'label' => $payment_method->admin_name(),
348
+					'class' => $payment_method->active() ? 'gateway-active' : '',
349
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
350
+					'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
351
+					'slug'  => $payment_method->slug(),
352
+					'icon'  => $payment_method->active()
353
+						? '<span class="dashicons dashicons-yes-alt"></span>'
354
+						: '<span class="dashicons dashicons-remove"></span>',
355
+				);
356
+			}
357
+		}
358
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
359
+			$tabs,
360
+			'payment_method_links',
361
+			'',
362
+			$this->_get_active_payment_method_slug()
363
+		);
364
+		$this->display_admin_page_with_sidebar();
365
+	}
366
+
367
+
368
+	/**
369
+	 *   _get_active_payment_method_slug
370
+	 *
371
+	 * @return string
372
+	 * @throws EE_Error
373
+	 */
374
+	protected function _get_active_payment_method_slug()
375
+	{
376
+		$payment_method_slug = false;
377
+		// decide which payment method tab to open first, as dictated by the request's 'payment_method'
378
+		if (isset($this->_req_data['payment_method'])) {
379
+			// if they provided the current payment method, use it
380
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
381
+		}
382
+		/** @var EE_Payment_Method $payment_method */
383
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
384
+		// if that didn't work or wasn't provided, find another way to select the current pm
385
+		if (! $this->_verify_payment_method($payment_method)) {
386
+			// like, looking for an active one
387
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
388
+			// test that one as well
389
+			if ($this->_verify_payment_method($payment_method)) {
390
+				$payment_method_slug = $payment_method->slug();
391
+			} else {
392
+				$payment_method_slug = 'paypal_standard';
393
+			}
394
+		}
395
+		return $payment_method_slug;
396
+	}
397
+
398
+
399
+	/**
400
+	 *    payment_method_settings_meta_box
401
+	 *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
402
+	 *    capabilities to access it
403
+	 *
404
+	 * @param EE_Payment_Method $payment_method
405
+	 * @return boolean
406
+	 * @throws EE_Error
407
+	 */
408
+	protected function _verify_payment_method($payment_method)
409
+	{
410
+		if (
411
+			$payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
412
+			&& EE_Registry::instance()->CAP->current_user_can(
413
+				$payment_method->type_obj()->cap_name(),
414
+				'specific_payment_method_type_access'
415
+			)
416
+		) {
417
+			return true;
418
+		}
419
+		return false;
420
+	}
421
+
422
+
423
+	/**
424
+	 *    payment_method_settings_meta_box
425
+	 *
426
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
427
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
428
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
429
+	 * @return void
430
+	 * @throws EE_Error
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
434
+	{
435
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
436
+			? $metabox['args']['payment_method'] : null;
437
+		if (! $payment_method instanceof EE_Payment_Method) {
438
+			throw new EE_Error(
439
+				esc_html__(
440
+					'Payment method metabox setup incorrectly. No Payment method object was supplied',
441
+					'event_espresso'
442
+				)
443
+			);
444
+		}
445
+		$payment_method_scopes = $payment_method->active();
446
+		// if the payment method really exists show its form, otherwise the activation template
447
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
448
+			$form = $this->_generate_payment_method_settings_form($payment_method);
449
+			if ($form->form_data_present_in($this->_req_data)) {
450
+				$form->receive_form_submission($this->_req_data);
451
+			}
452
+			echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
453
+		} else {
454
+			echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
455
+		}
456
+	}
457
+
458
+
459
+	/**
460
+	 * Gets the form for all the settings related to this payment method type
461
+	 *
462
+	 * @access protected
463
+	 * @param EE_Payment_Method $payment_method
464
+	 * @return EE_Form_Section_Proper
465
+	 * @throws EE_Error
466
+	 */
467
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
468
+	{
469
+		if (! $payment_method instanceof EE_Payment_Method) {
470
+			return new EE_Form_Section_Proper();
471
+		}
472
+		return new EE_Form_Section_Proper(
473
+			array(
474
+				'name'            => $payment_method->slug() . '_settings_form',
475
+				'html_id'         => $payment_method->slug() . '_settings_form',
476
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
477
+					array(
478
+						'action'         => 'update_payment_method',
479
+						'payment_method' => $payment_method->slug(),
480
+					),
481
+					EE_PAYMENTS_ADMIN_URL
482
+				),
483
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
484
+				'subsections'     => apply_filters(
485
+					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
486
+					array(
487
+						'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
488
+						'currency_support'        => $this->_currency_support($payment_method),
489
+						'payment_method_settings' => $this->_payment_method_settings($payment_method),
490
+						'update'                  => $this->_update_payment_method_button($payment_method),
491
+						'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
492
+						'fine_print'              => $this->_fine_print(),
493
+					),
494
+					$payment_method
495
+				),
496
+			)
497
+		);
498
+	}
499
+
500
+
501
+	/**
502
+	 * _pci_dss_compliance
503
+	 *
504
+	 * @access protected
505
+	 * @param EE_Payment_Method $payment_method
506
+	 * @return EE_Form_Section_HTML
507
+	 * @throws EE_Error
508
+	 */
509
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
510
+	{
511
+		if ($payment_method->type_obj()->requires_https()) {
512
+			return new EE_Form_Section_HTML(
513
+				EEH_HTML::table(
514
+					EEH_HTML::tr(
515
+						EEH_HTML::th(
516
+							EEH_HTML::label(
517
+								EEH_HTML::strong(
518
+									esc_html__('IMPORTANT', 'event_espresso'),
519
+									'',
520
+									'important-notice'
521
+								)
522
+							)
523
+						) .
524
+						EEH_HTML::td(
525
+							EEH_HTML::strong(
526
+								esc_html__(
527
+									'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
528
+									'event_espresso'
529
+								)
530
+							)
531
+							.
532
+							EEH_HTML::br()
533
+							.
534
+							esc_html__('Learn more about ', 'event_espresso')
535
+							. EEH_HTML::link(
536
+								'https://www.pcisecuritystandards.org/merchants/index.php',
537
+								esc_html__('PCI DSS compliance', 'event_espresso')
538
+							)
539
+						)
540
+					)
541
+				)
542
+			);
543
+		}
544
+		return new EE_Form_Section_HTML('');
545
+	}
546
+
547
+
548
+	/**
549
+	 * _currency_support
550
+	 *
551
+	 * @access protected
552
+	 * @param EE_Payment_Method $payment_method
553
+	 * @return EE_Form_Section_HTML
554
+	 * @throws EE_Error
555
+	 */
556
+	protected function _currency_support(EE_Payment_Method $payment_method)
557
+	{
558
+		if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
559
+			return new EE_Form_Section_HTML(
560
+				EEH_HTML::table(
561
+					EEH_HTML::tr(
562
+						EEH_HTML::th(
563
+							EEH_HTML::label(
564
+								EEH_HTML::strong(
565
+									esc_html__('IMPORTANT', 'event_espresso'),
566
+									'',
567
+									'important-notice'
568
+								)
569
+							)
570
+						) .
571
+						EEH_HTML::td(
572
+							EEH_HTML::strong(
573
+								sprintf(
574
+									esc_html__(
575
+										'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.',
576
+										'event_espresso'
577
+									),
578
+									EE_Config::instance()->currency->code
579
+								)
580
+							)
581
+						)
582
+					)
583
+				)
584
+			);
585
+		}
586
+		return new EE_Form_Section_HTML('');
587
+	}
588
+
589
+
590
+	/**
591
+	 * _update_payment_method_button
592
+	 *
593
+	 * @access protected
594
+	 * @param EE_Payment_Method $payment_method
595
+	 * @return EE_Payment_Method_Form
596
+	 * @throws EE_Error
597
+	 */
598
+	protected function _payment_method_settings(EE_Payment_Method $payment_method)
599
+	{
600
+		// modify the form, so we only have/show fields that will be implemented for this version
601
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
602
+	}
603
+
604
+
605
+	/**
606
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
607
+	 *
608
+	 * @param EE_Form_Section_Proper $form_section
609
+	 * @param string                 $payment_method_name
610
+	 * @return EE_Payment_Method_Form
611
+	 * @throws EE_Error
612
+	 */
613
+	protected function _simplify_form($form_section, $payment_method_name = '')
614
+	{
615
+		if ($form_section instanceof EE_Payment_Method_Form) {
616
+			$form_section->exclude(
617
+				array(
618
+					'PMD_type', // don't want them changing the type
619
+					'PMD_slug', // or the slug (probably never)
620
+					'PMD_wp_user', // or the user's ID
621
+					'Currency' // or the currency, until the rest of EE supports simultaneous currencies
622
+				)
623
+			);
624
+			return $form_section;
625
+		} else {
626
+			throw new EE_Error(
627
+				sprintf(
628
+					esc_html__(
629
+						'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
630
+						'event_espresso'
631
+					),
632
+					$payment_method_name
633
+				)
634
+			);
635
+		}
636
+	}
637
+
638
+
639
+	/**
640
+	 * _update_payment_method_button
641
+	 *
642
+	 * @access protected
643
+	 * @param EE_Payment_Method $payment_method
644
+	 * @return EE_Form_Section_HTML
645
+	 * @throws EE_Error
646
+	 */
647
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method)
648
+	{
649
+		$update_button = new EE_Submit_Input(
650
+			array(
651
+				'name'       => 'submit',
652
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
653
+				'default'    => sprintf(
654
+					esc_html__('Update %s Payment Settings', 'event_espresso'),
655
+					$payment_method->admin_name()
656
+				),
657
+				'html_label' => EEH_HTML::nbsp(),
658
+			)
659
+		);
660
+		return new EE_Form_Section_HTML(
661
+			EEH_HTML::table(
662
+				EEH_HTML::no_row(EEH_HTML::br(2)) .
663
+				EEH_HTML::tr(
664
+					EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
665
+					EEH_HTML::td(
666
+						$update_button->get_html_for_input()
667
+					)
668
+				)
669
+			)
670
+		);
671
+	}
672
+
673
+
674
+	/**
675
+	 * _deactivate_payment_method_button
676
+	 *
677
+	 * @access protected
678
+	 * @param EE_Payment_Method $payment_method
679
+	 * @return EE_Form_Section_HTML
680
+	 */
681
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
682
+	{
683
+		$link_text_and_title = sprintf(
684
+			esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
685
+			$payment_method->admin_name()
686
+		);
687
+		return new EE_Form_Section_HTML(
688
+			EEH_HTML::table(
689
+				EEH_HTML::tr(
690
+					EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
691
+					EEH_HTML::td(
692
+						EEH_HTML::link(
693
+							EE_Admin_Page::add_query_args_and_nonce(
694
+								array(
695
+									'action'         => 'deactivate_payment_method',
696
+									'payment_method' => $payment_method->slug(),
697
+								),
698
+								EE_PAYMENTS_ADMIN_URL
699
+							),
700
+							$link_text_and_title,
701
+							$link_text_and_title,
702
+							'deactivate_' . $payment_method->slug(),
703
+							'button button--secondary'
704
+						)
705
+					)
706
+				)
707
+			)
708
+		);
709
+	}
710
+
711
+
712
+	/**
713
+	 * _activate_payment_method_button
714
+	 *
715
+	 * @access protected
716
+	 * @param EE_Payment_Method $payment_method
717
+	 * @return EE_Form_Section_Proper
718
+	 * @throws EE_Error
719
+	 */
720
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
721
+	{
722
+		$link_text_and_title = sprintf(
723
+			esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
724
+			$payment_method->admin_name()
725
+		);
726
+		return new EE_Form_Section_Proper(
727
+			array(
728
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
729
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
730
+				'action'          => '#',
731
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
732
+				'subsections'     => apply_filters(
733
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
734
+					array(
735
+						new EE_Form_Section_HTML(
736
+							EEH_HTML::table(
737
+								EEH_HTML::tr(
738
+									EEH_HTML::td(
739
+										$payment_method->type_obj()->introductory_html(),
740
+										'',
741
+										'',
742
+										'',
743
+										'colspan="2"'
744
+									)
745
+								) .
746
+								EEH_HTML::tr(
747
+									EEH_HTML::th(
748
+										EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
749
+									) .
750
+									EEH_HTML::td(
751
+										EEH_HTML::link(
752
+											EE_Admin_Page::add_query_args_and_nonce(
753
+												array(
754
+													'action'              => 'activate_payment_method',
755
+													'payment_method_type' => $payment_method->type(),
756
+												),
757
+												EE_PAYMENTS_ADMIN_URL
758
+											),
759
+											$link_text_and_title,
760
+											$link_text_and_title,
761
+											'activate_' . $payment_method->slug(),
762
+											'button button--primary-alt'
763
+										)
764
+									)
765
+								)
766
+							)
767
+						),
768
+					),
769
+					$payment_method
770
+				),
771
+			)
772
+		);
773
+	}
774
+
775
+
776
+	/**
777
+	 * _fine_print
778
+	 *
779
+	 * @access protected
780
+	 * @return EE_Form_Section_HTML
781
+	 */
782
+	protected function _fine_print()
783
+	{
784
+		return new EE_Form_Section_HTML(
785
+			EEH_HTML::table(
786
+				EEH_HTML::tr(
787
+					EEH_HTML::th() .
788
+					EEH_HTML::td(
789
+						EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
790
+					)
791
+				)
792
+			)
793
+		);
794
+	}
795
+
796
+
797
+	/**
798
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
799
+	 *
800
+	 * @throws EE_Error
801
+	 * @throws ReflectionException
802
+	 * @global WP_User $current_user
803
+	 */
804
+	protected function _activate_payment_method()
805
+	{
806
+		if (isset($this->_req_data['payment_method_type'])) {
807
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
808
+			// see if one exists
809
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
810
+			$payment_method = EE_Payment_Method_Manager::instance()
811
+													   ->activate_a_payment_method_of_type($payment_method_type);
812
+			$this->_redirect_after_action(
813
+				1,
814
+				'Payment Method',
815
+				'activated',
816
+				array('action' => 'default', 'payment_method' => $payment_method->slug())
817
+			);
818
+		} else {
819
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
820
+		}
821
+	}
822
+
823
+
824
+	/**
825
+	 * @throws EE_Error
826
+	 * @throws ReflectionException
827
+	 */
828
+	protected function _deactivate_payment_method()
829
+	{
830
+		if (isset($this->_req_data['payment_method'])) {
831
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
832
+			// deactivate it
833
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
834
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
835
+			$this->_redirect_after_action(
836
+				$count_updated,
837
+				'Payment Method',
838
+				'deactivated',
839
+				array('action' => 'default', 'payment_method' => $payment_method_slug)
840
+			);
841
+		} else {
842
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
843
+		}
844
+	}
845
+
846
+
847
+	/**
848
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
849
+	 * processing because we first need to identify WHICH form was processed and which payment method
850
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
851
+	 * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
852
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
853
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
854
+	 *
855
+	 * @return void
856
+	 * @throws EE_Error
857
+	 * @throws ReflectionException
858
+	 */
859
+	protected function _update_payment_method()
860
+	{
861
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
862
+			// ok let's find which gateway form to use based on the form input
863
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
864
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
865
+			$correct_pmt_form_to_use = null;
866
+			$payment_method = null;
867
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
868
+				if ($payment_method instanceof EE_Payment_Method) {
869
+					// get the form and simplify it, like what we do when we display it
870
+					$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
871
+					if ($pmt_form->form_data_present_in($this->_req_data)) {
872
+						$correct_pmt_form_to_use = $pmt_form;
873
+						break;
874
+					}
875
+				}
876
+			}
877
+			// if we couldn't find the correct payment method type...
878
+			if (! $correct_pmt_form_to_use) {
879
+				EE_Error::add_error(
880
+					esc_html__(
881
+						"We could not find which payment method type your form submission related to. Please contact support",
882
+						'event_espresso'
883
+					),
884
+					__FILE__,
885
+					__FUNCTION__,
886
+					__LINE__
887
+				);
888
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
889
+			}
890
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
891
+			if ($correct_pmt_form_to_use->is_valid()) {
892
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
893
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
894
+					throw new EE_Error(
895
+						sprintf(
896
+							esc_html__(
897
+								'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
898
+								'event_espresso'
899
+							),
900
+							'payment_method_settings'
901
+						)
902
+					);
903
+				}
904
+				$payment_settings_subform->save();
905
+				/** @var $pm EE_Payment_Method */
906
+				$this->_redirect_after_action(
907
+					true,
908
+					'Payment Method',
909
+					'updated',
910
+					array('action' => 'default', 'payment_method' => $payment_method->slug())
911
+				);
912
+			} else {
913
+				EE_Error::add_error(
914
+					sprintf(
915
+						esc_html__(
916
+							'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
917
+							'event_espresso'
918
+						),
919
+						$payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
920
+							: esc_html__('"(unknown)"', 'event_espresso')
921
+					),
922
+					__FILE__,
923
+					__FUNCTION__,
924
+					__LINE__
925
+				);
926
+			}
927
+		}
928
+	}
929
+
930
+
931
+	/**
932
+	 * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
933
+	 * @throws DomainException
934
+	 * @throws EE_Error
935
+	 * @throws InvalidArgumentException
936
+	 * @throws InvalidDataTypeException
937
+	 * @throws InvalidInterfaceException
938
+	 */
939
+	protected function _payment_settings()
940
+	{
941
+		$form = $this->getPaymentSettingsForm();
942
+		$this->_set_add_edit_form_tags('update_payment_settings');
943
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
944
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
945
+			$form->get_html_and_js(),
946
+			'',
947
+			'padding'
948
+		);
949
+		$this->display_admin_page_with_sidebar();
950
+	}
951
+
952
+
953
+	/**
954
+	 *        _update_payment_settings
955
+	 *
956
+	 * @access protected
957
+	 * @return void
958
+	 * @throws EE_Error
959
+	 * @throws InvalidArgumentException
960
+	 * @throws InvalidDataTypeException
961
+	 * @throws InvalidInterfaceException
962
+	 */
963
+	protected function _update_payment_settings()
964
+	{
965
+		$form = $this->getPaymentSettingsForm();
966
+		if ($form->was_submitted($this->_req_data)) {
967
+			$form->receive_form_submission($this->_req_data);
968
+			if ($form->is_valid()) {
969
+				/**
970
+				 * @var $reg_config EE_Registration_Config
971
+				 */
972
+				$loader = LoaderFactory::getLoader();
973
+				$reg_config = $loader->getShared('EE_Registration_Config');
974
+				$valid_data = $form->valid_data();
975
+				$reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
976
+				$reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
977
+			}
978
+		}
979
+		EE_Registry::instance()->CFG = apply_filters(
980
+			'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
981
+			EE_Registry::instance()->CFG
982
+		);
983
+
984
+		$what = esc_html__('Payment Settings', 'event_espresso');
985
+		$success = $this->_update_espresso_configuration(
986
+			$what,
987
+			EE_Registry::instance()->CFG,
988
+			__FILE__,
989
+			__FUNCTION__,
990
+			__LINE__
991
+		);
992
+		$this->_redirect_after_action(
993
+			$success,
994
+			$what,
995
+			esc_html__('updated', 'event_espresso'),
996
+			array('action' => 'payment_settings')
997
+		);
998
+	}
999
+
1000
+
1001
+	/**
1002
+	 * Gets the form used for updating payment settings
1003
+	 *
1004
+	 * @return EE_Form_Section_Proper
1005
+	 * @throws EE_Error
1006
+	 * @throws InvalidArgumentException
1007
+	 * @throws InvalidDataTypeException
1008
+	 * @throws InvalidInterfaceException
1009
+	 */
1010
+	protected function getPaymentSettingsForm()
1011
+	{
1012
+		/**
1013
+		 * @var $reg_config EE_Registration_Config
1014
+		 */
1015
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1016
+		return new EE_Form_Section_Proper(
1017
+			array(
1018
+				'name' => 'payment-settings',
1019
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1020
+				'subsections' => array(
1021
+					'show_pending_payment_options' => new EE_Yes_No_Input(
1022
+						array(
1023
+							'html_name' => 'show_pending_payment_options',
1024
+							'default' => $reg_config->show_pending_payment_options,
1025
+							'html_help_text' => esc_html__(
1026
+								"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. ",
1027
+								'event_espresso'
1028
+							)
1029
+						)
1030
+					),
1031
+					'gateway_log_lifespan' => new EE_Select_Input(
1032
+						$reg_config->gatewayLogLifespanOptions(),
1033
+						array(
1034
+							'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1035
+							'html_help_text' => esc_html__('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.', 'event_espresso'),
1036
+							'default' => $reg_config->gateway_log_lifespan,
1037
+						)
1038
+					)
1039
+				)
1040
+			)
1041
+		);
1042
+	}
1043
+
1044
+
1045
+	/**
1046
+	 * @throws EE_Error
1047
+	 */
1048
+	protected function _payment_log_overview_list_table()
1049
+	{
1050
+		$this->display_admin_list_table_page_with_sidebar();
1051
+	}
1052
+
1053
+
1054
+	protected function _set_list_table_views_payment_log()
1055
+	{
1056
+		$this->_views = array(
1057
+			'all' => array(
1058
+				'slug'  => 'all',
1059
+				'label' => esc_html__('View All Logs', 'event_espresso'),
1060
+				'count' => 0,
1061
+			),
1062
+		);
1063
+	}
1064
+
1065
+
1066
+	/**
1067
+	 * @param int  $per_page
1068
+	 * @param int  $current_page
1069
+	 * @param bool $count
1070
+	 * @return array|int
1071
+	 * @throws EE_Error
1072
+	 * @throws ReflectionException
1073
+	 */
1074
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1075
+	{
1076
+		EE_Registry::instance()->load_model('Change_Log');
1077
+		// we may need to do multiple queries (joining differently), so we actually want an array of query params
1078
+		$query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1079
+		// check if they've selected a specific payment method
1080
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1081
+			$query_params[0]['OR*pm_or_pay_pm'] = array(
1082
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1083
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1084
+			);
1085
+		}
1086
+		// take into account search
1087
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1088
+			$similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1089
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1090
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1091
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1092
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1093
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1094
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1095
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1096
+			$query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1097
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1098
+			$query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1099
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1100
+		}
1101
+		if (
1102
+			isset($this->_req_data['payment-filter-start-date'])
1103
+			&& isset($this->_req_data['payment-filter-end-date'])
1104
+		) {
1105
+			// add date
1106
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1107
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1108
+			// make sure our timestamps start and end right at the boundaries for each day
1109
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1110
+			$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1111
+			// convert to timestamps
1112
+			$start_date = strtotime($start_date);
1113
+			$end_date = strtotime($end_date);
1114
+			// makes sure start date is the lowest value and vice versa
1115
+			$start_date = min($start_date, $end_date);
1116
+			$end_date = max($start_date, $end_date);
1117
+			// convert for query
1118
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1119
+				'LOG_time',
1120
+				date('Y-m-d H:i:s', $start_date),
1121
+				'Y-m-d H:i:s'
1122
+			);
1123
+			$end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1124
+				'LOG_time',
1125
+				date('Y-m-d H:i:s', $end_date),
1126
+				'Y-m-d H:i:s'
1127
+			);
1128
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1129
+		}
1130
+		if ($count) {
1131
+			return EEM_Change_Log::instance()->count($query_params);
1132
+		}
1133
+		if (isset($this->_req_data['order'])) {
1134
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1135
+				? $this->_req_data['order']
1136
+				: 'DESC';
1137
+			$query_params['order_by'] = array('LOG_time' => $sort);
1138
+		} else {
1139
+			$query_params['order_by'] = array('LOG_time' => 'DESC');
1140
+		}
1141
+		$offset = ($current_page - 1) * $per_page;
1142
+		if (! isset($this->_req_data['download_results'])) {
1143
+			$query_params['limit'] = array($offset, $per_page);
1144
+		}
1145
+		// now they've requested to instead just download the file instead of viewing it.
1146
+		if (isset($this->_req_data['download_results'])) {
1147
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1148
+			header('Content-Disposition: attachment');
1149
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1150
+			echo '<h1> '
1151
+				. sprintf(
1152
+					esc_html__('Payment Logs for %1$s', 'event_espresso'),
1153
+					esc_url_raw(site_url())
1154
+				)
1155
+				. '</h1 >';
1156
+			echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1157
+			echo esc_html(var_export($query_params, true));
1158
+			echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1159
+			echo esc_html(var_export($wpdb_results, true));
1160
+			die;
1161
+		}
1162
+		return EEM_Change_Log::instance()->get_all($query_params);
1163
+	}
1164
+
1165
+
1166
+	/**
1167
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1168
+	 * because we're possibly combining the results from two queries
1169
+	 *
1170
+	 * @param EE_Change_Log $logA
1171
+	 * @param EE_Change_Log $logB
1172
+	 * @return int
1173
+	 * @throws EE_Error
1174
+	 * @throws ReflectionException
1175
+	 */
1176
+	protected function _sort_logs_again($logA, $logB)
1177
+	{
1178
+		$timeA = $logA->get_raw('LOG_time');
1179
+		$timeB = $logB->get_raw('LOG_time');
1180
+		if ($timeA == $timeB) {
1181
+			return 0;
1182
+		}
1183
+		$comparison = $timeA < $timeB ? -1 : 1;
1184
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1185
+			return $comparison * -1;
1186
+		}
1187
+		return $comparison;
1188
+	}
1189
+
1190
+
1191
+	/**
1192
+	 * @throws EE_Error
1193
+	 * @throws ReflectionException
1194
+	 */
1195
+	protected function _payment_log_details()
1196
+	{
1197
+		EE_Registry::instance()->load_model('Change_Log');
1198
+		/** @var $payment_log EE_Change_Log */
1199
+		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1200
+		$payment_method = null;
1201
+		$transaction = null;
1202
+		if ($payment_log instanceof EE_Change_Log) {
1203
+			if ($payment_log->object() instanceof EE_Payment) {
1204
+				$payment_method = $payment_log->object()->payment_method();
1205
+				$transaction = $payment_log->object()->transaction();
1206
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1207
+				$payment_method = $payment_log->object();
1208
+			} elseif ($payment_log->object() instanceof EE_Transaction) {
1209
+				$transaction = $payment_log->object();
1210
+				$payment_method = $transaction->payment_method();
1211
+			}
1212
+		}
1213
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1214
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1215
+			array(
1216
+				'payment_log'    => $payment_log,
1217
+				'payment_method' => $payment_method,
1218
+				'transaction'    => $transaction,
1219
+			),
1220
+			true
1221
+		);
1222
+		$this->display_admin_page_with_no_sidebar();
1223
+	}
1224 1224
 }
Please login to merge, or discard this patch.
admin_pages/about/About_Admin_Page.core.php 1 patch
Indentation   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -15,132 +15,132 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class About_Admin_Page extends EE_Admin_Page
17 17
 {
18
-    protected function _init_page_props()
19
-    {
20
-        $this->page_slug = EE_ABOUT_PG_SLUG;
21
-        $this->page_label = esc_html__('About Event Espresso', 'event_espresso');
22
-        $this->_admin_base_url = EE_ABOUT_ADMIN_URL;
23
-        $this->_admin_base_path = EE_ABOUT_ADMIN;
24
-    }
25
-
26
-
27
-    protected function _ajax_hooks()
28
-    {
29
-        // todo: all hooks for ajax goes here.
30
-    }
31
-
32
-
33
-    protected function _define_page_props()
34
-    {
35
-        $this->_labels = array();
36
-        $this->_admin_page_title = $this->page_label;
37
-    }
38
-
39
-
40
-    protected function _set_page_routes()
41
-    {
42
-        $this->_page_routes = array(
43
-            'default' => array(
44
-                'func'       => '_overview',
45
-                'capability' => 'manage_options',
46
-            ),
47
-            // 'overview' => '_overview',
48
-            // 'func' => '_overview',
49
-            // 'capability' => 'ee_read_ee'
50
-            // ),
51
-            'credits' => array(
52
-                'func'       => '_credits',
53
-                'capability' => 'manage_options',
54
-            ),
55
-
56
-            'decafvpro' => array(
57
-                'func'       => '_decafvpro',
58
-                'capability' => 'manage_options',
59
-            ),
60
-            'reviews'   => array(
61
-                'func'       => '_reviews',
62
-                'capability' => 'manage_options',
63
-            ),
64
-        );
65
-    }
66
-
67
-
68
-    protected function _set_page_config()
69
-    {
70
-        $this->_page_config = array(
71
-            /*'default' => array(
18
+	protected function _init_page_props()
19
+	{
20
+		$this->page_slug = EE_ABOUT_PG_SLUG;
21
+		$this->page_label = esc_html__('About Event Espresso', 'event_espresso');
22
+		$this->_admin_base_url = EE_ABOUT_ADMIN_URL;
23
+		$this->_admin_base_path = EE_ABOUT_ADMIN;
24
+	}
25
+
26
+
27
+	protected function _ajax_hooks()
28
+	{
29
+		// todo: all hooks for ajax goes here.
30
+	}
31
+
32
+
33
+	protected function _define_page_props()
34
+	{
35
+		$this->_labels = array();
36
+		$this->_admin_page_title = $this->page_label;
37
+	}
38
+
39
+
40
+	protected function _set_page_routes()
41
+	{
42
+		$this->_page_routes = array(
43
+			'default' => array(
44
+				'func'       => '_overview',
45
+				'capability' => 'manage_options',
46
+			),
47
+			// 'overview' => '_overview',
48
+			// 'func' => '_overview',
49
+			// 'capability' => 'ee_read_ee'
50
+			// ),
51
+			'credits' => array(
52
+				'func'       => '_credits',
53
+				'capability' => 'manage_options',
54
+			),
55
+
56
+			'decafvpro' => array(
57
+				'func'       => '_decafvpro',
58
+				'capability' => 'manage_options',
59
+			),
60
+			'reviews'   => array(
61
+				'func'       => '_reviews',
62
+				'capability' => 'manage_options',
63
+			),
64
+		);
65
+	}
66
+
67
+
68
+	protected function _set_page_config()
69
+	{
70
+		$this->_page_config = array(
71
+			/*'default' => array(
72 72
                 'nav' => array(
73 73
                     'label' => esc_html__('What\'s New', 'event_espresso'),
74 74
                     'order' => 10),
75 75
                 'require_nonce' => FALSE
76 76
                 ),*/
77
-            // 'overview' => array(
78
-            'default' => array(
79
-                'nav'           => array(
80
-                    'label' => esc_html__('About', 'event_espresso'),
81
-                    'icon' => 'dashicons-welcome-learn-more',
82
-                    'order' => 20,
83
-                ),
84
-                'require_nonce' => false,
85
-            ),
86
-            'credits' => array(
87
-                'nav'           => array(
88
-                    'label' => esc_html__('Credits', 'event_espresso'),
89
-                    'icon' => 'dashicons-thumbs-up',
90
-                    'order' => 30,
91
-                ),
92
-                'require_nonce' => false,
93
-            ),
94
-
95
-            'decafvpro' => array(
96
-                'nav'           => array(
97
-                    'label' => esc_html__('Decaf vs Regular', 'event_espresso'),
98
-                    'icon' => 'dashicons-editor-code',
99
-                    'order' => 40,
100
-                ),
101
-                'require_nonce' => false,
102
-            ),
103
-            'reviews'   => array(
104
-                'nav'           => array(
105
-                    'label' => esc_html__('Reviews', 'event_espresso'),
106
-                    'icon' => 'dashicons-star-filled',
107
-                    'order' => 50,
108
-                ),
109
-                'require_nonce' => false,
110
-            ),
111
-        );
112
-    }
113
-
114
-
115
-    // none of the below group are currently used for Support pages
116
-    protected function _add_screen_options()
117
-    {
118
-    }
119
-
120
-    protected function _add_feature_pointers()
121
-    {
122
-    }
123
-
124
-    public function admin_init()
125
-    {
126
-    }
127
-
128
-    public function admin_notices()
129
-    {
130
-    }
131
-
132
-    public function admin_footer_scripts()
133
-    {
134
-    }
135
-
136
-    public function load_scripts_styles()
137
-    {
138
-    }
139
-
140
-
141
-    protected function _whats_new()
142
-    {
143
-        /*$steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ? $this->_get_started_steps() : FALSE;
77
+			// 'overview' => array(
78
+			'default' => array(
79
+				'nav'           => array(
80
+					'label' => esc_html__('About', 'event_espresso'),
81
+					'icon' => 'dashicons-welcome-learn-more',
82
+					'order' => 20,
83
+				),
84
+				'require_nonce' => false,
85
+			),
86
+			'credits' => array(
87
+				'nav'           => array(
88
+					'label' => esc_html__('Credits', 'event_espresso'),
89
+					'icon' => 'dashicons-thumbs-up',
90
+					'order' => 30,
91
+				),
92
+				'require_nonce' => false,
93
+			),
94
+
95
+			'decafvpro' => array(
96
+				'nav'           => array(
97
+					'label' => esc_html__('Decaf vs Regular', 'event_espresso'),
98
+					'icon' => 'dashicons-editor-code',
99
+					'order' => 40,
100
+				),
101
+				'require_nonce' => false,
102
+			),
103
+			'reviews'   => array(
104
+				'nav'           => array(
105
+					'label' => esc_html__('Reviews', 'event_espresso'),
106
+					'icon' => 'dashicons-star-filled',
107
+					'order' => 50,
108
+				),
109
+				'require_nonce' => false,
110
+			),
111
+		);
112
+	}
113
+
114
+
115
+	// none of the below group are currently used for Support pages
116
+	protected function _add_screen_options()
117
+	{
118
+	}
119
+
120
+	protected function _add_feature_pointers()
121
+	{
122
+	}
123
+
124
+	public function admin_init()
125
+	{
126
+	}
127
+
128
+	public function admin_notices()
129
+	{
130
+	}
131
+
132
+	public function admin_footer_scripts()
133
+	{
134
+	}
135
+
136
+	public function load_scripts_styles()
137
+	{
138
+	}
139
+
140
+
141
+	protected function _whats_new()
142
+	{
143
+		/*$steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ? $this->_get_started_steps() : FALSE;
144 144
         $steps = $steps !== FALSE ? $steps : '';
145 145
         $this->_admin_page_title = sprintf( esc_html__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION );
146 146
         $settings_message = $steps;
@@ -148,168 +148,168 @@  discard block
 block discarded – undo
148 148
         $template = EE_ABOUT_TEMPLATE_PATH . 'whats_new.template.php';
149 149
         $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE );
150 150
         $this->display_about_admin_page();*/
151
-    }
151
+	}
152 152
 
153 153
 
154
-    protected function _overview()
155
-    {
156
-        /*$this->_template_args['admin_page_title'] = esc_html__('About Event Espresso', 'event_espresso');
154
+	protected function _overview()
155
+	{
156
+		/*$this->_template_args['admin_page_title'] = esc_html__('About Event Espresso', 'event_espresso');
157 157
         $this->_template_args['admin_page_subtitle'] = esc_html__('Thank you for choosing Event Espresso Decaf, the most powerful, and free, Event Management plugin for WordPress.', 'event_espresso');
158 158
         $template = EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php';
159 159
         $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE );
160 160
         $this->display_about_admin_page();*/
161 161
 
162
-        // Copied from _whats_new()
163
-        $steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance
164
-            ? $this->_get_started_steps() : false;
165
-        $steps = $steps !== false ? $steps : '';
166
-        $this->_admin_page_title = sprintf(
167
-            esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
168
-            EVENT_ESPRESSO_VERSION
169
-        );
170
-        $settings_message = $steps;
171
-        $this->_template_args['admin_page_subtitle'] = esc_html__(
172
-            'Thank you for choosing Event Espresso, the most powerful, and free, Event Management plugin for WordPress.',
173
-            'event_espresso'
174
-        ) . $settings_message;
175
-        $template = EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php';
176
-        $this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
177
-            $template,
178
-            $this->_template_args,
179
-            true
180
-        );
181
-        $this->display_about_admin_page();
182
-    }
183
-
184
-
185
-    protected function _get_started_steps()
186
-    {
187
-        $steps = '<h2>' . esc_html__('Getting Started', 'event_espresso') . '</h2>';
188
-        $step_one = '<p>'
189
-                    . sprintf(
190
-                        esc_html__(
191
-                            '%sStep 1%s: Visit your %sOrganization Settings%s and add/update your details.',
192
-                            'event_espresso'
193
-                        ),
194
-                        '<strong>',
195
-                        '</strong>',
196
-                        '<a href="admin.php?page=espresso_general_settings">',
197
-                        '</a>'
198
-                    ) . '</strong></p>';
199
-        $step_two = '<p>'
200
-                    . sprintf(
201
-                        esc_html__('%sStep 2%s: Setup your %sPayment Methods%s.', 'event_espresso'),
202
-                        '<strong>',
203
-                        '</strong>',
204
-                        '<a href="admin.php?page=espresso_payment_settings">',
205
-                        '</a>'
206
-                    ) . '</strong></p>';
207
-        $step_three = '<p>'
208
-                      . sprintf(
209
-                          esc_html__('%sStep 3%s: Create your %sFirst Event%s.', 'event_espresso'),
210
-                          '<strong>',
211
-                          '</strong>',
212
-                          '<a href="admin.php?page=espresso_events&action=create_new">',
213
-                          '</a>'
214
-                      ) . '</strong></p>';
215
-
216
-        // done?
217
-        $done_step_one = EE_Registry::instance()->CFG->organization->address_1 == '123 Onna Road' ? false : true;
218
-        $active_invoice_pm = EEM_Payment_Method::instance()->get_one_active(
219
-            EEM_Payment_Method::scope_cart,
220
-            array(array('PMD_type' => 'Invoice'))
221
-        );
222
-        $active_pms_count = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
223
-        // done step two if a non-invoice paymetn method is active; or there is more than one PM active, or
224
-        // if only the invoice is active but it's clearly been updated
225
-        $done_step_two = $active_pms_count > 1 ||
226
-                         ($active_pms_count === 1 && ! $active_invoice_pm) ||
227
-                         ($active_invoice_pm instanceof EE_Payment_Method && (
228
-                                 $active_invoice_pm->get_extra_meta('pdf_payee_name', true, '') ||
229
-                                 $active_invoice_pm->get_extra_meta('pdf_payee_email', true, '') ||
230
-                                 $active_invoice_pm->get_extra_meta('pdf_payee_tax_number', true, '') ||
231
-                                 $active_invoice_pm->get_extra_meta('pdf_payee_address', true, '') ||
232
-                                 $active_invoice_pm->get_extra_meta('page_extra_info', true, '')
233
-                             )
234
-                         );
235
-        $done_step_three = EE_Registry::instance()->load_model('Event')->count() > 0 ? true : false;
236
-
237
-        // if ALL steps are done, let's just return FALSE so we don't display anything
238
-        if ($done_step_one && $done_step_two && $done_step_three) {
239
-            return false;
240
-        }
241
-
242
-        // now let's put it together
243
-        $steps .= sprintf('%s' . $step_one . '%s', $done_step_one ? '<strike>' : '', $done_step_one ? '</strike>' : '');
244
-        $steps .= sprintf('%s' . $step_two . '%s', $done_step_two ? '<strike>' : '', $done_step_two ? '</strike>' : '');
245
-        $steps .= sprintf(
246
-            '%s' . $step_three . '%s',
247
-            $done_step_three ? '<strike>' : '',
248
-            $done_step_three ? '</strike>' : ''
249
-        );
250
-
251
-        return $steps;
252
-    }
253
-
254
-
255
-    protected function _credits()
256
-    {
257
-        $this->_template_args['admin_page_title'] = sprintf(
258
-            esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
259
-            EVENT_ESPRESSO_VERSION
260
-        );
261
-        $this->_template_args['admin_page_subtitle'] = esc_html__(
262
-            'Thank you for choosing Event Espresso Decaf, the most powerful, and free, Event Management plugin for WordPress.',
263
-            'event_espresso'
264
-        );
265
-        $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php';
266
-        $this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
267
-            $template,
268
-            $this->_template_args,
269
-            true
270
-        );
271
-        $this->display_about_admin_page();
272
-    }
273
-
274
-
275
-    protected function _decafvpro()
276
-    {
277
-        $this->_template_args['admin_page_title'] = sprintf(
278
-            esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
279
-            EVENT_ESPRESSO_VERSION
280
-        );
281
-        $this->_template_args['admin_page_subtitle'] = sprintf(
282
-            esc_html__(
283
-                'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s',
284
-                'event_espresso'
285
-            ),
286
-            '<em>',
287
-            '</em>',
288
-            '<strong>',
289
-            '</strong>'
290
-        );
291
-        $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php';
292
-        $this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
293
-            $template,
294
-            $this->_template_args,
295
-            true
296
-        );
297
-        $this->display_about_admin_page();
298
-    }
299
-
300
-    protected function _reviews()
301
-    {
302
-        $this->_template_args['admin_page_title'] = esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso');
303
-        $this->_template_args['admin_page_subtitle'] = esc_html__(
304
-            'At Event Espresso, customer satisfaction is our ultimate goal.',
305
-            'event_espresso'
306
-        );
307
-        $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php';
308
-        $this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
309
-            $template,
310
-            $this->_template_args,
311
-            true
312
-        );
313
-        $this->display_about_admin_page();
314
-    }
162
+		// Copied from _whats_new()
163
+		$steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance
164
+			? $this->_get_started_steps() : false;
165
+		$steps = $steps !== false ? $steps : '';
166
+		$this->_admin_page_title = sprintf(
167
+			esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
168
+			EVENT_ESPRESSO_VERSION
169
+		);
170
+		$settings_message = $steps;
171
+		$this->_template_args['admin_page_subtitle'] = esc_html__(
172
+			'Thank you for choosing Event Espresso, the most powerful, and free, Event Management plugin for WordPress.',
173
+			'event_espresso'
174
+		) . $settings_message;
175
+		$template = EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php';
176
+		$this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
177
+			$template,
178
+			$this->_template_args,
179
+			true
180
+		);
181
+		$this->display_about_admin_page();
182
+	}
183
+
184
+
185
+	protected function _get_started_steps()
186
+	{
187
+		$steps = '<h2>' . esc_html__('Getting Started', 'event_espresso') . '</h2>';
188
+		$step_one = '<p>'
189
+					. sprintf(
190
+						esc_html__(
191
+							'%sStep 1%s: Visit your %sOrganization Settings%s and add/update your details.',
192
+							'event_espresso'
193
+						),
194
+						'<strong>',
195
+						'</strong>',
196
+						'<a href="admin.php?page=espresso_general_settings">',
197
+						'</a>'
198
+					) . '</strong></p>';
199
+		$step_two = '<p>'
200
+					. sprintf(
201
+						esc_html__('%sStep 2%s: Setup your %sPayment Methods%s.', 'event_espresso'),
202
+						'<strong>',
203
+						'</strong>',
204
+						'<a href="admin.php?page=espresso_payment_settings">',
205
+						'</a>'
206
+					) . '</strong></p>';
207
+		$step_three = '<p>'
208
+					  . sprintf(
209
+						  esc_html__('%sStep 3%s: Create your %sFirst Event%s.', 'event_espresso'),
210
+						  '<strong>',
211
+						  '</strong>',
212
+						  '<a href="admin.php?page=espresso_events&action=create_new">',
213
+						  '</a>'
214
+					  ) . '</strong></p>';
215
+
216
+		// done?
217
+		$done_step_one = EE_Registry::instance()->CFG->organization->address_1 == '123 Onna Road' ? false : true;
218
+		$active_invoice_pm = EEM_Payment_Method::instance()->get_one_active(
219
+			EEM_Payment_Method::scope_cart,
220
+			array(array('PMD_type' => 'Invoice'))
221
+		);
222
+		$active_pms_count = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
223
+		// done step two if a non-invoice paymetn method is active; or there is more than one PM active, or
224
+		// if only the invoice is active but it's clearly been updated
225
+		$done_step_two = $active_pms_count > 1 ||
226
+						 ($active_pms_count === 1 && ! $active_invoice_pm) ||
227
+						 ($active_invoice_pm instanceof EE_Payment_Method && (
228
+								 $active_invoice_pm->get_extra_meta('pdf_payee_name', true, '') ||
229
+								 $active_invoice_pm->get_extra_meta('pdf_payee_email', true, '') ||
230
+								 $active_invoice_pm->get_extra_meta('pdf_payee_tax_number', true, '') ||
231
+								 $active_invoice_pm->get_extra_meta('pdf_payee_address', true, '') ||
232
+								 $active_invoice_pm->get_extra_meta('page_extra_info', true, '')
233
+							 )
234
+						 );
235
+		$done_step_three = EE_Registry::instance()->load_model('Event')->count() > 0 ? true : false;
236
+
237
+		// if ALL steps are done, let's just return FALSE so we don't display anything
238
+		if ($done_step_one && $done_step_two && $done_step_three) {
239
+			return false;
240
+		}
241
+
242
+		// now let's put it together
243
+		$steps .= sprintf('%s' . $step_one . '%s', $done_step_one ? '<strike>' : '', $done_step_one ? '</strike>' : '');
244
+		$steps .= sprintf('%s' . $step_two . '%s', $done_step_two ? '<strike>' : '', $done_step_two ? '</strike>' : '');
245
+		$steps .= sprintf(
246
+			'%s' . $step_three . '%s',
247
+			$done_step_three ? '<strike>' : '',
248
+			$done_step_three ? '</strike>' : ''
249
+		);
250
+
251
+		return $steps;
252
+	}
253
+
254
+
255
+	protected function _credits()
256
+	{
257
+		$this->_template_args['admin_page_title'] = sprintf(
258
+			esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
259
+			EVENT_ESPRESSO_VERSION
260
+		);
261
+		$this->_template_args['admin_page_subtitle'] = esc_html__(
262
+			'Thank you for choosing Event Espresso Decaf, the most powerful, and free, Event Management plugin for WordPress.',
263
+			'event_espresso'
264
+		);
265
+		$template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php';
266
+		$this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
267
+			$template,
268
+			$this->_template_args,
269
+			true
270
+		);
271
+		$this->display_about_admin_page();
272
+	}
273
+
274
+
275
+	protected function _decafvpro()
276
+	{
277
+		$this->_template_args['admin_page_title'] = sprintf(
278
+			esc_html__('Welcome to Event Espresso %s', 'event_espresso'),
279
+			EVENT_ESPRESSO_VERSION
280
+		);
281
+		$this->_template_args['admin_page_subtitle'] = sprintf(
282
+			esc_html__(
283
+				'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s',
284
+				'event_espresso'
285
+			),
286
+			'<em>',
287
+			'</em>',
288
+			'<strong>',
289
+			'</strong>'
290
+		);
291
+		$template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php';
292
+		$this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
293
+			$template,
294
+			$this->_template_args,
295
+			true
296
+		);
297
+		$this->display_about_admin_page();
298
+	}
299
+
300
+	protected function _reviews()
301
+	{
302
+		$this->_template_args['admin_page_title'] = esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso');
303
+		$this->_template_args['admin_page_subtitle'] = esc_html__(
304
+			'At Event Espresso, customer satisfaction is our ultimate goal.',
305
+			'event_espresso'
306
+		);
307
+		$template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php';
308
+		$this->_template_args['about_admin_page_content'] = EEH_Template::display_template(
309
+			$template,
310
+			$this->_template_args,
311
+			true
312
+		);
313
+		$this->display_about_admin_page();
314
+	}
315 315
 }
Please login to merge, or discard this patch.
admin_pages/about/templates/credits.template.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $tEEm_members = [
3
-    esc_html__('Founders', 'event_espresso') => [
4
-        'garth-koyle' => [
5
-            'email' => '[email protected]',
6
-            'name'  => 'Garth Koyle',
7
-            'desc'  => esc_html__('Co-Founder', 'event_espresso'),
8
-        ],
9
-    ],
10
-    esc_html__('Core Developers', 'event_espresso') => [
11
-        'brent-christensen' => [
12
-            'email' => '[email protected]',
13
-            'name'  => 'Brent Christensen',
14
-            'desc'  => esc_html__('Lead Developer', 'event_espresso'),
15
-        ],
16
-        'nazar-kolivoshka' => [
17
-            'email' => '[email protected]',
18
-            'name'  => 'Nazar Kolivoshka',
19
-            'desc'  => esc_html__('Core Developer', 'event_espresso'),
20
-        ],
21
-        'marlon-hario' => [
22
-            'email' => '[email protected]',
23
-            'name'  => 'Marlon Hario',
24
-            'desc'  => esc_html__('Core Developer', 'event_espresso'),
25
-        ],
26
-        'hossein-rafiei' => [
27
-            'email' => '[email protected]',
28
-            'name'  => 'Hossein Rafiei',
29
-            'desc'  => esc_html__('Core Developer', 'event_espresso'),
30
-        ],
31
-    ],
32
-    esc_html__('Support Staff', 'event_espresso') => [
33
-        'tony-warwick' => [
34
-            'email' => '[email protected]',
35
-            'name'  => 'Tony Warwick',
36
-            'desc'  => esc_html__('Support', 'event_espresso'),
37
-        ],
38
-        'lorenzo-caum' => [
39
-            'email' => '[email protected]',
40
-            'name'  => 'Lorenzo Caum',
41
-            'desc'  => esc_html__('Sales & Support', 'event_espresso'),
42
-        ],
43
-        'janice-gutierrez' => [
44
-            'email' => '[email protected]',
45
-            'name'  => 'Janice Gutierrez',
46
-            'desc'  => esc_html__('Support', 'event_espresso'),
47
-        ],
48
-        'chinny-love-verana' => [
49
-            'email' => '[email protected]',
50
-            'name'  => 'Chinny Love Verana',
51
-            'desc'  => esc_html__('Sales & Support', 'event_espresso'),
52
-        ],
53
-    ],
3
+	esc_html__('Founders', 'event_espresso') => [
4
+		'garth-koyle' => [
5
+			'email' => '[email protected]',
6
+			'name'  => 'Garth Koyle',
7
+			'desc'  => esc_html__('Co-Founder', 'event_espresso'),
8
+		],
9
+	],
10
+	esc_html__('Core Developers', 'event_espresso') => [
11
+		'brent-christensen' => [
12
+			'email' => '[email protected]',
13
+			'name'  => 'Brent Christensen',
14
+			'desc'  => esc_html__('Lead Developer', 'event_espresso'),
15
+		],
16
+		'nazar-kolivoshka' => [
17
+			'email' => '[email protected]',
18
+			'name'  => 'Nazar Kolivoshka',
19
+			'desc'  => esc_html__('Core Developer', 'event_espresso'),
20
+		],
21
+		'marlon-hario' => [
22
+			'email' => '[email protected]',
23
+			'name'  => 'Marlon Hario',
24
+			'desc'  => esc_html__('Core Developer', 'event_espresso'),
25
+		],
26
+		'hossein-rafiei' => [
27
+			'email' => '[email protected]',
28
+			'name'  => 'Hossein Rafiei',
29
+			'desc'  => esc_html__('Core Developer', 'event_espresso'),
30
+		],
31
+	],
32
+	esc_html__('Support Staff', 'event_espresso') => [
33
+		'tony-warwick' => [
34
+			'email' => '[email protected]',
35
+			'name'  => 'Tony Warwick',
36
+			'desc'  => esc_html__('Support', 'event_espresso'),
37
+		],
38
+		'lorenzo-caum' => [
39
+			'email' => '[email protected]',
40
+			'name'  => 'Lorenzo Caum',
41
+			'desc'  => esc_html__('Sales & Support', 'event_espresso'),
42
+		],
43
+		'janice-gutierrez' => [
44
+			'email' => '[email protected]',
45
+			'name'  => 'Janice Gutierrez',
46
+			'desc'  => esc_html__('Support', 'event_espresso'),
47
+		],
48
+		'chinny-love-verana' => [
49
+			'email' => '[email protected]',
50
+			'name'  => 'Chinny Love Verana',
51
+			'desc'  => esc_html__('Sales & Support', 'event_espresso'),
52
+		],
53
+	],
54 54
 ];
55 55
 
56 56
 function espressoPerson($id, $email, $name, $desc): string
57 57
 {
58
-    return '
58
+	return '
59 59
     <li class="ee-card ee-credits-person" id="ee-person-' . $id . '">
60 60
         <a href="' . esp_gravatar_profile($email) . '" target="_blank">
61 61
             ' . esp_gravatar_image($email, $name) . '
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 
70 70
 function esp_gravatar_profile($email)
71 71
 {
72
-    return esc_url_raw('https://www.gravatar.com/' . md5($email));
72
+	return esc_url_raw('https://www.gravatar.com/' . md5($email));
73 73
 }
74 74
 
75 75
 function esp_gravatar_image($email, $name)
76 76
 {
77
-    $email = md5($email);
78
-    $name  = esc_attr($name);
79
-    $url   = esc_url_raw("https://0.gravatar.com/avatar/{$email}?s=60");
80
-    return "<img src='{$url}' class='gravatar' alt='{$name}'/>";
77
+	$email = md5($email);
78
+	$name  = esc_attr($name);
79
+	$url   = esc_url_raw("https://0.gravatar.com/avatar/{$email}?s=60");
80
+	return "<img src='{$url}' class='gravatar' alt='{$name}'/>";
81 81
 }
82 82
 
83 83
 ?>
@@ -87,38 +87,38 @@  discard block
 block discarded – undo
87 87
 
88 88
         <h4>
89 89
             <?php esc_html_e(
90
-                'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!',
91
-                'event_espresso'
92
-            ); ?>
90
+				'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!',
91
+				'event_espresso'
92
+			); ?>
93 93
         </h4>
94 94
 
95 95
         <div class='ee-credits-tEEm'>
96 96
             <?php
97
-            foreach ($tEEm_members as $tEEm => $members) {
98
-                echo '
97
+			foreach ($tEEm_members as $tEEm => $members) {
98
+				echo '
99 99
             <h3 class="wp-people-group">' . $tEEm . '</h3>
100 100
             <ul class="ee-card-grid ee-card-grid-4-cols" id="' . sanitize_key($tEEm) . '">';
101
-                foreach ($members as $id => $person) {
102
-                    echo espressoPerson($id, $person['email'], $person['name'], $person['desc']);
103
-                }
104
-                echo '
101
+				foreach ($members as $id => $person) {
102
+					echo espressoPerson($id, $person['email'], $person['name'], $person['desc']);
103
+				}
104
+				echo '
105 105
             </ul>';
106
-            }
107
-            ?>
106
+			}
107
+			?>
108 108
         </div>
109 109
 
110 110
         <h3 class="wp-people-group"><?php esc_html_e('Contributor Recognition', 'event_espresso'); ?></h3>
111 111
         <p class="description">
112 112
             <?php
113
-            printf(
114
-                esc_html__(
115
-                    'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.',
116
-                    'event_espresso'
117
-                ),
118
-                '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub" target="_blank">',
119
-                '</a>'
120
-            );
121
-            ?>
113
+			printf(
114
+				esc_html__(
115
+					'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.',
116
+					'event_espresso'
117
+				),
118
+				'<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub" target="_blank">',
119
+				'</a>'
120
+			);
121
+			?>
122 122
         </p>
123 123
         <p class="wp-credits-list">
124 124
         <ul>
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
         <h3 class="wp-people-group"><?php esc_html_e('External Libraries', 'event_espresso'); ?></h3>
134 134
         <p class="description">
135 135
             <?php
136
-            printf(
137
-                esc_html__(
138
-                    'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:',
139
-                    'event_espresso'
140
-                ),
141
-                '<a href="credits.php">',
142
-                '</a>'
143
-            );
144
-            ?>
136
+			printf(
137
+				esc_html__(
138
+					'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:',
139
+					'event_espresso'
140
+				),
141
+				'<a href="credits.php">',
142
+				'</a>'
143
+			);
144
+			?>
145 145
         </p>
146 146
         <p class="wp-credits-list">
147 147
             <a href="https://openexchangerates.github.io/accounting.js/" target='_blank'>accounting.js</a>,
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,20 +56,20 @@  discard block
 block discarded – undo
56 56
 function espressoPerson($id, $email, $name, $desc): string
57 57
 {
58 58
     return '
59
-    <li class="ee-card ee-credits-person" id="ee-person-' . $id . '">
60
-        <a href="' . esp_gravatar_profile($email) . '" target="_blank">
61
-            ' . esp_gravatar_image($email, $name) . '
59
+    <li class="ee-card ee-credits-person" id="ee-person-' . $id.'">
60
+        <a href="' . esp_gravatar_profile($email).'" target="_blank">
61
+            ' . esp_gravatar_image($email, $name).'
62 62
         </a>
63 63
         <p>
64
-            <a class="web" href="' . esp_gravatar_profile($email) . '" target="_blank">' . $name . '</a>
65
-            <span class="title">' . $desc . '</span>
64
+            <a class="web" href="' . esp_gravatar_profile($email).'" target="_blank">'.$name.'</a>
65
+            <span class="title">' . $desc.'</span>
66 66
         </p>
67 67
     </li>';
68 68
 }
69 69
 
70 70
 function esp_gravatar_profile($email)
71 71
 {
72
-    return esc_url_raw('https://www.gravatar.com/' . md5($email));
72
+    return esc_url_raw('https://www.gravatar.com/'.md5($email));
73 73
 }
74 74
 
75 75
 function esp_gravatar_image($email, $name)
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
             <?php
97 97
             foreach ($tEEm_members as $tEEm => $members) {
98 98
                 echo '
99
-            <h3 class="wp-people-group">' . $tEEm . '</h3>
100
-            <ul class="ee-card-grid ee-card-grid-4-cols" id="' . sanitize_key($tEEm) . '">';
99
+            <h3 class="wp-people-group">' . $tEEm.'</h3>
100
+            <ul class="ee-card-grid ee-card-grid-4-cols" id="' . sanitize_key($tEEm).'">';
101 101
                 foreach ($members as $id => $person) {
102 102
                     echo espressoPerson($id, $person['email'], $person['name'], $person['desc']);
103 103
                 }
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page.core.php 1 patch
Indentation   +952 added lines, -952 removed lines patch added patch discarded remove patch
@@ -14,956 +14,956 @@
 block discarded – undo
14 14
  */
15 15
 class Maintenance_Admin_Page extends EE_Admin_Page
16 16
 {
17
-    /**
18
-     * @var EE_Data_Migration_Manager
19
-     */
20
-    protected $migration_manager;
21
-
22
-    /**
23
-     * @var EE_Maintenance_Mode
24
-     */
25
-    protected $maintenance_mode;
26
-
27
-    /**
28
-     * @var EE_Form_Section_Proper
29
-     */
30
-    protected $datetime_fix_offset_form;
31
-
32
-
33
-    /**
34
-     * @param bool $routing
35
-     * @throws EE_Error
36
-     * @throws ReflectionException
37
-     */
38
-    public function __construct($routing = true)
39
-    {
40
-        $this->migration_manager = EE_Data_Migration_Manager::instance();
41
-        $this->maintenance_mode  = EE_Maintenance_Mode::instance();
42
-        parent::__construct($routing);
43
-    }
44
-
45
-
46
-    protected function _init_page_props()
47
-    {
48
-        $this->page_slug        = EE_MAINTENANCE_PG_SLUG;
49
-        $this->page_label       = EE_MAINTENANCE_LABEL;
50
-        $this->_admin_base_url  = EE_MAINTENANCE_ADMIN_URL;
51
-        $this->_admin_base_path = EE_MAINTENANCE_ADMIN;
52
-    }
53
-
54
-
55
-    protected function _ajax_hooks()
56
-    {
57
-        add_action('wp_ajax_migration_step', [$this, 'migration_step']);
58
-        add_action('wp_ajax_add_error_to_migrations_ran', [$this, 'add_error_to_migrations_ran']);
59
-    }
60
-
61
-
62
-    protected function _define_page_props()
63
-    {
64
-        $this->_admin_page_title = EE_MAINTENANCE_LABEL;
65
-        $this->_labels           = [
66
-            'buttons' => [
67
-                'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
68
-                'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
69
-            ],
70
-        ];
71
-    }
72
-
73
-
74
-    protected function _set_page_routes()
75
-    {
76
-        $this->_page_routes = [
77
-            'default'                             => [
78
-                'func'       => '_maintenance',
79
-                'capability' => 'manage_options',
80
-            ],
81
-            'change_maintenance_level'            => [
82
-                'func'       => '_change_maintenance_level',
83
-                'capability' => 'manage_options',
84
-                'noheader'   => true,
85
-            ],
86
-            'system_status'                       => [
87
-                'func'       => '_system_status',
88
-                'capability' => 'manage_options',
89
-            ],
90
-            'download_system_status'              => [
91
-                'func'       => '_download_system_status',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ],
95
-            'send_migration_crash_report'         => [
96
-                'func'       => '_send_migration_crash_report',
97
-                'capability' => 'manage_options',
98
-                'noheader'   => true,
99
-            ],
100
-            'confirm_migration_crash_report_sent' => [
101
-                'func'       => '_confirm_migration_crash_report_sent',
102
-                'capability' => 'manage_options',
103
-            ],
104
-            'data_reset'                          => [
105
-                'func'       => '_data_reset_and_delete',
106
-                'capability' => 'manage_options',
107
-            ],
108
-            'reset_db'                            => [
109
-                'func'       => '_reset_db',
110
-                'capability' => 'manage_options',
111
-                'noheader'   => true,
112
-                'args'       => ['nuke_old_ee4_data' => true],
113
-            ],
114
-            'start_with_fresh_ee4_db'             => [
115
-                'func'       => '_reset_db',
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-                'args'       => ['nuke_old_ee4_data' => false],
119
-            ],
120
-            'delete_db'                           => [
121
-                'func'       => '_delete_db',
122
-                'capability' => 'manage_options',
123
-                'noheader'   => true,
124
-            ],
125
-            'rerun_migration_from_ee3'            => [
126
-                'func'       => '_rerun_migration_from_ee3',
127
-                'capability' => 'manage_options',
128
-                'noheader'   => true,
129
-            ],
130
-            'reset_reservations'                  => [
131
-                'func'       => '_reset_reservations',
132
-                'capability' => 'manage_options',
133
-                'noheader'   => true,
134
-            ],
135
-            'reset_capabilities'                  => [
136
-                'func'       => '_reset_capabilities',
137
-                'capability' => 'manage_options',
138
-                'noheader'   => true,
139
-            ],
140
-            'reattempt_migration'                 => [
141
-                'func'       => '_reattempt_migration',
142
-                'capability' => 'manage_options',
143
-                'noheader'   => true,
144
-            ],
145
-            'datetime_tools'                      => [
146
-                'func'       => '_datetime_tools',
147
-                'capability' => 'manage_options',
148
-            ],
149
-            'run_datetime_offset_fix'             => [
150
-                'func'               => '_apply_datetime_offset',
151
-                'noheader'           => true,
152
-                'headers_sent_route' => 'datetime_tools',
153
-                'capability'         => 'manage_options',
154
-            ],
155
-        ];
156
-    }
157
-
158
-
159
-    protected function _set_page_config()
160
-    {
161
-        $this->_page_config = [
162
-            'default'        => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Maintenance', 'event_espresso'),
165
-                    'icon' => 'dashicons-admin-tools',
166
-                    'order' => 10,
167
-                ],
168
-                'require_nonce' => false,
169
-            ],
170
-            'data_reset'     => [
171
-                'nav'           => [
172
-                    'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
173
-                    'icon' => 'dashicons-trash',
174
-                    'order' => 20,
175
-                ],
176
-                'require_nonce' => false,
177
-            ],
178
-            'datetime_tools' => [
179
-                'nav'           => [
180
-                    'label' => esc_html__('Datetime Utilities', 'event_espresso'),
181
-                    'icon' => 'dashicons-calendar-alt',
182
-                    'order' => 25,
183
-                ],
184
-                'require_nonce' => false,
185
-            ],
186
-            'system_status'  => [
187
-                'nav'           => [
188
-                    'label' => esc_html__("System Information", "event_espresso"),
189
-                    'icon' => 'dashicons-info',
190
-                    'order' => 30,
191
-                ],
192
-                'require_nonce' => false,
193
-            ],
194
-        ];
195
-    }
196
-
197
-
198
-    /**
199
-     * default maintenance page.
200
-     * If we're in maintenance mode level 2, then we need to show the migration scripts and all that UI.
201
-     *
202
-     * @throws EE_Error
203
-     */
204
-    public function _maintenance()
205
-    {
206
-        $show_maintenance_switch         = true;
207
-        $show_backup_db_text             = false;
208
-        $show_migration_progress         = false;
209
-        $script_names                    = [];
210
-        $addons_should_be_upgraded_first = false;
211
-        // it all depends on if we're in maintenance model level 1 (frontend-only) or
212
-        // level 2 (everything except maintenance page)
213
-        try {
214
-            // get the current maintenance level and check if
215
-            // we are removed
216
-            $mMode_level  = $this->maintenance_mode->level();
217
-            $placed_in_mm = $this->maintenance_mode->set_maintenance_mode_if_db_old();
218
-            if ($mMode_level == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
219
-                // we just took the site out of maintenance mode, so notify the user.
220
-                // unfortunately this message appears to be echoed on the NEXT page load...
221
-                // oh well, we should really be checking for this on addon deactivation anyways
222
-                EE_Error::add_attention(
223
-                    esc_html__(
224
-                        'Site taken out of maintenance mode because no data migration scripts are required',
225
-                        'event_espresso'
226
-                    )
227
-                );
228
-                $this->_process_notices(['page' => 'espresso_maintenance_settings']);
229
-            }
230
-            // in case an exception is thrown while trying to handle migrations
231
-            if ($mMode_level === EE_Maintenance_Mode::level_2_complete_maintenance) {
232
-                $show_maintenance_switch = false;
233
-                $show_migration_progress = true;
234
-                if (isset($this->_req_data['continue_migration'])) {
235
-                    $show_backup_db_text = false;
236
-                } else {
237
-                    $show_backup_db_text = true;
238
-                }
239
-                $scripts_needing_to_run          =
240
-                    $this->migration_manager->check_for_applicable_data_migration_scripts();
241
-                $addons_should_be_upgraded_first = $this->migration_manager->addons_need_updating();
242
-                $script_names                    = [];
243
-                $current_script                  = null;
244
-                foreach ($scripts_needing_to_run as $script) {
245
-                    if ($script instanceof EE_Data_Migration_Script_Base) {
246
-                        if (! $current_script) {
247
-                            $current_script = $script;
248
-                            $current_script->migration_page_hooks();
249
-                        }
250
-                        $script_names[] = $script->pretty_name();
251
-                    }
252
-                }
253
-            }
254
-            $most_recent_migration = $this->migration_manager->get_last_ran_script(true);
255
-            $exception_thrown      = false;
256
-        } catch (EE_Error $e) {
257
-            $this->migration_manager->add_error_to_migrations_ran($e->getMessage());
258
-            // now, just so we can display the page correctly, make an error migration script stage object
259
-            // and also put the error on it. It only persists for the duration of this request
260
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
261
-            $most_recent_migration->add_error($e->getMessage());
262
-            $exception_thrown = true;
263
-        }
264
-        $current_db_state = $this->migration_manager->ensure_current_database_state_is_set();
265
-        $current_db_state = str_replace('.decaf', '', $current_db_state);
266
-        if (
267
-            $exception_thrown
268
-            || (
269
-                $most_recent_migration instanceof EE_Data_Migration_Script_Base
270
-                && $most_recent_migration->is_broken()
271
-            )
272
-        ) {
273
-            $this->_template_path                =
274
-                EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
275
-            $this->_template_args['support_url'] = 'https://eventespresso.com/support/forums/';
276
-            $this->_template_args['next_url']    = EEH_URL::add_query_args_and_nonce(
277
-                [
278
-                    'action'  => 'confirm_migration_crash_report_sent',
279
-                    'success' => '0',
280
-                ],
281
-                EE_MAINTENANCE_ADMIN_URL
282
-            );
283
-        } elseif ($addons_should_be_upgraded_first) {
284
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
285
-        } else {
286
-            if (
287
-                $most_recent_migration instanceof EE_Data_Migration_Script_Base
288
-                && $most_recent_migration->can_continue()
289
-            ) {
290
-                $show_backup_db_text                    = false;
291
-                $show_continue_current_migration_script = true;
292
-                $show_most_recent_migration             = true;
293
-            } elseif (isset($this->_req_data['continue_migration'])) {
294
-                $show_most_recent_migration             = true;
295
-                $show_continue_current_migration_script = false;
296
-            } else {
297
-                $show_most_recent_migration             = false;
298
-                $show_continue_current_migration_script = false;
299
-            }
300
-            if (isset($current_script)) {
301
-                $migrates_to          = $current_script->migrates_to_version();
302
-                $plugin_slug          = $migrates_to['slug'];
303
-                $new_version          = $migrates_to['version'];
304
-                $this->_template_args = array_merge(
305
-                    $this->_template_args,
306
-                    [
307
-                        'current_db_state' => sprintf(
308
-                            esc_html__("EE%s (%s)", "event_espresso"),
309
-                            isset($current_db_state[ $plugin_slug ]) ? $current_db_state[ $plugin_slug ] : 3,
310
-                            $plugin_slug
311
-                        ),
312
-                        'next_db_state'    => sprintf(
313
-                            esc_html__("EE%s (%s)", 'event_espresso'),
314
-                            $new_version,
315
-                            $plugin_slug
316
-                        ),
317
-                    ]
318
-                );
319
-            } else {
320
-                $this->_template_args['current_db_state'] = null;
321
-                $this->_template_args['next_db_state']    = null;
322
-            }
323
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
324
-            $this->_template_args = array_merge(
325
-                $this->_template_args,
326
-                [
327
-                    'show_most_recent_migration'             => $show_most_recent_migration,
328
-                    // flag for showing the most recent migration's status and/or errors
329
-                    'show_migration_progress'                => $show_migration_progress,
330
-                    // flag for showing the option to run migrations and see their progress
331
-                    'show_backup_db_text'                    => $show_backup_db_text,
332
-                    // flag for showing text telling the user to back up their DB
333
-                    'show_maintenance_switch'                => $show_maintenance_switch,
334
-                    // flag for showing the option to change maintenance mode between levels 0 and 1
335
-                    'script_names'                           => $script_names,
336
-                    // array of names of scripts that have run
337
-                    'show_continue_current_migration_script' => $show_continue_current_migration_script,
338
-                    // flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
339
-                    'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(
340
-                        ['action' => 'reset_db'],
341
-                        EE_MAINTENANCE_ADMIN_URL
342
-                    ),
343
-                    'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(
344
-                        ['action' => 'data_reset'],
345
-                        EE_MAINTENANCE_ADMIN_URL
346
-                    ),
347
-                    'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(
348
-                        ['action' => 'change_maintenance_level'],
349
-                        EE_MAINTENANCE_ADMIN_URL
350
-                    ),
351
-                    'ultimate_db_state'                      => sprintf(
352
-                        esc_html__("EE%s", 'event_espresso'),
353
-                        espresso_version()
354
-                    ),
355
-                ]
356
-            );
357
-        }
358
-        $this->_template_args['most_recent_migration'] =
359
-            $most_recent_migration;// the actual most recently ran migration
360
-        // now render the migration options part, and put it in a variable
361
-        $migration_options_template_file                = apply_filters(
362
-            'FHEE__ee_migration_page__migration_options_template',
363
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
364
-        );
365
-        $migration_options_html                         = EEH_Template::display_template(
366
-            $migration_options_template_file,
367
-            $this->_template_args,
368
-            true
369
-        );
370
-        $this->_template_args['migration_options_html'] = $migration_options_html;
371
-        $this->_template_args['admin_page_content']     = EEH_Template::display_template(
372
-            $this->_template_path,
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * returns JSON and executes another step of the currently-executing data migration (called via ajax)
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    public function migration_step()
386
-    {
387
-        $this->_template_args['data'] = $this->migration_manager->response_to_migration_ajax_request();
388
-        $this->_return_json();
389
-    }
390
-
391
-
392
-    /**
393
-     * Can be used by js when it notices a response with HTML in it in order
394
-     * to log the malformed response
395
-     *
396
-     * @throws EE_Error
397
-     */
398
-    public function add_error_to_migrations_ran()
399
-    {
400
-        $this->migration_manager->add_error_to_migrations_ran($this->_req_data['message']);
401
-        $this->_template_args['data'] = ['ok' => true];
402
-        $this->_return_json();
403
-    }
404
-
405
-
406
-    /**
407
-     * changes the maintenance level, provided there are still no migration scripts that should run
408
-     *
409
-     * @throws EE_Error
410
-     */
411
-    public function _change_maintenance_level()
412
-    {
413
-        $new_level = absint($this->_req_data['maintenance_mode_level']);
414
-        if (! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
415
-            $this->maintenance_mode->set_maintenance_level($new_level);
416
-            $success = true;
417
-        } else {
418
-            $this->maintenance_mode->set_maintenance_mode_if_db_old();
419
-            $success = false;
420
-        }
421
-        $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
422
-    }
423
-
424
-
425
-    /**
426
-     * a tab with options for resetting and/or deleting EE data
427
-     *
428
-     * @throws EE_Error
429
-     * @throws DomainException
430
-     */
431
-    public function _data_reset_and_delete()
432
-    {
433
-        $this->_template_path                              =
434
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
435
-        $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
436
-            'reset_reservations',
437
-            'reset_reservations',
438
-            [],
439
-            'button button--caution ee-confirm'
440
-        );
441
-        $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
442
-            'reset_capabilities',
443
-            'reset_capabilities',
444
-            [],
445
-            'button button--caution ee-confirm'
446
-        );
447
-        $this->_template_args['delete_db_url']             = EE_Admin_Page::add_query_args_and_nonce(
448
-            ['action' => 'delete_db'],
449
-            EE_MAINTENANCE_ADMIN_URL
450
-        );
451
-        $this->_template_args['reset_db_url']              = EE_Admin_Page::add_query_args_and_nonce(
452
-            ['action' => 'reset_db'],
453
-            EE_MAINTENANCE_ADMIN_URL
454
-        );
455
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
456
-            $this->_template_path,
457
-            $this->_template_args,
458
-            true
459
-        );
460
-        $this->display_admin_page_with_no_sidebar();
461
-    }
462
-
463
-
464
-    /**
465
-     * @throws EE_Error
466
-     * @throws ReflectionException
467
-     */
468
-    protected function _reset_reservations()
469
-    {
470
-        if (EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
471
-            EE_Error::add_success(
472
-                esc_html__(
473
-                    'Ticket and datetime reserved counts have been successfully reset.',
474
-                    'event_espresso'
475
-                )
476
-            );
477
-        } else {
478
-            EE_Error::add_success(
479
-                esc_html__(
480
-                    'Ticket and datetime reserved counts were correct and did not need resetting.',
481
-                    'event_espresso'
482
-                )
483
-            );
484
-        }
485
-        $this->_redirect_after_action(true, '', '', ['action' => 'data_reset'], true);
486
-    }
487
-
488
-
489
-    /**
490
-     * @throws EE_Error
491
-     */
492
-    protected function _reset_capabilities()
493
-    {
494
-        EE_Registry::instance()->CAP->init_caps(true);
495
-        EE_Error::add_success(
496
-            esc_html__(
497
-                'Default Event Espresso capabilities have been restored for all current roles.',
498
-                'event_espresso'
499
-            )
500
-        );
501
-        $this->_redirect_after_action(false, '', '', ['action' => 'data_reset'], true);
502
-    }
503
-
504
-
505
-    /**
506
-     * resets the DMSs, so we can attempt to continue migrating after a fatal error
507
-     * (only a good idea when someone has somehow tried ot fix whatever caused
508
-     * the fatal error in teh first place)
509
-     *
510
-     * @throws EE_Error
511
-     */
512
-    protected function _reattempt_migration()
513
-    {
514
-        $this->migration_manager->reattempt();
515
-        $this->_redirect_after_action(false, '', '', ['action' => 'default'], true);
516
-    }
517
-
518
-
519
-    /**
520
-     * shows the big ol' System Information page
521
-     *
522
-     * @throws EE_Error
523
-     */
524
-    public function _system_status()
525
-    {
526
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
527
-        $this->_template_args['system_stati']               = EEM_System_Status::instance()->get_system_stati();
528
-        $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
529
-            [
530
-                'action' => 'download_system_status',
531
-            ],
532
-            EE_MAINTENANCE_ADMIN_URL
533
-        );
534
-        $this->_template_args['admin_page_content']         = EEH_Template::display_template(
535
-            $this->_template_path,
536
-            $this->_template_args,
537
-            true
538
-        );
539
-        $this->display_admin_page_with_no_sidebar();
540
-    }
541
-
542
-
543
-    /**
544
-     * Downloads an HTML file of the system status that can be easily stored or emailed
545
-     */
546
-    public function _download_system_status()
547
-    {
548
-        $status_info = EEM_System_Status::instance()->get_system_stati();
549
-        header('Content-Disposition: attachment');
550
-        header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html");
551
-        $output = '<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>';
552
-        $output .= '<h1>' . sprintf(
553
-            __('System Information for %1$s', 'event_espresso'),
554
-            esc_url_raw(site_url())
555
-        ) . '</h1>';
556
-        $output .= EEH_Template::layout_array_as_table($status_info);
557
-        echo esc_html($output);
558
-        die;
559
-    }
560
-
561
-
562
-    /**
563
-     * @throws EE_Error
564
-     */
565
-    public function _send_migration_crash_report()
566
-    {
567
-        $from      = $this->_req_data['from'];
568
-        $from_name = $this->_req_data['from_name'];
569
-        $body      = $this->_req_data['body'];
570
-        try {
571
-            $success = wp_mail(
572
-                EE_SUPPORT_EMAIL,
573
-                'Migration Crash Report',
574
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
575
-                [
576
-                    "from:$from_name<$from>",
577
-                ]
578
-            );
579
-        } catch (Exception $e) {
580
-            $success = false;
581
-        }
582
-        $this->_redirect_after_action(
583
-            $success,
584
-            esc_html__("Migration Crash Report", "event_espresso"),
585
-            esc_html__("sent", "event_espresso"),
586
-            ['success' => $success, 'action' => 'confirm_migration_crash_report_sent']
587
-        );
588
-    }
589
-
590
-
591
-    /**
592
-     * @throws EE_Error
593
-     */
594
-    public function _confirm_migration_crash_report_sent()
595
-    {
596
-        try {
597
-            $most_recent_migration = $this->migration_manager->get_last_ran_script(true);
598
-        } catch (EE_Error $e) {
599
-            $this->migration_manager->add_error_to_migrations_ran($e->getMessage());
600
-            // now, just so we can display the page correctly, make an error migration script stage object
601
-            // and also put the error on it. It only persists for the duration of this request
602
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
603
-            $most_recent_migration->add_error($e->getMessage());
604
-        }
605
-        $success                                       = $this->_req_data['success'] === '1';
606
-        $this->_template_args['success']               = $success;
607
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;
608
-        $this->_template_args['reset_db_action_url']   = EE_Admin_Page::add_query_args_and_nonce(
609
-            ['action' => 'reset_db'],
610
-            EE_MAINTENANCE_ADMIN_URL
611
-        );
612
-        $this->_template_args['reset_db_page_url']     = EE_Admin_Page::add_query_args_and_nonce(
613
-            ['action' => 'data_reset'],
614
-            EE_MAINTENANCE_ADMIN_URL
615
-        );
616
-        $this->_template_args['reattempt_action_url']  = EE_Admin_Page::add_query_args_and_nonce(
617
-            ['action' => 'reattempt_migration'],
618
-            EE_MAINTENANCE_ADMIN_URL
619
-        );
620
-        $this->_template_path                          =
621
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
622
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
623
-            $this->_template_path,
624
-            $this->_template_args,
625
-            true
626
-        );
627
-        $this->display_admin_page_with_sidebar();
628
-    }
629
-
630
-
631
-    /**
632
-     * Resets the entire EE4 database.
633
-     * only sets up ee4 database for a fresh install-
634
-     * doesn't actually clean out the old wp options, or cpts
635
-     * (although it does erase old ee table data)
636
-     *
637
-     * @param boolean $nuke_old_ee4_data controls whether we destroy the old ee4 data,
638
-     *                                   or just try initializing ee4 default data
639
-     * @throws EE_Error
640
-     * @throws ReflectionException
641
-     */
642
-    public function _reset_db($nuke_old_ee4_data = true)
643
-    {
644
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
645
-        if ($nuke_old_ee4_data) {
646
-            EEH_Activation::delete_all_espresso_cpt_data();
647
-            EEH_Activation::delete_all_espresso_tables_and_data(false);
648
-            EEH_Activation::remove_cron_tasks();
649
-        }
650
-        // make sure when we reset the registry's config that it
651
-        // switches to using the new singleton
652
-        EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
653
-        EE_System::instance()->initialize_db_if_no_migrations_required(true);
654
-        EE_System::instance()->redirect_to_about_ee();
655
-    }
656
-
657
-
658
-    /**
659
-     * Deletes ALL EE tables, Records, and Options from the database.
660
-     *
661
-     * @throws EE_Error
662
-     * @throws ReflectionException
663
-     */
664
-    public function _delete_db()
665
-    {
666
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
667
-        EEH_Activation::delete_all_espresso_cpt_data();
668
-        EEH_Activation::delete_all_espresso_tables_and_data();
669
-        EEH_Activation::remove_cron_tasks();
670
-        EEH_Activation::deactivate_event_espresso();
671
-        wp_safe_redirect(admin_url('plugins.php'));
672
-        exit;
673
-    }
674
-
675
-
676
-    /**
677
-     * sets up EE4 to rerun the migrations from ee3 to ee4
678
-     *
679
-     * @throws EE_Error
680
-     * @throws ReflectionException
681
-     */
682
-    public function _rerun_migration_from_ee3()
683
-    {
684
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
685
-        EEH_Activation::delete_all_espresso_cpt_data();
686
-        EEH_Activation::delete_all_espresso_tables_and_data(false);
687
-        // set the db state to something that will require migrations
688
-        update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
689
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
690
-        $this->_redirect_after_action(
691
-            true,
692
-            esc_html__("Database", 'event_espresso'),
693
-            esc_html__("reset", 'event_espresso')
694
-        );
695
-    }
696
-
697
-
698
-    // none of the below group are currently used for Gateway Settings
699
-    protected function _add_screen_options()
700
-    {
701
-    }
702
-
703
-
704
-    protected function _add_feature_pointers()
705
-    {
706
-    }
707
-
708
-
709
-    public function admin_init()
710
-    {
711
-    }
712
-
713
-
714
-    public function admin_notices()
715
-    {
716
-    }
717
-
718
-
719
-    public function admin_footer_scripts()
720
-    {
721
-    }
722
-
723
-
724
-    public function load_scripts_styles()
725
-    {
726
-        wp_enqueue_script('ee_admin_js');
727
-        wp_enqueue_script(
728
-            'ee-maintenance',
729
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',
730
-            ['jquery'],
731
-            EVENT_ESPRESSO_VERSION,
732
-            true
733
-        );
734
-        wp_register_style(
735
-            'espresso_maintenance',
736
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',
737
-            [],
738
-            EVENT_ESPRESSO_VERSION
739
-        );
740
-        wp_enqueue_style('espresso_maintenance');
741
-        // localize script stuff
742
-        wp_localize_script(
743
-            'ee-maintenance',
744
-            'ee_maintenance',
745
-            [
746
-                'migrating'                        => wp_strip_all_tags(__("Updating Database...", "event_espresso")),
747
-                'next'                             => wp_strip_all_tags(__("Next", "event_espresso")),
748
-                'fatal_error'                      => wp_strip_all_tags(__(
749
-                    "A Fatal Error Has Occurred",
750
-                    "event_espresso"
751
-                )),
752
-                'click_next_when_ready'            => wp_strip_all_tags(
753
-                    __(
754
-                        "The current Database Update has ended. Click 'next' when ready to proceed",
755
-                        "event_espresso"
756
-                    )
757
-                ),
758
-                'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
759
-                'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
760
-                'status_completed'                 => EE_Data_Migration_Manager::status_completed,
761
-                'confirm'                          => wp_strip_all_tags(
762
-                    __(
763
-                        'Are you sure you want to do this? It CANNOT be undone!',
764
-                        'event_espresso'
765
-                    )
766
-                ),
767
-                'confirm_skip_migration'           => wp_strip_all_tags(
768
-                    __(
769
-                        'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',
770
-                        'event_espresso'
771
-                    )
772
-                ),
773
-            ]
774
-        );
775
-    }
776
-
777
-
778
-    public function load_scripts_styles_default()
779
-    {
780
-    }
781
-
782
-
783
-    /**
784
-     * Enqueue scripts and styles for the datetime tools page.
785
-     */
786
-    public function load_scripts_styles_datetime_tools()
787
-    {
788
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
789
-    }
790
-
791
-
792
-    /**
793
-     * @throws EE_Error
794
-     */
795
-    protected function _datetime_tools()
796
-    {
797
-        $form_action                                = EE_Admin_Page::add_query_args_and_nonce(
798
-            [
799
-                'action'        => 'run_datetime_offset_fix',
800
-                'return_action' => $this->_req_action,
801
-            ],
802
-            EE_MAINTENANCE_ADMIN_URL
803
-        );
804
-        $form                                       = $this->_get_datetime_offset_fix_form();
805
-        $this->_admin_page_title                    = esc_html__('Datetime Utilities', 'event_espresso');
806
-        $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')
807
-                                                      . $form->get_html_and_js()
808
-                                                      . $form->form_close();
809
-        $this->display_admin_page_with_sidebar();
810
-    }
811
-
812
-
813
-    /**
814
-     * @throws EE_Error
815
-     */
816
-    protected function _get_datetime_offset_fix_form()
817
-    {
818
-        if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
819
-            $this->datetime_fix_offset_form = new EE_Form_Section_Proper(
820
-                [
821
-                    'name'            => 'datetime_offset_fix_option',
822
-                    'layout_strategy' => new EE_Admin_Two_Column_Layout(),
823
-                    'subsections'     => [
824
-                        'title'                  => new EE_Form_Section_HTML(
825
-                            EEH_HTML::h2(
826
-                                esc_html__('Datetime Offset Tool', 'event_espresso')
827
-                            )
828
-                        ),
829
-                        'explanation'            => new EE_Form_Section_HTML(
830
-                            EEH_HTML::p(
831
-                                esc_html__(
832
-                                    'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',
833
-                                    'event_espresso'
834
-                                )
835
-                            )
836
-                            . EEH_HTML::p(
837
-                                esc_html__(
838
-                                    'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied.  Decimals represent the fraction of hours, not minutes.',
839
-                                    'event_espresso'
840
-                                )
841
-                            )
842
-                        ),
843
-                        'offset_input'           => new EE_Float_Input(
844
-                            [
845
-                                'html_name'       => 'offset_for_datetimes',
846
-                                'html_label_text' => esc_html__(
847
-                                    'Offset to apply (in hours):',
848
-                                    'event_espresso'
849
-                                ),
850
-                                'min_value'       => '-12',
851
-                                'max_value'       => '14',
852
-                                'step_value'      => '.25',
853
-                                'default'         => DatetimeOffsetFix::getOffset(),
854
-                            ]
855
-                        ),
856
-                        'date_range_explanation' => new EE_Form_Section_HTML(
857
-                            EEH_HTML::p(
858
-                                esc_html__(
859
-                                    'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',
860
-                                    'event_espresso'
861
-                                )
862
-                            )
863
-                            . EEH_HTML::p(
864
-                                EEH_HTML::strong(
865
-                                    sprintf(
866
-                                        esc_html__(
867
-                                            'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',
868
-                                            'event_espresso'
869
-                                        ),
870
-                                        '<a href="https://www.timeanddate.com/worldclock/converter.html">',
871
-                                        '</a>'
872
-                                    )
873
-                                )
874
-                            )
875
-                        ),
876
-                        'date_range_start_date'  => new EE_Datepicker_Input(
877
-                            [
878
-                                'html_name'       => 'offset_date_start_range',
879
-                                'html_label_text' => esc_html__(
880
-                                    'Start Date for dates the offset applied to:',
881
-                                    'event_espresso'
882
-                                ),
883
-                            ]
884
-                        ),
885
-                        'date_range_end_date'    => new EE_Datepicker_Input(
886
-                            [
887
-                                'html_name'       => 'offset_date_end_range',
888
-                                'html_label_text' => esc_html__(
889
-                                    'End Date for dates the offset is applied to:',
890
-                                    'event_espresso'
891
-                                ),
892
-                            ]
893
-                        ),
894
-                        'submit'                 => new EE_Submit_Input(
895
-                            [
896
-                                'html_label_text' => '',
897
-                                'default'         => esc_html__('Apply Offset', 'event_espresso'),
898
-                            ]
899
-                        ),
900
-                    ],
901
-                ]
902
-            );
903
-        }
904
-        return $this->datetime_fix_offset_form;
905
-    }
906
-
907
-
908
-    /**
909
-     * Callback for the run_datetime_offset_fix route.
910
-     *
911
-     * @throws EE_Error
912
-     */
913
-    protected function _apply_datetime_offset()
914
-    {
915
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
916
-            $form = $this->_get_datetime_offset_fix_form();
917
-            $form->receive_form_submission($this->_req_data);
918
-            if ($form->is_valid()) {
919
-                // save offset data so batch processor can get it.
920
-                DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input'));
921
-                $utc_timezone          = new DateTimeZone('UTC');
922
-                $date_range_start_date = DateTime::createFromFormat(
923
-                    'm/d/Y H:i:s',
924
-                    $form->get_input_value('date_range_start_date') . ' 00:00:00',
925
-                    $utc_timezone
926
-                );
927
-                $date_range_end_date   = DateTime::createFromFormat(
928
-                    'm/d/Y H:i:s',
929
-                    $form->get_input_value('date_range_end_date') . ' 23:59:59',
930
-                    $utc_timezone
931
-                );
932
-                if ($date_range_start_date instanceof DateTime) {
933
-                    DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));
934
-                }
935
-                if ($date_range_end_date instanceof DateTime) {
936
-                    DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));
937
-                }
938
-                // redirect to batch tool
939
-                wp_redirect(
940
-                    EE_Admin_Page::add_query_args_and_nonce(
941
-                        [
942
-                            'page'        => EED_Batch::PAGE_SLUG,
943
-                            'batch'       => EED_Batch::batch_job,
944
-                            'label'       => esc_html__('Applying Offset', 'event_espresso'),
945
-                            'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'),
946
-                            'return_url'  => urlencode(
947
-                                add_query_arg(
948
-                                    [
949
-                                        'action' => 'datetime_tools',
950
-                                    ],
951
-                                    EEH_URL::current_url_without_query_paramaters(
952
-                                        [
953
-                                            'return_action',
954
-                                            'run_datetime_offset_fix_nonce',
955
-                                            'return',
956
-                                            'datetime_tools_nonce',
957
-                                        ]
958
-                                    )
959
-                                )
960
-                            ),
961
-                        ],
962
-                        admin_url()
963
-                    )
964
-                );
965
-                exit;
966
-            }
967
-        }
968
-    }
17
+	/**
18
+	 * @var EE_Data_Migration_Manager
19
+	 */
20
+	protected $migration_manager;
21
+
22
+	/**
23
+	 * @var EE_Maintenance_Mode
24
+	 */
25
+	protected $maintenance_mode;
26
+
27
+	/**
28
+	 * @var EE_Form_Section_Proper
29
+	 */
30
+	protected $datetime_fix_offset_form;
31
+
32
+
33
+	/**
34
+	 * @param bool $routing
35
+	 * @throws EE_Error
36
+	 * @throws ReflectionException
37
+	 */
38
+	public function __construct($routing = true)
39
+	{
40
+		$this->migration_manager = EE_Data_Migration_Manager::instance();
41
+		$this->maintenance_mode  = EE_Maintenance_Mode::instance();
42
+		parent::__construct($routing);
43
+	}
44
+
45
+
46
+	protected function _init_page_props()
47
+	{
48
+		$this->page_slug        = EE_MAINTENANCE_PG_SLUG;
49
+		$this->page_label       = EE_MAINTENANCE_LABEL;
50
+		$this->_admin_base_url  = EE_MAINTENANCE_ADMIN_URL;
51
+		$this->_admin_base_path = EE_MAINTENANCE_ADMIN;
52
+	}
53
+
54
+
55
+	protected function _ajax_hooks()
56
+	{
57
+		add_action('wp_ajax_migration_step', [$this, 'migration_step']);
58
+		add_action('wp_ajax_add_error_to_migrations_ran', [$this, 'add_error_to_migrations_ran']);
59
+	}
60
+
61
+
62
+	protected function _define_page_props()
63
+	{
64
+		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
65
+		$this->_labels           = [
66
+			'buttons' => [
67
+				'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
68
+				'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
69
+			],
70
+		];
71
+	}
72
+
73
+
74
+	protected function _set_page_routes()
75
+	{
76
+		$this->_page_routes = [
77
+			'default'                             => [
78
+				'func'       => '_maintenance',
79
+				'capability' => 'manage_options',
80
+			],
81
+			'change_maintenance_level'            => [
82
+				'func'       => '_change_maintenance_level',
83
+				'capability' => 'manage_options',
84
+				'noheader'   => true,
85
+			],
86
+			'system_status'                       => [
87
+				'func'       => '_system_status',
88
+				'capability' => 'manage_options',
89
+			],
90
+			'download_system_status'              => [
91
+				'func'       => '_download_system_status',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			],
95
+			'send_migration_crash_report'         => [
96
+				'func'       => '_send_migration_crash_report',
97
+				'capability' => 'manage_options',
98
+				'noheader'   => true,
99
+			],
100
+			'confirm_migration_crash_report_sent' => [
101
+				'func'       => '_confirm_migration_crash_report_sent',
102
+				'capability' => 'manage_options',
103
+			],
104
+			'data_reset'                          => [
105
+				'func'       => '_data_reset_and_delete',
106
+				'capability' => 'manage_options',
107
+			],
108
+			'reset_db'                            => [
109
+				'func'       => '_reset_db',
110
+				'capability' => 'manage_options',
111
+				'noheader'   => true,
112
+				'args'       => ['nuke_old_ee4_data' => true],
113
+			],
114
+			'start_with_fresh_ee4_db'             => [
115
+				'func'       => '_reset_db',
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+				'args'       => ['nuke_old_ee4_data' => false],
119
+			],
120
+			'delete_db'                           => [
121
+				'func'       => '_delete_db',
122
+				'capability' => 'manage_options',
123
+				'noheader'   => true,
124
+			],
125
+			'rerun_migration_from_ee3'            => [
126
+				'func'       => '_rerun_migration_from_ee3',
127
+				'capability' => 'manage_options',
128
+				'noheader'   => true,
129
+			],
130
+			'reset_reservations'                  => [
131
+				'func'       => '_reset_reservations',
132
+				'capability' => 'manage_options',
133
+				'noheader'   => true,
134
+			],
135
+			'reset_capabilities'                  => [
136
+				'func'       => '_reset_capabilities',
137
+				'capability' => 'manage_options',
138
+				'noheader'   => true,
139
+			],
140
+			'reattempt_migration'                 => [
141
+				'func'       => '_reattempt_migration',
142
+				'capability' => 'manage_options',
143
+				'noheader'   => true,
144
+			],
145
+			'datetime_tools'                      => [
146
+				'func'       => '_datetime_tools',
147
+				'capability' => 'manage_options',
148
+			],
149
+			'run_datetime_offset_fix'             => [
150
+				'func'               => '_apply_datetime_offset',
151
+				'noheader'           => true,
152
+				'headers_sent_route' => 'datetime_tools',
153
+				'capability'         => 'manage_options',
154
+			],
155
+		];
156
+	}
157
+
158
+
159
+	protected function _set_page_config()
160
+	{
161
+		$this->_page_config = [
162
+			'default'        => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Maintenance', 'event_espresso'),
165
+					'icon' => 'dashicons-admin-tools',
166
+					'order' => 10,
167
+				],
168
+				'require_nonce' => false,
169
+			],
170
+			'data_reset'     => [
171
+				'nav'           => [
172
+					'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
173
+					'icon' => 'dashicons-trash',
174
+					'order' => 20,
175
+				],
176
+				'require_nonce' => false,
177
+			],
178
+			'datetime_tools' => [
179
+				'nav'           => [
180
+					'label' => esc_html__('Datetime Utilities', 'event_espresso'),
181
+					'icon' => 'dashicons-calendar-alt',
182
+					'order' => 25,
183
+				],
184
+				'require_nonce' => false,
185
+			],
186
+			'system_status'  => [
187
+				'nav'           => [
188
+					'label' => esc_html__("System Information", "event_espresso"),
189
+					'icon' => 'dashicons-info',
190
+					'order' => 30,
191
+				],
192
+				'require_nonce' => false,
193
+			],
194
+		];
195
+	}
196
+
197
+
198
+	/**
199
+	 * default maintenance page.
200
+	 * If we're in maintenance mode level 2, then we need to show the migration scripts and all that UI.
201
+	 *
202
+	 * @throws EE_Error
203
+	 */
204
+	public function _maintenance()
205
+	{
206
+		$show_maintenance_switch         = true;
207
+		$show_backup_db_text             = false;
208
+		$show_migration_progress         = false;
209
+		$script_names                    = [];
210
+		$addons_should_be_upgraded_first = false;
211
+		// it all depends on if we're in maintenance model level 1 (frontend-only) or
212
+		// level 2 (everything except maintenance page)
213
+		try {
214
+			// get the current maintenance level and check if
215
+			// we are removed
216
+			$mMode_level  = $this->maintenance_mode->level();
217
+			$placed_in_mm = $this->maintenance_mode->set_maintenance_mode_if_db_old();
218
+			if ($mMode_level == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
219
+				// we just took the site out of maintenance mode, so notify the user.
220
+				// unfortunately this message appears to be echoed on the NEXT page load...
221
+				// oh well, we should really be checking for this on addon deactivation anyways
222
+				EE_Error::add_attention(
223
+					esc_html__(
224
+						'Site taken out of maintenance mode because no data migration scripts are required',
225
+						'event_espresso'
226
+					)
227
+				);
228
+				$this->_process_notices(['page' => 'espresso_maintenance_settings']);
229
+			}
230
+			// in case an exception is thrown while trying to handle migrations
231
+			if ($mMode_level === EE_Maintenance_Mode::level_2_complete_maintenance) {
232
+				$show_maintenance_switch = false;
233
+				$show_migration_progress = true;
234
+				if (isset($this->_req_data['continue_migration'])) {
235
+					$show_backup_db_text = false;
236
+				} else {
237
+					$show_backup_db_text = true;
238
+				}
239
+				$scripts_needing_to_run          =
240
+					$this->migration_manager->check_for_applicable_data_migration_scripts();
241
+				$addons_should_be_upgraded_first = $this->migration_manager->addons_need_updating();
242
+				$script_names                    = [];
243
+				$current_script                  = null;
244
+				foreach ($scripts_needing_to_run as $script) {
245
+					if ($script instanceof EE_Data_Migration_Script_Base) {
246
+						if (! $current_script) {
247
+							$current_script = $script;
248
+							$current_script->migration_page_hooks();
249
+						}
250
+						$script_names[] = $script->pretty_name();
251
+					}
252
+				}
253
+			}
254
+			$most_recent_migration = $this->migration_manager->get_last_ran_script(true);
255
+			$exception_thrown      = false;
256
+		} catch (EE_Error $e) {
257
+			$this->migration_manager->add_error_to_migrations_ran($e->getMessage());
258
+			// now, just so we can display the page correctly, make an error migration script stage object
259
+			// and also put the error on it. It only persists for the duration of this request
260
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
261
+			$most_recent_migration->add_error($e->getMessage());
262
+			$exception_thrown = true;
263
+		}
264
+		$current_db_state = $this->migration_manager->ensure_current_database_state_is_set();
265
+		$current_db_state = str_replace('.decaf', '', $current_db_state);
266
+		if (
267
+			$exception_thrown
268
+			|| (
269
+				$most_recent_migration instanceof EE_Data_Migration_Script_Base
270
+				&& $most_recent_migration->is_broken()
271
+			)
272
+		) {
273
+			$this->_template_path                =
274
+				EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
275
+			$this->_template_args['support_url'] = 'https://eventespresso.com/support/forums/';
276
+			$this->_template_args['next_url']    = EEH_URL::add_query_args_and_nonce(
277
+				[
278
+					'action'  => 'confirm_migration_crash_report_sent',
279
+					'success' => '0',
280
+				],
281
+				EE_MAINTENANCE_ADMIN_URL
282
+			);
283
+		} elseif ($addons_should_be_upgraded_first) {
284
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
285
+		} else {
286
+			if (
287
+				$most_recent_migration instanceof EE_Data_Migration_Script_Base
288
+				&& $most_recent_migration->can_continue()
289
+			) {
290
+				$show_backup_db_text                    = false;
291
+				$show_continue_current_migration_script = true;
292
+				$show_most_recent_migration             = true;
293
+			} elseif (isset($this->_req_data['continue_migration'])) {
294
+				$show_most_recent_migration             = true;
295
+				$show_continue_current_migration_script = false;
296
+			} else {
297
+				$show_most_recent_migration             = false;
298
+				$show_continue_current_migration_script = false;
299
+			}
300
+			if (isset($current_script)) {
301
+				$migrates_to          = $current_script->migrates_to_version();
302
+				$plugin_slug          = $migrates_to['slug'];
303
+				$new_version          = $migrates_to['version'];
304
+				$this->_template_args = array_merge(
305
+					$this->_template_args,
306
+					[
307
+						'current_db_state' => sprintf(
308
+							esc_html__("EE%s (%s)", "event_espresso"),
309
+							isset($current_db_state[ $plugin_slug ]) ? $current_db_state[ $plugin_slug ] : 3,
310
+							$plugin_slug
311
+						),
312
+						'next_db_state'    => sprintf(
313
+							esc_html__("EE%s (%s)", 'event_espresso'),
314
+							$new_version,
315
+							$plugin_slug
316
+						),
317
+					]
318
+				);
319
+			} else {
320
+				$this->_template_args['current_db_state'] = null;
321
+				$this->_template_args['next_db_state']    = null;
322
+			}
323
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
324
+			$this->_template_args = array_merge(
325
+				$this->_template_args,
326
+				[
327
+					'show_most_recent_migration'             => $show_most_recent_migration,
328
+					// flag for showing the most recent migration's status and/or errors
329
+					'show_migration_progress'                => $show_migration_progress,
330
+					// flag for showing the option to run migrations and see their progress
331
+					'show_backup_db_text'                    => $show_backup_db_text,
332
+					// flag for showing text telling the user to back up their DB
333
+					'show_maintenance_switch'                => $show_maintenance_switch,
334
+					// flag for showing the option to change maintenance mode between levels 0 and 1
335
+					'script_names'                           => $script_names,
336
+					// array of names of scripts that have run
337
+					'show_continue_current_migration_script' => $show_continue_current_migration_script,
338
+					// flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
339
+					'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(
340
+						['action' => 'reset_db'],
341
+						EE_MAINTENANCE_ADMIN_URL
342
+					),
343
+					'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(
344
+						['action' => 'data_reset'],
345
+						EE_MAINTENANCE_ADMIN_URL
346
+					),
347
+					'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(
348
+						['action' => 'change_maintenance_level'],
349
+						EE_MAINTENANCE_ADMIN_URL
350
+					),
351
+					'ultimate_db_state'                      => sprintf(
352
+						esc_html__("EE%s", 'event_espresso'),
353
+						espresso_version()
354
+					),
355
+				]
356
+			);
357
+		}
358
+		$this->_template_args['most_recent_migration'] =
359
+			$most_recent_migration;// the actual most recently ran migration
360
+		// now render the migration options part, and put it in a variable
361
+		$migration_options_template_file                = apply_filters(
362
+			'FHEE__ee_migration_page__migration_options_template',
363
+			EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
364
+		);
365
+		$migration_options_html                         = EEH_Template::display_template(
366
+			$migration_options_template_file,
367
+			$this->_template_args,
368
+			true
369
+		);
370
+		$this->_template_args['migration_options_html'] = $migration_options_html;
371
+		$this->_template_args['admin_page_content']     = EEH_Template::display_template(
372
+			$this->_template_path,
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	public function migration_step()
386
+	{
387
+		$this->_template_args['data'] = $this->migration_manager->response_to_migration_ajax_request();
388
+		$this->_return_json();
389
+	}
390
+
391
+
392
+	/**
393
+	 * Can be used by js when it notices a response with HTML in it in order
394
+	 * to log the malformed response
395
+	 *
396
+	 * @throws EE_Error
397
+	 */
398
+	public function add_error_to_migrations_ran()
399
+	{
400
+		$this->migration_manager->add_error_to_migrations_ran($this->_req_data['message']);
401
+		$this->_template_args['data'] = ['ok' => true];
402
+		$this->_return_json();
403
+	}
404
+
405
+
406
+	/**
407
+	 * changes the maintenance level, provided there are still no migration scripts that should run
408
+	 *
409
+	 * @throws EE_Error
410
+	 */
411
+	public function _change_maintenance_level()
412
+	{
413
+		$new_level = absint($this->_req_data['maintenance_mode_level']);
414
+		if (! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
415
+			$this->maintenance_mode->set_maintenance_level($new_level);
416
+			$success = true;
417
+		} else {
418
+			$this->maintenance_mode->set_maintenance_mode_if_db_old();
419
+			$success = false;
420
+		}
421
+		$this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
422
+	}
423
+
424
+
425
+	/**
426
+	 * a tab with options for resetting and/or deleting EE data
427
+	 *
428
+	 * @throws EE_Error
429
+	 * @throws DomainException
430
+	 */
431
+	public function _data_reset_and_delete()
432
+	{
433
+		$this->_template_path                              =
434
+			EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
435
+		$this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
436
+			'reset_reservations',
437
+			'reset_reservations',
438
+			[],
439
+			'button button--caution ee-confirm'
440
+		);
441
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
442
+			'reset_capabilities',
443
+			'reset_capabilities',
444
+			[],
445
+			'button button--caution ee-confirm'
446
+		);
447
+		$this->_template_args['delete_db_url']             = EE_Admin_Page::add_query_args_and_nonce(
448
+			['action' => 'delete_db'],
449
+			EE_MAINTENANCE_ADMIN_URL
450
+		);
451
+		$this->_template_args['reset_db_url']              = EE_Admin_Page::add_query_args_and_nonce(
452
+			['action' => 'reset_db'],
453
+			EE_MAINTENANCE_ADMIN_URL
454
+		);
455
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
456
+			$this->_template_path,
457
+			$this->_template_args,
458
+			true
459
+		);
460
+		$this->display_admin_page_with_no_sidebar();
461
+	}
462
+
463
+
464
+	/**
465
+	 * @throws EE_Error
466
+	 * @throws ReflectionException
467
+	 */
468
+	protected function _reset_reservations()
469
+	{
470
+		if (EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
471
+			EE_Error::add_success(
472
+				esc_html__(
473
+					'Ticket and datetime reserved counts have been successfully reset.',
474
+					'event_espresso'
475
+				)
476
+			);
477
+		} else {
478
+			EE_Error::add_success(
479
+				esc_html__(
480
+					'Ticket and datetime reserved counts were correct and did not need resetting.',
481
+					'event_espresso'
482
+				)
483
+			);
484
+		}
485
+		$this->_redirect_after_action(true, '', '', ['action' => 'data_reset'], true);
486
+	}
487
+
488
+
489
+	/**
490
+	 * @throws EE_Error
491
+	 */
492
+	protected function _reset_capabilities()
493
+	{
494
+		EE_Registry::instance()->CAP->init_caps(true);
495
+		EE_Error::add_success(
496
+			esc_html__(
497
+				'Default Event Espresso capabilities have been restored for all current roles.',
498
+				'event_espresso'
499
+			)
500
+		);
501
+		$this->_redirect_after_action(false, '', '', ['action' => 'data_reset'], true);
502
+	}
503
+
504
+
505
+	/**
506
+	 * resets the DMSs, so we can attempt to continue migrating after a fatal error
507
+	 * (only a good idea when someone has somehow tried ot fix whatever caused
508
+	 * the fatal error in teh first place)
509
+	 *
510
+	 * @throws EE_Error
511
+	 */
512
+	protected function _reattempt_migration()
513
+	{
514
+		$this->migration_manager->reattempt();
515
+		$this->_redirect_after_action(false, '', '', ['action' => 'default'], true);
516
+	}
517
+
518
+
519
+	/**
520
+	 * shows the big ol' System Information page
521
+	 *
522
+	 * @throws EE_Error
523
+	 */
524
+	public function _system_status()
525
+	{
526
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
527
+		$this->_template_args['system_stati']               = EEM_System_Status::instance()->get_system_stati();
528
+		$this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
529
+			[
530
+				'action' => 'download_system_status',
531
+			],
532
+			EE_MAINTENANCE_ADMIN_URL
533
+		);
534
+		$this->_template_args['admin_page_content']         = EEH_Template::display_template(
535
+			$this->_template_path,
536
+			$this->_template_args,
537
+			true
538
+		);
539
+		$this->display_admin_page_with_no_sidebar();
540
+	}
541
+
542
+
543
+	/**
544
+	 * Downloads an HTML file of the system status that can be easily stored or emailed
545
+	 */
546
+	public function _download_system_status()
547
+	{
548
+		$status_info = EEM_System_Status::instance()->get_system_stati();
549
+		header('Content-Disposition: attachment');
550
+		header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html");
551
+		$output = '<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>';
552
+		$output .= '<h1>' . sprintf(
553
+			__('System Information for %1$s', 'event_espresso'),
554
+			esc_url_raw(site_url())
555
+		) . '</h1>';
556
+		$output .= EEH_Template::layout_array_as_table($status_info);
557
+		echo esc_html($output);
558
+		die;
559
+	}
560
+
561
+
562
+	/**
563
+	 * @throws EE_Error
564
+	 */
565
+	public function _send_migration_crash_report()
566
+	{
567
+		$from      = $this->_req_data['from'];
568
+		$from_name = $this->_req_data['from_name'];
569
+		$body      = $this->_req_data['body'];
570
+		try {
571
+			$success = wp_mail(
572
+				EE_SUPPORT_EMAIL,
573
+				'Migration Crash Report',
574
+				$body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
575
+				[
576
+					"from:$from_name<$from>",
577
+				]
578
+			);
579
+		} catch (Exception $e) {
580
+			$success = false;
581
+		}
582
+		$this->_redirect_after_action(
583
+			$success,
584
+			esc_html__("Migration Crash Report", "event_espresso"),
585
+			esc_html__("sent", "event_espresso"),
586
+			['success' => $success, 'action' => 'confirm_migration_crash_report_sent']
587
+		);
588
+	}
589
+
590
+
591
+	/**
592
+	 * @throws EE_Error
593
+	 */
594
+	public function _confirm_migration_crash_report_sent()
595
+	{
596
+		try {
597
+			$most_recent_migration = $this->migration_manager->get_last_ran_script(true);
598
+		} catch (EE_Error $e) {
599
+			$this->migration_manager->add_error_to_migrations_ran($e->getMessage());
600
+			// now, just so we can display the page correctly, make an error migration script stage object
601
+			// and also put the error on it. It only persists for the duration of this request
602
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
603
+			$most_recent_migration->add_error($e->getMessage());
604
+		}
605
+		$success                                       = $this->_req_data['success'] === '1';
606
+		$this->_template_args['success']               = $success;
607
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
608
+		$this->_template_args['reset_db_action_url']   = EE_Admin_Page::add_query_args_and_nonce(
609
+			['action' => 'reset_db'],
610
+			EE_MAINTENANCE_ADMIN_URL
611
+		);
612
+		$this->_template_args['reset_db_page_url']     = EE_Admin_Page::add_query_args_and_nonce(
613
+			['action' => 'data_reset'],
614
+			EE_MAINTENANCE_ADMIN_URL
615
+		);
616
+		$this->_template_args['reattempt_action_url']  = EE_Admin_Page::add_query_args_and_nonce(
617
+			['action' => 'reattempt_migration'],
618
+			EE_MAINTENANCE_ADMIN_URL
619
+		);
620
+		$this->_template_path                          =
621
+			EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
622
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
623
+			$this->_template_path,
624
+			$this->_template_args,
625
+			true
626
+		);
627
+		$this->display_admin_page_with_sidebar();
628
+	}
629
+
630
+
631
+	/**
632
+	 * Resets the entire EE4 database.
633
+	 * only sets up ee4 database for a fresh install-
634
+	 * doesn't actually clean out the old wp options, or cpts
635
+	 * (although it does erase old ee table data)
636
+	 *
637
+	 * @param boolean $nuke_old_ee4_data controls whether we destroy the old ee4 data,
638
+	 *                                   or just try initializing ee4 default data
639
+	 * @throws EE_Error
640
+	 * @throws ReflectionException
641
+	 */
642
+	public function _reset_db($nuke_old_ee4_data = true)
643
+	{
644
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
645
+		if ($nuke_old_ee4_data) {
646
+			EEH_Activation::delete_all_espresso_cpt_data();
647
+			EEH_Activation::delete_all_espresso_tables_and_data(false);
648
+			EEH_Activation::remove_cron_tasks();
649
+		}
650
+		// make sure when we reset the registry's config that it
651
+		// switches to using the new singleton
652
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
653
+		EE_System::instance()->initialize_db_if_no_migrations_required(true);
654
+		EE_System::instance()->redirect_to_about_ee();
655
+	}
656
+
657
+
658
+	/**
659
+	 * Deletes ALL EE tables, Records, and Options from the database.
660
+	 *
661
+	 * @throws EE_Error
662
+	 * @throws ReflectionException
663
+	 */
664
+	public function _delete_db()
665
+	{
666
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
667
+		EEH_Activation::delete_all_espresso_cpt_data();
668
+		EEH_Activation::delete_all_espresso_tables_and_data();
669
+		EEH_Activation::remove_cron_tasks();
670
+		EEH_Activation::deactivate_event_espresso();
671
+		wp_safe_redirect(admin_url('plugins.php'));
672
+		exit;
673
+	}
674
+
675
+
676
+	/**
677
+	 * sets up EE4 to rerun the migrations from ee3 to ee4
678
+	 *
679
+	 * @throws EE_Error
680
+	 * @throws ReflectionException
681
+	 */
682
+	public function _rerun_migration_from_ee3()
683
+	{
684
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
685
+		EEH_Activation::delete_all_espresso_cpt_data();
686
+		EEH_Activation::delete_all_espresso_tables_and_data(false);
687
+		// set the db state to something that will require migrations
688
+		update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
689
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
690
+		$this->_redirect_after_action(
691
+			true,
692
+			esc_html__("Database", 'event_espresso'),
693
+			esc_html__("reset", 'event_espresso')
694
+		);
695
+	}
696
+
697
+
698
+	// none of the below group are currently used for Gateway Settings
699
+	protected function _add_screen_options()
700
+	{
701
+	}
702
+
703
+
704
+	protected function _add_feature_pointers()
705
+	{
706
+	}
707
+
708
+
709
+	public function admin_init()
710
+	{
711
+	}
712
+
713
+
714
+	public function admin_notices()
715
+	{
716
+	}
717
+
718
+
719
+	public function admin_footer_scripts()
720
+	{
721
+	}
722
+
723
+
724
+	public function load_scripts_styles()
725
+	{
726
+		wp_enqueue_script('ee_admin_js');
727
+		wp_enqueue_script(
728
+			'ee-maintenance',
729
+			EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',
730
+			['jquery'],
731
+			EVENT_ESPRESSO_VERSION,
732
+			true
733
+		);
734
+		wp_register_style(
735
+			'espresso_maintenance',
736
+			EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',
737
+			[],
738
+			EVENT_ESPRESSO_VERSION
739
+		);
740
+		wp_enqueue_style('espresso_maintenance');
741
+		// localize script stuff
742
+		wp_localize_script(
743
+			'ee-maintenance',
744
+			'ee_maintenance',
745
+			[
746
+				'migrating'                        => wp_strip_all_tags(__("Updating Database...", "event_espresso")),
747
+				'next'                             => wp_strip_all_tags(__("Next", "event_espresso")),
748
+				'fatal_error'                      => wp_strip_all_tags(__(
749
+					"A Fatal Error Has Occurred",
750
+					"event_espresso"
751
+				)),
752
+				'click_next_when_ready'            => wp_strip_all_tags(
753
+					__(
754
+						"The current Database Update has ended. Click 'next' when ready to proceed",
755
+						"event_espresso"
756
+					)
757
+				),
758
+				'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
759
+				'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
760
+				'status_completed'                 => EE_Data_Migration_Manager::status_completed,
761
+				'confirm'                          => wp_strip_all_tags(
762
+					__(
763
+						'Are you sure you want to do this? It CANNOT be undone!',
764
+						'event_espresso'
765
+					)
766
+				),
767
+				'confirm_skip_migration'           => wp_strip_all_tags(
768
+					__(
769
+						'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',
770
+						'event_espresso'
771
+					)
772
+				),
773
+			]
774
+		);
775
+	}
776
+
777
+
778
+	public function load_scripts_styles_default()
779
+	{
780
+	}
781
+
782
+
783
+	/**
784
+	 * Enqueue scripts and styles for the datetime tools page.
785
+	 */
786
+	public function load_scripts_styles_datetime_tools()
787
+	{
788
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
789
+	}
790
+
791
+
792
+	/**
793
+	 * @throws EE_Error
794
+	 */
795
+	protected function _datetime_tools()
796
+	{
797
+		$form_action                                = EE_Admin_Page::add_query_args_and_nonce(
798
+			[
799
+				'action'        => 'run_datetime_offset_fix',
800
+				'return_action' => $this->_req_action,
801
+			],
802
+			EE_MAINTENANCE_ADMIN_URL
803
+		);
804
+		$form                                       = $this->_get_datetime_offset_fix_form();
805
+		$this->_admin_page_title                    = esc_html__('Datetime Utilities', 'event_espresso');
806
+		$this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')
807
+													  . $form->get_html_and_js()
808
+													  . $form->form_close();
809
+		$this->display_admin_page_with_sidebar();
810
+	}
811
+
812
+
813
+	/**
814
+	 * @throws EE_Error
815
+	 */
816
+	protected function _get_datetime_offset_fix_form()
817
+	{
818
+		if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
819
+			$this->datetime_fix_offset_form = new EE_Form_Section_Proper(
820
+				[
821
+					'name'            => 'datetime_offset_fix_option',
822
+					'layout_strategy' => new EE_Admin_Two_Column_Layout(),
823
+					'subsections'     => [
824
+						'title'                  => new EE_Form_Section_HTML(
825
+							EEH_HTML::h2(
826
+								esc_html__('Datetime Offset Tool', 'event_espresso')
827
+							)
828
+						),
829
+						'explanation'            => new EE_Form_Section_HTML(
830
+							EEH_HTML::p(
831
+								esc_html__(
832
+									'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',
833
+									'event_espresso'
834
+								)
835
+							)
836
+							. EEH_HTML::p(
837
+								esc_html__(
838
+									'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied.  Decimals represent the fraction of hours, not minutes.',
839
+									'event_espresso'
840
+								)
841
+							)
842
+						),
843
+						'offset_input'           => new EE_Float_Input(
844
+							[
845
+								'html_name'       => 'offset_for_datetimes',
846
+								'html_label_text' => esc_html__(
847
+									'Offset to apply (in hours):',
848
+									'event_espresso'
849
+								),
850
+								'min_value'       => '-12',
851
+								'max_value'       => '14',
852
+								'step_value'      => '.25',
853
+								'default'         => DatetimeOffsetFix::getOffset(),
854
+							]
855
+						),
856
+						'date_range_explanation' => new EE_Form_Section_HTML(
857
+							EEH_HTML::p(
858
+								esc_html__(
859
+									'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',
860
+									'event_espresso'
861
+								)
862
+							)
863
+							. EEH_HTML::p(
864
+								EEH_HTML::strong(
865
+									sprintf(
866
+										esc_html__(
867
+											'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',
868
+											'event_espresso'
869
+										),
870
+										'<a href="https://www.timeanddate.com/worldclock/converter.html">',
871
+										'</a>'
872
+									)
873
+								)
874
+							)
875
+						),
876
+						'date_range_start_date'  => new EE_Datepicker_Input(
877
+							[
878
+								'html_name'       => 'offset_date_start_range',
879
+								'html_label_text' => esc_html__(
880
+									'Start Date for dates the offset applied to:',
881
+									'event_espresso'
882
+								),
883
+							]
884
+						),
885
+						'date_range_end_date'    => new EE_Datepicker_Input(
886
+							[
887
+								'html_name'       => 'offset_date_end_range',
888
+								'html_label_text' => esc_html__(
889
+									'End Date for dates the offset is applied to:',
890
+									'event_espresso'
891
+								),
892
+							]
893
+						),
894
+						'submit'                 => new EE_Submit_Input(
895
+							[
896
+								'html_label_text' => '',
897
+								'default'         => esc_html__('Apply Offset', 'event_espresso'),
898
+							]
899
+						),
900
+					],
901
+				]
902
+			);
903
+		}
904
+		return $this->datetime_fix_offset_form;
905
+	}
906
+
907
+
908
+	/**
909
+	 * Callback for the run_datetime_offset_fix route.
910
+	 *
911
+	 * @throws EE_Error
912
+	 */
913
+	protected function _apply_datetime_offset()
914
+	{
915
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
916
+			$form = $this->_get_datetime_offset_fix_form();
917
+			$form->receive_form_submission($this->_req_data);
918
+			if ($form->is_valid()) {
919
+				// save offset data so batch processor can get it.
920
+				DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input'));
921
+				$utc_timezone          = new DateTimeZone('UTC');
922
+				$date_range_start_date = DateTime::createFromFormat(
923
+					'm/d/Y H:i:s',
924
+					$form->get_input_value('date_range_start_date') . ' 00:00:00',
925
+					$utc_timezone
926
+				);
927
+				$date_range_end_date   = DateTime::createFromFormat(
928
+					'm/d/Y H:i:s',
929
+					$form->get_input_value('date_range_end_date') . ' 23:59:59',
930
+					$utc_timezone
931
+				);
932
+				if ($date_range_start_date instanceof DateTime) {
933
+					DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));
934
+				}
935
+				if ($date_range_end_date instanceof DateTime) {
936
+					DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));
937
+				}
938
+				// redirect to batch tool
939
+				wp_redirect(
940
+					EE_Admin_Page::add_query_args_and_nonce(
941
+						[
942
+							'page'        => EED_Batch::PAGE_SLUG,
943
+							'batch'       => EED_Batch::batch_job,
944
+							'label'       => esc_html__('Applying Offset', 'event_espresso'),
945
+							'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'),
946
+							'return_url'  => urlencode(
947
+								add_query_arg(
948
+									[
949
+										'action' => 'datetime_tools',
950
+									],
951
+									EEH_URL::current_url_without_query_paramaters(
952
+										[
953
+											'return_action',
954
+											'run_datetime_offset_fix_nonce',
955
+											'return',
956
+											'datetime_tools_nonce',
957
+										]
958
+									)
959
+								)
960
+							),
961
+						],
962
+						admin_url()
963
+					)
964
+				);
965
+				exit;
966
+			}
967
+		}
968
+	}
969 969
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page.core.php 1 patch
Indentation   +1563 added lines, -1563 removed lines patch added patch discarded remove patch
@@ -13,1573 +13,1573 @@
 block discarded – undo
13 13
  */
14 14
 class Venues_Admin_Page extends EE_Admin_Page_CPT
15 15
 {
16
-    /**
17
-     * _venue
18
-     * This will hold the venue object for venue_details screen.
19
-     *
20
-     * @access protected
21
-     * @var object
22
-     */
23
-    protected $_venue;
24
-
25
-
26
-    /**
27
-     * This will hold the category object for category_details screen.
28
-     *
29
-     * @var object
30
-     */
31
-    protected $_category;
32
-
33
-
34
-    /**
35
-     * This property will hold the venue model instance
36
-     *
37
-     * @var object
38
-     */
39
-    protected $_venue_model;
40
-
41
-
42
-    /**
43
-     * @throws EE_Error
44
-     */
45
-    protected function _init_page_props()
46
-    {
47
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
48
-        $this->page_slug        = EE_VENUES_PG_SLUG;
49
-        $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
50
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
51
-        $this->page_label       = esc_html__('Event Venues', 'event_espresso');
52
-        $this->_cpt_model_names = [
53
-            'create_new' => 'EEM_Venue',
54
-            'edit'       => 'EEM_Venue',
55
-        ];
56
-        $this->_cpt_edit_routes = [
57
-            'espresso_venues' => 'edit',
58
-        ];
59
-        $this->_venue_model     = EEM_Venue::instance();
60
-    }
61
-
62
-
63
-    protected function _ajax_hooks()
64
-    {
65
-        // todo: all hooks for ee_venues ajax goes in here.
66
-    }
67
-
68
-
69
-    protected function _define_page_props()
70
-    {
71
-        $this->_admin_page_title = $this->page_label;
72
-        $this->_labels           = [
73
-            'buttons'      => [
74
-                'add'             => esc_html__('Add New Venue', 'event_espresso'),
75
-                'edit'            => esc_html__('Edit Venue', 'event_espresso'),
76
-                'delete'          => esc_html__('Delete Venue', 'event_espresso'),
77
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
78
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
79
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
80
-            ],
81
-            'editor_title' => [
82
-                'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
83
-            ],
84
-            'publishbox'   => [
85
-                'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
86
-                'edit'                => esc_html__('Update Venue', 'event_espresso'),
87
-                'add_category'        => esc_html__('Save New Category', 'event_espresso'),
88
-                'edit_category'       => esc_html__('Update Category', 'event_espresso'),
89
-                'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
90
-            ],
91
-        ];
92
-    }
93
-
94
-
95
-    protected function _set_page_routes()
96
-    {
97
-
98
-        // load formatter helper
99
-        // load field generator helper
100
-
101
-        // is there a vnu_id in the request?
102
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
103
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
104
-
105
-        $this->_page_routes = [
106
-            'default'                    => [
107
-                'func'       => '_overview_list_table',
108
-                'capability' => 'ee_read_venues',
109
-            ],
110
-            'create_new'                 => [
111
-                'func'       => '_create_new_cpt_item',
112
-                'capability' => 'ee_edit_venues',
113
-            ],
114
-            'edit'                       => [
115
-                'func'       => '_edit_cpt_item',
116
-                'capability' => 'ee_edit_venue',
117
-                'obj_id'     => $VNU_ID,
118
-            ],
119
-            'trash_venue'                => [
120
-                'func'       => '_trash_or_restore_venue',
121
-                'args'       => ['venue_status' => 'trash'],
122
-                'noheader'   => true,
123
-                'capability' => 'ee_delete_venue',
124
-                'obj_id'     => $VNU_ID,
125
-            ],
126
-            'trash_venues'               => [
127
-                'func'       => '_trash_or_restore_venues',
128
-                'args'       => ['venue_status' => 'trash'],
129
-                'noheader'   => true,
130
-                'capability' => 'ee_delete_venues',
131
-            ],
132
-            'restore_venue'              => [
133
-                'func'       => '_trash_or_restore_venue',
134
-                'args'       => ['venue_status' => 'draft'],
135
-                'noheader'   => true,
136
-                'capability' => 'ee_delete_venue',
137
-                'obj_id'     => $VNU_ID,
138
-            ],
139
-            'restore_venues'             => [
140
-                'func'       => '_trash_or_restore_venues',
141
-                'args'       => ['venue_status' => 'draft'],
142
-                'noheader'   => true,
143
-                'capability' => 'ee_delete_venues',
144
-            ],
145
-            'delete_venues'              => [
146
-                'func'       => '_delete_venues',
147
-                'noheader'   => true,
148
-                'capability' => 'ee_delete_venues',
149
-            ],
150
-            'delete_venue'               => [
151
-                'func'       => '_delete_venue',
152
-                'noheader'   => true,
153
-                'capability' => 'ee_delete_venue',
154
-                'obj_id'     => $VNU_ID,
155
-            ],
156
-            // settings related
157
-            'google_map_settings'        => [
158
-                'func'       => '_google_map_settings',
159
-                'capability' => 'manage_options',
160
-            ],
161
-            'update_google_map_settings' => [
162
-                'func'       => '_update_google_map_settings',
163
-                'capability' => 'manage_options',
164
-                'noheader'   => true,
165
-            ],
166
-            // venue category tab related
167
-            'add_category'               => [
168
-                'func'       => '_category_details',
169
-                'args'       => ['add'],
170
-                'capability' => 'ee_edit_venue_category',
171
-            ],
172
-            'edit_category'              => [
173
-                'func'       => '_category_details',
174
-                'args'       => ['edit'],
175
-                'capability' => 'ee_edit_venue_category',
176
-            ],
177
-            'delete_categories'          => [
178
-                'func'       => '_delete_categories',
179
-                'noheader'   => true,
180
-                'capability' => 'ee_delete_venue_category',
181
-            ],
182
-
183
-            'delete_category' => [
184
-                'func'       => '_delete_categories',
185
-                'noheader'   => true,
186
-                'capability' => 'ee_delete_venue_category',
187
-            ],
188
-
189
-            'insert_category' => [
190
-                'func'       => '_insert_or_update_category',
191
-                'args'       => ['new_category' => true],
192
-                'noheader'   => true,
193
-                'capability' => 'ee_edit_venue_category',
194
-            ],
195
-
196
-            'update_category'   => [
197
-                'func'       => '_insert_or_update_category',
198
-                'args'       => ['new_category' => false],
199
-                'noheader'   => true,
200
-                'capability' => 'ee_edit_venue_category',
201
-            ],
202
-            'export_categories' => [
203
-                'func'       => '_categories_export',
204
-                'noheader'   => true,
205
-                'capability' => 'export',
206
-            ],
207
-            'import_categories' => [
208
-                'func'       => '_import_categories',
209
-                'capability' => 'import',
210
-            ],
211
-            'category_list'     => [
212
-                'func'       => '_category_list_table',
213
-                'capability' => 'ee_manage_venue_categories',
214
-            ],
215
-        ];
216
-    }
217
-
218
-
219
-    protected function _set_page_config()
220
-    {
221
-        $VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
222
-        $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
223
-
224
-        $this->_page_config = [
225
-            'default'             => [
226
-                'nav'           => [
227
-                    'label' => esc_html__('Overview', 'event_espresso'),
228
-                    'icon' => 'dashicons-list-view',
229
-                    'order' => 10,
230
-                ],
231
-                'list_table'    => 'Venues_Admin_List_Table',
232
-                'help_tabs'     => [
233
-                    'venues_overview_help_tab'                           => [
234
-                        'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
-                        'filename' => 'venues_overview',
236
-                    ],
237
-                    'venues_overview_table_column_headings_help_tab'     => [
238
-                        'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
-                        'filename' => 'venues_overview_table_column_headings',
240
-                    ],
241
-                    'venues_overview_views_bulk_actions_search_help_tab' => [
242
-                        'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
-                        'filename' => 'venues_overview_views_bulk_actions_search',
244
-                    ],
245
-                ],
246
-                'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
247
-                'require_nonce' => false,
248
-            ],
249
-            'create_new'          => [
250
-                'nav'           => [
251
-                    'label'      => esc_html__('Add Venue', 'event_espresso'),
252
-                    'icon' => 'dashicons-plus-alt',
253
-                    'order'      => 15,
254
-                    'persistent' => false,
255
-                ],
256
-                'help_tabs'     => [
257
-                    'venues_editor_help_tab'                                               => [
258
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
259
-                        'filename' => 'venues_editor',
260
-                    ],
261
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
262
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
263
-                        'filename' => 'venues_editor_title_richtexteditor',
264
-                    ],
265
-                    'venues_editor_tags_categories_help_tab'                               => [
266
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
267
-                        'filename' => 'venues_editor_tags_categories',
268
-                    ],
269
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
270
-                        'title'    => esc_html__(
271
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
272
-                            'event_espresso'
273
-                        ),
274
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
275
-                    ],
276
-                    'venues_editor_save_new_venue_help_tab'                                => [
277
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
278
-                        'filename' => 'venues_editor_save_new_venue',
279
-                    ],
280
-                    'venues_editor_other_help_tab'                                         => [
281
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
282
-                        'filename' => 'venues_editor_other',
283
-                    ],
284
-                ],
285
-                'metaboxes'     => ['_venue_editor_metaboxes'],
286
-                'require_nonce' => false,
287
-            ],
288
-            'edit'                => [
289
-                'nav'           => [
290
-                    'label'      => esc_html__('Edit Venue', 'event_espresso'),
291
-                    'icon' => 'dashicons-edit-large',
292
-                    'order'      => 15,
293
-                    'persistent' => false,
294
-                    'url'        => $VNU_ID
295
-                        ? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
296
-                        : $this->_admin_base_url,
297
-                ],
298
-                'help_tabs'     => [
299
-                    'venues_editor_help_tab'                                               => [
300
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
301
-                        'filename' => 'venues_editor',
302
-                    ],
303
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
304
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
305
-                        'filename' => 'venues_editor_title_richtexteditor',
306
-                    ],
307
-                    'venues_editor_tags_categories_help_tab'                               => [
308
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
309
-                        'filename' => 'venues_editor_tags_categories',
310
-                    ],
311
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
312
-                        'title'    => esc_html__(
313
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
314
-                            'event_espresso'
315
-                        ),
316
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
317
-                    ],
318
-                    'venues_editor_save_new_venue_help_tab'                                => [
319
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
320
-                        'filename' => 'venues_editor_save_new_venue',
321
-                    ],
322
-                    'venues_editor_other_help_tab'                                         => [
323
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
324
-                        'filename' => 'venues_editor_other',
325
-                    ],
326
-                ],
327
-                'metaboxes'     => ['_venue_editor_metaboxes'],
328
-                'require_nonce' => false,
329
-            ],
330
-            'google_map_settings' => [
331
-                'nav'           => [
332
-                    'label' => esc_html__('Google Maps', 'event_espresso'),
333
-                    'icon' => 'dashicons-location-alt',
334
-                    'order' => 40,
335
-                ],
336
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
337
-                'help_tabs'     => [
338
-                    'general_settings_google_maps_help_tab' => [
339
-                        'title'    => esc_html__('Google Maps', 'event_espresso'),
340
-                        'filename' => 'general_settings_google_maps',
341
-                    ],
342
-                ],
343
-                'require_nonce' => false,
344
-            ],
345
-            // venue category stuff
346
-            'add_category'        => [
347
-                'nav'           => [
348
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
349
-                    'icon' => 'dashicons-plus-alt',
350
-                    'order'      => 25,
351
-                    'persistent' => false,
352
-                ],
353
-                'metaboxes'     => ['_publish_post_box'],
354
-                'help_tabs'     => [
355
-                    'venues_add_category_help_tab' => [
356
-                        'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
357
-                        'filename' => 'venues_add_category',
358
-                    ],
359
-                ],
360
-                'require_nonce' => false,
361
-            ],
362
-            'edit_category'       => [
363
-                'nav'           => [
364
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
365
-                    'icon' => 'dashicons-edit-large',
366
-                    'order'      => 25,
367
-                    'persistent' => false,
368
-                    'url'        => $EVT_CAT_ID
369
-                        ? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
370
-                        : $this->_admin_base_url,
371
-                ],
372
-                'metaboxes'     => ['_publish_post_box'],
373
-                'help_tabs'     => [
374
-                    'venues_edit_category_help_tab' => [
375
-                        'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
376
-                        'filename' => 'venues_edit_category',
377
-                    ],
378
-                ],
379
-                'require_nonce' => false,
380
-            ],
381
-            'category_list'       => [
382
-                'nav'           => [
383
-                    'label' => esc_html__('Categories', 'event_espresso'),
384
-                    'icon' => 'dashicons-networking',
385
-                    'order' => 20,
386
-                ],
387
-                'list_table'    => 'Venue_Categories_Admin_List_Table',
388
-                'help_tabs'     => [
389
-                    'venues_categories_help_tab'                       => [
390
-                        'title'    => esc_html__('Venue Categories', 'event_espresso'),
391
-                        'filename' => 'venues_categories',
392
-                    ],
393
-                    'venues_categories_table_column_headings_help_tab' => [
394
-                        'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
395
-                        'filename' => 'venues_categories_table_column_headings',
396
-                    ],
397
-                    'venues_categories_views_help_tab'                 => [
398
-                        'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
399
-                        'filename' => 'venues_categories_views',
400
-                    ],
401
-                    'venues_categories_other_help_tab'                 => [
402
-                        'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
403
-                        'filename' => 'venues_categories_other',
404
-                    ],
405
-                ],
406
-                'metaboxes'     => $this->_default_espresso_metaboxes,
407
-                'require_nonce' => false,
408
-            ],
409
-        ];
410
-    }
411
-
412
-
413
-    protected function _add_screen_options()
414
-    {
415
-        // todo
416
-    }
417
-
418
-
419
-    protected function _add_screen_options_default()
420
-    {
421
-        $this->_per_page_screen_option();
422
-    }
423
-
424
-
425
-    protected function _add_screen_options_category_list()
426
-    {
427
-        $page_title              = $this->_admin_page_title;
428
-        $this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
429
-        $this->_per_page_screen_option();
430
-        $this->_admin_page_title = $page_title;
431
-    }
432
-
433
-
434
-    // none of the below group are currently used for Event Venues
435
-    protected function _add_feature_pointers()
436
-    {
437
-    }
438
-
439
-
440
-    public function admin_init()
441
-    {
442
-    }
443
-
444
-
445
-    public function admin_notices()
446
-    {
447
-    }
448
-
449
-
450
-    public function admin_footer_scripts()
451
-    {
452
-    }
453
-
454
-
455
-    public function load_scripts_styles_create_new()
456
-    {
457
-        $this->load_scripts_styles_edit();
458
-    }
459
-
460
-
461
-    public function load_scripts_styles()
462
-    {
463
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
464
-        wp_enqueue_style('ee-cat-admin');
465
-    }
466
-
467
-
468
-    public function load_scripts_styles_add_category()
469
-    {
470
-        $this->load_scripts_styles_edit_category();
471
-    }
472
-
473
-
474
-    public function load_scripts_styles_edit_category()
475
-    {
476
-    }
477
-
478
-
479
-    public function load_scripts_styles_edit()
480
-    {
481
-        // styles
482
-        wp_enqueue_style('espresso-ui-theme');
483
-        wp_register_style(
484
-            'espresso_venues',
485
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
486
-            [],
487
-            EVENT_ESPRESSO_VERSION
488
-        );
489
-        wp_enqueue_style('espresso_venues');
490
-    }
491
-
492
-
493
-    protected function _set_list_table_views_default()
494
-    {
495
-        $this->_views = [
496
-            'all' => [
497
-                'slug'        => 'all',
498
-                'label'       => esc_html__('View All Venues', 'event_espresso'),
499
-                'count'       => 0,
500
-                'bulk_action' => [],
501
-            ],
502
-        ];
503
-
504
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
505
-            $this->_views['all']['bulk_action'] = [
506
-                'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
507
-            ];
508
-            $this->_views['trash']              = [
509
-                'slug'        => 'trash',
510
-                'label'       => esc_html__('Trash', 'event_espresso'),
511
-                'count'       => 0,
512
-                'bulk_action' => [
513
-                    'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
514
-                    'delete_venues'  => esc_html__('Delete', 'event_espresso'),
515
-                ],
516
-            ];
517
-        }
518
-    }
519
-
520
-
521
-    protected function _set_list_table_views_category_list()
522
-    {
523
-        $this->_views = [
524
-            'all' => [
525
-                'slug'        => 'all',
526
-                'label'       => esc_html__('All', 'event_espresso'),
527
-                'count'       => 0,
528
-                'bulk_action' => [
529
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
530
-                ],
531
-            ],
532
-        ];
533
-    }
534
-
535
-
536
-    /**
537
-     * @throws EE_Error
538
-     */
539
-    protected function _overview_list_table()
540
-    {
541
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
542
-        $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
543
-            get_post_type_archive_link('espresso_venues'),
544
-            esc_html__("View Venue Archive Page", "event_espresso"),
545
-            'button'
546
-        );
547
-
548
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
549
-            'create_new',
550
-            'add',
551
-            [],
552
-            'add-new-h2'
553
-        );
554
-
555
-        $this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
556
-        $this->display_admin_list_table_page_with_sidebar();
557
-    }
558
-
559
-
560
-    /**
561
-     * @throws EE_Error
562
-     * @throws ReflectionException
563
-     */
564
-    public function extra_misc_actions_publish_box()
565
-    {
566
-        $extra_rows = [
567
-            'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
568
-            'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
569
-            'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
570
-        ];
571
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
572
-        EEH_Template::display_template($template, $extra_rows);
573
-    }
574
-
575
-
576
-    /*************        Google Maps        *************
16
+	/**
17
+	 * _venue
18
+	 * This will hold the venue object for venue_details screen.
19
+	 *
20
+	 * @access protected
21
+	 * @var object
22
+	 */
23
+	protected $_venue;
24
+
25
+
26
+	/**
27
+	 * This will hold the category object for category_details screen.
28
+	 *
29
+	 * @var object
30
+	 */
31
+	protected $_category;
32
+
33
+
34
+	/**
35
+	 * This property will hold the venue model instance
36
+	 *
37
+	 * @var object
38
+	 */
39
+	protected $_venue_model;
40
+
41
+
42
+	/**
43
+	 * @throws EE_Error
44
+	 */
45
+	protected function _init_page_props()
46
+	{
47
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
48
+		$this->page_slug        = EE_VENUES_PG_SLUG;
49
+		$this->_admin_base_url  = EE_VENUES_ADMIN_URL;
50
+		$this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
51
+		$this->page_label       = esc_html__('Event Venues', 'event_espresso');
52
+		$this->_cpt_model_names = [
53
+			'create_new' => 'EEM_Venue',
54
+			'edit'       => 'EEM_Venue',
55
+		];
56
+		$this->_cpt_edit_routes = [
57
+			'espresso_venues' => 'edit',
58
+		];
59
+		$this->_venue_model     = EEM_Venue::instance();
60
+	}
61
+
62
+
63
+	protected function _ajax_hooks()
64
+	{
65
+		// todo: all hooks for ee_venues ajax goes in here.
66
+	}
67
+
68
+
69
+	protected function _define_page_props()
70
+	{
71
+		$this->_admin_page_title = $this->page_label;
72
+		$this->_labels           = [
73
+			'buttons'      => [
74
+				'add'             => esc_html__('Add New Venue', 'event_espresso'),
75
+				'edit'            => esc_html__('Edit Venue', 'event_espresso'),
76
+				'delete'          => esc_html__('Delete Venue', 'event_espresso'),
77
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
78
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
79
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
80
+			],
81
+			'editor_title' => [
82
+				'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
83
+			],
84
+			'publishbox'   => [
85
+				'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
86
+				'edit'                => esc_html__('Update Venue', 'event_espresso'),
87
+				'add_category'        => esc_html__('Save New Category', 'event_espresso'),
88
+				'edit_category'       => esc_html__('Update Category', 'event_espresso'),
89
+				'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
90
+			],
91
+		];
92
+	}
93
+
94
+
95
+	protected function _set_page_routes()
96
+	{
97
+
98
+		// load formatter helper
99
+		// load field generator helper
100
+
101
+		// is there a vnu_id in the request?
102
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
103
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
104
+
105
+		$this->_page_routes = [
106
+			'default'                    => [
107
+				'func'       => '_overview_list_table',
108
+				'capability' => 'ee_read_venues',
109
+			],
110
+			'create_new'                 => [
111
+				'func'       => '_create_new_cpt_item',
112
+				'capability' => 'ee_edit_venues',
113
+			],
114
+			'edit'                       => [
115
+				'func'       => '_edit_cpt_item',
116
+				'capability' => 'ee_edit_venue',
117
+				'obj_id'     => $VNU_ID,
118
+			],
119
+			'trash_venue'                => [
120
+				'func'       => '_trash_or_restore_venue',
121
+				'args'       => ['venue_status' => 'trash'],
122
+				'noheader'   => true,
123
+				'capability' => 'ee_delete_venue',
124
+				'obj_id'     => $VNU_ID,
125
+			],
126
+			'trash_venues'               => [
127
+				'func'       => '_trash_or_restore_venues',
128
+				'args'       => ['venue_status' => 'trash'],
129
+				'noheader'   => true,
130
+				'capability' => 'ee_delete_venues',
131
+			],
132
+			'restore_venue'              => [
133
+				'func'       => '_trash_or_restore_venue',
134
+				'args'       => ['venue_status' => 'draft'],
135
+				'noheader'   => true,
136
+				'capability' => 'ee_delete_venue',
137
+				'obj_id'     => $VNU_ID,
138
+			],
139
+			'restore_venues'             => [
140
+				'func'       => '_trash_or_restore_venues',
141
+				'args'       => ['venue_status' => 'draft'],
142
+				'noheader'   => true,
143
+				'capability' => 'ee_delete_venues',
144
+			],
145
+			'delete_venues'              => [
146
+				'func'       => '_delete_venues',
147
+				'noheader'   => true,
148
+				'capability' => 'ee_delete_venues',
149
+			],
150
+			'delete_venue'               => [
151
+				'func'       => '_delete_venue',
152
+				'noheader'   => true,
153
+				'capability' => 'ee_delete_venue',
154
+				'obj_id'     => $VNU_ID,
155
+			],
156
+			// settings related
157
+			'google_map_settings'        => [
158
+				'func'       => '_google_map_settings',
159
+				'capability' => 'manage_options',
160
+			],
161
+			'update_google_map_settings' => [
162
+				'func'       => '_update_google_map_settings',
163
+				'capability' => 'manage_options',
164
+				'noheader'   => true,
165
+			],
166
+			// venue category tab related
167
+			'add_category'               => [
168
+				'func'       => '_category_details',
169
+				'args'       => ['add'],
170
+				'capability' => 'ee_edit_venue_category',
171
+			],
172
+			'edit_category'              => [
173
+				'func'       => '_category_details',
174
+				'args'       => ['edit'],
175
+				'capability' => 'ee_edit_venue_category',
176
+			],
177
+			'delete_categories'          => [
178
+				'func'       => '_delete_categories',
179
+				'noheader'   => true,
180
+				'capability' => 'ee_delete_venue_category',
181
+			],
182
+
183
+			'delete_category' => [
184
+				'func'       => '_delete_categories',
185
+				'noheader'   => true,
186
+				'capability' => 'ee_delete_venue_category',
187
+			],
188
+
189
+			'insert_category' => [
190
+				'func'       => '_insert_or_update_category',
191
+				'args'       => ['new_category' => true],
192
+				'noheader'   => true,
193
+				'capability' => 'ee_edit_venue_category',
194
+			],
195
+
196
+			'update_category'   => [
197
+				'func'       => '_insert_or_update_category',
198
+				'args'       => ['new_category' => false],
199
+				'noheader'   => true,
200
+				'capability' => 'ee_edit_venue_category',
201
+			],
202
+			'export_categories' => [
203
+				'func'       => '_categories_export',
204
+				'noheader'   => true,
205
+				'capability' => 'export',
206
+			],
207
+			'import_categories' => [
208
+				'func'       => '_import_categories',
209
+				'capability' => 'import',
210
+			],
211
+			'category_list'     => [
212
+				'func'       => '_category_list_table',
213
+				'capability' => 'ee_manage_venue_categories',
214
+			],
215
+		];
216
+	}
217
+
218
+
219
+	protected function _set_page_config()
220
+	{
221
+		$VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
222
+		$EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
223
+
224
+		$this->_page_config = [
225
+			'default'             => [
226
+				'nav'           => [
227
+					'label' => esc_html__('Overview', 'event_espresso'),
228
+					'icon' => 'dashicons-list-view',
229
+					'order' => 10,
230
+				],
231
+				'list_table'    => 'Venues_Admin_List_Table',
232
+				'help_tabs'     => [
233
+					'venues_overview_help_tab'                           => [
234
+						'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
+						'filename' => 'venues_overview',
236
+					],
237
+					'venues_overview_table_column_headings_help_tab'     => [
238
+						'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
+						'filename' => 'venues_overview_table_column_headings',
240
+					],
241
+					'venues_overview_views_bulk_actions_search_help_tab' => [
242
+						'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
+						'filename' => 'venues_overview_views_bulk_actions_search',
244
+					],
245
+				],
246
+				'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
247
+				'require_nonce' => false,
248
+			],
249
+			'create_new'          => [
250
+				'nav'           => [
251
+					'label'      => esc_html__('Add Venue', 'event_espresso'),
252
+					'icon' => 'dashicons-plus-alt',
253
+					'order'      => 15,
254
+					'persistent' => false,
255
+				],
256
+				'help_tabs'     => [
257
+					'venues_editor_help_tab'                                               => [
258
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
259
+						'filename' => 'venues_editor',
260
+					],
261
+					'venues_editor_title_richtexteditor_help_tab'                          => [
262
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
263
+						'filename' => 'venues_editor_title_richtexteditor',
264
+					],
265
+					'venues_editor_tags_categories_help_tab'                               => [
266
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
267
+						'filename' => 'venues_editor_tags_categories',
268
+					],
269
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
270
+						'title'    => esc_html__(
271
+							'Venue Editor Physical Location & Google Map & Virtual Location',
272
+							'event_espresso'
273
+						),
274
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
275
+					],
276
+					'venues_editor_save_new_venue_help_tab'                                => [
277
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
278
+						'filename' => 'venues_editor_save_new_venue',
279
+					],
280
+					'venues_editor_other_help_tab'                                         => [
281
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
282
+						'filename' => 'venues_editor_other',
283
+					],
284
+				],
285
+				'metaboxes'     => ['_venue_editor_metaboxes'],
286
+				'require_nonce' => false,
287
+			],
288
+			'edit'                => [
289
+				'nav'           => [
290
+					'label'      => esc_html__('Edit Venue', 'event_espresso'),
291
+					'icon' => 'dashicons-edit-large',
292
+					'order'      => 15,
293
+					'persistent' => false,
294
+					'url'        => $VNU_ID
295
+						? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
296
+						: $this->_admin_base_url,
297
+				],
298
+				'help_tabs'     => [
299
+					'venues_editor_help_tab'                                               => [
300
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
301
+						'filename' => 'venues_editor',
302
+					],
303
+					'venues_editor_title_richtexteditor_help_tab'                          => [
304
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
305
+						'filename' => 'venues_editor_title_richtexteditor',
306
+					],
307
+					'venues_editor_tags_categories_help_tab'                               => [
308
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
309
+						'filename' => 'venues_editor_tags_categories',
310
+					],
311
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
312
+						'title'    => esc_html__(
313
+							'Venue Editor Physical Location & Google Map & Virtual Location',
314
+							'event_espresso'
315
+						),
316
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
317
+					],
318
+					'venues_editor_save_new_venue_help_tab'                                => [
319
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
320
+						'filename' => 'venues_editor_save_new_venue',
321
+					],
322
+					'venues_editor_other_help_tab'                                         => [
323
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
324
+						'filename' => 'venues_editor_other',
325
+					],
326
+				],
327
+				'metaboxes'     => ['_venue_editor_metaboxes'],
328
+				'require_nonce' => false,
329
+			],
330
+			'google_map_settings' => [
331
+				'nav'           => [
332
+					'label' => esc_html__('Google Maps', 'event_espresso'),
333
+					'icon' => 'dashicons-location-alt',
334
+					'order' => 40,
335
+				],
336
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
337
+				'help_tabs'     => [
338
+					'general_settings_google_maps_help_tab' => [
339
+						'title'    => esc_html__('Google Maps', 'event_espresso'),
340
+						'filename' => 'general_settings_google_maps',
341
+					],
342
+				],
343
+				'require_nonce' => false,
344
+			],
345
+			// venue category stuff
346
+			'add_category'        => [
347
+				'nav'           => [
348
+					'label'      => esc_html__('Add Category', 'event_espresso'),
349
+					'icon' => 'dashicons-plus-alt',
350
+					'order'      => 25,
351
+					'persistent' => false,
352
+				],
353
+				'metaboxes'     => ['_publish_post_box'],
354
+				'help_tabs'     => [
355
+					'venues_add_category_help_tab' => [
356
+						'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
357
+						'filename' => 'venues_add_category',
358
+					],
359
+				],
360
+				'require_nonce' => false,
361
+			],
362
+			'edit_category'       => [
363
+				'nav'           => [
364
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
365
+					'icon' => 'dashicons-edit-large',
366
+					'order'      => 25,
367
+					'persistent' => false,
368
+					'url'        => $EVT_CAT_ID
369
+						? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
370
+						: $this->_admin_base_url,
371
+				],
372
+				'metaboxes'     => ['_publish_post_box'],
373
+				'help_tabs'     => [
374
+					'venues_edit_category_help_tab' => [
375
+						'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
376
+						'filename' => 'venues_edit_category',
377
+					],
378
+				],
379
+				'require_nonce' => false,
380
+			],
381
+			'category_list'       => [
382
+				'nav'           => [
383
+					'label' => esc_html__('Categories', 'event_espresso'),
384
+					'icon' => 'dashicons-networking',
385
+					'order' => 20,
386
+				],
387
+				'list_table'    => 'Venue_Categories_Admin_List_Table',
388
+				'help_tabs'     => [
389
+					'venues_categories_help_tab'                       => [
390
+						'title'    => esc_html__('Venue Categories', 'event_espresso'),
391
+						'filename' => 'venues_categories',
392
+					],
393
+					'venues_categories_table_column_headings_help_tab' => [
394
+						'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
395
+						'filename' => 'venues_categories_table_column_headings',
396
+					],
397
+					'venues_categories_views_help_tab'                 => [
398
+						'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
399
+						'filename' => 'venues_categories_views',
400
+					],
401
+					'venues_categories_other_help_tab'                 => [
402
+						'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
403
+						'filename' => 'venues_categories_other',
404
+					],
405
+				],
406
+				'metaboxes'     => $this->_default_espresso_metaboxes,
407
+				'require_nonce' => false,
408
+			],
409
+		];
410
+	}
411
+
412
+
413
+	protected function _add_screen_options()
414
+	{
415
+		// todo
416
+	}
417
+
418
+
419
+	protected function _add_screen_options_default()
420
+	{
421
+		$this->_per_page_screen_option();
422
+	}
423
+
424
+
425
+	protected function _add_screen_options_category_list()
426
+	{
427
+		$page_title              = $this->_admin_page_title;
428
+		$this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
429
+		$this->_per_page_screen_option();
430
+		$this->_admin_page_title = $page_title;
431
+	}
432
+
433
+
434
+	// none of the below group are currently used for Event Venues
435
+	protected function _add_feature_pointers()
436
+	{
437
+	}
438
+
439
+
440
+	public function admin_init()
441
+	{
442
+	}
443
+
444
+
445
+	public function admin_notices()
446
+	{
447
+	}
448
+
449
+
450
+	public function admin_footer_scripts()
451
+	{
452
+	}
453
+
454
+
455
+	public function load_scripts_styles_create_new()
456
+	{
457
+		$this->load_scripts_styles_edit();
458
+	}
459
+
460
+
461
+	public function load_scripts_styles()
462
+	{
463
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
464
+		wp_enqueue_style('ee-cat-admin');
465
+	}
466
+
467
+
468
+	public function load_scripts_styles_add_category()
469
+	{
470
+		$this->load_scripts_styles_edit_category();
471
+	}
472
+
473
+
474
+	public function load_scripts_styles_edit_category()
475
+	{
476
+	}
477
+
478
+
479
+	public function load_scripts_styles_edit()
480
+	{
481
+		// styles
482
+		wp_enqueue_style('espresso-ui-theme');
483
+		wp_register_style(
484
+			'espresso_venues',
485
+			EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
486
+			[],
487
+			EVENT_ESPRESSO_VERSION
488
+		);
489
+		wp_enqueue_style('espresso_venues');
490
+	}
491
+
492
+
493
+	protected function _set_list_table_views_default()
494
+	{
495
+		$this->_views = [
496
+			'all' => [
497
+				'slug'        => 'all',
498
+				'label'       => esc_html__('View All Venues', 'event_espresso'),
499
+				'count'       => 0,
500
+				'bulk_action' => [],
501
+			],
502
+		];
503
+
504
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
505
+			$this->_views['all']['bulk_action'] = [
506
+				'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
507
+			];
508
+			$this->_views['trash']              = [
509
+				'slug'        => 'trash',
510
+				'label'       => esc_html__('Trash', 'event_espresso'),
511
+				'count'       => 0,
512
+				'bulk_action' => [
513
+					'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
514
+					'delete_venues'  => esc_html__('Delete', 'event_espresso'),
515
+				],
516
+			];
517
+		}
518
+	}
519
+
520
+
521
+	protected function _set_list_table_views_category_list()
522
+	{
523
+		$this->_views = [
524
+			'all' => [
525
+				'slug'        => 'all',
526
+				'label'       => esc_html__('All', 'event_espresso'),
527
+				'count'       => 0,
528
+				'bulk_action' => [
529
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
530
+				],
531
+			],
532
+		];
533
+	}
534
+
535
+
536
+	/**
537
+	 * @throws EE_Error
538
+	 */
539
+	protected function _overview_list_table()
540
+	{
541
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
542
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
543
+			get_post_type_archive_link('espresso_venues'),
544
+			esc_html__("View Venue Archive Page", "event_espresso"),
545
+			'button'
546
+		);
547
+
548
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
549
+			'create_new',
550
+			'add',
551
+			[],
552
+			'add-new-h2'
553
+		);
554
+
555
+		$this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
556
+		$this->display_admin_list_table_page_with_sidebar();
557
+	}
558
+
559
+
560
+	/**
561
+	 * @throws EE_Error
562
+	 * @throws ReflectionException
563
+	 */
564
+	public function extra_misc_actions_publish_box()
565
+	{
566
+		$extra_rows = [
567
+			'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
568
+			'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
569
+			'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
570
+		];
571
+		$template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
572
+		EEH_Template::display_template($template, $extra_rows);
573
+	}
574
+
575
+
576
+	/*************        Google Maps        *************
577 577
      *
578 578
      * @throws EE_Error
579 579
      * @throws EE_Error
580 580
      */
581 581
 
582 582
 
583
-    protected function _google_map_settings()
584
-    {
585
-
586
-
587
-        $this->_template_args['values']           = $this->_yes_no_values;
588
-        $default_map_settings                     = new stdClass();
589
-        $default_map_settings->use_google_maps    = true;
590
-        $default_map_settings->google_map_api_key = '';
591
-        // for event details pages (reg page)
592
-        $default_map_settings->event_details_map_width    = 585;
593
-        // ee_map_width_single
594
-        $default_map_settings->event_details_map_height   = 362;
595
-        // ee_map_height_single
596
-        $default_map_settings->event_details_map_zoom     = 14;
597
-        // ee_map_zoom_single
598
-        $default_map_settings->event_details_display_nav  = true;
599
-        // ee_map_nav_display_single
600
-        $default_map_settings->event_details_nav_size     = false;
601
-        // ee_map_nav_size_single
602
-        $default_map_settings->event_details_control_type = 'default';
603
-        // ee_map_type_control_single
604
-        $default_map_settings->event_details_map_align    = 'center';
605
-        // ee_map_align_single
606
-
607
-        // for event list pages
608
-        $default_map_settings->event_list_map_width    = 300;
609
-        // ee_map_width
610
-        $default_map_settings->event_list_map_height   = 185;
611
-        // ee_map_height
612
-        $default_map_settings->event_list_map_zoom     = 12;
613
-        // ee_map_zoom
614
-        $default_map_settings->event_list_display_nav  = false;
615
-        // ee_map_nav_display
616
-        $default_map_settings->event_list_nav_size     = true;
617
-        // ee_map_nav_size
618
-        $default_map_settings->event_list_control_type = 'dropdown';
619
-        // ee_map_type_control
620
-        $default_map_settings->event_list_map_align    = 'center';
621
-        // ee_map_align
622
-
623
-        $this->_template_args['map_settings'] =
624
-            isset(EE_Registry::instance()->CFG->map_settings)
625
-            && ! empty(EE_Registry::instance()->CFG->map_settings)
626
-                ? (object) array_merge(
627
-                    (array) $default_map_settings,
628
-                    (array) EE_Registry::instance()->CFG->map_settings
629
-                )
630
-                : $default_map_settings;
631
-
632
-        $this->_set_add_edit_form_tags('update_google_map_settings');
633
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
634
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
635
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
636
-            $this->_template_args,
637
-            true
638
-        );
639
-        $this->display_admin_page_with_sidebar();
640
-    }
641
-
642
-
643
-    /**
644
-     * @throws EE_Error
645
-     */
646
-    protected function _update_google_map_settings()
647
-    {
648
-        $map_settings = EE_Registry::instance()->CFG->map_settings;
649
-
650
-        $settings = [
651
-            'use_google_maps'            => 'int',
652
-            'google_map_api_key'         => 'string',
653
-            'event_details_map_width'    => 'int',
654
-            'event_details_map_zoom'     => 'int',
655
-            'event_details_display_nav'  => 'int',
656
-            'event_details_nav_size'     => 'int',
657
-            'event_details_control_type' => 'string',
658
-            'event_details_map_align'    => 'string',
659
-            'event_list_map_width'       => 'int',
660
-            'event_list_map_height'      => 'int',
661
-            'event_list_map_zoom'        => 'int',
662
-            'event_list_display_nav'     => 'int',
663
-            'event_list_nav_size'        => 'int',
664
-            'event_list_control_type'    => 'string',
665
-            'event_list_map_align'       => 'string',
666
-        ];
667
-
668
-        foreach ($settings as $setting => $type) {
669
-            $map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
670
-        }
671
-
672
-        EE_Registry::instance()->CFG->map_settings = apply_filters(
673
-            'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
674
-            $map_settings
675
-        );
676
-
677
-        $what    = 'Google Map Settings';
678
-        $success = $this->_update_espresso_configuration(
679
-            $what,
680
-            EE_Registry::instance()->CFG->map_settings,
681
-            __FILE__,
682
-            __FUNCTION__,
683
-            __LINE__
684
-        );
685
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
686
-    }
687
-
688
-
689
-    /**
690
-     * @throws EE_Error
691
-     * @throws ReflectionException
692
-     */
693
-    protected function _venue_editor_metaboxes()
694
-    {
695
-        $this->verify_cpt_object();
696
-
697
-        $this->addMetaBox(
698
-            'espresso_venue_address_options',
699
-            esc_html__('Physical Location', 'event_espresso'),
700
-            [$this, 'venue_address_metabox'],
701
-            $this->page_slug,
702
-            'side'
703
-        );
704
-        $this->addMetaBox(
705
-            'espresso_venue_gmap_options',
706
-            esc_html__('Google Map', 'event_espresso'),
707
-            [$this, 'venue_gmap_metabox'],
708
-            $this->page_slug,
709
-            'side'
710
-        );
711
-        $this->addMetaBox(
712
-            'espresso_venue_virtual_loc_options',
713
-            esc_html__('Virtual Location', 'event_espresso'),
714
-            [$this, 'venue_virtual_loc_metabox'],
715
-            $this->page_slug,
716
-            'side'
717
-        );
718
-    }
719
-
720
-
721
-    public function venue_gmap_metabox()
722
-    {
723
-        $template_args = [
724
-            'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
725
-                'vnu_enable_for_gmap',
726
-                $this->get_yes_no_values(),
727
-                $this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
728
-            ),
729
-            'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
730
-        ];
731
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
732
-        EEH_Template::display_template($template, $template_args);
733
-    }
734
-
735
-
736
-    /**
737
-     * @throws EE_Error
738
-     * @throws ReflectionException
739
-     */
740
-    public function venue_address_metabox()
741
-    {
742
-        $template_args['_venue'] = $this->_cpt_model_obj;
743
-
744
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
745
-            new EE_Question_Form_Input(
746
-                EE_Question::new_instance(
747
-                    ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
748
-                ),
749
-                EE_Answer::new_instance(
750
-                    [
751
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
752
-                            ? $this->_cpt_model_obj->state_ID()
753
-                            : 0,
754
-                    ]
755
-                ),
756
-                [
757
-                    'input_name'     => 'sta_id',
758
-                    'input_id'       => 'sta_id',
759
-                    'input_class'    => '',
760
-                    'input_prefix'   => '',
761
-                    'append_qstn_id' => false,
762
-                ]
763
-            )
764
-        );
765
-        $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
766
-            new EE_Question_Form_Input(
767
-                EE_Question::new_instance(
768
-                    ['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
769
-                ),
770
-                EE_Answer::new_instance(
771
-                    [
772
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
773
-                            ? $this->_cpt_model_obj->country_ID()
774
-                            : 0,
775
-                    ]
776
-                ),
777
-                [
778
-                    'input_name'     => 'cnt_iso',
779
-                    'input_id'       => 'cnt_iso',
780
-                    'input_class'    => '',
781
-                    'input_prefix'   => '',
782
-                    'append_qstn_id' => false,
783
-                ]
784
-            )
785
-        );
786
-
787
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
788
-        EEH_Template::display_template($template, $template_args);
789
-    }
790
-
791
-
792
-    public function venue_virtual_loc_metabox()
793
-    {
794
-        $template_args = [
795
-            '_venue' => $this->_cpt_model_obj,
796
-        ];
797
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
798
-        EEH_Template::display_template($template, $template_args);
799
-    }
800
-
801
-
802
-    protected function _restore_cpt_item($post_id, $revision_id)
803
-    {
804
-        $venue_obj = $this->_venue_model->get_one_by_ID($post_id);
805
-
806
-        // meta revision restore
807
-        $venue_obj->restore_revision($revision_id);
808
-    }
809
-
810
-
811
-    /**
812
-     * Handles updates for venue cpts
813
-     *
814
-     * @param int    $post_id ID of Venue CPT
815
-     * @param WP_Post $post    Post object (with "blessed" WP properties)
816
-     * @return void
817
-     */
818
-    protected function _insert_update_cpt_item($post_id, $post)
819
-    {
820
-
821
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
822
-            return;// get out we're not processing the saving of venues.
823
-        }
824
-
825
-        $wheres = [$this->_venue_model->primary_key_name() => $post_id];
826
-
827
-        $venue_values = [
828
-            'VNU_address'         => $this->request->getRequestParam('vnu_address'),
829
-            'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
830
-            'VNU_city'            => $this->request->getRequestParam('vnu_city'),
831
-            'STA_ID'              => $this->request->getRequestParam('sta_id'),
832
-            'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
833
-            'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
834
-            'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
835
-            'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
836
-                ? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
837
-                : EE_INF,
838
-            'VNU_url'             => $this->request->getRequestParam('vnu_url'),
839
-            'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
840
-            'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
841
-            'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
842
-            'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
843
-        ];
844
-
845
-        // update venue
846
-        $success = $this->_venue_model->update($venue_values, [$wheres]);
847
-
848
-        // 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!
849
-        $get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
850
-        $venue         = $this->_venue_model->get_one([$get_one_where]);
851
-
852
-        // 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.
853
-        $venue_update_callbacks = apply_filters(
854
-            'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
855
-            []
856
-        );
857
-        $att_success            = true;
858
-        foreach ($venue_update_callbacks as $v_callback) {
859
-            // if ANY of these updates fail then we want the appropriate global error message
860
-            $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
861
-                ? $att_success
862
-                : false;
863
-        }
864
-
865
-        // any errors?
866
-        if ($success && ! $att_success) {
867
-            EE_Error::add_error(
868
-                esc_html__(
869
-                    'Venue Details saved successfully but something went wrong with saving attachments.',
870
-                    'event_espresso'
871
-                ),
872
-                __FILE__,
873
-                __FUNCTION__,
874
-                __LINE__
875
-            );
876
-        } elseif ($success === false) {
877
-            EE_Error::add_error(
878
-                esc_html__('Venue Details did not save successfully.', 'event_espresso'),
879
-                __FILE__,
880
-                __FUNCTION__,
881
-                __LINE__
882
-            );
883
-        }
884
-    }
885
-
886
-
887
-    /**
888
-     * @param int $post_id
889
-     * @throws EE_Error
890
-     * @throws ReflectionException
891
-     */
892
-    public function trash_cpt_item($post_id)
893
-    {
894
-        $this->request->setRequestParam('VNU_ID', $post_id);
895
-        $this->_trash_or_restore_venue('trash', false);
896
-    }
897
-
898
-
899
-    /**
900
-     * @param int $post_id
901
-     * @throws EE_Error
902
-     * @throws ReflectionException
903
-     */
904
-    public function restore_cpt_item($post_id)
905
-    {
906
-        $this->request->setRequestParam('VNU_ID', $post_id);
907
-        $this->_trash_or_restore_venue('draft', false);
908
-    }
909
-
910
-
911
-    /**
912
-     * @param int $post_id
913
-     * @throws EE_Error
914
-     * @throws ReflectionException
915
-     */
916
-    public function delete_cpt_item($post_id)
917
-    {
918
-        $this->request->setRequestParam('VNU_ID', $post_id);
919
-        $this->_delete_venue(false);
920
-    }
921
-
922
-
923
-    public function get_venue_object()
924
-    {
925
-        return $this->_cpt_model_obj;
926
-    }
927
-
928
-
929
-    /**
930
-     * @throws EE_Error
931
-     * @throws ReflectionException
932
-     */
933
-    protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
934
-    {
935
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
936
-
937
-        // loop thru venues
938
-        if ($VNU_ID) {
939
-            // clean status
940
-            $venue_status = sanitize_key($venue_status);
941
-            // grab status
942
-            if (! empty($venue_status)) {
943
-                $success = $this->_change_venue_status($VNU_ID, $venue_status);
944
-            } else {
945
-                $success = false;
946
-                $msg     = esc_html__(
947
-                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
948
-                    'event_espresso'
949
-                );
950
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
951
-            }
952
-        } else {
953
-            $success = false;
954
-            $msg     = esc_html__(
955
-                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
956
-                'event_espresso'
957
-            );
958
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
959
-        }
960
-        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
961
-
962
-        if ($redirect_after) {
963
-            $this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
964
-        }
965
-    }
966
-
967
-
968
-    /**
969
-     * @throws EE_Error
970
-     * @throws ReflectionException
971
-     */
972
-    protected function _trash_or_restore_venues($venue_status = 'trash')
973
-    {
974
-        // clean status
975
-        $venue_status = sanitize_key($venue_status);
976
-        // grab status
977
-        if (! empty($venue_status)) {
978
-            $success = true;
979
-            // determine the event id and set to array.
980
-            $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
981
-            // loop thru events
982
-            foreach ($VNU_IDs as $VNU_ID) {
983
-                if ($VNU_ID = absint($VNU_ID)) {
984
-                    $results = $this->_change_venue_status($VNU_ID, $venue_status);
985
-                    $success = $results !== false ? $success : false;
986
-                } else {
987
-                    $msg = sprintf(
988
-                        esc_html__(
989
-                            'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
990
-                            'event_espresso'
991
-                        ),
992
-                        $VNU_ID
993
-                    );
994
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
995
-                    $success = false;
996
-                }
997
-            }
998
-        } else {
999
-            $success = false;
1000
-            $msg     = esc_html__(
1001
-                'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1002
-                'event_espresso'
1003
-            );
1004
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1005
-        }
1006
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1007
-        $success = $success ? 2 : false;
1008
-        $action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1009
-        $this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1010
-    }
1011
-
1012
-
1013
-    /**
1014
-     * _trash_or_restore_venues
1015
-     *
1016
-     * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1017
-     * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1018
-     * accepting a certain number of params.
1019
-     *
1020
-     * @access  private
1021
-     * @param int    $VNU_ID
1022
-     * @param string $venue_status
1023
-     * @return bool
1024
-     * @throws EE_Error
1025
-     * @throws ReflectionException
1026
-     */
1027
-    private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1028
-    {
1029
-        // grab venue id
1030
-        if (! $VNU_ID) {
1031
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1032
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1033
-            return false;
1034
-        }
1035
-
1036
-        $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1037
-
1038
-        // clean status
1039
-        $venue_status = sanitize_key($venue_status);
1040
-        // grab status
1041
-        if (! $venue_status) {
1042
-            $msg = esc_html__(
1043
-                'An error occurred. No Venue Status or an invalid Venue Status was received.',
1044
-                'event_espresso'
1045
-            );
1046
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1047
-            return false;
1048
-        }
1049
-
1050
-        // was event trashed or restored ?
1051
-        switch ($venue_status) {
1052
-            case 'draft':
1053
-                $action = 'restored from the trash';
1054
-                $hook   = 'AHEE_venue_restored_from_trash';
1055
-                break;
1056
-            case 'trash':
1057
-                $action = 'moved to the trash';
1058
-                $hook   = 'AHEE_venue_moved_to_trash';
1059
-                break;
1060
-            default:
1061
-                $action = 'updated';
1062
-                $hook   = false;
1063
-        }
1064
-        // use class to change status
1065
-        $this->_cpt_model_obj->set_status($venue_status);
1066
-        $success = $this->_cpt_model_obj->save();
1067
-
1068
-        if ($success === false) {
1069
-            $msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1070
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1071
-            return false;
1072
-        }
1073
-        if ($hook) {
1074
-            do_action($hook);
1075
-        }
1076
-        return true;
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     * @param bool $redirect_after
1082
-     * @return void
1083
-     * @throws EE_Error
1084
-     * @throws ReflectionException
1085
-     */
1086
-    protected function _delete_venue($redirect_after = true)
1087
-    {
1088
-        // determine the venue id and set to array.
1089
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1090
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1091
-
1092
-        // loop thru venues
1093
-        if ($VNU_ID) {
1094
-            $success = $this->_delete_or_trash_venue($VNU_ID);
1095
-        } else {
1096
-            $success = false;
1097
-            $msg     = esc_html__(
1098
-                'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1099
-                'event_espresso'
1100
-            );
1101
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1102
-        }
1103
-        if ($redirect_after) {
1104
-            $this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1105
-        }
1106
-    }
1107
-
1108
-
1109
-    /**
1110
-     * @throws EE_Error
1111
-     * @throws ReflectionException
1112
-     */
1113
-    protected function _delete_venues()
1114
-    {
1115
-        $success = true;
1116
-        // determine the event id and set to array.
1117
-        $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1118
-        // loop thru events
1119
-        foreach ($VNU_IDs as $VNU_ID) {
1120
-            if ($VNU_ID = absint($VNU_ID)) {
1121
-                $results = $this->_delete_or_trash_venue($VNU_ID);
1122
-                $success = $results !== false ? $success : false;
1123
-            } else {
1124
-                $success = false;
1125
-                $msg     = esc_html__(
1126
-                    'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1127
-                    'event_espresso'
1128
-                );
1129
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1130
-            }
1131
-        }
1132
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1133
-        $success = $success ? 2 : false;
1134
-        $this->_redirect_after_action(
1135
-            $success,
1136
-            esc_html__('Venues', 'event_espresso'),
1137
-            esc_html__('deleted', 'event_espresso'),
1138
-            ['action' => 'default']
1139
-        );
1140
-    }
1141
-
1142
-
1143
-    // todo: put in parent
1144
-
1145
-
1146
-    /**
1147
-     * @throws EE_Error
1148
-     * @throws ReflectionException
1149
-     */
1150
-    private function _delete_or_trash_venue($VNU_ID = false)
1151
-    {
1152
-        // grab event id
1153
-        if (! $VNU_ID = absint($VNU_ID)) {
1154
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1155
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1156
-            return false;
1157
-        }
1158
-
1159
-
1160
-        $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1161
-        // first need to remove all term relationships
1162
-        $venue->_remove_relations('Term_Taxonomy');
1163
-        $success = $venue->delete_permanently();
1164
-        // did it all go as planned ?
1165
-        if ($success) {
1166
-            $msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1167
-            EE_Error::add_success($msg);
1168
-        } else {
1169
-            $msg =
1170
-                sprintf(
1171
-                    esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1172
-                    $VNU_ID
1173
-                );
1174
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1175
-            return false;
1176
-        }
1177
-        do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1178
-        return true;
1179
-    }
1180
-
1181
-
1182
-
1183
-
1184
-    /***********/
1185
-    /* QUERIES */
1186
-
1187
-
1188
-    public function get_venues($per_page = 10, $count = false)
1189
-    {
1190
-
1191
-        $orderby = $this->request->getRequestParam('orderby', '');
1192
-
1193
-        switch ($orderby) {
1194
-            case 'id':
1195
-                $orderby = 'VNU_ID';
1196
-                break;
1197
-
1198
-            case 'capacity':
1199
-                $orderby = 'VNU_capacity';
1200
-                break;
1201
-
1202
-            case 'city':
1203
-                $orderby = 'VNU_city';
1204
-                break;
1205
-
1206
-            default:
1207
-                $orderby = 'VNU_name';
1208
-        }
1209
-
1210
-        $sort         = $this->request->getRequestParam('order', 'ASC');
1211
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1212
-        $per_page     = ! empty($per_page) ? $per_page : 10;
1213
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1214
-
1215
-        $offset = ($current_page - 1) * $per_page;
1216
-        $limit  = [$offset, $per_page];
1217
-
1218
-        $category = $this->request->getRequestParam('category');
1219
-        $category = $category > 0 ? $category : null;
1220
-
1221
-        $where = [];
1222
-
1223
-        // only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1224
-        $status = $this->request->getRequestParam('status');
1225
-        if ($status && $status !== 'all') {
1226
-            $where['status'] = $status;
1227
-        }
1228
-
1229
-        $venue_status = $this->request->getRequestParam('venue_status');
1230
-        if ($venue_status) {
1231
-            $where['status'] = $venue_status;
1232
-        }
1233
-
1234
-
1235
-        if ($category) {
1236
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1237
-            $where['Term_Taxonomy.term_id']  = $category;
1238
-        }
1239
-
1240
-
1241
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1242
-            $where['VNU_wp_user'] = get_current_user_id();
1243
-        } else {
1244
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1245
-                $where['OR'] = [
1246
-                    'status*restrict_private' => ['!=', 'private'],
1247
-                    'AND'                     => [
1248
-                        'status*inclusive' => ['=', 'private'],
1249
-                        'VNU_wp_user'      => get_current_user_id(),
1250
-                    ],
1251
-                ];
1252
-            }
1253
-        }
1254
-
1255
-        $search_term = $this->request->getRequestParam('s');
1256
-        if ($search_term) {
1257
-            $search_term = '%' . $search_term . '%';
1258
-            $where['OR'] = [
1259
-                'VNU_name'               => ['LIKE', $search_term],
1260
-                'VNU_desc'               => ['LIKE', $search_term],
1261
-                'VNU_short_desc'         => ['LIKE', $search_term],
1262
-                'VNU_address'            => ['LIKE', $search_term],
1263
-                'VNU_address2'           => ['LIKE', $search_term],
1264
-                'VNU_city'               => ['LIKE', $search_term],
1265
-                'VNU_zip'                => ['LIKE', $search_term],
1266
-                'VNU_phone'              => ['LIKE', $search_term],
1267
-                'VNU_url'                => ['LIKE', $search_term],
1268
-                'VNU_virtual_phone'      => ['LIKE', $search_term],
1269
-                'VNU_virtual_url'        => ['LIKE', $search_term],
1270
-                'VNU_google_map_link'    => ['LIKE', $search_term],
1271
-                'Event.EVT_name'         => ['LIKE', $search_term],
1272
-                'Event.EVT_desc'         => ['LIKE', $search_term],
1273
-                'Event.EVT_phone'        => ['LIKE', $search_term],
1274
-                'Event.EVT_external_URL' => ['LIKE', $search_term],
1275
-            ];
1276
-        }
1277
-
1278
-
1279
-        return $count
1280
-            ? $this->_venue_model->count([$where], 'VNU_ID')
1281
-            : $this->_venue_model->get_all(
1282
-                [$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1283
-            );
1284
-    }
1285
-
1286
-
1287
-
1288
-
1289
-    /** Venue Category Stuff **/
1290
-
1291
-    /**
1292
-     * set the _category property with the category object for the loaded page.
1293
-     *
1294
-     * @access private
1295
-     * @return void
1296
-     */
1297
-    private function _set_category_object()
1298
-    {
1299
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
1300
-            return;
1301
-        } // already have the category object so get out.
1302
-
1303
-        // set default category object
1304
-        $this->_set_empty_category_object();
1305
-
1306
-        // only set if we've got an id
1307
-        $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1308
-        if (! $category_ID) {
1309
-            return;
1310
-        }
1311
-
1312
-        $term = get_term($category_ID, 'espresso_venue_categories');
1313
-
1314
-
1315
-        if (! empty($term)) {
1316
-            $this->_category->category_name       = $term->name;
1317
-            $this->_category->category_identifier = $term->slug;
1318
-            $this->_category->category_desc       = $term->description;
1319
-            $this->_category->id                  = $term->term_id;
1320
-            $this->_category->parent              = $term->parent;
1321
-        }
1322
-    }
1323
-
1324
-
1325
-    private function _set_empty_category_object()
1326
-    {
1327
-        $this->_category                = new stdClass();
1328
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1329
-        $this->_category->id            = $this->_category->parent = 0;
1330
-    }
1331
-
1332
-
1333
-    /**
1334
-     * @throws EE_Error
1335
-     */
1336
-    protected function _category_list_table()
1337
-    {
1338
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1339
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1340
-            'add_category',
1341
-            'add_category',
1342
-            [],
1343
-            'add-new-h2'
1344
-        );
1345
-        $this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1346
-        $this->display_admin_list_table_page_with_sidebar();
1347
-    }
1348
-
1349
-
1350
-    /**
1351
-     * @throws EE_Error
1352
-     */
1353
-    protected function _category_details($view)
1354
-    {
1355
-
1356
-        // load formatter helper
1357
-        // load field generator helper
1358
-
1359
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
1360
-        $this->_set_add_edit_form_tags($route);
1361
-
1362
-        $this->_set_category_object();
1363
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
1364
-
1365
-        $delete_action = 'delete_category';
1366
-
1367
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1368
-
1369
-        $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1370
-
1371
-        // take care of contents
1372
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
1373
-        $this->display_admin_page_with_sidebar();
1374
-    }
1375
-
1376
-
1377
-    protected function _category_details_content()
1378
-    {
1379
-        $editor_args['category_desc'] = [
1380
-            'type'          => 'wp_editor',
1381
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1382
-            'class'         => 'my_editor_custom',
1383
-            'wpeditor_args' => ['media_buttons' => false],
1384
-        ];
1385
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1386
-
1387
-        $all_terms = get_terms(
1388
-            ['espresso_venue_categories'],
1389
-            ['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1390
-        );
1391
-
1392
-        // setup category select for term parents.
1393
-        $category_select_values[] = [
1394
-            'text' => esc_html__('No Parent', 'event_espresso'),
1395
-            'id'   => 0,
1396
-        ];
1397
-        foreach ($all_terms as $term) {
1398
-            $category_select_values[] = [
1399
-                'text' => $term->name,
1400
-                'id'   => $term->term_id,
1401
-            ];
1402
-        }
1403
-
1404
-        $category_select = EEH_Form_Fields::select_input(
1405
-            'category_parent',
1406
-            $category_select_values,
1407
-            $this->_category->parent
1408
-        );
1409
-        $template_args   = [
1410
-            'category'                 => $this->_category,
1411
-            'category_select'          => $category_select,
1412
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1413
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1414
-            'disable'                  => '',
1415
-            'disabled_message'         => false,
1416
-        ];
1417
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1418
-        return EEH_Template::display_template($template, $template_args, true);
1419
-    }
1420
-
1421
-
1422
-    /**
1423
-     * @throws EE_Error
1424
-     */
1425
-    protected function _delete_categories()
1426
-    {
1427
-        $category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1428
-        $category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1429
-
1430
-        foreach ($category_IDs as $cat_id) {
1431
-            $this->_delete_category($cat_id);
1432
-        }
1433
-
1434
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
1435
-        $query_args = [
1436
-            'action' => 'category_list',
1437
-        ];
1438
-        $this->_redirect_after_action(0, '', '', $query_args);
1439
-    }
1440
-
1441
-
1442
-    protected function _delete_category($cat_id)
1443
-    {
1444
-        $cat_id = absint($cat_id);
1445
-        wp_delete_term($cat_id, 'espresso_venue_categories');
1446
-    }
1447
-
1448
-
1449
-    /**
1450
-     * @throws EE_Error
1451
-     */
1452
-    protected function _insert_or_update_category($new_category)
1453
-    {
1454
-
1455
-        $cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1456
-        $success = 0; // we already have a success message so lets not send another.
1457
-        if ($cat_id) {
1458
-            $query_args = [
1459
-                'action'     => 'edit_category',
1460
-                'VEN_CAT_ID' => $cat_id,
1461
-            ];
1462
-        } else {
1463
-            $query_args = ['action' => 'add_category'];
1464
-        }
1465
-        $this->_redirect_after_action($success, '', '', $query_args, true);
1466
-    }
1467
-
1468
-
1469
-    private function _insert_category($update = false)
1470
-    {
1471
-        $category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1472
-        $category_name   = $this->request->getRequestParam('category_name', '');
1473
-        $category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1474
-        $category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1475
-
1476
-        if (empty($category_name)) {
1477
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
1478
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1479
-            return false;
1480
-        }
1481
-
1482
-
1483
-        $term_args = [
1484
-            'name'        => $category_name,
1485
-            'description' => $category_desc,
1486
-            'parent'      => $category_parent,
1487
-        ];
1488
-
1489
-        $insert_ids = $update
1490
-            ? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1491
-            : wp_insert_term(
1492
-                $category_name,
1493
-                'espresso_venue_categories',
1494
-                $term_args
1495
-            );
1496
-
1497
-        if (! is_array($insert_ids)) {
1498
-            EE_Error::add_error(
1499
-                esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1500
-                __FILE__,
1501
-                __FUNCTION__,
1502
-                __LINE__
1503
-            );
1504
-        } else {
1505
-            $category_ID = $insert_ids['term_id'];
1506
-            EE_Error::add_success(
1507
-                sprintf(
1508
-                    esc_html__('The category %s was successfully created', 'event_espresso'),
1509
-                    $category_name
1510
-                )
1511
-            );
1512
-        }
1513
-
1514
-        return $category_ID;
1515
-    }
1516
-
1517
-
1518
-    /**
1519
-     * TODO handle category exports()
1520
-     *
1521
-     * @return void
1522
-     */
1523
-    protected function _categories_export()
1524
-    {
1525
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
1526
-        $this->request->mergeRequestParams(
1527
-            [
1528
-                'export'       => 'report',
1529
-                'action'       => 'categories',
1530
-                'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1531
-            ]
1532
-        );
1533
-
1534
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1535
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1536
-            $EE_Export = EE_Export::instance($this->request->requestParams());
1537
-            $EE_Export->export();
1538
-        }
1539
-    }
1540
-
1541
-
1542
-    protected function _import_categories()
1543
-    {
1544
-
1545
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1546
-        EE_Import::instance()->import();
1547
-    }
1548
-
1549
-
1550
-    /**
1551
-     * @throws EE_Error
1552
-     */
1553
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
1554
-    {
1555
-
1556
-        // testing term stuff
1557
-        $orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1558
-        $order       = $this->request->getRequestParam('order', 'DESC');
1559
-        $limit       = ($current_page - 1) * $per_page;
1560
-        $where       = ['taxonomy' => 'espresso_venue_categories'];
1561
-        $search_term = $this->request->getRequestParam('s');
1562
-        if ($search_term) {
1563
-            $search_term = '%' . $search_term . '%';
1564
-            $where['OR'] = [
1565
-                'Term.name'   => ['LIKE', $search_term],
1566
-                'description' => ['LIKE', $search_term],
1567
-            ];
1568
-        }
1569
-
1570
-        $query_params = [
1571
-            $where,
1572
-            'order_by'   => [$orderby => $order],
1573
-            'limit'      => $limit . ',' . $per_page,
1574
-            'force_join' => ['Term'],
1575
-        ];
1576
-
1577
-        return $count
1578
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1579
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
1580
-    }
1581
-
1582
-
1583
-    /* end category stuff */
1584
-    /**************/
583
+	protected function _google_map_settings()
584
+	{
585
+
586
+
587
+		$this->_template_args['values']           = $this->_yes_no_values;
588
+		$default_map_settings                     = new stdClass();
589
+		$default_map_settings->use_google_maps    = true;
590
+		$default_map_settings->google_map_api_key = '';
591
+		// for event details pages (reg page)
592
+		$default_map_settings->event_details_map_width    = 585;
593
+		// ee_map_width_single
594
+		$default_map_settings->event_details_map_height   = 362;
595
+		// ee_map_height_single
596
+		$default_map_settings->event_details_map_zoom     = 14;
597
+		// ee_map_zoom_single
598
+		$default_map_settings->event_details_display_nav  = true;
599
+		// ee_map_nav_display_single
600
+		$default_map_settings->event_details_nav_size     = false;
601
+		// ee_map_nav_size_single
602
+		$default_map_settings->event_details_control_type = 'default';
603
+		// ee_map_type_control_single
604
+		$default_map_settings->event_details_map_align    = 'center';
605
+		// ee_map_align_single
606
+
607
+		// for event list pages
608
+		$default_map_settings->event_list_map_width    = 300;
609
+		// ee_map_width
610
+		$default_map_settings->event_list_map_height   = 185;
611
+		// ee_map_height
612
+		$default_map_settings->event_list_map_zoom     = 12;
613
+		// ee_map_zoom
614
+		$default_map_settings->event_list_display_nav  = false;
615
+		// ee_map_nav_display
616
+		$default_map_settings->event_list_nav_size     = true;
617
+		// ee_map_nav_size
618
+		$default_map_settings->event_list_control_type = 'dropdown';
619
+		// ee_map_type_control
620
+		$default_map_settings->event_list_map_align    = 'center';
621
+		// ee_map_align
622
+
623
+		$this->_template_args['map_settings'] =
624
+			isset(EE_Registry::instance()->CFG->map_settings)
625
+			&& ! empty(EE_Registry::instance()->CFG->map_settings)
626
+				? (object) array_merge(
627
+					(array) $default_map_settings,
628
+					(array) EE_Registry::instance()->CFG->map_settings
629
+				)
630
+				: $default_map_settings;
631
+
632
+		$this->_set_add_edit_form_tags('update_google_map_settings');
633
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
634
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
635
+			EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
636
+			$this->_template_args,
637
+			true
638
+		);
639
+		$this->display_admin_page_with_sidebar();
640
+	}
641
+
642
+
643
+	/**
644
+	 * @throws EE_Error
645
+	 */
646
+	protected function _update_google_map_settings()
647
+	{
648
+		$map_settings = EE_Registry::instance()->CFG->map_settings;
649
+
650
+		$settings = [
651
+			'use_google_maps'            => 'int',
652
+			'google_map_api_key'         => 'string',
653
+			'event_details_map_width'    => 'int',
654
+			'event_details_map_zoom'     => 'int',
655
+			'event_details_display_nav'  => 'int',
656
+			'event_details_nav_size'     => 'int',
657
+			'event_details_control_type' => 'string',
658
+			'event_details_map_align'    => 'string',
659
+			'event_list_map_width'       => 'int',
660
+			'event_list_map_height'      => 'int',
661
+			'event_list_map_zoom'        => 'int',
662
+			'event_list_display_nav'     => 'int',
663
+			'event_list_nav_size'        => 'int',
664
+			'event_list_control_type'    => 'string',
665
+			'event_list_map_align'       => 'string',
666
+		];
667
+
668
+		foreach ($settings as $setting => $type) {
669
+			$map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
670
+		}
671
+
672
+		EE_Registry::instance()->CFG->map_settings = apply_filters(
673
+			'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
674
+			$map_settings
675
+		);
676
+
677
+		$what    = 'Google Map Settings';
678
+		$success = $this->_update_espresso_configuration(
679
+			$what,
680
+			EE_Registry::instance()->CFG->map_settings,
681
+			__FILE__,
682
+			__FUNCTION__,
683
+			__LINE__
684
+		);
685
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
686
+	}
687
+
688
+
689
+	/**
690
+	 * @throws EE_Error
691
+	 * @throws ReflectionException
692
+	 */
693
+	protected function _venue_editor_metaboxes()
694
+	{
695
+		$this->verify_cpt_object();
696
+
697
+		$this->addMetaBox(
698
+			'espresso_venue_address_options',
699
+			esc_html__('Physical Location', 'event_espresso'),
700
+			[$this, 'venue_address_metabox'],
701
+			$this->page_slug,
702
+			'side'
703
+		);
704
+		$this->addMetaBox(
705
+			'espresso_venue_gmap_options',
706
+			esc_html__('Google Map', 'event_espresso'),
707
+			[$this, 'venue_gmap_metabox'],
708
+			$this->page_slug,
709
+			'side'
710
+		);
711
+		$this->addMetaBox(
712
+			'espresso_venue_virtual_loc_options',
713
+			esc_html__('Virtual Location', 'event_espresso'),
714
+			[$this, 'venue_virtual_loc_metabox'],
715
+			$this->page_slug,
716
+			'side'
717
+		);
718
+	}
719
+
720
+
721
+	public function venue_gmap_metabox()
722
+	{
723
+		$template_args = [
724
+			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
725
+				'vnu_enable_for_gmap',
726
+				$this->get_yes_no_values(),
727
+				$this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
728
+			),
729
+			'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
730
+		];
731
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
732
+		EEH_Template::display_template($template, $template_args);
733
+	}
734
+
735
+
736
+	/**
737
+	 * @throws EE_Error
738
+	 * @throws ReflectionException
739
+	 */
740
+	public function venue_address_metabox()
741
+	{
742
+		$template_args['_venue'] = $this->_cpt_model_obj;
743
+
744
+		$template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
745
+			new EE_Question_Form_Input(
746
+				EE_Question::new_instance(
747
+					['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
748
+				),
749
+				EE_Answer::new_instance(
750
+					[
751
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
752
+							? $this->_cpt_model_obj->state_ID()
753
+							: 0,
754
+					]
755
+				),
756
+				[
757
+					'input_name'     => 'sta_id',
758
+					'input_id'       => 'sta_id',
759
+					'input_class'    => '',
760
+					'input_prefix'   => '',
761
+					'append_qstn_id' => false,
762
+				]
763
+			)
764
+		);
765
+		$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
766
+			new EE_Question_Form_Input(
767
+				EE_Question::new_instance(
768
+					['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
769
+				),
770
+				EE_Answer::new_instance(
771
+					[
772
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
773
+							? $this->_cpt_model_obj->country_ID()
774
+							: 0,
775
+					]
776
+				),
777
+				[
778
+					'input_name'     => 'cnt_iso',
779
+					'input_id'       => 'cnt_iso',
780
+					'input_class'    => '',
781
+					'input_prefix'   => '',
782
+					'append_qstn_id' => false,
783
+				]
784
+			)
785
+		);
786
+
787
+		$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
788
+		EEH_Template::display_template($template, $template_args);
789
+	}
790
+
791
+
792
+	public function venue_virtual_loc_metabox()
793
+	{
794
+		$template_args = [
795
+			'_venue' => $this->_cpt_model_obj,
796
+		];
797
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
798
+		EEH_Template::display_template($template, $template_args);
799
+	}
800
+
801
+
802
+	protected function _restore_cpt_item($post_id, $revision_id)
803
+	{
804
+		$venue_obj = $this->_venue_model->get_one_by_ID($post_id);
805
+
806
+		// meta revision restore
807
+		$venue_obj->restore_revision($revision_id);
808
+	}
809
+
810
+
811
+	/**
812
+	 * Handles updates for venue cpts
813
+	 *
814
+	 * @param int    $post_id ID of Venue CPT
815
+	 * @param WP_Post $post    Post object (with "blessed" WP properties)
816
+	 * @return void
817
+	 */
818
+	protected function _insert_update_cpt_item($post_id, $post)
819
+	{
820
+
821
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
822
+			return;// get out we're not processing the saving of venues.
823
+		}
824
+
825
+		$wheres = [$this->_venue_model->primary_key_name() => $post_id];
826
+
827
+		$venue_values = [
828
+			'VNU_address'         => $this->request->getRequestParam('vnu_address'),
829
+			'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
830
+			'VNU_city'            => $this->request->getRequestParam('vnu_city'),
831
+			'STA_ID'              => $this->request->getRequestParam('sta_id'),
832
+			'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
833
+			'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
834
+			'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
835
+			'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
836
+				? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
837
+				: EE_INF,
838
+			'VNU_url'             => $this->request->getRequestParam('vnu_url'),
839
+			'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
840
+			'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
841
+			'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
842
+			'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
843
+		];
844
+
845
+		// update venue
846
+		$success = $this->_venue_model->update($venue_values, [$wheres]);
847
+
848
+		// 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!
849
+		$get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
850
+		$venue         = $this->_venue_model->get_one([$get_one_where]);
851
+
852
+		// 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.
853
+		$venue_update_callbacks = apply_filters(
854
+			'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
855
+			[]
856
+		);
857
+		$att_success            = true;
858
+		foreach ($venue_update_callbacks as $v_callback) {
859
+			// if ANY of these updates fail then we want the appropriate global error message
860
+			$att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
861
+				? $att_success
862
+				: false;
863
+		}
864
+
865
+		// any errors?
866
+		if ($success && ! $att_success) {
867
+			EE_Error::add_error(
868
+				esc_html__(
869
+					'Venue Details saved successfully but something went wrong with saving attachments.',
870
+					'event_espresso'
871
+				),
872
+				__FILE__,
873
+				__FUNCTION__,
874
+				__LINE__
875
+			);
876
+		} elseif ($success === false) {
877
+			EE_Error::add_error(
878
+				esc_html__('Venue Details did not save successfully.', 'event_espresso'),
879
+				__FILE__,
880
+				__FUNCTION__,
881
+				__LINE__
882
+			);
883
+		}
884
+	}
885
+
886
+
887
+	/**
888
+	 * @param int $post_id
889
+	 * @throws EE_Error
890
+	 * @throws ReflectionException
891
+	 */
892
+	public function trash_cpt_item($post_id)
893
+	{
894
+		$this->request->setRequestParam('VNU_ID', $post_id);
895
+		$this->_trash_or_restore_venue('trash', false);
896
+	}
897
+
898
+
899
+	/**
900
+	 * @param int $post_id
901
+	 * @throws EE_Error
902
+	 * @throws ReflectionException
903
+	 */
904
+	public function restore_cpt_item($post_id)
905
+	{
906
+		$this->request->setRequestParam('VNU_ID', $post_id);
907
+		$this->_trash_or_restore_venue('draft', false);
908
+	}
909
+
910
+
911
+	/**
912
+	 * @param int $post_id
913
+	 * @throws EE_Error
914
+	 * @throws ReflectionException
915
+	 */
916
+	public function delete_cpt_item($post_id)
917
+	{
918
+		$this->request->setRequestParam('VNU_ID', $post_id);
919
+		$this->_delete_venue(false);
920
+	}
921
+
922
+
923
+	public function get_venue_object()
924
+	{
925
+		return $this->_cpt_model_obj;
926
+	}
927
+
928
+
929
+	/**
930
+	 * @throws EE_Error
931
+	 * @throws ReflectionException
932
+	 */
933
+	protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
934
+	{
935
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
936
+
937
+		// loop thru venues
938
+		if ($VNU_ID) {
939
+			// clean status
940
+			$venue_status = sanitize_key($venue_status);
941
+			// grab status
942
+			if (! empty($venue_status)) {
943
+				$success = $this->_change_venue_status($VNU_ID, $venue_status);
944
+			} else {
945
+				$success = false;
946
+				$msg     = esc_html__(
947
+					'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
948
+					'event_espresso'
949
+				);
950
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
951
+			}
952
+		} else {
953
+			$success = false;
954
+			$msg     = esc_html__(
955
+				'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
956
+				'event_espresso'
957
+			);
958
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
959
+		}
960
+		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
961
+
962
+		if ($redirect_after) {
963
+			$this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
964
+		}
965
+	}
966
+
967
+
968
+	/**
969
+	 * @throws EE_Error
970
+	 * @throws ReflectionException
971
+	 */
972
+	protected function _trash_or_restore_venues($venue_status = 'trash')
973
+	{
974
+		// clean status
975
+		$venue_status = sanitize_key($venue_status);
976
+		// grab status
977
+		if (! empty($venue_status)) {
978
+			$success = true;
979
+			// determine the event id and set to array.
980
+			$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
981
+			// loop thru events
982
+			foreach ($VNU_IDs as $VNU_ID) {
983
+				if ($VNU_ID = absint($VNU_ID)) {
984
+					$results = $this->_change_venue_status($VNU_ID, $venue_status);
985
+					$success = $results !== false ? $success : false;
986
+				} else {
987
+					$msg = sprintf(
988
+						esc_html__(
989
+							'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
990
+							'event_espresso'
991
+						),
992
+						$VNU_ID
993
+					);
994
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
995
+					$success = false;
996
+				}
997
+			}
998
+		} else {
999
+			$success = false;
1000
+			$msg     = esc_html__(
1001
+				'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1002
+				'event_espresso'
1003
+			);
1004
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1005
+		}
1006
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1007
+		$success = $success ? 2 : false;
1008
+		$action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1009
+		$this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1010
+	}
1011
+
1012
+
1013
+	/**
1014
+	 * _trash_or_restore_venues
1015
+	 *
1016
+	 * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1017
+	 * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1018
+	 * accepting a certain number of params.
1019
+	 *
1020
+	 * @access  private
1021
+	 * @param int    $VNU_ID
1022
+	 * @param string $venue_status
1023
+	 * @return bool
1024
+	 * @throws EE_Error
1025
+	 * @throws ReflectionException
1026
+	 */
1027
+	private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1028
+	{
1029
+		// grab venue id
1030
+		if (! $VNU_ID) {
1031
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1032
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1033
+			return false;
1034
+		}
1035
+
1036
+		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1037
+
1038
+		// clean status
1039
+		$venue_status = sanitize_key($venue_status);
1040
+		// grab status
1041
+		if (! $venue_status) {
1042
+			$msg = esc_html__(
1043
+				'An error occurred. No Venue Status or an invalid Venue Status was received.',
1044
+				'event_espresso'
1045
+			);
1046
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1047
+			return false;
1048
+		}
1049
+
1050
+		// was event trashed or restored ?
1051
+		switch ($venue_status) {
1052
+			case 'draft':
1053
+				$action = 'restored from the trash';
1054
+				$hook   = 'AHEE_venue_restored_from_trash';
1055
+				break;
1056
+			case 'trash':
1057
+				$action = 'moved to the trash';
1058
+				$hook   = 'AHEE_venue_moved_to_trash';
1059
+				break;
1060
+			default:
1061
+				$action = 'updated';
1062
+				$hook   = false;
1063
+		}
1064
+		// use class to change status
1065
+		$this->_cpt_model_obj->set_status($venue_status);
1066
+		$success = $this->_cpt_model_obj->save();
1067
+
1068
+		if ($success === false) {
1069
+			$msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1070
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1071
+			return false;
1072
+		}
1073
+		if ($hook) {
1074
+			do_action($hook);
1075
+		}
1076
+		return true;
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 * @param bool $redirect_after
1082
+	 * @return void
1083
+	 * @throws EE_Error
1084
+	 * @throws ReflectionException
1085
+	 */
1086
+	protected function _delete_venue($redirect_after = true)
1087
+	{
1088
+		// determine the venue id and set to array.
1089
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1090
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1091
+
1092
+		// loop thru venues
1093
+		if ($VNU_ID) {
1094
+			$success = $this->_delete_or_trash_venue($VNU_ID);
1095
+		} else {
1096
+			$success = false;
1097
+			$msg     = esc_html__(
1098
+				'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1099
+				'event_espresso'
1100
+			);
1101
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1102
+		}
1103
+		if ($redirect_after) {
1104
+			$this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1105
+		}
1106
+	}
1107
+
1108
+
1109
+	/**
1110
+	 * @throws EE_Error
1111
+	 * @throws ReflectionException
1112
+	 */
1113
+	protected function _delete_venues()
1114
+	{
1115
+		$success = true;
1116
+		// determine the event id and set to array.
1117
+		$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1118
+		// loop thru events
1119
+		foreach ($VNU_IDs as $VNU_ID) {
1120
+			if ($VNU_ID = absint($VNU_ID)) {
1121
+				$results = $this->_delete_or_trash_venue($VNU_ID);
1122
+				$success = $results !== false ? $success : false;
1123
+			} else {
1124
+				$success = false;
1125
+				$msg     = esc_html__(
1126
+					'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1127
+					'event_espresso'
1128
+				);
1129
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1130
+			}
1131
+		}
1132
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1133
+		$success = $success ? 2 : false;
1134
+		$this->_redirect_after_action(
1135
+			$success,
1136
+			esc_html__('Venues', 'event_espresso'),
1137
+			esc_html__('deleted', 'event_espresso'),
1138
+			['action' => 'default']
1139
+		);
1140
+	}
1141
+
1142
+
1143
+	// todo: put in parent
1144
+
1145
+
1146
+	/**
1147
+	 * @throws EE_Error
1148
+	 * @throws ReflectionException
1149
+	 */
1150
+	private function _delete_or_trash_venue($VNU_ID = false)
1151
+	{
1152
+		// grab event id
1153
+		if (! $VNU_ID = absint($VNU_ID)) {
1154
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1155
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1156
+			return false;
1157
+		}
1158
+
1159
+
1160
+		$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1161
+		// first need to remove all term relationships
1162
+		$venue->_remove_relations('Term_Taxonomy');
1163
+		$success = $venue->delete_permanently();
1164
+		// did it all go as planned ?
1165
+		if ($success) {
1166
+			$msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1167
+			EE_Error::add_success($msg);
1168
+		} else {
1169
+			$msg =
1170
+				sprintf(
1171
+					esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1172
+					$VNU_ID
1173
+				);
1174
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1175
+			return false;
1176
+		}
1177
+		do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1178
+		return true;
1179
+	}
1180
+
1181
+
1182
+
1183
+
1184
+	/***********/
1185
+	/* QUERIES */
1186
+
1187
+
1188
+	public function get_venues($per_page = 10, $count = false)
1189
+	{
1190
+
1191
+		$orderby = $this->request->getRequestParam('orderby', '');
1192
+
1193
+		switch ($orderby) {
1194
+			case 'id':
1195
+				$orderby = 'VNU_ID';
1196
+				break;
1197
+
1198
+			case 'capacity':
1199
+				$orderby = 'VNU_capacity';
1200
+				break;
1201
+
1202
+			case 'city':
1203
+				$orderby = 'VNU_city';
1204
+				break;
1205
+
1206
+			default:
1207
+				$orderby = 'VNU_name';
1208
+		}
1209
+
1210
+		$sort         = $this->request->getRequestParam('order', 'ASC');
1211
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1212
+		$per_page     = ! empty($per_page) ? $per_page : 10;
1213
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1214
+
1215
+		$offset = ($current_page - 1) * $per_page;
1216
+		$limit  = [$offset, $per_page];
1217
+
1218
+		$category = $this->request->getRequestParam('category');
1219
+		$category = $category > 0 ? $category : null;
1220
+
1221
+		$where = [];
1222
+
1223
+		// only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1224
+		$status = $this->request->getRequestParam('status');
1225
+		if ($status && $status !== 'all') {
1226
+			$where['status'] = $status;
1227
+		}
1228
+
1229
+		$venue_status = $this->request->getRequestParam('venue_status');
1230
+		if ($venue_status) {
1231
+			$where['status'] = $venue_status;
1232
+		}
1233
+
1234
+
1235
+		if ($category) {
1236
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1237
+			$where['Term_Taxonomy.term_id']  = $category;
1238
+		}
1239
+
1240
+
1241
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1242
+			$where['VNU_wp_user'] = get_current_user_id();
1243
+		} else {
1244
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1245
+				$where['OR'] = [
1246
+					'status*restrict_private' => ['!=', 'private'],
1247
+					'AND'                     => [
1248
+						'status*inclusive' => ['=', 'private'],
1249
+						'VNU_wp_user'      => get_current_user_id(),
1250
+					],
1251
+				];
1252
+			}
1253
+		}
1254
+
1255
+		$search_term = $this->request->getRequestParam('s');
1256
+		if ($search_term) {
1257
+			$search_term = '%' . $search_term . '%';
1258
+			$where['OR'] = [
1259
+				'VNU_name'               => ['LIKE', $search_term],
1260
+				'VNU_desc'               => ['LIKE', $search_term],
1261
+				'VNU_short_desc'         => ['LIKE', $search_term],
1262
+				'VNU_address'            => ['LIKE', $search_term],
1263
+				'VNU_address2'           => ['LIKE', $search_term],
1264
+				'VNU_city'               => ['LIKE', $search_term],
1265
+				'VNU_zip'                => ['LIKE', $search_term],
1266
+				'VNU_phone'              => ['LIKE', $search_term],
1267
+				'VNU_url'                => ['LIKE', $search_term],
1268
+				'VNU_virtual_phone'      => ['LIKE', $search_term],
1269
+				'VNU_virtual_url'        => ['LIKE', $search_term],
1270
+				'VNU_google_map_link'    => ['LIKE', $search_term],
1271
+				'Event.EVT_name'         => ['LIKE', $search_term],
1272
+				'Event.EVT_desc'         => ['LIKE', $search_term],
1273
+				'Event.EVT_phone'        => ['LIKE', $search_term],
1274
+				'Event.EVT_external_URL' => ['LIKE', $search_term],
1275
+			];
1276
+		}
1277
+
1278
+
1279
+		return $count
1280
+			? $this->_venue_model->count([$where], 'VNU_ID')
1281
+			: $this->_venue_model->get_all(
1282
+				[$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1283
+			);
1284
+	}
1285
+
1286
+
1287
+
1288
+
1289
+	/** Venue Category Stuff **/
1290
+
1291
+	/**
1292
+	 * set the _category property with the category object for the loaded page.
1293
+	 *
1294
+	 * @access private
1295
+	 * @return void
1296
+	 */
1297
+	private function _set_category_object()
1298
+	{
1299
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
1300
+			return;
1301
+		} // already have the category object so get out.
1302
+
1303
+		// set default category object
1304
+		$this->_set_empty_category_object();
1305
+
1306
+		// only set if we've got an id
1307
+		$category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1308
+		if (! $category_ID) {
1309
+			return;
1310
+		}
1311
+
1312
+		$term = get_term($category_ID, 'espresso_venue_categories');
1313
+
1314
+
1315
+		if (! empty($term)) {
1316
+			$this->_category->category_name       = $term->name;
1317
+			$this->_category->category_identifier = $term->slug;
1318
+			$this->_category->category_desc       = $term->description;
1319
+			$this->_category->id                  = $term->term_id;
1320
+			$this->_category->parent              = $term->parent;
1321
+		}
1322
+	}
1323
+
1324
+
1325
+	private function _set_empty_category_object()
1326
+	{
1327
+		$this->_category                = new stdClass();
1328
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1329
+		$this->_category->id            = $this->_category->parent = 0;
1330
+	}
1331
+
1332
+
1333
+	/**
1334
+	 * @throws EE_Error
1335
+	 */
1336
+	protected function _category_list_table()
1337
+	{
1338
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1339
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1340
+			'add_category',
1341
+			'add_category',
1342
+			[],
1343
+			'add-new-h2'
1344
+		);
1345
+		$this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1346
+		$this->display_admin_list_table_page_with_sidebar();
1347
+	}
1348
+
1349
+
1350
+	/**
1351
+	 * @throws EE_Error
1352
+	 */
1353
+	protected function _category_details($view)
1354
+	{
1355
+
1356
+		// load formatter helper
1357
+		// load field generator helper
1358
+
1359
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
1360
+		$this->_set_add_edit_form_tags($route);
1361
+
1362
+		$this->_set_category_object();
1363
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
1364
+
1365
+		$delete_action = 'delete_category';
1366
+
1367
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1368
+
1369
+		$this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1370
+
1371
+		// take care of contents
1372
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
1373
+		$this->display_admin_page_with_sidebar();
1374
+	}
1375
+
1376
+
1377
+	protected function _category_details_content()
1378
+	{
1379
+		$editor_args['category_desc'] = [
1380
+			'type'          => 'wp_editor',
1381
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1382
+			'class'         => 'my_editor_custom',
1383
+			'wpeditor_args' => ['media_buttons' => false],
1384
+		];
1385
+		$_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1386
+
1387
+		$all_terms = get_terms(
1388
+			['espresso_venue_categories'],
1389
+			['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1390
+		);
1391
+
1392
+		// setup category select for term parents.
1393
+		$category_select_values[] = [
1394
+			'text' => esc_html__('No Parent', 'event_espresso'),
1395
+			'id'   => 0,
1396
+		];
1397
+		foreach ($all_terms as $term) {
1398
+			$category_select_values[] = [
1399
+				'text' => $term->name,
1400
+				'id'   => $term->term_id,
1401
+			];
1402
+		}
1403
+
1404
+		$category_select = EEH_Form_Fields::select_input(
1405
+			'category_parent',
1406
+			$category_select_values,
1407
+			$this->_category->parent
1408
+		);
1409
+		$template_args   = [
1410
+			'category'                 => $this->_category,
1411
+			'category_select'          => $category_select,
1412
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1413
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1414
+			'disable'                  => '',
1415
+			'disabled_message'         => false,
1416
+		];
1417
+		$template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1418
+		return EEH_Template::display_template($template, $template_args, true);
1419
+	}
1420
+
1421
+
1422
+	/**
1423
+	 * @throws EE_Error
1424
+	 */
1425
+	protected function _delete_categories()
1426
+	{
1427
+		$category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1428
+		$category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1429
+
1430
+		foreach ($category_IDs as $cat_id) {
1431
+			$this->_delete_category($cat_id);
1432
+		}
1433
+
1434
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
1435
+		$query_args = [
1436
+			'action' => 'category_list',
1437
+		];
1438
+		$this->_redirect_after_action(0, '', '', $query_args);
1439
+	}
1440
+
1441
+
1442
+	protected function _delete_category($cat_id)
1443
+	{
1444
+		$cat_id = absint($cat_id);
1445
+		wp_delete_term($cat_id, 'espresso_venue_categories');
1446
+	}
1447
+
1448
+
1449
+	/**
1450
+	 * @throws EE_Error
1451
+	 */
1452
+	protected function _insert_or_update_category($new_category)
1453
+	{
1454
+
1455
+		$cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1456
+		$success = 0; // we already have a success message so lets not send another.
1457
+		if ($cat_id) {
1458
+			$query_args = [
1459
+				'action'     => 'edit_category',
1460
+				'VEN_CAT_ID' => $cat_id,
1461
+			];
1462
+		} else {
1463
+			$query_args = ['action' => 'add_category'];
1464
+		}
1465
+		$this->_redirect_after_action($success, '', '', $query_args, true);
1466
+	}
1467
+
1468
+
1469
+	private function _insert_category($update = false)
1470
+	{
1471
+		$category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1472
+		$category_name   = $this->request->getRequestParam('category_name', '');
1473
+		$category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1474
+		$category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1475
+
1476
+		if (empty($category_name)) {
1477
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
1478
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1479
+			return false;
1480
+		}
1481
+
1482
+
1483
+		$term_args = [
1484
+			'name'        => $category_name,
1485
+			'description' => $category_desc,
1486
+			'parent'      => $category_parent,
1487
+		];
1488
+
1489
+		$insert_ids = $update
1490
+			? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1491
+			: wp_insert_term(
1492
+				$category_name,
1493
+				'espresso_venue_categories',
1494
+				$term_args
1495
+			);
1496
+
1497
+		if (! is_array($insert_ids)) {
1498
+			EE_Error::add_error(
1499
+				esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1500
+				__FILE__,
1501
+				__FUNCTION__,
1502
+				__LINE__
1503
+			);
1504
+		} else {
1505
+			$category_ID = $insert_ids['term_id'];
1506
+			EE_Error::add_success(
1507
+				sprintf(
1508
+					esc_html__('The category %s was successfully created', 'event_espresso'),
1509
+					$category_name
1510
+				)
1511
+			);
1512
+		}
1513
+
1514
+		return $category_ID;
1515
+	}
1516
+
1517
+
1518
+	/**
1519
+	 * TODO handle category exports()
1520
+	 *
1521
+	 * @return void
1522
+	 */
1523
+	protected function _categories_export()
1524
+	{
1525
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
1526
+		$this->request->mergeRequestParams(
1527
+			[
1528
+				'export'       => 'report',
1529
+				'action'       => 'categories',
1530
+				'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1531
+			]
1532
+		);
1533
+
1534
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1535
+			require_once(EE_CLASSES . 'EE_Export.class.php');
1536
+			$EE_Export = EE_Export::instance($this->request->requestParams());
1537
+			$EE_Export->export();
1538
+		}
1539
+	}
1540
+
1541
+
1542
+	protected function _import_categories()
1543
+	{
1544
+
1545
+		require_once(EE_CLASSES . 'EE_Import.class.php');
1546
+		EE_Import::instance()->import();
1547
+	}
1548
+
1549
+
1550
+	/**
1551
+	 * @throws EE_Error
1552
+	 */
1553
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
1554
+	{
1555
+
1556
+		// testing term stuff
1557
+		$orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1558
+		$order       = $this->request->getRequestParam('order', 'DESC');
1559
+		$limit       = ($current_page - 1) * $per_page;
1560
+		$where       = ['taxonomy' => 'espresso_venue_categories'];
1561
+		$search_term = $this->request->getRequestParam('s');
1562
+		if ($search_term) {
1563
+			$search_term = '%' . $search_term . '%';
1564
+			$where['OR'] = [
1565
+				'Term.name'   => ['LIKE', $search_term],
1566
+				'description' => ['LIKE', $search_term],
1567
+			];
1568
+		}
1569
+
1570
+		$query_params = [
1571
+			$where,
1572
+			'order_by'   => [$orderby => $order],
1573
+			'limit'      => $limit . ',' . $per_page,
1574
+			'force_join' => ['Term'],
1575
+		];
1576
+
1577
+		return $count
1578
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1579
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
1580
+	}
1581
+
1582
+
1583
+	/* end category stuff */
1584
+	/**************/
1585 1585
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -43,534 +43,534 @@
 block discarded – undo
43 43
  */
44 44
 class OrganizationSettings extends FormHandler
45 45
 {
46
-    /**
47
-     * @var EE_Organization_Config
48
-     */
49
-    protected $organization_config;
46
+	/**
47
+	 * @var EE_Organization_Config
48
+	 */
49
+	protected $organization_config;
50 50
 
51
-    /**
52
-     * @var EE_Core_Config
53
-     */
54
-    protected $core_config;
51
+	/**
52
+	 * @var EE_Core_Config
53
+	 */
54
+	protected $core_config;
55 55
 
56 56
 
57
-    /**
58
-     * @var EE_Network_Core_Config
59
-     */
60
-    protected $network_core_config;
57
+	/**
58
+	 * @var EE_Network_Core_Config
59
+	 */
60
+	protected $network_core_config;
61 61
 
62
-    /**
63
-     * @var CountrySubRegionDao $countrySubRegionDao
64
-     */
65
-    protected $countrySubRegionDao;
62
+	/**
63
+	 * @var CountrySubRegionDao $countrySubRegionDao
64
+	 */
65
+	protected $countrySubRegionDao;
66 66
 
67 67
 
68
-    /**
69
-     * Form constructor.
70
-     *
71
-     * @param EE_Registry            $registry
72
-     * @param EE_Organization_Config $organization_config
73
-     * @param EE_Core_Config         $core_config
74
-     * @param EE_Network_Core_Config $network_core_config
75
-     * @param CountrySubRegionDao    $countrySubRegionDao
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws DomainException
79
-     */
80
-    public function __construct(
81
-        EE_Registry $registry,
82
-        EE_Organization_Config $organization_config,
83
-        EE_Core_Config $core_config,
84
-        EE_Network_Core_Config $network_core_config,
85
-        CountrySubRegionDao $countrySubRegionDao
86
-    ) {
87
-        $this->organization_config = $organization_config;
88
-        $this->core_config         = $core_config;
89
-        $this->network_core_config = $network_core_config;
90
-        $this->countrySubRegionDao = $countrySubRegionDao;
91
-        parent::__construct(
92
-            esc_html__('Your Organization Settings', 'event_espresso'),
93
-            esc_html__('Your Organization Settings', 'event_espresso'),
94
-            'organization_settings',
95
-            '',
96
-            FormHandler::DO_NOT_SETUP_FORM,
97
-            $registry
98
-        );
99
-    }
68
+	/**
69
+	 * Form constructor.
70
+	 *
71
+	 * @param EE_Registry            $registry
72
+	 * @param EE_Organization_Config $organization_config
73
+	 * @param EE_Core_Config         $core_config
74
+	 * @param EE_Network_Core_Config $network_core_config
75
+	 * @param CountrySubRegionDao    $countrySubRegionDao
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws DomainException
79
+	 */
80
+	public function __construct(
81
+		EE_Registry $registry,
82
+		EE_Organization_Config $organization_config,
83
+		EE_Core_Config $core_config,
84
+		EE_Network_Core_Config $network_core_config,
85
+		CountrySubRegionDao $countrySubRegionDao
86
+	) {
87
+		$this->organization_config = $organization_config;
88
+		$this->core_config         = $core_config;
89
+		$this->network_core_config = $network_core_config;
90
+		$this->countrySubRegionDao = $countrySubRegionDao;
91
+		parent::__construct(
92
+			esc_html__('Your Organization Settings', 'event_espresso'),
93
+			esc_html__('Your Organization Settings', 'event_espresso'),
94
+			'organization_settings',
95
+			'',
96
+			FormHandler::DO_NOT_SETUP_FORM,
97
+			$registry
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * creates and returns the actual form
104
-     *
105
-     * @return EE_Form_Section_Proper
106
-     * @throws EE_Error
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidInterfaceException
110
-     * @throws ReflectionException
111
-     */
112
-    public function generate()
113
-    {
114
-        $has_sub_regions = EEM_State::instance()->count(
115
-            [['Country.CNT_ISO' => $this->organization_config->CNT_ISO]]
116
-        );
117
-        $form            = new EE_Form_Section_Proper(
118
-            [
119
-                'name'            => 'organization_settings',
120
-                'html_id'         => 'organization_settings',
121
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
-                'subsections'     => [
123
-                    'contact_information_hdr' => new EE_Form_Section_HTML(
124
-                        EEH_HTML::h2(
125
-                            esc_html__('Contact Information', 'event_espresso')
126
-                            . ' '
127
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
-                            '',
129
-                            'contact-information-hdr'
130
-                        )
131
-                    ),
132
-                    'organization_name'       => new EE_Text_Input(
133
-                        [
134
-                            'html_name'       => 'organization_name',
135
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
-                            'html_help_text'  => esc_html__(
137
-                                'Displayed on all emails and invoices.',
138
-                                'event_espresso'
139
-                            ),
140
-                            'default'         => $this->organization_config->get_pretty('name'),
141
-                            'required'        => false,
142
-                        ]
143
-                    ),
144
-                    'organization_address_1'  => new EE_Text_Input(
145
-                        [
146
-                            'html_name'       => 'organization_address_1',
147
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
-                            'default'         => $this->organization_config->get_pretty('address_1'),
149
-                            'required'        => false,
150
-                        ]
151
-                    ),
152
-                    'organization_address_2'  => new EE_Text_Input(
153
-                        [
154
-                            'html_name'       => 'organization_address_2',
155
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
-                            'default'         => $this->organization_config->get_pretty('address_2'),
157
-                            'required'        => false,
158
-                        ]
159
-                    ),
160
-                    'organization_city'       => new EE_Text_Input(
161
-                        [
162
-                            'html_name'       => 'organization_city',
163
-                            'html_class'      => 'ee-input-size--reg',
164
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
165
-                            'default'         => $this->organization_config->get_pretty('city'),
166
-                            'required'        => false,
167
-                        ]
168
-                    ),
169
-                    'organization_country'    => new EE_Country_Select_Input(
170
-                        null,
171
-                        [
172
-                            EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
173
-                            'html_name'                             => 'organization_country',
174
-                            'html_class'                            => 'ee-input-size--reg',
175
-                            'html_label_text'                       => esc_html__('Country', 'event_espresso'),
176
-                            'default'                               => $this->organization_config->CNT_ISO,
177
-                            'required'                              => false,
178
-                            'html_help_text'                        => sprintf(
179
-                                esc_html__(
180
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
181
-                                    'event_espresso'
182
-                                ),
183
-                                '<span class="reminder-spn">',
184
-                                '</span>'
185
-                            ),
186
-                        ]
187
-                    ),
188
-                    'organization_state'      => new EE_State_Select_Input(
189
-                        null,
190
-                        [
191
-                            'html_name'       => 'organization_state',
192
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
193
-                            'default'         => $this->organization_config->STA_ID,
194
-                            'required'        => false,
195
-                            'html_help_text'  => empty($this->organization_config->STA_ID) || ! $has_sub_regions
196
-                                ? sprintf(
197
-                                    esc_html__(
198
-                                        'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
199
-                                        'event_espresso'
200
-                                    ),
201
-                                    '<span class="reminder-spn">',
202
-                                    '</span>',
203
-                                    '<br />'
204
-                                )
205
-                                : '',
206
-                        ]
207
-                    ),
208
-                    'organization_zip'        => new EE_Text_Input(
209
-                        [
210
-                            'html_name'       => 'organization_zip',
211
-                            'html_class'      => 'ee-input-size--small',
212
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
213
-                            'default'         => $this->organization_config->get_pretty('zip'),
214
-                            'required'        => false,
215
-                        ]
216
-                    ),
217
-                    'organization_email'      => new EE_Text_Input(
218
-                        [
219
-                            'html_name'       => 'organization_email',
220
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
221
-                            'html_help_text'  => sprintf(
222
-                                esc_html__(
223
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
224
-                                    'event_espresso'
225
-                                ),
226
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
227
-                                '<code>[CO_EMAIL]</code>'
228
-                            ),
229
-                            'default'         => $this->organization_config->get_pretty('email'),
230
-                            'required'        => false,
231
-                        ]
232
-                    ),
233
-                    'organization_phone'      => new EE_Text_Input(
234
-                        [
235
-                            'html_name'       => 'organization_phone',
236
-                            'html_class'      => 'ee-input-size--small',
237
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
238
-                            'html_help_text'  => esc_html__(
239
-                                'The phone number for your organization.',
240
-                                'event_espresso'
241
-                            ),
242
-                            'default'         => $this->organization_config->get_pretty('phone'),
243
-                            'required'        => false,
244
-                        ]
245
-                    ),
246
-                    'organization_vat'        => new EE_Text_Input(
247
-                        [
248
-                            'html_name'       => 'organization_vat',
249
-                            'html_class'      => 'ee-input-size--reg',
250
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
251
-                            'html_help_text'  => esc_html__(
252
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
253
-                                'event_espresso'
254
-                            ),
255
-                            'default'         => $this->organization_config->get_pretty('vat'),
256
-                            'required'        => false,
257
-                        ]
258
-                    ),
259
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
260
-                        EEH_HTML::h2(
261
-                            esc_html__('Company Logo', 'event_espresso')
262
-                            . ' '
263
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
264
-                            '',
265
-                            'company-logo-hdr'
266
-                        )
267
-                    ),
268
-                    'organization_logo_url'   => new EE_Admin_File_Uploader_Input(
269
-                        [
270
-                            'html_name'       => 'organization_logo_url',
271
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
272
-                            'html_help_text'  => esc_html__(
273
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
274
-                                'event_espresso'
275
-                            ),
276
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
277
-                            'required'        => false,
278
-                        ]
279
-                    ),
280
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
281
-                        EEH_HTML::h2(
282
-                            esc_html__('Social Links', 'event_espresso')
283
-                            . ' '
284
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
285
-                            . EEH_HTML::br()
286
-                            . EEH_HTML::p(
287
-                                esc_html__(
288
-                                    'Enter any links to social accounts for your organization here',
289
-                                    'event_espresso'
290
-                                ),
291
-                                '',
292
-                                'description'
293
-                            ),
294
-                            '',
295
-                            'social-links-hdr'
296
-                        )
297
-                    ),
298
-                    'organization_facebook'   => new EE_Text_Input(
299
-                        [
300
-                            'html_name'             => 'organization_facebook',
301
-                            'html_label_text'       => esc_html__('Facebook', 'event_espresso'),
302
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
303
-                            'default'               => $this->organization_config->get_pretty('facebook'),
304
-                            'required'              => false,
305
-                        ]
306
-                    ),
307
-                    'organization_twitter'    => new EE_Text_Input(
308
-                        [
309
-                            'html_name'             => 'organization_twitter',
310
-                            'html_label_text'       => esc_html__('Twitter', 'event_espresso'),
311
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
312
-                            'default'               => $this->organization_config->get_pretty('twitter'),
313
-                            'required'              => false,
314
-                        ]
315
-                    ),
316
-                    'organization_linkedin'   => new EE_Text_Input(
317
-                        [
318
-                            'html_name'             => 'organization_linkedin',
319
-                            'html_label_text'       => esc_html__('LinkedIn', 'event_espresso'),
320
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
321
-                            'default'               => $this->organization_config->get_pretty('linkedin'),
322
-                            'required'              => false,
323
-                        ]
324
-                    ),
325
-                    'organization_pinterest'  => new EE_Text_Input(
326
-                        [
327
-                            'html_name'             => 'organization_pinterest',
328
-                            'html_label_text'       => esc_html__('Pinterest', 'event_espresso'),
329
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
330
-                            'default'               => $this->organization_config->get_pretty('pinterest'),
331
-                            'required'              => false,
332
-                        ]
333
-                    ),
334
-                    'organization_instagram'  => new EE_Text_Input(
335
-                        [
336
-                            'html_name'             => 'organization_instagram',
337
-                            'html_label_text'       => esc_html__('Instagram', 'event_espresso'),
338
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
339
-                            'default'               => $this->organization_config->get_pretty('instagram'),
340
-                            'required'              => false,
341
-                        ]
342
-                    ),
343
-                ],
344
-            ]
345
-        );
346
-        if (is_main_site()) {
347
-            $form->add_subsections(
348
-                [
349
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
350
-                        EEH_HTML::h2(
351
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
352
-                            . ' '
353
-                            . EEH_HTML::span(
354
-                                EEH_Template::get_help_tab_link('site_license_key_info')
355
-                            ),
356
-                            '',
357
-                            'site-license-key-hdr'
358
-                        )
359
-                    ),
360
-                    'site_license_key'     => $this->getSiteLicenseKeyField(),
361
-                ]
362
-            );
363
-            $form->add_subsections(
364
-                [
365
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
366
-                        $this->uxipOptinText()
367
-                    ),
368
-                    'ueip_optin'     => new EE_Checkbox_Multi_Input(
369
-                        [
370
-                            true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso'),
371
-                        ],
372
-                        [
373
-                            'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
374
-                            'html_label_text' => esc_html__(
375
-                                'UXIP Opt In?',
376
-                                'event_espresso'
377
-                            ),
378
-                            'default'         => isset($this->core_config->ee_ueip_optin)
379
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
380
-                                : false,
381
-                            'required'        => false,
382
-                        ]
383
-                    ),
384
-                ],
385
-                'organization_instagram',
386
-                false
387
-            );
388
-        }
389
-        return $form;
390
-    }
102
+	/**
103
+	 * creates and returns the actual form
104
+	 *
105
+	 * @return EE_Form_Section_Proper
106
+	 * @throws EE_Error
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidInterfaceException
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function generate()
113
+	{
114
+		$has_sub_regions = EEM_State::instance()->count(
115
+			[['Country.CNT_ISO' => $this->organization_config->CNT_ISO]]
116
+		);
117
+		$form            = new EE_Form_Section_Proper(
118
+			[
119
+				'name'            => 'organization_settings',
120
+				'html_id'         => 'organization_settings',
121
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
+				'subsections'     => [
123
+					'contact_information_hdr' => new EE_Form_Section_HTML(
124
+						EEH_HTML::h2(
125
+							esc_html__('Contact Information', 'event_espresso')
126
+							. ' '
127
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
+							'',
129
+							'contact-information-hdr'
130
+						)
131
+					),
132
+					'organization_name'       => new EE_Text_Input(
133
+						[
134
+							'html_name'       => 'organization_name',
135
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
+							'html_help_text'  => esc_html__(
137
+								'Displayed on all emails and invoices.',
138
+								'event_espresso'
139
+							),
140
+							'default'         => $this->organization_config->get_pretty('name'),
141
+							'required'        => false,
142
+						]
143
+					),
144
+					'organization_address_1'  => new EE_Text_Input(
145
+						[
146
+							'html_name'       => 'organization_address_1',
147
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
+							'default'         => $this->organization_config->get_pretty('address_1'),
149
+							'required'        => false,
150
+						]
151
+					),
152
+					'organization_address_2'  => new EE_Text_Input(
153
+						[
154
+							'html_name'       => 'organization_address_2',
155
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
+							'default'         => $this->organization_config->get_pretty('address_2'),
157
+							'required'        => false,
158
+						]
159
+					),
160
+					'organization_city'       => new EE_Text_Input(
161
+						[
162
+							'html_name'       => 'organization_city',
163
+							'html_class'      => 'ee-input-size--reg',
164
+							'html_label_text' => esc_html__('City', 'event_espresso'),
165
+							'default'         => $this->organization_config->get_pretty('city'),
166
+							'required'        => false,
167
+						]
168
+					),
169
+					'organization_country'    => new EE_Country_Select_Input(
170
+						null,
171
+						[
172
+							EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
173
+							'html_name'                             => 'organization_country',
174
+							'html_class'                            => 'ee-input-size--reg',
175
+							'html_label_text'                       => esc_html__('Country', 'event_espresso'),
176
+							'default'                               => $this->organization_config->CNT_ISO,
177
+							'required'                              => false,
178
+							'html_help_text'                        => sprintf(
179
+								esc_html__(
180
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
181
+									'event_espresso'
182
+								),
183
+								'<span class="reminder-spn">',
184
+								'</span>'
185
+							),
186
+						]
187
+					),
188
+					'organization_state'      => new EE_State_Select_Input(
189
+						null,
190
+						[
191
+							'html_name'       => 'organization_state',
192
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
193
+							'default'         => $this->organization_config->STA_ID,
194
+							'required'        => false,
195
+							'html_help_text'  => empty($this->organization_config->STA_ID) || ! $has_sub_regions
196
+								? sprintf(
197
+									esc_html__(
198
+										'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
199
+										'event_espresso'
200
+									),
201
+									'<span class="reminder-spn">',
202
+									'</span>',
203
+									'<br />'
204
+								)
205
+								: '',
206
+						]
207
+					),
208
+					'organization_zip'        => new EE_Text_Input(
209
+						[
210
+							'html_name'       => 'organization_zip',
211
+							'html_class'      => 'ee-input-size--small',
212
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
213
+							'default'         => $this->organization_config->get_pretty('zip'),
214
+							'required'        => false,
215
+						]
216
+					),
217
+					'organization_email'      => new EE_Text_Input(
218
+						[
219
+							'html_name'       => 'organization_email',
220
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
221
+							'html_help_text'  => sprintf(
222
+								esc_html__(
223
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
224
+									'event_espresso'
225
+								),
226
+								'<code>[CO_FORMATTED_EMAIL]</code>',
227
+								'<code>[CO_EMAIL]</code>'
228
+							),
229
+							'default'         => $this->organization_config->get_pretty('email'),
230
+							'required'        => false,
231
+						]
232
+					),
233
+					'organization_phone'      => new EE_Text_Input(
234
+						[
235
+							'html_name'       => 'organization_phone',
236
+							'html_class'      => 'ee-input-size--small',
237
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
238
+							'html_help_text'  => esc_html__(
239
+								'The phone number for your organization.',
240
+								'event_espresso'
241
+							),
242
+							'default'         => $this->organization_config->get_pretty('phone'),
243
+							'required'        => false,
244
+						]
245
+					),
246
+					'organization_vat'        => new EE_Text_Input(
247
+						[
248
+							'html_name'       => 'organization_vat',
249
+							'html_class'      => 'ee-input-size--reg',
250
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
251
+							'html_help_text'  => esc_html__(
252
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
253
+								'event_espresso'
254
+							),
255
+							'default'         => $this->organization_config->get_pretty('vat'),
256
+							'required'        => false,
257
+						]
258
+					),
259
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
260
+						EEH_HTML::h2(
261
+							esc_html__('Company Logo', 'event_espresso')
262
+							. ' '
263
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
264
+							'',
265
+							'company-logo-hdr'
266
+						)
267
+					),
268
+					'organization_logo_url'   => new EE_Admin_File_Uploader_Input(
269
+						[
270
+							'html_name'       => 'organization_logo_url',
271
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
272
+							'html_help_text'  => esc_html__(
273
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
274
+								'event_espresso'
275
+							),
276
+							'default'         => $this->organization_config->get_pretty('logo_url'),
277
+							'required'        => false,
278
+						]
279
+					),
280
+					'social_links_hdr'        => new EE_Form_Section_HTML(
281
+						EEH_HTML::h2(
282
+							esc_html__('Social Links', 'event_espresso')
283
+							. ' '
284
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
285
+							. EEH_HTML::br()
286
+							. EEH_HTML::p(
287
+								esc_html__(
288
+									'Enter any links to social accounts for your organization here',
289
+									'event_espresso'
290
+								),
291
+								'',
292
+								'description'
293
+							),
294
+							'',
295
+							'social-links-hdr'
296
+						)
297
+					),
298
+					'organization_facebook'   => new EE_Text_Input(
299
+						[
300
+							'html_name'             => 'organization_facebook',
301
+							'html_label_text'       => esc_html__('Facebook', 'event_espresso'),
302
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
303
+							'default'               => $this->organization_config->get_pretty('facebook'),
304
+							'required'              => false,
305
+						]
306
+					),
307
+					'organization_twitter'    => new EE_Text_Input(
308
+						[
309
+							'html_name'             => 'organization_twitter',
310
+							'html_label_text'       => esc_html__('Twitter', 'event_espresso'),
311
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
312
+							'default'               => $this->organization_config->get_pretty('twitter'),
313
+							'required'              => false,
314
+						]
315
+					),
316
+					'organization_linkedin'   => new EE_Text_Input(
317
+						[
318
+							'html_name'             => 'organization_linkedin',
319
+							'html_label_text'       => esc_html__('LinkedIn', 'event_espresso'),
320
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
321
+							'default'               => $this->organization_config->get_pretty('linkedin'),
322
+							'required'              => false,
323
+						]
324
+					),
325
+					'organization_pinterest'  => new EE_Text_Input(
326
+						[
327
+							'html_name'             => 'organization_pinterest',
328
+							'html_label_text'       => esc_html__('Pinterest', 'event_espresso'),
329
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
330
+							'default'               => $this->organization_config->get_pretty('pinterest'),
331
+							'required'              => false,
332
+						]
333
+					),
334
+					'organization_instagram'  => new EE_Text_Input(
335
+						[
336
+							'html_name'             => 'organization_instagram',
337
+							'html_label_text'       => esc_html__('Instagram', 'event_espresso'),
338
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
339
+							'default'               => $this->organization_config->get_pretty('instagram'),
340
+							'required'              => false,
341
+						]
342
+					),
343
+				],
344
+			]
345
+		);
346
+		if (is_main_site()) {
347
+			$form->add_subsections(
348
+				[
349
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
350
+						EEH_HTML::h2(
351
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
352
+							. ' '
353
+							. EEH_HTML::span(
354
+								EEH_Template::get_help_tab_link('site_license_key_info')
355
+							),
356
+							'',
357
+							'site-license-key-hdr'
358
+						)
359
+					),
360
+					'site_license_key'     => $this->getSiteLicenseKeyField(),
361
+				]
362
+			);
363
+			$form->add_subsections(
364
+				[
365
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
366
+						$this->uxipOptinText()
367
+					),
368
+					'ueip_optin'     => new EE_Checkbox_Multi_Input(
369
+						[
370
+							true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso'),
371
+						],
372
+						[
373
+							'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
374
+							'html_label_text' => esc_html__(
375
+								'UXIP Opt In?',
376
+								'event_espresso'
377
+							),
378
+							'default'         => isset($this->core_config->ee_ueip_optin)
379
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
380
+								: false,
381
+							'required'        => false,
382
+						]
383
+					),
384
+				],
385
+				'organization_instagram',
386
+				false
387
+			);
388
+		}
389
+		return $form;
390
+	}
391 391
 
392 392
 
393
-    /**
394
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
395
-     * returns a string of HTML that can be directly echoed in a template
396
-     *
397
-     * @return string
398
-     * @throws EE_Error
399
-     * @throws InvalidArgumentException
400
-     * @throws InvalidDataTypeException
401
-     * @throws InvalidInterfaceException
402
-     * @throws LogicException
403
-     */
404
-    public function display()
405
-    {
406
-        $this->form()->enqueue_js();
407
-        return parent::display();
408
-    }
393
+	/**
394
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
395
+	 * returns a string of HTML that can be directly echoed in a template
396
+	 *
397
+	 * @return string
398
+	 * @throws EE_Error
399
+	 * @throws InvalidArgumentException
400
+	 * @throws InvalidDataTypeException
401
+	 * @throws InvalidInterfaceException
402
+	 * @throws LogicException
403
+	 */
404
+	public function display()
405
+	{
406
+		$this->form()->enqueue_js();
407
+		return parent::display();
408
+	}
409 409
 
410 410
 
411
-    /**
412
-     * handles processing the form submission
413
-     * returns true or false depending on whether the form was processed successfully or not
414
-     *
415
-     * @param array $form_data
416
-     * @return bool
417
-     * @throws InvalidFormSubmissionException
418
-     * @throws EE_Error
419
-     * @throws LogicException
420
-     * @throws InvalidArgumentException
421
-     * @throws InvalidDataTypeException
422
-     * @throws ReflectionException
423
-     */
424
-    public function process($form_data = [])
425
-    {
426
-        // process form
427
-        $valid_data = (array) parent::process($form_data);
428
-        if (empty($valid_data)) {
429
-            return false;
430
-        }
411
+	/**
412
+	 * handles processing the form submission
413
+	 * returns true or false depending on whether the form was processed successfully or not
414
+	 *
415
+	 * @param array $form_data
416
+	 * @return bool
417
+	 * @throws InvalidFormSubmissionException
418
+	 * @throws EE_Error
419
+	 * @throws LogicException
420
+	 * @throws InvalidArgumentException
421
+	 * @throws InvalidDataTypeException
422
+	 * @throws ReflectionException
423
+	 */
424
+	public function process($form_data = [])
425
+	{
426
+		// process form
427
+		$valid_data = (array) parent::process($form_data);
428
+		if (empty($valid_data)) {
429
+			return false;
430
+		}
431 431
 
432
-        if (is_main_site()) {
433
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
434
-                ? sanitize_text_field($form_data['ee_site_license_key'])
435
-                : $this->network_core_config->site_license_key;
436
-        }
437
-        $this->organization_config->name         = isset($form_data['organization_name'])
438
-            ? sanitize_text_field($form_data['organization_name'])
439
-            : $this->organization_config->name;
440
-        $this->organization_config->address_1    = isset($form_data['organization_address_1'])
441
-            ? sanitize_text_field($form_data['organization_address_1'])
442
-            : $this->organization_config->address_1;
443
-        $this->organization_config->address_2    = isset($form_data['organization_address_2'])
444
-            ? sanitize_text_field($form_data['organization_address_2'])
445
-            : $this->organization_config->address_2;
446
-        $this->organization_config->city         = isset($form_data['organization_city'])
447
-            ? sanitize_text_field($form_data['organization_city'])
448
-            : $this->organization_config->city;
449
-        $this->organization_config->STA_ID       = isset($form_data['organization_state'])
450
-            ? absint($form_data['organization_state'])
451
-            : $this->organization_config->STA_ID;
452
-        $this->organization_config->CNT_ISO      = isset($form_data['organization_country'])
453
-            ? sanitize_text_field($form_data['organization_country'])
454
-            : $this->organization_config->CNT_ISO;
455
-        $this->organization_config->zip          = isset($form_data['organization_zip'])
456
-            ? sanitize_text_field($form_data['organization_zip'])
457
-            : $this->organization_config->zip;
458
-        $this->organization_config->email        = isset($form_data['organization_email'])
459
-            ? sanitize_email($form_data['organization_email'])
460
-            : $this->organization_config->email;
461
-        $this->organization_config->vat          = isset($form_data['organization_vat'])
462
-            ? sanitize_text_field($form_data['organization_vat'])
463
-            : $this->organization_config->vat;
464
-        $this->organization_config->phone        = isset($form_data['organization_phone'])
465
-            ? sanitize_text_field($form_data['organization_phone'])
466
-            : $this->organization_config->phone;
467
-        $this->organization_config->logo_url     = isset($form_data['organization_logo_url'])
468
-            ? esc_url_raw($form_data['organization_logo_url'])
469
-            : $this->organization_config->logo_url;
470
-        $this->organization_config->facebook     = isset($form_data['organization_facebook'])
471
-            ? esc_url_raw($form_data['organization_facebook'])
472
-            : $this->organization_config->facebook;
473
-        $this->organization_config->twitter      = isset($form_data['organization_twitter'])
474
-            ? esc_url_raw($form_data['organization_twitter'])
475
-            : $this->organization_config->twitter;
476
-        $this->organization_config->linkedin     = isset($form_data['organization_linkedin'])
477
-            ? esc_url_raw($form_data['organization_linkedin'])
478
-            : $this->organization_config->linkedin;
479
-        $this->organization_config->pinterest    = isset($form_data['organization_pinterest'])
480
-            ? esc_url_raw($form_data['organization_pinterest'])
481
-            : $this->organization_config->pinterest;
482
-        $this->organization_config->google       = isset($form_data['organization_google'])
483
-            ? esc_url_raw($form_data['organization_google'])
484
-            : $this->organization_config->google;
485
-        $this->organization_config->instagram    = isset($form_data['organization_instagram'])
486
-            ? esc_url_raw($form_data['organization_instagram'])
487
-            : $this->organization_config->instagram;
488
-        $this->core_config->ee_ueip_optin        = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
489
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
490
-            : false;
491
-        $this->core_config->ee_ueip_has_notified = true;
432
+		if (is_main_site()) {
433
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
434
+				? sanitize_text_field($form_data['ee_site_license_key'])
435
+				: $this->network_core_config->site_license_key;
436
+		}
437
+		$this->organization_config->name         = isset($form_data['organization_name'])
438
+			? sanitize_text_field($form_data['organization_name'])
439
+			: $this->organization_config->name;
440
+		$this->organization_config->address_1    = isset($form_data['organization_address_1'])
441
+			? sanitize_text_field($form_data['organization_address_1'])
442
+			: $this->organization_config->address_1;
443
+		$this->organization_config->address_2    = isset($form_data['organization_address_2'])
444
+			? sanitize_text_field($form_data['organization_address_2'])
445
+			: $this->organization_config->address_2;
446
+		$this->organization_config->city         = isset($form_data['organization_city'])
447
+			? sanitize_text_field($form_data['organization_city'])
448
+			: $this->organization_config->city;
449
+		$this->organization_config->STA_ID       = isset($form_data['organization_state'])
450
+			? absint($form_data['organization_state'])
451
+			: $this->organization_config->STA_ID;
452
+		$this->organization_config->CNT_ISO      = isset($form_data['organization_country'])
453
+			? sanitize_text_field($form_data['organization_country'])
454
+			: $this->organization_config->CNT_ISO;
455
+		$this->organization_config->zip          = isset($form_data['organization_zip'])
456
+			? sanitize_text_field($form_data['organization_zip'])
457
+			: $this->organization_config->zip;
458
+		$this->organization_config->email        = isset($form_data['organization_email'])
459
+			? sanitize_email($form_data['organization_email'])
460
+			: $this->organization_config->email;
461
+		$this->organization_config->vat          = isset($form_data['organization_vat'])
462
+			? sanitize_text_field($form_data['organization_vat'])
463
+			: $this->organization_config->vat;
464
+		$this->organization_config->phone        = isset($form_data['organization_phone'])
465
+			? sanitize_text_field($form_data['organization_phone'])
466
+			: $this->organization_config->phone;
467
+		$this->organization_config->logo_url     = isset($form_data['organization_logo_url'])
468
+			? esc_url_raw($form_data['organization_logo_url'])
469
+			: $this->organization_config->logo_url;
470
+		$this->organization_config->facebook     = isset($form_data['organization_facebook'])
471
+			? esc_url_raw($form_data['organization_facebook'])
472
+			: $this->organization_config->facebook;
473
+		$this->organization_config->twitter      = isset($form_data['organization_twitter'])
474
+			? esc_url_raw($form_data['organization_twitter'])
475
+			: $this->organization_config->twitter;
476
+		$this->organization_config->linkedin     = isset($form_data['organization_linkedin'])
477
+			? esc_url_raw($form_data['organization_linkedin'])
478
+			: $this->organization_config->linkedin;
479
+		$this->organization_config->pinterest    = isset($form_data['organization_pinterest'])
480
+			? esc_url_raw($form_data['organization_pinterest'])
481
+			: $this->organization_config->pinterest;
482
+		$this->organization_config->google       = isset($form_data['organization_google'])
483
+			? esc_url_raw($form_data['organization_google'])
484
+			: $this->organization_config->google;
485
+		$this->organization_config->instagram    = isset($form_data['organization_instagram'])
486
+			? esc_url_raw($form_data['organization_instagram'])
487
+			: $this->organization_config->instagram;
488
+		$this->core_config->ee_ueip_optin        = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
489
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
490
+			: false;
491
+		$this->core_config->ee_ueip_has_notified = true;
492 492
 
493
-        $this->registry->CFG->currency = new EE_Currency_Config(
494
-            $this->organization_config->CNT_ISO
495
-        );
496
-        /** @var EE_Country $country */
497
-        $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
498
-        if ($country instanceof EE_Country) {
499
-            $country->set('CNT_active', 1);
500
-            $country->save();
501
-            $this->countrySubRegionDao->saveCountrySubRegions($country);
502
-        }
503
-        return true;
504
-    }
493
+		$this->registry->CFG->currency = new EE_Currency_Config(
494
+			$this->organization_config->CNT_ISO
495
+		);
496
+		/** @var EE_Country $country */
497
+		$country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
498
+		if ($country instanceof EE_Country) {
499
+			$country->set('CNT_active', 1);
500
+			$country->save();
501
+			$this->countrySubRegionDao->saveCountrySubRegions($country);
502
+		}
503
+		return true;
504
+	}
505 505
 
506 506
 
507
-    /**
508
-     * @return string
509
-     */
510
-    private function uxipOptinText()
511
-    {
512
-        ob_start();
513
-        Stats::optinText(false);
514
-        return ob_get_clean();
515
-    }
507
+	/**
508
+	 * @return string
509
+	 */
510
+	private function uxipOptinText()
511
+	{
512
+		ob_start();
513
+		Stats::optinText(false);
514
+		return ob_get_clean();
515
+	}
516 516
 
517 517
 
518
-    /**
519
-     * Return whether the site license key has been verified or not.
520
-     *
521
-     * @return bool
522
-     */
523
-    private function licenseKeyVerified()
524
-    {
525
-        if (empty($this->network_core_config->site_license_key)) {
526
-            return false;
527
-        }
528
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
529
-        $verify_fail    = get_option($ver_option_key, false);
530
-        return $verify_fail === false
531
-               || ! empty($this->network_core_config->site_license_key);
532
-    }
518
+	/**
519
+	 * Return whether the site license key has been verified or not.
520
+	 *
521
+	 * @return bool
522
+	 */
523
+	private function licenseKeyVerified()
524
+	{
525
+		if (empty($this->network_core_config->site_license_key)) {
526
+			return false;
527
+		}
528
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
529
+		$verify_fail    = get_option($ver_option_key, false);
530
+		return $verify_fail === false
531
+			   || ! empty($this->network_core_config->site_license_key);
532
+	}
533 533
 
534 534
 
535
-    /**
536
-     * @return EE_Text_Input
537
-     */
538
-    private function getSiteLicenseKeyField()
539
-    {
540
-        $class = $this->licenseKeyVerified() ? 'ee-status-outline--success' : 'ee-status-outline--error';
541
-        return new EE_Text_Input(
542
-            [
543
-                'html_name'        => 'ee_site_license_key',
544
-                'html_id'          => 'site_license_key',
545
-                'html_class'       => 'ee-status-outline ' . $class,
546
-                'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
547
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
548
-                'html_help_text'   => sprintf(
549
-                    esc_html__(
550
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
551
-                        'event_espresso'
552
-                    ),
553
-                    '<strong>',
554
-                    '</strong>'
555
-                ),
556
-                /** phpcs:enable */
557
-                'default'          => $this->network_core_config->site_license_key ?? '',
558
-                'required'         => false,
559
-                'form_html_filter' => new VsprintfFilter(
560
-                    '%2$s %1$s',
561
-                    [$this->getValidationIndicator()]
562
-                ),
563
-            ]
564
-        );
565
-    }
535
+	/**
536
+	 * @return EE_Text_Input
537
+	 */
538
+	private function getSiteLicenseKeyField()
539
+	{
540
+		$class = $this->licenseKeyVerified() ? 'ee-status-outline--success' : 'ee-status-outline--error';
541
+		return new EE_Text_Input(
542
+			[
543
+				'html_name'        => 'ee_site_license_key',
544
+				'html_id'          => 'site_license_key',
545
+				'html_class'       => 'ee-status-outline ' . $class,
546
+				'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
547
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
548
+				'html_help_text'   => sprintf(
549
+					esc_html__(
550
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
551
+						'event_espresso'
552
+					),
553
+					'<strong>',
554
+					'</strong>'
555
+				),
556
+				/** phpcs:enable */
557
+				'default'          => $this->network_core_config->site_license_key ?? '',
558
+				'required'         => false,
559
+				'form_html_filter' => new VsprintfFilter(
560
+					'%2$s %1$s',
561
+					[$this->getValidationIndicator()]
562
+				),
563
+			]
564
+		);
565
+	}
566 566
 
567 567
 
568
-    /**
569
-     * @return string
570
-     */
571
-    private function getValidationIndicator()
572
-    {
573
-        $class = $this->licenseKeyVerified() ? 'ee-status--success' : 'ee-status--error';
574
-        return '<span class="dashicons dashicons-admin-network ' . $class . '"></span>';
575
-    }
568
+	/**
569
+	 * @return string
570
+	 */
571
+	private function getValidationIndicator()
572
+	{
573
+		$class = $this->licenseKeyVerified() ? 'ee-status--success' : 'ee-status--error';
574
+		return '<span class="dashicons dashicons-admin-network ' . $class . '"></span>';
575
+	}
576 576
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1419 added lines, -1419 removed lines patch added patch discarded remove patch
@@ -19,1436 +19,1436 @@
 block discarded – undo
19 19
  */
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22
-    /**
23
-     * @var EE_Core_Config
24
-     */
25
-    public $core_config;
26
-
27
-
28
-    /**
29
-     * Initialize basic properties.
30
-     */
31
-    protected function _init_page_props()
32
-    {
33
-        $this->page_slug        = GEN_SET_PG_SLUG;
34
-        $this->page_label       = GEN_SET_LABEL;
35
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
-        $this->_admin_base_path = GEN_SET_ADMIN;
37
-    }
38
-
39
-
40
-    /**
41
-     * Set ajax hooks
42
-     */
43
-    protected function _ajax_hooks()
44
-    {
45
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
-    }
50
-
51
-
52
-    /**
53
-     * More page properties initialization.
54
-     */
55
-    protected function _define_page_props()
56
-    {
57
-        $this->_admin_page_title = GEN_SET_LABEL;
58
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
-    }
60
-
61
-
62
-    /**
63
-     * Set page routes property.
64
-     */
65
-    protected function _set_page_routes()
66
-    {
67
-        $this->_page_routes = [
68
-            'critical_pages'                => [
69
-                'func'       => '_espresso_page_settings',
70
-                'capability' => 'manage_options',
71
-            ],
72
-            'update_espresso_page_settings' => [
73
-                'func'       => '_update_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-                'noheader'   => true,
76
-            ],
77
-            'default'                       => [
78
-                'func'       => '_your_organization_settings',
79
-                'capability' => 'manage_options',
80
-            ],
81
-
82
-            'update_your_organization_settings' => [
83
-                'func'       => '_update_your_organization_settings',
84
-                'capability' => 'manage_options',
85
-                'noheader'   => true,
86
-            ],
87
-
88
-            'admin_option_settings' => [
89
-                'func'       => '_admin_option_settings',
90
-                'capability' => 'manage_options',
91
-            ],
92
-
93
-            'update_admin_option_settings' => [
94
-                'func'       => '_update_admin_option_settings',
95
-                'capability' => 'manage_options',
96
-                'noheader'   => true,
97
-            ],
98
-
99
-            'country_settings' => [
100
-                'func'       => '_country_settings',
101
-                'capability' => 'manage_options',
102
-            ],
103
-
104
-            'update_country_settings' => [
105
-                'func'       => '_update_country_settings',
106
-                'capability' => 'manage_options',
107
-                'noheader'   => true,
108
-            ],
109
-
110
-            'display_country_settings' => [
111
-                'func'       => 'display_country_settings',
112
-                'capability' => 'manage_options',
113
-                'noheader'   => true,
114
-            ],
115
-
116
-            'add_new_state' => [
117
-                'func'       => 'add_new_state',
118
-                'capability' => 'manage_options',
119
-                'noheader'   => true,
120
-            ],
121
-
122
-            'delete_state'            => [
123
-                'func'       => 'delete_state',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-            'privacy_settings'        => [
128
-                'func'       => 'privacySettings',
129
-                'capability' => 'manage_options',
130
-            ],
131
-            'update_privacy_settings' => [
132
-                'func'               => 'updatePrivacySettings',
133
-                'capability'         => 'manage_options',
134
-                'noheader'           => true,
135
-                'headers_sent_route' => 'privacy_settings',
136
-            ],
137
-        ];
138
-    }
139
-
140
-
141
-    /**
142
-     * Set page configuration property
143
-     */
144
-    protected function _set_page_config()
145
-    {
146
-        $this->_page_config = [
147
-            'critical_pages'        => [
148
-                'nav'           => [
149
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
150
-                    'icon' => 'dashicons-warning',
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'icon' => 'dashicons-admin-home',
166
-                    'order' => 20,
167
-                ],
168
-                'help_tabs'     => [
169
-                    'general_settings_your_organization_help_tab' => [
170
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
171
-                        'filename' => 'general_settings_your_organization',
172
-                    ],
173
-                ],
174
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
175
-                'require_nonce' => false,
176
-            ],
177
-            'admin_option_settings' => [
178
-                'nav'           => [
179
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
180
-                    'icon' => 'dashicons-admin-settings',
181
-                    'order' => 60,
182
-                ],
183
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
184
-                'help_tabs'     => [
185
-                    'general_settings_admin_options_help_tab' => [
186
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
187
-                        'filename' => 'general_settings_admin_options',
188
-                    ],
189
-                ],
190
-                'require_nonce' => false,
191
-            ],
192
-            'country_settings'      => [
193
-                'nav'           => [
194
-                    'label' => esc_html__('Countries', 'event_espresso'),
195
-                    'icon' => 'dashicons-admin-site',
196
-                    'order' => 70,
197
-                ],
198
-                'help_tabs'     => [
199
-                    'general_settings_countries_help_tab' => [
200
-                        'title'    => esc_html__('Countries', 'event_espresso'),
201
-                        'filename' => 'general_settings_countries',
202
-                    ],
203
-                ],
204
-                'require_nonce' => false,
205
-            ],
206
-            'privacy_settings'      => [
207
-                'nav'           => [
208
-                    'label' => esc_html__('Privacy', 'event_espresso'),
209
-                    'icon' => 'dashicons-privacy',
210
-                    'order' => 80,
211
-                ],
212
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
213
-                'require_nonce' => false,
214
-            ],
215
-        ];
216
-    }
217
-
218
-
219
-    protected function _add_screen_options()
220
-    {
221
-    }
222
-
223
-
224
-    protected function _add_feature_pointers()
225
-    {
226
-    }
227
-
228
-
229
-    /**
230
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
231
-     */
232
-    public function load_scripts_styles()
233
-    {
234
-        // styles
235
-        wp_enqueue_style('espresso-ui-theme');
236
-        // scripts
237
-        wp_enqueue_script('ee_admin_js');
238
-    }
239
-
240
-
241
-    /**
242
-     * Execute logic running on `admin_init`
243
-     */
244
-    public function admin_init()
245
-    {
246
-        $this->core_config = EE_Registry::instance()->CFG->core;
247
-
248
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
249
-            esc_html__(
250
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
251
-                'event_espresso'
252
-            )
253
-        );
254
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
255
-            esc_html__(
256
-                'An error occurred! Please refresh the page and try again.',
257
-                'event_espresso'
258
-            )
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
261
-            esc_html__(
262
-                'Are you sure you want to delete this State / Province?',
263
-                'event_espresso'
264
-            )
265
-        );
266
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
267
-            'admin-ajax.php?page=espresso_general_settings',
268
-            is_ssl() ? 'https://' : 'http://'
269
-        );
270
-    }
271
-
272
-
273
-    public function admin_notices()
274
-    {
275
-    }
276
-
277
-
278
-    public function admin_footer_scripts()
279
-    {
280
-    }
281
-
282
-
283
-    /**
284
-     * Enqueue scripts and styles for the default route.
285
-     */
286
-    public function load_scripts_styles_default()
287
-    {
288
-        // styles
289
-        wp_enqueue_style('thickbox');
290
-        // scripts
291
-        wp_enqueue_script('media-upload');
292
-        wp_enqueue_script('thickbox');
293
-        wp_register_script(
294
-            'organization_settings',
295
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
296
-            ['jquery', 'media-upload', 'thickbox'],
297
-            EVENT_ESPRESSO_VERSION,
298
-            true
299
-        );
300
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
301
-        wp_enqueue_script('organization_settings');
302
-        wp_enqueue_style('organization-css');
303
-        $confirm_image_delete = [
304
-            'text' => wp_strip_all_tags(
305
-                esc_html__(
306
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
307
-                    'event_espresso'
308
-                )
309
-            ),
310
-        ];
311
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
312
-    }
313
-
314
-
315
-    /**
316
-     * Enqueue scripts and styles for the country settings route.
317
-     */
318
-    public function load_scripts_styles_country_settings()
319
-    {
320
-        // scripts
321
-        wp_register_script(
322
-            'gen_settings_countries',
323
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
324
-            ['ee_admin_js'],
325
-            EVENT_ESPRESSO_VERSION,
326
-            true
327
-        );
328
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
329
-        wp_enqueue_script('gen_settings_countries');
330
-        wp_enqueue_style('organization-css');
331
-    }
332
-
333
-
334
-    /*************        Espresso Pages        *************/
335
-    /**
336
-     * _espresso_page_settings
337
-     *
338
-     * @throws EE_Error
339
-     * @throws DomainException
340
-     * @throws DomainException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidArgumentException
343
-     */
344
-    protected function _espresso_page_settings()
345
-    {
346
-        // Check to make sure all of the main pages are set up properly,
347
-        // if not create the default pages and display an admin notice
348
-        EEH_Activation::verify_default_pages_exist();
349
-        $this->_transient_garbage_collection();
350
-
351
-        $this->_template_args['values'] = $this->_yes_no_values;
352
-
353
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
354
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
355
-            ? get_post($this->core_config->reg_page_id)
356
-            : false;
357
-
358
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
359
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
360
-            ? get_post($this->core_config->txn_page_id)
361
-            : false;
362
-
363
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
364
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
365
-            ? get_post($this->core_config->thank_you_page_id)
366
-            : false;
367
-
368
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
369
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
370
-            ? get_post($this->core_config->cancel_page_id)
371
-            : false;
372
-
373
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
374
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
375
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
376
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
377
-            $this->_template_args,
378
-            true
379
-        );
380
-        $this->display_admin_page_with_sidebar();
381
-    }
382
-
383
-
384
-    /**
385
-     * Handler for updating espresso page settings.
386
-     *
387
-     * @throws EE_Error
388
-     */
389
-    protected function _update_espresso_page_settings()
390
-    {
391
-        $this->core_config = EE_Registry::instance()->CFG->core;
392
-        // capture incoming request data && set page IDs
393
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
394
-            'reg_page_id',
395
-            $this->core_config->reg_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
399
-            'txn_page_id',
400
-            $this->core_config->txn_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
404
-            'thank_you_page_id',
405
-            $this->core_config->thank_you_page_id,
406
-            DataType::INT
407
-        );
408
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
409
-            'cancel_page_id',
410
-            $this->core_config->cancel_page_id,
411
-            DataType::INT
412
-        );
413
-
414
-        $this->core_config = apply_filters(
415
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
416
-            $this->core_config,
417
-            $this->request->requestParams()
418
-        );
419
-
420
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
421
-        $this->_redirect_after_action(
422
-            $this->_update_espresso_configuration(
423
-                $what,
424
-                $this->core_config,
425
-                __FILE__,
426
-                __FUNCTION__,
427
-                __LINE__
428
-            ),
429
-            $what,
430
-            '',
431
-            [
432
-                'action' => 'critical_pages',
433
-            ],
434
-            true
435
-        );
436
-    }
437
-
438
-
439
-    /*************        Your Organization        *************/
440
-
441
-
442
-    /**
443
-     * @throws DomainException
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     */
449
-    protected function _your_organization_settings()
450
-    {
451
-        $this->_template_args['admin_page_content'] = '';
452
-        try {
453
-            /** @var OrganizationSettings $organization_settings_form */
454
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
455
-
456
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
457
-                $organization_settings_form->display(),
458
-                '',
459
-                'padding'
460
-            );
461
-        } catch (Exception $e) {
462
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
463
-        }
464
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
465
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
466
-        $this->display_admin_page_with_sidebar();
467
-    }
468
-
469
-
470
-    /**
471
-     * Handler for updating organization settings.
472
-     *
473
-     * @throws EE_Error
474
-     */
475
-    protected function _update_your_organization_settings()
476
-    {
477
-        try {
478
-            /** @var OrganizationSettings $organization_settings_form */
479
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
480
-
481
-            $success = $organization_settings_form->process($this->request->requestParams());
482
-
483
-            EE_Registry::instance()->CFG = apply_filters(
484
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
485
-                EE_Registry::instance()->CFG
486
-            );
487
-        } catch (Exception $e) {
488
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
489
-            $success = false;
490
-        }
491
-
492
-        if ($success) {
493
-            $success = $this->_update_espresso_configuration(
494
-                esc_html__('Your Organization Settings', 'event_espresso'),
495
-                EE_Registry::instance()->CFG,
496
-                __FILE__,
497
-                __FUNCTION__,
498
-                __LINE__
499
-            );
500
-        }
501
-
502
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
503
-    }
504
-
505
-
506
-
507
-    /*************        Admin Options        *************/
508
-
509
-
510
-    /**
511
-     * _admin_option_settings
512
-     *
513
-     * @throws EE_Error
514
-     * @throws LogicException
515
-     */
516
-    protected function _admin_option_settings()
517
-    {
518
-        $this->_template_args['admin_page_content'] = '';
519
-        try {
520
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
521
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
522
-            $this->_template_args['values'] = $this->_yes_no_values;
523
-            // also need to account for the do_action that was in the old template
524
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
525
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
526
-                $admin_options_settings_form->display(),
527
-                '',
528
-                'padding'
529
-            );
530
-        } catch (Exception $e) {
531
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
532
-        }
533
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
534
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
535
-        $this->display_admin_page_with_sidebar();
536
-    }
537
-
538
-
539
-    /**
540
-     * _update_admin_option_settings
541
-     *
542
-     * @throws EE_Error
543
-     * @throws InvalidDataTypeException
544
-     * @throws InvalidFormSubmissionException
545
-     * @throws InvalidArgumentException
546
-     * @throws LogicException
547
-     */
548
-    protected function _update_admin_option_settings()
549
-    {
550
-        try {
551
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
552
-            $admin_options_settings_form->process(
553
-                $this->request->getRequestParam(
554
-                    $admin_options_settings_form->slug(),
555
-                    [],
556
-                    DataType::STRING,
557
-                    true
558
-                )
559
-            );
560
-            EE_Registry::instance()->CFG->admin = apply_filters(
561
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
562
-                EE_Registry::instance()->CFG->admin
563
-            );
564
-        } catch (Exception $e) {
565
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
566
-        }
567
-        $this->_redirect_after_action(
568
-            apply_filters(
569
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
570
-                $this->_update_espresso_configuration(
571
-                    esc_html__('Admin Options', 'event_espresso'),
572
-                    EE_Registry::instance()->CFG->admin,
573
-                    __FILE__,
574
-                    __FUNCTION__,
575
-                    __LINE__
576
-                )
577
-            ),
578
-            esc_html__('Admin Options', 'event_espresso'),
579
-            'updated',
580
-            ['action' => 'admin_option_settings']
581
-        );
582
-    }
583
-
584
-
585
-    /*************        Countries        *************/
586
-
587
-
588
-    /**
589
-     * @param string|null $default
590
-     * @return string
591
-     */
592
-    protected function getCountryISO(?string $default = null): string
593
-    {
594
-        $default = $default ?? $this->getCountryIsoForSite();
595
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
596
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
597
-        return strtoupper($CNT_ISO);
598
-    }
599
-
600
-
601
-    /**
602
-     * @return string
603
-     */
604
-    protected function getCountryIsoForSite(): string
605
-    {
606
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
607
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
608
-            : 'US';
609
-    }
610
-
611
-
612
-    /**
613
-     * @param string          $CNT_ISO
614
-     * @param EE_Country|null $country
615
-     * @return EE_Base_Class|EE_Country
616
-     * @throws EE_Error
617
-     * @throws InvalidArgumentException
618
-     * @throws InvalidDataTypeException
619
-     * @throws InvalidInterfaceException
620
-     * @throws ReflectionException
621
-     */
622
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
623
-    {
624
-        /** @var EE_Country $country */
625
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
626
-            ? $country
627
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
628
-    }
629
-
630
-
631
-    /**
632
-     * Output Country Settings view.
633
-     *
634
-     * @throws DomainException
635
-     * @throws EE_Error
636
-     * @throws InvalidArgumentException
637
-     * @throws InvalidDataTypeException
638
-     * @throws InvalidInterfaceException
639
-     * @throws ReflectionException
640
-     */
641
-    protected function _country_settings()
642
-    {
643
-        $CNT_ISO = $this->getCountryISO();
644
-
645
-        $this->_template_args['values']    = $this->_yes_no_values;
646
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
647
-            EE_Question::new_instance(
648
-                [
649
-                  'QST_ID'           => 0,
650
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
651
-                  'QST_system'       => 'admin-country',
652
-                ]
653
-            ),
654
-            EE_Answer::new_instance(
655
-                [
656
-                    'ANS_ID'    => 0,
657
-                    'ANS_value' => $CNT_ISO,
658
-                ]
659
-            ),
660
-            [
661
-                'input_id'       => 'country',
662
-                'input_name'     => 'country',
663
-                'input_prefix'   => '',
664
-                'append_qstn_id' => false,
665
-            ]
666
-        );
667
-
668
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
669
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
670
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
671
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
672
-            $country->ID(),
673
-            $country
674
-        );
675
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
676
-            $country->ID(),
677
-            $country
678
-        );
679
-        $this->_template_args['CNT_name_for_site']        = $country->name();
680
-
681
-        $this->_set_add_edit_form_tags('update_country_settings');
682
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
683
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
684
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
685
-            $this->_template_args,
686
-            true
687
-        );
688
-        $this->display_admin_page_with_no_sidebar();
689
-    }
690
-
691
-
692
-    /**
693
-     * @param string          $CNT_ISO
694
-     * @param EE_Country|null $country
695
-     * @return string
696
-     * @throws DomainException
697
-     * @throws EE_Error
698
-     * @throws InvalidArgumentException
699
-     * @throws InvalidDataTypeException
700
-     * @throws InvalidInterfaceException
701
-     * @throws ReflectionException
702
-     */
703
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
704
-    {
705
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
706
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
707
-
708
-        if (! $CNT_ISO) {
709
-            return '';
710
-        }
711
-
712
-        // for ajax
713
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
714
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
715
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
716
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
717
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
718
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
719
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
720
-
721
-        $country_input_types            = [
722
-            'CNT_active'      => [
723
-                'type'             => 'RADIO_BTN',
724
-                'input_name'       => "cntry[$CNT_ISO]",
725
-                'class'            => '',
726
-                'options'          => $this->_yes_no_values,
727
-                'use_desc_4_label' => true,
728
-            ],
729
-            'CNT_ISO'         => [
730
-                'type'       => 'TEXT',
731
-                'input_name' => "cntry[$CNT_ISO]",
732
-                'class'      => 'ee-input-width--small',
733
-            ],
734
-            'CNT_ISO3'        => [
735
-                'type'       => 'TEXT',
736
-                'input_name' => "cntry[$CNT_ISO]",
737
-                'class'      => 'ee-input-width--small',
738
-            ],
739
-            // 'RGN_ID'          => [
740
-            //     'type'       => 'TEXT',
741
-            //     'input_name' => "cntry[$CNT_ISO]",
742
-            //     'class'      => 'ee-input-width--small',
743
-            // ],
744
-            'CNT_name'        => [
745
-                'type'       => 'TEXT',
746
-                'input_name' => "cntry[$CNT_ISO]",
747
-                'class'      => 'ee-input-width--big',
748
-            ],
749
-            'CNT_cur_code'    => [
750
-                'type'       => 'TEXT',
751
-                'input_name' => "cntry[$CNT_ISO]",
752
-                'class'      => 'ee-input-width--small',
753
-                'disabled'   => $CNT_cur_disabled,
754
-            ],
755
-            'CNT_cur_single'  => [
756
-                'type'       => 'TEXT',
757
-                'input_name' => "cntry[$CNT_ISO]",
758
-                'class'      => 'ee-input-width--reg',
759
-                'disabled'   => $CNT_cur_disabled,
760
-            ],
761
-            'CNT_cur_plural'  => [
762
-                'type'       => 'TEXT',
763
-                'input_name' => "cntry[$CNT_ISO]",
764
-                'class'      => 'ee-input-width--reg',
765
-                'disabled'   => $CNT_cur_disabled,
766
-            ],
767
-            'CNT_cur_sign'    => [
768
-                'type'         => 'TEXT',
769
-                'input_name'   => "cntry[$CNT_ISO]",
770
-                'class'        => 'ee-input-width--small',
771
-                'htmlentities' => false,
772
-                'disabled'     => $CNT_cur_disabled,
773
-            ],
774
-            'CNT_cur_sign_b4' => [
775
-                'type'             => 'RADIO_BTN',
776
-                'input_name'       => "cntry[$CNT_ISO]",
777
-                'class'            => '',
778
-                'options'          => $this->_yes_no_values,
779
-                'use_desc_4_label' => true,
780
-                'disabled'         => $CNT_cur_disabled,
781
-            ],
782
-            'CNT_cur_dec_plc' => [
783
-                'type'       => 'RADIO_BTN',
784
-                'input_name' => "cntry[$CNT_ISO]",
785
-                'class'      => '',
786
-                'options'    => [
787
-                    ['id' => 0, 'text' => ''],
788
-                    ['id' => 1, 'text' => ''],
789
-                    ['id' => 2, 'text' => ''],
790
-                    ['id' => 3, 'text' => ''],
791
-                ],
792
-                'disabled'   => $CNT_cur_disabled,
793
-            ],
794
-            'CNT_cur_dec_mrk' => [
795
-                'type'             => 'RADIO_BTN',
796
-                'input_name'       => "cntry[$CNT_ISO]",
797
-                'class'            => '',
798
-                'options'          => [
799
-                    [
800
-                        'id'   => ',',
801
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
802
-                    ],
803
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
804
-                ],
805
-                'use_desc_4_label' => true,
806
-                'disabled'         => $CNT_cur_disabled,
807
-            ],
808
-            'CNT_cur_thsnds'  => [
809
-                'type'             => 'RADIO_BTN',
810
-                'input_name'       => "cntry[$CNT_ISO]",
811
-                'class'            => '',
812
-                'options'          => [
813
-                    [
814
-                        'id'   => ',',
815
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
816
-                    ],
817
-                    [
818
-                        'id'   => '.',
819
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
820
-                    ],
821
-                    [
822
-                        'id'   => '&nbsp;',
823
-                        'text' => esc_html__('(space)', 'event_espresso'),
824
-                    ],
825
-                ],
826
-                'use_desc_4_label' => true,
827
-                'disabled'         => $CNT_cur_disabled,
828
-            ],
829
-            'CNT_tel_code'    => [
830
-                'type'       => 'TEXT',
831
-                'input_name' => "cntry[$CNT_ISO]",
832
-                'class'      => 'ee-input-width--small',
833
-            ],
834
-            'CNT_is_EU'       => [
835
-                'type'             => 'RADIO_BTN',
836
-                'input_name'       => "cntry[$CNT_ISO]",
837
-                'class'            => '',
838
-                'options'          => $this->_yes_no_values,
839
-                'use_desc_4_label' => true,
840
-            ],
841
-        ];
842
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
843
-            $country,
844
-            $country_input_types
845
-        );
846
-        $country_details_settings       = EEH_Template::display_template(
847
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
848
-            $this->_template_args,
849
-            true
850
-        );
851
-
852
-        if (defined('DOING_AJAX')) {
853
-            $notices = EE_Error::get_notices(false, false, false);
854
-            echo wp_json_encode(
855
-                [
856
-                    'return_data' => $country_details_settings,
857
-                    'success'     => $notices['success'],
858
-                    'errors'      => $notices['errors'],
859
-                ]
860
-            );
861
-            die();
862
-        }
863
-        return $country_details_settings;
864
-    }
865
-
866
-
867
-    /**
868
-     * @param string          $CNT_ISO
869
-     * @param EE_Country|null $country
870
-     * @return string
871
-     * @throws DomainException
872
-     * @throws EE_Error
873
-     * @throws InvalidArgumentException
874
-     * @throws InvalidDataTypeException
875
-     * @throws InvalidInterfaceException
876
-     * @throws ReflectionException
877
-     */
878
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
879
-    {
880
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
881
-        if (! $CNT_ISO) {
882
-            return '';
883
-        }
884
-        // for ajax
885
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
886
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
887
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
888
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
889
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
890
-        if (empty($states)) {
891
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
892
-            $countrySubRegionDao = $this->loader->getShared(
893
-                'EventEspresso\core\services\address\CountrySubRegionDao'
894
-            );
895
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
896
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
897
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
898
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
899
-                }
900
-            }
901
-        }
902
-        if (is_array($states)) {
903
-            foreach ($states as $STA_ID => $state) {
904
-                if ($state instanceof EE_State) {
905
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
906
-                        $state,
907
-                        [
908
-                            'STA_abbrev' => [
909
-                                'type'             => 'TEXT',
910
-                                'label'            => esc_html__('Code', 'event_espresso'),
911
-                                'input_name'       => "states[$STA_ID]",
912
-                                'class'            => 'ee-input-width--tiny',
913
-                                'add_mobile_label' => true,
914
-                            ],
915
-                            'STA_name'   => [
916
-                                'type'             => 'TEXT',
917
-                                'label'            => esc_html__('Name', 'event_espresso'),
918
-                                'input_name'       => "states[$STA_ID]",
919
-                                'class'            => 'ee-input-width--big',
920
-                                'add_mobile_label' => true,
921
-                            ],
922
-                            'STA_active' => [
923
-                                'type'             => 'RADIO_BTN',
924
-                                'label'            => esc_html__(
925
-                                    'State Appears in Dropdown Select Lists',
926
-                                    'event_espresso'
927
-                                ),
928
-                                'input_name'       => "states[$STA_ID]",
929
-                                'options'          => $this->_yes_no_values,
930
-                                'use_desc_4_label' => true,
931
-                                'add_mobile_label' => true,
932
-                            ],
933
-                        ]
934
-                    );
935
-
936
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
937
-                        [
938
-                            'action'     => 'delete_state',
939
-                            'STA_ID'     => $STA_ID,
940
-                            'CNT_ISO'    => $CNT_ISO,
941
-                            'STA_abbrev' => $state->abbrev(),
942
-                        ],
943
-                        GEN_SET_ADMIN_URL
944
-                    );
945
-
946
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
947
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
948
-                }
949
-            }
950
-        } else {
951
-            $this->_template_args['states'] = false;
952
-        }
953
-
954
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
955
-            ['action' => 'add_new_state'],
956
-            GEN_SET_ADMIN_URL
957
-        );
958
-
959
-        $state_details_settings = EEH_Template::display_template(
960
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
961
-            $this->_template_args,
962
-            true
963
-        );
964
-
965
-        if (defined('DOING_AJAX')) {
966
-            $notices = EE_Error::get_notices(false, false, false);
967
-            echo wp_json_encode(
968
-                [
969
-                    'return_data' => $state_details_settings,
970
-                    'success'     => $notices['success'],
971
-                    'errors'      => $notices['errors'],
972
-                ]
973
-            );
974
-            die();
975
-        }
976
-        return $state_details_settings;
977
-    }
978
-
979
-
980
-    /**
981
-     * @return void
982
-     * @throws EE_Error
983
-     * @throws InvalidArgumentException
984
-     * @throws InvalidDataTypeException
985
-     * @throws InvalidInterfaceException
986
-     * @throws ReflectionException
987
-     */
988
-    public function add_new_state()
989
-    {
990
-        $success = true;
991
-        $CNT_ISO = $this->getCountryISO('');
992
-        if (! $CNT_ISO) {
993
-            EE_Error::add_error(
994
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
995
-                __FILE__,
996
-                __FUNCTION__,
997
-                __LINE__
998
-            );
999
-            $success = false;
1000
-        }
1001
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1002
-        if (! $STA_abbrev) {
1003
-            EE_Error::add_error(
1004
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1005
-                __FILE__,
1006
-                __FUNCTION__,
1007
-                __LINE__
1008
-            );
1009
-            $success = false;
1010
-        }
1011
-        $STA_name = $this->request->getRequestParam('STA_name');
1012
-        if (! $STA_name) {
1013
-            EE_Error::add_error(
1014
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1015
-                __FILE__,
1016
-                __FUNCTION__,
1017
-                __LINE__
1018
-            );
1019
-            $success = false;
1020
-        }
1021
-
1022
-        if ($success) {
1023
-            $cols_n_values = [
1024
-                'CNT_ISO'    => $CNT_ISO,
1025
-                'STA_abbrev' => $STA_abbrev,
1026
-                'STA_name'   => $STA_name,
1027
-                'STA_active' => true,
1028
-            ];
1029
-            $success       = EEM_State::instance()->insert($cols_n_values);
1030
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1031
-        }
1032
-
1033
-        if (defined('DOING_AJAX')) {
1034
-            $notices = EE_Error::get_notices(false, false, false);
1035
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1036
-            die();
1037
-        }
1038
-        $this->_redirect_after_action(
1039
-            $success,
1040
-            esc_html__('State', 'event_espresso'),
1041
-            'added',
1042
-            ['action' => 'country_settings']
1043
-        );
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * @return void
1049
-     * @throws EE_Error
1050
-     * @throws InvalidArgumentException
1051
-     * @throws InvalidDataTypeException
1052
-     * @throws InvalidInterfaceException
1053
-     * @throws ReflectionException
1054
-     */
1055
-    public function delete_state()
1056
-    {
1057
-        $CNT_ISO    = $this->getCountryISO();
1058
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1059
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1060
-
1061
-        if (! $STA_ID) {
1062
-            EE_Error::add_error(
1063
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1064
-                __FILE__,
1065
-                __FUNCTION__,
1066
-                __LINE__
1067
-            );
1068
-            return;
1069
-        }
1070
-
1071
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1072
-        if ($success !== false) {
1073
-            do_action(
1074
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1075
-                $CNT_ISO,
1076
-                $STA_ID,
1077
-                ['STA_abbrev' => $STA_abbrev]
1078
-            );
1079
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1080
-        }
1081
-        if (defined('DOING_AJAX')) {
1082
-            $notices                = EE_Error::get_notices(false);
1083
-            $notices['return_data'] = true;
1084
-            echo wp_json_encode($notices);
1085
-            die();
1086
-        }
1087
-        $this->_redirect_after_action(
1088
-            $success,
1089
-            esc_html__('State', 'event_espresso'),
1090
-            'deleted',
1091
-            ['action' => 'country_settings']
1092
-        );
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * @return void
1098
-     * @throws EE_Error
1099
-     * @throws InvalidArgumentException
1100
-     * @throws InvalidDataTypeException
1101
-     * @throws InvalidInterfaceException
1102
-     * @throws ReflectionException
1103
-     */
1104
-    protected function _update_country_settings()
1105
-    {
1106
-        $CNT_ISO = $this->getCountryISO();
1107
-        if (! $CNT_ISO) {
1108
-            EE_Error::add_error(
1109
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1110
-                __FILE__,
1111
-                __FUNCTION__,
1112
-                __LINE__
1113
-            );
1114
-            return;
1115
-        }
1116
-
1117
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1118
-
1119
-        $cols_n_values                    = [];
1120
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1121
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1122
-        );
1123
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1124
-            "cntry[$CNT_ISO][CNT_name]",
1125
-            $country->name()
1126
-        );
1127
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1128
-            $this->request->getRequestParam(
1129
-                "cntry[$CNT_ISO][CNT_cur_code]",
1130
-                $country->currency_code()
1131
-            )
1132
-        );
1133
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1134
-            "cntry[$CNT_ISO][CNT_cur_single]",
1135
-            $country->currency_name_single()
1136
-        );
1137
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1138
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1139
-            $country->currency_name_plural()
1140
-        );
1141
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1142
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1143
-            $country->currency_sign()
1144
-        );
1145
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1146
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1147
-            $country->currency_sign_before(),
1148
-            DataType::BOOL
1149
-        );
1150
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1151
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1152
-            $country->currency_decimal_places()
1153
-        );
1154
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1155
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1156
-            $country->currency_decimal_mark()
1157
-        );
1158
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1159
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1160
-            $country->currency_thousands_separator()
1161
-        );
1162
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1163
-            "cntry[$CNT_ISO][CNT_tel_code]",
1164
-            $country->telephoneCode()
1165
-        );
1166
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1167
-            "cntry[$CNT_ISO][CNT_active]",
1168
-            $country->isActive(),
1169
-            DataType::BOOL
1170
-        );
1171
-
1172
-        // allow filtering of country data
1173
-        $cols_n_values = apply_filters(
1174
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1175
-            $cols_n_values
1176
-        );
1177
-
1178
-        // where values
1179
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1180
-        // run the update
1181
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1182
-
1183
-        // allow filtering of states data
1184
-        $states = apply_filters(
1185
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1186
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1187
-        );
1188
-
1189
-        if (! empty($states) && $success !== false) {
1190
-            // loop thru state data ( looks like : states[75][STA_name] )
1191
-            foreach ($states as $STA_ID => $state) {
1192
-                $cols_n_values = [
1193
-                    'CNT_ISO'    => $CNT_ISO,
1194
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1195
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1196
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1197
-                ];
1198
-                // where values
1199
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1200
-                // run the update
1201
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1202
-                if ($success !== false) {
1203
-                    do_action(
1204
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1205
-                        $CNT_ISO,
1206
-                        $STA_ID,
1207
-                        $cols_n_values
1208
-                    );
1209
-                }
1210
-            }
1211
-        }
1212
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1213
-        if (
1214
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1215
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1216
-        ) {
1217
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1218
-            EE_Registry::instance()->CFG->update_espresso_config();
1219
-        }
1220
-
1221
-        if ($success !== false) {
1222
-            EE_Error::add_success(
1223
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1224
-            );
1225
-        }
1226
-        $this->_redirect_after_action(
1227
-            $success,
1228
-            '',
1229
-            '',
1230
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1231
-            true
1232
-        );
1233
-    }
1234
-
1235
-
1236
-    /**
1237
-     * form_form_field_label_wrap
1238
-     *
1239
-     * @param string $label
1240
-     * @return string
1241
-     */
1242
-    public function country_form_field_label_wrap(string $label): string
1243
-    {
1244
-        return '
22
+	/**
23
+	 * @var EE_Core_Config
24
+	 */
25
+	public $core_config;
26
+
27
+
28
+	/**
29
+	 * Initialize basic properties.
30
+	 */
31
+	protected function _init_page_props()
32
+	{
33
+		$this->page_slug        = GEN_SET_PG_SLUG;
34
+		$this->page_label       = GEN_SET_LABEL;
35
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
+		$this->_admin_base_path = GEN_SET_ADMIN;
37
+	}
38
+
39
+
40
+	/**
41
+	 * Set ajax hooks
42
+	 */
43
+	protected function _ajax_hooks()
44
+	{
45
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
+	}
50
+
51
+
52
+	/**
53
+	 * More page properties initialization.
54
+	 */
55
+	protected function _define_page_props()
56
+	{
57
+		$this->_admin_page_title = GEN_SET_LABEL;
58
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
+	}
60
+
61
+
62
+	/**
63
+	 * Set page routes property.
64
+	 */
65
+	protected function _set_page_routes()
66
+	{
67
+		$this->_page_routes = [
68
+			'critical_pages'                => [
69
+				'func'       => '_espresso_page_settings',
70
+				'capability' => 'manage_options',
71
+			],
72
+			'update_espresso_page_settings' => [
73
+				'func'       => '_update_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+				'noheader'   => true,
76
+			],
77
+			'default'                       => [
78
+				'func'       => '_your_organization_settings',
79
+				'capability' => 'manage_options',
80
+			],
81
+
82
+			'update_your_organization_settings' => [
83
+				'func'       => '_update_your_organization_settings',
84
+				'capability' => 'manage_options',
85
+				'noheader'   => true,
86
+			],
87
+
88
+			'admin_option_settings' => [
89
+				'func'       => '_admin_option_settings',
90
+				'capability' => 'manage_options',
91
+			],
92
+
93
+			'update_admin_option_settings' => [
94
+				'func'       => '_update_admin_option_settings',
95
+				'capability' => 'manage_options',
96
+				'noheader'   => true,
97
+			],
98
+
99
+			'country_settings' => [
100
+				'func'       => '_country_settings',
101
+				'capability' => 'manage_options',
102
+			],
103
+
104
+			'update_country_settings' => [
105
+				'func'       => '_update_country_settings',
106
+				'capability' => 'manage_options',
107
+				'noheader'   => true,
108
+			],
109
+
110
+			'display_country_settings' => [
111
+				'func'       => 'display_country_settings',
112
+				'capability' => 'manage_options',
113
+				'noheader'   => true,
114
+			],
115
+
116
+			'add_new_state' => [
117
+				'func'       => 'add_new_state',
118
+				'capability' => 'manage_options',
119
+				'noheader'   => true,
120
+			],
121
+
122
+			'delete_state'            => [
123
+				'func'       => 'delete_state',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+			'privacy_settings'        => [
128
+				'func'       => 'privacySettings',
129
+				'capability' => 'manage_options',
130
+			],
131
+			'update_privacy_settings' => [
132
+				'func'               => 'updatePrivacySettings',
133
+				'capability'         => 'manage_options',
134
+				'noheader'           => true,
135
+				'headers_sent_route' => 'privacy_settings',
136
+			],
137
+		];
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set page configuration property
143
+	 */
144
+	protected function _set_page_config()
145
+	{
146
+		$this->_page_config = [
147
+			'critical_pages'        => [
148
+				'nav'           => [
149
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
150
+					'icon' => 'dashicons-warning',
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'icon' => 'dashicons-admin-home',
166
+					'order' => 20,
167
+				],
168
+				'help_tabs'     => [
169
+					'general_settings_your_organization_help_tab' => [
170
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
171
+						'filename' => 'general_settings_your_organization',
172
+					],
173
+				],
174
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
175
+				'require_nonce' => false,
176
+			],
177
+			'admin_option_settings' => [
178
+				'nav'           => [
179
+					'label' => esc_html__('Admin Options', 'event_espresso'),
180
+					'icon' => 'dashicons-admin-settings',
181
+					'order' => 60,
182
+				],
183
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
184
+				'help_tabs'     => [
185
+					'general_settings_admin_options_help_tab' => [
186
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
187
+						'filename' => 'general_settings_admin_options',
188
+					],
189
+				],
190
+				'require_nonce' => false,
191
+			],
192
+			'country_settings'      => [
193
+				'nav'           => [
194
+					'label' => esc_html__('Countries', 'event_espresso'),
195
+					'icon' => 'dashicons-admin-site',
196
+					'order' => 70,
197
+				],
198
+				'help_tabs'     => [
199
+					'general_settings_countries_help_tab' => [
200
+						'title'    => esc_html__('Countries', 'event_espresso'),
201
+						'filename' => 'general_settings_countries',
202
+					],
203
+				],
204
+				'require_nonce' => false,
205
+			],
206
+			'privacy_settings'      => [
207
+				'nav'           => [
208
+					'label' => esc_html__('Privacy', 'event_espresso'),
209
+					'icon' => 'dashicons-privacy',
210
+					'order' => 80,
211
+				],
212
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
213
+				'require_nonce' => false,
214
+			],
215
+		];
216
+	}
217
+
218
+
219
+	protected function _add_screen_options()
220
+	{
221
+	}
222
+
223
+
224
+	protected function _add_feature_pointers()
225
+	{
226
+	}
227
+
228
+
229
+	/**
230
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
231
+	 */
232
+	public function load_scripts_styles()
233
+	{
234
+		// styles
235
+		wp_enqueue_style('espresso-ui-theme');
236
+		// scripts
237
+		wp_enqueue_script('ee_admin_js');
238
+	}
239
+
240
+
241
+	/**
242
+	 * Execute logic running on `admin_init`
243
+	 */
244
+	public function admin_init()
245
+	{
246
+		$this->core_config = EE_Registry::instance()->CFG->core;
247
+
248
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
249
+			esc_html__(
250
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
251
+				'event_espresso'
252
+			)
253
+		);
254
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
255
+			esc_html__(
256
+				'An error occurred! Please refresh the page and try again.',
257
+				'event_espresso'
258
+			)
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
261
+			esc_html__(
262
+				'Are you sure you want to delete this State / Province?',
263
+				'event_espresso'
264
+			)
265
+		);
266
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
267
+			'admin-ajax.php?page=espresso_general_settings',
268
+			is_ssl() ? 'https://' : 'http://'
269
+		);
270
+	}
271
+
272
+
273
+	public function admin_notices()
274
+	{
275
+	}
276
+
277
+
278
+	public function admin_footer_scripts()
279
+	{
280
+	}
281
+
282
+
283
+	/**
284
+	 * Enqueue scripts and styles for the default route.
285
+	 */
286
+	public function load_scripts_styles_default()
287
+	{
288
+		// styles
289
+		wp_enqueue_style('thickbox');
290
+		// scripts
291
+		wp_enqueue_script('media-upload');
292
+		wp_enqueue_script('thickbox');
293
+		wp_register_script(
294
+			'organization_settings',
295
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
296
+			['jquery', 'media-upload', 'thickbox'],
297
+			EVENT_ESPRESSO_VERSION,
298
+			true
299
+		);
300
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
301
+		wp_enqueue_script('organization_settings');
302
+		wp_enqueue_style('organization-css');
303
+		$confirm_image_delete = [
304
+			'text' => wp_strip_all_tags(
305
+				esc_html__(
306
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
307
+					'event_espresso'
308
+				)
309
+			),
310
+		];
311
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
312
+	}
313
+
314
+
315
+	/**
316
+	 * Enqueue scripts and styles for the country settings route.
317
+	 */
318
+	public function load_scripts_styles_country_settings()
319
+	{
320
+		// scripts
321
+		wp_register_script(
322
+			'gen_settings_countries',
323
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
324
+			['ee_admin_js'],
325
+			EVENT_ESPRESSO_VERSION,
326
+			true
327
+		);
328
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
329
+		wp_enqueue_script('gen_settings_countries');
330
+		wp_enqueue_style('organization-css');
331
+	}
332
+
333
+
334
+	/*************        Espresso Pages        *************/
335
+	/**
336
+	 * _espresso_page_settings
337
+	 *
338
+	 * @throws EE_Error
339
+	 * @throws DomainException
340
+	 * @throws DomainException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidArgumentException
343
+	 */
344
+	protected function _espresso_page_settings()
345
+	{
346
+		// Check to make sure all of the main pages are set up properly,
347
+		// if not create the default pages and display an admin notice
348
+		EEH_Activation::verify_default_pages_exist();
349
+		$this->_transient_garbage_collection();
350
+
351
+		$this->_template_args['values'] = $this->_yes_no_values;
352
+
353
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
354
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
355
+			? get_post($this->core_config->reg_page_id)
356
+			: false;
357
+
358
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
359
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
360
+			? get_post($this->core_config->txn_page_id)
361
+			: false;
362
+
363
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
364
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
365
+			? get_post($this->core_config->thank_you_page_id)
366
+			: false;
367
+
368
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
369
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
370
+			? get_post($this->core_config->cancel_page_id)
371
+			: false;
372
+
373
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
374
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
375
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
376
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
377
+			$this->_template_args,
378
+			true
379
+		);
380
+		$this->display_admin_page_with_sidebar();
381
+	}
382
+
383
+
384
+	/**
385
+	 * Handler for updating espresso page settings.
386
+	 *
387
+	 * @throws EE_Error
388
+	 */
389
+	protected function _update_espresso_page_settings()
390
+	{
391
+		$this->core_config = EE_Registry::instance()->CFG->core;
392
+		// capture incoming request data && set page IDs
393
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
394
+			'reg_page_id',
395
+			$this->core_config->reg_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
399
+			'txn_page_id',
400
+			$this->core_config->txn_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
404
+			'thank_you_page_id',
405
+			$this->core_config->thank_you_page_id,
406
+			DataType::INT
407
+		);
408
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
409
+			'cancel_page_id',
410
+			$this->core_config->cancel_page_id,
411
+			DataType::INT
412
+		);
413
+
414
+		$this->core_config = apply_filters(
415
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
416
+			$this->core_config,
417
+			$this->request->requestParams()
418
+		);
419
+
420
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
421
+		$this->_redirect_after_action(
422
+			$this->_update_espresso_configuration(
423
+				$what,
424
+				$this->core_config,
425
+				__FILE__,
426
+				__FUNCTION__,
427
+				__LINE__
428
+			),
429
+			$what,
430
+			'',
431
+			[
432
+				'action' => 'critical_pages',
433
+			],
434
+			true
435
+		);
436
+	}
437
+
438
+
439
+	/*************        Your Organization        *************/
440
+
441
+
442
+	/**
443
+	 * @throws DomainException
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 */
449
+	protected function _your_organization_settings()
450
+	{
451
+		$this->_template_args['admin_page_content'] = '';
452
+		try {
453
+			/** @var OrganizationSettings $organization_settings_form */
454
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
455
+
456
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
457
+				$organization_settings_form->display(),
458
+				'',
459
+				'padding'
460
+			);
461
+		} catch (Exception $e) {
462
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
463
+		}
464
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
465
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
466
+		$this->display_admin_page_with_sidebar();
467
+	}
468
+
469
+
470
+	/**
471
+	 * Handler for updating organization settings.
472
+	 *
473
+	 * @throws EE_Error
474
+	 */
475
+	protected function _update_your_organization_settings()
476
+	{
477
+		try {
478
+			/** @var OrganizationSettings $organization_settings_form */
479
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
480
+
481
+			$success = $organization_settings_form->process($this->request->requestParams());
482
+
483
+			EE_Registry::instance()->CFG = apply_filters(
484
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
485
+				EE_Registry::instance()->CFG
486
+			);
487
+		} catch (Exception $e) {
488
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
489
+			$success = false;
490
+		}
491
+
492
+		if ($success) {
493
+			$success = $this->_update_espresso_configuration(
494
+				esc_html__('Your Organization Settings', 'event_espresso'),
495
+				EE_Registry::instance()->CFG,
496
+				__FILE__,
497
+				__FUNCTION__,
498
+				__LINE__
499
+			);
500
+		}
501
+
502
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
503
+	}
504
+
505
+
506
+
507
+	/*************        Admin Options        *************/
508
+
509
+
510
+	/**
511
+	 * _admin_option_settings
512
+	 *
513
+	 * @throws EE_Error
514
+	 * @throws LogicException
515
+	 */
516
+	protected function _admin_option_settings()
517
+	{
518
+		$this->_template_args['admin_page_content'] = '';
519
+		try {
520
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
521
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
522
+			$this->_template_args['values'] = $this->_yes_no_values;
523
+			// also need to account for the do_action that was in the old template
524
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
525
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
526
+				$admin_options_settings_form->display(),
527
+				'',
528
+				'padding'
529
+			);
530
+		} catch (Exception $e) {
531
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
532
+		}
533
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
534
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
535
+		$this->display_admin_page_with_sidebar();
536
+	}
537
+
538
+
539
+	/**
540
+	 * _update_admin_option_settings
541
+	 *
542
+	 * @throws EE_Error
543
+	 * @throws InvalidDataTypeException
544
+	 * @throws InvalidFormSubmissionException
545
+	 * @throws InvalidArgumentException
546
+	 * @throws LogicException
547
+	 */
548
+	protected function _update_admin_option_settings()
549
+	{
550
+		try {
551
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
552
+			$admin_options_settings_form->process(
553
+				$this->request->getRequestParam(
554
+					$admin_options_settings_form->slug(),
555
+					[],
556
+					DataType::STRING,
557
+					true
558
+				)
559
+			);
560
+			EE_Registry::instance()->CFG->admin = apply_filters(
561
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
562
+				EE_Registry::instance()->CFG->admin
563
+			);
564
+		} catch (Exception $e) {
565
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
566
+		}
567
+		$this->_redirect_after_action(
568
+			apply_filters(
569
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
570
+				$this->_update_espresso_configuration(
571
+					esc_html__('Admin Options', 'event_espresso'),
572
+					EE_Registry::instance()->CFG->admin,
573
+					__FILE__,
574
+					__FUNCTION__,
575
+					__LINE__
576
+				)
577
+			),
578
+			esc_html__('Admin Options', 'event_espresso'),
579
+			'updated',
580
+			['action' => 'admin_option_settings']
581
+		);
582
+	}
583
+
584
+
585
+	/*************        Countries        *************/
586
+
587
+
588
+	/**
589
+	 * @param string|null $default
590
+	 * @return string
591
+	 */
592
+	protected function getCountryISO(?string $default = null): string
593
+	{
594
+		$default = $default ?? $this->getCountryIsoForSite();
595
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
596
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
597
+		return strtoupper($CNT_ISO);
598
+	}
599
+
600
+
601
+	/**
602
+	 * @return string
603
+	 */
604
+	protected function getCountryIsoForSite(): string
605
+	{
606
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
607
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
608
+			: 'US';
609
+	}
610
+
611
+
612
+	/**
613
+	 * @param string          $CNT_ISO
614
+	 * @param EE_Country|null $country
615
+	 * @return EE_Base_Class|EE_Country
616
+	 * @throws EE_Error
617
+	 * @throws InvalidArgumentException
618
+	 * @throws InvalidDataTypeException
619
+	 * @throws InvalidInterfaceException
620
+	 * @throws ReflectionException
621
+	 */
622
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
623
+	{
624
+		/** @var EE_Country $country */
625
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
626
+			? $country
627
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
628
+	}
629
+
630
+
631
+	/**
632
+	 * Output Country Settings view.
633
+	 *
634
+	 * @throws DomainException
635
+	 * @throws EE_Error
636
+	 * @throws InvalidArgumentException
637
+	 * @throws InvalidDataTypeException
638
+	 * @throws InvalidInterfaceException
639
+	 * @throws ReflectionException
640
+	 */
641
+	protected function _country_settings()
642
+	{
643
+		$CNT_ISO = $this->getCountryISO();
644
+
645
+		$this->_template_args['values']    = $this->_yes_no_values;
646
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
647
+			EE_Question::new_instance(
648
+				[
649
+				  'QST_ID'           => 0,
650
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
651
+				  'QST_system'       => 'admin-country',
652
+				]
653
+			),
654
+			EE_Answer::new_instance(
655
+				[
656
+					'ANS_ID'    => 0,
657
+					'ANS_value' => $CNT_ISO,
658
+				]
659
+			),
660
+			[
661
+				'input_id'       => 'country',
662
+				'input_name'     => 'country',
663
+				'input_prefix'   => '',
664
+				'append_qstn_id' => false,
665
+			]
666
+		);
667
+
668
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
669
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
670
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
671
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
672
+			$country->ID(),
673
+			$country
674
+		);
675
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
676
+			$country->ID(),
677
+			$country
678
+		);
679
+		$this->_template_args['CNT_name_for_site']        = $country->name();
680
+
681
+		$this->_set_add_edit_form_tags('update_country_settings');
682
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
683
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
684
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
685
+			$this->_template_args,
686
+			true
687
+		);
688
+		$this->display_admin_page_with_no_sidebar();
689
+	}
690
+
691
+
692
+	/**
693
+	 * @param string          $CNT_ISO
694
+	 * @param EE_Country|null $country
695
+	 * @return string
696
+	 * @throws DomainException
697
+	 * @throws EE_Error
698
+	 * @throws InvalidArgumentException
699
+	 * @throws InvalidDataTypeException
700
+	 * @throws InvalidInterfaceException
701
+	 * @throws ReflectionException
702
+	 */
703
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
704
+	{
705
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
706
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
707
+
708
+		if (! $CNT_ISO) {
709
+			return '';
710
+		}
711
+
712
+		// for ajax
713
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
714
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
715
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
716
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
717
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
718
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
719
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
720
+
721
+		$country_input_types            = [
722
+			'CNT_active'      => [
723
+				'type'             => 'RADIO_BTN',
724
+				'input_name'       => "cntry[$CNT_ISO]",
725
+				'class'            => '',
726
+				'options'          => $this->_yes_no_values,
727
+				'use_desc_4_label' => true,
728
+			],
729
+			'CNT_ISO'         => [
730
+				'type'       => 'TEXT',
731
+				'input_name' => "cntry[$CNT_ISO]",
732
+				'class'      => 'ee-input-width--small',
733
+			],
734
+			'CNT_ISO3'        => [
735
+				'type'       => 'TEXT',
736
+				'input_name' => "cntry[$CNT_ISO]",
737
+				'class'      => 'ee-input-width--small',
738
+			],
739
+			// 'RGN_ID'          => [
740
+			//     'type'       => 'TEXT',
741
+			//     'input_name' => "cntry[$CNT_ISO]",
742
+			//     'class'      => 'ee-input-width--small',
743
+			// ],
744
+			'CNT_name'        => [
745
+				'type'       => 'TEXT',
746
+				'input_name' => "cntry[$CNT_ISO]",
747
+				'class'      => 'ee-input-width--big',
748
+			],
749
+			'CNT_cur_code'    => [
750
+				'type'       => 'TEXT',
751
+				'input_name' => "cntry[$CNT_ISO]",
752
+				'class'      => 'ee-input-width--small',
753
+				'disabled'   => $CNT_cur_disabled,
754
+			],
755
+			'CNT_cur_single'  => [
756
+				'type'       => 'TEXT',
757
+				'input_name' => "cntry[$CNT_ISO]",
758
+				'class'      => 'ee-input-width--reg',
759
+				'disabled'   => $CNT_cur_disabled,
760
+			],
761
+			'CNT_cur_plural'  => [
762
+				'type'       => 'TEXT',
763
+				'input_name' => "cntry[$CNT_ISO]",
764
+				'class'      => 'ee-input-width--reg',
765
+				'disabled'   => $CNT_cur_disabled,
766
+			],
767
+			'CNT_cur_sign'    => [
768
+				'type'         => 'TEXT',
769
+				'input_name'   => "cntry[$CNT_ISO]",
770
+				'class'        => 'ee-input-width--small',
771
+				'htmlentities' => false,
772
+				'disabled'     => $CNT_cur_disabled,
773
+			],
774
+			'CNT_cur_sign_b4' => [
775
+				'type'             => 'RADIO_BTN',
776
+				'input_name'       => "cntry[$CNT_ISO]",
777
+				'class'            => '',
778
+				'options'          => $this->_yes_no_values,
779
+				'use_desc_4_label' => true,
780
+				'disabled'         => $CNT_cur_disabled,
781
+			],
782
+			'CNT_cur_dec_plc' => [
783
+				'type'       => 'RADIO_BTN',
784
+				'input_name' => "cntry[$CNT_ISO]",
785
+				'class'      => '',
786
+				'options'    => [
787
+					['id' => 0, 'text' => ''],
788
+					['id' => 1, 'text' => ''],
789
+					['id' => 2, 'text' => ''],
790
+					['id' => 3, 'text' => ''],
791
+				],
792
+				'disabled'   => $CNT_cur_disabled,
793
+			],
794
+			'CNT_cur_dec_mrk' => [
795
+				'type'             => 'RADIO_BTN',
796
+				'input_name'       => "cntry[$CNT_ISO]",
797
+				'class'            => '',
798
+				'options'          => [
799
+					[
800
+						'id'   => ',',
801
+						'text' => esc_html__(', (comma)', 'event_espresso'),
802
+					],
803
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
804
+				],
805
+				'use_desc_4_label' => true,
806
+				'disabled'         => $CNT_cur_disabled,
807
+			],
808
+			'CNT_cur_thsnds'  => [
809
+				'type'             => 'RADIO_BTN',
810
+				'input_name'       => "cntry[$CNT_ISO]",
811
+				'class'            => '',
812
+				'options'          => [
813
+					[
814
+						'id'   => ',',
815
+						'text' => esc_html__(', (comma)', 'event_espresso'),
816
+					],
817
+					[
818
+						'id'   => '.',
819
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
820
+					],
821
+					[
822
+						'id'   => '&nbsp;',
823
+						'text' => esc_html__('(space)', 'event_espresso'),
824
+					],
825
+				],
826
+				'use_desc_4_label' => true,
827
+				'disabled'         => $CNT_cur_disabled,
828
+			],
829
+			'CNT_tel_code'    => [
830
+				'type'       => 'TEXT',
831
+				'input_name' => "cntry[$CNT_ISO]",
832
+				'class'      => 'ee-input-width--small',
833
+			],
834
+			'CNT_is_EU'       => [
835
+				'type'             => 'RADIO_BTN',
836
+				'input_name'       => "cntry[$CNT_ISO]",
837
+				'class'            => '',
838
+				'options'          => $this->_yes_no_values,
839
+				'use_desc_4_label' => true,
840
+			],
841
+		];
842
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
843
+			$country,
844
+			$country_input_types
845
+		);
846
+		$country_details_settings       = EEH_Template::display_template(
847
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
848
+			$this->_template_args,
849
+			true
850
+		);
851
+
852
+		if (defined('DOING_AJAX')) {
853
+			$notices = EE_Error::get_notices(false, false, false);
854
+			echo wp_json_encode(
855
+				[
856
+					'return_data' => $country_details_settings,
857
+					'success'     => $notices['success'],
858
+					'errors'      => $notices['errors'],
859
+				]
860
+			);
861
+			die();
862
+		}
863
+		return $country_details_settings;
864
+	}
865
+
866
+
867
+	/**
868
+	 * @param string          $CNT_ISO
869
+	 * @param EE_Country|null $country
870
+	 * @return string
871
+	 * @throws DomainException
872
+	 * @throws EE_Error
873
+	 * @throws InvalidArgumentException
874
+	 * @throws InvalidDataTypeException
875
+	 * @throws InvalidInterfaceException
876
+	 * @throws ReflectionException
877
+	 */
878
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
879
+	{
880
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
881
+		if (! $CNT_ISO) {
882
+			return '';
883
+		}
884
+		// for ajax
885
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
886
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
887
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
888
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
889
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
890
+		if (empty($states)) {
891
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
892
+			$countrySubRegionDao = $this->loader->getShared(
893
+				'EventEspresso\core\services\address\CountrySubRegionDao'
894
+			);
895
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
896
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
897
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
898
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
899
+				}
900
+			}
901
+		}
902
+		if (is_array($states)) {
903
+			foreach ($states as $STA_ID => $state) {
904
+				if ($state instanceof EE_State) {
905
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
906
+						$state,
907
+						[
908
+							'STA_abbrev' => [
909
+								'type'             => 'TEXT',
910
+								'label'            => esc_html__('Code', 'event_espresso'),
911
+								'input_name'       => "states[$STA_ID]",
912
+								'class'            => 'ee-input-width--tiny',
913
+								'add_mobile_label' => true,
914
+							],
915
+							'STA_name'   => [
916
+								'type'             => 'TEXT',
917
+								'label'            => esc_html__('Name', 'event_espresso'),
918
+								'input_name'       => "states[$STA_ID]",
919
+								'class'            => 'ee-input-width--big',
920
+								'add_mobile_label' => true,
921
+							],
922
+							'STA_active' => [
923
+								'type'             => 'RADIO_BTN',
924
+								'label'            => esc_html__(
925
+									'State Appears in Dropdown Select Lists',
926
+									'event_espresso'
927
+								),
928
+								'input_name'       => "states[$STA_ID]",
929
+								'options'          => $this->_yes_no_values,
930
+								'use_desc_4_label' => true,
931
+								'add_mobile_label' => true,
932
+							],
933
+						]
934
+					);
935
+
936
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
937
+						[
938
+							'action'     => 'delete_state',
939
+							'STA_ID'     => $STA_ID,
940
+							'CNT_ISO'    => $CNT_ISO,
941
+							'STA_abbrev' => $state->abbrev(),
942
+						],
943
+						GEN_SET_ADMIN_URL
944
+					);
945
+
946
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
947
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
948
+				}
949
+			}
950
+		} else {
951
+			$this->_template_args['states'] = false;
952
+		}
953
+
954
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
955
+			['action' => 'add_new_state'],
956
+			GEN_SET_ADMIN_URL
957
+		);
958
+
959
+		$state_details_settings = EEH_Template::display_template(
960
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
961
+			$this->_template_args,
962
+			true
963
+		);
964
+
965
+		if (defined('DOING_AJAX')) {
966
+			$notices = EE_Error::get_notices(false, false, false);
967
+			echo wp_json_encode(
968
+				[
969
+					'return_data' => $state_details_settings,
970
+					'success'     => $notices['success'],
971
+					'errors'      => $notices['errors'],
972
+				]
973
+			);
974
+			die();
975
+		}
976
+		return $state_details_settings;
977
+	}
978
+
979
+
980
+	/**
981
+	 * @return void
982
+	 * @throws EE_Error
983
+	 * @throws InvalidArgumentException
984
+	 * @throws InvalidDataTypeException
985
+	 * @throws InvalidInterfaceException
986
+	 * @throws ReflectionException
987
+	 */
988
+	public function add_new_state()
989
+	{
990
+		$success = true;
991
+		$CNT_ISO = $this->getCountryISO('');
992
+		if (! $CNT_ISO) {
993
+			EE_Error::add_error(
994
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
995
+				__FILE__,
996
+				__FUNCTION__,
997
+				__LINE__
998
+			);
999
+			$success = false;
1000
+		}
1001
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1002
+		if (! $STA_abbrev) {
1003
+			EE_Error::add_error(
1004
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1005
+				__FILE__,
1006
+				__FUNCTION__,
1007
+				__LINE__
1008
+			);
1009
+			$success = false;
1010
+		}
1011
+		$STA_name = $this->request->getRequestParam('STA_name');
1012
+		if (! $STA_name) {
1013
+			EE_Error::add_error(
1014
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1015
+				__FILE__,
1016
+				__FUNCTION__,
1017
+				__LINE__
1018
+			);
1019
+			$success = false;
1020
+		}
1021
+
1022
+		if ($success) {
1023
+			$cols_n_values = [
1024
+				'CNT_ISO'    => $CNT_ISO,
1025
+				'STA_abbrev' => $STA_abbrev,
1026
+				'STA_name'   => $STA_name,
1027
+				'STA_active' => true,
1028
+			];
1029
+			$success       = EEM_State::instance()->insert($cols_n_values);
1030
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1031
+		}
1032
+
1033
+		if (defined('DOING_AJAX')) {
1034
+			$notices = EE_Error::get_notices(false, false, false);
1035
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1036
+			die();
1037
+		}
1038
+		$this->_redirect_after_action(
1039
+			$success,
1040
+			esc_html__('State', 'event_espresso'),
1041
+			'added',
1042
+			['action' => 'country_settings']
1043
+		);
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * @return void
1049
+	 * @throws EE_Error
1050
+	 * @throws InvalidArgumentException
1051
+	 * @throws InvalidDataTypeException
1052
+	 * @throws InvalidInterfaceException
1053
+	 * @throws ReflectionException
1054
+	 */
1055
+	public function delete_state()
1056
+	{
1057
+		$CNT_ISO    = $this->getCountryISO();
1058
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1059
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1060
+
1061
+		if (! $STA_ID) {
1062
+			EE_Error::add_error(
1063
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1064
+				__FILE__,
1065
+				__FUNCTION__,
1066
+				__LINE__
1067
+			);
1068
+			return;
1069
+		}
1070
+
1071
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1072
+		if ($success !== false) {
1073
+			do_action(
1074
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1075
+				$CNT_ISO,
1076
+				$STA_ID,
1077
+				['STA_abbrev' => $STA_abbrev]
1078
+			);
1079
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1080
+		}
1081
+		if (defined('DOING_AJAX')) {
1082
+			$notices                = EE_Error::get_notices(false);
1083
+			$notices['return_data'] = true;
1084
+			echo wp_json_encode($notices);
1085
+			die();
1086
+		}
1087
+		$this->_redirect_after_action(
1088
+			$success,
1089
+			esc_html__('State', 'event_espresso'),
1090
+			'deleted',
1091
+			['action' => 'country_settings']
1092
+		);
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * @return void
1098
+	 * @throws EE_Error
1099
+	 * @throws InvalidArgumentException
1100
+	 * @throws InvalidDataTypeException
1101
+	 * @throws InvalidInterfaceException
1102
+	 * @throws ReflectionException
1103
+	 */
1104
+	protected function _update_country_settings()
1105
+	{
1106
+		$CNT_ISO = $this->getCountryISO();
1107
+		if (! $CNT_ISO) {
1108
+			EE_Error::add_error(
1109
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1110
+				__FILE__,
1111
+				__FUNCTION__,
1112
+				__LINE__
1113
+			);
1114
+			return;
1115
+		}
1116
+
1117
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1118
+
1119
+		$cols_n_values                    = [];
1120
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1121
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1122
+		);
1123
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1124
+			"cntry[$CNT_ISO][CNT_name]",
1125
+			$country->name()
1126
+		);
1127
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1128
+			$this->request->getRequestParam(
1129
+				"cntry[$CNT_ISO][CNT_cur_code]",
1130
+				$country->currency_code()
1131
+			)
1132
+		);
1133
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1134
+			"cntry[$CNT_ISO][CNT_cur_single]",
1135
+			$country->currency_name_single()
1136
+		);
1137
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1138
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1139
+			$country->currency_name_plural()
1140
+		);
1141
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1142
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1143
+			$country->currency_sign()
1144
+		);
1145
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1146
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1147
+			$country->currency_sign_before(),
1148
+			DataType::BOOL
1149
+		);
1150
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1151
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1152
+			$country->currency_decimal_places()
1153
+		);
1154
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1155
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1156
+			$country->currency_decimal_mark()
1157
+		);
1158
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1159
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1160
+			$country->currency_thousands_separator()
1161
+		);
1162
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1163
+			"cntry[$CNT_ISO][CNT_tel_code]",
1164
+			$country->telephoneCode()
1165
+		);
1166
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1167
+			"cntry[$CNT_ISO][CNT_active]",
1168
+			$country->isActive(),
1169
+			DataType::BOOL
1170
+		);
1171
+
1172
+		// allow filtering of country data
1173
+		$cols_n_values = apply_filters(
1174
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1175
+			$cols_n_values
1176
+		);
1177
+
1178
+		// where values
1179
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1180
+		// run the update
1181
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1182
+
1183
+		// allow filtering of states data
1184
+		$states = apply_filters(
1185
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1186
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1187
+		);
1188
+
1189
+		if (! empty($states) && $success !== false) {
1190
+			// loop thru state data ( looks like : states[75][STA_name] )
1191
+			foreach ($states as $STA_ID => $state) {
1192
+				$cols_n_values = [
1193
+					'CNT_ISO'    => $CNT_ISO,
1194
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1195
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1196
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1197
+				];
1198
+				// where values
1199
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1200
+				// run the update
1201
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1202
+				if ($success !== false) {
1203
+					do_action(
1204
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1205
+						$CNT_ISO,
1206
+						$STA_ID,
1207
+						$cols_n_values
1208
+					);
1209
+				}
1210
+			}
1211
+		}
1212
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1213
+		if (
1214
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1215
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1216
+		) {
1217
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1218
+			EE_Registry::instance()->CFG->update_espresso_config();
1219
+		}
1220
+
1221
+		if ($success !== false) {
1222
+			EE_Error::add_success(
1223
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1224
+			);
1225
+		}
1226
+		$this->_redirect_after_action(
1227
+			$success,
1228
+			'',
1229
+			'',
1230
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1231
+			true
1232
+		);
1233
+	}
1234
+
1235
+
1236
+	/**
1237
+	 * form_form_field_label_wrap
1238
+	 *
1239
+	 * @param string $label
1240
+	 * @return string
1241
+	 */
1242
+	public function country_form_field_label_wrap(string $label): string
1243
+	{
1244
+		return '
1245 1245
 			<tr>
1246 1246
 				<th>
1247 1247
 					' . $label . '
1248 1248
 				</th>';
1249
-    }
1250
-
1251
-
1252
-    /**
1253
-     * form_form_field_input__wrap
1254
-     *
1255
-     * @param string $input
1256
-     * @return string
1257
-     */
1258
-    public function country_form_field_input__wrap(string $input): string
1259
-    {
1260
-        return '
1249
+	}
1250
+
1251
+
1252
+	/**
1253
+	 * form_form_field_input__wrap
1254
+	 *
1255
+	 * @param string $input
1256
+	 * @return string
1257
+	 */
1258
+	public function country_form_field_input__wrap(string $input): string
1259
+	{
1260
+		return '
1261 1261
 				<td class="general-settings-country-input-td">
1262 1262
 					' . $input . '
1263 1263
 				</td>
1264 1264
 			</tr>';
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * form_form_field_label_wrap
1270
-     *
1271
-     * @param string $label
1272
-     * @param string $required_text
1273
-     * @return string
1274
-     */
1275
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1276
-    {
1277
-        return $required_text;
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * form_form_field_input__wrap
1283
-     *
1284
-     * @param string $input
1285
-     * @return string
1286
-     */
1287
-    public function state_form_field_input__wrap(string $input): string
1288
-    {
1289
-        return '
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * form_form_field_label_wrap
1270
+	 *
1271
+	 * @param string $label
1272
+	 * @param string $required_text
1273
+	 * @return string
1274
+	 */
1275
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1276
+	{
1277
+		return $required_text;
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * form_form_field_input__wrap
1283
+	 *
1284
+	 * @param string $input
1285
+	 * @return string
1286
+	 */
1287
+	public function state_form_field_input__wrap(string $input): string
1288
+	{
1289
+		return '
1290 1290
 				<td class="general-settings-country-state-input-td">
1291 1291
 					' . $input . '
1292 1292
 				</td>';
1293
-    }
1294
-
1295
-
1296
-    /***********/
1297
-
1298
-
1299
-    /**
1300
-     * displays edit and view links for critical EE pages
1301
-     *
1302
-     * @param int $ee_page_id
1303
-     * @return string
1304
-     */
1305
-    public static function edit_view_links(int $ee_page_id): string
1306
-    {
1307
-        $edit_url = add_query_arg(
1308
-            ['post' => $ee_page_id, 'action' => 'edit'],
1309
-            admin_url('post.php')
1310
-        );
1311
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1312
-        $links    .= ' &nbsp;|&nbsp; ';
1313
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1314
-
1315
-        return $links;
1316
-    }
1317
-
1318
-
1319
-    /**
1320
-     * displays page and shortcode status for critical EE pages
1321
-     *
1322
-     * @param WP_Post $ee_page
1323
-     * @param string  $shortcode
1324
-     * @return string
1325
-     */
1326
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1327
-    {
1328
-        // page status
1329
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1330
-            $pg_class  = 'ee-status-bg--success';
1331
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1332
-        } else {
1333
-            $pg_class  = 'ee-status-bg--error';
1334
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1335
-        }
1336
-
1337
-        // shortcode status
1338
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1339
-            $sc_class  = 'ee-status-bg--success';
1340
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1341
-        } else {
1342
-            $sc_class  = 'ee-status-bg--error';
1343
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1344
-        }
1345
-
1346
-        return '
1293
+	}
1294
+
1295
+
1296
+	/***********/
1297
+
1298
+
1299
+	/**
1300
+	 * displays edit and view links for critical EE pages
1301
+	 *
1302
+	 * @param int $ee_page_id
1303
+	 * @return string
1304
+	 */
1305
+	public static function edit_view_links(int $ee_page_id): string
1306
+	{
1307
+		$edit_url = add_query_arg(
1308
+			['post' => $ee_page_id, 'action' => 'edit'],
1309
+			admin_url('post.php')
1310
+		);
1311
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1312
+		$links    .= ' &nbsp;|&nbsp; ';
1313
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1314
+
1315
+		return $links;
1316
+	}
1317
+
1318
+
1319
+	/**
1320
+	 * displays page and shortcode status for critical EE pages
1321
+	 *
1322
+	 * @param WP_Post $ee_page
1323
+	 * @param string  $shortcode
1324
+	 * @return string
1325
+	 */
1326
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1327
+	{
1328
+		// page status
1329
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1330
+			$pg_class  = 'ee-status-bg--success';
1331
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1332
+		} else {
1333
+			$pg_class  = 'ee-status-bg--error';
1334
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1335
+		}
1336
+
1337
+		// shortcode status
1338
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1339
+			$sc_class  = 'ee-status-bg--success';
1340
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1341
+		} else {
1342
+			$sc_class  = 'ee-status-bg--error';
1343
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1344
+		}
1345
+
1346
+		return '
1347 1347
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1348 1348
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1349
-    }
1350
-
1351
-
1352
-    /**
1353
-     * generates a dropdown of all parent pages - copied from WP core
1354
-     *
1355
-     * @param int  $default
1356
-     * @param int  $parent
1357
-     * @param int  $level
1358
-     * @param bool $echo
1359
-     * @return string;
1360
-     */
1361
-    public static function page_settings_dropdown(
1362
-        int $default = 0,
1363
-        int $parent = 0,
1364
-        int $level = 0,
1365
-        bool $echo = true
1366
-    ): string {
1367
-        global $wpdb;
1368
-        $items  = $wpdb->get_results(
1369
-            $wpdb->prepare(
1370
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1371
-                $parent
1372
-            )
1373
-        );
1374
-        $output = '';
1375
-
1376
-        if ($items) {
1377
-            $level = absint($level);
1378
-            foreach ($items as $item) {
1379
-                $ID         = absint($item->ID);
1380
-                $post_title = wp_strip_all_tags($item->post_title);
1381
-                $pad        = str_repeat('&nbsp;', $level * 3);
1382
-                $option     = "\n\t";
1383
-                $option     .= '<option class="level-' . $level . '" ';
1384
-                $option     .= 'value="' . $ID . '" ';
1385
-                $option     .= $ID === absint($default) ? ' selected' : '';
1386
-                $option     .= '>';
1387
-                $option     .= "$pad {$post_title}";
1388
-                $option     .= '</option>';
1389
-                $output     .= $option;
1390
-                ob_start();
1391
-                parent_dropdown($default, $item->ID, $level + 1);
1392
-                $output .= ob_get_clean();
1393
-            }
1394
-        }
1395
-        if ($echo) {
1396
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1397
-            return '';
1398
-        }
1399
-        return $output;
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     * Loads the scripts for the privacy settings form
1405
-     */
1406
-    public function load_scripts_styles_privacy_settings()
1407
-    {
1408
-        $form_handler = $this->loader->getShared(
1409
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1410
-        );
1411
-        $form_handler->enqueueStylesAndScripts();
1412
-    }
1413
-
1414
-
1415
-    /**
1416
-     * display the privacy settings form
1417
-     *
1418
-     * @throws EE_Error
1419
-     */
1420
-    public function privacySettings()
1421
-    {
1422
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1423
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1424
-        $form_handler                               = $this->loader->getShared(
1425
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1426
-        );
1427
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1428
-            $form_handler->display(),
1429
-            '',
1430
-            'padding'
1431
-        );
1432
-        $this->display_admin_page_with_sidebar();
1433
-    }
1434
-
1435
-
1436
-    /**
1437
-     * Update the privacy settings from form data
1438
-     *
1439
-     * @throws EE_Error
1440
-     */
1441
-    public function updatePrivacySettings()
1442
-    {
1443
-        $form_handler = $this->loader->getShared(
1444
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1445
-        );
1446
-        $success      = $form_handler->process($this->get_request_data());
1447
-        $this->_redirect_after_action(
1448
-            $success,
1449
-            esc_html__('Registration Form Options', 'event_espresso'),
1450
-            'updated',
1451
-            ['action' => 'privacy_settings']
1452
-        );
1453
-    }
1349
+	}
1350
+
1351
+
1352
+	/**
1353
+	 * generates a dropdown of all parent pages - copied from WP core
1354
+	 *
1355
+	 * @param int  $default
1356
+	 * @param int  $parent
1357
+	 * @param int  $level
1358
+	 * @param bool $echo
1359
+	 * @return string;
1360
+	 */
1361
+	public static function page_settings_dropdown(
1362
+		int $default = 0,
1363
+		int $parent = 0,
1364
+		int $level = 0,
1365
+		bool $echo = true
1366
+	): string {
1367
+		global $wpdb;
1368
+		$items  = $wpdb->get_results(
1369
+			$wpdb->prepare(
1370
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1371
+				$parent
1372
+			)
1373
+		);
1374
+		$output = '';
1375
+
1376
+		if ($items) {
1377
+			$level = absint($level);
1378
+			foreach ($items as $item) {
1379
+				$ID         = absint($item->ID);
1380
+				$post_title = wp_strip_all_tags($item->post_title);
1381
+				$pad        = str_repeat('&nbsp;', $level * 3);
1382
+				$option     = "\n\t";
1383
+				$option     .= '<option class="level-' . $level . '" ';
1384
+				$option     .= 'value="' . $ID . '" ';
1385
+				$option     .= $ID === absint($default) ? ' selected' : '';
1386
+				$option     .= '>';
1387
+				$option     .= "$pad {$post_title}";
1388
+				$option     .= '</option>';
1389
+				$output     .= $option;
1390
+				ob_start();
1391
+				parent_dropdown($default, $item->ID, $level + 1);
1392
+				$output .= ob_get_clean();
1393
+			}
1394
+		}
1395
+		if ($echo) {
1396
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1397
+			return '';
1398
+		}
1399
+		return $output;
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 * Loads the scripts for the privacy settings form
1405
+	 */
1406
+	public function load_scripts_styles_privacy_settings()
1407
+	{
1408
+		$form_handler = $this->loader->getShared(
1409
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1410
+		);
1411
+		$form_handler->enqueueStylesAndScripts();
1412
+	}
1413
+
1414
+
1415
+	/**
1416
+	 * display the privacy settings form
1417
+	 *
1418
+	 * @throws EE_Error
1419
+	 */
1420
+	public function privacySettings()
1421
+	{
1422
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1423
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1424
+		$form_handler                               = $this->loader->getShared(
1425
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1426
+		);
1427
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1428
+			$form_handler->display(),
1429
+			'',
1430
+			'padding'
1431
+		);
1432
+		$this->display_admin_page_with_sidebar();
1433
+	}
1434
+
1435
+
1436
+	/**
1437
+	 * Update the privacy settings from form data
1438
+	 *
1439
+	 * @throws EE_Error
1440
+	 */
1441
+	public function updatePrivacySettings()
1442
+	{
1443
+		$form_handler = $this->loader->getShared(
1444
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1445
+		);
1446
+		$success      = $form_handler->process($this->get_request_data());
1447
+		$this->_redirect_after_action(
1448
+			$success,
1449
+			esc_html__('Registration Form Options', 'event_espresso'),
1450
+			'updated',
1451
+			['action' => 'privacy_settings']
1452
+		);
1453
+	}
1454 1454
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/templates/espresso_page_settings.template.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
     </h2>
18 18
     <p class="ee-attention">
19 19
         <?php printf(
20
-            esc_html__(
21
-                'The following shortcodes and page settings are required for Event Espresso to function properly. These shortcodes should not be replaced with any other shortcodes. Please view %sthis page%s for a list of optional shortcodes you can use on other pages.',
22
-                'event_espresso'
23
-            ),
24
-            '<a href="admin.php?page=espresso_support">',
25
-            '</a>'
26
-        );
20
+			esc_html__(
21
+				'The following shortcodes and page settings are required for Event Espresso to function properly. These shortcodes should not be replaced with any other shortcodes. Please view %sthis page%s for a list of optional shortcodes you can use on other pages.',
22
+				'event_espresso'
23
+			),
24
+			'<a href="admin.php?page=espresso_support">',
25
+			'</a>'
26
+		);
27 27
 ?>
28 28
     </p>
29 29
 
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
                     </select>
55 55
                     <div class="ee-page-status__wrapper">
56 56
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
57
-                        $reg_page_obj,
58
-                        '[ESPRESSO_CHECKOUT]'
59
-                    ); // already escaped ?>
57
+						$reg_page_obj,
58
+						'[ESPRESSO_CHECKOUT]'
59
+					); // already escaped ?>
60 60
                     </div>
61 61
                     <br />
62 62
                     <p class="description">
63 63
                         <?php printf(
64
-                            esc_html__(
65
-                                'This page can be hidden from navigation if desired, but should always contain the %s shortcode.',
66
-                                'event_espresso'
67
-                            ),
68
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CHECKOUT]</span>'
69
-                        );
64
+							esc_html__(
65
+								'This page can be hidden from navigation if desired, but should always contain the %s shortcode.',
66
+								'event_espresso'
67
+							),
68
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CHECKOUT]</span>'
69
+						);
70 70
 ?>
71 71
                     </p>
72 72
                     <br /><br />
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
                     </select>
102 102
                     <div class='ee-page-status__wrapper'>
103 103
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
104
-                        $txn_page_obj,
105
-                        '[ESPRESSO_TXN_PAGE]'
106
-                    ); // already escaped ?>
104
+						$txn_page_obj,
105
+						'[ESPRESSO_TXN_PAGE]'
106
+					); // already escaped ?>
107 107
                     </div>
108 108
                     <br />
109 109
                     <p class="description">
110 110
                         <?php printf(
111
-                            esc_html__(
112
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
113
-                                'event_espresso'
114
-                            ),
115
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_TXN_PAGE]</span>'
116
-                        );
111
+							esc_html__(
112
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
113
+								'event_espresso'
114
+							),
115
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_TXN_PAGE]</span>'
116
+						);
117 117
 ?>
118 118
                     </p>
119 119
                     <br /><br />
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
                     </select>
145 145
                     <div class='ee-page-status__wrapper'>
146 146
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
147
-                        $thank_you_page_obj,
148
-                        '[ESPRESSO_THANK_YOU]'
149
-                    ); // already escaped ?>
147
+						$thank_you_page_obj,
148
+						'[ESPRESSO_THANK_YOU]'
149
+					); // already escaped ?>
150 150
                     </div>
151 151
                     <br />
152 152
                     <p class="description">
153 153
                         <?php printf(
154
-                            esc_html__(
155
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
156
-                                'event_espresso'
157
-                            ),
158
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_THANK_YOU]</span>'
159
-                        );
154
+							esc_html__(
155
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
156
+								'event_espresso'
157
+							),
158
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_THANK_YOU]</span>'
159
+						);
160 160
 ?>
161 161
                     </p>
162 162
                     <br /><br />
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
                     </select>
188 188
                     <div class='ee-page-status__wrapper'>
189 189
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
190
-                        $cancel_page_obj,
191
-                        '[ESPRESSO_CANCELLED]'
192
-                    ); // already escaped ?>
190
+						$cancel_page_obj,
191
+						'[ESPRESSO_CANCELLED]'
192
+					); // already escaped ?>
193 193
                     </div>
194 194
                     <br />
195 195
                     <p class="description">
196 196
                         <?php printf(
197
-                            esc_html__(
198
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain a "cancelled transaction" message and the %s shortcode.',
199
-                                'event_espresso'
200
-                            ),
201
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CANCELLED]</span>'
202
-                        );
197
+							esc_html__(
198
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain a "cancelled transaction" message and the %s shortcode.',
199
+								'event_espresso'
200
+							),
201
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CANCELLED]</span>'
202
+						);
203 203
 ?>
204 204
                     </p>
205 205
                     <br /><br />
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
                 <td>
223 223
                     <p class="description">
224 224
                         <?php esc_html_e(
225
-                            'Events are custom post types and use WordPress\' normal archive pages for displaying events.',
226
-                            'event_espresso'
227
-                        ) ?>
225
+							'Events are custom post types and use WordPress\' normal archive pages for displaying events.',
226
+							'event_espresso'
227
+						) ?>
228 228
                     </p>
229 229
                     <p class="description">
230 230
                         <?php printf(
231
-                            esc_html__(
232
-                                'If you would still like your events on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
233
-                                'event_espresso'
234
-                            ),
235
-                            '<a href="admin.php?page=espresso_support">',
236
-                            '</a>'
237
-                        ); ?>
231
+							esc_html__(
232
+								'If you would still like your events on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
233
+								'event_espresso'
234
+							),
235
+							'<a href="admin.php?page=espresso_support">',
236
+							'</a>'
237
+						); ?>
238 238
                     </p>
239 239
                     <br /><br />
240 240
                 </td>
@@ -256,19 +256,19 @@  discard block
 block discarded – undo
256 256
                 <td>
257 257
                     <p class="description">
258 258
                         <?php esc_html_e(
259
-                            'Venues are custom post types and use WordPress\' normal archive pages for displaying events.',
260
-                            'event_espresso'
261
-                        ) ?>
259
+							'Venues are custom post types and use WordPress\' normal archive pages for displaying events.',
260
+							'event_espresso'
261
+						) ?>
262 262
                     </p>
263 263
                     <p class="description">
264 264
                         <?php printf(
265
-                            esc_html__(
266
-                                'If you would still like your venues on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
267
-                                'event_espresso'
268
-                            ),
269
-                            '<a href="admin.php?page=espresso_support">',
270
-                            '</a>'
271
-                        ); ?>
265
+							esc_html__(
266
+								'If you would still like your venues on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
267
+								'event_espresso'
268
+							),
269
+							'<a href="admin.php?page=espresso_support">',
270
+							'</a>'
271
+						); ?>
272 272
                     </p>
273 273
                 </td>
274 274
             </tr>
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 1 patch
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -11,244 +11,244 @@
 block discarded – undo
11 11
  */
12 12
 class Support_Admin_Page extends EE_Admin_Page
13 13
 {
14
-    protected function _init_page_props()
15
-    {
16
-        $this->page_slug = EE_SUPPORT_PG_SLUG;
17
-        $this->page_label = esc_html__('Help & Support', 'event_espresso');
18
-        $this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
-        $this->_admin_base_path = EE_SUPPORT_ADMIN;
20
-    }
21
-
22
-
23
-    protected function _ajax_hooks()
24
-    {
25
-    }
26
-
27
-
28
-    protected function _define_page_props()
29
-    {
30
-        $this->_labels = array();
31
-        $this->_admin_page_title = $this->page_label;
32
-    }
33
-
34
-
35
-    protected function _set_page_routes()
36
-    {
37
-        $this->_page_routes = array(
38
-            'default'    => array(
39
-                'func'       => '_contact_support',
40
-                'capability' => 'ee_read_ee',
41
-            ),
42
-            'developers' => array(
43
-                'func'       => '_developers',
44
-                'capability' => 'ee_read_ee',
45
-            ),
46
-            'shortcodes' => array(
47
-                'func'       => '_shortcodes',
48
-                'capability' => 'ee_read_ee',
49
-            ),
50
-        );
51
-    }
52
-
53
-
54
-    protected function _set_page_config()
55
-    {
56
-        $this->_page_config = array(
57
-            'default'    => array(
58
-                'nav'           => array(
59
-                    'label' => esc_html__('Support', 'event_espresso'),
60
-                    'icon' => 'dashicons-sos',
61
-                    'order' => 30,
62
-                ),
63
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
-                'require_nonce' => false,
65
-            ),
66
-            'developers' => array(
67
-                'nav'           => array(
68
-                    'label' => esc_html__('Developers', 'event_espresso'),
69
-                    'icon' => 'dashicons-coffee',
70
-                    'order' => 50,
71
-                ),
72
-                'metaboxes'     => $this->_default_espresso_metaboxes,
73
-                'require_nonce' => false,
74
-            ),
75
-            'shortcodes' => array(
76
-                'nav'           => array(
77
-                    'label' => esc_html__('Shortcodes', 'event_espresso'),
78
-                    'icon' => 'dashicons-shortcode',
79
-                    'order' => 60,
80
-                ),
81
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
-                'require_nonce' => false,
83
-            ),
84
-        );
85
-    }
86
-
87
-
88
-    // none of the below group are currently used for Support pages
89
-    protected function _add_screen_options()
90
-    {
91
-    }
92
-
93
-
94
-    protected function _add_feature_pointers()
95
-    {
96
-    }
97
-
98
-
99
-    public function admin_init()
100
-    {
101
-    }
102
-
103
-
104
-    public function admin_notices()
105
-    {
106
-    }
107
-
108
-
109
-    public function admin_footer_scripts()
110
-    {
111
-    }
112
-
113
-
114
-    public function load_scripts_styles()
115
-    {
116
-    }
117
-
118
-
119
-    protected function _installation()
120
-    {
121
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
-            $template_path,
124
-            '',
125
-            true
126
-        );
127
-        $this->display_admin_page_with_sidebar();
128
-    }
129
-
130
-
131
-    protected function _resources()
132
-    {
133
-        $this->display_admin_page_with_sidebar();
134
-    }
135
-
136
-
137
-    protected function _add_settings_metabox($box, $label, array $args)
138
-    {
139
-        $this->addMetaBox(
140
-            "espresso_{$box}_settings",
141
-            $label,
142
-            function ($post, $metabox) {
143
-                EEH_Template::display_template(
144
-                    $metabox['args']['template_path'],
145
-                    $metabox['args']['template_args']
146
-                );
147
-            },
148
-            $this->_current_screen->id,
149
-            'normal',
150
-            'high',
151
-            apply_filters(
152
-                "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
-                $args
154
-            )
155
-        );
156
-    }
157
-
158
-
159
-    protected function _resources_boxes()
160
-    {
161
-        $boxes = apply_filters(
162
-            'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
-            array(
164
-                'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
-                'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
-                'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
-                'partners'                  => esc_html__('Partners', 'event_espresso'),
168
-                'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
-                'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
-            )
171
-        );
172
-        foreach ($boxes as $box => $label) {
173
-            $this->_add_settings_metabox(
174
-                $box,
175
-                $label,
176
-                array(
177
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
-                    'template_args' => $this->_template_args,
179
-                )
180
-            );
181
-        }
182
-    }
183
-
184
-
185
-    protected function _shortcodes()
186
-    {
187
-        $this->display_admin_page_with_sidebar();
188
-    }
189
-
190
-
191
-    protected function _shortcodes_boxes()
192
-    {
193
-        $boxes = apply_filters(
194
-            'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
-            array(
196
-                'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
-                'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
-                'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
-                'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
-                /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
-                /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
-            )
203
-        );
204
-        foreach ($boxes as $box => $label) {
205
-            $this->_add_settings_metabox(
206
-                $box,
207
-                $label,
208
-                array(
209
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
-                    'template_args' => $this->_template_args,
211
-                )
212
-            );
213
-        }
214
-    }
215
-
216
-
217
-    protected function _contact_support()
218
-    {
219
-        $this->display_admin_page_with_sidebar();
220
-    }
221
-
222
-
223
-    protected function _support_boxes()
224
-    {
225
-        $boxes = apply_filters(
226
-            'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
-            array(
228
-                'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
-                'important_information' => esc_html__('Important Information', 'event_espresso'),
230
-            )
231
-        );
232
-        foreach ($boxes as $box => $label) {
233
-            $this->_add_settings_metabox(
234
-                $box,
235
-                $label,
236
-                array(
237
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
-                    'template_args' => $this->_template_args,
239
-                )
240
-            );
241
-        }
242
-    }
243
-
244
-
245
-    protected function _developers()
246
-    {
247
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
-            array(),
250
-            true
251
-        );
252
-        $this->display_admin_page_with_sidebar();
253
-    }
14
+	protected function _init_page_props()
15
+	{
16
+		$this->page_slug = EE_SUPPORT_PG_SLUG;
17
+		$this->page_label = esc_html__('Help & Support', 'event_espresso');
18
+		$this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
+		$this->_admin_base_path = EE_SUPPORT_ADMIN;
20
+	}
21
+
22
+
23
+	protected function _ajax_hooks()
24
+	{
25
+	}
26
+
27
+
28
+	protected function _define_page_props()
29
+	{
30
+		$this->_labels = array();
31
+		$this->_admin_page_title = $this->page_label;
32
+	}
33
+
34
+
35
+	protected function _set_page_routes()
36
+	{
37
+		$this->_page_routes = array(
38
+			'default'    => array(
39
+				'func'       => '_contact_support',
40
+				'capability' => 'ee_read_ee',
41
+			),
42
+			'developers' => array(
43
+				'func'       => '_developers',
44
+				'capability' => 'ee_read_ee',
45
+			),
46
+			'shortcodes' => array(
47
+				'func'       => '_shortcodes',
48
+				'capability' => 'ee_read_ee',
49
+			),
50
+		);
51
+	}
52
+
53
+
54
+	protected function _set_page_config()
55
+	{
56
+		$this->_page_config = array(
57
+			'default'    => array(
58
+				'nav'           => array(
59
+					'label' => esc_html__('Support', 'event_espresso'),
60
+					'icon' => 'dashicons-sos',
61
+					'order' => 30,
62
+				),
63
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
+				'require_nonce' => false,
65
+			),
66
+			'developers' => array(
67
+				'nav'           => array(
68
+					'label' => esc_html__('Developers', 'event_espresso'),
69
+					'icon' => 'dashicons-coffee',
70
+					'order' => 50,
71
+				),
72
+				'metaboxes'     => $this->_default_espresso_metaboxes,
73
+				'require_nonce' => false,
74
+			),
75
+			'shortcodes' => array(
76
+				'nav'           => array(
77
+					'label' => esc_html__('Shortcodes', 'event_espresso'),
78
+					'icon' => 'dashicons-shortcode',
79
+					'order' => 60,
80
+				),
81
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
+				'require_nonce' => false,
83
+			),
84
+		);
85
+	}
86
+
87
+
88
+	// none of the below group are currently used for Support pages
89
+	protected function _add_screen_options()
90
+	{
91
+	}
92
+
93
+
94
+	protected function _add_feature_pointers()
95
+	{
96
+	}
97
+
98
+
99
+	public function admin_init()
100
+	{
101
+	}
102
+
103
+
104
+	public function admin_notices()
105
+	{
106
+	}
107
+
108
+
109
+	public function admin_footer_scripts()
110
+	{
111
+	}
112
+
113
+
114
+	public function load_scripts_styles()
115
+	{
116
+	}
117
+
118
+
119
+	protected function _installation()
120
+	{
121
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
+			$template_path,
124
+			'',
125
+			true
126
+		);
127
+		$this->display_admin_page_with_sidebar();
128
+	}
129
+
130
+
131
+	protected function _resources()
132
+	{
133
+		$this->display_admin_page_with_sidebar();
134
+	}
135
+
136
+
137
+	protected function _add_settings_metabox($box, $label, array $args)
138
+	{
139
+		$this->addMetaBox(
140
+			"espresso_{$box}_settings",
141
+			$label,
142
+			function ($post, $metabox) {
143
+				EEH_Template::display_template(
144
+					$metabox['args']['template_path'],
145
+					$metabox['args']['template_args']
146
+				);
147
+			},
148
+			$this->_current_screen->id,
149
+			'normal',
150
+			'high',
151
+			apply_filters(
152
+				"FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
+				$args
154
+			)
155
+		);
156
+	}
157
+
158
+
159
+	protected function _resources_boxes()
160
+	{
161
+		$boxes = apply_filters(
162
+			'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
+			array(
164
+				'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
+				'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
+				'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
+				'partners'                  => esc_html__('Partners', 'event_espresso'),
168
+				'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
+				'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
+			)
171
+		);
172
+		foreach ($boxes as $box => $label) {
173
+			$this->_add_settings_metabox(
174
+				$box,
175
+				$label,
176
+				array(
177
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
+					'template_args' => $this->_template_args,
179
+				)
180
+			);
181
+		}
182
+	}
183
+
184
+
185
+	protected function _shortcodes()
186
+	{
187
+		$this->display_admin_page_with_sidebar();
188
+	}
189
+
190
+
191
+	protected function _shortcodes_boxes()
192
+	{
193
+		$boxes = apply_filters(
194
+			'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
+			array(
196
+				'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
+				'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
+				'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
+				'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
+				/*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
+				/*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
+			)
203
+		);
204
+		foreach ($boxes as $box => $label) {
205
+			$this->_add_settings_metabox(
206
+				$box,
207
+				$label,
208
+				array(
209
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
+					'template_args' => $this->_template_args,
211
+				)
212
+			);
213
+		}
214
+	}
215
+
216
+
217
+	protected function _contact_support()
218
+	{
219
+		$this->display_admin_page_with_sidebar();
220
+	}
221
+
222
+
223
+	protected function _support_boxes()
224
+	{
225
+		$boxes = apply_filters(
226
+			'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
+			array(
228
+				'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
+				'important_information' => esc_html__('Important Information', 'event_espresso'),
230
+			)
231
+		);
232
+		foreach ($boxes as $box => $label) {
233
+			$this->_add_settings_metabox(
234
+				$box,
235
+				$label,
236
+				array(
237
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
+					'template_args' => $this->_template_args,
239
+				)
240
+			);
241
+		}
242
+	}
243
+
244
+
245
+	protected function _developers()
246
+	{
247
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
+			EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
+			array(),
250
+			true
251
+		);
252
+		$this->display_admin_page_with_sidebar();
253
+	}
254 254
 }
Please login to merge, or discard this patch.